mirror of
https://github.com/octoleo/plantuml.git
synced 2024-12-22 02:49:06 +00:00
fix: wip
https://forum.plantuml.net/17926/sprite-transparent-only-jar-defined-sprites-are-working https://github.com/plantuml/plantuml/issues/1448 https://forum.plantuml.net/17932/nwdiag-possible-misbehavior
This commit is contained in:
parent
c95bbfe585
commit
4a246c7cb9
@ -1,4 +1,4 @@
|
||||
# Warning, "version" should be the same in gradle.properties and Version.java
|
||||
# Any idea anyone how to magically synchronize those :-) ?
|
||||
version = 1.2023.9beta2
|
||||
version = 1.2023.9beta3
|
||||
org.gradle.workers.max = 3
|
@ -70,6 +70,7 @@ import net.sourceforge.plantuml.eggs.PSystemWelcomeFactory;
|
||||
import net.sourceforge.plantuml.emoji.PSystemListEmojiFactory;
|
||||
import net.sourceforge.plantuml.error.PSystemError;
|
||||
import net.sourceforge.plantuml.error.PSystemErrorUtils;
|
||||
import net.sourceforge.plantuml.filesdiagram.FilesDiagramFactory;
|
||||
import net.sourceforge.plantuml.flowdiagram.FlowDiagramFactory;
|
||||
import net.sourceforge.plantuml.font.PSystemListFontsFactory;
|
||||
import net.sourceforge.plantuml.gitlog.GitDiagramFactory;
|
||||
@ -101,7 +102,6 @@ import net.sourceforge.plantuml.sudoku.PSystemSudokuFactory;
|
||||
import net.sourceforge.plantuml.text.StringLocated;
|
||||
import net.sourceforge.plantuml.timingdiagram.TimingDiagramFactory;
|
||||
import net.sourceforge.plantuml.utils.Log;
|
||||
import net.sourceforge.plantuml.version.License;
|
||||
import net.sourceforge.plantuml.version.PSystemLicenseFactory;
|
||||
import net.sourceforge.plantuml.version.PSystemVersionFactory;
|
||||
import net.sourceforge.plantuml.wbs.WBSDiagramFactory;
|
||||
@ -251,6 +251,7 @@ public class PSystemBuilder {
|
||||
factories.add(new JsonDiagramFactory());
|
||||
factories.add(new GitDiagramFactory());
|
||||
// ::comment when __CORE__
|
||||
factories.add(new FilesDiagramFactory());
|
||||
factories.add(new BoardDiagramFactory());
|
||||
// ::done
|
||||
factories.add(new YamlDiagramFactory());
|
||||
|
@ -181,6 +181,8 @@ public class FtileBox extends AbstractFtile {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (print == null)
|
||||
return super.toString();
|
||||
return print;
|
||||
}
|
||||
|
||||
|
@ -105,9 +105,9 @@ public final class CommandFactorySprite implements SingleMultiFactoryCommand<Wit
|
||||
|
||||
lines = lines.subExtract(1, 1);
|
||||
lines = lines.removeEmptyColumns();
|
||||
if (lines.size() == 0) {
|
||||
if (lines.size() == 0)
|
||||
return CommandExecutionResult.error("No sprite defined.");
|
||||
}
|
||||
|
||||
return executeInternal(system, line0, lines.getLinesAsStringForSprite());
|
||||
}
|
||||
|
||||
@ -123,17 +123,17 @@ public final class CommandFactorySprite implements SingleMultiFactoryCommand<Wit
|
||||
final int height = Integer.parseInt(line0.get("DIM", 1));
|
||||
if (line0.get("DIM", 4) == null) {
|
||||
final int nbLevel = Integer.parseInt(line0.get("DIM", 2));
|
||||
if (nbLevel != 4 && nbLevel != 8 && nbLevel != 16) {
|
||||
if (nbLevel != 4 && nbLevel != 8 && nbLevel != 16)
|
||||
return CommandExecutionResult.error("Only 4, 8 or 16 graylevel are allowed.");
|
||||
}
|
||||
|
||||
final SpriteGrayLevel level = SpriteGrayLevel.get(nbLevel);
|
||||
if (line0.get("DIM", 3) == null) {
|
||||
sprite = level.buildSprite(width, height, strings);
|
||||
} else {
|
||||
sprite = level.buildSpriteZ(width, height, concat(strings));
|
||||
if (sprite == null) {
|
||||
if (sprite == null)
|
||||
return CommandExecutionResult.error("Cannot decode sprite.");
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
sprite = SpriteColorBuilder4096.buildSprite(strings);
|
||||
@ -145,9 +145,9 @@ public final class CommandFactorySprite implements SingleMultiFactoryCommand<Wit
|
||||
|
||||
private String concat(final List<String> strings) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (String s : strings) {
|
||||
for (String s : strings)
|
||||
sb.append(StringUtils.trin(s));
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ import net.sourceforge.plantuml.utils.StartUtils;
|
||||
public enum DiagramType {
|
||||
// ::remove folder when __HAXE__
|
||||
UML, BPM, DITAA, DOT, PROJECT, JCCKIT, SALT, FLOW, CREOLE, JUNGLE, CUTE, MATH, LATEX, DEFINITION, GANTT, NW,
|
||||
MINDMAP, WBS, WIRE, JSON, GIT, BOARD, YAML, HCL, EBNF, REGEX, UNKNOWN;
|
||||
MINDMAP, WBS, WIRE, JSON, GIT, BOARD, YAML, HCL, EBNF, REGEX, FILES, UNKNOWN;
|
||||
|
||||
static public DiagramType getTypeFromArobaseStart(String s) {
|
||||
s = s.toLowerCase();
|
||||
@ -125,6 +125,9 @@ public enum DiagramType {
|
||||
if (StartUtils.startsWithSymbolAnd("startregex", s))
|
||||
return REGEX;
|
||||
|
||||
if (StartUtils.startsWithSymbolAnd("startfiles", s))
|
||||
return FILES;
|
||||
|
||||
return UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
85
src/net/sourceforge/plantuml/filesdiagram/FilesDiagram.java
Normal file
85
src/net/sourceforge/plantuml/filesdiagram/FilesDiagram.java
Normal file
@ -0,0 +1,85 @@
|
||||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2024, Arnaud Roques
|
||||
*
|
||||
* Project Info: https://plantuml.com
|
||||
*
|
||||
* If you like this project or if you find it useful, you can support us at:
|
||||
*
|
||||
* https://plantuml.com/patreon (only 1$ per month!)
|
||||
* https://plantuml.com/paypal
|
||||
*
|
||||
* This file is part of PlantUML.
|
||||
*
|
||||
* PlantUML is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlantUML distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.filesdiagram;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Iterator;
|
||||
|
||||
import net.sourceforge.plantuml.FileFormatOption;
|
||||
import net.sourceforge.plantuml.UmlDiagram;
|
||||
import net.sourceforge.plantuml.core.DiagramDescription;
|
||||
import net.sourceforge.plantuml.core.ImageData;
|
||||
import net.sourceforge.plantuml.core.UmlSource;
|
||||
import net.sourceforge.plantuml.klimt.shape.TextBlock;
|
||||
import net.sourceforge.plantuml.skin.UmlDiagramType;
|
||||
import net.sourceforge.plantuml.text.StringLocated;
|
||||
|
||||
public class FilesDiagram extends UmlDiagram {
|
||||
|
||||
private final FilesListing list;
|
||||
|
||||
public FilesDiagram(UmlSource source) {
|
||||
super(source, UmlDiagramType.FILES, null);
|
||||
this.list = new FilesListing(getSkinParam());
|
||||
|
||||
final Iterator<StringLocated> it = source.iterator2();
|
||||
it.next();
|
||||
while (true) {
|
||||
final String line = it.next().getString();
|
||||
if (it.hasNext() == false)
|
||||
break;
|
||||
this.list.add(line);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public DiagramDescription getDescription() {
|
||||
return new DiagramDescription("(Files)");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
|
||||
throws IOException {
|
||||
|
||||
return createImageBuilder(fileFormatOption).drawable(getTextBlock()).write(os);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TextBlock getTextBlock() {
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2024, Arnaud Roques
|
||||
*
|
||||
* Project Info: https://plantuml.com
|
||||
*
|
||||
* If you like this project or if you find it useful, you can support us at:
|
||||
*
|
||||
* https://plantuml.com/patreon (only 1$ per month!)
|
||||
* https://plantuml.com/paypal
|
||||
*
|
||||
* This file is part of PlantUML.
|
||||
*
|
||||
* PlantUML is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlantUML distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.filesdiagram;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import net.sourceforge.plantuml.command.PSystemAbstractFactory;
|
||||
import net.sourceforge.plantuml.core.Diagram;
|
||||
import net.sourceforge.plantuml.core.DiagramType;
|
||||
import net.sourceforge.plantuml.core.UmlSource;
|
||||
|
||||
public class FilesDiagramFactory extends PSystemAbstractFactory {
|
||||
|
||||
public FilesDiagramFactory() {
|
||||
super(DiagramType.FILES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Diagram createSystem(UmlSource source, Map<String, String> skinParam) {
|
||||
return new FilesDiagram(source);
|
||||
}
|
||||
|
||||
}
|
83
src/net/sourceforge/plantuml/filesdiagram/FilesListing.java
Normal file
83
src/net/sourceforge/plantuml/filesdiagram/FilesListing.java
Normal file
@ -0,0 +1,83 @@
|
||||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2024, Arnaud Roques
|
||||
*
|
||||
* Project Info: https://plantuml.com
|
||||
*
|
||||
* If you like this project or if you find it useful, you can support us at:
|
||||
*
|
||||
* https://plantuml.com/patreon (only 1$ per month!)
|
||||
* https://plantuml.com/paypal
|
||||
*
|
||||
* This file is part of PlantUML.
|
||||
*
|
||||
* PlantUML is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlantUML distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.filesdiagram;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.klimt.UTranslate;
|
||||
import net.sourceforge.plantuml.klimt.creole.Display;
|
||||
import net.sourceforge.plantuml.klimt.drawing.UGraphic;
|
||||
import net.sourceforge.plantuml.klimt.font.FontConfiguration;
|
||||
import net.sourceforge.plantuml.klimt.font.StringBounder;
|
||||
import net.sourceforge.plantuml.klimt.font.UFont;
|
||||
import net.sourceforge.plantuml.klimt.geom.HorizontalAlignment;
|
||||
import net.sourceforge.plantuml.klimt.geom.XDimension2D;
|
||||
import net.sourceforge.plantuml.klimt.shape.AbstractTextBlock;
|
||||
import net.sourceforge.plantuml.klimt.shape.TextBlock;
|
||||
import net.sourceforge.plantuml.style.ISkinParam;
|
||||
|
||||
public class FilesListing extends AbstractTextBlock {
|
||||
|
||||
private final ISkinParam skinParam;
|
||||
private final FontConfiguration fontConfiguration = FontConfiguration.blackBlueTrue(UFont.courier(14));
|
||||
private final List<String> tmp = new ArrayList<>();
|
||||
|
||||
public FilesListing(ISkinParam skinParam) {
|
||||
this.skinParam = skinParam;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XDimension2D calculateDimension(StringBounder stringBounder) {
|
||||
return new XDimension2D(200, 200);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawU(UGraphic ug) {
|
||||
for (String s : tmp) {
|
||||
final Display display = Display.getWithNewlines("<:1f4c4:>" + s);
|
||||
TextBlock result = display.create(fontConfiguration, HorizontalAlignment.LEFT, skinParam);
|
||||
result.drawU(ug);
|
||||
ug = ug.apply(UTranslate.dy(result.calculateDimension(ug.getStringBounder()).getHeight()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void add(String line) {
|
||||
if (line.startsWith("/"))
|
||||
tmp.add(line.substring(1));
|
||||
}
|
||||
|
||||
}
|
@ -49,9 +49,9 @@ public class Commit {
|
||||
this.name = name;
|
||||
this.position = position;
|
||||
this.comment = position.getCommentInLine();
|
||||
if (position.matches("* ") == false && position.matches("*-") == false) {
|
||||
if (position.matches("* ") == false && position.matches("*-") == false)
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
@ -94,15 +94,15 @@ public class Commit {
|
||||
}
|
||||
|
||||
private static void addAbove(List<CursorPosition> result, CursorPosition here) {
|
||||
if (here.move(0, 1).matches("|")) {
|
||||
if (here.move(0, 1).matches("|"))
|
||||
result.add(here.move(0, 1));
|
||||
}
|
||||
if (here.move(1, 1).matches("\\")) {
|
||||
|
||||
if (here.move(1, 1).matches("\\"))
|
||||
result.add(here.move(1, 1));
|
||||
}
|
||||
if (here.move(-1, 1).matches("/")) {
|
||||
|
||||
if (here.move(-1, 1).matches("/"))
|
||||
result.add(here.move(-1, 1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public List<Commit> getAncestors() {
|
||||
|
@ -61,43 +61,43 @@ public class CursorPosition {
|
||||
}
|
||||
|
||||
public boolean matches(String prefix) {
|
||||
if (x < 0) {
|
||||
if (x < 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
final String line = getCurrentLine();
|
||||
if (x > line.length()) {
|
||||
if (x > line.length())
|
||||
return false;
|
||||
}
|
||||
|
||||
return line.substring(x).startsWith(prefix);
|
||||
}
|
||||
|
||||
public String getCommentInLine() {
|
||||
final String line = getCurrentLine();
|
||||
final int x = line.indexOf("*");
|
||||
if (x == -1) {
|
||||
if (x == -1)
|
||||
return null;
|
||||
}
|
||||
|
||||
final int y = line.indexOf("(", x);
|
||||
if (y == -1) {
|
||||
if (y == -1)
|
||||
return null;
|
||||
}
|
||||
|
||||
final int z = line.indexOf(")", y);
|
||||
if (z == -1) {
|
||||
if (z == -1)
|
||||
return null;
|
||||
}
|
||||
|
||||
return line.substring(y + 1, z);
|
||||
}
|
||||
|
||||
public static String getCommitNameInLine(String s) {
|
||||
final int x = s.indexOf("*");
|
||||
if (x == -1) {
|
||||
if (x == -1)
|
||||
return null;
|
||||
}
|
||||
|
||||
s = s.replaceAll("[-.*|/\\\\]", "").trim();
|
||||
final int space = s.indexOf(" ");
|
||||
if (space == -1) {
|
||||
if (space == -1)
|
||||
return s;
|
||||
}
|
||||
|
||||
final String name = s.substring(0, space);
|
||||
return name;
|
||||
}
|
||||
@ -116,9 +116,9 @@ public class CursorPosition {
|
||||
|
||||
private static CursorPosition getDownFromInternal(CursorPosition current) {
|
||||
while (true) {
|
||||
if (current.matches("* ")) {
|
||||
if (current.matches("* "))
|
||||
return current;
|
||||
}
|
||||
|
||||
if (current.matches("/") && current.move(-2, 0).matches("_|/")) {
|
||||
current = current.move(-2, 0);
|
||||
continue;
|
||||
|
@ -44,7 +44,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class GNodeBuilder {
|
||||
// ::remove folder when __HAXE__
|
||||
// ::remove folder when __HAXE__
|
||||
|
||||
private final List<GNode> all = new ArrayList<>();
|
||||
|
||||
@ -58,11 +58,9 @@ public class GNodeBuilder {
|
||||
tmp.put(commit.getName(), node);
|
||||
}
|
||||
|
||||
for (Commit commit : allCommits) {
|
||||
for (Commit parent : commit.getAncestors()) {
|
||||
for (Commit commit : allCommits)
|
||||
for (Commit parent : commit.getAncestors())
|
||||
GNode.link(tmp.get(commit.getName()), tmp.get(parent.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
this.all.addAll(tmp.values());
|
||||
|
||||
@ -82,9 +80,9 @@ public class GNodeBuilder {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (changed == false) {
|
||||
if (changed == false)
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,25 +57,24 @@ public class GitCurve {
|
||||
public GitCurve(ST_Agedgeinfo_t data, Mirror xMirror) {
|
||||
this.xMirror = xMirror;
|
||||
final ST_splines splines = data.spl;
|
||||
if (splines.size != 1) {
|
||||
if (splines.size != 1)
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
final ST_bezier beziers = splines.list.get__(0);
|
||||
for (int i = 0; i < beziers.size; i++) {
|
||||
final XPoint2D pt = getPoint(splines, i);
|
||||
points.add(pt);
|
||||
}
|
||||
|
||||
if (beziers.sp.x == 0 && beziers.sp.y == 0) {
|
||||
if (beziers.sp.x == 0 && beziers.sp.y == 0)
|
||||
sp = null;
|
||||
} else {
|
||||
else
|
||||
sp = new XPoint2D(beziers.sp.x, beziers.sp.y);
|
||||
}
|
||||
if (beziers.ep.x == 0 && beziers.ep.y == 0) {
|
||||
|
||||
if (beziers.ep.x == 0 && beziers.ep.y == 0)
|
||||
ep = null;
|
||||
} else {
|
||||
else
|
||||
ep = new XPoint2D(beziers.ep.x, beziers.ep.y);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -55,9 +55,9 @@ public class GitTextArea {
|
||||
final String name = CursorPosition.getCommitNameInLine(s);
|
||||
final int x = s.indexOf("*");
|
||||
assert (name == null) == (x == -1);
|
||||
if (x == -1) {
|
||||
if (x == -1)
|
||||
continue;
|
||||
}
|
||||
|
||||
commits.add(new Commit(name, new CursorPosition(this, x, y)));
|
||||
}
|
||||
|
||||
@ -69,18 +69,17 @@ public class GitTextArea {
|
||||
}
|
||||
|
||||
public String getLine(int y) {
|
||||
if (y >= lines.size()) {
|
||||
if (y >= lines.size())
|
||||
return "";
|
||||
}
|
||||
|
||||
return lines.get(y);
|
||||
}
|
||||
|
||||
public Commit getCommitByName(String name) {
|
||||
for (Commit commit : getAllCommits()) {
|
||||
if (commit.getName().equals(name)) {
|
||||
for (Commit commit : getAllCommits())
|
||||
if (commit.getName().equals(name))
|
||||
return commit;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -63,13 +63,13 @@ public class HColorGradient extends HColor {
|
||||
return color2;
|
||||
}
|
||||
|
||||
public final Color getColor(ColorMapper mapper, double coeff) {
|
||||
public final Color getColor(ColorMapper mapper, double coeff, int alpha) {
|
||||
if (coeff > 1 || coeff < 0)
|
||||
throw new IllegalArgumentException("c=" + coeff);
|
||||
|
||||
final Color c1 = color1.toColor(mapper);
|
||||
final Color c2 = color2.toColor(mapper);
|
||||
|
||||
|
||||
final int diffRed = c2.getRed() - c1.getRed();
|
||||
final int diffGreen = c2.getGreen() - c1.getGreen();
|
||||
final int diffBlue = c2.getBlue() - c1.getBlue();
|
||||
@ -77,12 +77,12 @@ public class HColorGradient extends HColor {
|
||||
final int vRed = (int) (coeff * diffRed);
|
||||
final int vGreen = (int) (coeff * diffGreen);
|
||||
final int vBlue = (int) (coeff * diffBlue);
|
||||
|
||||
|
||||
final int red = c1.getRed() + vRed;
|
||||
final int green = c1.getGreen() + vGreen;
|
||||
final int blue = c1.getBlue() + vBlue;
|
||||
|
||||
return new Color(red, green, blue);
|
||||
return new Color(red, green, blue, alpha);
|
||||
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ public class SpriteColor implements Sprite {
|
||||
}
|
||||
|
||||
public UImage toUImage(ColorMapper colorMapper, HColor backcolor, HColor forecolor) {
|
||||
final BufferedImage im = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
||||
final BufferedImage im = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
|
||||
|
||||
if (backcolor == null) {
|
||||
backcolor = HColors.WHITE;
|
||||
@ -113,7 +113,7 @@ public class SpriteColor implements Sprite {
|
||||
final int localColor = color[line][col];
|
||||
if (localColor == -1) {
|
||||
final double coef = 1.0 * gray[line][col] / (16 - 1);
|
||||
final Color c = gradient.getColor(colorMapper, coef);
|
||||
final Color c = gradient.getColor(colorMapper, coef, 255);
|
||||
im.setRGB(col, line, c.getRGB());
|
||||
} else {
|
||||
im.setRGB(col, line, localColor);
|
||||
|
@ -184,26 +184,23 @@ public class SpriteMonochrome implements Sprite {
|
||||
if (color == null || color.isTransparent())
|
||||
color = HColors.BLACK.withDark(HColors.WHITE);
|
||||
|
||||
final BufferedImage im = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
||||
final BufferedImage im = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
|
||||
final HColorGradient gradient = HColors.gradient(backcolor, color, '\0');
|
||||
for (int col = 0; col < width; col++) {
|
||||
for (int line = 0; line < height; line++) {
|
||||
final double coef = 1.0 * gray[line][col] / (grayLevel - 1);
|
||||
final Color c = gradient.getColor(colorMapper, coef);
|
||||
im.setRGB(col, line, c.getRGB());
|
||||
}
|
||||
}
|
||||
return new UImage(new PixelImage(im, AffineTransformType.TYPE_BILINEAR));
|
||||
}
|
||||
double maxCoef = 0;
|
||||
for (int col = 0; col < width; col++)
|
||||
for (int line = 0; line < height; line++)
|
||||
maxCoef = Math.max(maxCoef, 1.0 * gray[line][col] / (grayLevel - 1));
|
||||
|
||||
private UImage special(ColorMapper colorMapper, HColorGradient backcolor, HColor color) {
|
||||
final BufferedImage im = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
||||
for (int col = 0; col < width; col++) {
|
||||
for (int line = 0; line < height; line++) {
|
||||
final HColor backColorLocal = HColors.simple(backcolor.getColor(colorMapper, 1.0 * line / height));
|
||||
final HColorGradient gradient = HColors.gradient(backColorLocal, color, '\0');
|
||||
final double coef = 1.0 * gray[line][col] / (grayLevel - 1);
|
||||
final Color c = gradient.getColor(colorMapper, coef);
|
||||
final int grayValue = gray[line][col];
|
||||
final double coef = 1.0 * grayValue / (grayLevel - 1);
|
||||
final int alpha;
|
||||
if (coef > maxCoef / 4)
|
||||
alpha = 255;
|
||||
else
|
||||
alpha = (int) (255 * (coef * 4 / maxCoef));
|
||||
final Color c = gradient.getColor(colorMapper, coef, alpha);
|
||||
im.setRGB(col, line, c.getRGB());
|
||||
}
|
||||
}
|
||||
|
@ -118,6 +118,8 @@ public class NwDiagram extends UmlDiagram {
|
||||
@Override
|
||||
public void makeDiagramReady() {
|
||||
super.makeDiagramReady();
|
||||
if (networks.size() == 0)
|
||||
createNetwork("").goInvisible();
|
||||
for (NServer server : servers.values()) {
|
||||
server.connectMeIfAlone(networks.get(0));
|
||||
playField.addInPlayfield(server.getBar());
|
||||
@ -179,11 +181,26 @@ public class NwDiagram extends UmlDiagram {
|
||||
return veryFirstLink(name1, name2);
|
||||
return CommandExecutionResult.error("what about " + name1);
|
||||
}
|
||||
|
||||
if (server1.isAlone()) {
|
||||
if (networks.size() == 0)
|
||||
createNetwork("").goInvisible();
|
||||
server1.connectMeIfAlone(networks.get(0));
|
||||
}
|
||||
|
||||
final Network tmp1 = server1.getMainNetworkNext();
|
||||
final Network justAfter = justAfter(tmp1);
|
||||
|
||||
final Network network;
|
||||
if (justAfter != null && justAfter.isVisible() == false)
|
||||
network = justAfter;
|
||||
else
|
||||
network = createNetwork("");
|
||||
|
||||
NServer server2 = servers.get(name2);
|
||||
final Network network = createNetwork("");
|
||||
|
||||
network.goInvisible();
|
||||
if (server2 == null) {
|
||||
// server2 = NServer.create(name2, getSkinParam());
|
||||
server2 = new NServer(name2, server1.getBar(), getSkinParam());
|
||||
servers.put(name2, server2);
|
||||
server1.connectTo(network, "");
|
||||
@ -199,6 +216,13 @@ public class NwDiagram extends UmlDiagram {
|
||||
return CommandExecutionResult.ok();
|
||||
}
|
||||
|
||||
private Network justAfter(Network n) {
|
||||
final int x = networks.indexOf(n);
|
||||
if (x != -1 && x < networks.size() - 1)
|
||||
return networks.get(x + 1);
|
||||
return null;
|
||||
}
|
||||
|
||||
private CommandExecutionResult veryFirstLink(String name1, String name2) {
|
||||
Network network = createNetwork(name1);
|
||||
NServer server2 = NServer.create(name2, getSkinParam());
|
||||
@ -208,45 +232,6 @@ public class NwDiagram extends UmlDiagram {
|
||||
return CommandExecutionResult.ok();
|
||||
}
|
||||
|
||||
private CommandExecutionResult linkOld(String name1, String name2) {
|
||||
if (initDone == false)
|
||||
return errorNoInit();
|
||||
|
||||
String existingAddress = "";
|
||||
final NServer server2;
|
||||
Network created = null;
|
||||
if (currentNetwork() == null && networks.size() == 0) {
|
||||
created = createNetwork(name1);
|
||||
server2 = NServer.create(name2, getSkinParam());
|
||||
} else {
|
||||
final NServer server1 = servers.get(name1);
|
||||
final NServer previous2 = servers.get(name2);
|
||||
if (previous2 != null)
|
||||
existingAddress = previous2.someAddress();
|
||||
created = createNetwork("");
|
||||
created.goInvisible();
|
||||
if (server1 != null) {
|
||||
final Network someNetwork = server1.someNetwork();
|
||||
if (someNetwork != null && someNetwork.isVisible() == false && someNetwork.getUp() == null) {
|
||||
final String tmp = server1.someAddress();
|
||||
server1.blankSomeAddress();
|
||||
server1.connectTo(created, tmp);
|
||||
} else {
|
||||
server1.connectTo(created, "");
|
||||
}
|
||||
}
|
||||
|
||||
server2 = new NServer(name2, server1.getBar(), getSkinParam());
|
||||
}
|
||||
servers.put(name2, server2);
|
||||
if (created == null)
|
||||
server2.connectTo(currentNetwork(), existingAddress);
|
||||
else
|
||||
server2.connectTo(created, existingAddress);
|
||||
playField.addInPlayfield(server2.getBar());
|
||||
return CommandExecutionResult.ok();
|
||||
}
|
||||
|
||||
public CommandExecutionResult addElement(String name, String definition) {
|
||||
if (initDone == false)
|
||||
return errorNoInit();
|
||||
@ -269,6 +254,13 @@ public class NwDiagram extends UmlDiagram {
|
||||
}
|
||||
}
|
||||
|
||||
if (networks.size() == 0 || currentNetwork() == null) {
|
||||
server.updateProperties(props);
|
||||
server.learnThisAddress(props.get("address"));
|
||||
return CommandExecutionResult.ok();
|
||||
|
||||
}
|
||||
|
||||
if (networks.size() == 0) {
|
||||
final Network network = createNetwork("");
|
||||
network.goInvisible();
|
||||
@ -291,46 +283,6 @@ public class NwDiagram extends UmlDiagram {
|
||||
return CommandExecutionResult.ok();
|
||||
}
|
||||
|
||||
private CommandExecutionResult addElementOld(String name, String definition) {
|
||||
if (initDone == false)
|
||||
return errorNoInit();
|
||||
|
||||
if (currentGroup() != null) {
|
||||
if (alreadyInSomeGroup(name))
|
||||
return CommandExecutionResult.error("Element already in another group.");
|
||||
|
||||
currentGroup().addName(name);
|
||||
}
|
||||
|
||||
NServer server = null;
|
||||
Network created = null;
|
||||
if (currentNetwork() == null) {
|
||||
if (currentGroup() != null)
|
||||
return CommandExecutionResult.ok();
|
||||
|
||||
assert currentGroup() == null;
|
||||
created = createNetwork("");
|
||||
created.goInvisible();
|
||||
server = NServer.create(name, getSkinParam());
|
||||
servers.put(name, server);
|
||||
server.doNotPrintFirstLink();
|
||||
} else {
|
||||
server = servers.get(name);
|
||||
if (server == null) {
|
||||
server = NServer.create(name, getSkinParam());
|
||||
servers.put(name, server);
|
||||
}
|
||||
}
|
||||
final Map<String, String> props = toSet(definition);
|
||||
if (created == null)
|
||||
server.connectTo(currentNetwork(), props.get("address"));
|
||||
else
|
||||
server.connectTo(created, props.get("address"));
|
||||
server.updateProperties(props);
|
||||
playField.addInPlayfield(server.getBar());
|
||||
return CommandExecutionResult.ok();
|
||||
}
|
||||
|
||||
private boolean alreadyInSomeGroup(String name) {
|
||||
for (NwGroup g : groups)
|
||||
if (g.names().contains(name))
|
||||
|
@ -79,13 +79,17 @@ public class NServer {
|
||||
}
|
||||
|
||||
public void connectMeIfAlone(Network network) {
|
||||
if (connections.size() == 0) {
|
||||
if (isAlone()) {
|
||||
connectTo(network, "");
|
||||
if (network.isVisible() == false)
|
||||
this.doNotPrintFirstLink();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isAlone() {
|
||||
return connections.size() == 0;
|
||||
}
|
||||
|
||||
public String someAddress() {
|
||||
if (connections.size() > 0 && connections.values().iterator().next().length() > 0)
|
||||
return connections.values().iterator().next();
|
||||
|
@ -39,7 +39,7 @@ import net.sourceforge.plantuml.style.SName;
|
||||
|
||||
public enum UmlDiagramType {
|
||||
SEQUENCE, STATE, CLASS, OBJECT, ACTIVITY, DESCRIPTION, COMPOSITE, FLOW, TIMING, BPM, NWDIAG, MINDMAP, WBS, WIRE,
|
||||
HELP, GANTT, SALT, JSON, GIT, BOARD, YAML, HCL, EBNF, REGEX;
|
||||
HELP, GANTT, SALT, JSON, GIT, BOARD, YAML, HCL, EBNF, REGEX, FILES;
|
||||
|
||||
public SName getStyleName() {
|
||||
if (this == SEQUENCE)
|
||||
|
@ -46,7 +46,7 @@ public class Version {
|
||||
|
||||
// Warning, "version" should be the same in gradle.properties and Version.java
|
||||
// Any idea anyone how to magically synchronize those :-) ?
|
||||
private static final String version = "1.2023.9beta2";
|
||||
private static final String version = "1.2023.9beta3";
|
||||
|
||||
public static String versionString() {
|
||||
return version;
|
||||
|
@ -159,8 +159,8 @@ class PipeTest {
|
||||
// no links/invalid input => no pipemap to output (no error as of
|
||||
// https://forum.plantuml.net/10049/2019-pipemap-diagrams-containing-links-give-zero-exit-code
|
||||
// )
|
||||
l.add(TestCase.of("-pipemap", "@startuml\na->b\n@enduml", "<map id=\"plantuml_map\" name=\"plantuml_map\">\n</map>\n\n", Verification.EXACT, false, false));
|
||||
l.add(TestCase.of("-pipemap", "@startuml\na\n@enduml", "<map id=\"plantuml_map\" name=\"plantuml_map\">\n</map>\n\n", Verification.EXACT, false, false));
|
||||
l.add(TestCase.of("-pipemap", "@startuml\na->b\n@enduml", "\n", Verification.EXACT, false, false));
|
||||
l.add(TestCase.of("-pipemap", "@startuml\na\n@enduml", "\n", Verification.EXACT, false, false));
|
||||
|
||||
return l;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user