-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for graphviz builtin shapes
- Loading branch information
Showing
8 changed files
with
157 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,37 @@ | ||
from enum import Enum | ||
|
||
|
||
class Shape(Enum): | ||
RECT = "rect" | ||
ELLIPSE = "ellipse" | ||
ELLIPSE = "ellipse" | ||
OVAL = "oval" | ||
BOX = "box" | ||
RECT = "rect" | ||
RECTANGLE = "rectangle" | ||
HEXAGON = "hexagon" | ||
POLYGON = "polygon" | ||
CIRCLE = "circle" | ||
EGG = "egg" | ||
TRIANGLE = "triangle" | ||
PLAIN = "plain" | ||
DIAMOND = "diamond" | ||
TRAPEZIUM = "trapezium" | ||
PARALLELOGRAM = "parallelogram" | ||
HOUSE = "house" | ||
PENTAGON = "pentagon" | ||
OCTAGON = "octagon" | ||
DOUBLE_CIRCLE = "doublecircle" | ||
DOUBLE_OCTAGON = "doubleoctagon" | ||
INV_TRIANGLE = "invtriangle" | ||
INV_TRAPEZIUM = "invtrapezium" | ||
INV_HOUSE = "invhouse" | ||
SQUARE = "square" | ||
STAR = "star" | ||
UNDERLINE = "underline" | ||
CYLINDER = "cylinder" | ||
NOTE = "note" | ||
TAB = "tab" | ||
FOLDER = "folder" | ||
BOX_3D = "box3d" | ||
COMPONENT = "component" | ||
PROMOTER = "promoter" | ||
RPROMOTER = "rpromoter" | ||
LPROMOTER = "lpromoter" | ||
CDS = "cds" | ||
RARROW = "rarrow" | ||
LARROW = "larrow" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,112 @@ | ||
from enum import Enum | ||
from . import Shape | ||
|
||
|
||
class Styles(Enum): | ||
NODE = "verticalAlign=top;align=left;overflow=fill;html=1;rounded=0;shadow=0;comic=0;labelBackgroundColor=none;strokeColor={stroke};strokeWidth=1;fillColor={fill};" | ||
EDGE = "edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;exitX={exit_x:.3g};exitY={exit_y:.3g};entryX={entry_x:.3g};entryY={entry_y:.3g};jettySize=auto;orthogonalLoop=1;endArrow={end_arrow};dashed={dashed};endFill={end_fill};" | ||
TEXT = "margin:0px;text-align:{align};{margin};font-size:{size}px;font-family:{family};color:{color};" | ||
|
||
ELLIPSE = "ellipse;" + NODE | ||
CIRCLE = "ellipse;aspect=fixed;" + NODE | ||
HEXAGON = "shape=hexagon;perimeter=hexagonPerimeter2;" + NODE | ||
EGG = "shape=mxgraph.flowchart.display;direction=south;" + NODE | ||
TRIANGLE = "triangle;direction=north;" + NODE | ||
LINE = "line;strokeWidth=2;verticalAlign=bottom;labelPosition=center;verticalLabelPosition=top;align=center;" + NODE | ||
DIAMOND = "rhombus;" + NODE | ||
TRAPEZOID = "shape=trapezoid;perimeter=trapezoidPerimeter;" + NODE | ||
PARALLELOGRAM = "shape=parallelogram;perimeter=parallelogramPerimeter;" + NODE | ||
HOUSE = "shape=offPageConnector;direction=west;" + NODE | ||
PENTAGON = "shape=mxgraph.basic.pentagon;" + NODE | ||
OCTAGON = "shape=mxgraph.basic.octagon2;align=center;verticalAlign=middle;dx=15;" + NODE | ||
DOUBLE_CIRCLE = "ellipse;shape=doubleEllipse;aspect=fixed;" + NODE | ||
DOUBLE_OCTAGON = "shape=image;html=1;verticalAlign=middle;verticalLabelPosition=middle;imageAspect=0;aspect=fixed;image=https://cdn4.iconfinder.com/data/icons/feather/24/octagon-128.png;labelPosition=center;align=center;" + NODE | ||
INV_TRIANGLE = "triangle;direction=south;" + NODE | ||
INV_TRAPEZOID = "shape=trapezoid;perimeter=trapezoidPerimeter;direction=west;" + NODE | ||
INV_HOUSE = "shape=offPageConnector;direction=east;" + NODE | ||
SQUARE = "aspect=fixed;" + NODE | ||
STAR = "shape=mxgraph.basic.star;labelPosition=center;align=center;verticalLabelPosition=middle;verticalAlign=middle;" + NODE | ||
UNDERLINE = "line;strokeWidth=2;verticalAlign=bottom;labelPosition=center;verticalLabelPosition=top;align=center;" | ||
CYLINDER = "shape=cylinder;boundedLbl=1;backgroundOutline=1;" + NODE | ||
NOTE = "shape=note;backgroundOutline=1;" + NODE | ||
TAB = "shape=folder;tabWidth=40;tabHeight=14;tabPosition=left;" + NODE | ||
FOLDER = "shape=mxgraph.office.concepts.folder;outlineConnect=0;align=center;verticalLabelPosition=middle;verticalAlign=middle;labelPosition=center;shadow=0;dashed=0;" + NODE | ||
CUBE = "shape=cube;boundedLbl=1;backgroundOutline=1;" + NODE | ||
COMPONENT = "shape=component;align=center;spacingLeft=36;verticalAlign=bottom;" + NODE | ||
RPROMOTER = "shape=mxgraph.arrows2.bendArrow;dy=15;dx=38;notch=0;arrowHead=55;rounded=0;shadow=0;dashed=0;align=center;verticalAlign=middle;" + NODE | ||
LPROMOTER = "flipH=1;" + RPROMOTER | ||
CDS = "shape=mxgraph.arrows2.arrow;dy=0;dx=10;notch=0;shadow=0;dashed=0;align=center;verticalAlign=middle;" + NODE | ||
RARROW = "shape=mxgraph.arrows2.arrow;dy=0.6;dx=40;align=center;labelPosition=center;notch=0;strokeWidth=2;verticalLabelPosition=middle;verticalAlign=middle;" + NODE | ||
LARROW = "flipH=1;" + RARROW | ||
|
||
@staticmethod | ||
def get_for_shape(dot_shape): | ||
if dot_shape == Shape.ELLIPSE or dot_shape == Shape.OVAL: | ||
return Styles.ELLIPSE | ||
elif dot_shape == Shape.BOX or dot_shape == Shape.RECT or dot_shape == Shape.RECTANGLE: | ||
return Styles.NODE | ||
elif dot_shape == Shape.HEXAGON or dot_shape == Shape.POLYGON: | ||
return Styles.HEXAGON | ||
elif dot_shape == Shape.CIRCLE: | ||
return Styles.CIRCLE | ||
elif dot_shape == Shape.EGG: | ||
return Styles.EGG | ||
elif dot_shape == Shape.TRIANGLE: | ||
return Styles.TRIANGLE | ||
elif dot_shape == Shape.PLAIN: | ||
return Styles.LINE | ||
elif dot_shape == Shape.DIAMOND: | ||
return Styles.DIAMOND | ||
elif dot_shape == Shape.TRAPEZIUM: | ||
return Styles.TRAPEZOID | ||
elif dot_shape == Shape.PARALLELOGRAM: | ||
return Styles.PARALLELOGRAM | ||
elif dot_shape == Shape.HOUSE: | ||
return Styles.HOUSE | ||
elif dot_shape == Shape.PENTAGON: | ||
return Styles.PENTAGON | ||
elif dot_shape == Shape.OCTAGON: | ||
return Styles.OCTAGON | ||
elif dot_shape == Shape.DOUBLE_CIRCLE: | ||
return Styles.DOUBLE_CIRCLE | ||
elif dot_shape == Shape.DOUBLE_OCTAGON: | ||
return Styles.DOUBLE_OCTAGON | ||
elif dot_shape == Shape.INV_TRIANGLE: | ||
return Styles.INV_TRIANGLE | ||
elif dot_shape == Shape.INV_TRAPEZIUM: | ||
return Styles.INV_TRAPEZOID | ||
elif dot_shape == Shape.INV_HOUSE: | ||
return Styles.INV_HOUSE | ||
elif dot_shape == Shape.SQUARE: | ||
return Styles.SQUARE | ||
elif dot_shape == Shape.STAR: | ||
return Styles.STAR | ||
elif dot_shape == Shape.UNDERLINE: | ||
return Styles.UNDERLINE | ||
elif dot_shape == Shape.CYLINDER: | ||
return Styles.CYLINDER | ||
elif dot_shape == Shape.NOTE: | ||
return Styles.NODE | ||
elif dot_shape == Shape.TAB: | ||
return Styles.TAB | ||
elif dot_shape == Shape.FOLDER: | ||
return Styles.FOLDER | ||
elif dot_shape == Shape.BOX_3D: | ||
return Styles.CUBE | ||
elif dot_shape == Shape.COMPONENT: | ||
return Styles.COMPONENT | ||
elif dot_shape == Shape.PROMOTER or dot_shape == Shape.RPROMOTER: | ||
return Styles.RPROMOTER | ||
elif dot_shape == Shape.LPROMOTER: | ||
return Styles.LPROMOTER | ||
elif dot_shape == Shape.CDS: | ||
return Styles.CDS | ||
elif dot_shape == Shape.RARROW: | ||
return Styles.RARROW | ||
elif dot_shape == Shape.LARROW: | ||
return Styles.LARROW | ||
else: | ||
return Styles.NODE | ||
|
||
def format(self, **values): | ||
return self.value.format(**values) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "0.0.4" | ||
__version__ = "0.0.5" |
I think this is still broken. You need to do
t.attrib.get('fill')
. You still get a key error witht.attrib['fill'] or None
since fill is not in the dict. I'm not sure why this is happening, possibly different versions of graphviz. It's not happening on travis either but still happening for me.