Package berlin.yuna.survey.model
Class DiagramConfig
- java.lang.Object
-
- berlin.yuna.survey.model.DiagramConfig
-
public class DiagramConfig extends Object
TheDiagramConfig
is used to define the visible output of the diagram
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DiagramConfig.ElementType
-
Constructor Summary
Constructors Constructor Description DiagramConfig(DiagramExporter exporter)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description DiagramConfig
add(DiagramConfig.ElementType type, guru.nidi.graphviz.attribute.Attributes<? extends guru.nidi.graphviz.attribute.ForNode> attribute)
Adds a configuration/attribute to a specificDiagramConfig.ElementType
of the diagram Previous attribute with same key will be removedboolean
containsKey(DiagramConfig.ElementType type, String key)
Check if a key is already defined in the configDiagramExporter
diagram()
DiagramExporter
for chain operationsguru.nidi.graphviz.attribute.Rank.RankDir
direction()
Direction of the diagramDiagramConfig
direction(guru.nidi.graphviz.attribute.Rank.RankDir direction)
Sets the direction of the diagram (e.g.Set<guru.nidi.graphviz.attribute.Attributes<? extends guru.nidi.graphviz.attribute.ForNode>>
get(DiagramConfig.ElementType type)
Gets all configurations/attributes for the givenDiagramConfig.ElementType
Optional<guru.nidi.graphviz.attribute.Attributes<? extends guru.nidi.graphviz.attribute.ForNode>>
get(DiagramConfig.ElementType type, String key)
Gets a specific configuration/attribute for the given key andDiagramConfig.ElementType
guru.nidi.graphviz.attribute.Attributes<? extends guru.nidi.graphviz.attribute.ForNode>
getOrDefault(DiagramConfig.ElementType type, String key, guru.nidi.graphviz.attribute.Attributes<? extends guru.nidi.graphviz.attribute.ForNode> defaultValue)
Gets a specific configuration/attribute for the given key andDiagramConfig.ElementType
int
height()
Height of the diagramDiagramConfig
height(int height)
Sets the height of the diagram (-1 = automatic)boolean
showBackTransition()
Switch to show or hide the back transitionsDiagramConfig
showBackTransition(boolean showBackTransition)
Switch to show or hide the back transitionsstatic String
toKey(guru.nidi.graphviz.attribute.Attributes<? extends guru.nidi.graphviz.attribute.ForNode> attribute)
Extracts anAttributes
to its key valueint
width()
Width of the diagramDiagramConfig
width(int width)
Sets the width of the diagram (-1 = automatic)
-
-
-
Constructor Detail
-
DiagramConfig
public DiagramConfig(DiagramExporter exporter)
-
-
Method Detail
-
width
public int width()
Width of the diagram- Returns:
- current configured width
-
width
public DiagramConfig width(int width)
Sets the width of the diagram (-1 = automatic)- Returns:
- current
DiagramConfig
-
height
public int height()
Height of the diagram- Returns:
- current configured height
-
height
public DiagramConfig height(int height)
Sets the height of the diagram (-1 = automatic)- Returns:
- current
DiagramConfig
-
direction
public guru.nidi.graphviz.attribute.Rank.RankDir direction()
Direction of the diagram- Returns:
- the direction
Rank.RankDir
of the diagram
-
direction
public DiagramConfig direction(guru.nidi.graphviz.attribute.Rank.RankDir direction)
Sets the direction of the diagram (e.g. left to right)- Returns:
- current
DiagramConfig
-
showBackTransition
public boolean showBackTransition()
Switch to show or hide the back transitions- Returns:
true
if transitions will be shown on the diagram
-
showBackTransition
public DiagramConfig showBackTransition(boolean showBackTransition)
Switch to show or hide the back transitions- Returns:
- current
DiagramConfig
-
diagram
public DiagramExporter diagram()
DiagramExporter
for chain operations- Returns:
DiagramExporter
-
add
public DiagramConfig add(DiagramConfig.ElementType type, guru.nidi.graphviz.attribute.Attributes<? extends guru.nidi.graphviz.attribute.ForNode> attribute)
Adds a configuration/attribute to a specificDiagramConfig.ElementType
of the diagram Previous attribute with same key will be removed- Parameters:
type
-DiagramConfig.ElementType
to apply the attributeattribute
- configuration/attribute for the specifiedDiagramConfig.ElementType
- Returns:
- current
DiagramConfig
-
containsKey
public boolean containsKey(DiagramConfig.ElementType type, String key)
Check if a key is already defined in the config- Parameters:
type
-DiagramConfig.ElementType
to apply the attributekey
- configuration/attribute key for the specifiedDiagramConfig.ElementType
- Returns:
true
if the key exists in the configuration
-
getOrDefault
public guru.nidi.graphviz.attribute.Attributes<? extends guru.nidi.graphviz.attribute.ForNode> getOrDefault(DiagramConfig.ElementType type, String key, guru.nidi.graphviz.attribute.Attributes<? extends guru.nidi.graphviz.attribute.ForNode> defaultValue)
Gets a specific configuration/attribute for the given key andDiagramConfig.ElementType
- Parameters:
type
-DiagramConfig.ElementType
for the configuration/attributekey
- configuration/attribute key for the specifiedDiagramConfig.ElementType
defaultValue
- fallback if the key wasn't defined- Returns:
- configured
Attributes
or else value from 'defaultValue` parameter
-
get
public Optional<guru.nidi.graphviz.attribute.Attributes<? extends guru.nidi.graphviz.attribute.ForNode>> get(DiagramConfig.ElementType type, String key)
Gets a specific configuration/attribute for the given key andDiagramConfig.ElementType
- Parameters:
type
-DiagramConfig.ElementType
for the configuration/attributekey
- configuration/attribute key to search for- Returns:
- configured
Optional.empty()
if the key wasn't found in the configuration
-
get
public Set<guru.nidi.graphviz.attribute.Attributes<? extends guru.nidi.graphviz.attribute.ForNode>> get(DiagramConfig.ElementType type)
Gets all configurations/attributes for the givenDiagramConfig.ElementType
- Parameters:
type
-DiagramConfig.ElementType
for the configuration/attribute- Returns:
- a set of
Attributes
-
toKey
public static String toKey(guru.nidi.graphviz.attribute.Attributes<? extends guru.nidi.graphviz.attribute.ForNode> attribute)
Extracts anAttributes
to its key value- Parameters:
attribute
-Attributes
to extract key from- Returns:
- key from
Attributes
-
-