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

version 1.2020.10

This commit is contained in:
Arnaud Roques 2020-05-17 23:15:50 +02:00
parent a332e69c6f
commit bb94634fd4
189 changed files with 2957 additions and 1027 deletions

View File

@ -35,7 +35,7 @@
<groupId>net.sourceforge.plantuml</groupId>
<artifactId>plantuml</artifactId>
<version>1.2020.9</version>
<version>1.2020.11-SNAPSHOT</version>
<packaging>jar</packaging>
<name>PlantUML</name>
@ -75,9 +75,9 @@
</licenses>
<scm>
<connection>scm:svn:svn://svn.code.sf.net/p/plantuml/code/tags/plantuml-1.2020.9</connection>
<developerConnection>scm:svn:https://svn.code.sf.net/p/plantuml/code/tags/plantuml-1.2020.9</developerConnection>
<url>svn://svn.code.sf.net/p/plantuml/code/tags/plantuml-1.2020.9</url>
<connection>scm:svn:svn://svn.code.sf.net/p/plantuml/code/trunk</connection>
<developerConnection>scm:svn:https://svn.code.sf.net/p/plantuml/code/trunk</developerConnection>
<url>svn://svn.code.sf.net/p/plantuml/code/trunk</url>
</scm>
<issueManagement>

View File

@ -75,7 +75,12 @@ public abstract class AbstractPSystem implements Diagram {
if (source == null) {
return getVersion();
}
return source.getPlainString() + BackSlash.NEWLINE + getVersion();
final String rawString = source.getRawString();
final String plainString = source.getPlainString();
if (rawString != null && rawString.equals(plainString)) {
return rawString + BackSlash.NEWLINE + getVersion();
}
return rawString + BackSlash.NEWLINE + plainString + BackSlash.NEWLINE + getVersion();
}
final public UmlSource getSource() {

View File

@ -59,6 +59,7 @@ import net.sourceforge.plantuml.version.Version;
public class BlockUml {
private final List<StringLocated> rawSource;
private final List<StringLocated> data;
private List<StringLocated> debug;
private Diagram system;
@ -108,6 +109,7 @@ public class BlockUml {
private boolean preprocessorError;
public BlockUml(List<StringLocated> strings, Defines defines, ISkinSimple skinParam, PreprocessorModeSet mode) {
this.rawSource = new ArrayList<StringLocated>(strings);
this.localDefines = defines;
this.skinParam = skinParam;
final String s0 = strings.get(0).getTrimmed().getString();
@ -158,7 +160,7 @@ public class BlockUml {
if (preprocessorError) {
system = new PSystemErrorPreprocessor(data, debug);
} else {
system = new PSystemBuilder().createPSystem(skinParam, data);
system = new PSystemBuilder().createPSystem(skinParam, data, rawSource);
}
}
return system;

View File

@ -87,12 +87,12 @@ public final class BlockUmlBuilder implements DefinitionsContainer {
private void init(ReadLineNumbered includer) throws IOException {
StringLocated s = null;
List<StringLocated> current2 = null;
List<StringLocated> current = null;
boolean paused = false;
while ((s = includer.readLine()) != null) {
if (StartUtils.isArobaseStartDiagram(s.getString())) {
current2 = new ArrayList<StringLocated>();
current = new ArrayList<StringLocated>();
paused = false;
}
if (StartUtils.isArobasePauseDiagram(s.getString())) {
@ -103,12 +103,12 @@ public final class BlockUmlBuilder implements DefinitionsContainer {
paused = true;
reader.setPaused(true);
}
if (current2 != null && paused == false) {
current2.add(s);
if (current != null && paused == false) {
current.add(s);
} else if (paused) {
final StringLocated append = StartUtils.getPossibleAppend(s);
if (append != null) {
current2.add(append);
current.add(append);
}
}
@ -116,14 +116,14 @@ public final class BlockUmlBuilder implements DefinitionsContainer {
paused = false;
reader.setPaused(false);
}
if (StartUtils.isArobaseEndDiagram(s.getString()) && current2 != null) {
if (StartUtils.isArobaseEndDiagram(s.getString()) && current != null) {
if (paused) {
current2.add(s);
current.add(s);
}
final BlockUml uml = new BlockUml(current2, defines.cloneMe(), null, this);
final BlockUml uml = new BlockUml(current, defines.cloneMe(), null, this);
usedFiles.addAll(uml.getIncluded());
blocks.add(uml);
current2 = null;
current = null;
reader.setPaused(false);
}
}

View File

@ -49,7 +49,7 @@ import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.core.DiagramType;
import net.sourceforge.plantuml.core.UmlSource;
import net.sourceforge.plantuml.creole.PSystemCreoleFactory;
import net.sourceforge.plantuml.creole.legacy.PSystemCreoleFactory;
import net.sourceforge.plantuml.dedication.PSystemDedicationFactory;
import net.sourceforge.plantuml.definition.PSystemDefinitionFactory;
import net.sourceforge.plantuml.descdiagram.DescriptionDiagramFactory;
@ -96,24 +96,24 @@ public class PSystemBuilder {
public static final long startTime = System.currentTimeMillis();
final public Diagram createPSystem(ISkinSimple skinParam, final List<StringLocated> strings2) {
final public Diagram createPSystem(ISkinSimple skinParam, List<StringLocated> source,
List<StringLocated> rawSource) {
final long now = System.currentTimeMillis();
Diagram result = null;
try {
final DiagramType type = DiagramType.getTypeFromArobaseStart(strings2.get(0).getString());
final UmlSource umlSource = new UmlSource(strings2, type == DiagramType.UML);
final DiagramType type = DiagramType.getTypeFromArobaseStart(source.get(0).getString());
final UmlSource umlSource = new UmlSource(source, type == DiagramType.UML, rawSource);
for (StringLocated s : strings2) {
for (StringLocated s : source) {
if (s.getPreprocessorError() != null) {
// Dead code : should not append
assert false;
Log.error("Preprocessor Error: " + s.getPreprocessorError());
final ErrorUml err = new ErrorUml(ErrorUmlType.SYNTAX_ERROR, s.getPreprocessorError(), /* cpt */
s.getLocation());
// return PSystemErrorUtils.buildV1(umlSource, err, Collections.<String>
// emptyList());
return PSystemErrorUtils.buildV2(umlSource, err, Collections.<String>emptyList(), strings2);
return PSystemErrorUtils.buildV2(umlSource, err, Collections.<String>emptyList(), source);
}
}

View File

@ -52,7 +52,7 @@ import net.sourceforge.plantuml.command.BlocLines;
import net.sourceforge.plantuml.command.regex.Matcher2;
import net.sourceforge.plantuml.command.regex.MyPattern;
import net.sourceforge.plantuml.command.regex.Pattern2;
import net.sourceforge.plantuml.creole.command.CommandCreoleMonospaced;
import net.sourceforge.plantuml.creole.Parser;
import net.sourceforge.plantuml.cucadiagram.LinkStyle;
import net.sourceforge.plantuml.cucadiagram.Rankdir;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
@ -1082,7 +1082,7 @@ public class SkinParam implements ISkinParam {
public String getMonospacedFamily() {
final String value = getValue("defaultMonospacedFontName");
if (value == null) {
return CommandCreoleMonospaced.MONOSPACED;
return Parser.MONOSPACED;
}
return value;
}

View File

@ -37,7 +37,7 @@ package net.sourceforge.plantuml;
import java.util.Map;
import net.sourceforge.plantuml.creole.command.CommandCreoleMonospaced;
import net.sourceforge.plantuml.creole.Parser;
import net.sourceforge.plantuml.sprite.Sprite;
import net.sourceforge.plantuml.sprite.SpriteImage;
import net.sourceforge.plantuml.ugraphic.color.ColorMapper;
@ -63,7 +63,7 @@ public class SpriteContainerEmpty implements SpriteContainer, ISkinSimple {
}
public String getMonospacedFamily() {
return CommandCreoleMonospaced.MONOSPACED;
return Parser.MONOSPACED;
}
public int getTabSize() {
@ -94,6 +94,4 @@ public class SpriteContainerEmpty implements SpriteContainer, ISkinSimple {
throw new UnsupportedOperationException();
}
}

View File

@ -189,8 +189,7 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot
fileFormatOption = fileFormatOption.withPreserveAspectRatio(getSkinParam().getPreserveAspectRatio());
fileFormatOption = fileFormatOption.withTikzFontDistortion(getSkinParam().getTikzFontDistortion());
if (hover != null) {
fileFormatOption = fileFormatOption
.withHoverColor(getSkinParam().getColorMapper().toHtml(hover));
fileFormatOption = fileFormatOption.withHoverColor(getSkinParam().getColorMapper().toHtml(hover));
}
if (fileFormatOption.getFileFormat() == FileFormat.PDF) {
@ -230,15 +229,19 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot
strings.addAll(CommandExecutionResult.getStackTrace(exception));
final ImageBuilder imageBuilder = ImageBuilder.buildA(new ColorMapperIdentity(), false,
null, metadata, null, 1.0, HColorUtils.WHITE);
final ImageBuilder imageBuilder = ImageBuilder.buildA(new ColorMapperIdentity(), false, null, metadata, null,
1.0, HColorUtils.WHITE);
final BufferedImage im;
if (flash == null) {
im = null;
} else {
final FlashCodeUtils utils = FlashCodeFactory.getFlashCodeUtils();
final BufferedImage im = utils.exportFlashcode(flash, Color.BLACK, Color.WHITE);
im = utils.exportFlashcode(flash, Color.BLACK, Color.WHITE);
if (im != null) {
GraphvizCrash.addDecodeHint(strings);
}
}
final TextBlockBackcolored graphicStrings = GraphicStrings.createBlackOnWhite(strings, IconLoader.getRandom(),
GraphicPosition.BACKGROUND_CORNER_TOP_RIGHT);

View File

@ -45,6 +45,7 @@ import net.sourceforge.plantuml.ugraphic.MinMax;
import net.sourceforge.plantuml.ugraphic.UBackground;
import net.sourceforge.plantuml.ugraphic.UChange;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UGraphicNo;
import net.sourceforge.plantuml.ugraphic.ULine;
import net.sourceforge.plantuml.ugraphic.UParam;
import net.sourceforge.plantuml.ugraphic.UParamNull;
@ -57,7 +58,7 @@ import net.sourceforge.plantuml.ugraphic.color.ColorMapper;
import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
public class CollisionDetector implements UGraphic {
public class CollisionDetector extends UGraphicNo implements UGraphic {
public UGraphic apply(UChange change) {
if (change instanceof UTranslate) {
@ -199,12 +200,6 @@ public class CollisionDetector implements UGraphic {
throw new UnsupportedOperationException();
}
public void startUrl(Url url) {
}
public void closeAction() {
}
public void flushUg() {
}

View File

@ -54,7 +54,7 @@ public class FtileWithUrl extends FtileDecorate {
public void drawU(UGraphic ug) {
ug.startUrl(url);
getFtileDelegated().drawU(ug);
ug.closeAction();
ug.closeUrl();
}
}

View File

@ -35,12 +35,12 @@
*/
package net.sourceforge.plantuml.activitydiagram3.ftile;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.ugraphic.MinMax;
import net.sourceforge.plantuml.ugraphic.UBackground;
import net.sourceforge.plantuml.ugraphic.UChange;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UGraphicNo;
import net.sourceforge.plantuml.ugraphic.UParam;
import net.sourceforge.plantuml.ugraphic.UParamNull;
import net.sourceforge.plantuml.ugraphic.URectangle;
@ -50,7 +50,7 @@ import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.ColorMapper;
import net.sourceforge.plantuml.ugraphic.color.HColor;
public class ZadBuilder implements UGraphic {
public class ZadBuilder extends UGraphicNo implements UGraphic {
public UGraphic apply(UChange change) {
if (change instanceof UTranslate) {
@ -111,12 +111,6 @@ public class ZadBuilder implements UGraphic {
throw new UnsupportedOperationException();
}
public void startUrl(Url url) {
}
public void closeAction() {
}
public void flushUg() {
}

View File

@ -42,7 +42,7 @@ import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.LineBreakStrategy;
import net.sourceforge.plantuml.creole.CreoleMode;
import net.sourceforge.plantuml.creole.CreoleParser;
import net.sourceforge.plantuml.creole.Parser;
import net.sourceforge.plantuml.creole.Sheet;
import net.sourceforge.plantuml.creole.SheetBlock1;
import net.sourceforge.plantuml.creole.SheetBlock2;
@ -72,11 +72,13 @@ public class FloatingNote extends AbstractTextBlock implements Stencil, TextBloc
final FontConfiguration fc = new FontConfiguration(skinParam, FontParam.NOTE, null);
final Sheet sheet = new CreoleParser(fc, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT),
skinParam, CreoleMode.FULL).createSheet(note);
final SheetBlock2 sheetBlock2 = new SheetBlock2(new SheetBlock1(sheet, LineBreakStrategy.NONE, skinParam.getPadding()), this,
new UStroke(1));
final double shadowing;shadowing = skinParam.shadowing(null)?4:0;
final Sheet sheet = Parser
.build(fc, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT), skinParam, CreoleMode.FULL)
.createSheet(note);
final SheetBlock2 sheetBlock2 = new SheetBlock2(
new SheetBlock1(sheet, LineBreakStrategy.NONE, skinParam.getPadding()), this, new UStroke(1));
final double shadowing;
shadowing = skinParam.shadowing(null) ? 4 : 0;
this.opale = new Opale(shadowing, borderColor, noteBackgroundColor, sheetBlock2, false);
// this.text = sheetBlock2;

View File

@ -61,7 +61,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamond;
import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamondInside;
import net.sourceforge.plantuml.creole.CreoleMode;
import net.sourceforge.plantuml.creole.CreoleParser;
import net.sourceforge.plantuml.creole.Parser;
import net.sourceforge.plantuml.creole.Sheet;
import net.sourceforge.plantuml.creole.SheetBlock1;
import net.sourceforge.plantuml.creole.SheetBlock2;
@ -124,13 +124,15 @@ class FtileIfAndStop extends AbstractFtile {
final Ftile stopFtile = ftileFactory.stop(swimlane);
// final TextBlock tb1 = Display.create(branch1.getLabelPositive(), fcArrow, HorizontalAlignment.LEFT,
// final TextBlock tb1 = Display.create(branch1.getLabelPositive(), fcArrow,
// HorizontalAlignment.LEFT,
// ftileFactory);
// final TextBlock tb2 = Display.create(branch2.getLabelPositive(), fcArrow, HorizontalAlignment.LEFT,
// final TextBlock tb2 = Display.create(branch2.getLabelPositive(), fcArrow,
// HorizontalAlignment.LEFT,
// ftileFactory);
final Sheet sheet = new CreoleParser(fcTest, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT),
skinParam, CreoleMode.FULL).createSheet(labelTest);
final Sheet sheet = Parser.build(fcTest, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT), skinParam, CreoleMode.FULL)
.createSheet(labelTest);
final SheetBlock1 sheetBlock1 = new SheetBlock1(sheet, LineBreakStrategy.NONE, skinParam.getPadding());
final TextBlock tbTest = new SheetBlock2(sheetBlock1, Diamond.asStencil(sheetBlock1),
tileNonStop.getThickness());
@ -149,9 +151,11 @@ class FtileIfAndStop extends AbstractFtile {
// final Ftile diamond2;
// if (tile1.calculateDimension(stringBounder).hasPointOut()
// && tile2.calculateDimension(stringBounder).hasPointOut()) {
// diamond2 = new FtileDiamond(tile1.shadowing(), backColor, borderColor, swimlane);
// diamond2 = new FtileDiamond(tile1.shadowing(), backColor, borderColor,
// swimlane);
// } else {
// diamond2 = new FtileEmpty(tile1.shadowing(), Diamond.diamondHalfSize * 2, Diamond.diamondHalfSize * 2,
// diamond2 = new FtileEmpty(tile1.shadowing(), Diamond.diamondHalfSize * 2,
// Diamond.diamondHalfSize * 2,
// swimlane, swimlane);
// }
final FtileIfAndStop result = new FtileIfAndStop(diamond1, tileNonStop, arrowColor, stopFtile);
@ -161,14 +165,18 @@ class FtileIfAndStop extends AbstractFtile {
// conns.add(result.new ConnectionHorizontalThenVertical(tile2));
// if (tile1.calculateDimension(stringBounder).hasPointOut()
// && tile2.calculateDimension(stringBounder).hasPointOut()) {
// conns.add(result.new ConnectionVerticalThenHorizontal(tile1, branch1.getInlinkRenderingColor()));
// conns.add(result.new ConnectionVerticalThenHorizontal(tile2, branch2.getInlinkRenderingColor()));
// conns.add(result.new ConnectionVerticalThenHorizontal(tile1,
// branch1.getInlinkRenderingColor()));
// conns.add(result.new ConnectionVerticalThenHorizontal(tile2,
// branch2.getInlinkRenderingColor()));
// } else if (tile1.calculateDimension(stringBounder).hasPointOut()
// && tile2.calculateDimension(stringBounder).hasPointOut() == false) {
// conns.add(result.new ConnectionVerticalThenHorizontalDirect(tile1, branch1.getInlinkRenderingColor()));
// conns.add(result.new ConnectionVerticalThenHorizontalDirect(tile1,
// branch1.getInlinkRenderingColor()));
// } else if (tile1.calculateDimension(stringBounder).hasPointOut() == false
// && tile2.calculateDimension(stringBounder).hasPointOut()) {
// conns.add(result.new ConnectionVerticalThenHorizontalDirect(tile2, branch2.getInlinkRenderingColor()));
// conns.add(result.new ConnectionVerticalThenHorizontalDirect(tile2,
// branch2.getInlinkRenderingColor()));
// }
return FtileUtils.addConnection(result, conns);
// return result;
@ -281,7 +289,8 @@ class FtileIfAndStop extends AbstractFtile {
// final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
// if (tile1.calculateDimension(stringBounder).hasPointOut()) {
// return new FtileGeometry(dimTotal, getLeft(stringBounder), 0, dimTotal.getHeight());
// return new FtileGeometry(dimTotal, getLeft(stringBounder), 0,
// dimTotal.getHeight());
// }
// return new FtileGeometry(dimTotal, getLeft(stringBounder), 0);
}
@ -295,22 +304,26 @@ class FtileIfAndStop extends AbstractFtile {
// return calculateDimensionInternal;
// }
//
// private Dimension2D calculateDimensionInternalSlow(StringBounder stringBounder) {
// private Dimension2D calculateDimensionInternalSlow(StringBounder
// stringBounder) {
// final Dimension2D dim1 = tile1.calculateDimension(stringBounder);
// final Dimension2D dimDiamond1 = diamond1.calculateDimension(stringBounder);
// final Dimension2D dimStop2 = stop2.calculateDimension(stringBounder);
// final double width = Math.max(dim1.getWidth(),
// dimDiamond1.getWidth() + getDiamondStopDistance() + dimStop2.getWidth());
// return new Dimension2DDouble(width + 30, dim1.getHeight() + dimDiamond1.getHeight() + 40);
// return new Dimension2DDouble(width + 30, dim1.getHeight() +
// dimDiamond1.getHeight() + 40);
// }
//
// private double getLeft(StringBounder stringBounder) {
// // return calculateDimension(stringBounder).getLeft();
// return tile1.calculateDimension(stringBounder).translate(getTranslate1(stringBounder)).getLeft();
// return
// tile1.calculateDimension(stringBounder).translate(getTranslate1(stringBounder)).getLeft();
// // final double left1 =
// tile1.calculateDimension(stringBounder).translate(getTranslate1(stringBounder)).getLeft();
// // // final double left2 =
// // // tile2.calculateDimension(stringBounder).translate(getTranslate2(stringBounder)).getLeft();
// // //
// tile2.calculateDimension(stringBounder).translate(getTranslate2(stringBounder)).getLeft();
// // // return (left1 + left2) / 2;
// // return left1;
// }

View File

@ -50,7 +50,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.creole.CreoleMode;
import net.sourceforge.plantuml.creole.CreoleParser;
import net.sourceforge.plantuml.creole.Parser;
import net.sourceforge.plantuml.creole.Sheet;
import net.sourceforge.plantuml.creole.SheetBlock1;
import net.sourceforge.plantuml.creole.SheetBlock2;
@ -123,8 +123,9 @@ public class FtileNoteAlone extends AbstractFtile implements Stencil, Styleable
final FontConfiguration fc = new FontConfiguration(skinParam, FontParam.NOTE, null);
final Sheet sheet = new CreoleParser(fc, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT),
skinParam, CreoleMode.FULL).createSheet(note);
final Sheet sheet = Parser
.build(fc, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT), skinParam, CreoleMode.FULL)
.createSheet(note);
final TextBlock text = new SheetBlock2(new SheetBlock1(sheet, LineBreakStrategy.NONE, skinParam.getPadding()),
this, new UStroke(1));
opale = new Opale(shadowing, borderColor, noteBackgroundColor, text, false);

View File

@ -55,7 +55,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.creole.CreoleMode;
import net.sourceforge.plantuml.creole.CreoleParser;
import net.sourceforge.plantuml.creole.Parser;
import net.sourceforge.plantuml.creole.Sheet;
import net.sourceforge.plantuml.creole.SheetBlock1;
import net.sourceforge.plantuml.creole.SheetBlock2;
@ -144,7 +144,8 @@ public class FtileWithNoteOpale extends AbstractFtile implements Stencil, Stylea
final double shadowing;
if (SkinParam.USE_STYLES()) {
final Style style = getDefaultStyleDefinition().getMergedStyle(skinParam.getCurrentStyleBuilder()).eventuallyOverride(note.getColors());
final Style style = getDefaultStyleDefinition().getMergedStyle(skinParam.getCurrentStyleBuilder())
.eventuallyOverride(note.getColors());
noteBackgroundColor = style.value(PName.BackGroundColor).asColor(getIHtmlColorSet());
borderColor = style.value(PName.LineColor).asColor(getIHtmlColorSet());
fc = style.getFontConfiguration(getIHtmlColorSet());
@ -158,7 +159,7 @@ public class FtileWithNoteOpale extends AbstractFtile implements Stencil, Stylea
final HorizontalAlignment align = skinParam.getHorizontalAlignment(AlignmentParam.noteTextAlignment, null,
false);
final Sheet sheet = new CreoleParser(fc, align, skinParam, CreoleMode.FULL).createSheet(note.getDisplay());
final Sheet sheet = Parser.build(fc, align, skinParam, CreoleMode.FULL).createSheet(note.getDisplay());
final TextBlock text = new SheetBlock2(new SheetBlock1(sheet, skinParam.wrapWidth(), skinParam.getPadding()),
this, new UStroke(1));
opale = new Opale(shadowing, borderColor, noteBackgroundColor, text, withLink);

View File

@ -51,7 +51,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.creole.CreoleMode;
import net.sourceforge.plantuml.creole.CreoleParser;
import net.sourceforge.plantuml.creole.Parser;
import net.sourceforge.plantuml.creole.Sheet;
import net.sourceforge.plantuml.creole.SheetBlock1;
import net.sourceforge.plantuml.creole.SheetBlock2;
@ -129,8 +129,9 @@ public class FtileWithNotes extends AbstractFtile {
shadowing = skinParam.shadowing(null) ? 4 : 0;
}
final Sheet sheet = new CreoleParser(fc, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT),
skinParam, CreoleMode.FULL).createSheet(note.getDisplay());
final Sheet sheet = Parser
.build(fc, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT), skinParam, CreoleMode.FULL)
.createSheet(note.getDisplay());
final SheetBlock1 sheet1 = new SheetBlock1(sheet, LineBreakStrategy.NONE, skinParam.getPadding());
final SheetBlock2 sheet2 = new SheetBlock2(sheet1, new Stencil() {
// -6 and 15 value comes from Opale: this is very ugly!

View File

@ -54,10 +54,11 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileIfDown;
import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamond;
import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamondInside;
import net.sourceforge.plantuml.creole.CreoleMode;
import net.sourceforge.plantuml.creole.CreoleParser;
import net.sourceforge.plantuml.creole.Parser;
import net.sourceforge.plantuml.creole.Sheet;
import net.sourceforge.plantuml.creole.SheetBlock1;
import net.sourceforge.plantuml.creole.SheetBlock2;
import net.sourceforge.plantuml.creole.legacy.CreoleParser;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
@ -107,12 +108,12 @@ public class ConditionalBuilder {
if (SkinParam.USE_STYLES()) {
final Style styleArrow = getDefaultStyleDefinitionArrow()
.getMergedStyle(skinParam.getCurrentStyleBuilder());
final Style styleDiamond = getDefaultStyleDefinitionDiamond().getMergedStyle(
skinParam.getCurrentStyleBuilder());
final Style styleDiamond = getDefaultStyleDefinitionDiamond()
.getMergedStyle(skinParam.getCurrentStyleBuilder());
this.borderColor = styleDiamond.value(PName.LineColor).asColor(skinParam.getIHtmlColorSet());
this.backColor = styleDiamond.value(PName.BackGroundColor).asColor(skinParam.getIHtmlColorSet());
this.arrowColor = Rainbow
.fromColor(styleArrow.value(PName.LineColor).asColor(skinParam.getIHtmlColorSet()), null);
this.arrowColor = Rainbow.fromColor(styleArrow.value(PName.LineColor).asColor(skinParam.getIHtmlColorSet()),
null);
this.fontTest = styleDiamond.getFontConfiguration(skinParam.getIHtmlColorSet());
this.fontArrow = styleArrow.getFontConfiguration(skinParam.getIHtmlColorSet());
} else {
@ -238,7 +239,7 @@ public class ConditionalBuilder {
private Ftile getDiamond1(boolean eastWest, TextBlock tb1, TextBlock tb2) {
final Display labelTest = branch1.getLabelTest();
final Sheet sheet = new CreoleParser(fontTest, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT),
final Sheet sheet = Parser.build(fontTest, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT),
skinParam, CreoleMode.FULL).createSheet(labelTest);
final SheetBlock1 sheetBlock1 = new SheetBlock1(sheet, LineBreakStrategy.NONE, skinParam.getPadding());
final TextBlock tbTest = new SheetBlock2(sheetBlock1, Diamond.asStencil(sheetBlock1), tile1.getThickness());
@ -279,11 +280,13 @@ public class ConditionalBuilder {
// else use default ConditionEndStyle.DIAMOND
if (hasTwoBranches()) {
final Display out1 = branch1.getFtile().getOutLinkRendering().getDisplay();
final TextBlock tbout1 = out1 == null ? null : out1.create7(fontArrow, HorizontalAlignment.LEFT,
ftileFactory.skinParam(), CreoleMode.SIMPLE_LINE);
final TextBlock tbout1 = out1 == null ? null
: out1.create7(fontArrow, HorizontalAlignment.LEFT, ftileFactory.skinParam(),
CreoleMode.SIMPLE_LINE);
final Display out2 = branch2.getFtile().getOutLinkRendering().getDisplay();
final TextBlock tbout2 = out2 == null ? null : out2.create7(fontArrow, HorizontalAlignment.LEFT,
ftileFactory.skinParam(), CreoleMode.SIMPLE_LINE);
final TextBlock tbout2 = out2 == null ? null
: out2.create7(fontArrow, HorizontalAlignment.LEFT, ftileFactory.skinParam(),
CreoleMode.SIMPLE_LINE);
FtileDiamond tmp = new FtileDiamond(tile1.skinParam(), backColor, borderColor, swimlane);
tmp = useNorth ? tmp.withNorth(tbout1) : tmp.withWest(tbout1);
tmp = tmp.withEast(tbout2);

View File

@ -55,11 +55,12 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.creole.CreoleMode;
import net.sourceforge.plantuml.creole.CreoleParser;
import net.sourceforge.plantuml.creole.Parser;
import net.sourceforge.plantuml.creole.Sheet;
import net.sourceforge.plantuml.creole.SheetBlock1;
import net.sourceforge.plantuml.creole.SheetBlock2;
import net.sourceforge.plantuml.creole.Stencil;
import net.sourceforge.plantuml.creole.legacy.CreoleParser;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
@ -216,8 +217,9 @@ public class FtileBox extends AbstractFtile {
wrapWidth = skinParam.wrapWidth();
}
final Sheet sheet = new CreoleParser(fc, skinParam.getDefaultTextAlignment(horizontalAlignment), skinParam,
CreoleMode.FULL).createSheet(label);
final Sheet sheet = Parser
.build(fc, skinParam.getDefaultTextAlignment(horizontalAlignment), skinParam, CreoleMode.FULL)
.createSheet(label);
this.tb = new SheetBlock2(new SheetBlock1(sheet, wrapWidth, skinParam.getPadding()), new MyStencil(),
new UStroke(1));
this.print = label.toString();

View File

@ -121,12 +121,6 @@ public class UGraphicBraille extends AbstractUGraphic<BrailleGrid> implements Cl
return FileFormat.BRAILLE_PNG.getDefaultStringBounder(TikzFontDistortion.getDefault());
}
public void startUrl(Url url) {
}
public void closeAction() {
}
public void writeImageTOBEMOVED(OutputStream os, String metadata, int dpi) throws IOException {
final ImageBuilder imageBuilder = ImageBuilder.buildA(new ColorMapperIdentity(),
false, null, metadata, null, 1.0, HColorUtils.WHITE);

View File

@ -45,9 +45,6 @@ import net.sourceforge.plantuml.UrlBuilder;
import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2;
import net.sourceforge.plantuml.command.regex.Matcher2;
import net.sourceforge.plantuml.command.regex.MyPattern;
import net.sourceforge.plantuml.command.regex.Pattern2;
import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexOptional;
@ -58,10 +55,10 @@ import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.LinkArrow;
import net.sourceforge.plantuml.cucadiagram.LinkDecor;
import net.sourceforge.plantuml.cucadiagram.LinkType;
import net.sourceforge.plantuml.descdiagram.command.CommandLinkElement;
import net.sourceforge.plantuml.descdiagram.command.Labels;
import net.sourceforge.plantuml.graphic.color.ColorParser;
import net.sourceforge.plantuml.graphic.color.ColorType;
import net.sourceforge.plantuml.objectdiagram.AbstractClassOrObjectDiagram;
@ -198,67 +195,11 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
queue = getQueueLength(arg);
}
String firstLabel = arg.get("FIRST_LABEL", 0);
String secondLabel = arg.get("SECOND_LABEL", 0);
final Labels labels = new Labels(arg);
String labelLink = null;
if (arg.get("LABEL_LINK", 0) != null) {
labelLink = arg.get("LABEL_LINK", 0);
if (firstLabel == null && secondLabel == null) {
final Pattern2 p1 = MyPattern.cmpile("^[%g]([^%g]+)[%g]([^%g]+)[%g]([^%g]+)[%g]$");
final Matcher2 m1 = p1.matcher(labelLink);
if (m1.matches()) {
firstLabel = m1.group(1);
labelLink = StringUtils.trin(StringUtils
.eventuallyRemoveStartingAndEndingDoubleQuote(StringUtils.trin(m1.group(2)), "\""));
secondLabel = m1.group(3);
} else {
final Pattern2 p2 = MyPattern.cmpile("^[%g]([^%g]+)[%g]([^%g]+)$");
final Matcher2 m2 = p2.matcher(labelLink);
if (m2.matches()) {
firstLabel = m2.group(1);
labelLink = StringUtils.trin(StringUtils
.eventuallyRemoveStartingAndEndingDoubleQuote(StringUtils.trin(m2.group(2)), "\""));
secondLabel = null;
} else {
final Pattern2 p3 = MyPattern.cmpile("^([^%g]+)[%g]([^%g]+)[%g]$");
final Matcher2 m3 = p3.matcher(labelLink);
if (m3.matches()) {
firstLabel = null;
labelLink = StringUtils.trin(StringUtils
.eventuallyRemoveStartingAndEndingDoubleQuote(StringUtils.trin(m3.group(1)), "\""));
secondLabel = m3.group(2);
}
}
}
}
labelLink = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(labelLink, "\"");
}
LinkArrow linkArrow = LinkArrow.NONE;
if ("<".equals(labelLink)) {
linkArrow = LinkArrow.BACKWARD;
labelLink = null;
} else if (">".equals(labelLink)) {
linkArrow = LinkArrow.DIRECT_NORMAL;
labelLink = null;
} else if (labelLink != null && labelLink.startsWith("< ")) {
linkArrow = LinkArrow.BACKWARD;
labelLink = StringUtils.trin(labelLink.substring(2));
} else if (labelLink != null && labelLink.startsWith("> ")) {
linkArrow = LinkArrow.DIRECT_NORMAL;
labelLink = StringUtils.trin(labelLink.substring(2));
} else if (labelLink != null && labelLink.endsWith(" >")) {
linkArrow = LinkArrow.DIRECT_NORMAL;
labelLink = StringUtils.trin(labelLink.substring(0, labelLink.length() - 2));
} else if (labelLink != null && labelLink.endsWith(" <")) {
linkArrow = LinkArrow.BACKWARD;
labelLink = StringUtils.trin(labelLink.substring(0, labelLink.length() - 2));
}
Link link = new Link(cl1, cl2, linkType, Display.getWithNewlines(labelLink), queue, firstLabel, secondLabel,
diagram.getLabeldistance(), diagram.getLabelangle(), diagram.getSkinParam().getCurrentStyleBuilder());
Link link = new Link(cl1, cl2, linkType, labels.getDisplay(), queue, labels.getFirstLabel(),
labels.getSecondLabel(), diagram.getLabeldistance(), diagram.getLabelangle(),
diagram.getSkinParam().getCurrentStyleBuilder());
if (arg.get("URL", 0) != null) {
final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
final Url url = urlBuilder.getUrl(arg.get("URL", 0));
@ -269,7 +210,7 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
if (dir == Direction.LEFT || dir == Direction.UP) {
link = link.getInv();
}
link.setLinkArrow(linkArrow);
link.setLinkArrow(labels.getLinkArrow());
link.setColors(color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet()));
link.applyStyle(arg.getLazzy("ARROW_STYLE", 0));

View File

@ -53,8 +53,8 @@ import net.sourceforge.plantuml.version.IteratorCounter2;
import net.sourceforge.plantuml.version.IteratorCounter2Impl;
/**
* Represents the textual source of some diagram. The source should start with a <code>@startfoo</code> and end with
* <code>@endfoo</code>.
* Represents the textual source of some diagram. The source should start with a
* <code>@startfoo</code> and end with <code>@endfoo</code>.
* <p>
* So the diagram does not have to be a UML one.
*
@ -64,6 +64,7 @@ import net.sourceforge.plantuml.version.IteratorCounter2Impl;
final public class UmlSource {
final private List<StringLocated> source;
final private List<StringLocated> rawSource;
public UmlSource removeInitialSkinparam() {
if (hasInitialSkinparam(source) == false) {
@ -73,7 +74,7 @@ final public class UmlSource {
while (hasInitialSkinparam(copy)) {
copy.remove(1);
}
return new UmlSource(copy);
return new UmlSource(copy, rawSource);
}
public boolean containsIgnoreCase(String searched) {
@ -86,23 +87,29 @@ final public class UmlSource {
}
private static boolean hasInitialSkinparam(final List<StringLocated> copy) {
return copy.size() > 1 && (copy.get(1).getString().startsWith("skinparam ") || copy.get(1).getString().startsWith("skinparamlocked "));
return copy.size() > 1 && (copy.get(1).getString().startsWith("skinparam ")
|| copy.get(1).getString().startsWith("skinparamlocked "));
}
private UmlSource(List<StringLocated> source) {
private UmlSource(List<StringLocated> source, List<StringLocated> rawSource) {
this.source = source;
this.rawSource = rawSource;
}
public UmlSource(List<StringLocated> data, boolean checkEndingBackslash) {
this(data, checkEndingBackslash, new ArrayList<StringLocated>());
}
/**
* Build the source from a text.
*
* @param data
* the source of the diagram
* @param checkEndingBackslash
* <code>true</code> if an ending backslash means that a line has to be collapsed with the following one.
* @param data the source of the diagram
* @param checkEndingBackslash <code>true</code> if an ending backslash means
* that a line has to be collapsed with the
* following one.
*/
public UmlSource(List<StringLocated> data, boolean checkEndingBackslash) {
this(new ArrayList<StringLocated>());
public UmlSource(List<StringLocated> data, boolean checkEndingBackslash, List<StringLocated> rawSource) {
this(new ArrayList<StringLocated>(), rawSource);
if (checkEndingBackslash) {
final StringBuilder pending = new StringBuilder();
@ -122,7 +129,8 @@ final public class UmlSource {
}
/**
* Retrieve the type of the diagram. This is based on the first line <code>@startfoo</code>.
* Retrieve the type of the diagram. This is based on the first line
* <code>@startfoo</code>.
*
* @return the type of the diagram.
*/
@ -154,6 +162,16 @@ final public class UmlSource {
return sb.toString();
}
public String getRawString() {
final StringBuilder sb = new StringBuilder();
for (StringLocated s : rawSource) {
sb.append(s.getString());
sb.append('\r');
sb.append(BackSlash.CHAR_NEWLINE);
}
return sb.toString();
}
public long seed() {
long h = 1125899906842597L; // prime
final String string = getPlainString();
@ -184,7 +202,8 @@ final public class UmlSource {
}
/**
* Check if a source diagram description is empty. Does not take comment line into account.
* Check if a source diagram description is empty. Does not take comment line
* into account.
*
* @return <code>true<code> if the diagram does not contain information.
*/
@ -207,7 +226,8 @@ final public class UmlSource {
}
/**
* Retrieve the title, if defined in the diagram source. Never return <code>null</code>.
* Retrieve the title, if defined in the diagram source. Never return
* <code>null</code>.
*
* @return
*/

View File

@ -83,7 +83,8 @@ public class CreoleHorizontalLine extends AbstractAtom implements Atom {
if (line.length() == 0) {
return TextBlockUtils.empty(0, 0);
}
final CreoleParser parser = new CreoleParser(fontConfiguration, HorizontalAlignment.LEFT, skinParam, CreoleMode.FULL);
final SheetBuilder parser = Parser.build(fontConfiguration, HorizontalAlignment.LEFT, skinParam,
CreoleMode.FULL);
final Sheet sheet = parser.createSheet(Display.getWithNewlines(line));
final TextBlock tb = new SheetBlock1(sheet, LineBreakStrategy.NONE, skinParam.getPadding());
return tb;

View File

@ -45,7 +45,7 @@ import java.util.List;
import net.sourceforge.plantuml.LineBreakStrategy;
import net.sourceforge.plantuml.creole.atom.AbstractAtom;
import net.sourceforge.plantuml.creole.atom.Atom;
import net.sourceforge.plantuml.creole.atom.AtomText;
import net.sourceforge.plantuml.creole.legacy.AtomText;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.ugraphic.UGraphic;
@ -70,7 +70,7 @@ public class Fission {
return Arrays.asList(stripe);
}
final List<Stripe> result = new ArrayList<Stripe>();
StripeSimple current = new StripeSimple(stripe.getHeader());
StripeSimpleInternal current = new StripeSimpleInternal(stripe.getLHeader());
double remainingSpace = valueMaxWidth;
for (Atom atom : noHeader()) {
while (true) {
@ -81,7 +81,7 @@ public class Fission {
remainingSpace -= widthPart1;
if (remainingSpace <= 0) {
result.add(current);
current = new StripeSimple(blank(stripe.getHeader()));
current = new StripeSimpleInternal(blank(stripe.getLHeader()));
remainingSpace = valueMaxWidth;
}
if (splitInTwo.size() == 1) {
@ -91,7 +91,7 @@ public class Fission {
if (remainingSpace < valueMaxWidth
&& atom.calculateDimension(stringBounder).getWidth() > remainingSpace) {
result.add(current);
current = new StripeSimple(blank(stripe.getHeader()));
current = new StripeSimpleInternal(blank(stripe.getLHeader()));
remainingSpace = valueMaxWidth;
}
}
@ -110,13 +110,13 @@ public class Fission {
return Arrays.asList(stripe);
}
final List<Stripe> result = new ArrayList<Stripe>();
StripeSimple current = new StripeSimple(stripe.getHeader());
StripeSimpleInternal current = new StripeSimpleInternal(stripe.getLHeader());
for (Atom atom : noHeader()) {
for (Atom atomSplitted : getSplitted(stringBounder, atom)) {
final double width = atomSplitted.calculateDimension(stringBounder).getWidth();
if (current.totalWidth + width > valueMaxWidth) {
result.add(current);
current = new StripeSimple(blank(stripe.getHeader()));
current = new StripeSimpleInternal(blank(stripe.getLHeader()));
}
current.addAtom(atomSplitted, width);
}
@ -129,7 +129,7 @@ public class Fission {
private List<Atom> noHeader() {
final List<Atom> atoms = stripe.getAtoms();
if (stripe.getHeader() == null) {
if (stripe.getLHeader() == null) {
return atoms;
}
return atoms.subList(1, atoms.size());
@ -162,21 +162,12 @@ public class Fission {
return Collections.singleton(atom);
}
// private List<Stripe> getSplittedSimple() {
// final StripeSimple result = new StripeSimple();
// for (Atom atom : stripe.getAtoms1()) {
// result.addAtom(atom, 0);
//
// }
// return Arrays.asList((Stripe) result);
// }
static class StripeSimple implements Stripe {
static class StripeSimpleInternal implements Stripe {
private final List<Atom> atoms = new ArrayList<Atom>();
private double totalWidth;
private StripeSimple(Atom header) {
private StripeSimpleInternal(Atom header) {
if (header != null) {
this.atoms.add(header);
}
@ -191,7 +182,7 @@ public class Fission {
this.totalWidth += width;
}
public Atom getHeader() {
public Atom getLHeader() {
return null;
}

View File

@ -0,0 +1,90 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.creole;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.sourceforge.plantuml.ISkinSimple;
import net.sourceforge.plantuml.creole.legacy.CreoleParser;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
public class Parser {
public static final String MONOSPACED = "monospaced";
public static SheetBuilder build(FontConfiguration fontConfiguration, HorizontalAlignment horizontalAlignment,
ISkinSimple skinParam, CreoleMode creoleMode) {
final FontConfiguration stereotype = fontConfiguration.forceFont(null, null);
return new CreoleParser(fontConfiguration, horizontalAlignment, skinParam, creoleMode, stereotype);
}
public static SheetBuilder build(FontConfiguration fontConfiguration, HorizontalAlignment horizontalAlignment,
ISkinSimple skinParam, CreoleMode creoleMode, FontConfiguration stereotype) {
return new CreoleParser(fontConfiguration, horizontalAlignment, skinParam, creoleMode, stereotype);
}
public static boolean isTreeStart(String line) {
// return false;
return line.startsWith("|_");
}
public static double getScale(String s, double def) {
if (s == null) {
return def;
}
final Pattern p = Pattern.compile("(?:scale=|\\*)([0-9.]+)");
final Matcher m = p.matcher(s);
if (m.find()) {
return Double.parseDouble(m.group(1));
}
return def;
}
public static String getColor(String s) {
if (s == null) {
return null;
}
final Pattern p = Pattern.compile("color[= :](#[0-9a-fA-F]{6}|\\w+)");
final Matcher m = p.matcher(s);
if (m.find()) {
return m.group(1);
}
return null;
}
}

View File

@ -45,6 +45,7 @@ import java.util.Map;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.LineBreakStrategy;
import net.sourceforge.plantuml.creole.atom.Atom;
import net.sourceforge.plantuml.creole.legacy.StripeSimple;
import net.sourceforge.plantuml.graphic.AbstractTextBlock;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.InnerStrategy;

View File

@ -0,0 +1,44 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.creole;
import net.sourceforge.plantuml.cucadiagram.Display;
public interface SheetBuilder {
public Sheet createSheet(Display display);
}

View File

@ -41,7 +41,7 @@ import net.sourceforge.plantuml.creole.atom.Atom;
public interface Stripe {
public Atom getHeader();
public Atom getLHeader();
public List<Atom> getAtoms();

View File

@ -36,8 +36,8 @@
package net.sourceforge.plantuml.creole;
import net.sourceforge.plantuml.creole.atom.Atom;
import net.sourceforge.plantuml.creole.atom.AtomText;
import net.sourceforge.plantuml.creole.atom.Bullet;
import net.sourceforge.plantuml.creole.legacy.AtomText;
import net.sourceforge.plantuml.graphic.FontConfiguration;
public class StripeStyle {

View File

@ -37,6 +37,5 @@ package net.sourceforge.plantuml.creole;
import net.sourceforge.plantuml.ugraphic.UShape;
public interface UCreole extends UShape {
}

View File

@ -53,6 +53,7 @@ import net.sourceforge.plantuml.FileSystem;
import net.sourceforge.plantuml.FileUtils;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.code.Base64Coder;
import net.sourceforge.plantuml.creole.legacy.AtomText;
import net.sourceforge.plantuml.flashcode.FlashCodeFactory;
import net.sourceforge.plantuml.flashcode.FlashCodeUtils;
import net.sourceforge.plantuml.graphic.FontConfiguration;
@ -195,7 +196,7 @@ public class AtomImg extends AbstractAtom implements Atom {
}
ug.draw(new UImage(rawFileName, image).scale(scale));
if (url != null) {
ug.closeAction();
ug.closeUrl();
}
}

View File

@ -79,7 +79,7 @@ public class AtomOpenIcon extends AbstractAtom implements Atom {
}
asTextBlock().drawU(ug);
if (url != null) {
ug.closeAction();
ug.closeUrl();
}
}

View File

@ -72,7 +72,7 @@ public class AtomSprite extends AbstractAtom implements Atom {
}
sprite.asTextBlock(color, scale).drawU(ug);
if (url != null) {
ug.closeAction();
ug.closeUrl();
}
}

View File

@ -107,8 +107,8 @@ public class AtomTable extends AbstractAtom implements Atom {
final double y2 = getStartingY(i + 1);
final double x1 = getStartingX(0);
final double x2 = getStartingX(getNbCols());
ug.apply(new HColorNone()).apply(line.lineBackColor.bg())
.apply(new UTranslate(x1, y1)).draw(new URectangle(x2 - x1, y2 - y1));
ug.apply(new HColorNone()).apply(line.lineBackColor.bg()).apply(new UTranslate(x1, y1))
.draw(new URectangle(x2 - x1, y2 - y1));
}
for (int j = 0; j < getNbCols(); j++) {
if (j >= line.cells.size()) {
@ -126,8 +126,8 @@ public class AtomTable extends AbstractAtom implements Atom {
if (cellBackColor != null) {
final double y1 = getStartingY(i);
final double y2 = getStartingY(i + 1);
ug.apply(new HColorNone()).apply(cellBackColor.bg())
.apply(new UTranslate(x1, y1)).draw(new URectangle(x2 - x1, y2 - y1));
ug.apply(new HColorNone()).apply(cellBackColor.bg()).apply(new UTranslate(x1, y1))
.draw(new URectangle(x2 - x1, y2 - y1));
}
final Position pos = positions.get(cell);
final Dimension2D dimCell = cell.calculateDimension(ug.getStringBounder());

View File

@ -105,5 +105,4 @@ public class Bullet extends AbstractAtom implements Atom {
return new Dimension2DDouble(getWidth(stringBounder), 3);
}
}

View File

@ -35,7 +35,7 @@
*/
package net.sourceforge.plantuml.creole.command;
import net.sourceforge.plantuml.creole.StripeSimple;
import net.sourceforge.plantuml.creole.legacy.StripeSimple;
public interface Command {

View File

@ -38,7 +38,7 @@ package net.sourceforge.plantuml.creole.command;
import net.sourceforge.plantuml.command.regex.Matcher2;
import net.sourceforge.plantuml.command.regex.MyPattern;
import net.sourceforge.plantuml.command.regex.Pattern2;
import net.sourceforge.plantuml.creole.StripeSimple;
import net.sourceforge.plantuml.creole.legacy.StripeSimple;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorSet;

View File

@ -38,7 +38,7 @@ package net.sourceforge.plantuml.creole.command;
import net.sourceforge.plantuml.command.regex.Matcher2;
import net.sourceforge.plantuml.command.regex.MyPattern;
import net.sourceforge.plantuml.command.regex.Pattern2;
import net.sourceforge.plantuml.creole.StripeSimple;
import net.sourceforge.plantuml.creole.legacy.StripeSimple;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.Splitter;
import net.sourceforge.plantuml.ugraphic.color.HColor;

View File

@ -38,7 +38,7 @@ package net.sourceforge.plantuml.creole.command;
import net.sourceforge.plantuml.command.regex.Matcher2;
import net.sourceforge.plantuml.command.regex.MyPattern;
import net.sourceforge.plantuml.command.regex.Pattern2;
import net.sourceforge.plantuml.creole.StripeSimple;
import net.sourceforge.plantuml.creole.legacy.StripeSimple;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.FontPosition;
@ -53,12 +53,14 @@ public class CommandCreoleExposantChange implements Command {
}
public static Command create(FontPosition position) {
return new CommandCreoleExposantChange("^(?i)(" + "\\<" + position.getHtmlTag() + "\\>" + "(.*?)\\</"
+ position.getHtmlTag() + "\\>)", position);
return new CommandCreoleExposantChange(
"^(?i)(" + "\\<" + position.getHtmlTag() + "\\>" + "(.*?)\\</" + position.getHtmlTag() + "\\>)",
position);
}
// public static Command createLegacyEol(FontStyle style) {
// return new CommandCreoleExposantChange("^(" + style.getActivationPattern() + "(.+))$", style);
// return new CommandCreoleExposantChange("^(" + style.getActivationPattern() +
// "(.+))$", style);
// }
public int matchingSize(String line) {

View File

@ -38,7 +38,7 @@ package net.sourceforge.plantuml.creole.command;
import net.sourceforge.plantuml.command.regex.Matcher2;
import net.sourceforge.plantuml.command.regex.MyPattern;
import net.sourceforge.plantuml.command.regex.Pattern2;
import net.sourceforge.plantuml.creole.StripeSimple;
import net.sourceforge.plantuml.creole.legacy.StripeSimple;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.Splitter;

View File

@ -35,14 +35,12 @@
*/
package net.sourceforge.plantuml.creole.command;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.command.regex.Matcher2;
import net.sourceforge.plantuml.command.regex.MyPattern;
import net.sourceforge.plantuml.command.regex.Pattern2;
import net.sourceforge.plantuml.creole.StripeSimple;
import net.sourceforge.plantuml.creole.Parser;
import net.sourceforge.plantuml.creole.legacy.StripeSimple;
import net.sourceforge.plantuml.graphic.Splitter;
public class CommandCreoleImg implements Command {
@ -71,7 +69,7 @@ public class CommandCreoleImg implements Command {
throw new IllegalStateException();
}
String src = m.group(2);
final double scale = getScale(m.group(3), 1);
final double scale = Parser.getScale(m.group(3), 1);
if (src.toLowerCase().startsWith("src=")) {
src = src.substring(4);
}
@ -80,28 +78,4 @@ public class CommandCreoleImg implements Command {
return line.substring(m.group(1).length());
}
public static double getScale(String s, double def) {
if (s == null) {
return def;
}
final Pattern p = Pattern.compile("(?:scale=|\\*)([0-9.]+)");
final Matcher m = p.matcher(s);
if (m.find()) {
return Double.parseDouble(m.group(1));
}
return def;
}
public static String getColor(String s) {
if (s == null) {
return null;
}
final Pattern p = Pattern.compile("color[= :](#[0-9a-fA-F]{6}|\\w+)");
final Matcher m = p.matcher(s);
if (m.find()) {
return m.group(1);
}
return null;
}
}

View File

@ -38,7 +38,7 @@ package net.sourceforge.plantuml.creole.command;
import net.sourceforge.plantuml.command.regex.Matcher2;
import net.sourceforge.plantuml.command.regex.MyPattern;
import net.sourceforge.plantuml.command.regex.Pattern2;
import net.sourceforge.plantuml.creole.StripeSimple;
import net.sourceforge.plantuml.creole.legacy.StripeSimple;
import net.sourceforge.plantuml.graphic.Splitter;
import net.sourceforge.plantuml.math.ScientificEquationSafe;

View File

@ -38,7 +38,7 @@ package net.sourceforge.plantuml.creole.command;
import net.sourceforge.plantuml.command.regex.Matcher2;
import net.sourceforge.plantuml.command.regex.MyPattern;
import net.sourceforge.plantuml.command.regex.Pattern2;
import net.sourceforge.plantuml.creole.StripeSimple;
import net.sourceforge.plantuml.creole.legacy.StripeSimple;
import net.sourceforge.plantuml.graphic.Splitter;
import net.sourceforge.plantuml.math.ScientificEquationSafe;

View File

@ -38,13 +38,11 @@ package net.sourceforge.plantuml.creole.command;
import net.sourceforge.plantuml.command.regex.Matcher2;
import net.sourceforge.plantuml.command.regex.MyPattern;
import net.sourceforge.plantuml.command.regex.Pattern2;
import net.sourceforge.plantuml.creole.StripeSimple;
import net.sourceforge.plantuml.creole.legacy.StripeSimple;
import net.sourceforge.plantuml.graphic.FontConfiguration;
public class CommandCreoleMonospaced implements Command {
public static final String MONOSPACED = "monospaced";
private final Pattern2 pattern;
private final String monospacedFamily;

View File

@ -38,7 +38,8 @@ package net.sourceforge.plantuml.creole.command;
import net.sourceforge.plantuml.command.regex.Matcher2;
import net.sourceforge.plantuml.command.regex.MyPattern;
import net.sourceforge.plantuml.command.regex.Pattern2;
import net.sourceforge.plantuml.creole.StripeSimple;
import net.sourceforge.plantuml.creole.Parser;
import net.sourceforge.plantuml.creole.legacy.StripeSimple;
import net.sourceforge.plantuml.graphic.Splitter;
import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorSet;
@ -71,8 +72,8 @@ public class CommandCreoleOpenIcon implements Command {
throw new IllegalStateException();
}
final String src = m.group(2);
final double scale = CommandCreoleImg.getScale(m.group(3), 1);
final String colorName = CommandCreoleImg.getColor(m.group(3));
final double scale = Parser.getScale(m.group(3), 1);
final String colorName = Parser.getColor(m.group(3));
HColor color = null;
if (colorName != null) {
color = colorSet.getColorIfValid(colorName);

View File

@ -38,7 +38,8 @@ package net.sourceforge.plantuml.creole.command;
import net.sourceforge.plantuml.command.regex.Matcher2;
import net.sourceforge.plantuml.command.regex.MyPattern;
import net.sourceforge.plantuml.command.regex.Pattern2;
import net.sourceforge.plantuml.creole.StripeSimple;
import net.sourceforge.plantuml.creole.Parser;
import net.sourceforge.plantuml.creole.legacy.StripeSimple;
import net.sourceforge.plantuml.graphic.Splitter;
public class CommandCreoleQrcode implements Command {
@ -67,7 +68,7 @@ public class CommandCreoleQrcode implements Command {
throw new IllegalStateException();
}
final String src = m.group(2);
final double scale = CommandCreoleImg.getScale(m.group(3), 3);
final double scale = Parser.getScale(m.group(3), 3);
stripe.addQrcode(src, scale);
return line.substring(m.group(1).length());
}

View File

@ -38,7 +38,7 @@ package net.sourceforge.plantuml.creole.command;
import net.sourceforge.plantuml.command.regex.Matcher2;
import net.sourceforge.plantuml.command.regex.MyPattern;
import net.sourceforge.plantuml.command.regex.Pattern2;
import net.sourceforge.plantuml.creole.StripeSimple;
import net.sourceforge.plantuml.creole.legacy.StripeSimple;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.Splitter;

View File

@ -38,7 +38,7 @@ package net.sourceforge.plantuml.creole.command;
import net.sourceforge.plantuml.command.regex.Matcher2;
import net.sourceforge.plantuml.command.regex.MyPattern;
import net.sourceforge.plantuml.command.regex.Pattern2;
import net.sourceforge.plantuml.creole.StripeSimple;
import net.sourceforge.plantuml.creole.legacy.StripeSimple;
public class CommandCreoleSpace implements Command {

View File

@ -38,7 +38,8 @@ package net.sourceforge.plantuml.creole.command;
import net.sourceforge.plantuml.command.regex.Matcher2;
import net.sourceforge.plantuml.command.regex.MyPattern;
import net.sourceforge.plantuml.command.regex.Pattern2;
import net.sourceforge.plantuml.creole.StripeSimple;
import net.sourceforge.plantuml.creole.Parser;
import net.sourceforge.plantuml.creole.legacy.StripeSimple;
import net.sourceforge.plantuml.graphic.Splitter;
import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorSet;
@ -71,8 +72,8 @@ public class CommandCreoleSprite implements Command {
throw new IllegalStateException();
}
final String src = m.group(2);
final double scale = CommandCreoleImg.getScale(m.group(3), 1);
final String colorName = CommandCreoleImg.getColor(m.group(3));
final double scale = Parser.getScale(m.group(3), 1);
final String colorName = Parser.getColor(m.group(3));
HColor color = null;
if (colorName != null) {
color = colorSet.getColorIfValid(colorName);

View File

@ -38,7 +38,7 @@ package net.sourceforge.plantuml.creole.command;
import net.sourceforge.plantuml.command.regex.Matcher2;
import net.sourceforge.plantuml.command.regex.MyPattern;
import net.sourceforge.plantuml.command.regex.Pattern2;
import net.sourceforge.plantuml.creole.StripeSimple;
import net.sourceforge.plantuml.creole.legacy.StripeSimple;
import net.sourceforge.plantuml.graphic.AddStyle;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.FontStyle;
@ -56,8 +56,9 @@ public class CommandCreoleStyle implements Command {
}
public static Command createLegacy(FontStyle style) {
return new CommandCreoleStyle("^((" + style.getActivationPattern() + ")(.+?)" + style.getDeactivationPattern()
+ ")", style, style.canHaveExtendedColor());
return new CommandCreoleStyle(
"^((" + style.getActivationPattern() + ")(.+?)" + style.getDeactivationPattern() + ")", style,
style.canHaveExtendedColor());
}
public static Command createLegacyEol(FontStyle style) {

View File

@ -38,7 +38,7 @@ package net.sourceforge.plantuml.creole.command;
import net.sourceforge.plantuml.command.regex.Matcher2;
import net.sourceforge.plantuml.command.regex.MyPattern;
import net.sourceforge.plantuml.command.regex.Pattern2;
import net.sourceforge.plantuml.creole.StripeSimple;
import net.sourceforge.plantuml.creole.legacy.StripeSimple;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.Splitter;
import net.sourceforge.plantuml.graphic.SvgAttributes;

View File

@ -42,7 +42,7 @@ import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
import net.sourceforge.plantuml.command.regex.Matcher2;
import net.sourceforge.plantuml.command.regex.MyPattern;
import net.sourceforge.plantuml.command.regex.Pattern2;
import net.sourceforge.plantuml.creole.StripeSimple;
import net.sourceforge.plantuml.creole.legacy.StripeSimple;
public class CommandCreoleUrl implements Command {

View File

@ -33,7 +33,7 @@
*
*
*/
package net.sourceforge.plantuml.creole.atom;
package net.sourceforge.plantuml.creole.legacy;
import java.awt.font.LineMetrics;
import java.awt.geom.Dimension2D;
@ -53,7 +53,14 @@ import net.sourceforge.plantuml.LineBreakStrategy;
import net.sourceforge.plantuml.Log;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.creole.command.CommandCreoleImg;
import net.sourceforge.plantuml.creole.Parser;
import net.sourceforge.plantuml.creole.atom.AbstractAtom;
import net.sourceforge.plantuml.creole.atom.Atom;
import net.sourceforge.plantuml.creole.atom.AtomHorizontalTexts;
import net.sourceforge.plantuml.creole.atom.AtomImg;
import net.sourceforge.plantuml.creole.atom.AtomOpenIcon;
import net.sourceforge.plantuml.creole.atom.AtomSprite;
import net.sourceforge.plantuml.creole.atom.AtomVerticalTexts;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.ImgValign;
@ -124,17 +131,17 @@ public class AtomText extends AbstractAtom implements Atom {
if (valOpenicon != null) {
final OpenIcon openIcon = OpenIcon.retrieve(valOpenicon);
if (openIcon != null) {
final double scale = CommandCreoleImg.getScale(m.group(2), 1);
final double scale = Parser.getScale(m.group(2), 1);
result.add(new AtomOpenIcon(null, scale, openIcon, fontConfiguration, url));
}
} else if (valSprite != null) {
final Sprite sprite = skinSimple.getSprite(valSprite);
if (sprite != null) {
final double scale = CommandCreoleImg.getScale(m.group(4), 1);
final double scale = Parser.getScale(m.group(4), 1);
result.add(new AtomSprite(null, scale, fontConfiguration, sprite, url));
}
} else if (valImg != null) {
final double scale = CommandCreoleImg.getScale(m.group(6), 1);
final double scale = Parser.getScale(m.group(6), 1);
result.add(AtomImg.create(valImg, ImgValign.TOP, 0, scale, url));
}
@ -271,7 +278,7 @@ public class AtomText extends AbstractAtom implements Atom {
}
}
if (url != null) {
ug.closeAction();
ug.closeUrl();
}
}

View File

@ -33,7 +33,7 @@
*
*
*/
package net.sourceforge.plantuml.creole;
package net.sourceforge.plantuml.creole.legacy;
import java.util.Arrays;
import java.util.List;
@ -41,28 +41,29 @@ import java.util.List;
import net.sourceforge.plantuml.EmbeddedDiagram;
import net.sourceforge.plantuml.ISkinSimple;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.creole.CreoleContext;
import net.sourceforge.plantuml.creole.CreoleMode;
import net.sourceforge.plantuml.creole.Parser;
import net.sourceforge.plantuml.creole.Sheet;
import net.sourceforge.plantuml.creole.SheetBuilder;
import net.sourceforge.plantuml.creole.Stripe;
import net.sourceforge.plantuml.creole.atom.Atom;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
public class CreoleParser {
public class CreoleParser implements SheetBuilder {
private final FontConfiguration fontConfiguration;
private final ISkinSimple skinParam;
private final HorizontalAlignment horizontalAlignment;
private final CreoleMode creoleMode;
private final FontConfiguration stereotypeConfiguration;
private final FontConfiguration stereotype;
public CreoleParser(FontConfiguration fontConfiguration, HorizontalAlignment horizontalAlignment,
ISkinSimple skinParam, CreoleMode creoleMode) {
this(fontConfiguration, horizontalAlignment, skinParam, creoleMode, fontConfiguration.forceFont(null, null));
}
public CreoleParser(FontConfiguration fontConfiguration, HorizontalAlignment horizontalAlignment,
ISkinSimple skinParam, CreoleMode creoleMode, FontConfiguration stereotypeConfiguration) {
this.stereotypeConfiguration = stereotypeConfiguration;
ISkinSimple skinParam, CreoleMode creoleMode, FontConfiguration stereotype) {
this.stereotype = stereotype;
this.creoleMode = creoleMode;
this.fontConfiguration = fontConfiguration;
this.skinParam = skinParam;
@ -78,13 +79,13 @@ public class CreoleParser {
final StripeTable table = (StripeTable) lastStripe;
table.analyzeAndAddLine(line);
return null;
} else if (lastStripe instanceof StripeTree && isTreeStart(StringUtils.trinNoTrace(line))) {
} else if (lastStripe instanceof StripeTree && Parser.isTreeStart(StringUtils.trinNoTrace(line))) {
final StripeTree tree = (StripeTree) lastStripe;
tree.analyzeAndAdd(line);
return null;
} else if (isTableLine(line)) {
return new StripeTable(fontConfiguration, skinParam, line);
} else if (isTreeStart(line)) {
} else if (Parser.isTreeStart(line)) {
return new StripeTree(fontConfiguration, skinParam, line);
}
return new CreoleStripeSimpleParser(line, context, fontConfiguration, skinParam, creoleMode)
@ -99,11 +100,6 @@ public class CreoleParser {
return line.matches("^\\=?\\s*(\\<#\\w+(,#?\\w+)?\\>).*");
}
public static boolean isTreeStart(String line) {
// return false;
return line.startsWith("|_");
}
public Sheet createSheet(Display display) {
final Sheet sheet = new Sheet(horizontalAlignment);
if (Display.isNull(display) == false) {
@ -113,7 +109,7 @@ public class CreoleParser {
if (cs instanceof EmbeddedDiagram) {
final Atom atom = ((EmbeddedDiagram) cs).asDraw(skinParam);
stripe = new Stripe() {
public Atom getHeader() {
public Atom getLHeader() {
return null;
}
@ -123,7 +119,7 @@ public class CreoleParser {
};
} else if (cs instanceof Stereotype) {
for (String st : ((Stereotype) cs).getLabels(skinParam.guillemet())) {
sheet.add(createStripe(st, context, sheet.getLastStripe(), stereotypeConfiguration));
sheet.add(createStripe(st, context, sheet.getLastStripe(), stereotype));
}
continue;
} else {

View File

@ -33,7 +33,7 @@
*
*
*/
package net.sourceforge.plantuml.creole;
package net.sourceforge.plantuml.creole.legacy;
import net.sourceforge.plantuml.BackSlash;
import net.sourceforge.plantuml.ISkinSimple;
@ -41,6 +41,11 @@ import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.command.regex.Matcher2;
import net.sourceforge.plantuml.command.regex.MyPattern;
import net.sourceforge.plantuml.command.regex.Pattern2;
import net.sourceforge.plantuml.creole.CreoleContext;
import net.sourceforge.plantuml.creole.CreoleMode;
import net.sourceforge.plantuml.creole.Stripe;
import net.sourceforge.plantuml.creole.StripeStyle;
import net.sourceforge.plantuml.creole.StripeStyleType;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.utils.CharHidder;

View File

@ -33,7 +33,7 @@
*
*
*/
package net.sourceforge.plantuml.creole;
package net.sourceforge.plantuml.creole.legacy;
import java.io.IOException;
import java.io.OutputStream;
@ -47,6 +47,10 @@ import net.sourceforge.plantuml.SkinParam;
import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.creole.CreoleMode;
import net.sourceforge.plantuml.creole.Parser;
import net.sourceforge.plantuml.creole.Sheet;
import net.sourceforge.plantuml.creole.SheetBlock1;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
@ -75,17 +79,17 @@ public class PSystemCreole extends AbstractPSystem {
final Display display = Display.create(lines);
final UFont font = UFont.serif(14);
final FontConfiguration fontConfiguration = FontConfiguration.blackBlueTrue(font);
final Sheet sheet = new CreoleParser(fontConfiguration, HorizontalAlignment.LEFT, SkinParam.create(UmlDiagramType.SEQUENCE), CreoleMode.FULL)
.createSheet(display);
final Sheet sheet = Parser.build(fontConfiguration, HorizontalAlignment.LEFT,
SkinParam.create(UmlDiagramType.SEQUENCE), CreoleMode.FULL).createSheet(display);
final SheetBlock1 sheetBlock = new SheetBlock1(sheet, LineBreakStrategy.NONE, 0);
final ImageBuilder builder = ImageBuilder.buildA(new ColorMapperIdentity(), false, null, null, null, 1.0,
null);
final ImageBuilder builder = ImageBuilder.buildA(new ColorMapperIdentity(), false, null, null, null, 1.0, null);
builder.setUDrawable(sheetBlock);
return builder.writeImageTOBEMOVED(fileFormat, seed, os);
// final Dimension2D dim = TextBlockUtils.getDimension(sheetBlock);
// final UGraphic2 ug = fileFormat.createUGraphic(new ColorMapperIdentity(), 1, dim, null, false);
// final UGraphic2 ug = fileFormat.createUGraphic(new ColorMapperIdentity(), 1,
// dim, null, false);
// // sheetBlock.drawU(ug.apply(UTranslate.dy(10)));
// sheetBlock.drawU(ug);
// ug.writeImageTOBEMOVED(os, null, 96);

View File

@ -33,7 +33,7 @@
*
*
*/
package net.sourceforge.plantuml.creole;
package net.sourceforge.plantuml.creole.legacy;
import net.sourceforge.plantuml.command.PSystemBasicFactory;
import net.sourceforge.plantuml.core.DiagramType;

View File

@ -33,7 +33,7 @@
*
*
*/
package net.sourceforge.plantuml.creole;
package net.sourceforge.plantuml.creole.legacy;
import java.util.ArrayList;
import java.util.Collections;
@ -42,13 +42,18 @@ import java.util.List;
import net.sourceforge.plantuml.BackSlash;
import net.sourceforge.plantuml.ISkinSimple;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.creole.CreoleContext;
import net.sourceforge.plantuml.creole.CreoleHorizontalLine;
import net.sourceforge.plantuml.creole.CreoleMode;
import net.sourceforge.plantuml.creole.Stripe;
import net.sourceforge.plantuml.creole.StripeStyle;
import net.sourceforge.plantuml.creole.StripeStyleType;
import net.sourceforge.plantuml.creole.atom.Atom;
import net.sourceforge.plantuml.creole.atom.AtomImg;
import net.sourceforge.plantuml.creole.atom.AtomMath;
import net.sourceforge.plantuml.creole.atom.AtomOpenIcon;
import net.sourceforge.plantuml.creole.atom.AtomSpace;
import net.sourceforge.plantuml.creole.atom.AtomSprite;
import net.sourceforge.plantuml.creole.atom.AtomText;
import net.sourceforge.plantuml.creole.command.Command;
import net.sourceforge.plantuml.creole.command.CommandCreoleColorAndSizeChange;
import net.sourceforge.plantuml.creole.command.CommandCreoleColorChange;
@ -103,7 +108,7 @@ public class StripeSimple implements Stripe {
return super.toString() + " " + atoms.toString();
}
public Atom getHeader() {
public Atom getLHeader() {
return header;
}

View File

@ -33,7 +33,7 @@
*
*
*/
package net.sourceforge.plantuml.creole;
package net.sourceforge.plantuml.creole.legacy;
import java.util.ArrayList;
import java.util.Collections;
@ -43,6 +43,13 @@ import java.util.StringTokenizer;
import net.sourceforge.plantuml.BackSlash;
import net.sourceforge.plantuml.ISkinSimple;
import net.sourceforge.plantuml.LineBreakStrategy;
import net.sourceforge.plantuml.creole.CreoleContext;
import net.sourceforge.plantuml.creole.CreoleMode;
import net.sourceforge.plantuml.creole.Sheet;
import net.sourceforge.plantuml.creole.SheetBlock1;
import net.sourceforge.plantuml.creole.Stripe;
import net.sourceforge.plantuml.creole.StripeStyle;
import net.sourceforge.plantuml.creole.StripeStyleType;
import net.sourceforge.plantuml.creole.atom.Atom;
import net.sourceforge.plantuml.creole.atom.AtomTable;
import net.sourceforge.plantuml.creole.atom.AtomWithMargin;
@ -78,7 +85,7 @@ public class StripeTable implements Stripe {
return Collections.<Atom>singletonList(marged);
}
public Atom getHeader() {
public Atom getLHeader() {
return null;
}

View File

@ -33,12 +33,17 @@
*
*
*/
package net.sourceforge.plantuml.creole;
package net.sourceforge.plantuml.creole.legacy;
import java.util.Collections;
import java.util.List;
import net.sourceforge.plantuml.ISkinSimple;
import net.sourceforge.plantuml.creole.CreoleContext;
import net.sourceforge.plantuml.creole.CreoleMode;
import net.sourceforge.plantuml.creole.Stripe;
import net.sourceforge.plantuml.creole.StripeStyle;
import net.sourceforge.plantuml.creole.StripeStyleType;
import net.sourceforge.plantuml.creole.atom.Atom;
import net.sourceforge.plantuml.creole.atom.AtomTree;
import net.sourceforge.plantuml.creole.atom.AtomWithMargin;
@ -64,7 +69,7 @@ public class StripeTree implements Stripe {
return Collections.<Atom>singletonList(marged);
}
public Atom getHeader() {
public Atom getLHeader() {
return null;
}

View File

@ -0,0 +1,289 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.creole.rosetta;
import java.awt.font.LineMetrics;
import java.awt.geom.Dimension2D;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;
import net.sourceforge.plantuml.BackSlash;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.LineBreakStrategy;
import net.sourceforge.plantuml.Log;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.creole.atom.AbstractAtom;
import net.sourceforge.plantuml.creole.atom.Atom;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UText;
import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.color.HColor;
import net.sourceforge.plantuml.ugraphic.color.HColorAutomatic;
import net.sourceforge.plantuml.ugraphic.color.HColorSimple;
import net.sourceforge.plantuml.utils.CharHidder;
public class AtomText22 extends AbstractAtom implements Atom {
interface DelayedDouble {
public double getDouble(StringBounder stringBounder);
}
private static DelayedDouble ZERO = new DelayedDouble() {
public double getDouble(StringBounder stringBounder) {
return 0;
}
};
private final FontConfiguration fontConfiguration;
private final String text;
private final DelayedDouble marginLeft;
private final DelayedDouble marginRight;
private final Url url;
public static Atom create(String text, FontConfiguration fontConfiguration) {
return new AtomText22(text, fontConfiguration, null, ZERO, ZERO);
}
@Override
public String toString() {
return text + " " + fontConfiguration;
}
private AtomText22(String text, FontConfiguration style, Url url, DelayedDouble marginLeft,
DelayedDouble marginRight) {
if (text.contains("" + BackSlash.hiddenNewLine())) {
throw new IllegalArgumentException(text);
}
this.marginLeft = marginLeft;
this.marginRight = marginRight;
this.text = CharHidder.unhide(text);
// this.text = StringUtils.manageTildeArobaseStart(StringUtils.manageUnicodeNotationUplus(
// StringUtils.manageAmpDiese(StringUtils.showComparatorCharacters(CharHidder.unhide(text)))));
this.fontConfiguration = style;
this.url = url;
}
public FontConfiguration getFontConfiguration() {
return fontConfiguration;
}
public Dimension2D calculateDimension(StringBounder stringBounder) {
final Dimension2D rect = stringBounder.calculateDimension(fontConfiguration.getFont(), text);
Log.debug("g2d=" + rect);
Log.debug("Size for " + text + " is " + rect);
double h = rect.getHeight();
if (h < 10) {
h = 10;
}
final double width = text.indexOf('\t') == -1 ? rect.getWidth() : getWidth(stringBounder);
final double left = marginLeft.getDouble(stringBounder);
final double right = marginRight.getDouble(stringBounder);
return new Dimension2DDouble(width + left + right, h);
}
private double getDescent() {
final LineMetrics fm = TextBlockUtils.getLineMetrics(fontConfiguration.getFont(), text);
final double descent = fm.getDescent();
return descent;
}
public double getFontSize2D() {
return fontConfiguration.getFont().getSize2D();
}
public double getStartingAltitude(StringBounder stringBounder) {
return fontConfiguration.getSpace();
}
private double getTabSize(StringBounder stringBounder) {
return stringBounder.calculateDimension(fontConfiguration.getFont(), tabString()).getWidth();
}
private String tabString() {
final int nb = fontConfiguration.getTabSize();
if (nb >= 1 && nb < 7) {
return " ".substring(0, nb);
}
return " ";
}
public void drawU(UGraphic ug) {
if (url != null) {
ug.startUrl(url);
}
if (ug.matchesProperty("SPECIALTXT")) {
ug.draw(this);
throw new UnsupportedOperationException("SPECIALTXT");
} else {
HColor textColor = fontConfiguration.getColor();
FontConfiguration useFontConfiguration = fontConfiguration;
if (textColor instanceof HColorAutomatic && ug.getParam().getBackcolor() != null) {
textColor = ((HColorSimple) ug.getParam().getBackcolor()).opposite();
useFontConfiguration = fontConfiguration.changeColor(textColor);
}
if (marginLeft != ZERO) {
ug = ug.apply(UTranslate.dx(marginLeft.getDouble(ug.getStringBounder())));
}
final StringTokenizer tokenizer = new StringTokenizer(text, "\t", true);
double x = 0;
// final int ypos = fontConfiguration.getSpace();
final Dimension2D rect = ug.getStringBounder().calculateDimension(fontConfiguration.getFont(), text);
final double descent = getDescent();
final double ypos = rect.getHeight() - descent;
if (tokenizer.hasMoreTokens()) {
final double tabSize = getTabSize(ug.getStringBounder());
while (tokenizer.hasMoreTokens()) {
final String s = tokenizer.nextToken();
if (s.equals("\t")) {
final double remainder = x % tabSize;
x += tabSize - remainder;
} else {
final UText utext = new UText(s, useFontConfiguration);
final Dimension2D dim = ug.getStringBounder().calculateDimension(fontConfiguration.getFont(),
s);
ug.apply(new UTranslate(x, ypos)).draw(utext);
x += dim.getWidth();
}
}
}
}
if (url != null) {
ug.closeUrl();
}
}
private double getWidth(StringBounder stringBounder) {
return getWidth(stringBounder, text);
}
private double getWidth(StringBounder stringBounder, String text) {
final StringTokenizer tokenizer = new StringTokenizer(text, "\t", true);
final double tabSize = getTabSize(stringBounder);
double x = 0;
while (tokenizer.hasMoreTokens()) {
final String s = tokenizer.nextToken();
if (s.equals("\t")) {
final double remainder = x % tabSize;
x += tabSize - remainder;
} else {
final Dimension2D dim = stringBounder.calculateDimension(fontConfiguration.getFont(), s);
x += dim.getWidth();
}
}
return x;
}
public List<AtomText22> getSplitted(StringBounder stringBounder, LineBreakStrategy maxWidthAsString) {
final double maxWidth = maxWidthAsString.getMaxWidth();
if (maxWidth == 0) {
throw new IllegalStateException();
}
final List<AtomText22> result = new ArrayList<AtomText22>();
final StringTokenizer st = new StringTokenizer(text, " ", true);
final StringBuilder currentLine = new StringBuilder();
while (st.hasMoreTokens()) {
final String token1 = st.nextToken();
for (String tmp : Arrays.asList(token1)) {
final double w = getWidth(stringBounder, currentLine + tmp);
if (w > maxWidth) {
result.add(new AtomText22(currentLine.toString(), fontConfiguration, url, marginLeft, marginRight));
currentLine.setLength(0);
if (tmp.startsWith(" ") == false) {
currentLine.append(tmp);
}
} else {
currentLine.append(tmp);
}
}
}
result.add(new AtomText22(currentLine.toString(), fontConfiguration, url, marginLeft, marginRight));
return Collections.unmodifiableList(result);
}
@Override
public List<Atom> splitInTwo(StringBounder stringBounder, double width) {
final StringBuilder tmp = new StringBuilder();
for (String token : splitted()) {
if (tmp.length() > 0 && getWidth(stringBounder, tmp.toString() + token) > width) {
final Atom part1 = new AtomText22(tmp.toString(), fontConfiguration, url, marginLeft, marginRight);
String remain = text.substring(tmp.length());
while (remain.startsWith(" ")) {
remain = remain.substring(1);
}
final Atom part2 = new AtomText22(remain, fontConfiguration, url, marginLeft, marginRight);
return Arrays.asList(part1, part2);
}
tmp.append(token);
}
return Collections.singletonList((Atom) this);
}
private Collection<String> splitted() {
final List<String> result = new ArrayList<String>();
for (int i = 0; i < text.length(); i++) {
final char ch = text.charAt(i);
if (Character.isLetter(ch)) {
final StringBuilder tmp = new StringBuilder();
tmp.append(ch);
while (i + 1 < text.length() && Character.isLetter(text.charAt(i + 1))) {
i++;
tmp.append(text.charAt(i));
}
result.add(tmp.toString());
} else {
result.add("" + text.charAt(i));
}
}
return result;
}
public final String getText() {
return text;
}
}

View File

@ -0,0 +1,78 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.creole.rosetta;
import net.sourceforge.plantuml.ISkinSimple;
import net.sourceforge.plantuml.creole.CreoleMode;
import net.sourceforge.plantuml.creole.Sheet;
import net.sourceforge.plantuml.creole.SheetBuilder;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
public class CreoleParser2 implements SheetBuilder {
private final FontConfiguration fontConfiguration;
private final ISkinSimple skinParam;
private final HorizontalAlignment horizontalAlignment;
private final CreoleMode creoleMode;
private final FontConfiguration stereotype;
public CreoleParser2(FontConfiguration fontConfiguration, HorizontalAlignment horizontalAlignment,
ISkinSimple skinParam, CreoleMode creoleMode, FontConfiguration stereotype) {
this.stereotype = stereotype;
this.creoleMode = creoleMode;
this.fontConfiguration = fontConfiguration;
this.skinParam = skinParam;
if (skinParam == null) {
throw new IllegalArgumentException();
}
this.horizontalAlignment = horizontalAlignment;
}
public Sheet createSheet(Display display) {
final Sheet sheet = new Sheet(horizontalAlignment);
if (display.isWhite() == false) {
final Rosetta rosetta = Rosetta.fromSyntax(WikiLanguage.CREOLE, display);
for (String cs : rosetta.translateTo(WikiLanguage.UNICODE)) {
final StripeRow row = StripeRow.parseUnicode(cs, fontConfiguration);
sheet.add(row);
}
}
return sheet;
}
}

View File

@ -0,0 +1,105 @@
package net.sourceforge.plantuml.creole.rosetta;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public abstract class ReaderAbstractWiki implements ReaderWiki {
static protected final String PNG_OR_GIF = "([-_\\w]+\\.(?:png|gif))";
static protected final String BRACKET1 = "\\[([^\\[\\]]+?)\\]";
static protected final String BRACKET0 = "\\[([^\\[\\]]*?)\\]";
final public List<String> transform(String... data) {
return transform(Arrays.asList(data));
}
// final protected String protectURL(String s) {
// return WikiLanguage.protectURL(s);
// }
final protected String rawCode(String s, String start, String end) {
final StringBuilder sb = new StringBuilder(s.length());
boolean rawMode = false;
boolean rawInRaw = false;
for (int i = 0; i < s.length(); i++) {
if (rawMode == false && s.substring(i).startsWith(start)) {
rawMode = true;
rawInRaw = false;
i += start.length() - 1;
sb.append(WikiLanguage.UNICODE.tag("code"));
if (s.substring(i + 1).startsWith(start)) {
i += start.length();
sb.append(WikiLanguage.hideCharsF7(start));
rawInRaw = true;
}
continue;
}
if (rawMode == true && s.substring(i).startsWith(end) && s.substring(i + 1).startsWith(end) == false) {
rawMode = false;
i += end.length() - 1;
if (rawInRaw && s.substring(i + 1).startsWith(end)) {
i += end.length();
sb.append(WikiLanguage.hideCharsF7(end));
}
sb.append(WikiLanguage.UNICODE.slashTag("code"));
rawInRaw = false;
continue;
}
char ch = s.charAt(i);
if (rawMode) {
ch = WikiLanguage.toF7(ch);
}
sb.append(ch);
}
return sb.toString();
}
protected final String cleanAndHideBackslashSeparator(String s, String sep, String unicodeSep) {
s = s.trim();
if (s.startsWith(sep)) {
s = s.substring(1);
}
if (s.endsWith(sep)) {
s = s.substring(0, s.length() - 1);
}
s = s.trim();
final String regex;
if (sep.equals("^") || sep.equals("|")) {
regex = "\\\\\\" + sep;
} else {
throw new IllegalArgumentException();
}
s = s.replaceAll(regex, unicodeSep);
s = singleLineFormat(s.trim());
s = s.replace(sep, " " + sep + " ");
return s;
}
protected abstract String singleLineFormat(String wiki);
final protected void exportCodeInternal(List<String> uhtml, String tag, List<String> lines) {
uhtml.add(WikiLanguage.UNICODE.tag(tag));
for (String s : lines) {
uhtml.add(s);
}
uhtml.add(WikiLanguage.UNICODE.slashTag(tag));
}
final protected void exportCodeInternalEnsureStartuml(List<String> uhtml, String tag, List<String> lines) {
exportCodeInternal(uhtml, tag, ensureStartuml(lines));
}
private List<String> ensureStartuml(List<String> lines) {
final String first = lines.get(0);
if (first.startsWith("@start")) {
return lines;
}
final List<String> copy = new ArrayList<String>(lines);
copy.add(0, "@startuml");
copy.add("@enduml");
return copy;
}
}

View File

@ -0,0 +1,40 @@
package net.sourceforge.plantuml.creole.rosetta;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class ReaderCreole extends ReaderAbstractWiki implements ReaderWiki {
@Override
protected String singleLineFormat(String wiki) {
// Legacy HTML
wiki = wiki.replace("<b>", WikiLanguage.UNICODE.tag("strong"));
wiki = wiki.replace("</b>", WikiLanguage.UNICODE.slashTag("strong"));
wiki = wiki.replace("<i>", WikiLanguage.UNICODE.tag("em"));
wiki = wiki.replace("</i>", WikiLanguage.UNICODE.slashTag("em"));
// Em & Strong
wiki = wiki.replaceAll("\\*\\*(.+?)\\*\\*",
WikiLanguage.UNICODE.tag("strong") + "$1" + WikiLanguage.UNICODE.slashTag("strong"));
wiki = wiki.replaceAll("//(.+?)//",
WikiLanguage.UNICODE.tag("em") + "$1" + WikiLanguage.UNICODE.slashTag("em"));
// Strike
wiki = wiki.replaceAll("--([^-]+?)--",
WikiLanguage.UNICODE.tag("strike") + "$1" + WikiLanguage.UNICODE.slashTag("strike"));
return wiki;
}
public List<String> transform(List<String> raw) {
final List<String> uhtml = new ArrayList<String>();
for (int i = 0; i < raw.size(); i++) {
String current = raw.get(i);
uhtml.add(singleLineFormat(current));
}
return Collections.unmodifiableList(uhtml);
}
}

View File

@ -0,0 +1,326 @@
package net.sourceforge.plantuml.creole.rosetta;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class ReaderDokuwiki extends ReaderAbstractWiki implements ReaderWiki {
@Override
protected String singleLineFormat(String wiki) {
final boolean endingSlashSlash = wiki.endsWith("\\\\");
if (endingSlashSlash) {
wiki = wiki.substring(0, wiki.length() - 2);
}
// Raw %% and ''
wiki = rawCode(wiki, "''%%", "%%''");
wiki = rawCode(wiki, "%%", "%%");
wiki = rawCode(wiki, "''", "''");
// Protect/escape some character
for (char c : "^|<".toCharArray()) {
wiki = wiki.replace("\\" + c, "" + WikiLanguage.toF7(c));
}
// Horizontal lines
wiki = wiki.replaceAll("^___+$", WikiLanguage.UNICODE.tag("hr"));
wiki = wiki.replaceAll("^---+$", WikiLanguage.UNICODE.tag("hr"));
wiki = wiki.replaceAll("^\\*\\*\\*+$", WikiLanguage.UNICODE.tag("hr"));
// Strike
wiki = wiki.replaceAll("\\<del\\>([^<>]+?)\\</del\\>",
WikiLanguage.UNICODE.tag("strike") + "$1" + WikiLanguage.UNICODE.slashTag("strike"));
wiki = wiki.replaceAll("\\<strike\\>([^<>]+?)\\</strike\\>",
WikiLanguage.UNICODE.tag("strike") + "$1" + WikiLanguage.UNICODE.slashTag("strike"));
wiki = wiki.replaceAll("~~([^~]+?)~~",
WikiLanguage.UNICODE.tag("strike") + "$1" + WikiLanguage.UNICODE.slashTag("strike"));
// break
wiki = wiki.replace("\\\\ ", WikiLanguage.UNICODE.tag("br"));
// Em & Strong
wiki = wiki.replaceAll("//(.+?)//",
WikiLanguage.UNICODE.tag("em") + "$1" + WikiLanguage.UNICODE.slashTag("em"));
wiki = wiki.replaceAll("\\*\\*(.+?)\\*\\*",
WikiLanguage.UNICODE.tag("strong") + "$1" + WikiLanguage.UNICODE.slashTag("strong"));
wiki = wiki.replace(WikiLanguage.UNICODE.tag("strong") + WikiLanguage.UNICODE.tag("em"),
WikiLanguage.UNICODE.tag("strongem"));
wiki = wiki.replace(WikiLanguage.UNICODE.tag("em") + WikiLanguage.UNICODE.tag("strong"),
WikiLanguage.UNICODE.tag("strongem"));
wiki = wiki.replace(WikiLanguage.UNICODE.slashTag("strong") + WikiLanguage.UNICODE.slashTag("em"),
WikiLanguage.UNICODE.slashTag("strongem"));
wiki = wiki.replace(WikiLanguage.UNICODE.slashTag("em") + WikiLanguage.UNICODE.slashTag("strong"),
WikiLanguage.UNICODE.slashTag("strongem"));
// Underscore
wiki = wiki.replaceAll("__(.+?)__", WikiLanguage.UNICODE.tag("u") + "$1" + WikiLanguage.UNICODE.slashTag("u"));
if (endingSlashSlash) {
wiki += WikiLanguage.UNICODE.tag("br");
}
return wiki;
}
public List<String> transform(List<String> raw) {
final List<String> uhtml = new ArrayList<String>();
for (int i = 0; i < raw.size(); i++) {
String current = raw.get(i);
if (current.startsWith("FIXME ")) {
continue;
}
current = current.replaceFirst("^\\s+@start", "@start");
current = current.replaceFirst("^\\s+@end", "@end");
final AutoGroup autoGroup = getAutoGroup(raw, i);
if (autoGroup != null) {
i += autoGroup.getSkipped() - 1;
autoGroup.exportHtml(uhtml);
continue;
}
final StartEndGroup startEndGroup = getStartEndGroup(raw, i);
if (startEndGroup != null) {
i += startEndGroup.getSkipped() - 1;
startEndGroup.exportHtml(uhtml);
continue;
}
if (current.length() == 0) {
uhtml.add(WikiLanguage.UNICODE.tag("p"));
} else {
uhtml.add(singleLineFormat(current));
}
}
return Collections.unmodifiableList(uhtml);
}
private StartEndGroup getStartEndGroup(List<String> raw, int i) {
if (raw.get(i).equals("<code>")) {
return new StartEndGroup(raw, i, "</code>");
}
if (raw.get(i).startsWith("<uml")) {
return new StartEndGroup(raw, i, "</uml>");
}
if (raw.get(i).equals("<plantuml>")) {
return new StartEndGroup(raw, i, "</plantuml>");
}
return null;
}
private AutoGroup getAutoGroup(List<String> raw, int i) {
AutoGroup group = getAutoGroup(raw, i, " * ", " * ");
if (group != null) {
return group;
}
group = getAutoGroup(raw, i, " - ", " - ");
if (group != null) {
return group;
}
group = getAutoGroup(raw, i, "\t");
if (group != null) {
return group;
}
group = getAutoGroup(raw, i, "> ");
if (group != null) {
return group;
}
group = getAutoGroup(raw, i, "] ");
if (group != null) {
return group;
}
group = getAutoGroup(raw, i, " ");
if (group != null) {
return group;
}
group = getAutoGroup(raw, i, "^");
if (group != null) {
return group;
}
return null;
}
private AutoGroup getAutoGroup(List<String> raw, int i, String... headers) {
if (raw.get(i).startsWith(headers[0]) == false) {
return null;
}
final AutoGroup result = new AutoGroup(headers);
while (i < raw.size() && result.isInTheGroup(raw.get(i))) {
result.addLine(raw.get(i));
i++;
}
return result;
}
class AutoGroup {
private final List<String> lines = new ArrayList<String>();
private int skip = 0;
private final String[] headers;
private AutoGroup(String[] headers) {
this.headers = headers;
}
private void addLine(String s) {
if (headers[0].equals("> ") && s.equals(">")) {
lines.add("");
} else if (headers[0].equals("] ") && s.equals("]")) {
lines.add("");
} else if (headers[0].equals("^")) {
lines.add(s);
} else {
lines.add(s.substring(headers[0].length()));
}
skip++;
}
private int getSkipped() {
return skip;
}
private void exportHtml(List<String> uhtml) {
if (headers[0].equals(" * ")) {
exportList(uhtml, "ul");
} else if (headers[0].equals(" - ")) {
exportList(uhtml, "ol");
} else if (headers[0].equals(" ")) {
exportCode(uhtml);
} else if (headers[0].equals("\t")) {
exportCode(uhtml);
} else if (headers[0].equals("> ")) {
exportBlockquote(uhtml);
} else if (headers[0].equals("] ")) {
exportFieldset(uhtml);
} else if (headers[0].equals("^")) {
exportTable(uhtml);
} else {
throw new UnsupportedOperationException();
}
}
private void exportCode(List<String> uhtml) {
exportCodeInternal(uhtml, "codepre", lines);
}
private void exportList(List<String> uhtml, String type) {
uhtml.add(WikiLanguage.UNICODE.tag(type));
for (String s : lines) {
int level = 0;
if (s.startsWith("* ") || s.startsWith("- ")) {
level++;
s = s.substring(2);
}
uhtml.add(WikiLanguage.UNICODE.tag(type + "li", "level", "" + level) + singleLineFormat(s)
+ WikiLanguage.UNICODE.slashTag(type + "li"));
}
uhtml.add(WikiLanguage.UNICODE.slashTag(type));
}
private void exportFieldset(List<String> uhtml) {
uhtml.add(WikiLanguage.UNICODE.tag("fieldset"));
uhtml.addAll(transform(lines));
uhtml.add(WikiLanguage.UNICODE.slashTag("fieldset"));
}
private void exportBlockquote(List<String> uhtml) {
uhtml.add(WikiLanguage.UNICODE.tag("blockquote"));
uhtml.addAll(transform(lines));
uhtml.add(WikiLanguage.UNICODE.slashTag("blockquote"));
}
private void exportTable(List<String> uhtml) {
uhtml.add(WikiLanguage.UNICODE.tag("table"));
int i = 0;
int sizeHeader = 0;
for (String s : lines) {
final String sep = i == 0 ? "^" : "|";
final String tagHeader = i == 0 ? "th" : "tr";
final String cellHeader = i == 0 ? "tdh" : "td";
uhtml.add(WikiLanguage.UNICODE.tag(tagHeader));
s = cleanAndHideBackslashSeparator(s, sep, "\uF500");
final String cols[] = s.split("\\" + sep);
// System.err.println("cols1=" + Arrays.asList(cols));
if (i == 0) {
sizeHeader = cols.length;
} else if (cols.length != sizeHeader) {
System.err.println("lines=" + lines);
System.err.println("WARNING!!! " + sizeHeader + " " + cols.length);
throw new IllegalStateException("WARNING!!! " + sizeHeader + " " + cols.length);
}
for (String cell : cols) {
cell = cell.trim();
// if (cell.length() > 0) {
uhtml.add(WikiLanguage.UNICODE.tag(cellHeader));
// uhtml.add(singleLineFormat(cell));
uhtml.add(WikiLanguage.restoreAllCharsF7(cell.replace('\uF500', sep.charAt(0))));
uhtml.add(WikiLanguage.UNICODE.slashTag(cellHeader));
// }
}
uhtml.add(WikiLanguage.UNICODE.slashTag(tagHeader));
i++;
}
uhtml.add(WikiLanguage.UNICODE.slashTag("table"));
}
public boolean isInTheGroup(String line) {
if (headers[0].equals("^") && line.startsWith("|")) {
return true;
}
if (headers[0].equals("> ") && line.startsWith(">")) {
return true;
}
if (headers[0].equals("] ") && line.startsWith("]")) {
return true;
}
for (String header : headers) {
if (line.startsWith(header)) {
return true;
}
}
return false;
}
}
class StartEndGroup {
private final List<String> lines = new ArrayList<String>();
private int skip = 0;
private final String first;
private StartEndGroup(List<String> raw, int i, String end) {
this.first = raw.get(i);
skip++;
i++;
while (i < raw.size() && raw.get(i).equals(end) == false) {
lines.add(raw.get(i));
i++;
skip++;
}
skip++;
}
private void exportHtml(List<String> uhtml) {
if (first.equals("<code>")) {
exportCodeInternal(uhtml, "codepre", lines);
} else if (first.startsWith("<uml")) {
exportCodeInternal(uhtml, "imageuml", lines);
} else if (first.equals("<plantuml>")) {
exportCodeInternalEnsureStartuml(uhtml, "codeandimg", lines);
} else {
throw new UnsupportedOperationException();
}
}
private int getSkipped() {
return skip;
}
}
}

View File

@ -0,0 +1,11 @@
package net.sourceforge.plantuml.creole.rosetta;
import java.util.List;
public interface ReaderWiki {
public static final String REGEX_HTTP = "https?://[^\\s/$.?#][^()\\[\\]\\s]*";
public List<String> transform(List<String> data);
}

View File

@ -0,0 +1,65 @@
package net.sourceforge.plantuml.creole.rosetta;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import net.sourceforge.plantuml.cucadiagram.Display;
public class Rosetta {
private final List<String> unicodeHtml;
public static Rosetta fromUnicodeHtml(List<String> lines) {
return new Rosetta(lines);
}
public static Rosetta fromSyntax(WikiLanguage syntaxSource, String... wiki) {
return new Rosetta(syntaxSource, Arrays.asList(wiki));
}
public static Rosetta fromSyntax(WikiLanguage syntaxSource, List<String> wiki) {
return new Rosetta(syntaxSource, wiki);
}
public static Rosetta fromSyntax(WikiLanguage syntaxSource, Display display) {
return new Rosetta(syntaxSource, from(display));
}
private static List<String> from(Display display) {
final List<String> result = new ArrayList<String>();
for (CharSequence cs : display) {
result.add(cs.toString());
}
return result;
}
private Rosetta(List<String> lines) {
this.unicodeHtml = new ArrayList<String>(lines);
}
private Rosetta(WikiLanguage syntaxSource, List<String> wiki) {
final ReaderWiki reader;
if (syntaxSource == WikiLanguage.DOKUWIKI) {
reader = new ReaderDokuwiki();
} else if (syntaxSource == WikiLanguage.CREOLE) {
reader = new ReaderCreole();
// } else if (syntaxSource == WikiLanguage.MARKDOWN) {
// reader = new ReaderMarkdown();
// } else if (syntaxSource == WikiLanguage.ASCIIDOC) {
// reader = new ReaderAsciidoc();
} else {
throw new UnsupportedOperationException();
}
this.unicodeHtml = reader.transform(wiki);
}
public List<String> translateTo(WikiLanguage syntaxDestination) {
final List<String> html = new ArrayList<String>();
final WriterWiki writer = new WriterWiki(syntaxDestination);
html.addAll(writer.transform(unicodeHtml));
return Collections.unmodifiableList(html);
}
}

View File

@ -0,0 +1,128 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.creole.rosetta;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.sourceforge.plantuml.creole.Stripe;
import net.sourceforge.plantuml.creole.atom.Atom;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.FontStyle;
public class StripeRow implements Stripe {
private final List<Atom> atoms = new ArrayList<Atom>();
public Atom getLHeader() {
return null;
}
public List<Atom> getAtoms() {
return Collections.unmodifiableList(atoms);
}
public void add(Atom atom) {
atoms.add(atom);
}
private static final Pattern bold = Pattern.compile("^" + WikiLanguage.UNICODE.tag("strong") + "(.*)$");
private static final Pattern unbold = Pattern.compile("^" + WikiLanguage.UNICODE.slashTag("strong") + "(.*)$");
private static final Pattern italic = Pattern.compile("^" + WikiLanguage.UNICODE.tag("em") + "(.*)$");
private static final Pattern unitalic = Pattern.compile("^" + WikiLanguage.UNICODE.slashTag("em") + "(.*)$");
private static final Pattern strike = Pattern.compile("^" + WikiLanguage.UNICODE.tag("strike") + "(.*)$");
private static final Pattern unstrike = Pattern.compile("^" + WikiLanguage.UNICODE.slashTag("strike") + "(.*)$");
private static Pattern getPattern(String line) {
if (bold.matcher(line).find()) {
return bold;
}
if (unbold.matcher(line).find()) {
return unbold;
}
if (italic.matcher(line).find()) {
return italic;
}
if (unitalic.matcher(line).find()) {
return unitalic;
}
return null;
}
public static StripeRow parseUnicode(String line, FontConfiguration fontConfiguration) {
final StripeRow result = new StripeRow();
StringBuilder tmp = new StringBuilder();
while (line.length() > 0) {
final Pattern cmd = getPattern(line);
if (cmd == null) {
tmp.append(line.charAt(0));
line = line.substring(1);
continue;
}
if (tmp.length() > 0) {
result.add(AtomText22.create(tmp.toString(), fontConfiguration));
tmp.setLength(0);
}
final Matcher matcher = cmd.matcher(line);
matcher.find();
if (cmd == bold) {
fontConfiguration = fontConfiguration.bold();
} else if (cmd == unbold) {
fontConfiguration = fontConfiguration.unbold();
} else if (cmd == italic) {
fontConfiguration = fontConfiguration.italic();
} else if (cmd == unitalic) {
fontConfiguration = fontConfiguration.unitalic();
} else if (cmd == strike) {
fontConfiguration = fontConfiguration.add(FontStyle.STRIKE);
} else if (cmd == unstrike) {
fontConfiguration = fontConfiguration.remove(FontStyle.STRIKE);
} else {
throw new IllegalStateException();
}
line = matcher.group(1);
}
assert line.length() == 0;
if (tmp.length() > 0) {
result.add(AtomText22.create(tmp.toString(), fontConfiguration));
}
return result;
}
}

View File

@ -0,0 +1,41 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.creole.rosetta;
import net.sourceforge.plantuml.ugraphic.UShape;
public interface URosetta extends UShape {
}

View File

@ -0,0 +1,110 @@
package net.sourceforge.plantuml.creole.rosetta;
public enum WikiLanguage {
DOKUWIKI, MARKDOWN, ASCIIDOC, MEDIAWIKI, CREOLE, UNICODE, HTML_DEBUG;
public String toString() {
return super.toString().toLowerCase();
}
static class MyChar {
final String unicode;
final String htmlDebug;
MyChar(String unicode, String htmlDebug) {
this.unicode = unicode;
this.htmlDebug = htmlDebug;
}
String toRightSyntax(WikiLanguage lg) {
if (lg == WikiLanguage.UNICODE) {
return "" + unicode;
} else if (lg == WikiLanguage.HTML_DEBUG) {
return "" + htmlDebug;
}
throw new UnsupportedOperationException();
}
public String toHtmlDebug(String s) {
return s.replace(unicode, htmlDebug);
}
}
static public String toHtmlDebug(String s) {
s = START.toHtmlDebug(s);
s = END.toHtmlDebug(s);
s = SEMICOLON.toHtmlDebug(s);
s = EQUALS.toHtmlDebug(s);
s = EOB.toHtmlDebug(s);
return s;
}
private static final MyChar START = new MyChar("\uF800", "<<{{");
private static final MyChar END = new MyChar("\uF802", "<</{{");
private static final MyChar SEMICOLON = new MyChar("\uF810", ";;;");
private static final MyChar EQUALS = new MyChar("\uF811", "===");
private static final MyChar EOB = new MyChar("\uF899", "}}>>");
public static String hideCharsF7(String s) {
final StringBuilder sb = new StringBuilder(s.length());
for (char ch : s.toCharArray()) {
sb.append(toF7(ch));
}
return sb.toString();
}
public static String restoreAllCharsF7AndDoEscapeForBackSlash(String s) {
return restoreAllCharsF7(s);
}
public static String restoreAllCharsF7(String s) {
final StringBuilder sb = new StringBuilder(s.length());
for (char ch : s.toCharArray()) {
if (ch >= '\uF700' && ch <= '\uF7FF') {
ch = (char) (ch - '\uF700');
}
sb.append(ch);
}
return sb.toString();
}
public static char toF7(char ch) {
if (ch < 127) {
return (char) ('\uF700' + ch);
}
return ch;
}
public String slashTag(String tagName) {
final StringBuilder tmp = new StringBuilder();
tmp.append(END.toRightSyntax(this));
tmp.append(tagName);
tmp.append(SEMICOLON.toRightSyntax(this));
tmp.append(EOB.toRightSyntax(this));
return tmp.toString();
}
public String tag(String tagName) {
final StringBuilder tmp = new StringBuilder();
tmp.append(START.toRightSyntax(this));
tmp.append(tagName);
tmp.append(SEMICOLON.toRightSyntax(this));
tmp.append(EOB.toRightSyntax(this));
return tmp.toString();
}
public String tag(String tagName, String name, String value) {
final StringBuilder tmp = new StringBuilder();
tmp.append(START.toRightSyntax(this));
tmp.append(tagName);
tmp.append(SEMICOLON.toRightSyntax(this));
tmp.append(name);
tmp.append(EQUALS.toRightSyntax(this));
tmp.append(value);
tmp.append(SEMICOLON.toRightSyntax(this));
tmp.append(EOB.toRightSyntax(this));
return tmp.toString();
}
}

View File

@ -0,0 +1,28 @@
package net.sourceforge.plantuml.creole.rosetta;
import java.util.ArrayList;
import java.util.List;
public class WriterWiki {
private final WikiLanguage syntaxDestination;
public WriterWiki(WikiLanguage syntaxDestination) {
this.syntaxDestination = syntaxDestination;
if (syntaxDestination != WikiLanguage.HTML_DEBUG && syntaxDestination != WikiLanguage.UNICODE) {
throw new IllegalArgumentException(syntaxDestination.toString());
}
}
public List<String> transform(List<String> data) {
if (syntaxDestination == WikiLanguage.UNICODE) {
return data;
}
final List<String> result = new ArrayList<String>();
for (String s : data) {
result.add(WikiLanguage.toHtmlDebug(s));
}
return result;
}
}

View File

@ -49,7 +49,7 @@ import net.sourceforge.plantuml.ISkinSimple;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.creole.CreoleMode;
import net.sourceforge.plantuml.creole.CreoleParser;
import net.sourceforge.plantuml.creole.Parser;
import net.sourceforge.plantuml.graphic.AbstractTextBlock;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
@ -154,15 +154,17 @@ public class BodyEnhanced extends AbstractTextBlock implements TextBlock, WithPo
} else {
final String s = s2.toString();
if (manageHorizontalLine && isBlockSeparator(s)) {
blocks.add(decorate(stringBounder, new MethodsOrFieldsArea(members, fontParam, skinParam, align,
stereotype, entity), separator, title));
blocks.add(decorate(stringBounder,
new MethodsOrFieldsArea(members, fontParam, skinParam, align, stereotype, entity),
separator, title));
separator = s.charAt(0);
title = getTitle(s, skinParam);
members = new ArrayList<Member>();
} else if (CreoleParser.isTreeStart(s)) {
} else if (Parser.isTreeStart(s)) {
if (members.size() > 0) {
blocks.add(decorate(stringBounder, new MethodsOrFieldsArea(members, fontParam, skinParam,
align, stereotype, entity), separator, title));
blocks.add(decorate(stringBounder,
new MethodsOrFieldsArea(members, fontParam, skinParam, align, stereotype, entity),
separator, title));
}
members = new ArrayList<Member>();
final List<CharSequence> allTree = buildAllTree(s, it);
@ -181,8 +183,8 @@ public class BodyEnhanced extends AbstractTextBlock implements TextBlock, WithPo
if (inEllipse && members.size() == 0) {
members.add(new Member("", false, false));
}
blocks.add(decorate(stringBounder, new MethodsOrFieldsArea(members, fontParam, skinParam, align, stereotype,
entity), separator, title));
blocks.add(decorate(stringBounder,
new MethodsOrFieldsArea(members, fontParam, skinParam, align, stereotype, entity), separator, title));
if (blocks.size() == 1) {
this.area2 = blocks.get(0);
@ -198,7 +200,7 @@ public class BodyEnhanced extends AbstractTextBlock implements TextBlock, WithPo
result.add(init);
while (it.hasNext()) {
final CharSequence s = it.next();
if (CreoleParser.isTreeStart(StringUtils.trinNoTrace(s))) {
if (Parser.isTreeStart(StringUtils.trinNoTrace(s))) {
result.add(s);
} else {
it.previous();

View File

@ -57,7 +57,7 @@ import net.sourceforge.plantuml.command.regex.Matcher2;
import net.sourceforge.plantuml.command.regex.MyPattern;
import net.sourceforge.plantuml.command.regex.Pattern2;
import net.sourceforge.plantuml.creole.CreoleMode;
import net.sourceforge.plantuml.creole.CreoleParser;
import net.sourceforge.plantuml.creole.Parser;
import net.sourceforge.plantuml.creole.Sheet;
import net.sourceforge.plantuml.creole.SheetBlock1;
import net.sourceforge.plantuml.creole.SheetBlock2;
@ -526,8 +526,9 @@ public class Display implements Iterable<CharSequence> {
private TextBlock getCreole(FontConfiguration fontConfiguration, HorizontalAlignment horizontalAlignment,
ISkinSimple spriteContainer, LineBreakStrategy maxMessageSize, CreoleMode creoleMode,
FontConfiguration stereotypeConfiguration) {
final Sheet sheet = new CreoleParser(fontConfiguration, horizontalAlignment, spriteContainer, creoleMode,
stereotypeConfiguration).createSheet(this);
final Sheet sheet = Parser
.build(fontConfiguration, horizontalAlignment, spriteContainer, creoleMode, stereotypeConfiguration)
.createSheet(this);
final double padding = spriteContainer == null ? 0 : spriteContainer.getPadding();
final SheetBlock1 sheetBlock1 = new SheetBlock1(sheet, maxMessageSize, padding);
return new SheetBlock2(sheetBlock1, sheetBlock1, new UStroke(1.5));
@ -544,4 +545,35 @@ public class Display implements Iterable<CharSequence> {
}
public boolean hasSeveralGuideLines() {
return hasSeveralGuideLines(displayData);
}
public static boolean hasSeveralGuideLines(String s) {
final List<String> splitted = Arrays.asList(s.split("\\\\n"));
return hasSeveralGuideLines(splitted);
}
private static boolean hasSeveralGuideLines(Collection<? extends CharSequence> all) {
if (all.size() <= 1) {
return false;
}
for (CharSequence cs : all) {
final String s = cs.toString();
if (s.startsWith("< ")) {
return true;
}
if (s.startsWith("> ")) {
return true;
}
if (s.endsWith(" <")) {
return true;
}
if (s.endsWith(" >")) {
return true;
}
}
return false;
}
}

View File

@ -90,7 +90,7 @@ public class Link extends WithLinkType implements Hideable, Removeable {
private boolean constraint = true;
private boolean inverted = false;
private LinkArrow linkArrow = LinkArrow.NONE;
private LinkArrow linkArrow = LinkArrow.NONE_OR_SEVERAL;
private boolean opale;
private boolean horizontalSolitary;

View File

@ -35,9 +35,12 @@
*/
package net.sourceforge.plantuml.cucadiagram;
import net.sourceforge.plantuml.Direction;
import net.sourceforge.plantuml.svek.GuideLine;
public enum LinkArrow {
NONE, DIRECT_NORMAL, BACKWARD;
NONE_OR_SEVERAL, DIRECT_NORMAL, BACKWARD;
public LinkArrow reverse() {
if (this == DIRECT_NORMAL) {
@ -46,7 +49,22 @@ public enum LinkArrow {
if (this == BACKWARD) {
return DIRECT_NORMAL;
}
return NONE;
return NONE_OR_SEVERAL;
}
public GuideLine mute(final GuideLine guide) {
switch (this) {
case DIRECT_NORMAL:
return guide;
case BACKWARD:
return new GuideLine() {
public Direction getArrowDirection() {
return guide.getArrowDirection().getInv();
}
};
}
throw new UnsupportedOperationException();
}
}

View File

@ -200,7 +200,7 @@ public class MethodsOrFieldsArea extends AbstractTextBlock implements TextBlockW
}
bloc.drawU(ug);
if (url != null) {
ug.closeAction();
ug.closeUrl();
}
}

View File

@ -53,7 +53,7 @@ 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.creole.command.CommandCreoleImg;
import net.sourceforge.plantuml.creole.Parser;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.sprite.Sprite;
import net.sourceforge.plantuml.sprite.SpriteUtils;
@ -122,7 +122,7 @@ public class Stereotype implements CharSequence {
if (label.startsWith("<<$") && label.endsWith(">>")) {
final RegexResult mCircleSprite = circleSprite.matcher(label);
this.spriteName = mCircleSprite.get("NAME", 0);
this.spriteScale = CommandCreoleImg.getScale(mCircleSprite.get("SCALE", 0), 1);
this.spriteScale = Parser.getScale(mCircleSprite.get("SCALE", 0), 1);
} else {
this.spriteName = null;
}
@ -157,7 +157,7 @@ public class Stereotype implements CharSequence {
this.htmlColor = col == null ? HColorUtils.BLACK : col;
this.spriteName = mCircleSprite.get("NAME", 0);
this.character = '\0';
this.spriteScale = CommandCreoleImg.getScale(mCircleSprite.get("SCALE", 0), 1);
this.spriteScale = Parser.getScale(mCircleSprite.get("SCALE", 0), 1);
} else if (mCircleChar != null) {
if (StringUtils.isNotEmpty(mCircleChar.get("LABEL", 0))) {
local = "<<" + mCircleChar.get("LABEL", 0) + ">>";

View File

@ -145,7 +145,7 @@ public class EntityImageDesignedDomain extends AbstractEntityImage {
header.drawU(ug.apply(UTranslate.dx(4)), dimTotal.getWidth(), dimTitle.getHeight());
if (url != null) {
ug.closeAction();
ug.closeUrl();
}
}

View File

@ -149,7 +149,7 @@ public class EntityImageDomain extends AbstractEntityImage {
footer.drawU(ug.apply(new UTranslate(dimTotal.getWidth() - dimTag.getWidth(), dimTitle.getHeight())),
dimTag.getWidth(), dimTag.getHeight());
if (url != null) {
ug.closeAction();
ug.closeUrl();
}
}

View File

@ -144,7 +144,7 @@ public class EntityImageMachine extends AbstractEntityImage {
header.drawU(ug.apply(UTranslate.dx(5)), dimTotal.getWidth(), dimTitle.getHeight());
if (url != null) {
ug.closeAction();
ug.closeUrl();
}
}

View File

@ -132,7 +132,7 @@ public class EntityImageRequirement extends AbstractEntityImage {
ellipse.drawU(ug2);
if (url != null) {
ug.closeAction();
ug.closeUrl();
}
}

View File

@ -42,9 +42,6 @@ import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2;
import net.sourceforge.plantuml.command.regex.IRegex;
import net.sourceforge.plantuml.command.regex.Matcher2;
import net.sourceforge.plantuml.command.regex.MyPattern;
import net.sourceforge.plantuml.command.regex.Pattern2;
import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexOptional;
@ -56,7 +53,6 @@ import net.sourceforge.plantuml.cucadiagram.ILeaf;
import net.sourceforge.plantuml.cucadiagram.Ident;
import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.LinkArrow;
import net.sourceforge.plantuml.cucadiagram.LinkDecor;
import net.sourceforge.plantuml.cucadiagram.LinkType;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
@ -82,7 +78,7 @@ public class CommandLinkElement extends SingleLineCommand2<DescriptionDiagram> {
return RegexConcat.build(CommandLinkElement.class.getName(), RegexLeaf.start(), //
getGroup("ENT1"), //
RegexLeaf.spaceZeroOrMore(), //
new RegexOptional(new RegexLeaf("LABEL1", "[%g]([^%g]+)[%g]")), //
new RegexOptional(new RegexLeaf("FIRST_LABEL", "[%g]([^%g]+)[%g]")), //
RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("HEAD2", "(0\\)|<<|[<^*+#0@)]|<\\|[\\|\\:]?|[%s]+o)?"), //
new RegexLeaf("BODY1", "([-=.~]+)"), //
@ -93,7 +89,7 @@ public class CommandLinkElement extends SingleLineCommand2<DescriptionDiagram> {
new RegexLeaf("BODY2", "([-=.~]*)"), //
new RegexLeaf("HEAD1", "(\\(0|>>|[>^*+#0@(]|[\\:\\|]?\\|>|\\\\\\\\|o[%s]+)?"), //
RegexLeaf.spaceZeroOrMore(), //
new RegexOptional(new RegexLeaf("LABEL2", "[%g]([^%g]+)[%g]")), //
new RegexOptional(new RegexLeaf("SECOND_LABEL", "[%g]([^%g]+)[%g]")), //
RegexLeaf.spaceZeroOrMore(), //
getGroup("ENT2"), //
RegexLeaf.spaceZeroOrMore(), //
@ -223,78 +219,6 @@ public class CommandLinkElement extends SingleLineCommand2<DescriptionDiagram> {
"([\\p{L}0-9_.]+|\\(\\)[%s]*[\\p{L}0-9_.]+|\\(\\)[%s]*[%g][^%g]+[%g]|:[^:]+:|(?!\\[\\*\\])\\[[^\\[\\]]+\\]|\\((?!\\*\\))[^)]+\\))");
}
static class Labels {
private String firstLabel;
private String secondLabel;
private String labelLink;
private LinkArrow linkArrow = LinkArrow.NONE;
Labels(RegexResult arg) {
firstLabel = arg.get("LABEL1", 0);
secondLabel = arg.get("LABEL2", 0);
labelLink = arg.get("LABEL_LINK", 0);
if (labelLink != null) {
if (firstLabel == null && secondLabel == null) {
init();
}
labelLink = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(labelLink, "\"");
if ("<".equals(labelLink)) {
linkArrow = LinkArrow.BACKWARD;
labelLink = null;
} else if (">".equals(labelLink)) {
linkArrow = LinkArrow.DIRECT_NORMAL;
labelLink = null;
} else if (labelLink != null && labelLink.startsWith("< ")) {
linkArrow = LinkArrow.BACKWARD;
labelLink = StringUtils.trin(labelLink.substring(2));
} else if (labelLink != null && labelLink.startsWith("> ")) {
linkArrow = LinkArrow.DIRECT_NORMAL;
labelLink = StringUtils.trin(labelLink.substring(2));
} else if (labelLink != null && labelLink.endsWith(" >")) {
linkArrow = LinkArrow.DIRECT_NORMAL;
labelLink = StringUtils.trin(labelLink.substring(0, labelLink.length() - 2));
} else if (labelLink != null && labelLink.endsWith(" <")) {
linkArrow = LinkArrow.BACKWARD;
labelLink = StringUtils.trin(labelLink.substring(0, labelLink.length() - 2));
}
}
}
private void init() {
final Pattern2 p1 = MyPattern.cmpile("^[%g]([^%g]+)[%g]([^%g]+)[%g]([^%g]+)[%g]$");
final Matcher2 m1 = p1.matcher(labelLink);
if (m1.matches()) {
firstLabel = m1.group(1);
labelLink = StringUtils
.trin(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(StringUtils.trin(m1.group(2))));
secondLabel = m1.group(3);
return;
}
final Pattern2 p2 = MyPattern.cmpile("^[%g]([^%g]+)[%g]([^%g]+)$");
final Matcher2 m2 = p2.matcher(labelLink);
if (m2.matches()) {
firstLabel = m2.group(1);
labelLink = StringUtils
.trin(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(StringUtils.trin(m2.group(2))));
secondLabel = null;
return;
}
final Pattern2 p3 = MyPattern.cmpile("^([^%g]+)[%g]([^%g]+)[%g]$");
final Matcher2 m3 = p3.matcher(labelLink);
if (m3.matches()) {
firstLabel = null;
labelLink = StringUtils
.trin(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(StringUtils.trin(m3.group(1))));
secondLabel = m3.group(2);
}
}
}
@Override
protected CommandExecutionResult executeArg(DescriptionDiagram diagram, LineLocation location, RegexResult arg) {
final String ent1String = arg.get("ENT1", 0);
@ -327,10 +251,10 @@ public class CommandLinkElement extends SingleLineCommand2<DescriptionDiagram> {
cl1 = getFoo1(diagram, code1, ident1, ident1pure);
cl2 = getFoo1(diagram, code2, ident2, ident2pure);
}
Link link = new Link(cl1, cl2, linkType, Display.getWithNewlines(labels.labelLink), queue.length(),
labels.firstLabel, labels.secondLabel, diagram.getLabeldistance(), diagram.getLabelangle(),
Link link = new Link(cl1, cl2, linkType, Display.getWithNewlines(labels.getLabelLink()), queue.length(),
labels.getFirstLabel(), labels.getSecondLabel(), diagram.getLabeldistance(), diagram.getLabelangle(),
diagram.getSkinParam().getCurrentStyleBuilder());
link.setLinkArrow(labels.linkArrow);
link.setLinkArrow(labels.getLinkArrow());
if (dir == Direction.LEFT || dir == Direction.UP) {
link = link.getInv();
}

View File

@ -0,0 +1,115 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
* Contribution : Hisashi Miyashita
*
*/
package net.sourceforge.plantuml.descdiagram.command;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.command.regex.Matcher2;
import net.sourceforge.plantuml.command.regex.MyPattern;
import net.sourceforge.plantuml.command.regex.Pattern2;
import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.LinkArrow;
public class Labels {
private String firstLabel;
private String secondLabel;
private final StringWithArrow stringWithArrow;
public Labels(RegexResult arg) {
this.firstLabel = arg.get("FIRST_LABEL", 0);
this.secondLabel = arg.get("SECOND_LABEL", 0);
String labelLink = arg.get("LABEL_LINK", 0);
if (labelLink != null) {
labelLink = init(labelLink);
}
this.stringWithArrow = new StringWithArrow(labelLink);
}
private String init(String labelLink) {
if (firstLabel == null && secondLabel == null) {
final Pattern2 p1 = MyPattern.cmpile("^[%g]([^%g]+)[%g]([^%g]+)[%g]([^%g]+)[%g]$");
final Matcher2 m1 = p1.matcher(labelLink);
if (m1.matches()) {
firstLabel = m1.group(1);
secondLabel = m1.group(3);
return StringUtils
.trin(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(StringUtils.trin(m1.group(2))));
}
final Pattern2 p2 = MyPattern.cmpile("^[%g]([^%g]+)[%g]([^%g]+)$");
final Matcher2 m2 = p2.matcher(labelLink);
if (m2.matches()) {
firstLabel = m2.group(1);
secondLabel = null;
return StringUtils
.trin(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(StringUtils.trin(m2.group(2))));
}
final Pattern2 p3 = MyPattern.cmpile("^([^%g]+)[%g]([^%g]+)[%g]$");
final Matcher2 m3 = p3.matcher(labelLink);
if (m3.matches()) {
firstLabel = null;
secondLabel = m3.group(2);
return StringUtils
.trin(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(StringUtils.trin(m3.group(1))));
}
}
return StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(labelLink, "\"");
}
public final String getFirstLabel() {
return firstLabel;
}
public final String getSecondLabel() {
return secondLabel;
}
public final String getLabelLink() {
return stringWithArrow.getLabel();
}
public final LinkArrow getLinkArrow() {
return stringWithArrow.getLinkArrow();
}
public Display getDisplay() {
return stringWithArrow.getDisplay();
}
}

View File

@ -0,0 +1,144 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
* Contribution : Hisashi Miyashita
*
*/
package net.sourceforge.plantuml.descdiagram.command;
import net.sourceforge.plantuml.Direction;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.LinkArrow;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockArrow;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.graphic.VerticalAlignment;
import net.sourceforge.plantuml.svek.DirectionalTextBlock;
import net.sourceforge.plantuml.svek.GuideLine;
public class StringWithArrow {
private final String label;
private final LinkArrow linkArrow;
public StringWithArrow(String completeLabel) {
if (completeLabel == null) {
this.linkArrow = LinkArrow.NONE_OR_SEVERAL;
this.label = null;
return;
}
completeLabel = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(completeLabel, "\"");
if (Display.hasSeveralGuideLines(completeLabel)) {
this.linkArrow = LinkArrow.NONE_OR_SEVERAL;
this.label = completeLabel;
} else {
if ("<".equals(completeLabel)) {
this.linkArrow = LinkArrow.BACKWARD;
this.label = null;
} else if (">".equals(completeLabel)) {
this.linkArrow = LinkArrow.DIRECT_NORMAL;
this.label = null;
} else if (completeLabel.startsWith("< ")) {
this.linkArrow = LinkArrow.BACKWARD;
this.label = StringUtils.trin(completeLabel.substring(2));
} else if (completeLabel.startsWith("> ")) {
this.linkArrow = LinkArrow.DIRECT_NORMAL;
this.label = StringUtils.trin(completeLabel.substring(2));
} else if (completeLabel.endsWith(" >")) {
this.linkArrow = LinkArrow.DIRECT_NORMAL;
this.label = StringUtils.trin(completeLabel.substring(0, completeLabel.length() - 2));
} else if (completeLabel.endsWith(" <")) {
this.linkArrow = LinkArrow.BACKWARD;
this.label = StringUtils.trin(completeLabel.substring(0, completeLabel.length() - 2));
} else {
this.linkArrow = LinkArrow.NONE_OR_SEVERAL;
this.label = completeLabel;
}
}
}
public final String getLabel() {
return label;
}
public final LinkArrow getLinkArrow() {
return linkArrow;
}
public final Display getDisplay() {
return Display.getWithNewlines(label);
}
static public TextBlock addMagicArrow(TextBlock label, GuideLine guide, FontConfiguration font) {
final TextBlock arrowRight = new TextBlockArrow(Direction.RIGHT, font);
final TextBlock arrowLeft = new TextBlockArrow(Direction.LEFT, font);
final TextBlock arrowUp = new TextBlockArrow(Direction.UP, font);
final TextBlock arrowDown = new TextBlockArrow(Direction.DOWN, font);
final TextBlock right = TextBlockUtils.mergeLR(label, arrowRight, VerticalAlignment.CENTER);
final TextBlock left = TextBlockUtils.mergeLR(arrowLeft, label, VerticalAlignment.CENTER);
final TextBlock up = TextBlockUtils.mergeTB(arrowUp, label, HorizontalAlignment.CENTER);
final TextBlock down = TextBlockUtils.mergeTB(label, arrowDown, HorizontalAlignment.CENTER);
return new DirectionalTextBlock(guide, right, left, up, down);
}
static private TextBlock addMagicArrow2(TextBlock label, GuideLine guide, FontConfiguration font) {
final TextBlock arrowRight = new TextBlockArrow(Direction.RIGHT, font);
final TextBlock arrowLeft = new TextBlockArrow(Direction.LEFT, font);
final TextBlock arrowUp = new TextBlockArrow(Direction.UP, font);
final TextBlock arrowDown = new TextBlockArrow(Direction.DOWN, font);
final TextBlock right = TextBlockUtils.mergeLR(label, arrowRight, VerticalAlignment.CENTER);
final TextBlock left = TextBlockUtils.mergeLR(arrowLeft, label, VerticalAlignment.CENTER);
final TextBlock up = TextBlockUtils.mergeLR(arrowUp, label, VerticalAlignment.CENTER);
final TextBlock down = TextBlockUtils.mergeLR(label, arrowDown, VerticalAlignment.CENTER);
return new DirectionalTextBlock(guide, right, left, up, down);
}
public static TextBlock addSeveralMagicArrows(Display label, GuideLine guide, FontConfiguration font,
HorizontalAlignment alignment, ISkinParam skinParam) {
TextBlock result = TextBlockUtils.EMPTY_TEXT_BLOCK;
for (CharSequence cs : label) {
StringWithArrow tmp = new StringWithArrow(cs.toString());
TextBlock block = tmp.getDisplay().create9(font, alignment, skinParam, skinParam.maxMessageSize());
if (tmp.getLinkArrow() != LinkArrow.NONE_OR_SEVERAL) {
block = StringWithArrow.addMagicArrow2(block, tmp.getLinkArrow().mute(guide), font);
}
result = TextBlockUtils.mergeTB(result, block, alignment);
}
return result;
}
}

View File

@ -39,6 +39,8 @@ import java.io.IOException;
import java.io.OutputStream;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import javax.imageio.ImageIO;
@ -46,9 +48,11 @@ import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.BackSlash;
import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.UmlDiagram;
import net.sourceforge.plantuml.api.ImageDataSimple;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.svek.GraphvizCrash;
public class PSystemDitaa extends AbstractPSystem {
@ -120,16 +124,18 @@ public class PSystemDitaa extends AbstractPSystem {
// final Diagram diagram = new Diagram(grid, options, processingOptions);
final Class<?> clDiagram = Class.forName("org.stathissideris.ascii2image.graphics.Diagram");
clDiagram.getConstructor(grid.getClass(), options.getClass(), processingOptions.getClass()).newInstance(
grid, options, processingOptions);
final Object diagram = clDiagram.getConstructor(grid.getClass(), options.getClass(),
processingOptions.getClass()).newInstance(grid, options, processingOptions);
clDiagram.getConstructor(grid.getClass(), options.getClass(), processingOptions.getClass())
.newInstance(grid, options, processingOptions);
final Object diagram = clDiagram
.getConstructor(grid.getClass(), options.getClass(), processingOptions.getClass())
.newInstance(grid, options, processingOptions);
// final BitmapRenderer bitmapRenderer = new BitmapRenderer();
final Object bitmapRenderer = Class.forName("org.stathissideris.ascii2image.graphics.BitmapRenderer")
.newInstance();
// final BufferedImage image = (BufferedImage) bitmapRenderer.renderToImage(diagram, renderingOptions);
// final BufferedImage image = (BufferedImage)
// bitmapRenderer.renderToImage(diagram, renderingOptions);
final Method renderToImage = bitmapRenderer.getClass().getMethod("renderToImage", diagram.getClass(),
renderingOptions.getClass());
final BufferedImage image = (BufferedImage) renderToImage.invoke(bitmapRenderer, diagram, renderingOptions);
@ -138,10 +144,15 @@ public class PSystemDitaa extends AbstractPSystem {
final int width = image.getWidth();
final int height = image.getHeight();
return new ImageDataSimple(width, height);
} catch (Exception e) {
e.printStackTrace();
} catch (Throwable e) {
final List<String> strings = new ArrayList<String>();
strings.add("DITAA has crashed");
strings.add(" ");
GraphvizCrash.youShouldSendThisDiagram(strings);
strings.add(" ");
UmlDiagram.exportDiagramError(os, e, new FileFormatOption(FileFormat.PNG), seed(), null, null, strings);
return ImageDataSimple.error();
}
return null;
}

View File

@ -97,8 +97,8 @@ public class EpsGraphics {
true));
roundrect.add(new PostScriptCommandRaw(
"2 index 5 index add 1 index sub 2 index 5 index add 2 index sub 2 index 0 90 arc", true));
roundrect.add(new PostScriptCommandRaw("dup 3 index add 2 index 5 index add 2 index sub 2 index 90 180 arc",
true));
roundrect.add(
new PostScriptCommandRaw("dup 3 index add 2 index 5 index add 2 index sub 2 index 90 180 arc", true));
roundrect.add(new PostScriptCommandRaw("pop pop pop pop pop ", true));
}
@ -401,8 +401,8 @@ public class EpsGraphics {
}
}
public void epsRectangle(double x, double y, double width, double height, double rx, double ry,
HColorGradient gr, ColorMapper mapper) {
public void epsRectangle(double x, double y, double width, double height, double rx, double ry, HColorGradient gr,
ColorMapper mapper) {
checkCloseDone();
ensureVisible(x, y);
ensureVisible(x + width, y + height);
@ -488,13 +488,14 @@ public class EpsGraphics {
}
/**
* Converts a counter clockwise angle to a clockwise
* angle. i.e. 0 -> 360, 90 -> 270, 180 -> 180, 270 -> 90
* Converts a counter clockwise angle to a clockwise angle. i.e. 0 -> 360, 90 ->
* 270, 180 -> 180, 270 -> 90
*
* @param counterClockwise counter clockwise angle in degrees
* @return clockwise angle in degrees
*/
private double convertToClockwiseAngle(double counterClockwise) {
return 360.0 - counterClockwise;
private int convertToClockwiseAngle(double counterClockwise) {
return (int) (360.0 - counterClockwise);
}
public void epsEllipse(double x, double y, double xRadius, double yRadius, double start, double extend) {
@ -509,7 +510,8 @@ public class EpsGraphics {
// if (fillcolor != null) {
// appendColor(fillcolor);
// append("newpath", true);
// append(format(x) + " " + format(y / scale) + " " + format(xRadius) + " 0 360 arc", true);
// append(format(x) + " " + format(y / scale) + " " + format(xRadius) + " 0 360
// arc", true);
// append("closepath eofill", true);
// }
@ -518,12 +520,9 @@ public class EpsGraphics {
appendColor(color);
append("newpath", true);
final double a1 = convertToClockwiseAngle(start + extend);
final double a2 = convertToClockwiseAngle(start);
append(format(x) + " " + format(y / scale) + " " + format(xRadius) + " " + (long)a1 + " " + (long)a2
+ " arc", true);
append(format(x) + " " + format(y / scale) + " " + format(xRadius) + " " + a1 + " " + a2 + " arc", true);
append("stroke", true);
}
@ -630,8 +629,8 @@ public class EpsGraphics {
}
final public void curvetoNoMacro(double x1, double y1, double x2, double y2, double x3, double y3) {
append(format(x1) + " " + format(y1) + " " + format(x2) + " " + format(y2) + " " + format(x3) + " "
+ format(y3) + " curveto", true);
append(format(x1) + " " + format(y1) + " " + format(x2) + " " + format(y2) + " " + format(x3) + " " + format(y3)
+ " curveto", true);
ensureVisible(x1, y1);
ensureVisible(x2, y2);
ensureVisible(x3, y3);
@ -649,16 +648,16 @@ public class EpsGraphics {
}
public void curveto(double x1, double y1, double x2, double y2, double x3, double y3) {
append(format(x1) + " " + format(y1) + " " + format(x2) + " " + format(y2) + " " + format(x3) + " "
+ format(y3) + " curveto", true);
append(format(x1) + " " + format(y1) + " " + format(x2) + " " + format(y2) + " " + format(x3) + " " + format(y3)
+ " curveto", true);
ensureVisible(x1, y1);
ensureVisible(x2, y2);
ensureVisible(x3, y3);
}
public void quadto(double x1, double y1, double x2, double y2) {
append(format(x1) + " " + format(y1) + " " + format(x1) + " " + format(y1) + " " + format(x2) + " "
+ format(y2) + " curveto", true);
append(format(x1) + " " + format(y1) + " " + format(x1) + " " + format(y1) + " " + format(x2) + " " + format(y2)
+ " curveto", true);
ensureVisible(x1, y1);
ensureVisible(x2, y2);
}

View File

@ -210,7 +210,7 @@ public class FontConfiguration {
FontPosition.NORMAL, new SvgAttributes(), hyperlink, hyperlinkColor, useUnderlineForHyperlink, tabSize);
}
FontConfiguration add(FontStyle style) {
public FontConfiguration add(FontStyle style) {
final EnumSet<FontStyle> r = styles.clone();
if (style == FontStyle.PLAIN) {
r.clear();
@ -228,6 +228,14 @@ public class FontConfiguration {
return add(FontStyle.BOLD);
}
public FontConfiguration unbold() {
return remove(FontStyle.BOLD);
}
public FontConfiguration unitalic() {
return remove(FontStyle.ITALIC);
}
public FontConfiguration underline() {
return add(FontStyle.UNDERLINE);
}
@ -243,7 +251,7 @@ public class FontConfiguration {
return withHyperlink();
}
FontConfiguration remove(FontStyle style) {
public FontConfiguration remove(FontStyle style) {
final EnumSet<FontStyle> r = styles.clone();
r.remove(style);
return new FontConfiguration(r, motherFont, motherColor, currentFont, currentColor, extendedColor, fontPosition,

View File

@ -268,7 +268,10 @@ public class QuoteUtils {
"...naq gnk phgf. Gung'yy fubj gurz znegvnaf.",
"Jurarire V srry gur arrq gb rkrepvfr, V yvr qbja hagvy vg tbrf njnl", "Ernyvgl pbagvahrf gb ehva zl yvsr",
"Vs lbh gvpxyr hf, qb jr abg ynhtu?", "V xabj n HQC wbxr, ohg lbh zvtug abg trg vg",
"Chvfdhr prf zlfgrerf abhf qrcnffrag, srvtabaf q'ra rger y'betnavfngrhe.");
"Chvfdhr prf zlfgrerf abhf qrcnffrag, srvtabaf q'ra rger y'betnavfngrhe.",
"V qba'g gnxr nal erfcbafvovyvgl ng nyy",
"Gurer'f n jbeq sbe crbcyr jub guvax rirelbar vf pbafcvevat ntnvafg gurz: creprcgvir",
"V'yy yrg gung cnff orpnhfr guvf vf tbbqolr");
private QuoteUtils() {
}

View File

@ -68,6 +68,8 @@ import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
public class TextBlockUtils {
public static final TextBlock EMPTY_TEXT_BLOCK = TextBlockUtils.empty(0, 0);
public static TextBlock bordered(TextBlock textBlock, UStroke stroke, HColor borderColor, HColor backgroundColor,
double cornersize) {
return new TextBlockBordered(textBlock, stroke, borderColor, backgroundColor, cornersize);
@ -143,10 +145,22 @@ public class TextBlockUtils {
}
public static TextBlock mergeLR(TextBlock b1, TextBlock b2, VerticalAlignment verticallAlignment) {
if (b1 == EMPTY_TEXT_BLOCK) {
return b2;
}
if (b2 == EMPTY_TEXT_BLOCK) {
return b1;
}
return new TextBlockHorizontal(b1, b2, verticallAlignment);
}
public static TextBlock mergeTB(TextBlock b1, TextBlock b2, HorizontalAlignment horizontalAlignment) {
if (b1 == EMPTY_TEXT_BLOCK) {
return b2;
}
if (b2 == EMPTY_TEXT_BLOCK) {
return b1;
}
return new TextBlockVertical2(b1, b2, horizontalAlignment);
}

View File

@ -63,7 +63,7 @@ public class TextBlockWithUrl implements TextBlock {
public void drawU(UGraphic ug) {
ug.startUrl(url);
block.drawU(ug);
ug.closeAction();
ug.closeUrl();
}
public Dimension2D calculateDimension(StringBounder stringBounder) {

View File

@ -110,7 +110,7 @@ public class TileText extends AbstractTextBlock implements TextBlock {
}
}
if (url != null) {
ug.closeAction();
ug.closeUrl();
}
}

View File

@ -50,7 +50,6 @@ public abstract class UGraphicDelegator implements UGraphic {
return super.toString() + " " + getUg().toString();
}
public final boolean matchesProperty(String propertyName) {
return ug.matchesProperty(propertyName);
}
@ -79,8 +78,16 @@ public abstract class UGraphicDelegator implements UGraphic {
ug.startUrl(url);
}
public void closeAction() {
ug.closeAction();
public void closeUrl() {
ug.closeUrl();
}
public void startGroup(String groupId) {
ug.startGroup(groupId);
}
public void closeGroup() {
ug.closeGroup();
}
protected UGraphic getUg() {

View File

@ -46,9 +46,10 @@ import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.creole.CreoleMode;
import net.sourceforge.plantuml.creole.CreoleParser;
import net.sourceforge.plantuml.creole.Parser;
import net.sourceforge.plantuml.creole.Sheet;
import net.sourceforge.plantuml.creole.SheetBlock1;
import net.sourceforge.plantuml.creole.legacy.CreoleParser;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
@ -75,12 +76,11 @@ public class Help extends UmlDiagram {
final Display display = Display.create(lines);
final UFont font = UFont.serif(16);
final FontConfiguration fontConfiguration = FontConfiguration.blackBlueTrue(font);
final Sheet sheet = new CreoleParser(fontConfiguration, HorizontalAlignment.LEFT, getSkinParam(),
CreoleMode.FULL).createSheet(display);
final Sheet sheet = Parser.build(fontConfiguration, HorizontalAlignment.LEFT, getSkinParam(), CreoleMode.FULL)
.createSheet(display);
final SheetBlock1 sheetBlock = new SheetBlock1(sheet, LineBreakStrategy.NONE, 0);
final ImageBuilder builder = ImageBuilder.buildA(new ColorMapperIdentity(), false, null, null, null, 1.0,
null);
final ImageBuilder builder = ImageBuilder.buildA(new ColorMapperIdentity(), false, null, null, null, 1.0, null);
builder.setUDrawable(sheetBlock);
return builder.writeImageTOBEMOVED(fileFormat, 0, os);
}

View File

@ -42,9 +42,10 @@ import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.LineBreakStrategy;
import net.sourceforge.plantuml.SkinParam;
import net.sourceforge.plantuml.creole.CreoleMode;
import net.sourceforge.plantuml.creole.CreoleParser;
import net.sourceforge.plantuml.creole.Parser;
import net.sourceforge.plantuml.creole.Sheet;
import net.sourceforge.plantuml.creole.SheetBlock1;
import net.sourceforge.plantuml.creole.legacy.CreoleParser;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.AbstractTextBlock;
import net.sourceforge.plantuml.graphic.FontConfiguration;
@ -69,7 +70,8 @@ public class GTileNode extends AbstractTextBlock implements GTile {
final SheetBlock1 sheetBlock1 = getTextBlock(display);
final SymbolContext symbolContext = new SymbolContext(HColorUtils.MY_YELLOW, HColorUtils.BLACK);
tb = USymbol.RECTANGLE.asSmall(null, sheetBlock1, TextBlockUtils.empty(0, 0), symbolContext, HorizontalAlignment.CENTER);
tb = USymbol.RECTANGLE.asSmall(null, sheetBlock1, TextBlockUtils.empty(0, 0), symbolContext,
HorizontalAlignment.CENTER);
}
public static SheetBlock1 getTextBlock(final Display display) {
@ -80,7 +82,7 @@ public class GTileNode extends AbstractTextBlock implements GTile {
final FontConfiguration fc = new FontConfiguration(skinParam, FontParam.NOTE, null);
final Sheet sheet9 = new CreoleParser(fc, HorizontalAlignment.LEFT, skinParam, CreoleMode.FULL)
final Sheet sheet9 = Parser.build(fc, HorizontalAlignment.LEFT, skinParam, CreoleMode.FULL)
.createSheet(display);
final SheetBlock1 sheetBlock1 = new SheetBlock1(sheet9, LineBreakStrategy.NONE, 0);
return sheetBlock1;

View File

@ -128,7 +128,7 @@ public class PreprocessorUtils {
return ReadLineReader.create(new InputStreamReader(is, charset), url.toString(), s.getLocation());
} catch (IOException e) {
e.printStackTrace();
throw EaterException.located("Cannot open URL " + e.getMessage(), s);
throw EaterException.located("Cannot open URL " + e.getMessage());
}
}

View File

@ -39,19 +39,32 @@ import java.io.IOException;
import net.sourceforge.plantuml.StringLocated;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.core.DiagramType;
import net.sourceforge.plantuml.preproc.ReadLine;
import net.sourceforge.plantuml.utils.StartUtils;
public class ReadFilterMergeLines implements ReadFilter {
public ReadLine applyFilter(final ReadLine source) {
return new ReadLine() {
private boolean manageEndingBackslash = true;
public void close() throws IOException {
source.close();
}
public StringLocated readLine() throws IOException {
StringLocated result = source.readLine();
while (result != null && StringUtils.endsWithBackslash(result.getString())) {
if (result != null && StartUtils.isArobaseStartDiagram(result.getString())
&& isDitaa(result.getString())) {
this.manageEndingBackslash = false;
}
if (result != null && StartUtils.isArobaseEndDiagram(result.getString())) {
this.manageEndingBackslash = true;
}
while (result != null && manageEndingBackslash && StringUtils.endsWithBackslash(result.getString())) {
final StringLocated next = source.readLine();
if (next == null) {
break;
@ -61,6 +74,10 @@ public class ReadFilterMergeLines implements ReadFilter {
}
return result;
}
private boolean isDitaa(String string) {
return DiagramType.getTypeFromArobaseStart(StringUtils.trinNoTrace((string))) == DiagramType.DITAA;
}
};
}

View File

@ -173,8 +173,8 @@ public class GanttDiagram extends TitledDiagram implements Subject {
margin2 = 0;
}
final double dpiFactor = scale == null ? 1 : scale.getScale(100, 100);
final ImageBuilder imageBuilder = ImageBuilder.buildB(new ColorMapperIdentity(), false, ClockwiseTopRightBottomLeft.margin1margin2((double) margin1, (double) margin2),
null, "", "", dpiFactor, null);
final ImageBuilder imageBuilder = ImageBuilder.buildB(new ColorMapperIdentity(), false,
ClockwiseTopRightBottomLeft.margin1margin2(margin1, margin2), null, getMetadata(), "", dpiFactor, null);
final SkinParam skinParam = SkinParam.create(UmlDiagramType.TIMING);
TextBlock result = getTextBlock();
@ -228,7 +228,6 @@ public class GanttDiagram extends TitledDiagram implements Subject {
drawConstraints(ug, timeHeader.getTimeScale());
drawTasksRect(ug);
drawTasksTitle(ug);
if (printStart == null)
drawResources(ug);
}

View File

@ -141,7 +141,7 @@ public class TaskDrawRegular extends AbstractTaskDraw {
ug.apply(new HColorNone().bg()).draw(full);
}
if (url != null) {
ug.closeAction();
ug.closeUrl();
}
}

View File

@ -42,7 +42,7 @@ import net.sourceforge.plantuml.Guillemet;
import net.sourceforge.plantuml.ISkinSimple;
import net.sourceforge.plantuml.LineBreakStrategy;
import net.sourceforge.plantuml.SpriteContainer;
import net.sourceforge.plantuml.creole.command.CommandCreoleMonospaced;
import net.sourceforge.plantuml.creole.Parser;
import net.sourceforge.plantuml.salt.element.Element;
import net.sourceforge.plantuml.salt.element.WrappedElement;
import net.sourceforge.plantuml.sprite.Sprite;
@ -83,7 +83,7 @@ public class Dictionary implements SpriteContainer, ISkinSimple {
}
public String getMonospacedFamily() {
return CommandCreoleMonospaced.MONOSPACED;
return Parser.MONOSPACED;
}
public int getTabSize() {

View File

@ -127,8 +127,9 @@ public class PSystemSalt extends AbstractPSystem implements WithSprite {
margin2 = 5;
}
final ImageBuilder builder = ImageBuilder.buildB(new ColorMapperIdentity(), false, ClockwiseTopRightBottomLeft.margin1margin2((double) margin1, (double) margin2),
null, null, null, scale, HColorUtils.WHITE);
final ImageBuilder builder = ImageBuilder.buildB(new ColorMapperIdentity(), false,
ClockwiseTopRightBottomLeft.margin1margin2(margin1, margin2), null, getMetadata(), null, scale,
HColorUtils.WHITE);
builder.setUDrawable(new UDrawable() {
public void drawU(UGraphic ug) {

View File

@ -86,7 +86,7 @@ abstract class Arrow extends GraphicalElement implements InGroupable {
protected final void endUrl(UGraphic ug) {
if (url != null) {
ug.closeAction();
ug.closeUrl();
}
}

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