1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-06-25 19:32:35 +00:00

version 8046

This commit is contained in:
Arnaud Roques 2016-07-25 21:25:28 +02:00
parent dccc859954
commit 4638f93975
71 changed files with 1377 additions and 343 deletions

View File

@ -36,7 +36,7 @@
<groupId>net.sourceforge.plantuml</groupId>
<artifactId>plantuml</artifactId>
<version>8043-SNAPSHOT</version>
<version>8046-SNAPSHOT</version>
<packaging>jar</packaging>
<name>PlantUML</name>

View File

@ -43,7 +43,7 @@ import java.io.File;
*/
public enum FileFormat {
PNG, SVG, EPS, EPS_TEXT, ATXT, UTXT, XMI_STANDARD, XMI_STAR, XMI_ARGO, SCXML,
PDF, MJPEG, ANIMATED_GIF, HTML, HTML5, VDX, LATEX, LATEX_NO_PREAMBLE, BASE64;
PDF, MJPEG, ANIMATED_GIF, HTML, HTML5, VDX, LATEX, LATEX_NO_PREAMBLE, BASE64, BRAILLE_PNG;
/**
* Returns the file format to be used for that format.
@ -63,6 +63,9 @@ public enum FileFormat {
if (this == ANIMATED_GIF) {
return ".gif";
}
if (this == BRAILLE_PNG) {
return ".braille.png";
}
if (this == EPS_TEXT) {
return EPS.getFileSuffix();
}

View File

@ -122,7 +122,8 @@ public class InstructionFork extends WithNote implements Instruction {
}
public Swimlane getSwimlaneOut() {
return getLastList().getSwimlaneOut();
return forks.get(0).getSwimlaneOut();
//return getLastList().getSwimlaneOut();
}
public void manageOutRendering(LinkRendering nextLinkRenderer, boolean endFork) {

View File

@ -147,11 +147,11 @@ public class InstructionWhile extends WithNote implements Instruction, Instructi
}
public Swimlane getSwimlaneIn() {
return parent.getSwimlaneOut();
return parent.getSwimlaneIn();
}
public Swimlane getSwimlaneOut() {
return getSwimlaneIn();
return parent.getSwimlaneOut();
}
public Instruction getLast() {

View File

@ -42,7 +42,7 @@ public class Arrows {
final static private double delta2 = 4;
public static UPolygon asToUp() {
final UPolygon polygon = new UPolygon();
final UPolygon polygon = new UPolygon("asToUp");
polygon.addPoint(-delta2, delta1);
polygon.addPoint(0, 0);
polygon.addPoint(delta2, delta1);
@ -51,7 +51,7 @@ public class Arrows {
}
public static UPolygon asToDown() {
final UPolygon polygon = new UPolygon();
final UPolygon polygon = new UPolygon("asToDown");
polygon.addPoint(-delta2, -delta1);
polygon.addPoint(0, 0);
polygon.addPoint(delta2, -delta1);
@ -60,7 +60,7 @@ public class Arrows {
}
public static UPolygon asToRight() {
final UPolygon polygon = new UPolygon();
final UPolygon polygon = new UPolygon("asToRight");
polygon.addPoint(-delta1, -delta2);
polygon.addPoint(0, 0);
polygon.addPoint(-delta1, delta2);
@ -69,7 +69,7 @@ public class Arrows {
}
public static UPolygon asToLeft() {
final UPolygon polygon = new UPolygon();
final UPolygon polygon = new UPolygon("asToLeft");
polygon.addPoint(delta1, -delta2);
polygon.addPoint(0, 0);
polygon.addPoint(delta1, delta2);

View File

@ -135,8 +135,11 @@ public class Snake implements UShape {
final int colorArrowSeparationSpace = color.getColorArrowSeparationSpace();
final double move = 2 + colorArrowSeparationSpace;
final WormMutation mutation = WormMutation.create(worm, move);
ug = ug.apply(mutation.getGlobalTranslate(colors.size()));
Worm current = worm;
final double globalMove = -1.0 * (colors.size() - 1) / 2.0;
Worm current = worm.moveFirstPoint(mutation.getFirst().multiplyBy(globalMove));
if (mutation.size() > 2) {
current = current.moveLastPoint(mutation.getLast().multiplyBy(globalMove));
}
for (int i = 0; i < colors.size(); i++) {
double stroke = 1.5;
if (colorArrowSeparationSpace == 0) {
@ -149,34 +152,9 @@ public class Snake implements UShape {
drawInternalLabel(ug.apply(textTranslate));
}
// private void drawRainbowOld(UGraphic ug) {
// final HtmlColorRainbow rainbow = (HtmlColorRainbow) color;
// final List<HtmlColor> colors = rainbow.getColors();
// final int colorArrowSeparationSpace = rainbow.getColorArrowSeparationSpace();
// final double move = 2 + colorArrowSeparationSpace;
// ug = ug.apply(new UTranslate(-move * (colors.size() - 1) / 2.0, 0));
// double dx = -move;
// for (int i = 0; i < colors.size(); i++) {
// dx += move;
// double stroke = 1.5;
// if (colorArrowSeparationSpace == 0) {
// stroke = i == colors.size() - 1 ? 2.0 : 3.0;
// }
// worm.drawInternalOneColor(ug.apply(new UTranslate(dx, 0)), colors.get(i), stroke, emphasizeDirection,
// endDecoration);
// }
// drawInternalLabel(ug.apply(new UTranslate(dx, 0)));
// }
private void drawInternalLabel(UGraphic ug) {
if (textBlock != null) {
final Point2D position = getTextBlockPosition(ug.getStringBounder());
// final double max = getMaxX(ug.getStringBounder());
// ug.apply(new UChangeBackColor(HtmlColorUtils.LIGHT_GRAY))
// .apply(new UTranslate(position.getX(), position.getY()))
// .draw(new URectangle(textBlock.calculateDimension(ug.getStringBounder())));
// ug.apply(new UChangeBackColor(HtmlColorUtils.RED)).apply(new UTranslate(0, position.getY() + 10))
// .draw(new URectangle(max, 10));
textBlock.drawU(ug.apply(new UTranslate(position)));
}
}
@ -240,7 +218,7 @@ public class Snake implements UShape {
// return null;
// }
if (same(this.getLast(), other.getFirst())) {
final UPolygon oneOf = endDecoration == null ? other.endDecoration : endDecoration;
final UPolygon oneOf = other.endDecoration == null ? endDecoration : other.endDecoration;
final Snake result = new Snake(color, oneOf);
result.emphasizeDirection = emphasizeDirection == null ? other.emphasizeDirection : emphasizeDirection;
result.worm.addAll(this.worm.merge(other.worm));

View File

@ -113,6 +113,64 @@ public class Worm implements Iterable<Point2D.Double> {
return result;
}
public Worm moveFirstPoint(UTranslate move) {
final double dx = move.getDx();
final double dy = move.getDy();
if (dx != 0 && dy != 0) {
throw new IllegalArgumentException("move=" + move);
}
final Worm result = new Worm();
double x0 = this.points.get(0).getX();
double y0 = this.points.get(0).getY();
double x1 = this.points.get(1).getX();
double y1 = this.points.get(1).getY();
if (dx != 0 && x0 == x1) {
x1 += dx;
}
if (dy != 0 && y0 == y1) {
y1 += dy;
}
x0 += dx;
y0 += dy;
result.addPoint(x0, y0);
result.addPoint(x1, y1);
for (int i = 2; i < this.points.size(); i++) {
result.addPoint(this.points.get(i));
}
return result;
}
public Worm moveLastPoint(UTranslate move) {
final double dx = move.getDx();
final double dy = move.getDy();
if (dx != 0 && dy != 0) {
throw new IllegalArgumentException("move=" + move);
}
final Worm result = new Worm();
double x8 = this.points.get(this.points.size() - 2).getX();
double y8 = this.points.get(this.points.size() - 2).getY();
double x9 = this.points.get(this.points.size() - 1).getX();
double y9 = this.points.get(this.points.size() - 1).getY();
if (dx != 0 && x8 == x9) {
x8 += dx;
}
if (dy != 0 && y8 == y9) {
y8 += dy;
}
x9 += dx;
y9 += dy;
for (int i = 0; i < this.points.size() - 2; i++) {
result.addPoint(this.points.get(i));
}
result.addPoint(x8, y8);
result.addPoint(x9, y9);
return result;
}
@Override
public String toString() {
final StringBuilder result = new StringBuilder();

View File

@ -36,7 +36,6 @@ package net.sourceforge.plantuml.activitydiagram3.ftile;
import java.util.ArrayList;
import java.util.List;
import net.sourceforge.plantuml.ugraphic.UChange;
import net.sourceforge.plantuml.ugraphic.UTranslate;
public class WormMutation {
@ -83,12 +82,21 @@ public class WormMutation {
return result;
}
private UTranslate getLast() {
public UTranslate getLast() {
return translations.get(translations.size() - 1);
}
public UTranslate getFirst() {
return translations.get(0);
}
public int size() {
return translations.size();
}
private static WormMutation createFromSimpleSignature(final String signature, final double delta) {
final WormMutation result = new WormMutation();
// System.err.println("signature=" + signature);
if (signature.equals("D") || signature.equals("U")) {
final UTranslate translate = new UTranslate(delta, 0);
result.translations.add(translate);
@ -177,20 +185,6 @@ public class WormMutation {
return new UTranslate(result.getExtreme() * (size - 1), 0);
}
public UChange getGlobalTranslate(int size) {
final MinMax result = new MinMax();
if (translations.get(0).getDy() == 0) {
for (UTranslate tr : translations) {
result.append(tr.getDx());
}
return new UTranslate(-result.getExtreme() * (size - 1) / 2.0, 0);
}
for (UTranslate tr : translations) {
result.append(tr.getDy());
}
return new UTranslate(0, -result.getExtreme() * (size - 1) / 2.0);
}
public Worm mute(Worm original) {
final Worm result = new Worm();
for (int i = 0; i < original.size(); i++) {

View File

@ -69,8 +69,8 @@ public class FloatingNote extends AbstractTextBlock implements Stencil, TextBloc
final FontConfiguration fc = new FontConfiguration(skinParam, FontParam.NOTE, null);
final Sheet sheet = new CreoleParser(fc, HorizontalAlignment.LEFT, skinParam, CreoleMode.FULL)
.createSheet(note);
final Sheet sheet = new CreoleParser(fc, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT),
skinParam, CreoleMode.FULL).createSheet(note);
final SheetBlock2 sheetBlock2 = new SheetBlock2(new SheetBlock1(sheet, 0, skinParam.getPadding()), this,
new UStroke(1));
this.opale = new Opale(borderColor, noteBackgroundColor, sheetBlock2, skinParam.shadowing(), false);

View File

@ -94,8 +94,8 @@ public class FtileFactoryDelegatorCreateFork extends FtileFactoryDelegator {
double x = 0;
for (Ftile tmp : list) {
final Dimension2D dim = tmp.calculateDimension(getStringBounder());
conns.add(new ConnectionIn(black, tmp, x, arrowColor));
conns.add(new ConnectionOut(tmp, black, x, arrowColor, height1));
conns.add(new ConnectionIn(black, tmp, x, tmp.getInLinkRendering().getRainbow(arrowColor)));
conns.add(new ConnectionOut(tmp, black, x, tmp.getOutLinkRendering().getRainbow(arrowColor), height1));
x += dim.getWidth();
}

View File

@ -138,10 +138,12 @@ public class FtileFactoryDelegatorCreateSplit extends FtileFactoryDelegator {
boolean hasOut = false;
for (Ftile tmp : list) {
final Dimension2D dim = tmp.calculateDimension(getStringBounder());
conns.add(new ConnectionIn(tmp, x, arrowColor, getTextBlock(tmp.getInLinkRendering())));
conns.add(new ConnectionIn(tmp, x, tmp.getInLinkRendering().getRainbow(arrowColor), getTextBlock(tmp
.getInLinkRendering())));
final boolean hasOutTmp = tmp.calculateDimension(getStringBounder()).hasPointOut();
if (hasOutTmp) {
conns.add(new ConnectionOut(tmp, x, arrowColor, height1, getTextBlock(tmp.getOutLinkRendering())));
conns.add(new ConnectionOut(tmp, x, tmp.getOutLinkRendering().getRainbow(arrowColor), height1,
getTextBlock(tmp.getOutLinkRendering())));
hasOut = true;
}
x += dim.getWidth();

View File

@ -126,10 +126,11 @@ class FtileIfAndStop extends AbstractFtile {
// final TextBlock tb2 = Display.create(branch2.getLabelPositive(), fcArrow, HorizontalAlignment.LEFT,
// ftileFactory);
final Sheet sheet = new CreoleParser(fcTest, HorizontalAlignment.LEFT, skinParam, CreoleMode.FULL)
.createSheet(labelTest);
final Sheet sheet = new CreoleParser(fcTest, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT),
skinParam, CreoleMode.FULL).createSheet(labelTest);
final SheetBlock1 sheetBlock1 = new SheetBlock1(sheet, 0, skinParam.getPadding());
final TextBlock tbTest = new SheetBlock2(sheetBlock1, Diamond.asStencil(sheetBlock1), tileNonStop.getThickness());
final TextBlock tbTest = new SheetBlock2(sheetBlock1, Diamond.asStencil(sheetBlock1),
tileNonStop.getThickness());
final Ftile diamond1;
if (conditionStyle == ConditionStyle.INSIDE) {

View File

@ -92,8 +92,8 @@ public class FtileNoteAlone extends AbstractFtile implements Stencil {
final FontConfiguration fc = new FontConfiguration(skinParam, FontParam.NOTE, null);
final Sheet sheet = new CreoleParser(fc, HorizontalAlignment.LEFT, skinParam, CreoleMode.FULL)
.createSheet(note);
final Sheet sheet = new CreoleParser(fc, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT),
skinParam, CreoleMode.FULL).createSheet(note);
final TextBlock text = new SheetBlock2(new SheetBlock1(sheet, 0, skinParam.getPadding()), this, new UStroke(1));
opale = new Opale(borderColor, noteBackgroundColor, text, skinParam.shadowing(), false);

View File

@ -106,7 +106,8 @@ class FtileRepeat extends AbstractFtile {
final FontConfiguration fontConfiguration1 = conditionStyle == ConditionStyle.INSIDE ? fcDiamond : fcArrow;
final TextBlock tbTest = (Display.isNull(test) || test.isWhite()) ? TextBlockUtils.empty(0, 0) : test.create(
fontConfiguration1, HorizontalAlignment.LEFT, spriteContainer);
fontConfiguration1, repeat.skinParam().getDefaultTextAlignment(HorizontalAlignment.LEFT),
spriteContainer);
final TextBlock yesTb = yes.create(fcArrow, HorizontalAlignment.LEFT, spriteContainer);
final TextBlock outTb = out.create(fcArrow, HorizontalAlignment.LEFT, spriteContainer);

View File

@ -116,7 +116,8 @@ class FtileWhile extends AbstractFtile {
ConditionStyle conditionStyle, FontConfiguration fcTest) {
final TextBlock yesTb = yes.create(fontArrow, HorizontalAlignment.LEFT, ftileFactory.skinParam());
final TextBlock testTb = test.create(fcTest, HorizontalAlignment.LEFT, ftileFactory.skinParam());
final TextBlock testTb = test.create(fcTest,
whileBlock.skinParam().getDefaultTextAlignment(HorizontalAlignment.LEFT), ftileFactory.skinParam());
final TextBlock out = out2.create(fontArrow, HorizontalAlignment.LEFT, ftileFactory.skinParam());
final Ftile diamond1;

View File

@ -116,8 +116,8 @@ public class FtileWithNoteOpale extends AbstractFtile implements Stencil {
final FontConfiguration fc = new FontConfiguration(skinParam, FontParam.NOTE, null);
final Sheet sheet = new CreoleParser(fc, HorizontalAlignment.LEFT, skinParam, CreoleMode.FULL).createSheet(note
.getDisplay());
final Sheet sheet = new CreoleParser(fc, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT),
skinParam, CreoleMode.FULL).createSheet(note.getDisplay());
final TextBlock text = new SheetBlock2(new SheetBlock1(sheet, 0, skinParam.getPadding()), this, new UStroke(1));
opale = new Opale(borderColor, noteBackgroundColor, text, skinParam.shadowing(), withLink);

View File

@ -99,8 +99,8 @@ public class FtileWithNotes extends AbstractFtile /* implements Stencil */{
final FontConfiguration fc = new FontConfiguration(skinParam, FontParam.NOTE, null);
for (PositionedNote note : notes) {
final Sheet sheet = new CreoleParser(fc, HorizontalAlignment.LEFT, skinParam, CreoleMode.FULL)
.createSheet(note.getDisplay());
final Sheet sheet = new CreoleParser(fc, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT),
skinParam, CreoleMode.FULL).createSheet(note.getDisplay());
final SheetBlock1 sheet1 = new SheetBlock1(sheet, 0, skinParam.getPadding());
final TextBlock opale = TextBlockUtils.withMargin(new Opale(borderColor, noteBackgroundColor, sheet1,

View File

@ -153,8 +153,8 @@ public class ConditionalBuilder {
final TextBlock tb1 = getLabelBranch1();
final TextBlock tb2 = getLabelBranch2();
final Sheet sheet = new CreoleParser(fontTest, HorizontalAlignment.LEFT, skinParam, CreoleMode.FULL)
.createSheet(labelTest);
final Sheet sheet = new CreoleParser(fontTest, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT),
skinParam, CreoleMode.FULL).createSheet(labelTest);
final SheetBlock1 sheetBlock1 = new SheetBlock1(sheet, 0, skinParam.getPadding());
final TextBlock tbTest = new SheetBlock2(sheetBlock1, Diamond.asStencil(sheetBlock1), tile1.getThickness());
@ -172,14 +172,14 @@ public class ConditionalBuilder {
}
private TextBlock getLabelBranch2() {
final TextBlock tb2 = branch2.getLabelPositive().create(fontArrow, HorizontalAlignment.LEFT, ftileFactory.skinParam(),
CreoleMode.SIMPLE_LINE);
final TextBlock tb2 = branch2.getLabelPositive().create(fontArrow, HorizontalAlignment.LEFT,
ftileFactory.skinParam(), CreoleMode.SIMPLE_LINE);
return tb2;
}
private TextBlock getLabelBranch1() {
final TextBlock tb1 = branch1.getLabelPositive().create(fontArrow, HorizontalAlignment.LEFT, ftileFactory.skinParam(),
CreoleMode.SIMPLE_LINE);
final TextBlock tb1 = branch1.getLabelPositive().create(fontArrow, HorizontalAlignment.LEFT,
ftileFactory.skinParam(), CreoleMode.SIMPLE_LINE);
return tb1;
}

View File

@ -0,0 +1,71 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 6170 $
*
*/
package net.sourceforge.plantuml.braille;
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
import net.sourceforge.plantuml.ugraphic.UChangeColor;
import net.sourceforge.plantuml.ugraphic.UEllipse;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate;
public class BrailleDrawer implements UDrawable {
private final BrailleGrid grid;
private final double step = 9;
private final double spotSize = 5;
public BrailleDrawer(BrailleGrid grid) {
this.grid = grid;
}
public void drawU(UGraphic ug) {
ug = ug.apply(new UChangeColor(HtmlColorUtils.BLACK)).apply(new UChangeBackColor(HtmlColorUtils.BLACK));
for (int x = grid.getMinX(); x <= grid.getMaxX(); x++) {
for (int y = grid.getMinY(); y <= grid.getMaxY(); y++) {
if (grid.getState(x, y)) {
drawCircle(ug, x, y);
}
}
}
}
private void drawCircle(UGraphic ug, int x, int y) {
final double cx = x * step;
final double cy = y * step;
ug.apply(new UTranslate(cx, cy)).draw(new UEllipse(spotSize, spotSize));
}
}

View File

@ -0,0 +1,127 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 6170 $
*
*/
package net.sourceforge.plantuml.braille;
import java.util.HashSet;
import java.util.Set;
public class BrailleGrid {
private int minX;
private int minY;
private int maxX;
private int maxY;
private final double quanta;
private final Set<Coords> on = new HashSet<Coords>();
public BrailleGrid(double quanta) {
this.quanta = quanta;
}
public boolean getState(int x, int y) {
final Coords coords = new Coords(x, y);
return on.contains(coords);
}
public void setState(int x, int y, boolean state) {
final Coords coords = new Coords(x, y);
if (state) {
on.add(coords);
} else {
on.remove(coords);
}
minX = Math.min(minX, x);
maxX = Math.max(maxX, x);
minY = Math.min(minY, y);
maxY = Math.max(maxY, y);
}
public int getMinX() {
return minX;
}
public int getMinY() {
return minY;
}
public int getMaxX() {
return maxX;
}
public int getMaxY() {
return maxY;
}
public void rectangle(double x, double y, double width, double height) {
hline(y, x, x + width);
hline(y + height, x, x + width);
vline(x, y, y + height);
vline(x + width, y, y + height);
}
private void vline(double x, double y1, double y2) {
final int i = toInt(x);
final int j1 = toInt(y1);
final int j2 = toInt(y2);
for (int j = j1; j <= j2; j++) {
setState(i, j, true);
}
}
private void hline(double y, double x1, double x2) {
final int j = toInt(y);
final int i1 = toInt(x1);
final int i2 = toInt(x2);
for (int i = i1; i <= i2; i++) {
setState(i, j, true);
}
}
private int toInt(double value) {
return (int) Math.round(value / quanta);
}
public void line(double x1, double y1, double x2, double y2) {
if (x1 == x2) {
vline(x1, y1, y2);
} else if (y1 == y2) {
hline(y1, x1, x2);
} else {
System.err.println("warning line");
}
}
}

View File

@ -0,0 +1,70 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 6170 $
*
*/
package net.sourceforge.plantuml.braille;
public class Coords {
private final int x;
private final int y;
public Coords(int x, int y) {
this.x = x;
this.y = y;
}
@Override
public boolean equals(Object obj) {
final Coords other = (Coords) obj;
return this.x == other.x && this.y == other.y;
}
@Override
public int hashCode() {
return x + y * 8192;
}
@Override
public String toString() {
return "( " + x + " ; " + y + " )";
}
public int getX() {
return x;
}
public int getY() {
return y;
}
}

View File

@ -0,0 +1,72 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* Original Author: Arnaud Roques
*
*/
package net.sourceforge.plantuml.braille;
import java.awt.geom.Line2D;
import net.sourceforge.plantuml.ugraphic.ClipContainer;
import net.sourceforge.plantuml.ugraphic.ColorMapper;
import net.sourceforge.plantuml.ugraphic.UClip;
import net.sourceforge.plantuml.ugraphic.UDriver;
import net.sourceforge.plantuml.ugraphic.ULine;
import net.sourceforge.plantuml.ugraphic.UParam;
import net.sourceforge.plantuml.ugraphic.UShape;
public class DriverLineBraille implements UDriver<BrailleGrid> {
private final ClipContainer clipContainer;
public DriverLineBraille(ClipContainer clipContainer) {
this.clipContainer = clipContainer;
}
public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, BrailleGrid grid) {
final ULine shape = (ULine) ushape;
double x2 = x + shape.getDX();
double y2 = y + shape.getDY();
final UClip clip = clipContainer.getClip();
if (clip != null) {
final Line2D.Double line = clip.getClippedLine(new Line2D.Double(x, y, x2, y2));
if (line == null) {
return;
}
x = line.x1;
y = line.y1;
x2 = line.x2;
y2 = line.y2;
}
grid.line(x, y, x2, y2);
}
}

View File

@ -0,0 +1,44 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* Original Author: Arnaud Roques
*
*/
package net.sourceforge.plantuml.braille;
import net.sourceforge.plantuml.ugraphic.ColorMapper;
import net.sourceforge.plantuml.ugraphic.UDriver;
import net.sourceforge.plantuml.ugraphic.UParam;
import net.sourceforge.plantuml.ugraphic.UShape;
public class DriverNoneBraille implements UDriver<BrailleGrid> {
public void draw(UShape shape, double x, double y, ColorMapper mapper, UParam param, BrailleGrid object) {
}
}

View File

@ -0,0 +1,89 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* Original Author: Arnaud Roques
*
*/
package net.sourceforge.plantuml.braille;
import java.awt.geom.Rectangle2D;
import net.sourceforge.plantuml.ugraphic.ClipContainer;
import net.sourceforge.plantuml.ugraphic.ColorMapper;
import net.sourceforge.plantuml.ugraphic.UClip;
import net.sourceforge.plantuml.ugraphic.UDriver;
import net.sourceforge.plantuml.ugraphic.UParam;
import net.sourceforge.plantuml.ugraphic.URectangle;
import net.sourceforge.plantuml.ugraphic.UShape;
public class DriverRectangleBraille implements UDriver<BrailleGrid> {
private final ClipContainer clipContainer;
public DriverRectangleBraille(ClipContainer clipContainer) {
this.clipContainer = clipContainer;
}
public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, BrailleGrid grid) {
final URectangle rect = (URectangle) ushape;
// final double rx = rect.getRx();
// final double ry = rect.getRy();
double width = rect.getWidth();
double height = rect.getHeight();
// final String color = StringUtils.getAsSvg(mapper, param.getColor());
// final HtmlColor back = param.getBackcolor();
// if (back instanceof HtmlColorGradient) {
// final HtmlColorGradient gr = (HtmlColorGradient) back;
// final String id = svg.createSvgGradient(StringUtils.getAsHtml(mapper.getMappedColor(gr.getColor1())),
// StringUtils.getAsHtml(mapper.getMappedColor(gr.getColor2())), gr.getPolicy());
// svg.setFillColor("url(#" + id + ")");
// svg.setStrokeColor(color);
// } else {
// final String backcolor = StringUtils.getAsSvg(mapper, back);
// svg.setFillColor(backcolor);
// svg.setStrokeColor(color);
// }
//
// svg.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDasharraySvg());
final UClip clip = clipContainer.getClip();
if (clip != null) {
final Rectangle2D.Double r = clip.getClippedRectangle(new Rectangle2D.Double(x, y, width, height));
x = r.x;
y = r.y;
width = r.width;
height = r.height;
if (height <= 0) {
return;
}
}
grid.rectangle(x, y, width, height);
}
}

View File

@ -0,0 +1,135 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* Original Author: Arnaud Roques
*
*/
package net.sourceforge.plantuml.braille;
import java.io.IOException;
import java.io.OutputStream;
import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.posimo.DotPath;
import net.sourceforge.plantuml.ugraphic.AbstractCommonUGraphic;
import net.sourceforge.plantuml.ugraphic.AbstractUGraphic;
import net.sourceforge.plantuml.ugraphic.ClipContainer;
import net.sourceforge.plantuml.ugraphic.ColorMapper;
import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.UCenteredCharacter;
import net.sourceforge.plantuml.ugraphic.UEllipse;
import net.sourceforge.plantuml.ugraphic.UGraphic2;
import net.sourceforge.plantuml.ugraphic.UImage;
import net.sourceforge.plantuml.ugraphic.ULine;
import net.sourceforge.plantuml.ugraphic.UPath;
import net.sourceforge.plantuml.ugraphic.UPolygon;
import net.sourceforge.plantuml.ugraphic.URectangle;
import net.sourceforge.plantuml.ugraphic.UText;
public class UGraphicBraille extends AbstractUGraphic<BrailleGrid> implements ClipContainer, UGraphic2 {
private final StringBounder stringBounder;
private final BrailleGrid grid;
@Override
protected AbstractCommonUGraphic copyUGraphic() {
return new UGraphicBraille(this);
}
public UGraphicBraille(ColorMapper colorMapper, FileFormat fileFormat) {
this(colorMapper, new BrailleGrid(4));
}
private UGraphicBraille(UGraphicBraille other) {
super(other);
this.stringBounder = other.stringBounder;
this.grid = other.grid;
register();
}
// public UGraphicBraille(ColorMapper colorMapper, String backcolor, boolean textAsPath, double scale, String
// linkTarget) {
// this(colorMapper, new SvgGraphics(backcolor, scale), textAsPath, linkTarget);
// }
//
// public UGraphicBraille(ColorMapper colorMapper, boolean textAsPath, double scale, String linkTarget) {
// this(colorMapper, new SvgGraphics(scale), textAsPath, linkTarget);
// }
//
// public UGraphicBraille(ColorMapper mapper, HtmlColorGradient gr, boolean textAsPath, double scale, String
// linkTarget) {
// this(mapper, new SvgGraphics(scale), textAsPath, linkTarget);
//
// final SvgGraphics svg = getGraphicObject();
// svg.paintBackcolorGradient(mapper, gr);
// }
private UGraphicBraille(ColorMapper colorMapper, BrailleGrid grid) {
super(colorMapper, grid);
this.grid = grid;
this.stringBounder = TextBlockUtils.getDummyStringBounder();
register();
}
private void register() {
registerDriver(URectangle.class, new DriverRectangleBraille(this));
registerDriver(UText.class, new DriverNoneBraille());
registerDriver(ULine.class, new DriverLineBraille(this));
registerDriver(UPolygon.class, new DriverNoneBraille());
registerDriver(UEllipse.class, new DriverNoneBraille());
registerDriver(UImage.class, new DriverNoneBraille());
registerDriver(UPath.class, new DriverNoneBraille());
registerDriver(DotPath.class, new DriverNoneBraille());
registerDriver(UCenteredCharacter.class, new DriverNoneBraille());
}
public StringBounder getStringBounder() {
return stringBounder;
}
public void startUrl(Url url) {
}
public void closeAction() {
}
public void writeImageTOBEMOVED(OutputStream os, String metadata, int dpi) throws IOException {
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, HtmlColorUtils.WHITE,
metadata, null, 0, 0, null, false);
imageBuilder.setUDrawable(new BrailleDrawer(getGraphicObject()));
imageBuilder.writeImageTOBEMOVED(new FileFormatOption(FileFormat.PNG), os);
}
}

View File

@ -83,6 +83,7 @@ public class CommandCreateClassMultilines extends CommandMultilines2<ClassDiagra
private static RegexConcat getRegexConcat() {
return new RegexConcat(new RegexLeaf("^"), //
new RegexLeaf("VISIBILITY", "(" + VisibilityModifier.regexForVisibilityCharacter() + ")?"), //
new RegexLeaf("TYPE", "(interface|enum|abstract[%s]+class|abstract|class)[%s]+"), //
new RegexOr(//
new RegexConcat(//
@ -178,6 +179,11 @@ public class CommandCreateClassMultilines extends CommandMultilines2<ClassDiagra
private IEntity executeArg0(ClassDiagram diagram, RegexResult arg) {
final LeafType type = LeafType.getLeafType(StringUtils.goUpperCase(arg.get("TYPE", 0)));
final String visibilityString = arg.get("VISIBILITY", 0);
VisibilityModifier visibilityModifier = null;
if (visibilityString != null) {
visibilityModifier = VisibilityModifier.getVisibilityModifier(visibilityString.charAt(0), false);
}
final Code code = Code.of(arg.getLazzy("CODE", 0)).eventuallyRemoveStartingAndEndingDoubleQuote("\"([:");
final String display = arg.getLazzy("DISPLAY", 0);
@ -192,6 +198,7 @@ public class CommandCreateClassMultilines extends CommandMultilines2<ClassDiagra
} else {
result = diagram.createLeaf(code, Display.getWithNewlines(display), type, null);
}
result.setVisibilityModifier(visibilityModifier);
if (stereotype != null) {
result.setStereotype(new Stereotype(stereotype, diagram.getSkinParam().getCircledCharacterRadius(), diagram
.getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER), diagram.getSkinParam()
@ -227,5 +234,4 @@ public class CommandCreateClassMultilines extends CommandMultilines2<ClassDiagra
}
return result;
}
}

View File

@ -60,13 +60,21 @@ public abstract class PSystemBasicFactory<P extends AbstractPSystem> extends PSy
return null;
}
private boolean isEmptyLine(CharSequence2 result) {
return result.trin().length() == 0;
}
final public Diagram createSystem(UmlSource source) {
final IteratorCounter2 it = source.iterator2();
final CharSequence2 startLine = it.next();
P system = init(startLine.toString2());
boolean first = true;
while (it.hasNext()) {
final CharSequence2 s = it.next();
if (first && s != null && isEmptyLine(s)) {
continue;
}
first = false;
if (StartUtils.isArobaseEndDiagram(s)) {
if (source.getTotalLineCount() == 2) {
return buildEmptyError(source, s.getLocation());
@ -88,6 +96,4 @@ public abstract class PSystemBasicFactory<P extends AbstractPSystem> extends PSy
return system;
}
}

View File

@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 20028 $
* Revision $Revision: 20149 $
*
*/
package net.sourceforge.plantuml.cucadiagram;
@ -197,7 +197,7 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
}
public final boolean isGroup(Code code) {
return entityFactory.getGroups().containsKey(code);
return leafExist(code) == false && entityFactory.getGroups().containsKey(code);
}
public final Collection<IGroup> getGroups(boolean withRootGroup) {

View File

@ -254,5 +254,4 @@ public class GroupRoot implements IGroup {
public void setRemoved(boolean removed) {
throw new UnsupportedOperationException();
}
}

View File

@ -35,6 +35,7 @@ package net.sourceforge.plantuml.cucadiagram;
import net.sourceforge.plantuml.cucadiagram.dot.Neighborhood;
import net.sourceforge.plantuml.graphic.USymbol;
import net.sourceforge.plantuml.skin.VisibilityModifier;
import net.sourceforge.plantuml.svek.IEntityImage;
public interface ILeaf extends IEntity {
@ -73,4 +74,8 @@ public interface ILeaf extends IEntity {
public void setHasPort(boolean hasPort);
public void setVisibilityModifier(VisibilityModifier visibility);
public VisibilityModifier getVisibilityModifier();
}

View File

@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 19398 $
* Revision $Revision: 20172 $
*
*/
package net.sourceforge.plantuml.cucadiagram.dot;
@ -82,7 +82,7 @@ abstract class AbstractGraphviz implements Graphviz {
throw new IllegalArgumentException();
}
if (illegalDotExe()) {
if (getExeState() != ExeState.OK) {
// createPngNoGraphviz(os, new FileFormatOption(FileFormat.valueOf(type[0].goUpperCase())));
throw new IllegalStateException();
}
@ -123,8 +123,8 @@ abstract class AbstractGraphviz implements Graphviz {
return state;
}
public boolean illegalDotExe() {
return dotExe == null || dotExe.isFile() == false || dotExe.canRead() == false;
final public ExeState getExeState() {
return ExeState.checkFile(dotExe);
}
final public String dotVersion() {

View File

@ -36,9 +36,11 @@ package net.sourceforge.plantuml.cucadiagram.dot;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.List;
import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
import net.sourceforge.plantuml.cucadiagram.GroupRoot;
import net.sourceforge.plantuml.cucadiagram.GroupType;
import net.sourceforge.plantuml.cucadiagram.IGroup;
import net.sourceforge.plantuml.cucadiagram.LeafType;
@ -55,7 +57,7 @@ public final class CucaDiagramSimplifierState {
boolean changed;
do {
changed = false;
final Collection<IGroup> groups = putConcurrentStateAtEnd(diagram.getGroups(false));
final Collection<IGroup> groups = getOrdered(diagram.getRootGroup());
for (IGroup g : groups) {
if (diagram.isAutarkic(g)) {
final IEntityImage img = computeImage(g);
@ -68,17 +70,39 @@ public final class CucaDiagramSimplifierState {
} while (changed);
}
private Collection<IGroup> putConcurrentStateAtEnd(Collection<IGroup> groups) {
final List<IGroup> result = new ArrayList<IGroup>();
final List<IGroup> end = new ArrayList<IGroup>();
for (IGroup g : groups) {
if (g.getGroupType() == GroupType.CONCURRENT_STATE) {
end.add(g);
} else {
result.add(g);
private Collection<IGroup> getOrdered(IGroup root) {
final Collection<IGroup> ordered = new LinkedHashSet<IGroup>();
ordered.add(root);
int size = 1;
while (true) {
size = ordered.size();
addOneLevel(ordered);
if (size == ordered.size()) {
break;
}
}
result.addAll(end);
final List<IGroup> result = new ArrayList<IGroup>();
for (IGroup g : ordered) {
if (g instanceof GroupRoot == false) {
result.add(0, g);
}
}
return result;
}
private void addOneLevel(Collection<IGroup> currents) {
for (IGroup g : new ArrayList<IGroup>(currents)) {
for (IGroup child : reverse(g.getChildren())) {
currents.add(child);
}
}
}
private List<IGroup> reverse(Collection<IGroup> source) {
final List<IGroup> result = new ArrayList<IGroup>();
for (IGroup g : source) {
result.add(0, g);
}
return result;
}

View File

@ -0,0 +1,93 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 20169 $
*
*/
package net.sourceforge.plantuml.cucadiagram.dot;
import java.io.File;
public enum ExeState {
NULL_UNDEFINED, OK, DOES_NOT_EXIST, IS_A_DIRECTORY, NOT_A_FILE, CANNOT_BE_READ;
public static ExeState checkFile(File dotExe) {
if (dotExe == null) {
return NULL_UNDEFINED;
} else if (dotExe.exists() == false) {
return DOES_NOT_EXIST;
} else if (dotExe.isDirectory()) {
return IS_A_DIRECTORY;
} else if (dotExe.isFile() == false) {
return NOT_A_FILE;
} else if (dotExe.canRead() == false) {
return CANNOT_BE_READ;
}
return OK;
}
public String getTextMessage() {
switch (this) {
case OK:
return "File OK";
case NULL_UNDEFINED:
return "No dot executable found";
case DOES_NOT_EXIST:
return "File does not exist";
case IS_A_DIRECTORY:
return "It should be an executable, not a directory";
case NOT_A_FILE:
return "Not a valid file";
case CANNOT_BE_READ:
return "File cannot be read";
}
throw new IllegalStateException();
}
public String getTextMessage(File exe) {
switch (this) {
case OK:
return "File " + exe.getAbsolutePath() + " OK";
case NULL_UNDEFINED:
return NULL_UNDEFINED.getTextMessage();
case DOES_NOT_EXIST:
return "File " + exe.getAbsolutePath() + " does not exist";
case IS_A_DIRECTORY:
return "File " + exe.getAbsolutePath() + " should be an executable, not a directory";
case NOT_A_FILE:
return "File " + exe.getAbsolutePath() + " is not a valid file";
case CANNOT_BE_READ:
return "File " + exe.getAbsolutePath() + " cannot be read";
}
throw new IllegalStateException();
}
}

View File

@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 19109 $
* Revision $Revision: 20172 $
*
*/
package net.sourceforge.plantuml.cucadiagram.dot;
@ -43,6 +43,7 @@ public interface Graphviz {
File getDotExe();
String dotVersion();
boolean illegalDotExe();
ExeState getExeState();
}

View File

@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 19931 $
* Revision $Revision: 20173 $
*
*/
package net.sourceforge.plantuml.cucadiagram.dot;
@ -43,13 +43,14 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.Log;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.vizjs.GraphvizJs;
import net.sourceforge.plantuml.vizjs.VizJsEngine;
public class GraphvizUtils {
// private static final String VIZJS = "vizjs";
private static final String VIZJS = "vizjs";
private static int DOT_VERSION_LIMIT = 226;
private static boolean isWindows() {
@ -67,7 +68,8 @@ public class GraphvizUtils {
}
public static Graphviz create(ISkinParam skinParam, String dotString, String... type) {
if (VizJsEngine.isOk()) {
if (useVizJs(skinParam)) {
Log.info("Using " + VIZJS);
return new GraphvizJs(dotString);
}
final AbstractGraphviz result;
@ -76,12 +78,24 @@ public class GraphvizUtils {
} else {
result = new GraphvizLinux(skinParam, dotString, type);
}
// if (OptionFlags.GRAPHVIZCACHE) {
// return new GraphvizCached(result);
// }
if (result.getExeState() != ExeState.OK && VizJsEngine.isOk()) {
Log.info("Error with file " + result.getDotExe() + ": " + result.getExeState().getTextMessage());
Log.info("Using " + VIZJS);
return new GraphvizJs(dotString);
}
return result;
}
private static boolean useVizJs(ISkinParam skinParam) {
if (skinParam != null && VIZJS.equalsIgnoreCase(skinParam.getDotExecutable()) && VizJsEngine.isOk()) {
return true;
}
if (VIZJS.equalsIgnoreCase(getenvGraphvizDot()) && VizJsEngine.isOk()) {
return true;
}
return false;
}
static public File getDotExe() {
return create(null, "png").getDotExe();
}
@ -125,16 +139,12 @@ public class GraphvizUtils {
public static String dotVersion() throws IOException, InterruptedException {
if (dotVersion == null) {
if (GraphvizUtils.getDotExe() == null) {
dotVersion = "Error: Dot not installed";
} else if (GraphvizUtils.getDotExe().exists() == false) {
dotVersion = "Error: " + GraphvizUtils.getDotExe().getAbsolutePath() + " does not exist";
} else if (GraphvizUtils.getDotExe().isFile() == false) {
dotVersion = "Error: " + GraphvizUtils.getDotExe().getAbsolutePath() + " is not a file";
} else if (GraphvizUtils.getDotExe().canRead() == false) {
dotVersion = "Error: " + GraphvizUtils.getDotExe().getAbsolutePath() + " cannot be read";
} else {
final File dotExe = GraphvizUtils.getDotExe();
final ExeState exeState = ExeState.checkFile(dotExe);
if (exeState == ExeState.OK) {
dotVersion = create(null, "png").dotVersion();
} else {
dotVersion = "Error:" + exeState.getTextMessage(dotExe);
}
}
return dotVersion;
@ -165,7 +175,7 @@ public class GraphvizUtils {
}
final List<String> result = new ArrayList<String>();
if (VizJsEngine.isOk()) {
if (useVizJs(null)) {
result.add("VizJs library is used!");
try {
final String err = getTestCreateSimpleFile();
@ -190,22 +200,9 @@ public class GraphvizUtils {
final File dotExe = GraphvizUtils.getDotExe();
result.add("Dot executable is " + dotExe);
boolean ok = true;
if (dotExe == null) {
result.add(red + "Error: No dot executable found");
ok = false;
} else if (dotExe.exists() == false) {
result.add(red + "Error: file does not exist");
ok = false;
} else if (dotExe.isFile() == false) {
result.add(red + "Error: not a valid file");
ok = false;
} else if (dotExe.canRead() == false) {
result.add(red + "Error: cannot be read");
ok = false;
}
final ExeState exeState = ExeState.checkFile(dotExe);
if (ok) {
if (exeState == ExeState.OK) {
try {
final String version = GraphvizUtils.dotVersion();
result.add("Dot version: " + version);
@ -228,6 +225,7 @@ public class GraphvizUtils {
e.printStackTrace();
}
} else {
result.add(red + "Error: " + exeState.getTextMessage());
result.add("Error: only sequence diagrams will be generated");
}

View File

@ -64,6 +64,7 @@ import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.USymbol;
import net.sourceforge.plantuml.graphic.color.ColorType;
import net.sourceforge.plantuml.graphic.color.Colors;
import net.sourceforge.plantuml.skin.VisibilityModifier;
import net.sourceforge.plantuml.svek.IEntityImage;
import net.sourceforge.plantuml.svek.PackageStyle;
import net.sourceforge.plantuml.svek.SingleStrategy;
@ -590,4 +591,14 @@ final class EntityImpl implements ILeaf, IGroup {
this.hasPort = hasPort;
}
private VisibilityModifier visibility;
public void setVisibilityModifier(VisibilityModifier visibility) {
this.visibility = visibility;
}
public VisibilityModifier getVisibilityModifier() {
return visibility;
}
}

View File

@ -43,6 +43,7 @@ import net.sourceforge.plantuml.api.ImageDataSimple;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.cucadiagram.dot.ExeState;
import net.sourceforge.plantuml.cucadiagram.dot.Graphviz;
import net.sourceforge.plantuml.cucadiagram.dot.GraphvizUtils;
import net.sourceforge.plantuml.cucadiagram.dot.ProcessState;
@ -65,10 +66,11 @@ public class PSystemDot extends AbstractPSystem {
}
public ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormat) throws IOException {
final Graphviz graphviz = GraphvizUtils
.create(null, data, StringUtils.goLowerCase(fileFormat.getFileFormat().name()));
if (graphviz.illegalDotExe()) {
final TextBlock result = GraphicStrings.createDefault(Arrays.asList("There is an issue with your Dot/Graphviz installation"), false);
final Graphviz graphviz = GraphvizUtils.create(null, data,
StringUtils.goLowerCase(fileFormat.getFileFormat().name()));
if (graphviz.getExeState() != ExeState.OK) {
final TextBlock result = GraphicStrings.createDefault(
Arrays.asList("There is an issue with your Dot/Graphviz installation"), false);
UGraphicUtils.writeImage(os, null, fileFormat, new ColorMapperIdentity(), HtmlColorUtils.WHITE, result);
return new ImageDataSimple();
}

View File

@ -179,11 +179,11 @@ public class QuoteUtils {
"Daylight, I must wait for the sunrise. I must think of a new life. And I mustn't give in.", //
"If I cannot bring you comfort then at least I bring you hope", //
"We all must learn from small misfortune, count the blessings that are real", //
"Prepare Three Sealed Envelopes...",
"You know that thing you just did? Don't do that"
// Well I never, was there ever, A cat so clever, as magical Mr Mistoffelees
// Do you like your morning tea weak or strong ?
// It took me a long time to understand that if you want to do this job well you have to stay detached.
"Prepare Three Sealed Envelopes...", //
"You know that thing you just did? Don't do that", //
"It took me a long time to understand that if you want to do this job well you have to stay detached.", //
"Do you like your morning tea weak or strong ?", //
"Winter is coming" //
);
private QuoteUtils() {

View File

@ -47,7 +47,7 @@ import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
import net.sourceforge.plantuml.cucadiagram.ILeaf;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.svek.CucaDiagramFileMaker;
import net.sourceforge.plantuml.svek.CucaDiagramFileMakerSvek2;
import net.sourceforge.plantuml.svek.DotDataImageBuilder;
import net.sourceforge.plantuml.svek.IEntityImage;
import net.sourceforge.plantuml.ugraphic.UGraphic2;
import net.sourceforge.plantuml.ugraphic.UTranslate;
@ -97,7 +97,7 @@ public class CucaDiagramFileMakerHector implements CucaDiagramFileMaker {
}
private IEntityImage computeImage(final ILeaf leaf) {
final IEntityImage image = CucaDiagramFileMakerSvek2.createEntityImageBlock(leaf, diagram.getSkinParam(),
final IEntityImage image = DotDataImageBuilder.createEntityImageBlock(leaf, diagram.getSkinParam(),
false, diagram, null, null, null);
return image;
}

View File

@ -51,7 +51,7 @@ import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.skin.rose.Rose;
import net.sourceforge.plantuml.svek.CucaDiagramFileMaker;
import net.sourceforge.plantuml.svek.CucaDiagramFileMakerSvek2;
import net.sourceforge.plantuml.svek.DotDataImageBuilder;
import net.sourceforge.plantuml.svek.IEntityImage;
import net.sourceforge.plantuml.ugraphic.MinMax;
import net.sourceforge.plantuml.ugraphic.UChangeColor;
@ -172,7 +172,7 @@ public class CucaDiagramFileMakerHector2 implements CucaDiagramFileMaker {
}
private IEntityImage computeImage(final ILeaf leaf) {
final IEntityImage image = CucaDiagramFileMakerSvek2.createEntityImageBlock(leaf, diagram.getSkinParam(),
final IEntityImage image = DotDataImageBuilder.createEntityImageBlock(leaf, diagram.getSkinParam(),
false, diagram, null, null, null);
return image;
}

View File

@ -51,7 +51,7 @@ import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.skin.rose.Rose;
import net.sourceforge.plantuml.svek.CucaDiagramFileMaker;
import net.sourceforge.plantuml.svek.CucaDiagramFileMakerSvek2;
import net.sourceforge.plantuml.svek.DotDataImageBuilder;
import net.sourceforge.plantuml.svek.IEntityImage;
import net.sourceforge.plantuml.ugraphic.MinMax;
import net.sourceforge.plantuml.ugraphic.UChangeColor;
@ -173,7 +173,7 @@ public class CucaDiagramFileMakerHector3 implements CucaDiagramFileMaker {
}
private IEntityImage computeImage(final ILeaf leaf) {
final IEntityImage image = CucaDiagramFileMakerSvek2.createEntityImageBlock(leaf, diagram.getSkinParam(),
final IEntityImage image = DotDataImageBuilder.createEntityImageBlock(leaf, diagram.getSkinParam(),
false, diagram, null, null, null);
return image;
}

View File

@ -52,7 +52,7 @@ import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.skin.rose.Rose;
import net.sourceforge.plantuml.svek.CucaDiagramFileMaker;
import net.sourceforge.plantuml.svek.CucaDiagramFileMakerSvek2;
import net.sourceforge.plantuml.svek.DotDataImageBuilder;
import net.sourceforge.plantuml.svek.IEntityImage;
import net.sourceforge.plantuml.ugraphic.MinMax;
import net.sourceforge.plantuml.ugraphic.UGraphic;
@ -188,7 +188,7 @@ public class CucaDiagramFileMakerHector4 implements CucaDiagramFileMaker {
}
private IEntityImage computeImage(final ILeaf leaf) {
final IEntityImage image = CucaDiagramFileMakerSvek2.createEntityImageBlock(leaf, diagram.getSkinParam(),
final IEntityImage image = DotDataImageBuilder.createEntityImageBlock(leaf, diagram.getSkinParam(),
false, diagram, null, null, null);
return image;
}

View File

@ -52,7 +52,7 @@ import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
import net.sourceforge.plantuml.skin.rose.Rose;
import net.sourceforge.plantuml.svek.CucaDiagramFileMaker;
import net.sourceforge.plantuml.svek.CucaDiagramFileMakerSvek2;
import net.sourceforge.plantuml.svek.DotDataImageBuilder;
import net.sourceforge.plantuml.svek.IEntityImage;
import net.sourceforge.plantuml.ugraphic.MinMax;
import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
@ -160,7 +160,7 @@ public class CucaDiagramFileMakerHectorB1 implements CucaDiagramFileMaker {
}
private IEntityImage computeImage(final ILeaf leaf) {
final IEntityImage image = CucaDiagramFileMakerSvek2.createEntityImageBlock(leaf, diagram.getSkinParam(),
final IEntityImage image = DotDataImageBuilder.createEntityImageBlock(leaf, diagram.getSkinParam(),
false, diagram, null, null, null);
return image;
}

View File

@ -53,7 +53,7 @@ import net.sourceforge.plantuml.graphic.HtmlColorUtils;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.skin.rose.Rose;
import net.sourceforge.plantuml.svek.CucaDiagramFileMaker;
import net.sourceforge.plantuml.svek.CucaDiagramFileMakerSvek2;
import net.sourceforge.plantuml.svek.DotDataImageBuilder;
import net.sourceforge.plantuml.svek.IEntityImage;
import net.sourceforge.plantuml.ugraphic.MinMax;
import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
@ -194,7 +194,7 @@ public class CucaDiagramFileMakerHectorB2 implements CucaDiagramFileMaker {
}
private IEntityImage computeImage(final ILeaf leaf) {
final IEntityImage image = CucaDiagramFileMakerSvek2.createEntityImageBlock(leaf, diagram.getSkinParam(),
final IEntityImage image = DotDataImageBuilder.createEntityImageBlock(leaf, diagram.getSkinParam(),
false, diagram, null, null, null);
return image;
}

View File

@ -41,7 +41,7 @@ import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.cucadiagram.ILeaf;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.hector2.layering.Layer;
import net.sourceforge.plantuml.svek.CucaDiagramFileMakerSvek2;
import net.sourceforge.plantuml.svek.DotDataImageBuilder;
import net.sourceforge.plantuml.svek.IEntityImage;
public class Foo1 {
@ -57,7 +57,7 @@ public class Foo1 {
}
private static IEntityImage computeImage(final ILeaf leaf, CucaDiagram diagram) {
final IEntityImage image = CucaDiagramFileMakerSvek2.createEntityImageBlock(leaf, diagram.getSkinParam(),
final IEntityImage image = DotDataImageBuilder.createEntityImageBlock(leaf, diagram.getSkinParam(),
false, diagram, null, null, null);
return image;
}

View File

@ -45,7 +45,7 @@ import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.hector2.MinMax;
import net.sourceforge.plantuml.hector2.layering.Layer;
import net.sourceforge.plantuml.hector2.mpos.Distribution;
import net.sourceforge.plantuml.svek.CucaDiagramFileMakerSvek2;
import net.sourceforge.plantuml.svek.DotDataImageBuilder;
import net.sourceforge.plantuml.svek.IEntityImage;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate;
@ -98,7 +98,7 @@ public class Foo2 extends AbstractTextBlock implements TextBlock {
}
private IEntityImage computeImage(final ILeaf leaf) {
final IEntityImage image = CucaDiagramFileMakerSvek2.createEntityImageBlock(leaf, diagram.getSkinParam(),
final IEntityImage image = DotDataImageBuilder.createEntityImageBlock(leaf, diagram.getSkinParam(),
false, diagram, null, null, null);
return image;
}

View File

@ -94,9 +94,8 @@ import net.sourceforge.plantuml.graphic.USymbol;
import net.sourceforge.plantuml.graphic.color.ColorType;
import net.sourceforge.plantuml.svek.Bibliotekon;
import net.sourceforge.plantuml.svek.Cluster;
import net.sourceforge.plantuml.svek.ColorSequence;
import net.sourceforge.plantuml.svek.CucaDiagramFileMaker;
import net.sourceforge.plantuml.svek.CucaDiagramFileMakerSvek2;
import net.sourceforge.plantuml.svek.DotDataImageBuilder;
import net.sourceforge.plantuml.svek.DotStringFactory;
import net.sourceforge.plantuml.svek.GraphvizCrash;
import net.sourceforge.plantuml.svek.IEntityImage;
@ -173,7 +172,7 @@ public class CucaDiagramFileMakerJDot implements CucaDiagramFileMaker {
public CucaDiagramFileMakerJDot(CucaDiagram diagram) {
this.diagram = diagram;
this.dotStringFactory = new DotStringFactory(new ColorSequence(), stringBounder, diagram);
this.dotStringFactory = new DotStringFactory(stringBounder, diagram);
printGroups(diagram.getRootGroup());
printEntities(getUnpackagedEntities());
@ -586,9 +585,8 @@ public class CucaDiagramFileMakerJDot implements CucaDiagramFileMaker {
// skinParam = new SkinParamSameClassWidth(dotData.getSkinParam(), width);
}
return CucaDiagramFileMakerSvek2.createEntityImageBlock(ent, skinParam,
diagram.isHideEmptyDescriptionForState(), diagram, getBibliotekon(), null,
diagram.getUmlDiagramType());
return DotDataImageBuilder.createEntityImageBlock(ent, skinParam, diagram.isHideEmptyDescriptionForState(),
diagram, getBibliotekon(), null, diagram.getUmlDiagramType());
}
return ent.getSvekImage();
}

View File

@ -63,6 +63,10 @@ public enum VisibilityModifier {
private final ColorParam foregroundParam;
private final ColorParam backgroundParam;
public static String regexForVisibilityCharacter() {
return "[-#+~]";
}
private VisibilityModifier(ColorParam foreground, ColorParam background) {
this.foregroundParam = foreground;
this.backgroundParam = background;
@ -83,7 +87,7 @@ public enum VisibilityModifier {
public Dimension2D calculateDimension(StringBounder stringBounder) {
return new Dimension2DDouble(size + 1, size + 1);
}
@Override
public Rectangle2D getInnerPosition(String member, StringBounder stringBounder) {
return null;

View File

@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 19886 $
* Revision $Revision: 20161 $
*
*/
package net.sourceforge.plantuml.statediagram;
@ -165,7 +165,7 @@ public class StateDiagram extends AbstractEntityDiagram {
public final boolean isHideEmptyDescriptionForState() {
return hideEmptyDescription;
}
@Override
public String checkFinalError() {
for (Link link : this.getLinks()) {
@ -179,7 +179,7 @@ public class StateDiagram extends AbstractEntityDiagram {
}
return super.checkFinalError();
}
private static boolean isCompatible(IGroup parent1, IGroup parent2) {
if (parent1 == null && parent2 == null) {
return true;
@ -203,7 +203,4 @@ public class StateDiagram extends AbstractEntityDiagram {
}
}

View File

@ -36,10 +36,12 @@ package net.sourceforge.plantuml.svek;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.cucadiagram.IGroup;
import net.sourceforge.plantuml.cucadiagram.ILeaf;
@ -141,6 +143,17 @@ public class Bibliotekon {
return sb.length() == 0 ? "" : sb.toString();
}
public Map<Code, Double> getMaxX() {
final Map<Code, Double> result = new HashMap<Code, Double>();
for (Map.Entry<ILeaf, Shape> ent : shapeMap.entrySet()) {
final Shape sh = ent.getValue();
final double maxX = sh.getMinX() + sh.getWidth();
final IEntity entity = ent.getKey();
result.put(entity.getCode(), maxX);
}
return Collections.unmodifiableMap(result);
}
public List<Line> allLines() {
return Collections.unmodifiableList(allLines);
}

View File

@ -76,6 +76,7 @@ import net.sourceforge.plantuml.skin.rose.Rose;
import net.sourceforge.plantuml.svek.image.EntityImageState;
import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
import net.sourceforge.plantuml.ugraphic.UChangeColor;
import net.sourceforge.plantuml.ugraphic.UComment;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.ULine;
import net.sourceforge.plantuml.ugraphic.URectangle;
@ -297,7 +298,7 @@ public class Cluster implements Moveable {
}
public void drawU(UGraphic ug, UStroke stroke, final UmlDiagramType umlDiagramType, final ISkinParam skinParam2) {
ug.draw(new UComment("cluster " + group.getCode().getFullName()));
final Stereotype stereotype = group.getStereotype();
HtmlColor borderColor;
if (umlDiagramType == UmlDiagramType.STATE) {

View File

@ -0,0 +1,157 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 6711 $
*
*/
package net.sourceforge.plantuml.svek;
import java.awt.geom.Dimension2D;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import net.sourceforge.plantuml.ColorParam;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.graphic.AbstractTextBlock;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.skin.rose.Rose;
import net.sourceforge.plantuml.ugraphic.UChangeColor;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.ULine;
import net.sourceforge.plantuml.ugraphic.UStroke;
import net.sourceforge.plantuml.ugraphic.UTranslate;
public final class ConcurrentStateImage extends AbstractTextBlock implements IEntityImage {
private final List<IEntityImage> inners = new ArrayList<IEntityImage>();
private final Separator separator;
private final ISkinParam skinParam;
private final HtmlColor backColor;
static enum Separator {
VERTICAL, HORIZONTAL;
static Separator fromChar(char sep) {
if (sep == '|') {
return VERTICAL;
}
if (sep == '-') {
return HORIZONTAL;
}
throw new IllegalArgumentException();
}
UTranslate move(Dimension2D dim) {
if (this == VERTICAL) {
return new UTranslate(dim.getWidth(), 0);
}
return new UTranslate(0, dim.getHeight());
}
Dimension2D add(Dimension2D orig, Dimension2D other) {
if (this == VERTICAL) {
return new Dimension2DDouble(orig.getWidth() + other.getWidth(), Math.max(orig.getHeight(),
other.getHeight()));
}
return new Dimension2DDouble(Math.max(orig.getWidth(), other.getWidth()), orig.getHeight()
+ other.getHeight());
}
void drawSeparator(UGraphic ug, Dimension2D dimTotal) {
final double THICKNESS_BORDER = 1.5;
final int DASH = 8;
ug = ug.apply(new UStroke(DASH, 10, THICKNESS_BORDER));
if (this == VERTICAL) {
ug.draw(new ULine(0, dimTotal.getHeight() + DASH));
} else {
ug.draw(new ULine(dimTotal.getWidth() + DASH, 0));
}
}
}
private HtmlColor getColor(ColorParam colorParam) {
return new Rose().getHtmlColor(skinParam, colorParam);
}
public ConcurrentStateImage(Collection<IEntityImage> images, char concurrentSeparator, ISkinParam skinParam,
HtmlColor backColor) {
this.separator = Separator.fromChar(concurrentSeparator);
this.skinParam = skinParam;
this.backColor = skinParam.getBackgroundColor();
this.inners.addAll(images);
}
public void drawU(UGraphic ug) {
System.err.println("drawing " + inners.size());
final HtmlColor dotColor = getColor(ColorParam.stateBorder);
final StringBounder stringBounder = ug.getStringBounder();
final Dimension2D dimTotal = calculateDimension(stringBounder);
for (int i = 0; i < inners.size(); i++) {
final IEntityImage inner = inners.get(i);
inner.drawU(ug);
final Dimension2D dim = inner.calculateDimension(stringBounder);
ug = ug.apply(separator.move(dim));
if (i < inners.size() - 1) {
separator.drawSeparator(ug.apply(new UChangeColor(dotColor)), dimTotal);
}
}
}
public Dimension2D calculateDimension(StringBounder stringBounder) {
Dimension2D result = new Dimension2DDouble(0, 0);
for (IEntityImage inner : inners) {
final Dimension2D dim = inner.calculateDimension(stringBounder);
result = separator.add(result, dim);
}
return result;
}
public HtmlColor getBackcolor() {
return backColor;
}
public boolean isHidden() {
return false;
}
public int getShield() {
return 0;
}
public ShapeType getShapeType() {
return ShapeType.RECTANGLE;
}
}

View File

@ -42,34 +42,22 @@ import java.util.List;
import net.sourceforge.plantuml.AnnotatedWorker;
import net.sourceforge.plantuml.BaseFile;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.NamedOutputStream;
import net.sourceforge.plantuml.Scale;
import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.cucadiagram.dot.CucaDiagramSimplifierActivity;
import net.sourceforge.plantuml.cucadiagram.dot.CucaDiagramSimplifierState;
import net.sourceforge.plantuml.cucadiagram.dot.DotData;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.StringBounderUtils;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.UFont;
public final class CucaDiagramFileMakerSvek implements CucaDiagramFileMaker {
private final CucaDiagram diagram;
static private final StringBounder stringBounder;
static {
stringBounder = StringBounderUtils.asStringBounder();
}
public CucaDiagramFileMakerSvek(CucaDiagram diagram) throws IOException {
this.diagram = diagram;
}
@ -84,14 +72,12 @@ public final class CucaDiagramFileMakerSvek implements CucaDiagramFileMaker {
}
}
private CucaDiagramFileMakerSvek2 buildCucaDiagramFileMakerSvek2(DotMode dotMode) {
private DotDataImageBuilder createDotDataImageBuilder(DotMode dotMode) {
final DotData dotData = new DotData(diagram.getEntityFactory().getRootGroup(), getOrderedLinks(),
diagram.getLeafsvalues(), diagram.getUmlDiagramType(), diagram.getSkinParam(), diagram, diagram,
diagram.getColorMapper(), diagram.getEntityFactory(), diagram.isHideEmptyDescriptionForState(),
dotMode, diagram.getNamespaceSeparator(), diagram.getPragma());
final CucaDiagramFileMakerSvek2 svek2 = new CucaDiagramFileMakerSvek2(dotData, diagram.getEntityFactory(),
diagram.getSource(), diagram.getPragma());
return svek2;
return new DotDataImageBuilder(dotData, diagram.getEntityFactory(), diagram.getSource(), diagram.getPragma());
}
@ -104,27 +90,26 @@ public final class CucaDiagramFileMakerSvek implements CucaDiagramFileMaker {
}
// System.err.println("FOO11 type=" + os.getClass());
CucaDiagramFileMakerSvek2 svek2 = buildCucaDiagramFileMakerSvek2(DotMode.NORMAL);
DotDataImageBuilder svek2 = createDotDataImageBuilder(DotMode.NORMAL);
BaseFile basefile = null;
if (fileFormatOption.isDebugSvek() && os instanceof NamedOutputStream) {
basefile = ((NamedOutputStream) os).getBasefile();
}
// System.err.println("FOO11 basefile=" + basefile);
TextBlockBackcolored result = svek2.createFile(basefile, diagram.getDotStringSkek());
TextBlockBackcolored result = svek2.buildImage(basefile, diagram.getDotStringSkek());
if (result instanceof GraphvizCrash) {
svek2 = buildCucaDiagramFileMakerSvek2(DotMode.NO_LEFT_RIGHT);
result = svek2.createFile(basefile, diagram.getDotStringSkek());
svek2 = createDotDataImageBuilder(DotMode.NO_LEFT_RIGHT);
result = svek2.buildImage(basefile, diagram.getDotStringSkek());
}
result = new AnnotatedWorker(diagram, diagram.getSkinParam()).addAdd(result);
final String widthwarning = diagram.getSkinParam().getValue("widthwarning");
String warningOrError = null;
if (widthwarning != null && widthwarning.matches("\\d+")) {
this.warningOrError = svek2.getBibliotekon().getWarningOrError(Integer.parseInt(widthwarning));
} else {
this.warningOrError = null;
warningOrError = svek2.getWarningOrError(Integer.parseInt(widthwarning));
}
final Dimension2D dim = result.calculateDimension(stringBounder);
final Dimension2D dim = result.calculateDimension(StringBounderUtils.asStringBounder());
final double scale = getScale(fileFormatOption, dim);
final ImageBuilder imageBuilder = new ImageBuilder(diagram.getSkinParam().getColorMapper(), scale,
@ -161,22 +146,6 @@ public final class CucaDiagramFileMakerSvek implements CucaDiagramFileMaker {
result.add(link);
}
private String warningOrError;
private String getWarningOrError() {
return warningOrError;
}
private final UFont getFont(FontParam fontParam) {
final ISkinParam skinParam = diagram.getSkinParam();
return skinParam.getFont(null, false, fontParam);
}
private final HtmlColor getFontColor(FontParam fontParam, Stereotype stereo) {
final ISkinParam skinParam = diagram.getSkinParam();
return skinParam.getFontHtmlColor(stereo, fontParam);
}
private double getScale(FileFormatOption fileFormatOption, final Dimension2D dim) {
final double scale;
final Scale diagScale = diagram.getScale();

View File

@ -34,14 +34,11 @@
package net.sourceforge.plantuml.svek;
import java.awt.geom.Dimension2D;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import net.sourceforge.plantuml.ColorParam;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.cucadiagram.ILeaf;
import net.sourceforge.plantuml.graphic.AbstractTextBlock;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.StringBounder;
@ -54,10 +51,9 @@ import net.sourceforge.plantuml.ugraphic.UTranslate;
public final class CucaDiagramFileMakerSvek2InternalImage extends AbstractTextBlock implements IEntityImage {
private final List<IEntityImage> inners = new ArrayList<IEntityImage>();
private final List<IEntityImage> inners;
private final Separator separator;
private final ISkinParam skinParam;
private final HtmlColor backColor;
static enum Separator {
VERTICAL, HORIZONTAL;
@ -105,14 +101,11 @@ public final class CucaDiagramFileMakerSvek2InternalImage extends AbstractTextBl
return new Rose().getHtmlColor(skinParam, colorParam);
}
public CucaDiagramFileMakerSvek2InternalImage(Collection<ILeaf> leafs, char concurrentSeparator,
ISkinParam skinParam, HtmlColor backColor) {
public CucaDiagramFileMakerSvek2InternalImage(List<IEntityImage> inners, char concurrentSeparator,
ISkinParam skinParam) {
this.separator = Separator.fromChar(concurrentSeparator);
this.skinParam = skinParam;
this.backColor = backColor;
for (ILeaf inner : leafs) {
inners.add(inner.getSvekImage());
}
this.inners = inners;
}
public void drawU(UGraphic ug) {
@ -142,7 +135,7 @@ public final class CucaDiagramFileMakerSvek2InternalImage extends AbstractTextBl
}
public HtmlColor getBackcolor() {
return backColor;
return skinParam.getBackgroundColor();
}
public boolean isHidden() {

View File

@ -39,6 +39,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -54,6 +55,7 @@ import net.sourceforge.plantuml.SkinParamSameClassWidth;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.core.UmlSource;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.EntityPortion;
import net.sourceforge.plantuml.cucadiagram.EntityPosition;
@ -69,6 +71,7 @@ import net.sourceforge.plantuml.cucadiagram.PortionShower;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.cucadiagram.UnparsableGraphvizException;
import net.sourceforge.plantuml.cucadiagram.dot.DotData;
import net.sourceforge.plantuml.cucadiagram.dot.ExeState;
import net.sourceforge.plantuml.cucadiagram.dot.GraphvizVersion;
import net.sourceforge.plantuml.cucadiagram.dot.Neighborhood;
import net.sourceforge.plantuml.cucadiagram.entity.EntityFactory;
@ -112,14 +115,13 @@ import net.sourceforge.plantuml.svek.image.EntityImageTips;
import net.sourceforge.plantuml.svek.image.EntityImageUseCase;
import net.sourceforge.plantuml.ugraphic.sprite.Sprite;
public final class CucaDiagramFileMakerSvek2 {
private final ColorSequence colorSequence = new ColorSequence();
public final class DotDataImageBuilder {
private final DotData dotData;
private final EntityFactory entityFactory;
private final UmlSource source;
private final Pragma pragma;
private Map<Code, Double> maxX;
static private final StringBounder stringBounder;
@ -127,32 +129,19 @@ public final class CucaDiagramFileMakerSvek2 {
stringBounder = StringBounderUtils.asStringBounder();
}
public CucaDiagramFileMakerSvek2(DotData dotData, EntityFactory entityFactory, UmlSource source, Pragma pragma) {
public DotDataImageBuilder(DotData dotData, EntityFactory entityFactory, UmlSource source, Pragma pragma) {
this.dotData = dotData;
this.entityFactory = entityFactory;
this.source = source;
this.pragma = pragma;
}
private DotStringFactory dotStringFactory;
public Bibliotekon getBibliotekon() {
return dotStringFactory.getBibliotekon();
}
public IEntityImage createFileForConcurrentState() {
return new CucaDiagramFileMakerSvek2InternalImage(dotData.getLeafs(), dotData.getTopParent()
.getConcurrentSeparator(), dotData.getSkinParam(), dotData.getSkinParam().getBackgroundColor());
}
public IEntityImage createFile(BaseFile basefile, String dotStrings[]) {
public IEntityImage buildImage(BaseFile basefile, String dotStrings[]) {
dotData.removeIrrelevantSametail();
dotStringFactory = new DotStringFactory(colorSequence, stringBounder, dotData);
final DotStringFactory dotStringFactory = new DotStringFactory(stringBounder, dotData);
printGroups(dotData.getRootGroup());
printEntities(getUnpackagedEntities());
printGroups(dotStringFactory, dotData.getRootGroup());
printEntities(dotStringFactory, getUnpackagedEntities());
for (Link link : dotData.getLinks()) {
if (link.isRemoved()) {
@ -162,23 +151,23 @@ public final class CucaDiagramFileMakerSvek2 {
final ISkinParam skinParam = dotData.getSkinParam();
final FontConfiguration labelFont = new FontConfiguration(skinParam, FontParam.GENERIC_ARROW, null);
final Line line = new Line(link, colorSequence, skinParam, stringBounder, labelFont, getBibliotekon(),
dotData.getPragma());
final Line line = new Line(link, dotStringFactory.getColorSequence(), skinParam, stringBounder,
labelFont, dotStringFactory.getBibliotekon(), dotData.getPragma());
getBibliotekon().addLine(line);
dotStringFactory.getBibliotekon().addLine(line);
if (link.getEntity1().isGroup() == false && link.getEntity1().getEntityType() == LeafType.NOTE
&& onlyOneLink(link.getEntity1())) {
final Shape shape = getBibliotekon().getShape(link.getEntity1());
final Shape other = getBibliotekon().getShape(link.getEntity2());
final Shape shape = dotStringFactory.getBibliotekon().getShape(link.getEntity1());
final Shape other = dotStringFactory.getBibliotekon().getShape(link.getEntity2());
if (other != null) {
((EntityImageNote) shape.getImage()).setOpaleLine(line, shape, other);
line.setOpale(true);
}
} else if (link.getEntity2().isGroup() == false && link.getEntity2().getEntityType() == LeafType.NOTE
&& onlyOneLink(link.getEntity2())) {
final Shape shape = getBibliotekon().getShape(link.getEntity2());
final Shape other = getBibliotekon().getShape(link.getEntity1());
final Shape shape = dotStringFactory.getBibliotekon().getShape(link.getEntity2());
final Shape other = dotStringFactory.getBibliotekon().getShape(link.getEntity1());
if (other != null) {
((EntityImageNote) shape.getImage()).setOpaleLine(line, shape, other);
line.setOpale(true);
@ -219,6 +208,7 @@ public final class CucaDiagramFileMakerSvek2 {
}
final SvekResult result = new SvekResult(position, dotData, dotStringFactory);
result.moveSvek(6 - minX, -minY);
this.maxX = dotStringFactory.getBibliotekon().getMaxX();
return result;
} catch (Exception e) {
Log.error("Exception " + e);
@ -261,17 +251,8 @@ public final class CucaDiagramFileMakerSvek2 {
final List<String> msg = new ArrayList<String>();
msg.add("Dot Executable: " + dotExe);
if (dotExe != null) {
if (dotExe.exists() == false) {
msg.add("File does not exist");
} else if (dotExe.isDirectory()) {
msg.add("It should be an executable, not a directory");
} else if (dotExe.isFile() == false) {
msg.add("Not a valid file");
} else if (dotExe.canRead() == false) {
msg.add("File cannot be read");
}
}
final ExeState exeState = ExeState.checkFile(dotExe);
msg.add(exeState.getTextMessage());
msg.add("Cannot find Graphviz. You should try");
msg.add(" ");
msg.add("@startuml");
@ -285,45 +266,46 @@ public final class CucaDiagramFileMakerSvek2 {
return GraphicStrings.createDefault(msg, false);
}
private void printEntities(Collection<ILeaf> entities2) {
private void printEntities(DotStringFactory dotStringFactory, Collection<ILeaf> entities2) {
for (ILeaf ent : entities2) {
if (ent.isRemoved()) {
continue;
}
printEntity(ent);
printEntity(dotStringFactory, ent);
}
}
private void printEntity(ILeaf ent) {
private void printEntity(DotStringFactory dotStringFactory, ILeaf ent) {
if (ent.isRemoved()) {
throw new IllegalStateException();
}
final IEntityImage image = printEntityInternal(ent);
final IEntityImage image = printEntityInternal(dotStringFactory, ent);
final Dimension2D dim = image.calculateDimension(stringBounder);
final Shape shape = new Shape(image, image.getShapeType(), dim.getWidth(), dim.getHeight(), colorSequence,
ent.isTop(), image.getShield(), ent.getEntityPosition());
final Shape shape = new Shape(image, image.getShapeType(), dim.getWidth(), dim.getHeight(),
dotStringFactory.getColorSequence(), ent.isTop(), image.getShield(), ent.getEntityPosition());
dotStringFactory.addShape(shape);
getBibliotekon().putShape(ent, shape);
dotStringFactory.getBibliotekon().putShape(ent, shape);
}
private IEntityImage printEntityInternal(ILeaf ent) {
private IEntityImage printEntityInternal(DotStringFactory dotStringFactory, ILeaf ent) {
if (ent.isRemoved()) {
throw new IllegalStateException();
}
if (ent.getSvekImage() == null) {
ISkinParam skinParam = dotData.getSkinParam();
if (skinParam.sameClassWidth()) {
final double width = getMaxWidth();
final double width = getMaxWidth(dotStringFactory);
skinParam = new SkinParamSameClassWidth(skinParam, width);
}
return createEntityImageBlock(ent, skinParam, dotData.isHideEmptyDescriptionForState(), dotData,
getBibliotekon(), dotStringFactory.getGraphvizVersion(), dotData.getUmlDiagramType());
dotStringFactory.getBibliotekon(), dotStringFactory.getGraphvizVersion(),
dotData.getUmlDiagramType());
}
return ent.getSvekImage();
}
private double getMaxWidth() {
private double getMaxWidth(DotStringFactory dotStringFactory) {
double result = 0;
for (ILeaf ent : dotData.getLeafs()) {
if (ent.getEntityType().isLikeClass() == false) {
@ -453,7 +435,7 @@ public final class CucaDiagramFileMakerSvek2 {
return result;
}
private void printGroups(IGroup parent) {
private void printGroups(DotStringFactory dotStringFactory, IGroup parent) {
for (IGroup g : dotData.getGroupHierarchy().getChildrenGroups(parent)) {
if (g.isRemoved()) {
continue;
@ -473,14 +455,14 @@ public final class CucaDiagramFileMakerSvek2 {
folder.setSpecificColorTOBEREMOVED(ColorType.BACK,
g.getColors(dotData.getSkinParam()).getColor(ColorType.BACK));
}
printEntity(folder);
printEntity(dotStringFactory, folder);
} else {
printGroup(g);
printGroup(dotStringFactory, g);
}
}
}
private void printGroup(IGroup g) {
private void printGroup(DotStringFactory dotStringFactory, IGroup g) {
if (g.getGroupType() == GroupType.CONCURRENT_STATE) {
return;
}
@ -513,9 +495,9 @@ public final class CucaDiagramFileMakerSvek2 {
}
dotStringFactory.openCluster(g, titleAndAttributeWidth, titleAndAttributeHeight, title, stereo);
this.printEntities(g.getLeafsDirect());
this.printEntities(dotStringFactory, g.getLeafsDirect());
printGroups(g);
printGroups(dotStringFactory, g);
dotStringFactory.closeCluster();
}
@ -555,4 +537,18 @@ public final class CucaDiagramFileMakerSvek2 {
return Display.create(stereos).create(new FontConfiguration(dotData.getSkinParam(), fontParam, stereotype),
HorizontalAlignment.CENTER, dotData.getSkinParam());
}
public String getWarningOrError(int warningOrError) {
if (maxX == null) {
return "";
}
final StringBuilder sb = new StringBuilder();
for (Map.Entry<Code, Double> ent : maxX.entrySet()) {
if (ent.getValue() > warningOrError) {
sb.append(ent.getKey() + " is overpassing the width limit.");
sb.append("\n");
}
}
return sb.length() == 0 ? "" : sb.toString();
}
}

View File

@ -80,23 +80,23 @@ public class DotStringFactory implements Moveable {
private final StringBounder stringBounder;
public DotStringFactory(ColorSequence colorSequence, StringBounder stringBounder, DotData dotData) {
public DotStringFactory(StringBounder stringBounder, DotData dotData) {
this.skinParam = dotData.getSkinParam();
this.umlDiagramType = dotData.getUmlDiagramType();
this.dotMode = dotData.getDotMode();
this.colorSequence = colorSequence;
this.colorSequence = new ColorSequence();
this.stringBounder = stringBounder;
this.root = new Cluster(colorSequence, skinParam, dotData.getRootGroup());
this.current = root;
}
public DotStringFactory(ColorSequence colorSequence, StringBounder stringBounder, CucaDiagram diagram) {
public DotStringFactory(StringBounder stringBounder, CucaDiagram diagram) {
this.skinParam = diagram.getSkinParam();
this.umlDiagramType = diagram.getUmlDiagramType();
this.dotMode = DotMode.NORMAL;
this.colorSequence = colorSequence;
this.colorSequence = new ColorSequence();
this.stringBounder = stringBounder;
this.root = new Cluster(colorSequence, skinParam, diagram.getEntityFactory().getRootGroup());
this.current = root;

View File

@ -111,7 +111,7 @@ public final class GroupPngMakerActivity {
skinParam, new InnerGroupHierarchy(), diagram.getColorMapper(), diagram.getEntityFactory(), false,
DotMode.NORMAL, diagram.getNamespaceSeparator(), diagram.getPragma());
final CucaDiagramFileMakerSvek2 svek2 = new CucaDiagramFileMakerSvek2(dotData, diagram.getEntityFactory(),
final DotDataImageBuilder svek2 = new DotDataImageBuilder(dotData, diagram.getEntityFactory(),
diagram.getSource(), diagram.getPragma());
if (group.getGroupType() == GroupType.INNER_ACTIVITY) {
@ -119,7 +119,7 @@ public final class GroupPngMakerActivity {
final HtmlColor borderColor = getColor(ColorParam.activityBorder, stereo);
final HtmlColor backColor = group.getColors(skinParam).getColor(ColorType.BACK) == null ? getColor(
ColorParam.background, stereo) : group.getColors(skinParam).getColor(ColorType.BACK);
return new InnerActivity(svek2.createFile(null, new String[0]), borderColor, backColor, skinParam.shadowing());
return new InnerActivity(svek2.buildImage(null, new String[0]), borderColor, backColor, skinParam.shadowing());
}
throw new UnsupportedOperationException(group.getGroupType().toString());

View File

@ -63,7 +63,6 @@ import net.sourceforge.plantuml.graphic.TextBlockWidth;
import net.sourceforge.plantuml.graphic.color.ColorType;
import net.sourceforge.plantuml.skin.rose.Rose;
import net.sourceforge.plantuml.svek.image.EntityImageState;
import net.sourceforge.plantuml.ugraphic.UFont;
import net.sourceforge.plantuml.ugraphic.UStroke;
public final class GroupPngMakerState {
@ -116,55 +115,61 @@ public final class GroupPngMakerState {
}
final List<Link> links = getPureInnerLinks();
// boolean hasVerticalLine = false;
// for (ILeaf leaf : group.getLeafsDirect()) {
// if (leaf.getEntityType() == LeafType.STATE_CONCURRENT) {
// hasVerticalLine = true;
// }
// }
final DotData dotData = new DotData(group, links, group.getLeafsDirect(), diagram.getUmlDiagramType(),
skinParam, new InnerGroupHierarchy(), diagram.getColorMapper(), diagram.getEntityFactory(),
diagram.isHideEmptyDescriptionForState(), DotMode.NORMAL, diagram.getNamespaceSeparator(),
diagram.getPragma());
final CucaDiagramFileMakerSvek2 svek2 = new CucaDiagramFileMakerSvek2(dotData, diagram.getEntityFactory(),
final DotDataImageBuilder svek2 = new DotDataImageBuilder(dotData, diagram.getEntityFactory(),
diagram.getSource(), diagram.getPragma());
if (group.getGroupType() == GroupType.CONCURRENT_STATE) {
// return new InnerStateConcurrent(svek2.createFile());
return svek2.buildImage(null, new String[0]);
}
if (group.getGroupType() != GroupType.STATE) {
throw new UnsupportedOperationException(group.getGroupType().toString());
}
HtmlColor borderColor = group.getColors(skinParam).getColor(ColorType.LINE);
if (borderColor == null) {
borderColor = getColor(ColorParam.stateBorder, group.getStereotype());
}
final Stereotype stereo = group.getStereotype();
final HtmlColor backColor = group.getColors(skinParam).getColor(ColorType.BACK) == null ? getColor(
ColorParam.stateBackground, stereo) : group.getColors(skinParam).getColor(ColorType.BACK);
final List<Member> members = ((IEntity) group).getBodier().getFieldsToDisplay();
final TextBlockWidth attribute;
if (members.size() == 0) {
attribute = new TextBlockEmpty();
} else {
attribute = new MethodsOrFieldsArea(members, FontParam.STATE_ATTRIBUTE, diagram.getSkinParam(),
group.getStereotype());
}
final Stereotype stereotype = group.getStereotype();
final boolean withSymbol = stereotype != null && stereotype.isWithOOSymbol();
final boolean containsOnlyConcurrentStates = containsOnlyConcurrentStates(dotData);
final IEntityImage image = containsOnlyConcurrentStates ? buildImageForConcurrentState(dotData) : svek2
.buildImage(null, new String[0]);
UStroke stroke = group.getColors(skinParam).getSpecificLineStroke();
if (stroke == null) {
stroke = new UStroke(1.5);
}
return new InnerStateAutonom(image, title, attribute, borderColor, backColor, skinParam.shadowing(),
group.getUrl99(), withSymbol, stroke);
if (group.getGroupType() == GroupType.CONCURRENT_STATE) {
// return new InnerStateConcurrent(svek2.createFile());
return svek2.createFile(null, new String[0]);
} else if (group.getGroupType() == GroupType.STATE) {
HtmlColor borderColor = group.getColors(skinParam).getColor(ColorType.LINE);
if (borderColor == null) {
borderColor = getColor(ColorParam.stateBorder, group.getStereotype());
}
final Stereotype stereo = group.getStereotype();
final HtmlColor backColor = group.getColors(skinParam).getColor(ColorType.BACK) == null ? getColor(
ColorParam.stateBackground, stereo) : group.getColors(skinParam).getColor(ColorType.BACK);
final List<Member> members = ((IEntity) group).getBodier().getFieldsToDisplay();
final TextBlockWidth attribute;
if (members.size() == 0) {
attribute = new TextBlockEmpty();
} else {
attribute = new MethodsOrFieldsArea(members, FontParam.STATE_ATTRIBUTE, diagram.getSkinParam(), group.getStereotype());
}
}
final Stereotype stereotype = group.getStereotype();
final boolean withSymbol = stereotype != null && stereotype.isWithOOSymbol();
final boolean containsOnlyConcurrentStates = containsOnlyConcurrentStates(dotData);
final IEntityImage image = containsOnlyConcurrentStates ? svek2.createFileForConcurrentState() : svek2
.createFile(null, new String[0]);
return new InnerStateAutonom(image, title, attribute, borderColor, backColor, skinParam.shadowing(),
group.getUrl99(), withSymbol, stroke);
private IEntityImage buildImageForConcurrentState(DotData dotData) {
final List<IEntityImage> inners = new ArrayList<IEntityImage>();
for (ILeaf inner : dotData.getLeafs()) {
inners.add(inner.getSvekImage());
}
throw new UnsupportedOperationException(group.getGroupType().toString());
return new CucaDiagramFileMakerSvek2InternalImage(inners, dotData.getTopParent().getConcurrentSeparator(),
dotData.getSkinParam());
}
@ -180,14 +185,9 @@ public final class GroupPngMakerState {
return true;
}
private UFont getFont(FontParam fontParam) {
final ISkinParam skinParam = diagram.getSkinParam();
return skinParam.getFont(null, false, fontParam);
}
private final Rose rose = new Rose();
protected final HtmlColor getColor(ColorParam colorParam, Stereotype stereo) {
private HtmlColor getColor(ColorParam colorParam, Stereotype stereo) {
final ISkinParam skinParam = diagram.getSkinParam();
return rose.getHtmlColor(skinParam, colorParam, stereo);
}

View File

@ -60,6 +60,7 @@ import net.sourceforge.plantuml.svek.WithPorts;
import net.sourceforge.plantuml.ugraphic.Shadowable;
import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
import net.sourceforge.plantuml.ugraphic.UChangeColor;
import net.sourceforge.plantuml.ugraphic.UComment;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UGraphicStencil;
import net.sourceforge.plantuml.ugraphic.URectangle;
@ -115,6 +116,7 @@ public class EntityImageClass extends AbstractEntityImage implements Stencil, Wi
}
final public void drawU(UGraphic ug) {
ug.draw(new UComment("class " + getEntity().getCode().getFullName()));
if (url != null) {
ug.startUrl(url);
}

View File

@ -53,6 +53,9 @@ import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockGeneric;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.graphic.VerticalAlignment;
import net.sourceforge.plantuml.skin.VisibilityModifier;
import net.sourceforge.plantuml.skin.rose.Rose;
import net.sourceforge.plantuml.svek.AbstractEntityImage;
import net.sourceforge.plantuml.svek.HeaderLayout;
import net.sourceforge.plantuml.svek.ShapeType;
@ -76,9 +79,20 @@ public class EntityImageClassHeader2 extends AbstractEntityImage {
if (italic) {
fontConfigurationName = fontConfigurationName.italic();
}
final TextBlock name = TextBlockUtils.withMargin(
entity.getDisplay().createWithNiceCreoleMode(fontConfigurationName, HorizontalAlignment.CENTER,
skinParam), 3, 3, 0, 0);
TextBlock name = entity.getDisplay().createWithNiceCreoleMode(fontConfigurationName,
HorizontalAlignment.CENTER, skinParam);
final VisibilityModifier modifier = entity.getVisibilityModifier();
if (modifier == null) {
name = TextBlockUtils.withMargin(name, 3, 3, 0, 0);
} else {
final Rose rose = new Rose();
final HtmlColor back = rose.getHtmlColor(skinParam, modifier.getBackground());
final HtmlColor fore = rose.getHtmlColor(skinParam, modifier.getForeground());
final TextBlock uBlock = modifier.getUBlock(skinParam.classAttributeIconSize(), fore, back);
name = TextBlockUtils.mergeLR(uBlock, name, VerticalAlignment.CENTER);
name = TextBlockUtils.withMargin(name, 3, 3, 0, 0);
}
final TextBlock stereo;
if (stereotype == null || stereotype.getLabel(false) == null

View File

@ -57,6 +57,7 @@ import net.sourceforge.plantuml.graphic.USymbolFolder;
import net.sourceforge.plantuml.graphic.color.ColorType;
import net.sourceforge.plantuml.svek.AbstractEntityImage;
import net.sourceforge.plantuml.svek.ShapeType;
import net.sourceforge.plantuml.ugraphic.UComment;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UStroke;
@ -125,6 +126,7 @@ public class EntityImageDescription extends AbstractEntityImage {
}
final public void drawU(UGraphic ug) {
ug.draw(new UComment("entity " + getEntity().getCode().getFullName()));
if (url != null) {
ug.startUrl(url);
}

View File

@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 20096 $
* Revision $Revision: 20128 $
*
*/
package net.sourceforge.plantuml.svg;
@ -65,6 +65,7 @@ import net.sourceforge.plantuml.ugraphic.UPath;
import net.sourceforge.plantuml.ugraphic.USegment;
import net.sourceforge.plantuml.ugraphic.USegmentType;
import org.w3c.dom.Comment;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@ -128,14 +129,26 @@ public class SvgGraphics {
gRoot = simpleElement("g");
strokeWidth = "" + scale;
final Random rnd = new Random();
this.filterUid = "b" + Integer.toString(Math.abs(rnd.nextInt()), 36);
this.shadowId = "f" + Integer.toString(Math.abs(rnd.nextInt()), 36);
this.filterUid = "b" + getRandomString(rnd);
this.shadowId = "f" + getRandomString(rnd);
} catch (ParserConfigurationException e) {
e.printStackTrace();
throw new IllegalStateException(e);
}
}
private static String getRandomString(final Random rnd) {
String result = Integer.toString(Math.abs(rnd.nextInt()), 36);
while (result.length() < 6) {
result = "0" + result;
}
return result;
}
public static void main(String[] args) {
System.err.println(getRandomString(new Random()));
}
private Element pendingBackground;
public void paintBackcolorGradient(ColorMapper mapper, HtmlColorGradient gr) {
@ -735,4 +748,9 @@ public class SvgGraphics {
this.hidden = hidden;
}
public void addComment(String comment) {
final Comment commentElement = document.createComment(comment);
getG().appendChild(commentElement);
}
}

View File

@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 19109 $
* Revision $Revision: 20127 $
*
*/
package net.sourceforge.plantuml.ugraphic;
@ -69,6 +69,10 @@ public abstract class AbstractUGraphic<O> extends AbstractCommonUGraphic {
if (shape instanceof UEmpty) {
return;
}
if (shape instanceof UComment) {
drawComment((UComment) shape);
return;
}
final UDriver<O> driver = drivers.get(shape.getClass());
if (driver == null) {
throw new UnsupportedOperationException(shape.getClass().toString() + " " + this.getClass());
@ -87,6 +91,9 @@ public abstract class AbstractUGraphic<O> extends AbstractCommonUGraphic {
afterDraw();
}
protected void drawComment(UComment shape) {
}
protected void beforeDraw() {
}

View File

@ -63,6 +63,7 @@ import net.sourceforge.plantuml.anim.AffineTransformation;
import net.sourceforge.plantuml.anim.Animation;
import net.sourceforge.plantuml.api.ImageDataComplex;
import net.sourceforge.plantuml.api.ImageDataSimple;
import net.sourceforge.plantuml.braille.UGraphicBraille;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.eps.EpsStrategy;
import net.sourceforge.plantuml.graphic.HtmlColor;
@ -96,8 +97,7 @@ public class ImageBuilder {
private UDrawable udrawable;
public ImageBuilder(ColorMapper colorMapper, double dpiFactor, HtmlColor mybackcolor, String metadata,
String warningOrError, double margin1, double margin2, Animation animation,
boolean useHandwritten) {
String warningOrError, double margin1, double margin2, Animation animation, boolean useHandwritten) {
this.colorMapper = colorMapper;
this.dpiFactor = dpiFactor;
this.mybackcolor = mybackcolor;
@ -242,8 +242,8 @@ public class ImageBuilder {
return im;
}
private UGraphic2 createUGraphic(FileFormatOption fileFormatOption, final Dimension2D dim,
Animation animationArg, double dx, double dy) {
private UGraphic2 createUGraphic(FileFormatOption fileFormatOption, final Dimension2D dim, Animation animationArg,
double dx, double dy) {
final FileFormat fileFormat = fileFormatOption.getFileFormat();
switch (fileFormat) {
case PNG:
@ -262,6 +262,8 @@ public class ImageBuilder {
return new UGraphicTikz(colorMapper, true);
case LATEX_NO_PREAMBLE:
return new UGraphicTikz(colorMapper, false);
case BRAILLE_PNG:
return new UGraphicBraille(colorMapper, fileFormat);
default:
throw new UnsupportedOperationException(fileFormat.toString());
}

View File

@ -121,6 +121,7 @@ public class LimitFinder implements UGraphic {
drawDotPath(x, y, (DotPath) shape);
} else if (shape instanceof UImage) {
drawImage(x, y, (UImage) shape);
} else if (shape instanceof UComment) {
} else if (shape instanceof UEmpty) {
drawEmpty(x, y, (UEmpty) shape);
} else if (shape instanceof TextBlock) {

View File

@ -0,0 +1,47 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 19109 $
*
*/
package net.sourceforge.plantuml.ugraphic;
public class UComment implements UShape {
private final String comment;
public UComment(String comment) {
this.comment = comment;
}
public String getComment() {
return comment;
}
}

View File

@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 19109 $
* Revision $Revision: 20186 $
*
*/
package net.sourceforge.plantuml.ugraphic;
@ -41,19 +41,26 @@ import java.util.List;
public class UPolygon extends AbstractShadowable {
private final List<Point2D.Double> all = new ArrayList<Point2D.Double>();
private final String name;
private MinMax minmax = MinMax.getEmpty(false);
public UPolygon() {
this((String) null);
}
public UPolygon(List<Point2D.Double> points) {
this((String) null);
all.addAll(points);
for (Point2D.Double pt : all) {
manageMinMax(pt.getX(), pt.getY());
}
}
public UPolygon(String name) {
this.name = name;
}
public void addPoint(double x, double y) {
all.add(new Point2D.Double(x, y));
manageMinMax(x, y);
@ -84,6 +91,9 @@ public class UPolygon extends AbstractShadowable {
@Override
public String toString() {
if (name != null) {
return name;
}
return super.toString() + " " + all;
}

View File

@ -94,4 +94,8 @@ public class UTranslate implements UChange {
return new Rectangle2D.Double(rect.getX() + dx, rect.getY() + dy, rect.getWidth(), rect.getHeight());
}
public UTranslate multiplyBy(double v) {
return new UTranslate(dx * v, dy * v);
}
}

View File

@ -47,6 +47,7 @@ import net.sourceforge.plantuml.ugraphic.AbstractUGraphic;
import net.sourceforge.plantuml.ugraphic.ClipContainer;
import net.sourceforge.plantuml.ugraphic.ColorMapper;
import net.sourceforge.plantuml.ugraphic.UCenteredCharacter;
import net.sourceforge.plantuml.ugraphic.UComment;
import net.sourceforge.plantuml.ugraphic.UEllipse;
import net.sourceforge.plantuml.ugraphic.UGraphic2;
import net.sourceforge.plantuml.ugraphic.UImage;
@ -159,6 +160,11 @@ public class UGraphicSvg extends AbstractUGraphic<SvgGraphics> implements ClipCo
createXml(os);
}
@Override
protected void drawComment(UComment comment) {
getGraphicObject().addComment(comment.getComment());
}
// @Override
// public String startHiddenGroup() {
// getGraphicObject().startHiddenGroup();

View File

@ -28,7 +28,7 @@
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 20097 $
* Revision $Revision: 20196 $
*
*/
package net.sourceforge.plantuml.version;
@ -39,7 +39,7 @@ import java.util.Date;
public class Version {
public static int version() {
return 8045;
return 8046;
}
public static String versionString() {
@ -71,7 +71,7 @@ public class Version {
}
public static long compileTime() {
return 1467650874144L;
return 1469468610162L;
}
public static String compileTimeString() {

View File

@ -41,6 +41,7 @@ import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.ThreadFactory;
import net.sourceforge.plantuml.cucadiagram.dot.ExeState;
import net.sourceforge.plantuml.cucadiagram.dot.Graphviz;
import net.sourceforge.plantuml.cucadiagram.dot.GraphvizVersion;
import net.sourceforge.plantuml.cucadiagram.dot.ProcessState;
@ -111,8 +112,8 @@ public class GraphvizJs implements Graphviz {
return "VizJs";
}
public boolean illegalDotExe() {
return false;
public ExeState getExeState() {
return ExeState.OK;
}
public static GraphvizVersion getGraphvizVersion(final boolean modeSafe) {