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

version 1.2018.5

This commit is contained in:
Arnaud Roques 2018-05-06 21:59:19 +02:00
parent cfacbc1f97
commit 14e1e6671c
41 changed files with 594 additions and 138 deletions

View File

@ -30,13 +30,12 @@
Script Author: Julien Eluard
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.sourceforge.plantuml</groupId>
<artifactId>plantuml</artifactId>
<version>1.2018.4-SNAPSHOT</version>
<version>1.2018.6-SNAPSHOT</version>
<packaging>jar</packaging>
<name>PlantUML</name>

View File

@ -99,9 +99,9 @@ public abstract class AbstractPSystem implements Diagram {
public DisplayPositionned getTitle() {
if (source == null) {
return new DisplayPositionned(Display.empty(), HorizontalAlignment.CENTER, VerticalAlignment.TOP);
return DisplayPositionned.single(Display.empty(), HorizontalAlignment.CENTER, VerticalAlignment.TOP);
}
return new DisplayPositionned(source.getTitle(), HorizontalAlignment.CENTER, VerticalAlignment.TOP);
return DisplayPositionned.single(source.getTitle(), HorizontalAlignment.CENTER, VerticalAlignment.TOP);
}
public String getWarningOrError() {

View File

@ -36,6 +36,7 @@
package net.sourceforge.plantuml;
import net.sourceforge.plantuml.cucadiagram.DisplayPositionned;
import net.sourceforge.plantuml.cucadiagram.DisplaySection;
public interface Annotated {
@ -45,8 +46,8 @@ public interface Annotated {
public DisplayPositionned getLegend();
public DisplayPositionned getHeader();
public DisplaySection getHeader();
public DisplayPositionned getFooter();
public DisplaySection getFooter();
}

View File

@ -37,6 +37,7 @@ package net.sourceforge.plantuml;
import net.sourceforge.plantuml.activitydiagram3.ftile.EntityImageLegend;
import net.sourceforge.plantuml.cucadiagram.DisplayPositionned;
import net.sourceforge.plantuml.cucadiagram.DisplaySection;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.TextBlock;
@ -65,7 +66,7 @@ public class AnnotatedWorker {
private TextBlock addLegend(TextBlock original) {
final DisplayPositionned legend = annotated.getLegend();
if (DisplayPositionned.isNull(legend)) {
if (legend.isNull()) {
return original;
}
final TextBlock text = EntityImageLegend.create(legend.getDisplay(), getSkinParam());
@ -79,7 +80,7 @@ public class AnnotatedWorker {
private TextBlock addCaption(TextBlock original) {
final DisplayPositionned caption = annotated.getCaption();
if (DisplayPositionned.isNull(caption)) {
if (caption.isNull()) {
return original;
}
final TextBlock text = getCaption();
@ -89,7 +90,7 @@ public class AnnotatedWorker {
public TextBlock getCaption() {
final DisplayPositionned caption = annotated.getCaption();
if (DisplayPositionned.isNull(caption)) {
if (caption.isNull()) {
return TextBlockUtils.empty(0, 0);
}
return caption.getDisplay().create(new FontConfiguration(getSkinParam(), FontParam.CAPTION, null),
@ -98,7 +99,7 @@ public class AnnotatedWorker {
private TextBlock addTitle(TextBlock original) {
final DisplayPositionned title = annotated.getTitle();
if (DisplayPositionned.isNull(title)) {
if (title.isNull()) {
return original;
}
ISkinParam skinParam = getSkinParam();
@ -109,20 +110,18 @@ public class AnnotatedWorker {
}
private TextBlock addHeaderAndFooter(TextBlock original) {
final DisplayPositionned footer = annotated.getFooter();
final DisplayPositionned header = annotated.getHeader();
if (DisplayPositionned.isNull(footer) && DisplayPositionned.isNull(header)) {
final DisplaySection footer = annotated.getFooter();
final DisplaySection header = annotated.getHeader();
if (footer.isNull() && header.isNull()) {
return original;
}
TextBlock textFooter = null;
if (DisplayPositionned.isNull(footer) == false) {
textFooter = footer.getDisplay().create(new FontConfiguration(getSkinParam(), FontParam.FOOTER, null),
footer.getHorizontalAlignment(), getSkinParam());
if (footer.isNull() == false) {
textFooter = footer.createRibbon(new FontConfiguration(getSkinParam(), FontParam.FOOTER, null), getSkinParam());
}
TextBlock textHeader = null;
if (DisplayPositionned.isNull(header) == false) {
textHeader = header.getDisplay().create(new FontConfiguration(getSkinParam(), FontParam.HEADER, null),
header.getHorizontalAlignment(), getSkinParam());
if (header.isNull() == false) {
textHeader = header.createRibbon(new FontConfiguration(getSkinParam(), FontParam.HEADER, null), getSkinParam());
}
return DecorateEntityImage.addTopAndBottom(original, textHeader, header.getHorizontalAlignment(), textFooter,

View File

@ -60,6 +60,7 @@ import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.core.UmlSource;
import net.sourceforge.plantuml.cucadiagram.DisplayPositionned;
import net.sourceforge.plantuml.cucadiagram.DisplaySection;
import net.sourceforge.plantuml.cucadiagram.UnparsableGraphvizException;
import net.sourceforge.plantuml.flashcode.FlashCodeFactory;
import net.sourceforge.plantuml.flashcode.FlashCodeUtils;
@ -93,9 +94,9 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram, Ann
private DisplayPositionned title = DisplayPositionned.none(HorizontalAlignment.CENTER, VerticalAlignment.TOP);
private DisplayPositionned caption = DisplayPositionned.none(HorizontalAlignment.CENTER, VerticalAlignment.BOTTOM);
private DisplayPositionned header = DisplayPositionned.none(HorizontalAlignment.RIGHT, VerticalAlignment.TOP);
private DisplayPositionned footer = DisplayPositionned.none(HorizontalAlignment.CENTER, VerticalAlignment.BOTTOM);
private DisplayPositionned legend = DisplayPositionned.none(HorizontalAlignment.CENTER, VerticalAlignment.BOTTOM);
private final DisplaySection header = DisplaySection.none();
private final DisplaySection footer = DisplaySection.none();
private final Pragma pragma = new Pragma();
private Animation animation;
@ -103,7 +104,7 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram, Ann
private final SkinParam skinParam = SkinParam.create(getUmlDiagramType());
final public void setTitle(DisplayPositionned title) {
if (DisplayPositionned.isNull(title) || title.getDisplay().isWhite()) {
if (title.isNull() || title.getDisplay().isWhite()) {
return;
}
this.title = title;
@ -146,23 +147,15 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram, Ann
skinParam.setParam(StringUtils.goLowerCase(key), value);
}
public final DisplayPositionned getHeader() {
public final DisplaySection getHeader() {
return header;
}
public final void setHeader(DisplayPositionned header) {
this.header = header;
}
public final DisplayPositionned getFooter() {
public final DisplaySection getFooter() {
return footer;
}
public final void setFooter(DisplayPositionned footer) {
this.footer = footer;
}
public final DisplayPositionned getFooterOrHeaderTeoz(FontParam param) {
public final DisplaySection getFooterOrHeaderTeoz(FontParam param) {
if (param == FontParam.FOOTER) {
return getFooter();
}

View File

@ -64,6 +64,7 @@ import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.graphic.UGraphicDelegator;
import net.sourceforge.plantuml.graphic.color.ColorType;
import net.sourceforge.plantuml.skin.rose.Rose;
@ -424,5 +425,16 @@ public class Swimlanes extends AbstractTextBlock implements TextBlock {
public Swimlane getCurrentSwimlane() {
return currentSwimlane;
}
private MinMax cachedMinMax;
@Override
public MinMax getMinMax(StringBounder stringBounder) {
if (cachedMinMax == null) {
cachedMinMax = TextBlockUtils.getMinMax(this, stringBounder);
}
return cachedMinMax;
}
}

View File

@ -102,6 +102,7 @@ public class ArobaseStringCompressor implements StringCompressor {
}
private String clean(String s) {
s = s.replace("\0", "");
s = StringUtils.trin(s);
s = clean1(s);
s = s.replaceAll("@enduml[^\\n\\r]*", "");

View File

@ -0,0 +1,62 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.code;
public class AsciiEncoderHex implements URLEncoder {
public String encode(byte data[]) {
if (data == null) {
return "";
}
final StringBuilder result = new StringBuilder(data.length * 2);
for (byte b : data) {
final String val = Integer.toHexString(b & 0xFF);
if (val.length() == 1) {
result.append("0");
}
result.append(val);
}
return result.toString();
}
public byte[] decode(String s) {
final byte result[] = new byte[s.length() / 2];
for (int i = 0; i < result.length; i++) {
result[i] = (byte) Integer.parseInt(s.substring(i * 2, i * 2 + 2), 16);
}
return result;
}
}

View File

@ -43,17 +43,17 @@ public class TranscoderImpl implements Transcoder {
private final URLEncoder urlEncoder;
private final StringCompressor stringCompressor;
private TranscoderImpl() {
this(new AsciiEncoder(), new StringCompressorNone(), new CompressionHuffman());
}
private TranscoderImpl(Compression compression) {
this(new AsciiEncoder(), new StringCompressorNone(), compression);
}
public TranscoderImpl(URLEncoder urlEncoder, Compression compression) {
this(urlEncoder, new ArobaseStringCompressor(), compression);
}
// private TranscoderImpl() {
// this(new AsciiEncoder(), new StringCompressorNone(), new CompressionHuffman());
// }
//
// private TranscoderImpl(Compression compression) {
// this(new AsciiEncoder(), new StringCompressorNone(), compression);
// }
//
// private TranscoderImpl(URLEncoder urlEncoder, Compression compression) {
// this(urlEncoder, new ArobaseStringCompressor(), compression);
// }
public TranscoderImpl(URLEncoder urlEncoder, StringCompressor stringCompressor, Compression compression) {
this.compression = compression;

View File

@ -39,17 +39,59 @@ import java.io.IOException;
public class TranscoderSmart implements Transcoder {
private final Transcoder oldOne = new TranscoderImpl(new AsciiEncoder(), new CompressionHuffman());
private final Transcoder zlibBase64 = new TranscoderImpl(new AsciiEncoderBase64(), new CompressionZlib());
private final Transcoder zlib = new TranscoderImpl(new AsciiEncoder(), new CompressionZlib());
private final Transcoder brotliBase64 = new TranscoderImpl(new AsciiEncoderBase64(), new CompressionBrotli());
// Legacy encoder
private final Transcoder oldOne = new TranscoderImpl(new AsciiEncoder(), new ArobaseStringCompressor(),
new CompressionHuffman());
private final Transcoder zlib = new TranscoderImpl(new AsciiEncoder(), new ArobaseStringCompressor(),
new CompressionZlib());
private final Transcoder brotli = new TranscoderImpl(new AsciiEncoder(), new ArobaseStringCompressor(),
new CompressionBrotli());
private final Transcoder zlibBase64 = new TranscoderImpl(new AsciiEncoderBase64(), new ArobaseStringCompressor(),
new CompressionZlib());
private final Transcoder brotliBase64 = new TranscoderImpl(new AsciiEncoderBase64(), new ArobaseStringCompressor(),
new CompressionBrotli());
private final Transcoder base64only = new TranscoderImpl(new AsciiEncoderBase64(), new ArobaseStringCompressor(),
new CompressionNone());
private final Transcoder hexOnly = new TranscoderImpl(new AsciiEncoderHex(), new ArobaseStringCompressor(),
new CompressionNone());
public String decode(String code) throws IOException {
if (code.startsWith("0")) {
return zlibBase64.decode(code.substring(1));
// Work in progress
// See https://github.com/plantuml/plantuml/issues/117
// Two char headers
if (code.startsWith("0A")) {
return zlibBase64.decode(code.substring(2));
}
if (code.startsWith("1")) {
return brotliBase64.decode(code.substring(1));
if (code.startsWith("0B")) {
return brotliBase64.decode(code.substring(2));
}
if (code.startsWith("0C")) {
return base64only.decode(code.substring(2));
}
if (code.startsWith("0D")) {
return hexOnly.decode(code.substring(2));
}
// Text prefix
// Just a wild try: use them only for testing
if (code.startsWith("-zlib-")) {
return zlibBase64.decode(code.substring("-zlib-".length()));
}
if (code.startsWith("-brotli-")) {
return brotliBase64.decode(code.substring("-brotli-".length()));
}
if (code.startsWith("-base64-")) {
return base64only.decode(code.substring("-base64-".length()));
}
if (code.startsWith("-hex-")) {
return hexOnly.decode(code.substring("-hex-".length()));
}
// Legacy decoding : you should not use it any more.
if (code.startsWith("0")) {
return brotli.decode(code.substring(1));
}
try {
return zlib.decode(code);
@ -60,6 +102,8 @@ public class TranscoderSmart implements Transcoder {
}
public String encode(String text) throws IOException {
// Right now, we still use the legacy encoding.
// This will be changed in the incoming months
return zlib.encode(text);
}
}

View File

@ -51,7 +51,7 @@ public class CommandCaption extends SingleLineCommand<UmlDiagram> {
@Override
protected CommandExecutionResult executeArg(UmlDiagram diagram, List<String> arg) {
diagram.setCaption(new DisplayPositionned(Display.getWithNewlines(arg.get(0)), HorizontalAlignment.CENTER,
diagram.setCaption(DisplayPositionned.single(Display.getWithNewlines(arg.get(0)), HorizontalAlignment.CENTER,
VerticalAlignment.BOTTOM));
return CommandExecutionResult.ok();
}

View File

@ -39,7 +39,7 @@ import java.util.List;
import net.sourceforge.plantuml.UmlDiagram;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.DisplayPositionned;
import net.sourceforge.plantuml.cucadiagram.DisplaySection;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.VerticalAlignment;
@ -52,8 +52,8 @@ public class CommandFooter extends SingleLineCommand<UmlDiagram> {
@Override
protected CommandExecutionResult executeArg(UmlDiagram diagram, List<String> arg) {
final String align = arg.get(0);
diagram.setFooter(new DisplayPositionned(Display.getWithNewlines(arg.get(1)), HorizontalAlignment.fromString(
align, HorizontalAlignment.CENTER), VerticalAlignment.BOTTOM));
diagram.getFooter().put(Display.getWithNewlines(arg.get(1)),
HorizontalAlignment.fromString(align, HorizontalAlignment.CENTER));
return CommandExecutionResult.ok();
}
}

View File

@ -39,9 +39,7 @@ import java.util.List;
import net.sourceforge.plantuml.UmlDiagram;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.DisplayPositionned;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.VerticalAlignment;
public class CommandHeader extends SingleLineCommand<UmlDiagram> {
@ -52,8 +50,8 @@ public class CommandHeader extends SingleLineCommand<UmlDiagram> {
@Override
protected CommandExecutionResult executeArg(UmlDiagram diagram, List<String> arg) {
final String align = arg.get(0);
diagram.setHeader(new DisplayPositionned(Display.getWithNewlines(arg.get(1)), HorizontalAlignment.fromString(
align, HorizontalAlignment.RIGHT), VerticalAlignment.TOP));
diagram.getHeader().put(Display.getWithNewlines(arg.get(1)),
HorizontalAlignment.fromString(align, HorizontalAlignment.RIGHT));
return CommandExecutionResult.ok();
}
}

View File

@ -39,9 +39,7 @@ import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.UmlDiagram;
import net.sourceforge.plantuml.command.regex.Matcher2;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.DisplayPositionned;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.VerticalAlignment;
public class CommandMultilinesFooter extends CommandMultilines<UmlDiagram> {
@ -64,8 +62,7 @@ public class CommandMultilinesFooter extends CommandMultilines<UmlDiagram> {
lines = lines.subExtract(1, 1);
final Display strings = lines.toDisplay();
if (strings.size() > 0) {
diagram.setFooter(new DisplayPositionned(strings, HorizontalAlignment.fromString(align,
HorizontalAlignment.CENTER), VerticalAlignment.BOTTOM));
diagram.getFooter().put(strings, HorizontalAlignment.fromString(align, HorizontalAlignment.CENTER));
return CommandExecutionResult.ok();
}
return CommandExecutionResult.error("Empty footer");

View File

@ -39,9 +39,7 @@ import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.UmlDiagram;
import net.sourceforge.plantuml.command.regex.Matcher2;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.DisplayPositionned;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.VerticalAlignment;
public class CommandMultilinesHeader extends CommandMultilines<UmlDiagram> {
@ -64,8 +62,7 @@ public class CommandMultilinesHeader extends CommandMultilines<UmlDiagram> {
lines = lines.subExtract(1, 1);
final Display strings = lines.toDisplay();
if (strings.size() > 0) {
diagram.setHeader(new DisplayPositionned(strings, HorizontalAlignment.fromString(align,
HorizontalAlignment.RIGHT), VerticalAlignment.TOP));
diagram.getHeader().put(strings, HorizontalAlignment.fromString(align, HorizontalAlignment.RIGHT));
return CommandExecutionResult.ok();
}
return CommandExecutionResult.error("Empty header");

View File

@ -79,7 +79,7 @@ public class CommandMultilinesLegend extends CommandMultilines2<UmlDiagram> {
if (alignment == null) {
alignment = HorizontalAlignment.CENTER;
}
diagram.setLegend(new DisplayPositionned(strings, alignment, valignment));
diagram.setLegend(DisplayPositionned.single(strings, alignment, valignment));
return CommandExecutionResult.ok();
}
return CommandExecutionResult.error("No legend defined");

View File

@ -57,7 +57,7 @@ public class CommandMultilinesTitle extends CommandMultilines<UmlDiagram> {
lines = lines.removeEmptyColumns();
final Display strings = lines.toDisplay();
if (strings.size() > 0) {
diagram.setTitle(new DisplayPositionned(strings, HorizontalAlignment.CENTER, VerticalAlignment.TOP));
diagram.setTitle(DisplayPositionned.single(strings, HorizontalAlignment.CENTER, VerticalAlignment.TOP));
return CommandExecutionResult.ok();
}
return CommandExecutionResult.error("No title defined");

View File

@ -51,9 +51,8 @@ public class CommandTitle extends SingleLineCommand<UmlDiagram> {
@Override
protected CommandExecutionResult executeArg(UmlDiagram diagram, List<String> arg) {
diagram.setTitle(new DisplayPositionned(Display.getWithNewlines(arg.get(0)), HorizontalAlignment.CENTER,
diagram.setTitle(DisplayPositionned.single(Display.getWithNewlines(arg.get(0)), HorizontalAlignment.CENTER,
VerticalAlignment.TOP));
return CommandExecutionResult.ok();
}
}

View File

@ -44,13 +44,18 @@ public class DisplayPositionned {
private final HorizontalAlignment horizontalAlignment;
private final VerticalAlignment verticalAlignment;
public DisplayPositionned(Display display, HorizontalAlignment horizontalAlignment,
private DisplayPositionned(Display display, HorizontalAlignment horizontalAlignment,
VerticalAlignment verticalAlignment) {
this.display = display;
this.horizontalAlignment = horizontalAlignment;
this.verticalAlignment = verticalAlignment;
}
public static DisplayPositionned single(Display display, HorizontalAlignment horizontalAlignment,
VerticalAlignment verticalAlignment) {
return new DisplayPositionned(display, horizontalAlignment, verticalAlignment);
}
public static DisplayPositionned none(HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment) {
return new DisplayPositionned(Display.NULL, horizontalAlignment, verticalAlignment);
}
@ -67,8 +72,8 @@ public class DisplayPositionned {
return verticalAlignment;
}
public static boolean isNull(DisplayPositionned data) {
return data == null || Display.isNull(data.display);
public boolean isNull() {
return Display.isNull(display);
}
public boolean hasUrl() {

View File

@ -0,0 +1,105 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.cucadiagram;
import java.util.EnumMap;
import java.util.Map;
import net.sourceforge.plantuml.ISkinSimple;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.TextBlock;
public class DisplaySection {
// private final Display display;
// private final HorizontalAlignment horizontalAlignment;
private final Map<HorizontalAlignment, Display> map = new EnumMap<HorizontalAlignment, Display>(
HorizontalAlignment.class);
private DisplaySection() {
}
public DisplaySection withPage(int page, int lastpage) {
final DisplaySection result = new DisplaySection();
for (Map.Entry<HorizontalAlignment, Display> ent : this.map.entrySet()) {
result.map.put(ent.getKey(), ent.getValue().withPage(page, lastpage));
}
return result;
}
// public static DisplaySection single(Display display, HorizontalAlignment horizontalAlignment) {
// return new DisplaySection(display, horizontalAlignment);
// }
public static DisplaySection none() {
return new DisplaySection();
// return new DisplaySection(Display.NULL, horizontalAlignment);
}
public final HorizontalAlignment getHorizontalAlignment() {
if (map.size() == 0) {
return HorizontalAlignment.CENTER;
}
return map.keySet().iterator().next();
}
public boolean isNull() {
if (map.size() == 0) {
return true;
}
final Display display = map.values().iterator().next();
return Display.isNull(display);
}
public TextBlock createRibbon(FontConfiguration fontConfiguration, ISkinSimple spriteContainer) {
if (map.size() == 0) {
return null;
}
final Display display = map.values().iterator().next();
if (Display.isNull(display) || display.size() == 0) {
return null;
}
return display.create(fontConfiguration, getHorizontalAlignment(), spriteContainer);
}
public void put(Display display, HorizontalAlignment horizontalAlignment) {
this.map.put(horizontalAlignment, display);
}
}

View File

@ -48,6 +48,7 @@ import net.sourceforge.plantuml.BackSlash;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.code.AsciiEncoder;
import net.sourceforge.plantuml.code.CompressionBrotli;
import net.sourceforge.plantuml.code.StringCompressorNone;
import net.sourceforge.plantuml.code.Transcoder;
import net.sourceforge.plantuml.code.TranscoderImpl;
import net.sourceforge.plantuml.core.DiagramDescription;
@ -66,19 +67,19 @@ import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.version.PSystemVersion;
public class PSystemDonors extends AbstractPSystem {
public static final String DONORS = "6mK70AmER5DRWVz05mqtRsdC3wE5OakdUGahTcCbkRKA_62GTnixOmk2vuhY2Yf0NeWrj-s_RbXK54A7"
+ "AlohojhVCdtjt3gOud9H7GSveQY5J2TYN0IjrbiiTJefoOCyfvl_omKs9aZlhB4fyl0ue1ip6cFXn6XC"
+ "-pyg6_HVT0LQmDEeR5bKvfRu4AdqPTSkbKjo1YU8B2kSajPYAeRT8iNTDePvtR93aA_5wuWySVFh6_MY"
+ "kzbSpLA99n5nZf93r-stzNsdjn-GB838njZek661A2HFUi7OSd2XSWW0oAx9C3QiM7bYG0iVT88_lYWB"
+ "XRTKOqq7Yihf1H6u_I4AIFgZl1Oncru656ePBUgMDDNnyIMbD9liANzj6exHDqwMc06e2UG_w8dktbPT"
+ "8ZtZPK0azGt9jsm2ZIJt6jzXeazK7uYJKG3MGpDbF3-ghQMiMbt7-CsZ8TmjbMks6__6AoV47FyUahAu"
+ "j82y0HqQ2x3a7-XOB7I7TBMo2_Vgd5gyGmG4fqo3XTwcs6l-7xj8CLJ8RcHX3lrql1aDs59NITuWVcg5"
+ "-AnpWgGiBJuFVPusFfDO4yAuzoNiczKi5Vz_xcLcK8AWZM6eg8i9q9mvjAfDYYW2ju3-ZN1JbxpehhTh"
+ "EzvU3yLhX2xelPDCdBjDZ_PFnGsaQocarK7fT9a9O6coOZQLonO9Ojg1JgFACwuimhxTPLc-R2nvBEma"
+ "pHgDeMZJtPKdARU7Udet3AdtPlzkxIMj2LoWe31vYHgho6P7z-wuQ5xFOB2xqWCFfCyuvxwNNqhf5e0Y"
+ "osDDbuNY6U47VnwwzCVzMTJ6ukSR_v1NqUDNyfZIMoZlbdX_KvGLFQUaNO38ShqAaSYu2QwF9djgiKpb"
+ "i8BiMDcY2u-nOR1V2jp20sxhaK5hDgLLlQ-kGn7y45_qeFBQH69sj3iupZ0U1KR7l2DvR8lNaCnUGF4S"
+ "9dXA9w0nKjAHlXR9o7ijqMsTVloqneNQDhubtEDGUCT4inuRU4u15EoX6m00";
public static final String DONORS = "6rO702mEpFCVHV0StDQFZQ4KYXIQJO-ICGuxFM7I4cYu9-jpVDvE66nDSPvH5Fk0vi0crmphPDt6pjY2"
+ "uBcYk88Aa1TYgjX-ouJsTXreG_9MC8x0dygP_yi5DYP8xwonAVBmEA0r5cwBnhJ_ZygwwBzeW4wmQLIs"
+ "B2eDyYodLy4aXy6fi-EKKF9GZEahKfJronQWb8u5cMrdTOGVP9jzenQfIMis3PbP0ehBI95eFZPQsNTo"
+ "-rx62I1QVZzWAy4E9PAR732Ml16Z8zC3WjGeRiO6QjvvmeC93LHemnSbgQaj93BAm417xXueeFHdd83O"
+ "9sMKv6p3su3yBR95HOEWZkytflF7XsKfUtvfE4OUa7FG2g02o7-W6_wqDdE9SHcR0ZFaNHZ7ib78QwgN"
+ "KTuyqDTQ5mRWPV9aHk-N7stV5j8vvJh7hyu6UTMGbKTx66kySWdk-SzS2ksB1LG_WBRjEn3Z_SFvpK9t"
+ "28yfTI6LS_pE_IO2eXjBOQ4tSSbgzfztwHP3HVDepc8ySh-EjnA17LnNucxeSYr_YZedb6mQwjTBNXqw"
+ "hYBN-DNcVObUaqr3_7-jbZA3T0UjxiA6ws8493WMLkNYeel0OT2_8RSakP7Q3fD7_R1yYP_t9yczroA1"
+ "A6mws3_LP-0cDxim6xfqOXCF0AysYNQZe_0WCmYh0nq7bMTas5t_kqdFiAanQTxfre5XDuRwHxgxSZDz"
+ "CvTq2qE_B9hjkzep70NSYXFAuNUr_hOAPN89xwP5Q7oImVejp1c1z1bHzZrjoNHJ1ymiZmMlwkBltUta"
+ "pqFd_xwzMzHmTFvxjtzqVPl9p-RKKeyeQzTWsDlWiZPhuqLr0MrBvNcWEpCk0gvN9XigkOMEp72MGyoJ"
+ "95JsWuDZwC5DdQ1jFR8pDIrXRZrMoS2Mv8VKdJGgjGDFsETsU-SPeqM1_SbvErOzrBSXnTy558aXmLCg"
+ "m7s45FMmEPrCDywsjBkJxtfhymN3DQfnuKw3meybchJSOF4fm8oT_80qdff8j97NSIPA0B_Zz1lq3DdF" + "hgxRk8wMLW00";
@Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
@ -127,7 +128,7 @@ public class PSystemDonors extends AbstractPSystem {
private List<String> getDonors() throws IOException {
final List<String> lines = new ArrayList<String>();
final Transcoder t = new TranscoderImpl(new AsciiEncoder(), new CompressionBrotli());
final Transcoder t = new TranscoderImpl(new AsciiEncoder(), new StringCompressorNone(), new CompressionBrotli());
final String s = t.decode(DONORS).replace('*', '.');
final StringTokenizer st = new StringTokenizer(s, BackSlash.NEWLINE);
while (st.hasMoreTokens()) {

View File

@ -56,6 +56,7 @@ class USymbolFrame extends USymbol {
private void drawFrame(UGraphic ug, double width, double height, Dimension2D dimTitle, boolean shadowing,
double roundCorner) {
final URectangle shape = new URectangle(width, height, roundCorner, roundCorner);
shape.setIgnoreForCompression(true);
if (shadowing) {
shape.setDeltaShadow(3.0);
}

View File

@ -89,6 +89,44 @@ public class PngIO {
}
}
// /** writes a BufferedImage of type TYPE_INT_ARGB to PNG using PNGJ */
// public static void writeARGB(BufferedImage bi, OutputStream os, String metadata) {
// // if (bi.getType() != BufferedImage.TYPE_INT_ARGB)
// // throw new PngjException("This method expects BufferedImage.TYPE_INT_ARGB");
// ImageInfo imi = new ImageInfo(bi.getWidth(), bi.getHeight(), 8, false);
// PngChunkTEXT chunkText = new PngChunkTEXT(imi, "copyleft", copyleft);
// // PngChunkTEXT chunkTextDebug = new PngChunkTEXT(imi, "debug", "debugData");
// PngChunkITXT meta = new PngChunkITXT(imi);
// meta.setKeyVal("plantuml", metadata);
// meta.setCompressed(true);
//
// PngWriter pngw = new PngWriter(os, imi);
// pngw.setCompLevel(9);// maximum compression, not critical usually
// // pngw.setFilterType(FilterType.FILTER_ADAPTIVE_FAST); // see what you prefer here
// // pngw.setFilterType(FilterType.FILTER_ADAPTIVE_MEDIUM); // see what you prefer here
// pngw.setFilterType(FilterType.FILTER_ADAPTIVE_FULL); // see what you prefer here
// pngw.queueChunk(chunkText);
// // // pngw.queueChunk(chunkTextDebug);
// pngw.queueChunk(meta);
// DataBufferInt db = ((DataBufferInt) bi.getRaster().getDataBuffer());
// SinglePixelPackedSampleModel samplemodel = (SinglePixelPackedSampleModel) bi.getSampleModel();
// if (db.getNumBanks() != 1)
// throw new PngjException("This method expects one bank");
// ImageLineInt line = new ImageLineInt(imi);
// for (int row = 0; row < imi.rows; row++) {
// int elem = samplemodel.getOffset(0, row);
// for (int col = 0, j = 0; col < imi.cols; col++) {
// int sample = db.getElem(elem++);
// line.scanline[j++] = (sample & 0xFF0000) >> 16; // R
// line.scanline[j++] = (sample & 0xFF00) >> 8; // G
// line.scanline[j++] = (sample & 0xFF); // B
// // line.scanline[j++] = (((sample & 0xFF000000) >> 24) & 0xFF); // A
// }
// pngw.writeRow(line, row);
// }
// pngw.end();
// }
public static boolean forceImageIO = false;
static boolean checkPNGMetadata() {

View File

@ -39,9 +39,8 @@ import java.awt.Font;
import java.awt.geom.Dimension2D;
import net.sourceforge.plantuml.SpriteContainerEmpty;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.DisplaySection;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
@ -51,43 +50,38 @@ public class PngTitler {
private final HtmlColor textColor;
private final HtmlColor hyperlinkColor;
private final Display text;
private final DisplaySection text;
private final int fontSize;
private final String fontFamily;
private final HorizontalAlignment horizontalAlignment;
private final boolean useUnderlineForHyperlink;
public PngTitler(HtmlColor textColor, Display text, int fontSize, String fontFamily,
HorizontalAlignment horizontalAlignment, HtmlColor hyperlinkColor, boolean useUnderlineForHyperlink) {
public PngTitler(HtmlColor textColor, DisplaySection text, int fontSize, String fontFamily,
HtmlColor hyperlinkColor, boolean useUnderlineForHyperlink) {
this.textColor = textColor;
this.text = text;
this.fontSize = fontSize;
this.fontFamily = fontFamily;
this.horizontalAlignment = horizontalAlignment;
this.hyperlinkColor = hyperlinkColor;
this.useUnderlineForHyperlink = useUnderlineForHyperlink;
}
public Dimension2D getTextDimension(StringBounder stringBounder) {
final TextBlock textBloc = getTextBlock();
final TextBlock textBloc = getRibbonBlock();
if (textBloc == null) {
return null;
}
return textBloc.calculateDimension(stringBounder);
}
public TextBlock getTextBlock() {
if (Display.isNull(text) || text.size() == 0) {
return null;
}
public TextBlock getRibbonBlock() {
final UFont normalFont = new UFont(fontFamily, Font.PLAIN, fontSize);
return text.create(new FontConfiguration(normalFont, textColor, hyperlinkColor, useUnderlineForHyperlink),
horizontalAlignment, new SpriteContainerEmpty());
return text.createRibbon(new FontConfiguration(normalFont, textColor, hyperlinkColor, useUnderlineForHyperlink),
new SpriteContainerEmpty());
}
private double getOffsetX(double imWidth, StringBounder stringBounder) {
final TextBlock textBloc = getTextBlock();
final TextBlock textBloc = getRibbonBlock();
if (textBloc == null) {
return 0;
}
@ -100,7 +94,7 @@ public class PngTitler {
}
private double getOffsetY(StringBounder stringBounder) {
final TextBlock textBloc = getTextBlock();
final TextBlock textBloc = getRibbonBlock();
if (textBloc == null) {
return 0;
}

View File

@ -489,7 +489,7 @@ public class SequenceDiagram extends UmlDiagram {
return true;
}
}
if (DisplayPositionned.isNull(getLegend()) == false && getLegend().hasUrl()) {
if (getLegend().isNull() == false && getLegend().hasUrl()) {
return true;
}
return false;

View File

@ -50,6 +50,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.EntityImageLegend;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.DisplayPositionned;
import net.sourceforge.plantuml.cucadiagram.DisplaySection;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.HtmlColor;
@ -163,7 +164,7 @@ public class SequenceDiagramFileMakerPuma2 implements FileMaker {
final DisplayPositionned legend = diagram.getLegend();
final TextBlock legendBlock;
if (DisplayPositionned.isNull(legend)) {
if (legend.isNull()) {
legendBlock = TextBlockUtils.empty(0, 0);
} else {
legendBlock = EntityImageLegend.create(legend.getDisplay(), diagram.getSkinParam());
@ -203,7 +204,7 @@ public class SequenceDiagramFileMakerPuma2 implements FileMaker {
final double delta1 = Math.max(0, dimLegend.getWidth() - area.getWidth());
final boolean legendTop = DisplayPositionned.isNull(legend) == false
final boolean legendTop = legend.isNull() == false
&& legend.getVerticalAlignment() == VerticalAlignment.TOP;
double sequenceAreaY = area.getSequenceAreaY();
@ -216,7 +217,7 @@ public class SequenceDiagramFileMakerPuma2 implements FileMaker {
drawHeader(area, ug, index);
drawFooter(area, ug, index);
if (DisplayPositionned.isNull(legend) == false) {
if (legend.isNull() == false) {
final double delta2;
if (legend.getHorizontalAlignment() == HorizontalAlignment.LEFT) {
delta2 = 0;
@ -236,7 +237,7 @@ public class SequenceDiagramFileMakerPuma2 implements FileMaker {
private void drawFooter(SequenceDiagramArea area, UGraphic ug, int page) {
final PngTitler pngTitler = getPngTitler(FontParam.FOOTER, page);
final TextBlock text = pngTitler.getTextBlock();
final TextBlock text = pngTitler.getRibbonBlock();
if (text == null) {
return;
}
@ -246,7 +247,7 @@ public class SequenceDiagramFileMakerPuma2 implements FileMaker {
private void drawHeader(SequenceDiagramArea area, UGraphic ug, int page) {
final PngTitler pngTitler = getPngTitler(FontParam.HEADER, page);
final TextBlock text = pngTitler.getTextBlock();
final TextBlock text = pngTitler.getRibbonBlock();
if (text == null) {
return;
}
@ -286,9 +287,9 @@ public class SequenceDiagramFileMakerPuma2 implements FileMaker {
final HtmlColor titleColor = diagram.getSkinParam().getFontHtmlColor(null, fontParam);
final String fontFamily = diagram.getSkinParam().getFont(null, false, fontParam).getFamily(null);
final int fontSize = diagram.getSkinParam().getFont(null, false, fontParam).getSize();
final Display display = diagram.getFooterOrHeaderTeoz(fontParam).getDisplay().withPage(page + 1, pages.size());
return new PngTitler(titleColor, display, fontSize, fontFamily, diagram.getFooterOrHeaderTeoz(fontParam)
.getHorizontalAlignment(), hyperlinkColor, diagram.getSkinParam().useUnderlineForHyperlink());
final DisplaySection display = diagram.getFooterOrHeaderTeoz(fontParam).withPage(page + 1, pages.size());
return new PngTitler(titleColor, display, fontSize, fontFamily, hyperlinkColor, diagram.getSkinParam()
.useUnderlineForHyperlink());
}
}

View File

@ -47,7 +47,7 @@ import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.activitydiagram3.ftile.EntityImageLegend;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.DisplayPositionned;
import net.sourceforge.plantuml.cucadiagram.DisplaySection;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.HtmlColor;
@ -168,7 +168,7 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker {
ug = ug.apply(new UTranslate(0, heightEnglober2));
printAligned(ug, HorizontalAlignment.CENTER, caption);
if (diagram.getLegend().getVerticalAlignment() == VerticalAlignment.BOTTOM) {
printAligned(ug, diagram.getLegend().getHorizontalAlignment(), legend);
ug = goDown(ug, legend);
@ -233,7 +233,7 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker {
}
private TextBlock getTitle() {
if (DisplayPositionned.isNull(diagram.getTitle())) {
if (diagram.getTitle().isNull()) {
return new ComponentAdapter(null);
}
final TextBlock compTitle = TextBlockUtils.title(new FontConfiguration(getSkinParam(),
@ -250,17 +250,16 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker {
}
public TextBlock getFooterOrHeader(final FontParam param) {
if (DisplayPositionned.isNull(diagram.getFooterOrHeaderTeoz(param))) {
if (diagram.getFooterOrHeaderTeoz(param).isNull()) {
return new TeozLayer(null, stringBounder, param);
}
final Display display = diagram.getFooterOrHeaderTeoz(param).getDisplay();
final DisplaySection display = diagram.getFooterOrHeaderTeoz(param);
final HtmlColor hyperlinkColor = getSkinParam().getHyperlinkColor();
final HtmlColor titleColor = getSkinParam().getFontHtmlColor(null, param);
final String fontFamily = getSkinParam().getFont(null, false, param).getFamily(null);
final int fontSize = getSkinParam().getFont(null, false, param).getSize();
final PngTitler pngTitler = new PngTitler(titleColor, display, fontSize, fontFamily, diagram
.getFooterOrHeaderTeoz(param).getHorizontalAlignment(), hyperlinkColor, getSkinParam()
.useUnderlineForHyperlink());
final PngTitler pngTitler = new PngTitler(titleColor, display, fontSize, fontFamily, hyperlinkColor,
getSkinParam().useUnderlineForHyperlink());
return new TeozLayer(pngTitler, stringBounder, param);
}

View File

@ -56,8 +56,8 @@ public class TeozLayer extends AbstractTextBlock implements TextBlock {
this.param = param;
dimension = new Dimension2DDouble(0, 0);
if (titler != null && titler.getTextBlock() != null) {
dimension = titler.getTextBlock().calculateDimension(stringBounder);
if (titler != null && titler.getRibbonBlock() != null) {
dimension = titler.getRibbonBlock().calculateDimension(stringBounder);
}
}
@ -71,7 +71,7 @@ public class TeozLayer extends AbstractTextBlock implements TextBlock {
public void drawU(UGraphic ug) {
if (titler != null) {
titler.getTextBlock().drawU(ug);
titler.getRibbonBlock().drawU(ug);
}
}

View File

@ -363,7 +363,8 @@ public class DotStringFactory implements Moveable {
for (Shape sh : bibliotekon.allShapes()) {
int idx = svg.indexOf("<title>" + sh.getUid() + "</title>");
if (sh.getType() == ShapeType.RECTANGLE || sh.getType() == ShapeType.RECTANGLE_HTML_FOR_PORTS
|| sh.getType() == ShapeType.FOLDER || sh.getType() == ShapeType.DIAMOND) {
|| sh.getType() == ShapeType.RECTANGLE_WITH_CIRCLE_INSIDE || sh.getType() == ShapeType.FOLDER
|| sh.getType() == ShapeType.DIAMOND) {
final List<Point2D.Double> points = svgResult.substring(idx).extractList(SvgResult.POINTS_EQUALS);
final double minX = SvekUtils.getMinX(points);
final double minY = SvekUtils.getMinY(points);

View File

@ -99,7 +99,8 @@ public class Shape implements Positionable, IShapePseudo, Hideable {
this.color = colorSequence.getValue();
this.uid = String.format("sh%04d", color);
this.shield = shield;
if (shield.isZero() == false && type != ShapeType.RECTANGLE && type != ShapeType.RECTANGLE_HTML_FOR_PORTS) {
if (shield.isZero() == false && type != ShapeType.RECTANGLE && type != ShapeType.RECTANGLE_HTML_FOR_PORTS
&& type != ShapeType.RECTANGLE_WITH_CIRCLE_INSIDE) {
throw new IllegalArgumentException();
}
}
@ -121,6 +122,10 @@ public class Shape implements Positionable, IShapePseudo, Hideable {
appendLabelHtmlSpecialForLink(sb, stringBounder);
return;
}
if (type == ShapeType.RECTANGLE_WITH_CIRCLE_INSIDE) {
appendHtml(sb);
return;
}
if (type == ShapeType.RECTANGLE && shield.isZero() == false) {
appendHtml(sb);
return;
@ -232,7 +237,8 @@ public class Shape implements Positionable, IShapePseudo, Hideable {
private void appendShapeInternal(StringBuilder sb) {
if (type == ShapeType.RECTANGLE && shield.isZero() == false) {
throw new UnsupportedOperationException();
} else if (type == ShapeType.RECTANGLE || type == ShapeType.FOLDER) {
} else if (type == ShapeType.RECTANGLE || type == ShapeType.RECTANGLE_WITH_CIRCLE_INSIDE
|| type == ShapeType.FOLDER) {
sb.append("shape=rect");
} else if (type == ShapeType.RECTANGLE_HTML_FOR_PORTS) {
throw new UnsupportedOperationException();

View File

@ -37,6 +37,6 @@ package net.sourceforge.plantuml.svek;
public enum ShapeType {
RECTANGLE, RECTANGLE_HTML_FOR_PORTS, ROUND_RECTANGLE, CIRCLE, CIRCLE_IN_RECT, OVAL, DIAMOND, OCTAGON, FOLDER
RECTANGLE, RECTANGLE_WITH_CIRCLE_INSIDE, RECTANGLE_HTML_FOR_PORTS, ROUND_RECTANGLE, CIRCLE, CIRCLE_IN_RECT, OVAL, DIAMOND, OCTAGON, FOLDER
}

View File

@ -98,7 +98,14 @@ public class EntityImageDescription extends AbstractEntityImage {
this.links = links;
final Stereotype stereotype = entity.getStereotype();
USymbol symbol = getUSymbol(entity);
this.shapeType = symbol == USymbol.FOLDER ? ShapeType.FOLDER : ShapeType.RECTANGLE;
if (symbol == USymbol.FOLDER) {
this.shapeType = ShapeType.FOLDER;
} else if (symbol == USymbol.INTERFACE) {
this.shapeType = ShapeType.RECTANGLE;
// this.shapeType = ShapeType.RECTANGLE_WITH_CIRCLE_INSIDE;
} else {
this.shapeType = ShapeType.RECTANGLE;
}
this.hideText = symbol == USymbol.INTERFACE;
final Display codeDisplay = Display.getWithNewlines(entity.getCode());

View File

@ -0,0 +1,74 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.timingdiagram;
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.RegexResult;
public class CommandDefineStateLong extends SingleLineCommand2<TimingDiagram> {
public CommandDefineStateLong() {
super(getRegexConcat());
}
private static RegexConcat getRegexConcat() {
return new RegexConcat(new RegexLeaf("^"), //
new RegexLeaf("PLAYER", "([\\p{L}0-9_.@]+)"), //
new RegexLeaf("[%s]+has[%s]+"), //
new RegexLeaf("LABEL", "[%g]([^%g]+)[%g]"), //
new RegexLeaf("[%s]+as[%s]+"), //
new RegexLeaf("STATE", "([\\p{L}0-9_.@]+)"), //
new RegexLeaf("$"));
}
@Override
final protected CommandExecutionResult executeArg(TimingDiagram diagram, RegexResult arg) {
final String playerCode = arg.get("PLAYER", 0);
final Player player = diagram.getPlayer(playerCode);
if (player == null) {
return CommandExecutionResult.error("Unknown " + playerCode);
}
final String label = arg.get("LABEL", 0);
final String stateCode = arg.get("STATE", 0);
player.defineState(stateCode, label);
return CommandExecutionResult.ok();
}
}

View File

@ -0,0 +1,71 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.timingdiagram;
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.RegexResult;
public class CommandDefineStateShort extends SingleLineCommand2<TimingDiagram> {
public CommandDefineStateShort() {
super(getRegexConcat());
}
private static RegexConcat getRegexConcat() {
return new RegexConcat(new RegexLeaf("^"), //
new RegexLeaf("PLAYER", "([\\p{L}0-9_.@]+)"), //
new RegexLeaf("[%s]+has[%s]+"), //
new RegexLeaf("STATE", "([\\p{L}0-9_.@]+)"), //
new RegexLeaf("$"));
}
@Override
final protected CommandExecutionResult executeArg(TimingDiagram diagram, RegexResult arg) {
final String playerCode = arg.get("PLAYER", 0);
final Player player = diagram.getPlayer(playerCode);
if (player == null) {
return CommandExecutionResult.error("Unknown " + playerCode);
}
final String stateCode = arg.get("STATE", 0);
player.defineState(stateCode, stateCode);
return CommandExecutionResult.ok();
}
}

View File

@ -40,6 +40,7 @@ import java.awt.geom.Point2D.Double;
import java.awt.geom.Rectangle2D;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
@ -66,16 +67,18 @@ public class Histogram implements TimeDrawing {
private final List<ChangeState> changes = new ArrayList<ChangeState>();
private final List<TimeConstraint> constraints = new ArrayList<TimeConstraint>();
private List<String> allStates = new ArrayList<String>();
private List<String> allStates;
private final double stepHeight = 20;
private final ISkinParam skinParam;
private final TimingRuler ruler;
private String initialState;
public Histogram(TimingRuler ruler, ISkinParam skinParam) {
public Histogram(TimingRuler ruler, ISkinParam skinParam, Collection<String> someStates) {
this.ruler = ruler;
this.skinParam = skinParam;
this.allStates = new ArrayList<String>(someStates);
Collections.reverse(allStates);
}
public IntricatedPoint getTimeProjection(StringBounder stringBounder, TimeTick tick) {

View File

@ -37,7 +37,9 @@ package net.sourceforge.plantuml.timingdiagram;
import java.awt.geom.Dimension2D;
import java.awt.geom.Rectangle2D;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
@ -72,6 +74,7 @@ public class Player implements TextBlock, TimeProjected {
private final Set<ChangeState> changes = new TreeSet<ChangeState>();
private final List<TimeConstraint> constraints = new ArrayList<TimeConstraint>();
private final List<TimingNote> notes = new ArrayList<TimingNote>();
private final Map<String, String> statesLabel = new LinkedHashMap<String, String>();
public Player(String code, String full, TimingStyle type, ISkinParam skinParam, TimingRuler ruler) {
this.code = code;
@ -143,7 +146,7 @@ public class Player implements TextBlock, TimeProjected {
if (type == TimingStyle.CONCISE) {
result = new Ribbon(ruler, skinParam, notes);
} else if (type == TimingStyle.ROBUST) {
result = new Histogram(ruler, skinParam);
result = new Histogram(ruler, skinParam, statesLabel.values());
} else {
throw new IllegalStateException();
}
@ -177,6 +180,7 @@ public class Player implements TextBlock, TimeProjected {
}
public void setState(TimeTick now, String state, String comment, Colors color) {
state = decodeState(state);
if (now == null) {
this.initialState = state;
this.initialColors = color;
@ -189,6 +193,14 @@ public class Player implements TextBlock, TimeProjected {
}
private String decodeState(String code) {
final String label = statesLabel.get(code);
if (label == null) {
return code;
}
return label;
}
public IntricatedPoint getTimeProjection(StringBounder stringBounder, TimeTick tick) {
final IntricatedPoint point = getTimeDrawing().getTimeProjection(stringBounder, tick);
if (point == null) {
@ -206,4 +218,8 @@ public class Player implements TextBlock, TimeProjected {
this.notes.add(new TimingNote(now, this, note, position, skinParam));
}
public void defineState(String stateCode, String label) {
statesLabel.put(stateCode, label);
}
}

View File

@ -56,6 +56,8 @@ public class TimingDiagramFactory extends UmlDiagramFactory {
addCommonCommands(cmds);
cmds.add(new CommandLifeLine());
cmds.add(new CommandDefineStateShort());
cmds.add(new CommandDefineStateLong());
cmds.add(new CommandChangeStateByPlayerCode());
cmds.add(new CommandChangeStateByTime());
cmds.add(new CommandAtTime());

View File

@ -39,7 +39,7 @@ import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.graphic.StringBounder;
public class SlotFinder implements UGraphic {
public boolean matchesProperty(String propertyName) {
return false;
}
@ -87,7 +87,13 @@ public class SlotFinder implements UGraphic {
final double x = translate.getDx();
final double y = translate.getDy();
if (shape instanceof URectangle) {
drawRectangle(x, y, (URectangle) shape);
final URectangle rect = (URectangle) shape;
if (rect.isIgnoreForCompression()) {
drawRectangle(x, y, new URectangle(rect.getWidth(), 2));
drawRectangle(x, y + rect.getHeight() - 2, new URectangle(rect.getWidth(), 2));
return;
}
drawRectangle(x, y, rect);
} else if (shape instanceof UPolygon) {
drawPolygon(x, y, (UPolygon) shape);
} else if (shape instanceof UEllipse) {

View File

@ -64,6 +64,13 @@ public class UGraphicCompress extends UGraphicDelegator {
public void draw(UShape shape) {
final double x = translate.getDx();
final double y = translate.getDy();
if (shape instanceof URectangle) {
final URectangle rect = (URectangle) shape;
if (rect.isIgnoreForCompression()) {
final double y2 = ct(y + rect.getHeight());
shape = rect.withWidth(y2 - ct(y));
}
}
if (shape instanceof ULine) {
drawLine(x, y, (ULine) shape);
} else {

View File

@ -44,6 +44,13 @@ public class URectangle extends AbstractShadowable implements Scalable, UShapeSi
private final double ry;
private final String comment;
public URectangle withWidth(double newHeight) {
final URectangle result = new URectangle(width, newHeight, rx, ry, comment);
result.ignoreForCompression = this.ignoreForCompression;
result.setDeltaShadow(this.getDeltaShadow());
return result;
}
public UShape getScaled(double scale) {
if (scale == 1) {
return this;
@ -112,4 +119,14 @@ public class URectangle extends AbstractShadowable implements Scalable, UShapeSi
return comment;
}
private boolean ignoreForCompression;
public final boolean isIgnoreForCompression() {
return ignoreForCompression;
}
public final void setIgnoreForCompression(boolean ignoreForCompression) {
this.ignoreForCompression = ignoreForCompression;
}
}

View File

@ -43,7 +43,7 @@ public class Version {
private static final int MAJOR_SEPARATOR = 1000000;
public static int version() {
return 1201804;
return 1201805;
}
public static int versionPatched() {
@ -88,7 +88,7 @@ public class Version {
}
public static long compileTime() {
return 1525191499228L;
return 1525550417984L;
}
public static String compileTimeString() {