mirror of
https://github.com/octoleo/plantuml.git
synced 2024-11-21 12:35:10 +00:00
fix: better support for package with ELK layout
https://forum.plantuml.net/13709/eclipse-layout-kernel?show=18389#a18389
This commit is contained in:
parent
f91a19413b
commit
546174d17f
@ -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.13beta1
|
||||
version = 1.2023.13beta2
|
||||
org.gradle.workers.max = 3
|
@ -127,6 +127,7 @@ import net.sourceforge.plantuml.style.StyleSignatureBasic;
|
||||
import net.sourceforge.plantuml.svek.Bibliotekon;
|
||||
import net.sourceforge.plantuml.svek.Cluster;
|
||||
import net.sourceforge.plantuml.svek.ClusterDecoration;
|
||||
import net.sourceforge.plantuml.svek.ClusterHeader;
|
||||
import net.sourceforge.plantuml.svek.CucaDiagramFileMaker;
|
||||
import net.sourceforge.plantuml.svek.DotStringFactory;
|
||||
import net.sourceforge.plantuml.svek.GeneralImageBuilder;
|
||||
@ -298,12 +299,12 @@ public class CucaDiagramFileMakerElk implements CucaDiagramFileMaker {
|
||||
// final double roundCorner = group.getUSymbol() == null ? 0
|
||||
// : group.getUSymbol().getSkinParameter().getRoundCorner(skinParam, group.getStereotype());
|
||||
|
||||
final TextBlock ztitle = getTitleBlock(group);
|
||||
final TextBlock zstereo = TextBlockUtils.empty(0, 0);
|
||||
|
||||
final RectangleArea rectangleArea = new RectangleArea(0, 0, elkNode.getWidth(), elkNode.getHeight());
|
||||
final ClusterDecoration decoration = new ClusterDecoration(packageStyle, group.getUSymbol(), ztitle,
|
||||
zstereo, rectangleArea, stroke);
|
||||
final ClusterHeader clusterHeader = new ClusterHeader(group, diagram.getSkinParam(), diagram,
|
||||
stringBounder);
|
||||
|
||||
final ClusterDecoration decoration = new ClusterDecoration(packageStyle, group.getUSymbol(),
|
||||
clusterHeader.getTitle(), clusterHeader.getStereo(), rectangleArea, stroke);
|
||||
|
||||
final HColor borderColor = HColors.BLACK;
|
||||
decoration.drawU(ug.apply(UTranslate.point(corner)), backColor, borderColor, shadowing, roundCorner,
|
||||
@ -314,16 +315,6 @@ public class CucaDiagramFileMakerElk implements CucaDiagramFileMaker {
|
||||
// ug.apply(HColorUtils.BLACK).apply(UStroke.withThickness(1.5)).apply(new UTranslate(corner)).draw(rect);
|
||||
}
|
||||
|
||||
private TextBlock getTitleBlock(Entity g) {
|
||||
final Display label = g.getDisplay();
|
||||
if (label == null)
|
||||
return TextBlockUtils.empty(0, 0);
|
||||
|
||||
final ISkinParam skinParam = diagram.getSkinParam();
|
||||
final FontConfiguration fontConfiguration = g.getFontConfigurationForTitle(skinParam);
|
||||
return label.create(fontConfiguration, HorizontalAlignment.CENTER, skinParam);
|
||||
}
|
||||
|
||||
private HColor getBackColor(UmlDiagramType umlDiagramType) {
|
||||
return null;
|
||||
}
|
||||
@ -429,7 +420,14 @@ public class CucaDiagramFileMakerElk implements CucaDiagramFileMaker {
|
||||
// We create the "cluster" in ELK for this group
|
||||
final ElkNode elkCluster = ElkGraphUtil.createNode(cluster);
|
||||
elkCluster.setProperty(CoreOptions.DIRECTION, Direction.DOWN);
|
||||
elkCluster.setProperty(CoreOptions.PADDING, new ElkPadding(40, 15, 15, 15));
|
||||
|
||||
final ClusterHeader clusterHeader = new ClusterHeader(g, diagram.getSkinParam(), diagram,
|
||||
stringBounder);
|
||||
|
||||
final int titleAndAttributeHeight = clusterHeader.getTitleAndAttributeHeight();
|
||||
|
||||
final double topPadding = Math.max(25, titleAndAttributeHeight) + 15;
|
||||
elkCluster.setProperty(CoreOptions.PADDING, new ElkPadding(topPadding, 15, 15, 15));
|
||||
|
||||
// Not sure this is usefull to put a label on a "cluster"
|
||||
final ElkLabel label = ElkGraphUtil.createLabel(elkCluster);
|
||||
|
@ -97,7 +97,10 @@ public class FormatCounter {
|
||||
final String name = removeDotSaved(key);
|
||||
final NumberAnalyzed value = NumberAnalyzed.load(name, prefs);
|
||||
if (value != null) {
|
||||
final FileFormat format = FileFormat.valueOf(name.substring(prefix.length()));
|
||||
final String subname = name.substring(prefix.length());
|
||||
if (subname.equals("ANIMATED_GIF"))
|
||||
continue;
|
||||
final FileFormat format = FileFormat.valueOf(subname);
|
||||
data.put(format, value);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -617,7 +617,7 @@ public final class GeneralImageBuilder {
|
||||
if (g.getGroupType() == GroupType.CONCURRENT_STATE)
|
||||
return;
|
||||
|
||||
final ClusterHeader clusterHeader = new ClusterHeader((Entity) g, dotData.getSkinParam(), dotData,
|
||||
final ClusterHeader clusterHeader = new ClusterHeader(g, dotData.getSkinParam(), dotData,
|
||||
stringBounder);
|
||||
dotStringFactory.openCluster(g, clusterHeader);
|
||||
this.printEntities(dotStringFactory, g.leafs());
|
||||
|
150
src/net/sourceforge/plantuml/syntax/SyntaxChecker.java
Normal file
150
src/net/sourceforge/plantuml/syntax/SyntaxChecker.java
Normal file
@ -0,0 +1,150 @@
|
||||
/* ========================================================================
|
||||
* 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.syntax;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.BlockUml;
|
||||
import net.sourceforge.plantuml.ErrorUml;
|
||||
import net.sourceforge.plantuml.OptionFlags;
|
||||
import net.sourceforge.plantuml.SourceStringReader;
|
||||
import net.sourceforge.plantuml.UmlDiagram;
|
||||
import net.sourceforge.plantuml.core.Diagram;
|
||||
import net.sourceforge.plantuml.error.PSystemError;
|
||||
import net.sourceforge.plantuml.preproc.Defines;
|
||||
import net.sourceforge.plantuml.text.BackSlash;
|
||||
import net.sourceforge.plantuml.utils.LineLocation;
|
||||
import net.sourceforge.plantuml.utils.LineLocationImpl;
|
||||
|
||||
public class SyntaxChecker {
|
||||
// ::remove folder when __HAXE__
|
||||
// ::remove file when __CORE__
|
||||
|
||||
public static SyntaxResult checkSyntax(List<String> source) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (String s : source) {
|
||||
sb.append(s);
|
||||
sb.append(BackSlash.NEWLINE);
|
||||
}
|
||||
return checkSyntax(sb.toString());
|
||||
}
|
||||
|
||||
public static SyntaxResult checkSyntax(String source) {
|
||||
OptionFlags.getInstance().setQuiet(true);
|
||||
final SyntaxResult result = new SyntaxResult();
|
||||
|
||||
if (source.startsWith("@startuml\n") == false) {
|
||||
result.setError(true);
|
||||
result.setLineLocation(new LineLocationImpl("", null).oneLineRead());
|
||||
result.addErrorText("No @startuml/@enduml found");
|
||||
return result;
|
||||
}
|
||||
if (source.endsWith("@enduml\n") == false && source.endsWith("@enduml") == false) {
|
||||
result.setError(true);
|
||||
result.setLineLocation(lastLineNumber(source));
|
||||
result.addErrorText("No @enduml found");
|
||||
return result;
|
||||
}
|
||||
final SourceStringReader sourceStringReader = new SourceStringReader(Defines.createEmpty(), source,
|
||||
Collections.<String>emptyList());
|
||||
|
||||
final List<BlockUml> blocks = sourceStringReader.getBlocks();
|
||||
if (blocks.size() == 0) {
|
||||
result.setError(true);
|
||||
result.setLineLocation(lastLineNumber(source));
|
||||
result.addErrorText("No @enduml found");
|
||||
return result;
|
||||
}
|
||||
final Diagram system = blocks.get(0).getDiagram();
|
||||
result.setCmapData(system.hasUrl());
|
||||
if (system instanceof UmlDiagram) {
|
||||
result.setUmlDiagramType(((UmlDiagram) system).getUmlDiagramType());
|
||||
result.setDescription(system.getDescription().getDescription());
|
||||
} else if (system instanceof PSystemError) {
|
||||
result.setError(true);
|
||||
final PSystemError sys = (PSystemError) system;
|
||||
result.setLineLocation(sys.getLineLocation());
|
||||
result.setSystemError(sys);
|
||||
for (ErrorUml er : sys.getErrorsUml())
|
||||
result.addErrorText(er.getError());
|
||||
} else {
|
||||
result.setDescription(system.getDescription().getDescription());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static SyntaxResult checkSyntaxFair(String source) {
|
||||
final SyntaxResult result = new SyntaxResult();
|
||||
final SourceStringReader sourceStringReader = new SourceStringReader(Defines.createEmpty(), source,
|
||||
Collections.<String>emptyList());
|
||||
|
||||
final List<BlockUml> blocks = sourceStringReader.getBlocks();
|
||||
if (blocks.size() == 0) {
|
||||
result.setError(true);
|
||||
result.setLineLocation(lastLineNumber(source));
|
||||
result.addErrorText("No @enduml found");
|
||||
return result;
|
||||
}
|
||||
|
||||
final Diagram system = blocks.get(0).getDiagram();
|
||||
result.setCmapData(system.hasUrl());
|
||||
if (system instanceof UmlDiagram) {
|
||||
result.setUmlDiagramType(((UmlDiagram) system).getUmlDiagramType());
|
||||
result.setDescription(system.getDescription().getDescription());
|
||||
} else if (system instanceof PSystemError) {
|
||||
result.setError(true);
|
||||
final PSystemError sys = (PSystemError) system;
|
||||
result.setLineLocation(sys.getLineLocation());
|
||||
for (ErrorUml er : sys.getErrorsUml()) {
|
||||
result.addErrorText(er.getError());
|
||||
}
|
||||
result.setSystemError(sys);
|
||||
} else {
|
||||
result.setDescription(system.getDescription().getDescription());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static LineLocation lastLineNumber(String source) {
|
||||
LineLocationImpl result = new LineLocationImpl("", null).oneLineRead();
|
||||
for (int i = 0; i < source.length(); i++)
|
||||
if (source.charAt(i) == '\n')
|
||||
result = result.oneLineRead();
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
@ -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.13beta1";
|
||||
private static final String version = "1.2023.13beta2";
|
||||
|
||||
public static String versionString() {
|
||||
return version;
|
||||
|
Loading…
Reference in New Issue
Block a user