mirror of
https://github.com/octoleo/plantuml.git
synced 2024-05-29 06:30:48 +00:00
version 8052
This commit is contained in:
parent
23f63f7ae2
commit
3100d49b54
2
pom.xml
2
pom.xml
|
@ -35,7 +35,7 @@
|
|||
|
||||
<groupId>net.sourceforge.plantuml</groupId>
|
||||
<artifactId>plantuml</artifactId>
|
||||
<version>8052-SNAPSHOT</version>
|
||||
<version>8053-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>PlantUML</name>
|
||||
|
|
|
@ -121,7 +121,10 @@ public abstract class AbstractPSystem implements Diagram {
|
|||
try {
|
||||
return exportDiagramNow(os, index, fileFormatOption);
|
||||
} finally {
|
||||
StatsUtilsIncrement.onceMoreGenerate(System.currentTimeMillis() - now, getClass(), fileFormatOption.getFileFormat());
|
||||
if (OptionFlags.getInstance().isEnableStats()) {
|
||||
StatsUtilsIncrement.onceMoreGenerate(System.currentTimeMillis() - now, getClass(),
|
||||
fileFormatOption.getFileFormat());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,6 @@ import java.util.concurrent.Executors;
|
|||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import net.sourceforge.plantuml.preproc.Defines;
|
||||
import net.sourceforge.plantuml.preproc.FileWithSuffix;
|
||||
|
||||
public class DirWatcher2 {
|
||||
|
@ -62,6 +61,7 @@ public class DirWatcher2 {
|
|||
this.pattern = pattern;
|
||||
final int nb = Option.defaultNbThreads();
|
||||
this.executorService = Executors.newFixedThreadPool(nb);
|
||||
|
||||
}
|
||||
|
||||
public Map<File, Future<List<GeneratedImage>>> buildCreatedFiles() throws IOException, InterruptedException {
|
||||
|
@ -77,7 +77,7 @@ public class DirWatcher2 {
|
|||
final FileWatcher watcher = modifieds.get(f);
|
||||
|
||||
if (watcher == null || watcher.hasChanged()) {
|
||||
final SourceFileReader sourceFileReader = new SourceFileReader(new Defines(), f,
|
||||
final SourceFileReader sourceFileReader = new SourceFileReader(option.getDefaultDefines(), f,
|
||||
option.getOutputDir(), option.getConfig(), option.getCharset(),
|
||||
option.getFileFormatOption());
|
||||
modifieds.put(f, new FileWatcher(Collections.singleton(f)));
|
||||
|
@ -87,7 +87,8 @@ public class DirWatcher2 {
|
|||
try {
|
||||
final List<GeneratedImage> generatedImages = sourceFileReader
|
||||
.getGeneratedImages();
|
||||
final Set<File> files = FileWithSuffix.convert(sourceFileReader.getIncludedFiles());
|
||||
final Set<File> files = FileWithSuffix.convert(sourceFileReader
|
||||
.getIncludedFiles());
|
||||
files.add(f);
|
||||
modifieds.put(f, new FileWatcher(files));
|
||||
return Collections.unmodifiableList(generatedImages);
|
||||
|
|
|
@ -72,8 +72,6 @@ public interface ISkinParam extends ISkinSimple {
|
|||
|
||||
public ColorMapper getColorMapper();
|
||||
|
||||
public int getDpi();
|
||||
|
||||
public DotSplines getDotSplines();
|
||||
|
||||
public String getDotExecutable();
|
||||
|
@ -96,7 +94,7 @@ public interface ISkinParam extends ISkinSimple {
|
|||
|
||||
public double getRanksep();
|
||||
|
||||
public double getRoundCorner(String param);
|
||||
public double getRoundCorner(String param, Stereotype stereotype);
|
||||
|
||||
public double maxMessageSize();
|
||||
|
||||
|
|
|
@ -43,5 +43,7 @@ public interface ISkinSimple extends SpriteContainer {
|
|||
public int getTabSize();
|
||||
|
||||
public IHtmlColorSet getIHtmlColorSet();
|
||||
|
||||
public int getDpi();
|
||||
|
||||
}
|
|
@ -256,6 +256,10 @@ public class Option {
|
|||
OptionFlags.getInstance().setDumpStats(true);
|
||||
} else if (s.equalsIgnoreCase("-loopstats")) {
|
||||
OptionFlags.getInstance().setLoopStats(true);
|
||||
} else if (s.equalsIgnoreCase("-enablestats")) {
|
||||
OptionFlags.getInstance().setEnableStats(true);
|
||||
} else if (s.equalsIgnoreCase("-disablestats")) {
|
||||
OptionFlags.getInstance().setEnableStats(false);
|
||||
} else if (s.equalsIgnoreCase("-htmlstats")) {
|
||||
StatsUtils.setHtmlStats(true);
|
||||
} else if (s.equalsIgnoreCase("-xmlstats")) {
|
||||
|
|
|
@ -65,7 +65,6 @@ public class OptionFlags {
|
|||
static public final boolean OMEGA_CROSSING = false;
|
||||
|
||||
// static public final boolean LINK_BETWEEN_FIELDS = true;
|
||||
|
||||
// static public final boolean USE_JDOT = false;
|
||||
|
||||
public void reset() {
|
||||
|
@ -114,6 +113,7 @@ public class OptionFlags {
|
|||
private boolean dumpStats;
|
||||
private boolean loopStats;
|
||||
private boolean overwrite;
|
||||
private boolean enableStats = defaultForStats();
|
||||
private String fileSeparator = "_";
|
||||
private File logData;
|
||||
|
||||
|
@ -300,4 +300,20 @@ public class OptionFlags {
|
|||
this.loopStats = loopStats;
|
||||
}
|
||||
|
||||
private static boolean defaultForStats() {
|
||||
return isTrue(System.getProperty("PLANTUML_STATS")) || isTrue(System.getenv("PLANTUML_STATS"));
|
||||
}
|
||||
|
||||
private static boolean isTrue(final String value) {
|
||||
return "on".equalsIgnoreCase(value) || "true".equalsIgnoreCase(value) || "on".equalsIgnoreCase(value);
|
||||
}
|
||||
|
||||
public boolean isEnableStats() {
|
||||
return enableStats;
|
||||
}
|
||||
|
||||
public void setEnableStats(boolean enableStats) {
|
||||
this.enableStats = enableStats;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -119,9 +119,12 @@ public class OptionPrint {
|
|||
System.out.println(" -author[s]\t\tTo print information about PlantUML authors");
|
||||
System.out.println(" -overwrite\t\tTo allow to overwrite read only files");
|
||||
System.out.println(" -printfonts\t\tTo print fonts available on your system");
|
||||
System.out.println(" -enablestats\tTo enable statistics computation");
|
||||
System.out.println(" -disablestats\tTo disable statistics computation (default)");
|
||||
System.out.println(" -htmlstats\t\tTo output general statistics in file plantuml-stats.html");
|
||||
System.out.println(" -xmlstats\t\tTo output general statistics in file plantuml-stats.xml");
|
||||
System.out.println(" -realtimestats\tTo generate statistics on the fly rather than at the end");
|
||||
System.out.println(" -loopstats\t\tTo continuously print statistics about usage");
|
||||
System.out.println();
|
||||
System.out.println("If needed, you can setup the environment variable GRAPHVIZ_DOT.");
|
||||
exit();
|
||||
|
@ -249,19 +252,10 @@ public class OptionPrint {
|
|||
}
|
||||
|
||||
public static void printAbout() throws InterruptedException {
|
||||
// Duplicate in PSystemVersion
|
||||
System.out.println("PlantUML version " + Version.versionString() + " (" + Version.compileTimeString() + ")");
|
||||
System.out.println();
|
||||
System.out.println("Original idea: Arnaud Roques");
|
||||
System.out.println("Word Macro: Alain Bertucat & Matthieu Sabatier");
|
||||
System.out.println("Word Add-in: Adriaan van den Brand");
|
||||
System.out.println("Eclipse Plugin: Claude Durif & Anne Pecoil");
|
||||
System.out.println("Servlet & XWiki: Maxime Sinclair");
|
||||
System.out.println("Site design: Raphael Cotisson");
|
||||
System.out.println("Logo: Benjamin Croizet");
|
||||
System.out.println();
|
||||
System.out.println("http://plantuml.sourceforge.net");
|
||||
exit();
|
||||
for (String s : PSystemVersion.getAuthorsStrings(false)) {
|
||||
System.out.println(s);
|
||||
}
|
||||
OptionPrint.exit();
|
||||
}
|
||||
|
||||
public static void printLanguage() throws InterruptedException {
|
||||
|
|
|
@ -61,6 +61,7 @@ import net.sourceforge.plantuml.font.PSystemListFontsFactory;
|
|||
import net.sourceforge.plantuml.jcckit.PSystemJcckitFactory;
|
||||
import net.sourceforge.plantuml.jungle.PSystemTreeFactory;
|
||||
import net.sourceforge.plantuml.logo.PSystemLogoFactory;
|
||||
import net.sourceforge.plantuml.math.PSystemLatexFactory;
|
||||
import net.sourceforge.plantuml.math.PSystemMathFactory;
|
||||
import net.sourceforge.plantuml.openiconic.PSystemListOpenIconicFactory;
|
||||
import net.sourceforge.plantuml.openiconic.PSystemOpenIconicFactory;
|
||||
|
@ -109,7 +110,7 @@ public class PSystemBuilder {
|
|||
result = err;
|
||||
return err;
|
||||
} finally {
|
||||
if (result != null) {
|
||||
if (result != null && OptionFlags.getInstance().isEnableStats()) {
|
||||
StatsUtilsIncrement.onceMoreParse(System.currentTimeMillis() - now, result.getClass());
|
||||
}
|
||||
}
|
||||
|
@ -149,6 +150,7 @@ public class PSystemBuilder {
|
|||
factories.add(new PSystemSudokuFactory());
|
||||
}
|
||||
factories.add(new PSystemMathFactory(DiagramType.MATH));
|
||||
factories.add(new PSystemLatexFactory(DiagramType.LATEX));
|
||||
// factories.add(new PSystemStatsFactory());
|
||||
factories.add(new PSystemCreoleFactory());
|
||||
factories.add(new PSystemEggFactory());
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
*/
|
||||
package net.sourceforge.plantuml;
|
||||
|
||||
import h.stack;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
@ -594,8 +596,12 @@ public class SkinParam implements ISkinParam {
|
|||
return 0;
|
||||
}
|
||||
|
||||
public double getRoundCorner(String param) {
|
||||
final String value = getValue(param + "roundcorner");
|
||||
public double getRoundCorner(String param, Stereotype stereotype) {
|
||||
String key = param + "roundcorner";
|
||||
if (stereotype != null) {
|
||||
key += stereotype.getLabel(false);
|
||||
}
|
||||
final String value = getValue(key);
|
||||
if (value != null && value.matches("\\d+")) {
|
||||
return Double.parseDouble(value);
|
||||
}
|
||||
|
|
|
@ -142,8 +142,8 @@ public class SkinParamDelegator implements ISkinParam {
|
|||
return skinParam.getRanksep();
|
||||
}
|
||||
|
||||
public double getRoundCorner(String param) {
|
||||
return skinParam.getRoundCorner(param);
|
||||
public double getRoundCorner(String param, Stereotype stereotype) {
|
||||
return skinParam.getRoundCorner(param, stereotype);
|
||||
}
|
||||
|
||||
public UStroke getThickness(LineParam param, Stereotype stereotype) {
|
||||
|
|
|
@ -66,4 +66,8 @@ public class SpriteContainerEmpty implements SpriteContainer, ISkinSimple {
|
|||
return new HtmlColorSetSimple();
|
||||
}
|
||||
|
||||
public int getDpi() {
|
||||
return 96;
|
||||
}
|
||||
|
||||
}
|
|
@ -77,7 +77,7 @@ public abstract class AbstractFtile extends AbstractTextBlock implements Ftile {
|
|||
}
|
||||
|
||||
public UTranslate getTranslateFor(Ftile child, StringBounder stringBounder) {
|
||||
throw new UnsupportedOperationException();
|
||||
throw new UnsupportedOperationException("" + getClass());
|
||||
}
|
||||
|
||||
public final UStroke getThickness() {
|
||||
|
@ -92,4 +92,9 @@ public abstract class AbstractFtile extends AbstractTextBlock implements Ftile {
|
|||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public Collection<Ftile> getMyChildren() {
|
||||
throw new UnsupportedOperationException("" + getClass());
|
||||
// return Collections.emptyList();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -54,6 +54,8 @@ public interface Ftile extends Swimable, TextBlock {
|
|||
|
||||
public UTranslate getTranslateFor(Ftile child, StringBounder stringBounder);
|
||||
|
||||
public Collection<Ftile> getMyChildren();
|
||||
|
||||
public Collection<Connection> getInnerConnections();
|
||||
|
||||
public List<WeldingPoint> getWeldingPoints();
|
||||
|
|
|
@ -32,6 +32,7 @@ package net.sourceforge.plantuml.activitydiagram3.ftile;
|
|||
|
||||
import java.awt.geom.Dimension2D;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
|
@ -147,4 +148,8 @@ public class FtileAssemblySimple extends AbstractTextBlock implements Ftile {
|
|||
return Collections.unmodifiableList(result);
|
||||
}
|
||||
|
||||
public Collection<Ftile> getMyChildren() {
|
||||
return Arrays.asList(tile1, tile2);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
*/
|
||||
package net.sourceforge.plantuml.activitydiagram3.ftile;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -42,6 +43,16 @@ public class FtileBreak extends FtileEmpty implements WeldingPoint {
|
|||
super(skinParam, swimlane);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Ftile> getMyChildren() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "FtileBreak";
|
||||
}
|
||||
|
||||
public FtileGeometry calculateDimension(StringBounder stringBounder) {
|
||||
return super.calculateDimension(stringBounder).withoutPointOut();
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
*/
|
||||
package net.sourceforge.plantuml.activitydiagram3.ftile;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
@ -45,6 +46,11 @@ public class FtileEmpty extends AbstractFtile {
|
|||
private final Swimlane swimlaneIn;
|
||||
private final Swimlane swimlaneOut;
|
||||
|
||||
@Override
|
||||
public Collection<Ftile> getMyChildren() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public FtileEmpty(ISkinParam skinParam, double width, double height) {
|
||||
this(skinParam, width, height, null, null);
|
||||
}
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
*/
|
||||
package net.sourceforge.plantuml.activitydiagram3.ftile;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import net.sourceforge.plantuml.activitydiagram3.LinkRendering;
|
||||
|
@ -50,6 +52,12 @@ public class FtileMarged extends AbstractFtile {
|
|||
this.margin2 = margin2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Ftile> getMyChildren() {
|
||||
return Collections.singleton(tile);
|
||||
// return tile.getMyChildren();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LinkRendering getInLinkRendering() {
|
||||
return tile.getInLinkRendering();
|
||||
|
@ -79,13 +87,20 @@ public class FtileMarged extends AbstractFtile {
|
|||
}
|
||||
|
||||
public UTranslate getTranslateFor(Ftile child, StringBounder stringBounder) {
|
||||
if (child == tile) {
|
||||
return getTranslate();
|
||||
}
|
||||
UTranslate result = tile.getTranslateFor(child, stringBounder);
|
||||
result = result.compose(new UTranslate(margin1, 0));
|
||||
result = result.compose(getTranslate());
|
||||
return result;
|
||||
}
|
||||
|
||||
private UTranslate getTranslate() {
|
||||
return new UTranslate(margin1, 0);
|
||||
}
|
||||
|
||||
public void drawU(UGraphic ug) {
|
||||
ug.apply(new UTranslate(margin1, 0)).draw(tile);
|
||||
ug.apply(getTranslate()).draw(tile);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,87 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* This file is part of PlantUML.
|
||||
*
|
||||
* PlantUML is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlantUML distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.activitydiagram3.ftile;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||
|
||||
public class Genealogy {
|
||||
|
||||
private Map<Ftile, Ftile> myFatherIs = new HashMap<Ftile, Ftile>();
|
||||
private final Ftile root;
|
||||
|
||||
public Genealogy(Ftile root) {
|
||||
this.root = root;
|
||||
process(root);
|
||||
// System.err.println("myFatherIs=" + myFatherIs);
|
||||
}
|
||||
|
||||
private void process(Ftile current) {
|
||||
final Collection<Ftile> children = current.getMyChildren();
|
||||
// System.err.println("current=" + current);
|
||||
// System.err.println("children=" + children);
|
||||
for (Ftile child : children) {
|
||||
setMyFather(child, current);
|
||||
process(child);
|
||||
}
|
||||
}
|
||||
|
||||
public Ftile getMyFather(Ftile me) {
|
||||
return myFatherIs.get(me);
|
||||
}
|
||||
|
||||
private void setMyFather(Ftile child, Ftile father) {
|
||||
if (myFatherIs.containsKey(child)) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
myFatherIs.put(child, father);
|
||||
}
|
||||
|
||||
public UTranslate getTranslate(Ftile child, StringBounder stringBounder) {
|
||||
Ftile current = child;
|
||||
UTranslate result = new UTranslate();
|
||||
while (current != root) {
|
||||
final Ftile father = getMyFather(current);
|
||||
final UTranslate tr = father.getTranslateFor(current, stringBounder);
|
||||
// System.err.println("Father=" + father);
|
||||
// System.err.println("current=" + current);
|
||||
// System.err.println("TR=" + tr);
|
||||
result = tr.compose(result);
|
||||
current = father;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
|
@ -51,7 +51,7 @@ import net.sourceforge.plantuml.ugraphic.UTranslate;
|
|||
public class Snake implements UShape {
|
||||
|
||||
private final Worm worm = new Worm();
|
||||
private final UPolygon endDecoration;
|
||||
private UPolygon endDecoration;
|
||||
private final Rainbow color;
|
||||
private TextBlock textBlock;
|
||||
private MergeStrategy mergeable = MergeStrategy.FULL;
|
||||
|
@ -70,6 +70,10 @@ public class Snake implements UShape {
|
|||
return result;
|
||||
}
|
||||
|
||||
public void removeEndDecoration() {
|
||||
this.endDecoration = null;
|
||||
}
|
||||
|
||||
public Snake(Rainbow color, UPolygon endDecoration) {
|
||||
if (color == null) {
|
||||
throw new IllegalArgumentException();
|
||||
|
@ -173,6 +177,10 @@ public class Snake implements UShape {
|
|||
final Point2D pt1 = worm.get(0);
|
||||
final Point2D pt2 = worm.get(1);
|
||||
final Dimension2D dim = textBlock.calculateDimension(stringBounder);
|
||||
// if (worm.getDirectionsCode().startsWith("LD")) {
|
||||
// final double y = pt1.getY() - dim.getHeight();
|
||||
// return new Point2D.Double(Math.max(pt1.getX(), pt2.getX()) - dim.getWidth(), y);
|
||||
// }
|
||||
final double y = (pt1.getY() + pt2.getY()) / 2 - dim.getHeight() / 2;
|
||||
return new Point2D.Double(Math.max(pt1.getX(), pt2.getX()) + 4, y);
|
||||
}
|
||||
|
@ -208,16 +216,16 @@ public class Snake implements UShape {
|
|||
if (strategy == MergeStrategy.NONE) {
|
||||
return null;
|
||||
}
|
||||
if (TextBlockUtils.isEmpty(other.textBlock, stringBounder) == false) {
|
||||
return null;
|
||||
final boolean emptyOther = TextBlockUtils.isEmpty(other.textBlock, stringBounder);
|
||||
// final boolean emptyThis = TextBlockUtils.isEmpty(this.textBlock, stringBounder);
|
||||
if (emptyOther == false /* || emptyThis == false */) {
|
||||
// System.err.println("merge other.textBlock="+other.textBlock+" "+other.textBlock.calculateDimension(TextBlockUtils.getDummyStringBounder()));
|
||||
return null;
|
||||
}
|
||||
// if (other.textBlock != null) {
|
||||
// return null;
|
||||
// }
|
||||
if (same(this.getLast(), other.getFirst())) {
|
||||
final UPolygon oneOf = other.endDecoration == null ? endDecoration : other.endDecoration;
|
||||
final Snake result = new Snake(color, oneOf);
|
||||
// result.textBlock = oneOf(this.textBlock, other.textBlock, stringBounder);
|
||||
result.emphasizeDirection = emphasizeDirection == null ? other.emphasizeDirection : emphasizeDirection;
|
||||
result.worm.addAll(this.worm.merge(other.worm, strategy));
|
||||
result.mergeable = strategy;
|
||||
|
@ -229,6 +237,16 @@ public class Snake implements UShape {
|
|||
return null;
|
||||
}
|
||||
|
||||
public boolean touches(Snake other) {
|
||||
if (other.mergeable != MergeStrategy.FULL) {
|
||||
return false;
|
||||
}
|
||||
if (other.worm.isPureHorizontal()) {
|
||||
return false;
|
||||
}
|
||||
return same(this.getLast(), other.getFirst());
|
||||
}
|
||||
|
||||
public void goUnmergeable(MergeStrategy strategy) {
|
||||
this.mergeable = strategy;
|
||||
}
|
||||
|
|
|
@ -54,6 +54,10 @@ public class Worm implements Iterable<Point2D.Double> {
|
|||
|
||||
private final List<Point2D.Double> points = new ArrayList<Point2D.Double>();
|
||||
|
||||
public boolean isPureHorizontal() {
|
||||
return points.size() == 2 && points.get(0).getY() == points.get(1).getY();
|
||||
}
|
||||
|
||||
public void drawInternalOneColor(UGraphic ug, HtmlColorAndStyle color, double stroke, Direction emphasizeDirection,
|
||||
UPolygon endDecoration) {
|
||||
final HtmlColor color2 = color.getColor();
|
||||
|
|
|
@ -0,0 +1,141 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* This file is part of PlantUML.
|
||||
*
|
||||
* PlantUML is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlantUML distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.activitydiagram3.ftile;
|
||||
|
||||
import java.awt.geom.Dimension2D;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.util.Iterator;
|
||||
|
||||
import net.sourceforge.plantuml.Direction;
|
||||
import net.sourceforge.plantuml.graphic.HtmlColorAndStyle;
|
||||
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||
import net.sourceforge.plantuml.graphic.TextBlock;
|
||||
import net.sourceforge.plantuml.graphic.TextBlockUtils;
|
||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||
import net.sourceforge.plantuml.ugraphic.UPolygon;
|
||||
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||
|
||||
public class WormTexted implements Iterable<Point2D.Double> {
|
||||
|
||||
private final Worm worm;
|
||||
private TextBlock textBlock;
|
||||
|
||||
public WormTexted() {
|
||||
this(new Worm());
|
||||
}
|
||||
|
||||
private WormTexted(Worm worm) {
|
||||
this.worm = worm;
|
||||
}
|
||||
|
||||
public Iterator<Point2D.Double> iterator() {
|
||||
return worm.iterator();
|
||||
}
|
||||
|
||||
public void addPoint(double x, double y) {
|
||||
worm.addPoint(x, y);
|
||||
}
|
||||
|
||||
public void drawInternalOneColor(UGraphic ug, HtmlColorAndStyle color, double stroke, Direction emphasizeDirection,
|
||||
UPolygon endDecoration) {
|
||||
worm.drawInternalOneColor(ug, color, stroke, emphasizeDirection, endDecoration);
|
||||
}
|
||||
|
||||
public Worm getWorm() {
|
||||
return worm;
|
||||
}
|
||||
|
||||
public Point2D get(int i) {
|
||||
return worm.get(i);
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return worm.size();
|
||||
}
|
||||
|
||||
public WormTexted merge(WormTexted other, MergeStrategy merge) {
|
||||
final Worm result = worm.merge(other.worm, merge);
|
||||
return new WormTexted(result);
|
||||
}
|
||||
|
||||
public void addAll(WormTexted other) {
|
||||
this.worm.addAll(other.worm);
|
||||
|
||||
}
|
||||
|
||||
public void setLabel(TextBlock label) {
|
||||
if (textBlock != null) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
this.textBlock = label;
|
||||
}
|
||||
|
||||
public boolean isEmptyText(StringBounder stringBounder) {
|
||||
return TextBlockUtils.isEmpty(textBlock, stringBounder);
|
||||
}
|
||||
|
||||
private Point2D getTextBlockPosition(StringBounder stringBounder) {
|
||||
final Point2D pt1 = get(0);
|
||||
final Point2D pt2 = get(1);
|
||||
final Dimension2D dim = textBlock.calculateDimension(stringBounder);
|
||||
// if (worm.getDirectionsCode().startsWith("LD")) {
|
||||
// final double y = pt1.getY() - dim.getHeight();
|
||||
// return new Point2D.Double(Math.max(pt1.getX(), pt2.getX()) - dim.getWidth(), y);
|
||||
// }
|
||||
final double y = (pt1.getY() + pt2.getY()) / 2 - dim.getHeight() / 2;
|
||||
return new Point2D.Double(Math.max(pt1.getX(), pt2.getX()) + 4, y);
|
||||
}
|
||||
|
||||
public double getMaxX(StringBounder stringBounder) {
|
||||
double result = -Double.MAX_VALUE;
|
||||
for (Point2D pt : this) {
|
||||
result = Math.max(result, pt.getX());
|
||||
}
|
||||
if (textBlock != null) {
|
||||
final Point2D position = getTextBlockPosition(stringBounder);
|
||||
final Dimension2D dim = textBlock.calculateDimension(stringBounder);
|
||||
result = Math.max(result, position.getX() + dim.getWidth());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void drawInternalLabel(UGraphic ug) {
|
||||
if (textBlock != null) {
|
||||
final Point2D position = getTextBlockPosition(ug.getStringBounder());
|
||||
textBlock.drawU(ug.apply(new UTranslate(position)));
|
||||
}
|
||||
}
|
||||
|
||||
public void copyLabels(WormTexted other) {
|
||||
this.textBlock = other.textBlock;
|
||||
}
|
||||
|
||||
}
|
|
@ -30,15 +30,22 @@
|
|||
*/
|
||||
package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
|
||||
|
||||
import java.awt.geom.Dimension2D;
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.ColorParam;
|
||||
import net.sourceforge.plantuml.Direction;
|
||||
import net.sourceforge.plantuml.FontParam;
|
||||
import net.sourceforge.plantuml.activitydiagram3.LinkRendering;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.Connection;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileBreak;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactoryDelegator;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.Genealogy;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.Snake;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.WeldingPoint;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamond;
|
||||
|
@ -48,6 +55,7 @@ import net.sourceforge.plantuml.graphic.HtmlColor;
|
|||
import net.sourceforge.plantuml.graphic.HtmlColorAndStyle;
|
||||
import net.sourceforge.plantuml.graphic.Rainbow;
|
||||
import net.sourceforge.plantuml.svek.ConditionStyle;
|
||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||
|
||||
public class FtileFactoryDelegatorRepeat extends FtileFactoryDelegator {
|
||||
|
@ -57,8 +65,8 @@ public class FtileFactoryDelegatorRepeat extends FtileFactoryDelegator {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Ftile repeat(Swimlane swimlane, Swimlane swimlaneOut, Ftile repeat, Display test, Display yes, Display out,
|
||||
HtmlColor color, LinkRendering backRepeatLinkRendering) {
|
||||
public Ftile repeat(Swimlane swimlane, Swimlane swimlaneOut, final Ftile repeat, Display test, Display yes,
|
||||
Display out, HtmlColor color, LinkRendering backRepeatLinkRendering) {
|
||||
|
||||
final ConditionStyle conditionStyle = skinParam().getConditionStyle();
|
||||
|
||||
|
@ -79,13 +87,37 @@ public class FtileFactoryDelegatorRepeat extends FtileFactoryDelegator {
|
|||
|
||||
final List<WeldingPoint> weldingPoints = repeat.getWeldingPoints();
|
||||
if (weldingPoints.size() > 0) {
|
||||
// printAllChild(repeat);
|
||||
|
||||
final Ftile diamondBreak = new FtileDiamond(repeat.skinParam(), backColor, borderColor, swimlane);
|
||||
result = assembly(result, diamondBreak);
|
||||
final Genealogy genealogy = new Genealogy(result);
|
||||
|
||||
final FtileBreak ftileBreak = (FtileBreak) weldingPoints.get(0);
|
||||
System.err.println("break=" + ftileBreak);
|
||||
final UTranslate pos = repeat.getTranslateFor(ftileBreak, getStringBounder());
|
||||
System.err.println("pos=" + pos);
|
||||
|
||||
result = FtileUtils.addConnection(result, new Connection() {
|
||||
public void drawU(UGraphic ug) {
|
||||
final UTranslate tr1 = genealogy.getTranslate(ftileBreak, ug.getStringBounder());
|
||||
final UTranslate tr2 = genealogy.getTranslate(diamondBreak, ug.getStringBounder());
|
||||
final Dimension2D dimDiamond = diamondBreak.calculateDimension(ug.getStringBounder());
|
||||
|
||||
final Snake snake = new Snake(arrowColor, Arrows.asToRight());
|
||||
snake.addPoint(tr1.getDx(), tr1.getDy());
|
||||
snake.addPoint(0, tr1.getDy());
|
||||
snake.addPoint(0, tr2.getDy() + dimDiamond.getHeight() / 2);
|
||||
snake.addPoint(tr2.getDx(), tr2.getDy() + dimDiamond.getHeight() / 2);
|
||||
ug.draw(snake);
|
||||
}
|
||||
|
||||
public Ftile getFtile1() {
|
||||
return ftileBreak;
|
||||
}
|
||||
|
||||
public Ftile getFtile2() {
|
||||
return diamondBreak;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -33,6 +33,8 @@ package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
|
|||
import java.awt.geom.Dimension2D;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
@ -66,6 +68,14 @@ public class FtileIfDown extends AbstractFtile {
|
|||
private final Ftile diamond2;
|
||||
private final Ftile optionalStop;
|
||||
|
||||
@Override
|
||||
public Collection<Ftile> getMyChildren() {
|
||||
if (optionalStop == null) {
|
||||
return Arrays.asList(thenBlock, diamond1, diamond2);
|
||||
}
|
||||
return Arrays.asList(thenBlock, diamond1, diamond2, optionalStop);
|
||||
}
|
||||
|
||||
public Set<Swimlane> getSwimlanes() {
|
||||
final Set<Swimlane> result = new HashSet<Swimlane>(thenBlock.getSwimlanes());
|
||||
result.add(getSwimlaneIn());
|
||||
|
@ -331,7 +341,8 @@ public class FtileIfDown extends AbstractFtile {
|
|||
final FtileGeometry geoThen = thenBlock.calculateDimension(stringBounder);
|
||||
final FtileGeometry geoDiamond2 = diamond2.calculateDimension(stringBounder);
|
||||
final FtileGeometry geo = geoDiamond1.appendBottom(geoThen).appendBottom(geoDiamond2);
|
||||
final double height = geo.getHeight() + 4 * Diamond.diamondHalfSize;
|
||||
final double height = geo.getHeight() + 3 * Diamond.diamondHalfSize
|
||||
+ Math.max(Diamond.diamondHalfSize * 1, getSouthLabelHeight(stringBounder));
|
||||
double width = geo.getWidth() + Diamond.diamondHalfSize;
|
||||
if (optionalStop != null) {
|
||||
width += optionalStop.calculateDimension(stringBounder).getWidth() + getAdditionalWidth(stringBounder);
|
||||
|
@ -347,6 +358,16 @@ public class FtileIfDown extends AbstractFtile {
|
|||
return Math.max(stopWidth, val1 + stopWidth / 2);
|
||||
}
|
||||
|
||||
private double getSouthLabelHeight(StringBounder stringBounder) {
|
||||
if (diamond1 instanceof FtileDiamondInside) {
|
||||
return ((FtileDiamondInside) diamond1).getSouthLabelHeight(stringBounder);
|
||||
}
|
||||
if (diamond1 instanceof FtileDiamond) {
|
||||
return ((FtileDiamond) diamond1).getSouthLabelHeight(stringBounder);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private double getEastLabelWidth(StringBounder stringBounder) {
|
||||
if (diamond1 instanceof FtileDiamondInside) {
|
||||
return ((FtileDiamondInside) diamond1).getEastLabelWidth(stringBounder);
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
|
||||
|
||||
import java.awt.geom.Dimension2D;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -38,6 +39,7 @@ import net.sourceforge.plantuml.ColorParam;
|
|||
import net.sourceforge.plantuml.FontParam;
|
||||
import net.sourceforge.plantuml.ISkinParam;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
|
||||
import net.sourceforge.plantuml.creole.CreoleMode;
|
||||
|
@ -62,6 +64,11 @@ public class FtileNoteAlone extends AbstractFtile implements Stencil {
|
|||
private final Opale opale;
|
||||
private final boolean withOutPoint;
|
||||
private final Swimlane swimlane;
|
||||
|
||||
@Override
|
||||
public Collection<Ftile> getMyChildren() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public Set<Swimlane> getSwimlanes() {
|
||||
if (swimlane == null) {
|
||||
|
|
|
@ -33,6 +33,8 @@ package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
|
|||
import java.awt.geom.Dimension2D;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -74,6 +76,11 @@ class FtileRepeat extends AbstractFtile {
|
|||
private final Ftile diamond2;
|
||||
private final TextBlock tbTest;
|
||||
|
||||
@Override
|
||||
public Collection<Ftile> getMyChildren() {
|
||||
return Arrays.asList(repeat, diamond1, diamond2);
|
||||
}
|
||||
|
||||
private FtileRepeat(Ftile repeat, Ftile diamond1, Ftile diamond2, TextBlock tbTest) {
|
||||
super(repeat.skinParam());
|
||||
this.repeat = repeat;
|
||||
|
|
|
@ -33,6 +33,7 @@ package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
|
|||
import java.awt.geom.Dimension2D;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import net.sourceforge.plantuml.ColorParam;
|
||||
|
@ -84,6 +85,11 @@ public class FtileWithNoteOpale extends AbstractFtile implements Stencil {
|
|||
public Swimlane getSwimlaneOut() {
|
||||
return tile.getSwimlaneOut();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Ftile> getMyChildren() {
|
||||
return Collections.singleton(tile);
|
||||
}
|
||||
|
||||
public static Ftile create(Ftile tile, Collection<PositionedNote> notes, ISkinParam skinParam, boolean withLink) {
|
||||
if (notes.size() > 1) {
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.cond;
|
||||
|
||||
import java.awt.geom.Dimension2D;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
@ -55,6 +57,11 @@ public class FtileIfNude extends FtileDimensionMemoize {
|
|||
this.tile2 = tile2;
|
||||
this.in = in;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Ftile> getMyChildren() {
|
||||
return Arrays.asList(tile1, tile2);
|
||||
}
|
||||
|
||||
public boolean hasTwoBranches(StringBounder stringBounder) {
|
||||
return tile1.calculateDimension(stringBounder).hasPointOut()
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.cond;
|
||||
|
||||
import java.awt.geom.Dimension2D;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
|
||||
|
@ -52,6 +54,11 @@ public class FtileIfWithDiamonds extends FtileIfNude {
|
|||
this.diamond2 = diamond2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Ftile> getMyChildren() {
|
||||
return Arrays.asList(diamond1, diamond2, tile1, tile2);
|
||||
}
|
||||
|
||||
public int getYdelta1a(StringBounder stringBounder) {
|
||||
// if (getSwimlanes().size() > 1 && hasTwoBranches(stringBounder)) {
|
||||
if (getSwimlanes().size() > 1) {
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
package net.sourceforge.plantuml.activitydiagram3.ftile.vertical;
|
||||
|
||||
import java.awt.geom.Dimension2D;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -42,6 +43,7 @@ import net.sourceforge.plantuml.SkinParamUtils;
|
|||
import net.sourceforge.plantuml.activitydiagram3.LinkRendering;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.BoxStyle;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
|
||||
import net.sourceforge.plantuml.creole.CreoleMode;
|
||||
|
@ -149,4 +151,8 @@ public class FtileBox extends AbstractFtile {
|
|||
dim.getHeight() + 2 * MARGIN);
|
||||
}
|
||||
|
||||
public Collection<Ftile> getMyChildren() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
package net.sourceforge.plantuml.activitydiagram3.ftile.vertical;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -80,10 +81,6 @@ public abstract class FtileDecorate extends AbstractTextBlock implements Ftile {
|
|||
return ftile.getInnerConnections();
|
||||
}
|
||||
|
||||
public UTranslate getTranslateFor(Ftile child, StringBounder stringBounder) {
|
||||
return ftile.getTranslateFor(child, stringBounder);
|
||||
}
|
||||
|
||||
public Set<Swimlane> getSwimlanes() {
|
||||
return ftile.getSwimlanes();
|
||||
}
|
||||
|
@ -107,10 +104,23 @@ public abstract class FtileDecorate extends AbstractTextBlock implements Ftile {
|
|||
protected final Ftile getFtileDelegated() {
|
||||
return ftile;
|
||||
}
|
||||
|
||||
|
||||
public List<WeldingPoint> getWeldingPoints() {
|
||||
return ftile.getWeldingPoints();
|
||||
}
|
||||
|
||||
public UTranslate getTranslateFor(Ftile child, StringBounder stringBounder) {
|
||||
if (child == ftile) {
|
||||
return new UTranslate();
|
||||
}
|
||||
return ftile.getTranslateFor(child, stringBounder);
|
||||
}
|
||||
|
||||
public Collection<Ftile> getMyChildren() {
|
||||
if (this == ftile) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
return Collections.singleton(ftile);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
package net.sourceforge.plantuml.activitydiagram3.ftile.vertical;
|
||||
|
||||
import java.awt.geom.Dimension2D;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -64,6 +65,11 @@ public class FtileDiamond extends AbstractFtile {
|
|||
this(skinParam, backColor, borderColor, swimlane, TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0),
|
||||
TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Ftile> getMyChildren() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public FtileDiamond withNorth(TextBlock north) {
|
||||
return new FtileDiamond(skinParam(), backColor, borderColor, swimlane, north, south, east1, west1);
|
||||
|
@ -150,5 +156,11 @@ public class FtileDiamond extends AbstractFtile {
|
|||
final Dimension2D dimEast = east1.calculateDimension(stringBounder);
|
||||
return dimEast.getWidth();
|
||||
}
|
||||
|
||||
public double getSouthLabelHeight(StringBounder stringBounder) {
|
||||
final Dimension2D dimSouth = south.calculateDimension(stringBounder);
|
||||
return dimSouth.getHeight();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
package net.sourceforge.plantuml.activitydiagram3.ftile.vertical;
|
||||
|
||||
import java.awt.geom.Dimension2D;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -61,6 +62,11 @@ public class FtileDiamondInside extends AbstractFtile {
|
|||
private final TextBlock north;
|
||||
private final TextBlock south;
|
||||
|
||||
@Override
|
||||
public Collection<Ftile> getMyChildren() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public FtileDiamondInside(ISkinParam skinParam, HtmlColor backColor, HtmlColor borderColor, Swimlane swimlane,
|
||||
TextBlock label) {
|
||||
this(skinParam, backColor, borderColor, swimlane, label, TextBlockUtils.empty(0, 0),
|
||||
|
@ -164,4 +170,9 @@ public class FtileDiamondInside extends AbstractFtile {
|
|||
return dimEast.getWidth();
|
||||
}
|
||||
|
||||
public double getSouthLabelHeight(StringBounder stringBounder) {
|
||||
final Dimension2D dimSouth = south.calculateDimension(stringBounder);
|
||||
return dimSouth.getHeight();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -390,4 +390,9 @@ public class PlantUmlTask extends Task {
|
|||
StatsUtils.setRealTimeStats(flag);
|
||||
}
|
||||
|
||||
public void setEnableStats(String s) {
|
||||
final boolean flag = "true".equalsIgnoreCase(s) || "yes".equalsIgnoreCase(s) || "on".equalsIgnoreCase(s);
|
||||
OptionFlags.getInstance().setEnableStats(flag);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ public class CommandAddMethod extends SingleLineCommand<ClassDiagram> {
|
|||
if (field.length() > 0 && VisibilityModifier.isVisibilityCharacter(field.charAt(0))) {
|
||||
system.setVisibilityModifierPresent(true);
|
||||
}
|
||||
entity.getBodier().addFieldOrMethod(field);
|
||||
entity.getBodier().addFieldOrMethod(field, entity);
|
||||
return CommandExecutionResult.ok();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -135,7 +135,7 @@ public class CommandCreateClassMultilines extends CommandMultilines2<ClassDiagra
|
|||
if (s.length() > 0 && VisibilityModifier.isVisibilityCharacter(s.charAt(0))) {
|
||||
diagram.setVisibilityModifierPresent(true);
|
||||
}
|
||||
entity.getBodier().addFieldOrMethod(s.toString());
|
||||
entity.getBodier().addFieldOrMethod(s.toString(), entity);
|
||||
}
|
||||
if (url != null) {
|
||||
entity.addUrl(url);
|
||||
|
|
|
@ -61,6 +61,9 @@ import net.sourceforge.plantuml.objectdiagram.AbstractClassOrObjectDiagram;
|
|||
|
||||
final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrObjectDiagram> {
|
||||
|
||||
private static final String SINGLE = "[.\\\\]{0,2}[\\p{L}0-9_]+(?:[.\\\\]{1,2}[\\p{L}0-9_]+)*";
|
||||
private static final String COUPLE = "\\([%s]*(" + SINGLE + ")[%s]*,[%s]*(" + SINGLE + ")[%s]*\\)";
|
||||
|
||||
public CommandLinkClass(UmlDiagramType umlDiagramType) {
|
||||
super(getRegexConcat(umlDiagramType));
|
||||
}
|
||||
|
@ -68,12 +71,10 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
|
|||
static private RegexConcat getRegexConcat(UmlDiagramType umlDiagramType) {
|
||||
return new RegexConcat(
|
||||
new RegexLeaf("HEADER", "^(?:@([\\d.]+)[%s]+)?"), //
|
||||
new RegexOr(
|
||||
//
|
||||
new RegexOr( //
|
||||
new RegexLeaf("ENT1", "(?:" + optionalKeywords(umlDiagramType) + "[%s]+)?"
|
||||
+ getClassIdentifier()),
|
||||
new RegexLeaf("COUPLE1",
|
||||
"\\([%s]*(\\.?[\\p{L}0-9_]+(?:\\.[\\p{L}0-9_]+)*)[%s]*,[%s]*(\\.?[\\p{L}0-9_]+(?:\\.[\\p{L}0-9_]+)*)[%s]*\\)")),
|
||||
+ getClassIdentifier()),//
|
||||
new RegexLeaf("COUPLE1", COUPLE)),
|
||||
new RegexLeaf("[%s]*"), //
|
||||
new RegexLeaf("FIRST_LABEL", "(?:[%g]([^%g]+)[%g])?"), //
|
||||
new RegexLeaf("[%s]*"), //
|
||||
|
@ -92,13 +93,11 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
|
|||
new RegexLeaf("ARROW_HEAD2", "([ox][%s]+|[#\\]>*+^{]|\\|[>\\]])?")), //
|
||||
|
||||
new RegexLeaf("[%s]*"), //
|
||||
new RegexLeaf("SECOND_LABEL", "(?:[%g]([^%g]+)[%g])?"),
|
||||
new RegexLeaf("[%s]*"), //
|
||||
new RegexOr(
|
||||
new RegexLeaf("SECOND_LABEL", "(?:[%g]([^%g]+)[%g])?"), new RegexLeaf("[%s]*"), //
|
||||
new RegexOr( //
|
||||
new RegexLeaf("ENT2", "(?:" + optionalKeywords(umlDiagramType) + "[%s]+)?"
|
||||
+ getClassIdentifier()),
|
||||
new RegexLeaf("COUPLE2",
|
||||
"\\([%s]*(\\.?[\\p{L}0-9_]+(?:\\.[\\p{L}0-9_]+)*)[%s]*,[%s]*(\\.?[\\p{L}0-9_]+(?:\\.[\\p{L}0-9_]+)*)[%s]*\\)")),
|
||||
+ getClassIdentifier()), //
|
||||
new RegexLeaf("COUPLE2", COUPLE)), //
|
||||
new RegexLeaf("[%s]*"), //
|
||||
color().getRegex(), //
|
||||
new RegexLeaf("[%s]*"), //
|
||||
|
@ -149,7 +148,7 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
|
|||
}
|
||||
ent1 = ent1.eventuallyRemoveStartingAndEndingDoubleQuote("\"");
|
||||
ent2 = ent2.eventuallyRemoveStartingAndEndingDoubleQuote("\"");
|
||||
if (diagram.isGroup(ent1) && diagram.isGroup(ent2)) {
|
||||
if (isGroupButNotTheCurrentGroup(diagram, ent1) && isGroupButNotTheCurrentGroup(diagram, ent2)) {
|
||||
return executePackageLink(diagram, arg);
|
||||
}
|
||||
|
||||
|
@ -168,7 +167,7 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
|
|||
final String type1 = arg.get("ENT1", 0);
|
||||
final LeafType typeIfObject1 = getTypeIfObject(type1);
|
||||
|
||||
final IEntity cl1 = diagram.isGroup(ent1) ? diagram.getGroup(Code.of(StringUtils
|
||||
final IEntity cl1 = isGroupButNotTheCurrentGroup(diagram, ent1) ? diagram.getGroup(Code.of(StringUtils
|
||||
.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT1", 1), "\""))) : diagram.getOrCreateLeaf(
|
||||
ent1, typeIfObject1, null);
|
||||
|
||||
|
@ -178,7 +177,7 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
|
|||
typeIfObject2 = LeafType.OBJECT;
|
||||
}
|
||||
|
||||
final IEntity cl2 = diagram.isGroup(ent2) ? diagram.getGroup(Code.of(StringUtils
|
||||
final IEntity cl2 = isGroupButNotTheCurrentGroup(diagram, ent2) ? diagram.getGroup(Code.of(StringUtils
|
||||
.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT2", 1), "\""))) : diagram.getOrCreateLeaf(
|
||||
ent2, typeIfObject2, null);
|
||||
|
||||
|
@ -281,6 +280,13 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
|
|||
return CommandExecutionResult.ok();
|
||||
}
|
||||
|
||||
private boolean isGroupButNotTheCurrentGroup(AbstractClassOrObjectDiagram diagram, Code code) {
|
||||
if (diagram.getCurrentGroup().getCode().equals(code)) {
|
||||
return false;
|
||||
}
|
||||
return diagram.isGroup(code);
|
||||
}
|
||||
|
||||
private Code removeMemberPart(AbstractClassOrObjectDiagram diagram, Code code) {
|
||||
if (diagram.leafExist(code)) {
|
||||
return null;
|
||||
|
|
|
@ -33,7 +33,7 @@ package net.sourceforge.plantuml.core;
|
|||
import net.sourceforge.plantuml.utils.StartUtils;
|
||||
|
||||
public enum DiagramType {
|
||||
UML, DITAA, DOT, PROJECT, JCCKIT, SALT, FLOW, CREOLE, JUNGLE, CUTE, MATH, UNKNOWN;
|
||||
UML, DITAA, DOT, PROJECT, JCCKIT, SALT, FLOW, CREOLE, JUNGLE, CUTE, MATH, LATEX, UNKNOWN;
|
||||
|
||||
static public DiagramType getTypeFromArobaseStart(String s) {
|
||||
s = s.toLowerCase();
|
||||
|
@ -73,6 +73,9 @@ public enum DiagramType {
|
|||
if (StartUtils.startsWithSymbolAnd("startmath", s)) {
|
||||
return MATH;
|
||||
}
|
||||
if (StartUtils.startsWithSymbolAnd("startlatex", s)) {
|
||||
return LATEX;
|
||||
}
|
||||
return UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,25 +38,28 @@ import net.sourceforge.plantuml.Dimension2DDouble;
|
|||
import net.sourceforge.plantuml.graphic.HtmlColor;
|
||||
import net.sourceforge.plantuml.graphic.HtmlColorSimple;
|
||||
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||
import net.sourceforge.plantuml.math.AsciiMathSafe;
|
||||
import net.sourceforge.plantuml.math.ScientificEquationSafe;
|
||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||
import net.sourceforge.plantuml.ugraphic.UImage;
|
||||
import net.sourceforge.plantuml.ugraphic.UImageSvg;
|
||||
|
||||
public class AtomMath implements Atom {
|
||||
|
||||
private final double scale = 1;
|
||||
private final AsciiMathSafe math;
|
||||
private final double scale;
|
||||
private final ScientificEquationSafe math;
|
||||
private final HtmlColor foreground;
|
||||
private final HtmlColor background;
|
||||
|
||||
public AtomMath(AsciiMathSafe math, HtmlColor foreground) {
|
||||
public AtomMath(ScientificEquationSafe math, HtmlColor foreground, HtmlColor background, double scale) {
|
||||
this.math = math;
|
||||
this.foreground = foreground;
|
||||
this.background = background;
|
||||
this.scale = scale;
|
||||
}
|
||||
|
||||
private Dimension2D calculateDimensionSlow(StringBounder stringBounder) {
|
||||
final BufferedImage image = math.getImage(Color.BLACK, Color.WHITE);
|
||||
return new Dimension2DDouble(image.getWidth() * scale, image.getHeight() * scale);
|
||||
final BufferedImage image = math.getImage(scale, Color.BLACK, Color.WHITE);
|
||||
return new Dimension2DDouble(image.getWidth(), image.getHeight());
|
||||
}
|
||||
|
||||
private Dimension2D dim;
|
||||
|
@ -74,13 +77,13 @@ public class AtomMath implements Atom {
|
|||
|
||||
public void drawU(UGraphic ug) {
|
||||
final boolean isSvg = ug.matchesProperty("SVG");
|
||||
final Color back = getColor(ug.getParam().getBackcolor(), Color.WHITE);
|
||||
final Color back = getColor(background == null ? ug.getParam().getBackcolor() : background, Color.WHITE);
|
||||
final Color fore = getColor(foreground, Color.BLACK);
|
||||
if (isSvg) {
|
||||
final String svg = math.getSvg(fore, back);
|
||||
ug.draw(new UImageSvg(svg));
|
||||
} else {
|
||||
ug.draw(new UImage(math.getImage(fore, back), scale));
|
||||
ug.draw(new UImage(math.getImage(scale, fore, back)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
71
src/net/sourceforge/plantuml/creole/CommandCreoleLatex.java
Normal file
71
src/net/sourceforge/plantuml/creole/CommandCreoleLatex.java
Normal 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.
|
||||
*
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.creole;
|
||||
|
||||
import net.sourceforge.plantuml.command.regex.Matcher2;
|
||||
import net.sourceforge.plantuml.command.regex.MyPattern;
|
||||
import net.sourceforge.plantuml.command.regex.Pattern2;
|
||||
import net.sourceforge.plantuml.graphic.Splitter;
|
||||
import net.sourceforge.plantuml.math.ScientificEquationSafe;
|
||||
|
||||
public class CommandCreoleLatex implements Command {
|
||||
|
||||
private final Pattern2 pattern;
|
||||
private final double scale;
|
||||
|
||||
private CommandCreoleLatex(String p, double scale) {
|
||||
this.pattern = MyPattern.cmpile(p);
|
||||
this.scale = scale;
|
||||
}
|
||||
|
||||
public static Command create(double scale) {
|
||||
return new CommandCreoleLatex("^(?i)(" + Splitter.latexPattern + ")", scale);
|
||||
}
|
||||
|
||||
public int matchingSize(String line) {
|
||||
final Matcher2 m = pattern.matcher(line);
|
||||
if (m.find() == false) {
|
||||
return 0;
|
||||
}
|
||||
return m.group(1).length();
|
||||
}
|
||||
|
||||
public String executeAndGetRemaining(String line, StripeSimple stripe) {
|
||||
final Matcher2 m = pattern.matcher(line);
|
||||
if (m.find() == false) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
final String latex = m.group(2);
|
||||
stripe.addMath(ScientificEquationSafe.fromLatex(latex), scale);
|
||||
return line.substring(m.group(1).length());
|
||||
}
|
||||
|
||||
}
|
|
@ -34,18 +34,20 @@ import net.sourceforge.plantuml.command.regex.Matcher2;
|
|||
import net.sourceforge.plantuml.command.regex.MyPattern;
|
||||
import net.sourceforge.plantuml.command.regex.Pattern2;
|
||||
import net.sourceforge.plantuml.graphic.Splitter;
|
||||
import net.sourceforge.plantuml.math.AsciiMathSafe;
|
||||
import net.sourceforge.plantuml.math.ScientificEquationSafe;
|
||||
|
||||
public class CommandCreoleMath implements Command {
|
||||
|
||||
private final Pattern2 pattern;
|
||||
private final double scale;
|
||||
|
||||
private CommandCreoleMath(String p) {
|
||||
private CommandCreoleMath(String p, double scale) {
|
||||
this.pattern = MyPattern.cmpile(p);
|
||||
this.scale = scale;
|
||||
}
|
||||
|
||||
public static Command create() {
|
||||
return new CommandCreoleMath("^(?i)(" + Splitter.mathPattern + ")");
|
||||
public static Command create(double scale) {
|
||||
return new CommandCreoleMath("^(?i)(" + Splitter.mathPattern + ")", scale);
|
||||
}
|
||||
|
||||
public int matchingSize(String line) {
|
||||
|
@ -62,7 +64,7 @@ public class CommandCreoleMath implements Command {
|
|||
throw new IllegalStateException();
|
||||
}
|
||||
final String math = m.group(2);
|
||||
stripe.addMath(new AsciiMathSafe(math));
|
||||
stripe.addMath(ScientificEquationSafe.fromAsciiMath(math), scale);
|
||||
return line.substring(m.group(1).length());
|
||||
}
|
||||
|
||||
|
|
|
@ -44,6 +44,11 @@ public class Sheet implements Iterable<Stripe> {
|
|||
public Sheet(HorizontalAlignment horizontalAlignment) {
|
||||
this.horizontalAlignment = horizontalAlignment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return stripes.toString();
|
||||
}
|
||||
|
||||
public void add(Stripe stripe) {
|
||||
stripes.add(stripe);
|
||||
|
|
|
@ -62,6 +62,11 @@ public class SheetBlock1 extends AbstractTextBlock implements TextBlock, Atom, S
|
|||
this.maxWidth = maxWidth;
|
||||
this.padding = padding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return sheet.toString();
|
||||
}
|
||||
|
||||
public HorizontalAlignment getCellAlignment() {
|
||||
if (stripes.size() != 1) {
|
||||
|
|
|
@ -54,6 +54,11 @@ public class SheetBlock2 extends AbstractTextBlock implements TextBlock, Atom {
|
|||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return block.toString();
|
||||
}
|
||||
|
||||
public Dimension2D calculateDimension(StringBounder stringBounder) {
|
||||
return block.calculateDimension(stringBounder);
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
*/
|
||||
package net.sourceforge.plantuml.creole;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
@ -41,10 +40,8 @@ import net.sourceforge.plantuml.graphic.FontConfiguration;
|
|||
import net.sourceforge.plantuml.graphic.FontPosition;
|
||||
import net.sourceforge.plantuml.graphic.FontStyle;
|
||||
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
|
||||
import net.sourceforge.plantuml.graphic.HtmlColor;
|
||||
import net.sourceforge.plantuml.graphic.HtmlColorSimple;
|
||||
import net.sourceforge.plantuml.graphic.ImgValign;
|
||||
import net.sourceforge.plantuml.math.AsciiMathSafe;
|
||||
import net.sourceforge.plantuml.math.ScientificEquationSafe;
|
||||
import net.sourceforge.plantuml.openiconic.OpenIcon;
|
||||
import net.sourceforge.plantuml.ugraphic.sprite.Sprite;
|
||||
import net.sourceforge.plantuml.utils.CharHidder;
|
||||
|
@ -68,6 +65,11 @@ public class StripeSimple implements Stripe {
|
|||
final private StripeStyle style;
|
||||
final private ISkinSimple skinParam;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString() + " " + atoms.toString();
|
||||
}
|
||||
|
||||
public StripeSimple(FontConfiguration fontConfiguration, StripeStyle style, CreoleContext context,
|
||||
ISkinSimple skinParam, CreoleMode modeSimpleLine) {
|
||||
this.fontConfiguration = fontConfiguration;
|
||||
|
@ -81,6 +83,8 @@ public class StripeSimple implements Stripe {
|
|||
this.commands.add(CommandCreoleStyle.createCreole(FontStyle.ITALIC));
|
||||
this.commands.add(CommandCreoleStyle.createLegacy(FontStyle.ITALIC));
|
||||
this.commands.add(CommandCreoleStyle.createLegacyEol(FontStyle.ITALIC));
|
||||
this.commands.add(CommandCreoleStyle.createLegacy(FontStyle.PLAIN));
|
||||
this.commands.add(CommandCreoleStyle.createLegacyEol(FontStyle.PLAIN));
|
||||
if (modeSimpleLine == CreoleMode.FULL) {
|
||||
this.commands.add(CommandCreoleStyle.createCreole(FontStyle.UNDERLINE));
|
||||
}
|
||||
|
@ -104,7 +108,9 @@ public class StripeSimple implements Stripe {
|
|||
this.commands.add(CommandCreoleExposantChange.create(FontPosition.INDICE));
|
||||
this.commands.add(CommandCreoleImg.create());
|
||||
this.commands.add(CommandCreoleOpenIcon.create());
|
||||
this.commands.add(CommandCreoleMath.create());
|
||||
final double scale = skinParam.getDpi() / 96.0;
|
||||
this.commands.add(CommandCreoleMath.create(scale));
|
||||
this.commands.add(CommandCreoleLatex.create(scale));
|
||||
this.commands.add(CommandCreoleSprite.create());
|
||||
this.commands.add(CommandCreoleSpace.create());
|
||||
this.commands.add(CommandCreoleFontFamilyChange.create());
|
||||
|
@ -175,8 +181,8 @@ public class StripeSimple implements Stripe {
|
|||
}
|
||||
}
|
||||
|
||||
public void addMath(AsciiMathSafe math) {
|
||||
atoms.add(new AtomMath(math, fontConfiguration.getColor()));
|
||||
public void addMath(ScientificEquationSafe math, double scale) {
|
||||
atoms.add(new AtomMath(math, fontConfiguration.getColor(), fontConfiguration.getExtendedColor(), scale));
|
||||
}
|
||||
|
||||
private void modifyStripe(String line) {
|
||||
|
|
|
@ -52,6 +52,7 @@ public class Bodier {
|
|||
private List<Member> methodsToDisplay;
|
||||
private List<Member> fieldsToDisplay;
|
||||
private final boolean manageModifier;
|
||||
private ILeaf leaf;
|
||||
|
||||
public void muteClassToObject() {
|
||||
methodsToDisplay = null;
|
||||
|
@ -65,11 +66,20 @@ public class Bodier {
|
|||
this.manageModifier = type == null ? false : type.manageModifier();
|
||||
}
|
||||
|
||||
public void addFieldOrMethod(String s) {
|
||||
public void addFieldOrMethod(String s, IEntity leaf) {
|
||||
if (leaf == null) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
// Empty cache
|
||||
methodsToDisplay = null;
|
||||
fieldsToDisplay = null;
|
||||
rawBody.add(s);
|
||||
if (leaf instanceof ILeaf) {
|
||||
if (this.leaf != null && this.leaf != leaf) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
this.leaf = (ILeaf) leaf;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isBodyEnhanced() {
|
||||
|
@ -162,12 +172,12 @@ public class Bodier {
|
|||
final boolean showFields, Stereotype stereotype) {
|
||||
if (type.isLikeClass() && isBodyEnhanced()) {
|
||||
if (showMethods || showFields) {
|
||||
return new BodyEnhanced(rawBody, fontParam, skinParam, manageModifier, stereotype);
|
||||
return new BodyEnhanced(rawBody, fontParam, skinParam, manageModifier, stereotype, leaf);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
final MethodsOrFieldsArea fields = new MethodsOrFieldsArea(getFieldsToDisplay(), fontParam, skinParam,
|
||||
stereotype);
|
||||
stereotype, leaf);
|
||||
if (type == LeafType.OBJECT) {
|
||||
if (showFields == false) {
|
||||
return new TextBlockLineBefore(TextBlockUtils.empty(0, 0));
|
||||
|
@ -178,7 +188,7 @@ public class Bodier {
|
|||
throw new UnsupportedOperationException();
|
||||
}
|
||||
final MethodsOrFieldsArea methods = new MethodsOrFieldsArea(getMethodsToDisplay(), fontParam, skinParam,
|
||||
stereotype);
|
||||
stereotype, leaf);
|
||||
if (showFields && showMethods == false) {
|
||||
return fields.asBlockMemberImpl();
|
||||
} else if (showMethods && showFields == false) {
|
||||
|
|
|
@ -70,9 +70,10 @@ public class BodyEnhanced extends AbstractTextBlock implements TextBlock, WithPo
|
|||
private final List<Url> urls = new ArrayList<Url>();
|
||||
private final boolean manageUrl;
|
||||
private final Stereotype stereotype;
|
||||
private final ILeaf entity;
|
||||
|
||||
public BodyEnhanced(List<String> rawBody, FontParam fontParam, ISkinParam skinParam, boolean manageModifier,
|
||||
Stereotype stereotype) {
|
||||
Stereotype stereotype, ILeaf entity) {
|
||||
this.rawBody = new ArrayList<String>(rawBody);
|
||||
this.stereotype = stereotype;
|
||||
this.fontParam = fontParam;
|
||||
|
@ -84,10 +85,12 @@ public class BodyEnhanced extends AbstractTextBlock implements TextBlock, WithPo
|
|||
this.align = HorizontalAlignment.LEFT;
|
||||
this.manageHorizontalLine = true;
|
||||
this.manageModifier = manageModifier;
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
public BodyEnhanced(Display display, FontParam fontParam, ISkinParam skinParam, HorizontalAlignment align,
|
||||
Stereotype stereotype, boolean manageHorizontalLine, boolean manageModifier, boolean manageUrl) {
|
||||
Stereotype stereotype, boolean manageHorizontalLine, boolean manageModifier, boolean manageUrl, ILeaf entity) {
|
||||
this.entity = entity;
|
||||
this.manageUrl = manageUrl;
|
||||
this.stereotype = stereotype;
|
||||
this.rawBody = new ArrayList<String>();
|
||||
|
@ -136,14 +139,14 @@ public class BodyEnhanced extends AbstractTextBlock implements TextBlock, WithPo
|
|||
final String s = it.next();
|
||||
if (manageHorizontalLine && isBlockSeparator(s)) {
|
||||
blocks.add(decorate(stringBounder, new MethodsOrFieldsArea(members, fontParam, skinParam, align,
|
||||
stereotype), separator, title));
|
||||
stereotype, entity), separator, title));
|
||||
separator = s.charAt(0);
|
||||
title = getTitle(s, skinParam);
|
||||
members = new ArrayList<Member>();
|
||||
} else if (CreoleParser.isTreeStart(s)) {
|
||||
if (members.size() > 0) {
|
||||
blocks.add(decorate(stringBounder, new MethodsOrFieldsArea(members, fontParam, skinParam, align,
|
||||
stereotype), separator, title));
|
||||
stereotype, entity), separator, title));
|
||||
}
|
||||
members = new ArrayList<Member>();
|
||||
final List<String> allTree = buildAllTree(s, it);
|
||||
|
@ -158,7 +161,7 @@ public class BodyEnhanced extends AbstractTextBlock implements TextBlock, WithPo
|
|||
}
|
||||
}
|
||||
}
|
||||
blocks.add(decorate(stringBounder, new MethodsOrFieldsArea(members, fontParam, skinParam, align, stereotype),
|
||||
blocks.add(decorate(stringBounder, new MethodsOrFieldsArea(members, fontParam, skinParam, align, stereotype, entity),
|
||||
separator, title));
|
||||
|
||||
if (blocks.size() == 1) {
|
||||
|
|
93
src/net/sourceforge/plantuml/cucadiagram/Election.java
Normal file
93
src/net/sourceforge/plantuml/cucadiagram/Election.java
Normal 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.
|
||||
*
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.cucadiagram;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
class Election {
|
||||
|
||||
private final Map<String, Member> all = new HashMap<String, Member>();
|
||||
|
||||
public void addCandidat(String display, Member candidat) {
|
||||
all.put(display, candidat);
|
||||
|
||||
}
|
||||
|
||||
private Member getCandidat(String shortName) {
|
||||
List<Member> list = getAllCandidatContains(shortName);
|
||||
if (list.size() == 1) {
|
||||
return list.get(0);
|
||||
}
|
||||
list = getAllCandidatContainsStrict(shortName);
|
||||
if (list.size() == 1) {
|
||||
return list.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<Member> getAllCandidatContains(String shortName) {
|
||||
final List<Member> result = new ArrayList<Member>();
|
||||
for (Map.Entry<String, Member> ent : all.entrySet()) {
|
||||
if (ent.getKey().contains(shortName)) {
|
||||
result.add(ent.getValue());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<Member> getAllCandidatContainsStrict(String shortName) {
|
||||
final List<Member> result = new ArrayList<Member>();
|
||||
for (Map.Entry<String, Member> ent : all.entrySet()) {
|
||||
final String key = ent.getKey();
|
||||
if (key.matches(".*\\b" + shortName + "\\b.*")) {
|
||||
result.add(ent.getValue());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public Map<Member, String> getAllElected(Collection<String> shortNames) {
|
||||
final Map<Member, String> memberWithPort = new HashMap<Member, String>();
|
||||
for (String shortName : shortNames) {
|
||||
final Member m = getCandidat(shortName);
|
||||
if (m != null) {
|
||||
memberWithPort.put(m, shortName);
|
||||
}
|
||||
}
|
||||
return Collections.unmodifiableMap(memberWithPort);
|
||||
}
|
||||
|
||||
}
|
|
@ -66,7 +66,7 @@ public class EntityPort {
|
|||
return this.uid.equals(other.uid);
|
||||
}
|
||||
|
||||
public String getPortName() {
|
||||
private String getPortName() {
|
||||
return portName;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
*/
|
||||
package net.sourceforge.plantuml.cucadiagram;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import net.sourceforge.plantuml.cucadiagram.dot.Neighborhood;
|
||||
import net.sourceforge.plantuml.graphic.USymbol;
|
||||
import net.sourceforge.plantuml.skin.VisibilityModifier;
|
||||
|
@ -67,9 +69,9 @@ public interface ILeaf extends IEntity {
|
|||
|
||||
public Neighborhood getNeighborhood();
|
||||
|
||||
public boolean hasPort();
|
||||
public Collection<String> getPortShortNames();
|
||||
|
||||
public void setHasPort(boolean hasPort);
|
||||
public void addPortShortName(String portShortName);
|
||||
|
||||
public void setVisibilityModifier(VisibilityModifier visibility);
|
||||
|
||||
|
|
|
@ -545,10 +545,10 @@ public class Link implements Hideable, Removeable {
|
|||
this.port1 = port1;
|
||||
this.port2 = port2;
|
||||
if (port1 != null) {
|
||||
((ILeaf) cl1).setHasPort(true);
|
||||
((ILeaf) cl1).addPortShortName(port1);
|
||||
}
|
||||
if (port2 != null) {
|
||||
((ILeaf) cl2).setHasPort(true);
|
||||
((ILeaf) cl2).addPortShortName(port2);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ import net.sourceforge.plantuml.svek.extremity.ExtremityFactoryTriangle;
|
|||
public enum LinkDecor {
|
||||
|
||||
NONE(2, false, 0), EXTENDS(30, false, 2), COMPOSITION(15, true, 1.3), AGREGATION(15, false, 1.3), NOT_NAVIGABLE(1,
|
||||
false, 0.1),
|
||||
false, 0.5),
|
||||
|
||||
CROWFOOT(10, true, 0.8), ARROW(10, true, 0.5), ARROW_TRIANGLE(10, true, 0.8), ARROW_AND_CIRCLE(10, false, 0.5),
|
||||
|
||||
|
|
|
@ -46,6 +46,4 @@ public interface Member {
|
|||
public boolean isStatic();
|
||||
|
||||
public boolean isAbstract();
|
||||
|
||||
public String getPort();
|
||||
}
|
||||
|
|
|
@ -125,7 +125,7 @@ public class MemberImpl implements Member {
|
|||
return display;
|
||||
}
|
||||
|
||||
public String getDisplayWithVisibilityChar() {
|
||||
private String getDisplayWithVisibilityChar() {
|
||||
if (isPrivate()) {
|
||||
return "-" + display;
|
||||
}
|
||||
|
@ -202,14 +202,4 @@ public class MemberImpl implements Member {
|
|||
}
|
||||
return s.contains("(") || s.contains(")");
|
||||
}
|
||||
|
||||
public String getPort() {
|
||||
final Pattern2 pattern = MyPattern.cmpile("([\\p{L}0-9_.]+)");
|
||||
final Matcher2 matcher = pattern.matcher(display);
|
||||
if (matcher.find() == false) {
|
||||
return null;
|
||||
}
|
||||
return matcher.group(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -33,7 +33,10 @@ package net.sourceforge.plantuml.cucadiagram;
|
|||
import java.awt.geom.Dimension2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.sourceforge.plantuml.Dimension2DDouble;
|
||||
import net.sourceforge.plantuml.FontParam;
|
||||
|
@ -77,13 +80,16 @@ public class MethodsOrFieldsArea extends AbstractTextBlock implements TextBlockW
|
|||
private final List<Member> members = new ArrayList<Member>();
|
||||
private final HorizontalAlignment align;
|
||||
private final Stereotype stereotype;
|
||||
private final ILeaf leaf;
|
||||
|
||||
public MethodsOrFieldsArea(List<Member> members, FontParam fontParam, ISkinParam skinParam, Stereotype stereotype) {
|
||||
this(members, fontParam, skinParam, HorizontalAlignment.LEFT, stereotype);
|
||||
public MethodsOrFieldsArea(List<Member> members, FontParam fontParam, ISkinParam skinParam, Stereotype stereotype,
|
||||
ILeaf leaf) {
|
||||
this(members, fontParam, skinParam, HorizontalAlignment.LEFT, stereotype, leaf);
|
||||
}
|
||||
|
||||
public MethodsOrFieldsArea(List<Member> members, FontParam fontParam, ISkinParam skinParam,
|
||||
HorizontalAlignment align, Stereotype stereotype) {
|
||||
HorizontalAlignment align, Stereotype stereotype, ILeaf leaf) {
|
||||
this.leaf = leaf;
|
||||
this.stereotype = stereotype;
|
||||
this.align = align;
|
||||
this.skinParam = skinParam;
|
||||
|
@ -126,10 +132,18 @@ public class MethodsOrFieldsArea extends AbstractTextBlock implements TextBlockW
|
|||
public Ports getPorts(StringBounder stringBounder) {
|
||||
final Ports result = new Ports();
|
||||
double y = 0;
|
||||
final Election election = new Election();
|
||||
for (Member m : members) {
|
||||
election.addCandidat(m.getDisplay(false), m);
|
||||
}
|
||||
final Map<Member, String> memberWithPort = election.getAllElected(leaf.getPortShortNames());
|
||||
for (Member m : members) {
|
||||
final TextBlock bloc = createTextBlock(m);
|
||||
final Dimension2D dim = bloc.calculateDimension(stringBounder);
|
||||
result.add(m.getPort(), y, dim.getHeight());
|
||||
final String port = memberWithPort.get(m);
|
||||
if (port != null) {
|
||||
result.add(port, y, dim.getHeight());
|
||||
}
|
||||
y += dim.getHeight();
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -33,6 +33,7 @@ package net.sourceforge.plantuml.cucadiagram.entity;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -96,7 +97,7 @@ final class EntityImpl implements ILeaf, IGroup {
|
|||
|
||||
// Other
|
||||
private boolean nearDecoration = false;
|
||||
private boolean hasPort = false;
|
||||
private final Collection<String> portShortNames = new HashSet<String>();
|
||||
private int xposition;
|
||||
private IEntityImage svekImage;
|
||||
|
||||
|
@ -579,13 +580,13 @@ final class EntityImpl implements ILeaf, IGroup {
|
|||
// colors = colors.addSpecificLineStroke(specificLineStroke);
|
||||
// }
|
||||
|
||||
public boolean hasPort() {
|
||||
public Collection<String> getPortShortNames() {
|
||||
checkNotGroup();
|
||||
return hasPort;
|
||||
return Collections.unmodifiableCollection(portShortNames);
|
||||
}
|
||||
|
||||
public void setHasPort(boolean hasPort) {
|
||||
this.hasPort = hasPort;
|
||||
public void addPortShortName(String portShortName) {
|
||||
portShortNames.add(portShortName);
|
||||
}
|
||||
|
||||
private VisibilityModifier visibility;
|
||||
|
|
|
@ -60,7 +60,7 @@ import net.sourceforge.plantuml.version.PSystemVersion;
|
|||
|
||||
public class PSystemDonors extends AbstractPSystem {
|
||||
|
||||
public static final String DONORS = "UDfTKyjosp0ClEChUDQa7w7OiLk_ah7IT2OtM88jsXJXafHI-TjwwuyLSYkJ3a_4401t5ulSPFyFENYXG4xbDh3LMC8hPV5m0okEeVEGZwMuWxcBJzH3GJlqGQDL6wujvBPYf-PCuKB3TR-NZ34TBQmm-SW6cEenq0Ros9exADe8eOUvpkwFPLYCA5iFHQ1pJLPDcC_2Rph-GnwMpQTITZ1XewtQSki95ksdz-p8GcGCpXhM2Mfiqb2-oWtzGbk9d9DQIzS3kbwORc-qxG4sAVfmWMUZEocOwl8ao6ylsiAJlxMs2OYCEfXU6XrShrPOSuMm64H_hr7Q9taPcJWkEQTUPB8O94_m2Qx5F_1qkcDbAmbTAPhCSEVw4t_uavP6HigUNT0N-1gpAuQrBciowX6rwLC6vfA2yHuMXFRB0ikVBNarRNSEPPOcydtZOw2oLak77YEa0ub5aubz3CwI5BNaJgT6kLhbUoIi4RQ9UOSlKfxPKQhFYQtuD2Zpo0ujclE3UgU0VFQm5OBeAhNKmsXXPjWDUg___3RcElHe29EOK-oqkjd9uQZsCFNwdf5F738CxGL7ispr7VpSQ5KWLh98xa3g1za3kGUrpb-_5NaqUiOMvdItGAaEjXJ3DEfDE4p5mikOwMYOiwpEYWYUkdGFEeHDR4BD239BICrRBIvf6r8pRYb4jKiFitHELoxH6_QIYYXmD_eWZYfq4nTI0CbUxmVTKNRyBzppFBC0";
|
||||
public static final String DONORS = "UDfTKqjosp0CtUCKN6lIGoXsxDQ_PEmqdSaEbc2BDaMu9ELKFaUlaaLdkki5VAH2RcNIuOeO0k1x3m-voVuVSl14WPpARM2hiO1dokBX6cOSG-SXxqjn3MCNdwY55QtH1urMBRYoaDkIdHepXHDrryr6Clfqj333v2CROAZxG1l8Osi-mgg945eOw-psM8P9ZxBni0fqgCYg0VD1-0txVyZ3jFvGoWu6RBHLIsuymQJvy9xjM8ZqmK73F46DTHhALxcX7sXBaNDGQUcwHTSAq-MLjjt28aKVJl1ez54AXhhO2_BhYxRmuA-jRG8YeoCCJxKEhbKphBX4c7IYlrOexPEyZ4mSbvnzAp9P398d-0JNv1zusj-migM4hX1DHhXsxPxV_5vB8oDbZoxe4toEsIN3N1SL6NMFshGf0tDAmNWF4qBxQOB5zuQy6ZPhXp9B4_c-y2vGKQcfGuyHqfR4eid4tZfdIOgQyb6dHhbOvMiah16MYNcxBrAUsKwg3ucjUDyfSyyEBPh3dNgbW7pmi1I2w4errTreOMJOTNhF__msvZBqQ0YJc5FiDBlQoM6lTZVrwfQHJnpI3Uq9UxCizGtyt6YrGYnbaToMr3UoMt9tQfu_VrdbqUWPMnZJpGAbEjX235Eh5-4m50jFOwQZRiwoEZCYU3YcUt14MCGcLFSWiuJKkD7YagOcDUA6GbIxy31AvtJX4hrXJwc80dUXj-AebQxZGWeWsUjDfplAZYUWCsFW_FFydhG_lvz_mQ2wMVGM_WAyB4jD";
|
||||
|
||||
@Override
|
||||
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat)
|
||||
|
|
|
@ -197,6 +197,9 @@ public class FontConfiguration {
|
|||
|
||||
FontConfiguration add(FontStyle style) {
|
||||
final EnumSet<FontStyle> r = styles.clone();
|
||||
if (style == FontStyle.PLAIN) {
|
||||
r.clear();
|
||||
}
|
||||
r.add(style);
|
||||
return new FontConfiguration(r, motherFont, motherColor, currentFont, currentColor, extendedColor,
|
||||
fontPosition, svgAttributes, hyperlink, hyperlinkColor, useUnderlineForHyperlink, tabSize);
|
||||
|
|
|
@ -41,6 +41,9 @@ public enum FontStyle {
|
|||
PLAIN, ITALIC, BOLD, UNDERLINE, STRIKE, WAVE, BACKCOLOR;
|
||||
|
||||
public UFont mutateFont(UFont font) {
|
||||
if (this == PLAIN) {
|
||||
return font.deriveStyle(Font.PLAIN);
|
||||
}
|
||||
if (this == ITALIC) {
|
||||
return font.deriveStyle(font.getStyle() | Font.ITALIC);
|
||||
}
|
||||
|
@ -51,6 +54,9 @@ public enum FontStyle {
|
|||
}
|
||||
|
||||
public String getActivationPattern() {
|
||||
if (this == PLAIN) {
|
||||
return "\\<[pP][lL][aA][iI][nN]\\>";
|
||||
}
|
||||
if (this == ITALIC) {
|
||||
return "\\<[iI]\\>";
|
||||
}
|
||||
|
@ -121,6 +127,9 @@ public enum FontStyle {
|
|||
}
|
||||
|
||||
public String getDeactivationPattern() {
|
||||
if (this == PLAIN) {
|
||||
return "\\</[pP][lL][aA][iI][nN]\\>";
|
||||
}
|
||||
if (this == ITALIC) {
|
||||
return "\\</[iI]\\>";
|
||||
}
|
||||
|
@ -144,9 +153,6 @@ public enum FontStyle {
|
|||
|
||||
public static FontStyle getStyle(String line) {
|
||||
for (FontStyle style : EnumSet.allOf(FontStyle.class)) {
|
||||
if (style == FontStyle.PLAIN) {
|
||||
continue;
|
||||
}
|
||||
if (line.matches(style.getActivationPattern()) || line.matches(style.getDeactivationPattern())) {
|
||||
return style;
|
||||
}
|
||||
|
|
|
@ -49,9 +49,6 @@ class HtmlCommandFactory {
|
|||
final StringBuilder sbRemoveStyle = new StringBuilder();
|
||||
|
||||
for (FontStyle style : EnumSet.allOf(FontStyle.class)) {
|
||||
if (style == FontStyle.PLAIN) {
|
||||
continue;
|
||||
}
|
||||
if (sbAddStyle.length() > 0) {
|
||||
sbAddStyle.append('|');
|
||||
sbRemoveStyle.append('|');
|
||||
|
|
|
@ -195,7 +195,14 @@ public class QuoteUtils {
|
|||
"It's the last piece of the puzzle but you just can't make it fit", //
|
||||
"Doctor says you're cured but you still feel the pain", //
|
||||
"Is artificial intelligence the exact opposite of natural stupidity ?", //
|
||||
"Forcement, ca depend, ca depasse..." //
|
||||
"Forcement, ca depend, ca depasse...", //
|
||||
"There's been a pattern of insubordinate behavior recently.", //
|
||||
"No. We are not an effective team.", //
|
||||
"Our job is not to remember... remember?", //
|
||||
"This is mission control. How are you all doing this lovely morning?", //
|
||||
"If you could see your whole life laid out in front of you, would you change things?", //
|
||||
"Is this a non-zero-sum game?", //
|
||||
"Now that's a proper introduction." //
|
||||
);
|
||||
|
||||
private QuoteUtils() {
|
||||
|
|
|
@ -32,6 +32,8 @@ package net.sourceforge.plantuml.graphic;
|
|||
|
||||
import net.sourceforge.plantuml.ColorParam;
|
||||
import net.sourceforge.plantuml.FontParam;
|
||||
import net.sourceforge.plantuml.ISkinParam;
|
||||
import net.sourceforge.plantuml.cucadiagram.Stereotype;
|
||||
|
||||
public class SkinParameter {
|
||||
|
||||
|
@ -77,6 +79,9 @@ public class SkinParameter {
|
|||
public static final SkinParameter CARD = new SkinParameter("CARD", ColorParam.rectangleBackground,
|
||||
ColorParam.rectangleBorder, FontParam.RECTANGLE, FontParam.RECTANGLE_STEREOTYPE);
|
||||
|
||||
public static final SkinParameter RECTANGLE = new SkinParameter("RECTANGLE", ColorParam.rectangleBackground,
|
||||
ColorParam.rectangleBorder, FontParam.RECTANGLE, FontParam.RECTANGLE_STEREOTYPE);
|
||||
|
||||
public static final SkinParameter ACTOR = new SkinParameter("ACTOR", ColorParam.actorBackground,
|
||||
ColorParam.actorBorder, FontParam.ACTOR, FontParam.ACTOR_STEREOTYPE);
|
||||
|
||||
|
@ -106,7 +111,7 @@ public class SkinParameter {
|
|||
this.fontParam = fontParam;
|
||||
this.fontParamStereotype = fontParamStereotype;
|
||||
}
|
||||
|
||||
|
||||
public String getUpperCaseName() {
|
||||
return name;
|
||||
}
|
||||
|
@ -127,4 +132,8 @@ public class SkinParameter {
|
|||
return fontParamStereotype;
|
||||
}
|
||||
|
||||
public double getRoundCorner(ISkinParam skinParam, Stereotype stereotype) {
|
||||
return skinParam.getRoundCorner(name.toLowerCase(), stereotype);
|
||||
}
|
||||
|
||||
}
|
|
@ -65,6 +65,7 @@ public class Splitter {
|
|||
|
||||
static final String linkPattern = "\\[\\[([^\\[\\]]+)\\]\\]";
|
||||
public static final String mathPattern = "\\<math\\>(.+?)\\</math\\>";
|
||||
public static final String latexPattern = "\\<latex\\>(.+?)\\</latex\\>";
|
||||
|
||||
private static final Pattern2 tagOrText;
|
||||
|
||||
|
@ -72,9 +73,6 @@ public class Splitter {
|
|||
final StringBuilder sb = new StringBuilder("(?i)");
|
||||
|
||||
for (FontStyle style : EnumSet.allOf(FontStyle.class)) {
|
||||
if (style == FontStyle.PLAIN) {
|
||||
continue;
|
||||
}
|
||||
sb.append(style.getActivationPattern());
|
||||
sb.append('|');
|
||||
sb.append(style.getDeactivationPattern());
|
||||
|
|
|
@ -42,14 +42,16 @@ public class SymbolContext {
|
|||
private final UStroke stroke;
|
||||
private final boolean shadowing;
|
||||
private final double deltaShadow;
|
||||
private final double roundCorner;
|
||||
|
||||
private SymbolContext(HtmlColor backColor, HtmlColor foreColor, UStroke stroke, boolean shadowing,
|
||||
double deltaShadow) {
|
||||
double deltaShadow, double roundCorner) {
|
||||
this.backColor = backColor;
|
||||
this.foreColor = foreColor;
|
||||
this.stroke = stroke;
|
||||
this.shadowing = shadowing;
|
||||
this.deltaShadow = deltaShadow;
|
||||
this.roundCorner = roundCorner;
|
||||
// if (backColor instanceof HtmlColorTransparent) {
|
||||
// throw new UnsupportedOperationException();
|
||||
// }
|
||||
|
@ -73,23 +75,27 @@ public class SymbolContext {
|
|||
}
|
||||
|
||||
public SymbolContext(HtmlColor backColor, HtmlColor foreColor) {
|
||||
this(backColor, foreColor, new UStroke(), false, 0);
|
||||
this(backColor, foreColor, new UStroke(), false, 0, 0);
|
||||
}
|
||||
|
||||
public SymbolContext withShadow(boolean newShadow) {
|
||||
return new SymbolContext(backColor, foreColor, stroke, newShadow, deltaShadow);
|
||||
return new SymbolContext(backColor, foreColor, stroke, newShadow, deltaShadow, roundCorner);
|
||||
}
|
||||
|
||||
public SymbolContext withDeltaShadow(double deltaShadow) {
|
||||
return new SymbolContext(backColor, foreColor, stroke, shadowing, deltaShadow);
|
||||
return new SymbolContext(backColor, foreColor, stroke, shadowing, deltaShadow, roundCorner);
|
||||
}
|
||||
|
||||
public SymbolContext withStroke(UStroke newStroke) {
|
||||
return new SymbolContext(backColor, foreColor, newStroke, shadowing, deltaShadow);
|
||||
return new SymbolContext(backColor, foreColor, newStroke, shadowing, deltaShadow, roundCorner);
|
||||
}
|
||||
|
||||
public SymbolContext withBackColor(HtmlColor backColor) {
|
||||
return new SymbolContext(backColor, foreColor, stroke, shadowing, deltaShadow);
|
||||
return new SymbolContext(backColor, foreColor, stroke, shadowing, deltaShadow, roundCorner);
|
||||
}
|
||||
|
||||
public SymbolContext withRoundCorner(double roundCorner) {
|
||||
return new SymbolContext(backColor, foreColor, stroke, shadowing, deltaShadow, roundCorner);
|
||||
}
|
||||
|
||||
public HtmlColor getBackColor() {
|
||||
|
@ -112,4 +118,8 @@ public class SymbolContext {
|
|||
return deltaShadow;
|
||||
}
|
||||
|
||||
public double getRoundCorner() {
|
||||
return roundCorner;
|
||||
}
|
||||
|
||||
}
|
|
@ -76,7 +76,7 @@ public class TextBlockUtils {
|
|||
if (borderColor == null) {
|
||||
borderColor = HtmlColorUtils.BLACK;
|
||||
}
|
||||
final double corner = skinParam.getRoundCorner("titleBorder");
|
||||
final double corner = skinParam.getRoundCorner("titleBorder", null);
|
||||
return withMargin(bordered(result, stroke, borderColor, backgroundColor, corner), 2, 2);
|
||||
}
|
||||
|
||||
|
|
|
@ -55,8 +55,8 @@ public abstract class USymbol {
|
|||
SkinParameter.PACKAGE));
|
||||
public final static USymbol FOLDER = record("FOLDER", SkinParameter.FOLDER, new USymbolFolder(SkinParameter.FOLDER));
|
||||
public final static USymbol FILE = record("FILE", SkinParameter.FILE, new USymbolFile());
|
||||
public final static USymbol RECTANGLE = record("RECTANGLE", SkinParameter.CARD, new USymbolRect(SkinParameter.CARD,
|
||||
HorizontalAlignment.CENTER));
|
||||
public final static USymbol RECTANGLE = record("RECTANGLE", SkinParameter.RECTANGLE, new USymbolRect(
|
||||
SkinParameter.RECTANGLE, HorizontalAlignment.CENTER));
|
||||
public final static USymbol AGENT = record("AGENT", SkinParameter.AGENT, new USymbolRect(SkinParameter.AGENT,
|
||||
HorizontalAlignment.CENTER));
|
||||
public final static USymbol ACTOR = record("ACTOR", SkinParameter.ACTOR, new USymbolActor());
|
||||
|
|
|
@ -59,8 +59,8 @@ class USymbolRect extends USymbol {
|
|||
return skinParameter;
|
||||
}
|
||||
|
||||
private void drawRect(UGraphic ug, double width, double height, boolean shadowing) {
|
||||
final URectangle shape = new URectangle(width, height);
|
||||
private void drawRect(UGraphic ug, double width, double height, boolean shadowing, double roundCorner) {
|
||||
final URectangle shape = new URectangle(width, height, roundCorner, roundCorner);
|
||||
if (shadowing) {
|
||||
shape.setDeltaShadow(3.0);
|
||||
}
|
||||
|
@ -79,7 +79,8 @@ class USymbolRect extends USymbol {
|
|||
final Dimension2D dim = calculateDimension(ug.getStringBounder());
|
||||
ug = UGraphicStencil.create(ug, getRectangleStencil(dim), new UStroke());
|
||||
ug = symbolContext.apply(ug);
|
||||
drawRect(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing());
|
||||
drawRect(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing(),
|
||||
symbolContext.getRoundCorner());
|
||||
final Margin margin = getMargin();
|
||||
final TextBlock tb = TextBlockUtils.mergeTB(stereotype, label, stereotypeAlignement);
|
||||
tb.drawU(ug.apply(new UTranslate(margin.getX1(), margin.getY1())));
|
||||
|
@ -99,7 +100,8 @@ class USymbolRect extends USymbol {
|
|||
public void drawU(UGraphic ug) {
|
||||
final Dimension2D dim = calculateDimension(ug.getStringBounder());
|
||||
ug = symbolContext.apply(ug);
|
||||
drawRect(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing());
|
||||
drawRect(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing(),
|
||||
symbolContext.getRoundCorner());
|
||||
final Dimension2D dimStereo = stereotype.calculateDimension(ug.getStringBounder());
|
||||
final double posStereoX;
|
||||
final double posStereoY;
|
||||
|
|
|
@ -245,7 +245,7 @@ public class CucaDiagramFileMakerJDot implements CucaDiagramFileMaker {
|
|||
attribute = new TextBlockEmpty();
|
||||
} else {
|
||||
attribute = new MethodsOrFieldsArea(members, FontParam.STATE_ATTRIBUTE, diagram.getSkinParam(),
|
||||
g.getStereotype());
|
||||
g.getStereotype(), null);
|
||||
}
|
||||
final Dimension2D dimAttribute = attribute.calculateDimension(stringBounder);
|
||||
final double attributeHeight = dimAttribute.getHeight();
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
package net.sourceforge.plantuml.math;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.Dimension2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.BufferedReader;
|
||||
|
@ -43,14 +42,14 @@ import javax.script.Invocable;
|
|||
import javax.script.ScriptEngine;
|
||||
import javax.script.ScriptEngineManager;
|
||||
import javax.script.ScriptException;
|
||||
import javax.swing.Icon;
|
||||
|
||||
public class AsciiMath {
|
||||
public class AsciiMath implements ScientificEquation {
|
||||
|
||||
private static final String ASCIIMATH_PARSER_JS_LOCATION = "/net/sourceforge/plantuml/math/";
|
||||
|
||||
private static String JAVASCRIPT_CODE;
|
||||
|
||||
private final LatexBuilder builder;
|
||||
private final String tex;
|
||||
|
||||
static {
|
||||
|
@ -75,47 +74,27 @@ public class AsciiMath {
|
|||
final ScriptEngine engine = new ScriptEngineManager().getEngineByName("JavaScript");
|
||||
engine.eval(JAVASCRIPT_CODE);
|
||||
final Invocable inv = (Invocable) engine;
|
||||
tex = (String) inv.invokeFunction("plantuml", form);
|
||||
this.tex = (String) inv.invokeFunction("plantuml", form);
|
||||
this.builder = new LatexBuilder(tex);
|
||||
}
|
||||
|
||||
private Dimension2D dimension;
|
||||
|
||||
public Dimension2D getDimension() {
|
||||
return dimension;
|
||||
}
|
||||
|
||||
private Icon buildIcon(Color foregroundColor) throws ClassNotFoundException, NoSuchMethodException,
|
||||
SecurityException, InstantiationException, IllegalAccessException, IllegalArgumentException,
|
||||
InvocationTargetException {
|
||||
return new TeXIconBuilder(tex, foregroundColor).getIcon();
|
||||
return builder.getDimension();
|
||||
}
|
||||
|
||||
public String getSvg(Color foregroundColor, Color backgroundColor) throws ClassNotFoundException,
|
||||
IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException,
|
||||
SecurityException, InstantiationException, IOException {
|
||||
final Icon icon = buildIcon(foregroundColor);
|
||||
final ConverterSvg converterSvg = new ConverterSvg(icon);
|
||||
final String svg = converterSvg.getSvg(true, backgroundColor);
|
||||
dimension = converterSvg.getDimension();
|
||||
return svg;
|
||||
return builder.getSvg(foregroundColor, backgroundColor);
|
||||
}
|
||||
|
||||
public BufferedImage getImage(Color foregroundColor, Color backgroundColor) throws ClassNotFoundException,
|
||||
NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException,
|
||||
IllegalArgumentException, InvocationTargetException {
|
||||
final Icon icon = buildIcon(foregroundColor);
|
||||
final BufferedImage image = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(),
|
||||
BufferedImage.TYPE_INT_ARGB);
|
||||
final Graphics2D g2 = image.createGraphics();
|
||||
if (backgroundColor != null) {
|
||||
g2.setColor(backgroundColor);
|
||||
g2.fillRect(0, 0, icon.getIconWidth(), icon.getIconHeight());
|
||||
}
|
||||
icon.paintIcon(null, g2, 0, 0);
|
||||
return image;
|
||||
public BufferedImage getImage(double scale, Color foregroundColor, Color backgroundColor)
|
||||
throws ClassNotFoundException, NoSuchMethodException, SecurityException, InstantiationException,
|
||||
IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||
return builder.getImage(scale, foregroundColor, backgroundColor);
|
||||
}
|
||||
|
||||
public String getLatex() {
|
||||
public String getSource() {
|
||||
return tex;
|
||||
}
|
||||
|
||||
|
|
92
src/net/sourceforge/plantuml/math/LatexBuilder.java
Normal file
92
src/net/sourceforge/plantuml/math/LatexBuilder.java
Normal file
|
@ -0,0 +1,92 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* This file is part of PlantUML.
|
||||
*
|
||||
* PlantUML is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlantUML distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.math;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.Dimension2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import javax.swing.Icon;
|
||||
|
||||
public class LatexBuilder implements ScientificEquation {
|
||||
|
||||
private final String tex;
|
||||
|
||||
public LatexBuilder(String tex) {
|
||||
this.tex = tex;
|
||||
}
|
||||
|
||||
private Dimension2D dimension;
|
||||
|
||||
public Dimension2D getDimension() {
|
||||
return dimension;
|
||||
}
|
||||
|
||||
private Icon buildIcon(Color foregroundColor) throws ClassNotFoundException, NoSuchMethodException,
|
||||
SecurityException, InstantiationException, IllegalAccessException, IllegalArgumentException,
|
||||
InvocationTargetException {
|
||||
return new TeXIconBuilder(tex, foregroundColor).getIcon();
|
||||
}
|
||||
|
||||
public String getSvg(Color foregroundColor, Color backgroundColor) throws ClassNotFoundException,
|
||||
IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException,
|
||||
SecurityException, InstantiationException, IOException {
|
||||
final Icon icon = buildIcon(foregroundColor);
|
||||
final ConverterSvg converterSvg = new ConverterSvg(icon);
|
||||
final String svg = converterSvg.getSvg(true, backgroundColor);
|
||||
dimension = converterSvg.getDimension();
|
||||
return svg;
|
||||
}
|
||||
|
||||
public BufferedImage getImage(double scale, Color foregroundColor, Color backgroundColor)
|
||||
throws ClassNotFoundException, NoSuchMethodException, SecurityException, InstantiationException,
|
||||
IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||
final Icon icon = buildIcon(foregroundColor);
|
||||
final BufferedImage image = new BufferedImage((int) (icon.getIconWidth() * scale),
|
||||
(int) (icon.getIconHeight() * scale), BufferedImage.TYPE_INT_ARGB);
|
||||
final Graphics2D g2 = image.createGraphics();
|
||||
g2.scale(scale, scale);
|
||||
if (backgroundColor != null) {
|
||||
g2.setColor(backgroundColor);
|
||||
g2.fillRect(0, 0, icon.getIconWidth(), icon.getIconHeight());
|
||||
}
|
||||
icon.paintIcon(null, g2, 0, 0);
|
||||
return image;
|
||||
}
|
||||
|
||||
public String getSource() {
|
||||
return tex;
|
||||
}
|
||||
|
||||
}
|
65
src/net/sourceforge/plantuml/math/PSystemLatex.java
Normal file
65
src/net/sourceforge/plantuml/math/PSystemLatex.java
Normal file
|
@ -0,0 +1,65 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* This file is part of PlantUML.
|
||||
*
|
||||
* PlantUML is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlantUML distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.math;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import net.sourceforge.plantuml.AbstractPSystem;
|
||||
import net.sourceforge.plantuml.FileFormatOption;
|
||||
import net.sourceforge.plantuml.core.DiagramDescription;
|
||||
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
|
||||
import net.sourceforge.plantuml.core.ImageData;
|
||||
|
||||
public class PSystemLatex extends AbstractPSystem {
|
||||
|
||||
private String latex = "";
|
||||
|
||||
public PSystemLatex() {
|
||||
}
|
||||
|
||||
public DiagramDescription getDescription() {
|
||||
return new DiagramDescriptionImpl("(Latex)", getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat)
|
||||
throws IOException {
|
||||
final ScientificEquationSafe asciiMath = ScientificEquationSafe.fromLatex(latex);
|
||||
return asciiMath.export(os, fileFormat, 1, Color.BLACK, Color.WHITE);
|
||||
}
|
||||
|
||||
public void doCommandLine(String line) {
|
||||
this.latex = line;
|
||||
}
|
||||
|
||||
}
|
56
src/net/sourceforge/plantuml/math/PSystemLatexFactory.java
Normal file
56
src/net/sourceforge/plantuml/math/PSystemLatexFactory.java
Normal file
|
@ -0,0 +1,56 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* This file is part of PlantUML.
|
||||
*
|
||||
* PlantUML is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlantUML distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.math;
|
||||
|
||||
import net.sourceforge.plantuml.command.PSystemBasicFactory;
|
||||
import net.sourceforge.plantuml.core.DiagramType;
|
||||
|
||||
public class PSystemLatexFactory extends PSystemBasicFactory<PSystemLatex> {
|
||||
|
||||
public PSystemLatexFactory(DiagramType type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
public PSystemLatex init(String startLine) {
|
||||
if (getDiagramType() == DiagramType.LATEX) {
|
||||
return new PSystemLatex();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PSystemLatex executeLine(PSystemLatex system, String line) {
|
||||
system.doCommandLine(line);
|
||||
return system;
|
||||
}
|
||||
|
||||
}
|
|
@ -54,8 +54,8 @@ public class PSystemMath extends AbstractPSystem {
|
|||
@Override
|
||||
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat)
|
||||
throws IOException {
|
||||
AsciiMathSafe asciiMath = new AsciiMathSafe(math);
|
||||
return asciiMath.export(os, fileFormat, Color.BLACK, Color.WHITE);
|
||||
final ScientificEquationSafe asciiMath = ScientificEquationSafe.fromAsciiMath(math);
|
||||
return asciiMath.export(os, fileFormat, 1, Color.BLACK, Color.WHITE);
|
||||
}
|
||||
|
||||
public void doCommandLine(String line) {
|
||||
|
|
53
src/net/sourceforge/plantuml/math/ScientificEquation.java
Normal file
53
src/net/sourceforge/plantuml/math/ScientificEquation.java
Normal file
|
@ -0,0 +1,53 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* This file is part of PlantUML.
|
||||
*
|
||||
* PlantUML is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlantUML distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.math;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.geom.Dimension2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
public interface ScientificEquation {
|
||||
|
||||
public Dimension2D getDimension();
|
||||
|
||||
public String getSvg(Color foregroundColor, Color backgroundColor) throws ClassNotFoundException,
|
||||
IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException,
|
||||
SecurityException, InstantiationException, IOException;
|
||||
|
||||
public BufferedImage getImage(double scale, Color foregroundColor, Color backgroundColor) throws ClassNotFoundException,
|
||||
NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException,
|
||||
IllegalArgumentException, InvocationTargetException;
|
||||
|
||||
public String getSource();
|
||||
|
||||
}
|
|
@ -50,18 +50,33 @@ import net.sourceforge.plantuml.graphic.TextBlock;
|
|||
import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
|
||||
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
|
||||
|
||||
public class AsciiMathSafe {
|
||||
public class ScientificEquationSafe {
|
||||
|
||||
private AsciiMath math;
|
||||
private final String form;
|
||||
private final ScientificEquation equation;
|
||||
private final String formula;
|
||||
|
||||
public AsciiMathSafe(String form) {
|
||||
this.form = form;
|
||||
private ScientificEquationSafe(String formula, ScientificEquation equation) {
|
||||
this.formula = formula;
|
||||
this.equation = equation;
|
||||
}
|
||||
|
||||
public static ScientificEquationSafe fromAsciiMath(String formula) {
|
||||
try {
|
||||
this.math = new AsciiMath(form);
|
||||
return new ScientificEquationSafe(formula, new AsciiMath(formula));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.info("Error parsing " + form);
|
||||
Log.info("Error parsing " + formula);
|
||||
return new ScientificEquationSafe(formula, null);
|
||||
}
|
||||
}
|
||||
|
||||
public static ScientificEquationSafe fromLatex(String formula) {
|
||||
try {
|
||||
return new ScientificEquationSafe(formula, new LatexBuilder(formula));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.info("Error parsing " + formula);
|
||||
return new ScientificEquationSafe(formula, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,8 +85,8 @@ public class AsciiMathSafe {
|
|||
public String getSvg(Color foregroundColor, Color backgroundColor) {
|
||||
|
||||
try {
|
||||
final String svg = math.getSvg(foregroundColor, backgroundColor);
|
||||
dimSvg = new ImageDataSimple(math.getDimension());
|
||||
final String svg = equation.getSvg(foregroundColor, backgroundColor);
|
||||
dimSvg = new ImageDataSimple(equation.getDimension());
|
||||
return svg;
|
||||
} catch (Exception e) {
|
||||
printTrace(e);
|
||||
|
@ -86,9 +101,9 @@ public class AsciiMathSafe {
|
|||
}
|
||||
}
|
||||
|
||||
public BufferedImage getImage(Color foregroundColor, Color backgroundColor) {
|
||||
public BufferedImage getImage(double scale, Color foregroundColor, Color backgroundColor) {
|
||||
try {
|
||||
return math.getImage(foregroundColor, backgroundColor);
|
||||
return equation.getImage(scale, foregroundColor, backgroundColor);
|
||||
} catch (Exception e) {
|
||||
printTrace(e);
|
||||
final ImageBuilder imageBuilder = getRollback();
|
||||
|
@ -103,25 +118,25 @@ public class AsciiMathSafe {
|
|||
}
|
||||
|
||||
private void printTrace(Exception e) {
|
||||
System.err.println("Form=" + form);
|
||||
if (math != null) {
|
||||
System.err.println("Latex=" + math.getLatex());
|
||||
System.err.println("formula=" + formula);
|
||||
if (formula != null) {
|
||||
System.err.println("Latex=" + equation.getSource());
|
||||
}
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
private ImageBuilder getRollback() {
|
||||
final TextBlock block = GraphicStrings.createBlackOnWhiteMonospaced(Arrays.asList(form));
|
||||
final TextBlock block = GraphicStrings.createBlackOnWhiteMonospaced(Arrays.asList(formula));
|
||||
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, null, null, null, 0, 0,
|
||||
null, false);
|
||||
imageBuilder.setUDrawable(block);
|
||||
return imageBuilder;
|
||||
}
|
||||
|
||||
public ImageData export(OutputStream os, FileFormatOption fileFormat, Color foregroundColor, Color backgroundColor)
|
||||
public ImageData export(OutputStream os, FileFormatOption fileFormat, float scale, Color foregroundColor, Color backgroundColor)
|
||||
throws IOException {
|
||||
if (fileFormat.getFileFormat() == FileFormat.PNG) {
|
||||
final BufferedImage image = getImage(foregroundColor, backgroundColor);
|
||||
final BufferedImage image = getImage(scale, foregroundColor, backgroundColor);
|
||||
ImageIO.write(image, "png", os);
|
||||
return new ImageDataSimple(image.getWidth(), image.getHeight());
|
||||
}
|
|
@ -53,7 +53,7 @@ public class CommandAddData extends SingleLineCommand<AbstractClassOrObjectDiagr
|
|||
if (field.length() > 0 && VisibilityModifier.isVisibilityCharacter(field.charAt(0))) {
|
||||
diagram.setVisibilityModifierPresent(true);
|
||||
}
|
||||
entity.getBodier().addFieldOrMethod(field);
|
||||
entity.getBodier().addFieldOrMethod(field, entity);
|
||||
return CommandExecutionResult.ok();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ public class CommandCreateEntityObjectMultilines extends CommandMultilines2<Abst
|
|||
if (VisibilityModifier.isVisibilityCharacter(s.charAt(0))) {
|
||||
diagram.setVisibilityModifierPresent(true);
|
||||
}
|
||||
entity.getBodier().addFieldOrMethod(s.toString());
|
||||
entity.getBodier().addFieldOrMethod(s.toString(), entity);
|
||||
}
|
||||
return CommandExecutionResult.ok();
|
||||
}
|
||||
|
|
|
@ -86,4 +86,8 @@ public class Dictionary implements SpriteContainer, ISkinSimple {
|
|||
return new HtmlColorSetSimple();
|
||||
}
|
||||
|
||||
public int getDpi() {
|
||||
return 96;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -239,4 +239,20 @@ public enum VisibilityModifier {
|
|||
return backgroundParam;
|
||||
}
|
||||
|
||||
public String getXmiVisibility() {
|
||||
if (this == PUBLIC_FIELD || this == PUBLIC_METHOD) {
|
||||
return "public";
|
||||
}
|
||||
if (this == PRIVATE_FIELD || this == PRIVATE_METHOD) {
|
||||
return "private";
|
||||
}
|
||||
if (this == PROTECTED_FIELD || this == PROTECTED_METHOD) {
|
||||
return "protected";
|
||||
}
|
||||
if (this == PACKAGE_PRIVATE_FIELD || this == VisibilityModifier.PACKAGE_PRIVATE_METHOD) {
|
||||
return "package";
|
||||
}
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -102,22 +102,22 @@ public class Rose implements Skin {
|
|||
}
|
||||
if (type == ComponentType.PARTICIPANT_HEAD) {
|
||||
return new ComponentRoseParticipant(getSymbolContext(param, ColorParam.participantBorder), getUFont2(param,
|
||||
FontParam.PARTICIPANT), stringsToDisplay, param, param.getRoundCorner(""), newFontForStereotype,
|
||||
FontParam.PARTICIPANT), stringsToDisplay, param, param.getRoundCorner("", null), newFontForStereotype,
|
||||
getFontColor(param, FontParam.SEQUENCE_STEREOTYPE), param.minClassWidth(), false);
|
||||
}
|
||||
if (type == ComponentType.PARTICIPANT_TAIL) {
|
||||
return new ComponentRoseParticipant(getSymbolContext(param, ColorParam.participantBorder), getUFont2(param,
|
||||
FontParam.PARTICIPANT), stringsToDisplay, param, param.getRoundCorner(""), newFontForStereotype,
|
||||
FontParam.PARTICIPANT), stringsToDisplay, param, param.getRoundCorner("", null), newFontForStereotype,
|
||||
getFontColor(param, FontParam.SEQUENCE_STEREOTYPE), param.minClassWidth(), false);
|
||||
}
|
||||
if (type == ComponentType.COLLECTIONS_HEAD) {
|
||||
return new ComponentRoseParticipant(getSymbolContext(param, ColorParam.participantBorder), getUFont2(param,
|
||||
FontParam.PARTICIPANT), stringsToDisplay, param, param.getRoundCorner(""), newFontForStereotype,
|
||||
FontParam.PARTICIPANT), stringsToDisplay, param, param.getRoundCorner("", null), newFontForStereotype,
|
||||
getFontColor(param, FontParam.SEQUENCE_STEREOTYPE), param.minClassWidth(), true);
|
||||
}
|
||||
if (type == ComponentType.COLLECTIONS_TAIL) {
|
||||
return new ComponentRoseParticipant(getSymbolContext(param, ColorParam.participantBorder), getUFont2(param,
|
||||
FontParam.PARTICIPANT), stringsToDisplay, param, param.getRoundCorner(""), newFontForStereotype,
|
||||
FontParam.PARTICIPANT), stringsToDisplay, param, param.getRoundCorner("", null), newFontForStereotype,
|
||||
getFontColor(param, FontParam.SEQUENCE_STEREOTYPE), param.minClassWidth(), true);
|
||||
}
|
||||
if (type == ComponentType.PARTICIPANT_LINE) {
|
||||
|
|
|
@ -63,7 +63,7 @@ public class CommandAddField extends SingleLineCommand2<StateDiagram> {
|
|||
|
||||
final IEntity entity = diagram.getOrCreateLeaf(Code.of(code), null, null);
|
||||
|
||||
entity.getBodier().addFieldOrMethod(field);
|
||||
entity.getBodier().addFieldOrMethod(field, entity);
|
||||
return CommandExecutionResult.ok();
|
||||
}
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ public class CommandCreateState extends SingleLineCommand2<StateDiagram> {
|
|||
|
||||
final String addFields = arg.get("ADDFIELD", 0);
|
||||
if (addFields != null) {
|
||||
ent.getBodier().addFieldOrMethod(addFields);
|
||||
ent.getBodier().addFieldOrMethod(addFields, ent);
|
||||
}
|
||||
return CommandExecutionResult.ok();
|
||||
}
|
||||
|
|
|
@ -39,6 +39,9 @@ import java.io.PrintStream;
|
|||
import java.io.PrintWriter;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.logging.Filter;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.prefs.BackingStoreException;
|
||||
import java.util.prefs.Preferences;
|
||||
|
||||
|
@ -74,6 +77,18 @@ public class StatsUtils {
|
|||
private final static int VERSION = 14;
|
||||
|
||||
static {
|
||||
try {
|
||||
// Logger.getLogger("java.util.prefs").setLevel(Level.OFF);
|
||||
Logger.getLogger("java.util.prefs").setFilter(new Filter() {
|
||||
public boolean isLoggable(LogRecord record) {
|
||||
final String message = record.getMessage();
|
||||
System.err.println("SPECIAL TRACE FOR PLANTUML: " + message);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (prefs.getInt("VERSION", 0) != VERSION) {
|
||||
try {
|
||||
prefs.clear();
|
||||
|
|
|
@ -37,7 +37,7 @@ import net.sourceforge.plantuml.svek.extremity.ExtremityFactory;
|
|||
|
||||
public abstract class AbstractExtremityFactory implements ExtremityFactory {
|
||||
|
||||
public UDrawable createUDrawable(Point2D p0, double angle) {
|
||||
public UDrawable createUDrawable(Point2D p0, double angle, Side side) {
|
||||
throw new UnsupportedOperationException(getClass().toString());
|
||||
}
|
||||
|
||||
|
|
|
@ -342,9 +342,12 @@ public class Cluster implements Moveable {
|
|||
|
||||
if (ztitle != null || zstereo != null) {
|
||||
final HtmlColor back = getBackColor(getBackColor(umlDiagramType), skinParam2, group.getStereotype());
|
||||
final double roundCorner = group.getUSymbol() == null ? 0 : group.getUSymbol().getSkinParameter()
|
||||
.getRoundCorner(skinParam, stereotype);
|
||||
|
||||
final ClusterDecoration decoration = new ClusterDecoration(style, group.getUSymbol(), ztitle, zstereo,
|
||||
minX, minY, maxX, maxY, getStroke(skinParam2, group.getStereotype()));
|
||||
decoration.drawU(ug, back, borderColor, skinParam2.shadowing());
|
||||
decoration.drawU(ug, back, borderColor, skinParam2.shadowing(), roundCorner);
|
||||
return;
|
||||
}
|
||||
final URectangle rect = new URectangle(maxX - minX, maxY - minY);
|
||||
|
@ -459,7 +462,8 @@ public class Cluster implements Moveable {
|
|||
if (members.size() == 0) {
|
||||
attribute = new TextBlockEmpty();
|
||||
} else {
|
||||
attribute = new MethodsOrFieldsArea(members, FontParam.STATE_ATTRIBUTE, skinParam, group.getStereotype());
|
||||
attribute = new MethodsOrFieldsArea(members, FontParam.STATE_ATTRIBUTE, skinParam, group.getStereotype(),
|
||||
null);
|
||||
}
|
||||
return attribute;
|
||||
}
|
||||
|
|
|
@ -80,12 +80,13 @@ public class ClusterDecoration {
|
|||
public final static int marginTitleY1 = 3;
|
||||
public final static int marginTitleY2 = 3;
|
||||
|
||||
public void drawU(UGraphic ug, HtmlColor backColor, HtmlColor borderColor, boolean shadowing) {
|
||||
public void drawU(UGraphic ug, HtmlColor backColor, HtmlColor borderColor, boolean shadowing, double roundCorner) {
|
||||
final SymbolContext biColor = new SymbolContext(backColor, borderColor);
|
||||
if (symbol == null) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
final SymbolContext symbolContext = biColor.withShadow(shadowing).withStroke(defaultStroke);
|
||||
final SymbolContext symbolContext = biColor.withShadow(shadowing).withStroke(defaultStroke)
|
||||
.withRoundCorner(roundCorner);
|
||||
symbol.asBig(title, stereo, maxX - minX, maxY - minY, symbolContext)
|
||||
.drawU(ug.apply(new UTranslate(minX, minY)));
|
||||
// return;
|
||||
|
|
|
@ -184,4 +184,28 @@ public class ClusterPosition {
|
|||
return false;
|
||||
}
|
||||
|
||||
public Side getClosestSide(Point2D pt) {
|
||||
final double distNorth = Math.abs(minY - pt.getY());
|
||||
final double distSouth = Math.abs(maxY - pt.getY());
|
||||
final double distWest = Math.abs(minX - pt.getX());
|
||||
final double distEast = Math.abs(maxX - pt.getX());
|
||||
if (isSmallerThan(distNorth, distWest, distEast, distSouth)) {
|
||||
return Side.NORTH;
|
||||
}
|
||||
if (isSmallerThan(distSouth, distNorth, distWest, distEast)) {
|
||||
return Side.SOUTH;
|
||||
}
|
||||
if (isSmallerThan(distEast, distNorth, distWest, distSouth)) {
|
||||
return Side.EAST;
|
||||
}
|
||||
if (isSmallerThan(distWest, distNorth, distEast, distSouth)) {
|
||||
return Side.WEST;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean isSmallerThan(double value, double a, double b, double c) {
|
||||
return value <= a && value <= b && value <= c;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -474,7 +474,7 @@ public final class DotDataImageBuilder {
|
|||
attribute = new TextBlockEmpty();
|
||||
} else {
|
||||
attribute = new MethodsOrFieldsArea(members, FontParam.STATE_ATTRIBUTE, dotData.getSkinParam(),
|
||||
g.getStereotype());
|
||||
g.getStereotype(), null);
|
||||
}
|
||||
final Dimension2D dimAttribute = attribute.calculateDimension(stringBounder);
|
||||
final double attributeHeight = dimAttribute.getHeight();
|
||||
|
|
|
@ -145,7 +145,7 @@ public final class GroupPngMakerState {
|
|||
attribute = new TextBlockEmpty();
|
||||
} else {
|
||||
attribute = new MethodsOrFieldsArea(members, FontParam.STATE_ATTRIBUTE, diagram.getSkinParam(),
|
||||
group.getStereotype());
|
||||
group.getStereotype(), null);
|
||||
}
|
||||
|
||||
final Stereotype stereotype = group.getStereotype();
|
||||
|
|
|
@ -440,13 +440,13 @@ public class Line implements Moveable, Hideable {
|
|||
}
|
||||
|
||||
private UDrawable getExtremity(LinkDecor decor, PointListIterator pointListIterator, Point2D center, double angle,
|
||||
Cluster cluster) {
|
||||
Cluster cluster, Shape shapeContact) {
|
||||
final ExtremityFactory extremityFactory = decor.getExtremityFactory(backgroundColor);
|
||||
|
||||
if (cluster != null) {
|
||||
if (extremityFactory != null) {
|
||||
// System.err.println("angle=" + angle * 180 / Math.PI);
|
||||
return extremityFactory.createUDrawable(center, angle);
|
||||
return extremityFactory.createUDrawable(center, angle, null);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -456,7 +456,11 @@ public class Line implements Moveable, Hideable {
|
|||
final Point2D p0 = points.get(0);
|
||||
final Point2D p1 = points.get(1);
|
||||
final Point2D p2 = points.get(2);
|
||||
return extremityFactory.createUDrawable(p0, p1, p2);
|
||||
Side side = null;
|
||||
if (shapeContact != null) {
|
||||
side = shapeContact.getClusterPosition().getClosestSide(p1);
|
||||
}
|
||||
return extremityFactory.createUDrawable(p0, p1, p2, side);
|
||||
} else if (decor != LinkDecor.NONE) {
|
||||
final UShape sh = new UPolygon(pointListIterator.next());
|
||||
return new UDrawable() {
|
||||
|
@ -506,9 +510,9 @@ public class Line implements Moveable, Hideable {
|
|||
|
||||
final LinkType linkType = link.getType();
|
||||
this.extremity1 = getExtremity(linkType.getDecor2(), pointListIterator, dotPath.getStartPoint(),
|
||||
dotPath.getStartAngle() + Math.PI, ltail);
|
||||
dotPath.getStartAngle() + Math.PI, ltail, bibliotekon.getShape(link.getEntity1()));
|
||||
this.extremity2 = getExtremity(linkType.getDecor1(), pointListIterator, dotPath.getEndPoint(),
|
||||
dotPath.getEndAngle(), lhead);
|
||||
dotPath.getEndAngle(), lhead, bibliotekon.getShape(link.getEntity2()));
|
||||
if (extremity1 instanceof Extremity && extremity2 instanceof Extremity) {
|
||||
final Point2D p1 = ((Extremity) extremity1).somePoint();
|
||||
final Point2D p2 = ((Extremity) extremity2).somePoint();
|
||||
|
@ -521,9 +525,9 @@ public class Line implements Moveable, Hideable {
|
|||
if (dist1start > dist1end && dist2end > dist2start) {
|
||||
pointListIterator = new PointListIterator(svg.substring(end), fullHeight);
|
||||
this.extremity2 = getExtremity(linkType.getDecor1(), pointListIterator, dotPath.getEndPoint(),
|
||||
dotPath.getEndAngle(), lhead);
|
||||
dotPath.getEndAngle(), lhead, bibliotekon.getShape(link.getEntity2()));
|
||||
this.extremity1 = getExtremity(linkType.getDecor2(), pointListIterator, dotPath.getStartPoint(),
|
||||
dotPath.getStartAngle() + Math.PI, ltail);
|
||||
dotPath.getStartAngle() + Math.PI, ltail, bibliotekon.getShape(link.getEntity1()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -660,22 +664,24 @@ public class Line implements Moveable, Hideable {
|
|||
ug = ug.apply(new UStroke()).apply(new UChangeColor(color));
|
||||
|
||||
if (this.extremity2 != null) {
|
||||
UGraphic ug2 = ug;
|
||||
if (linkType.getDecor1().isFill()) {
|
||||
ug = ug.apply(new UChangeBackColor(color));
|
||||
ug2 = ug2.apply(new UChangeBackColor(color));
|
||||
} else {
|
||||
ug = ug.apply(new UChangeBackColor(null));
|
||||
ug2 = ug2.apply(new UChangeBackColor(null));
|
||||
}
|
||||
// System.err.println("Line::draw EXTREMITY1");
|
||||
this.extremity2.drawU(ug.apply(new UTranslate(x, y)));
|
||||
this.extremity2.drawU(ug2.apply(new UTranslate(x, y)));
|
||||
}
|
||||
if (this.extremity1 != null) {
|
||||
UGraphic ug2 = ug;
|
||||
if (linkType.getDecor2().isFill()) {
|
||||
ug = ug.apply(new UChangeBackColor(color));
|
||||
ug2 = ug2.apply(new UChangeBackColor(color));
|
||||
} else {
|
||||
ug = ug.apply(new UChangeBackColor(null));
|
||||
ug2 = ug2.apply(new UChangeBackColor(null));
|
||||
}
|
||||
// System.err.println("Line::draw EXTREMITY2");
|
||||
this.extremity1.drawU(ug.apply(new UTranslate(x, y)));
|
||||
this.extremity1.drawU(ug2.apply(new UTranslate(x, y)));
|
||||
}
|
||||
if (this.labelText != null && this.labelXY != null
|
||||
&& link.getNoteLinkStrategy() != NoteLinkStrategy.HALF_NOT_PRINTED) {
|
||||
|
|
|
@ -40,7 +40,7 @@ public class Ports {
|
|||
public void addThis(Ports other) {
|
||||
all.putAll(other.all);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return all.toString();
|
||||
|
@ -55,6 +55,9 @@ public class Ports {
|
|||
}
|
||||
|
||||
public void add(String portName, double position, double height) {
|
||||
if (portName == null) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
all.put(portName, new PortGeometry(position, height));
|
||||
}
|
||||
|
||||
|
|
37
src/net/sourceforge/plantuml/svek/Side.java
Normal file
37
src/net/sourceforge/plantuml/svek/Side.java
Normal file
|
@ -0,0 +1,37 @@
|
|||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2017, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* This file is part of PlantUML.
|
||||
*
|
||||
* PlantUML is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlantUML distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.svek;
|
||||
|
||||
public enum Side {
|
||||
|
||||
NORTH, EAST, SOUTH, WEST
|
||||
|
||||
}
|
|
@ -45,7 +45,7 @@ public class UGraphicForSnake extends UGraphicDelegator {
|
|||
private final double dx;
|
||||
private final double dy;
|
||||
private final List<PendingSnake> snakes;
|
||||
|
||||
|
||||
public UTranslate getTranslation() {
|
||||
return new UTranslate(dx, dy);
|
||||
}
|
||||
|
@ -67,15 +67,28 @@ public class UGraphicForSnake extends UGraphicDelegator {
|
|||
snake.drawInternal(ug);
|
||||
}
|
||||
|
||||
public void removeEndDecorationIfTouches(List<PendingSnake> snakes) {
|
||||
for (PendingSnake other : snakes) {
|
||||
if (moved().touches(other.moved())) {
|
||||
this.snake.removeEndDecoration();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Snake moved() {
|
||||
return snake.move(dx, dy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "dx=" + dx + " dy=" + dy + " " + snake.move(dx, dy).toString();
|
||||
}
|
||||
|
||||
public PendingSnake merge(PendingSnake newItem) {
|
||||
// if (snake.isMergeable() == false || newItem.snake.isMergeable() == false) {
|
||||
// return null;
|
||||
// }
|
||||
// if (snake.isMergeable() == false || newItem.snake.isMergeable() == false) {
|
||||
// return null;
|
||||
// }
|
||||
final Snake s1 = snake.move(dx, dy);
|
||||
final Snake s2 = newItem.snake.move(newItem.dx, newItem.dy);
|
||||
final Snake merge = s1.merge(s2, ug.getStringBounder());
|
||||
|
@ -84,6 +97,7 @@ public class UGraphicForSnake extends UGraphicDelegator {
|
|||
}
|
||||
return new PendingSnake(merge.move(-dx, -dy), ug, dx, dy);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public UGraphicForSnake(UGraphic ug) {
|
||||
|
@ -121,6 +135,7 @@ public class UGraphicForSnake extends UGraphicDelegator {
|
|||
@Override
|
||||
public void flushUg() {
|
||||
for (PendingSnake snake : snakes) {
|
||||
snake.removeEndDecorationIfTouches(snakes);
|
||||
snake.drawInternal();
|
||||
}
|
||||
snakes.clear();
|
||||
|
|
|
@ -33,6 +33,7 @@ package net.sourceforge.plantuml.svek.extremity;
|
|||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Point2D;
|
||||
|
||||
import net.sourceforge.plantuml.svek.Side;
|
||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||
import net.sourceforge.plantuml.ugraphic.ULine;
|
||||
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||
|
@ -41,15 +42,17 @@ class ExtremityCrowfoot extends Extremity {
|
|||
|
||||
private final Point2D contact;
|
||||
private double angle;
|
||||
private final Side side;
|
||||
|
||||
@Override
|
||||
public Point2D somePoint() {
|
||||
return contact;
|
||||
}
|
||||
|
||||
public ExtremityCrowfoot(Point2D p1, double angle) {
|
||||
public ExtremityCrowfoot(Point2D p1, double angle, Side side) {
|
||||
this.contact = new Point2D.Double(p1.getX(), p1.getY());
|
||||
this.angle = manageround(angle + Math.PI / 2);
|
||||
this.side = side;
|
||||
}
|
||||
|
||||
public void drawU(UGraphic ug) {
|
||||
|
@ -64,6 +67,15 @@ class ExtremityCrowfoot extends Extremity {
|
|||
rotate.transform(base, base);
|
||||
rotate.transform(right, right);
|
||||
|
||||
if (side == Side.WEST || side == Side.EAST) {
|
||||
left.setLocation(middle.getX(), left.getY());
|
||||
right.setLocation(middle.getX(), right.getY());
|
||||
}
|
||||
if (side == Side.SOUTH || side == Side.NORTH) {
|
||||
left.setLocation(left.getX(), middle.getY());
|
||||
right.setLocation(right.getX(), middle.getY());
|
||||
}
|
||||
|
||||
drawLine(ug, contact.getX(), contact.getY(), base, left);
|
||||
drawLine(ug, contact.getX(), contact.getY(), base, right);
|
||||
drawLine(ug, contact.getX(), contact.getY(), base, middle);
|
||||
|
|
|
@ -33,11 +33,12 @@ package net.sourceforge.plantuml.svek.extremity;
|
|||
import java.awt.geom.Point2D;
|
||||
|
||||
import net.sourceforge.plantuml.graphic.UDrawable;
|
||||
import net.sourceforge.plantuml.svek.Side;
|
||||
|
||||
public interface ExtremityFactory {
|
||||
|
||||
public UDrawable createUDrawable(Point2D p0, Point2D p1, Point2D p2);
|
||||
public UDrawable createUDrawable(Point2D p0, Point2D p1, Point2D p2, Side side);
|
||||
|
||||
public UDrawable createUDrawable(Point2D p0, double angle);
|
||||
public UDrawable createUDrawable(Point2D p0, double angle, Side side);
|
||||
|
||||
}
|
||||
|
|
|
@ -34,14 +34,15 @@ import java.awt.geom.Point2D;
|
|||
|
||||
import net.sourceforge.plantuml.graphic.UDrawable;
|
||||
import net.sourceforge.plantuml.svek.AbstractExtremityFactory;
|
||||
import net.sourceforge.plantuml.svek.Side;
|
||||
|
||||
public class ExtremityFactoryArrow extends AbstractExtremityFactory implements ExtremityFactory {
|
||||
|
||||
public UDrawable createUDrawable(Point2D p0, double angle) {
|
||||
public UDrawable createUDrawable(Point2D p0, double angle, Side side) {
|
||||
return new ExtremityArrow(p0, angle);
|
||||
}
|
||||
|
||||
public UDrawable createUDrawable(Point2D p0, Point2D p1, Point2D p2) {
|
||||
public UDrawable createUDrawable(Point2D p0, Point2D p1, Point2D p2, Side side) {
|
||||
final double ortho = atan2(p0, p2);
|
||||
final Point2D center = new Point2D.Double((p0.getX() + p2.getX()) / 2, (p0.getY() + p2.getY()) / 2);
|
||||
return new ExtremityArrow(p1, ortho, center);
|
||||
|
|
|
@ -34,10 +34,11 @@ import java.awt.geom.Point2D;
|
|||
|
||||
import net.sourceforge.plantuml.graphic.UDrawable;
|
||||
import net.sourceforge.plantuml.svek.AbstractExtremityFactory;
|
||||
import net.sourceforge.plantuml.svek.Side;
|
||||
|
||||
public class ExtremityFactoryArrowAndCircle extends AbstractExtremityFactory implements ExtremityFactory {
|
||||
|
||||
public UDrawable createUDrawable(Point2D p0, Point2D p1, Point2D p2) {
|
||||
public UDrawable createUDrawable(Point2D p0, Point2D p1, Point2D p2, Side side) {
|
||||
final double ortho = atan2(p0, p2);
|
||||
final Point2D center = new Point2D.Double((p0.getX() + p2.getX()) / 2, (p0.getY() + p2.getY()) / 2);
|
||||
return new ExtremityArrowAndCircle(p1, ortho, center);
|
||||
|
|
|
@ -34,10 +34,11 @@ import java.awt.geom.Point2D;
|
|||
|
||||
import net.sourceforge.plantuml.graphic.UDrawable;
|
||||
import net.sourceforge.plantuml.svek.AbstractExtremityFactory;
|
||||
import net.sourceforge.plantuml.svek.Side;
|
||||
|
||||
public class ExtremityFactoryCircle extends AbstractExtremityFactory implements ExtremityFactory {
|
||||
|
||||
public UDrawable createUDrawable(Point2D p0, Point2D p1, Point2D p2) {
|
||||
public UDrawable createUDrawable(Point2D p0, Point2D p1, Point2D p2, Side side) {
|
||||
// final double ortho = atan2(p0, p2);
|
||||
return new ExtremityCircle(p1);
|
||||
}
|
||||
|
|
|
@ -34,10 +34,11 @@ import java.awt.geom.Point2D;
|
|||
|
||||
import net.sourceforge.plantuml.graphic.UDrawable;
|
||||
import net.sourceforge.plantuml.svek.AbstractExtremityFactory;
|
||||
import net.sourceforge.plantuml.svek.Side;
|
||||
|
||||
public class ExtremityFactoryCircleConnect extends AbstractExtremityFactory implements ExtremityFactory {
|
||||
|
||||
public UDrawable createUDrawable(Point2D p0, Point2D p1, Point2D p2) {
|
||||
public UDrawable createUDrawable(Point2D p0, Point2D p1, Point2D p2, Side side) {
|
||||
final double ortho = atan2(p0, p2);
|
||||
return new ExtremityCircleConnect(p1, ortho);
|
||||
}
|
||||
|
|
|
@ -34,10 +34,11 @@ import java.awt.geom.Point2D;
|
|||
|
||||
import net.sourceforge.plantuml.graphic.UDrawable;
|
||||
import net.sourceforge.plantuml.svek.AbstractExtremityFactory;
|
||||
import net.sourceforge.plantuml.svek.Side;
|
||||
|
||||
public class ExtremityFactoryCircleCross extends AbstractExtremityFactory implements ExtremityFactory {
|
||||
|
||||
public UDrawable createUDrawable(Point2D p0, Point2D p1, Point2D p2) {
|
||||
public UDrawable createUDrawable(Point2D p0, Point2D p1, Point2D p2, Side side) {
|
||||
// final double ortho = atan2(p0, p2);
|
||||
return new ExtremityCircleCross(p1);
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user