diff options
Diffstat (limited to 'src/net/sourceforge/plantuml/cucadiagram/dot')
5 files changed, 84 insertions, 38 deletions
diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramTxtMaker.java b/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramTxtMaker.java index b4c41e2..eb2b1f4 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramTxtMaker.java +++ b/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramTxtMaker.java @@ -52,9 +52,12 @@ import net.sourceforge.plantuml.FileFormat; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.cucadiagram.CucaDiagram; import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.cucadiagram.EntityPortion; import net.sourceforge.plantuml.cucadiagram.IEntity; +import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.Member; +import net.sourceforge.plantuml.cucadiagram.PortionShower; import net.sourceforge.plantuml.posimo.Block; import net.sourceforge.plantuml.posimo.Cluster; import net.sourceforge.plantuml.posimo.GraphvizSolverB; @@ -67,6 +70,7 @@ public final class CucaDiagramTxtMaker { // private final CucaDiagram diagram; private final FileFormat fileFormat; private final UGraphicTxt globalUg = new UGraphicTxt(); + private final PortionShower portionShower; private static double getXPixelPerChar() { return 5; @@ -76,9 +80,15 @@ public final class CucaDiagramTxtMaker { return 10; } + private boolean showMember(IEntity entity) { + final boolean showMethods = portionShower.showPortion(EntityPortion.METHOD, entity); + final boolean showFields = portionShower.showPortion(EntityPortion.FIELD, entity); + return showMethods || showFields; + } + public CucaDiagramTxtMaker(CucaDiagram diagram, FileFormat fileFormat) throws IOException { - // this.diagram = diagram; this.fileFormat = fileFormat; + this.portionShower = diagram; final Cluster root = new Cluster(null, 0, 0); int uid = 0; @@ -123,20 +133,22 @@ public final class CucaDiagramTxtMaker { final int h = getHeight(ent); ug.getCharArea().drawBoxSimple(0, 0, w, h); ug.getCharArea().drawStringsLR(ent.getDisplay().as(), 1, 1); - int y = 2; - ug.getCharArea().drawHLine('-', y, 1, w - 1); - y++; - for (Member att : ent.getBodier().getFieldsToDisplay()) { - final List<String> disp = BackSlash.getWithNewlines(att.getDisplay(true)); - ug.getCharArea().drawStringsLR(disp, 1, y); - y += StringUtils.getHeight(disp); - } - ug.getCharArea().drawHLine('-', y, 1, w - 1); - y++; - for (Member att : ent.getBodier().getMethodsToDisplay()) { - final List<String> disp = BackSlash.getWithNewlines(att.getDisplay(true)); - ug.getCharArea().drawStringsLR(disp, 1, y); - y += StringUtils.getHeight(disp); + if (showMember(ent)) { + int y = 2; + ug.getCharArea().drawHLine('-', y, 1, w - 1); + y++; + for (Member att : ent.getBodier().getFieldsToDisplay()) { + final List<String> disp = BackSlash.getWithNewlines(att.getDisplay(true)); + ug.getCharArea().drawStringsLR(disp, 1, y); + y += StringUtils.getHeight(disp); + } + ug.getCharArea().drawHLine('-', y, 1, w - 1); + y++; + for (Member att : ent.getBodier().getMethodsToDisplay()) { + final List<String> disp = BackSlash.getWithNewlines(att.getDisplay(true)); + ug.getCharArea().drawStringsLR(disp, 1, y); + y += StringUtils.getHeight(disp); + } } } @@ -151,27 +163,33 @@ public final class CucaDiagramTxtMaker { private int getHeight(IEntity entity) { int result = StringUtils.getHeight(entity.getDisplay()); - for (Member att : entity.getBodier().getMethodsToDisplay()) { - result += StringUtils.getHeight(Display.getWithNewlines(att.getDisplay(true))); - } - for (Member att : entity.getBodier().getFieldsToDisplay()) { - result += StringUtils.getHeight(Display.getWithNewlines(att.getDisplay(true))); + if (showMember(entity)) { + for (Member att : entity.getBodier().getMethodsToDisplay()) { + result += StringUtils.getHeight(Display.getWithNewlines(att.getDisplay(true))); + } + result++; + for (Member att : entity.getBodier().getFieldsToDisplay()) { + result += StringUtils.getHeight(Display.getWithNewlines(att.getDisplay(true))); + } + result++; } - return result + 4; + return result + 2; } private int getWidth(IEntity entity) { - int result = StringUtils.getWidth(entity.getDisplay()); - for (Member att : entity.getBodier().getMethodsToDisplay()) { - final int w = StringUtils.getWidth(Display.getWithNewlines(att.getDisplay(true))); - if (w > result) { - result = w; + int result = StringUtils.getWcWidth(entity.getDisplay()); + if (showMember(entity)) { + for (Member att : entity.getBodier().getMethodsToDisplay()) { + final int w = StringUtils.getWcWidth(Display.getWithNewlines(att.getDisplay(true))); + if (w > result) { + result = w; + } } - } - for (Member att : entity.getBodier().getFieldsToDisplay()) { - final int w = StringUtils.getWidth(Display.getWithNewlines(att.getDisplay(true))); - if (w > result) { - result = w; + for (Member att : entity.getBodier().getFieldsToDisplay()) { + final int w = StringUtils.getWcWidth(Display.getWithNewlines(att.getDisplay(true))); + if (w > result) { + result = w; + } } } return result + 2; diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizLinux.java b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizLinux.java index 94b4d9f..d50500b 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizLinux.java +++ b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizLinux.java @@ -48,12 +48,15 @@ class GraphvizLinux extends AbstractGraphviz { @Override protected File specificDotExe() { final File usrLocalBinDot = new File("/usr/local/bin/dot"); - if (usrLocalBinDot.exists()) { return usrLocalBinDot; } final File usrBinDot = new File("/usr/bin/dot"); - return usrBinDot; + if (usrBinDot.exists()) { + return usrBinDot; + } + final File optLocalBinDot = new File("/opt/local/bin/dot"); + return optLocalBinDot; } } diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizUtils.java b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizUtils.java index 408c3ba..4e6c0da 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizUtils.java +++ b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizUtils.java @@ -117,7 +117,21 @@ public class GraphvizUtils { return null; } + private static final ThreadLocal<Integer> limitSize = new ThreadLocal<Integer>(); + + public static void removeLocalLimitSize() { + limitSize.remove(); + } + + public static void setLocalImageLimit(int value) { + limitSize.set(value); + } + public static int getenvImageLimit() { + final Integer local = limitSize.get(); + if (local != null) { + return local; + } final String env = System.getProperty("PLANTUML_LIMIT_SIZE"); if (StringUtils.isNotEmpty(env) && env.matches("\\d+")) { return Integer.parseInt(env); diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizVersion.java b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizVersion.java index 4b9f049..6f0b549 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizVersion.java +++ b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizVersion.java @@ -40,10 +40,10 @@ public interface GraphvizVersion { public boolean useProtectionWhenThereALinkFromOrToGroup(); - public boolean modeSafe(); + public boolean useXLabelInsteadOfLabel(); public boolean isVizjs(); - - // COMMON, V2_34_0 + + public boolean ignoreHorizontalLinks(); } diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizVersionFinder.java b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizVersionFinder.java index b8df542..968134e 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizVersionFinder.java +++ b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizVersionFinder.java @@ -53,13 +53,17 @@ public class GraphvizVersionFinder { return true; } - public boolean modeSafe() { + public boolean useXLabelInsteadOfLabel() { return false; } public boolean isVizjs() { return false; } + + public boolean ignoreHorizontalLinks() { + return false; + } }; public GraphvizVersionFinder(File dotExe) { @@ -89,7 +93,7 @@ public class GraphvizVersionFinder { return true; } - public boolean modeSafe() { + public boolean useXLabelInsteadOfLabel() { return false; } @@ -97,6 +101,13 @@ public class GraphvizVersionFinder { return false; } + public boolean ignoreHorizontalLinks() { + if (v == 230) { + return true; + } + return false; + } + }; } |