diff options
author | Andrej Shadura <andrew.shadura@collabora.co.uk> | 2020-03-10 16:38:20 +0100 |
---|---|---|
committer | Andrej Shadura <andrew.shadura@collabora.co.uk> | 2020-03-10 16:38:20 +0100 |
commit | 7cc8c823de644a510fcc434f39b53e5fffe66bfd (patch) | |
tree | 8f4d027284bb366734f610040c621a0c5dd0a12a /src/net/sourceforge/plantuml/jdot/CucaDiagramFileMakerJDot.java | |
parent | 567b200b91537405689ae0ca944f121201360a6b (diff) |
New upstream version 1.2020.2
Diffstat (limited to 'src/net/sourceforge/plantuml/jdot/CucaDiagramFileMakerJDot.java')
-rw-r--r-- | src/net/sourceforge/plantuml/jdot/CucaDiagramFileMakerJDot.java | 125 |
1 files changed, 54 insertions, 71 deletions
diff --git a/src/net/sourceforge/plantuml/jdot/CucaDiagramFileMakerJDot.java b/src/net/sourceforge/plantuml/jdot/CucaDiagramFileMakerJDot.java index 341ef61..c5fde00 100644 --- a/src/net/sourceforge/plantuml/jdot/CucaDiagramFileMakerJDot.java +++ b/src/net/sourceforge/plantuml/jdot/CucaDiagramFileMakerJDot.java @@ -2,7 +2,7 @@ * PlantUML : a free UML diagram generator * ======================================================================== * - * (C) Copyright 2009-2017, Arnaud Roques + * (C) Copyright 2009-2020, Arnaud Roques * * Project Info: http://plantuml.com * @@ -42,11 +42,10 @@ import static gen.lib.cgraph.node__c.agnode; import static gen.lib.cgraph.subg__c.agsubg; import static gen.lib.gvc.gvc__c.gvContext; import static gen.lib.gvc.gvlayout__c.gvLayoutJobs; -import h.ST_Agraph_s; -import h.ST_Agraphinfo_t; import h.ST_Agedge_s; import h.ST_Agnode_s; import h.ST_Agnodeinfo_t; +import h.ST_Agraph_s; import h.ST_Agraphinfo_t; import h.ST_GVC_s; import h.ST_boxf; @@ -84,6 +83,7 @@ import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.Member; import net.sourceforge.plantuml.cucadiagram.MethodsOrFieldsArea; import net.sourceforge.plantuml.cucadiagram.Stereotype; +import net.sourceforge.plantuml.cucadiagram.entity.EntityFactory; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.HtmlColor; @@ -103,12 +103,11 @@ import net.sourceforge.plantuml.svek.DotStringFactory; import net.sourceforge.plantuml.svek.GeneralImageBuilder; import net.sourceforge.plantuml.svek.GraphvizCrash; import net.sourceforge.plantuml.svek.IEntityImage; -import net.sourceforge.plantuml.svek.Shape; +import net.sourceforge.plantuml.svek.Node; import net.sourceforge.plantuml.ugraphic.ImageBuilder; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UTranslate; -import net.sourceforge.plantuml.ugraphic.sprite.Sprite; import smetana.core.CString; import smetana.core.JUtils; import smetana.core.JUtilsDebug; @@ -123,7 +122,6 @@ public class CucaDiagramFileMakerJDot implements CucaDiagramFileMaker { private final Map<ILeaf, ST_Agnode_s> nodes = new LinkedHashMap<ILeaf, ST_Agnode_s>(); private final Map<Link, ST_Agedge_s> edges = new LinkedHashMap<Link, ST_Agedge_s>(); private final Map<IGroup, ST_Agraph_s> clusters = new LinkedHashMap<IGroup, ST_Agraph_s>(); - private Map<IGroup, ILeaf> emptyGroups = new HashMap<IGroup, ILeaf>(); private final DotStringFactory dotStringFactory; @@ -143,18 +141,19 @@ public class CucaDiagramFileMakerJDot implements CucaDiagramFileMaker { for (Map.Entry<ILeaf, ST_Agnode_s> ent : nodes.entrySet()) { final ILeaf leaf = ent.getKey(); - final ST_Agnode_s node = ent.getValue(); - final Point2D corner = getCorner(node); + final ST_Agnode_s agnode = ent.getValue(); + final Point2D corner = getCorner(agnode); - final Shape shape = dotStringFactory.getBibliotekon().getShape(leaf); - final IEntityImage image = shape.getImage(); + final Node node = dotStringFactory.getBibliotekon().getNode(leaf); + final IEntityImage image = node.getImage(); image.drawU(ug.apply(new UTranslate(corner))); } for (Map.Entry<Link, ST_Agedge_s> ent : edges.entrySet()) { final Link link = ent.getKey(); final ST_Agedge_s edge = ent.getValue(); - new JDotPath(link, edge, ymirror, diagram, getLabel(link), getQualifier(link, 1), getQualifier(link, 2)).drawU(ug); + new JDotPath(link, edge, ymirror, diagram, getLabel(link), getQualifier(link, 1), getQualifier(link, 2)) + .drawU(ug); } } @@ -200,7 +199,8 @@ public class CucaDiagramFileMakerJDot implements CucaDiagramFileMaker { final Cluster cluster = dotStringFactory.getBibliotekon().getCluster(group); cluster.setPosition(llx, lly, urx, ury); JUtils.LOG2("cluster=" + cluster); - // ug.apply(new UTranslate(llx, lly)).apply(new UChangeColor(HtmlColorUtils.BLUE)) + // ug.apply(new UTranslate(llx, lly)).apply(new + // UChangeColor(HtmlColorUtils.BLUE)) // .draw(new URectangle(urx - llx, ury - lly)); cluster.drawU(ug, new UStroke(1.5), diagram.getUmlDiagramType(), diagram.getSkinParam()); } @@ -211,21 +211,9 @@ public class CucaDiagramFileMakerJDot implements CucaDiagramFileMaker { continue; } if (diagram.isEmpty(g) && g.getGroupType() == GroupType.PACKAGE) { - final ILeaf folder = diagram.getEntityFactory().createLeaf(g.getCode(), g.getDisplay(), - LeafType.EMPTY_PACKAGE, g.getParentContainer(), null, diagram.getNamespaceSeparator()); - emptyGroups.put(g, folder); - final USymbol symbol = g.getUSymbol(); - folder.setUSymbol(symbol); - folder.setStereotype(g.getStereotype()); - if (g.getColors(diagram.getSkinParam()).getColor(ColorType.BACK) == null) { - final ColorParam param = symbol == null ? ColorParam.packageBackground : symbol.getColorParamBack(); - final HtmlColor c1 = diagram.getSkinParam().getHtmlColor(param, g.getStereotype(), false); - folder.setSpecificColorTOBEREMOVED(ColorType.BACK, c1 == null ? diagram.getSkinParam() - .getBackgroundColor() : c1); - } else { - folder.setSpecificColorTOBEREMOVED(ColorType.BACK, - g.getColors(diagram.getSkinParam()).getColor(ColorType.BACK)); - } + final ISkinParam skinParam = diagram.getSkinParam(); + final EntityFactory entityFactory = diagram.getEntityFactory(); + final ILeaf folder = entityFactory.createLeafForEmptyGroup(g, skinParam); printEntityNew(folder); } else { printGroup(g); @@ -262,10 +250,11 @@ public class CucaDiagramFileMakerJDot implements CucaDiagramFileMaker { final int suppWidthBecauseOfShape = uSymbol == null ? 0 : uSymbol.suppWidthBecauseOfShape(); titleAndAttributeWidth = (int) Math.max(dimLabel.getWidth(), attributeWidth) + suppWidthBecauseOfShape; - titleAndAttributeHeight = (int) (dimLabel.getHeight() + attributeHeight + marginForFields + suppHeightBecauseOfShape); + titleAndAttributeHeight = (int) (dimLabel.getHeight() + attributeHeight + marginForFields + + suppHeightBecauseOfShape); } - dotStringFactory.openCluster(g, titleAndAttributeWidth, titleAndAttributeHeight, title, stereo); + dotStringFactory.openCluster(titleAndAttributeWidth, titleAndAttributeHeight, title, stereo, g); this.printEntities(g.getLeafsDirect()); printGroups(g); @@ -292,16 +281,16 @@ public class CucaDiagramFileMakerJDot implements CucaDiagramFileMaker { } private void exportEntity(ST_Agraph_s g, ILeaf leaf) { - final Shape shape = dotStringFactory.getBibliotekon().getShape(leaf); + final Node node = dotStringFactory.getBibliotekon().getNode(leaf); // System.err.println("exportEntity " + leaf); - final ST_Agnode_s node = agnode(g, new CString(shape.getUid()), true); - agsafeset(node, new CString("shape"), new CString("box"), new CString("")); - final String width = "" + (shape.getWidth() / 72); - final String height = "" + (shape.getHeight() / 72); - agsafeset(node, new CString("width"), new CString(width), new CString("")); - agsafeset(node, new CString("height"), new CString(height), new CString("")); + final ST_Agnode_s agnode = agnode(g, new CString(node.getUid()), true); + agsafeset(agnode, new CString("shape"), new CString("box"), new CString("")); + final String width = "" + (node.getWidth() / 72); + final String height = "" + (node.getHeight() / 72); + agsafeset(agnode, new CString("width"), new CString(width), new CString("")); + agsafeset(agnode, new CString("height"), new CString(height), new CString("")); // System.err.println("NODE " + leaf.getUid() + " " + width + " " + height); - nodes.put(leaf, node); + nodes.put(leaf, agnode); } private void printEntity(ILeaf ent) { @@ -309,12 +298,8 @@ public class CucaDiagramFileMakerJDot implements CucaDiagramFileMaker { throw new IllegalStateException(); } final IEntityImage image = printEntityInternal(ent); - final Dimension2D dim = image.calculateDimension(stringBounder); - final Shape shape = new Shape(image, image.getShapeType(), dim.getWidth(), dim.getHeight(), - dotStringFactory.getColorSequence(), ent.isTop(), image.getShield(stringBounder), - ent.getEntityPosition()); - dotStringFactory.addShape(shape); - getBibliotekon().putShape(ent, shape); + final Node node = getBibliotekon().createNode(ent, image, dotStringFactory.getColorSequence(), stringBounder); + dotStringFactory.addNode(node); } private TextBlock getTitleBlock(IGroup g) { @@ -333,13 +318,11 @@ public class CucaDiagramFileMakerJDot implements CucaDiagramFileMaker { if (stereotype == null) { return TextBlockUtils.empty(0, 0); } - if (stereotype.getSprite() != null) { - final Sprite tmp = diagram.getSkinParam().getSprite(stereotype.getSprite()); - if (tmp != null) { - return tmp.asTextBlock(stereotype.getHtmlColor(), 1); - } + final TextBlock tmp = stereotype.getSprite(diagram.getSkinParam()); + if (tmp != null) { + return tmp; } - final List<String> stereos = stereotype.getLabels(diagram.getSkinParam().useGuillemet()); + final List<String> stereos = stereotype.getLabels(diagram.getSkinParam().guillemet()); if (stereos == null) { return TextBlockUtils.empty(0, 0); } @@ -364,15 +347,15 @@ public class CucaDiagramFileMakerJDot implements CucaDiagramFileMaker { } private void printCluster(ST_Agraph_s g, Cluster cluster) { - for (Shape shape : cluster.getShapes()) { - final ST_Agnode_s node = agnode(g, new CString(shape.getUid()), true); - agsafeset(node, new CString("shape"), new CString("box"), new CString("")); - final String width = "" + (shape.getWidth() / 72); - final String height = "" + (shape.getHeight() / 72); - agsafeset(node, new CString("width"), new CString(width), new CString("")); - agsafeset(node, new CString("height"), new CString(height), new CString("")); - final ILeaf leaf = dotStringFactory.getBibliotekon().getLeaf(shape); - nodes.put(leaf, node); + for (Node node : cluster.getNodes()) { + final ST_Agnode_s agnode = agnode(g, new CString(node.getUid()), true); + agsafeset(agnode, new CString("shape"), new CString("box"), new CString("")); + final String width = "" + (node.getWidth() / 72); + final String height = "" + (node.getHeight() / 72); + agsafeset(agnode, new CString("width"), new CString(width), new CString("")); + agsafeset(agnode, new CString("height"), new CString(height), new CString("")); + final ILeaf leaf = dotStringFactory.getBibliotekon().getLeaf(node); + nodes.put(leaf, agnode); } } @@ -414,7 +397,8 @@ public class CucaDiagramFileMakerJDot implements CucaDiagramFileMaker { // agsafeset(node, new CString("height"), new CString(height), new CString("")); // nodes.put(leaf, node); // // System.err - // // .println("NODE " + leaf.getUid() + " [shape=box, width=" + width + ", height=" + height + "]"); + // // .println("NODE " + leaf.getUid() + " [shape=box, width=" + width + ", + // height=" + height + "]"); // } // for (Link link : diagram.getLinks()) { @@ -463,7 +447,8 @@ public class CucaDiagramFileMakerJDot implements CucaDiagramFileMaker { continue; } if (diagram.isEmpty(g) && g.getGroupType() == GroupType.PACKAGE) { - final ILeaf folder = emptyGroups.get(g); + final EntityFactory entityFactory = diagram.getEntityFactory(); + final ILeaf folder = entityFactory.getLeafForEmptyGroup(g); exportEntity(graph, folder); } else { exportGroup(graph, g); @@ -479,8 +464,8 @@ public class CucaDiagramFileMakerJDot implements CucaDiagramFileMaker { if (cluster.isLabel()) { final double width = cluster.getTitleAndAttributeWidth(); final double height = cluster.getTitleAndAttributeHeight() - 5; - agsafeset(cluster1, new CString("label"), - Macro.createHackInitDimensionFromLabel((int) width, (int) height), new CString("")); + agsafeset(cluster1, new CString("label"), Macro.createHackInitDimensionFromLabel((int) width, (int) height), + new CString("")); } this.exportEntities(cluster1, group.getLeafsDirect()); this.clusters.put(group, cluster1); @@ -520,9 +505,9 @@ public class CucaDiagramFileMakerJDot implements CucaDiagramFileMaker { if (n != null) { return n; } - final String id = getBibliotekon().getShapeUid((ILeaf) entity); + final String id = getBibliotekon().getNodeUid((ILeaf) entity); for (Map.Entry<ILeaf, ST_Agnode_s> ent : nodes.entrySet()) { - if (id.equals(getBibliotekon().getShapeUid(ent.getKey()))) { + if (id.equals(getBibliotekon().getNodeUid(ent.getKey()))) { return ent.getValue(); } } @@ -546,10 +531,12 @@ public class CucaDiagramFileMakerJDot implements CucaDiagramFileMaker { int length = link.getLength(); // System.err.println("length=" + length); - // if (/* pragma.horizontalLineBetweenDifferentPackageAllowed() || */link.isInvis() || length != 1) { + // if (/* pragma.horizontalLineBetweenDifferentPackageAllowed() || + // */link.isInvis() || length != 1) { agsafeset(e, new CString("minlen"), new CString("" + (length - 1)), new CString("")); // } - // System.err.print("EDGE " + link.getEntity1().getUid() + "->" + link.getEntity2().getUid() + " minlen=" + // System.err.print("EDGE " + link.getEntity1().getUid() + "->" + + // link.getEntity2().getUid() + " minlen=" // + (length - 1) + " "); final TextBlock label = getLabel(link); @@ -603,12 +590,8 @@ public class CucaDiagramFileMakerJDot implements CucaDiagramFileMaker { throw new IllegalStateException(); } final IEntityImage image = printEntityInternal(ent); - final Dimension2D dim = image.calculateDimension(stringBounder); - final Shape shape = new Shape(image, image.getShapeType(), dim.getWidth(), dim.getHeight(), - dotStringFactory.getColorSequence(), ent.isTop(), image.getShield(stringBounder), - ent.getEntityPosition()); + final Node shape = getBibliotekon().createNode(ent, image, dotStringFactory.getColorSequence(), stringBounder); // dotStringFactory.addShape(shape); - getBibliotekon().putShape(ent, shape); } private Bibliotekon getBibliotekon() { |