Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap element name #2889

Merged
merged 9 commits into from
Dec 2, 2023
3 changes: 3 additions & 0 deletions docs/style_sheets.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ family, size, weight.
``vertical-spacing`` Set vertical spacing for icon-like items (actors, start state).

Example: ``vertical-spacing: 4``.
``white-space`` Change the line wrapping behavior for text.
Some text, like class' attributes and operations, cannot be wrapped.
Either ``normal`` (text is wrapped) or ``nowrap``.
======================= =======================================
```

Expand Down
3 changes: 1 addition & 2 deletions gaphor/C4Model/diagramitems/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ def update_shapes(self, event=None):
else (
Text(
text=lambda: self.subject.description or "",
width=lambda: self.width - 8,
style={"padding": (4, 0, 0, 0), "text-align": text_align},
style={"padding": (4, 4, 0, 4), "text-align": text_align},
),
)
),
Expand Down
5 changes: 2 additions & 3 deletions gaphor/C4Model/diagramitems/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ def update_shapes(self, event=None):
),
Text(
text=lambda: self.subject.description or "",
width=lambda: self.width - 8,
style={"padding": (4, 0, 0, 0)},
style={"padding": (4, 4, 0, 4)},
),
style={"padding": (4, 4, 4, 4)},
style={"padding": (20, 4, 4, 4)},
),
style={
"text-align": TextAlign.LEFT
Expand Down
3 changes: 1 addition & 2 deletions gaphor/C4Model/diagramitems/person.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ def update_shapes(self, event=None):
),
Text(
text=lambda: self.subject.description or "",
width=lambda: self.width - 8,
style={"padding": (4, 0, 0, 0)},
style={"padding": (4, 4, 0, 4)},
),
style={"padding": (4, 4, 4, 4)},
),
Expand Down
1 change: 0 additions & 1 deletion gaphor/RAAML/fta/basicevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def update_shapes(self, event=None):
),
Text(
text=lambda: self.subject.name or "",
width=lambda: self.width - 4,
style={
"font-weight": FontWeight.BOLD,
"font-style": FontStyle.NORMAL,
Expand Down
1 change: 0 additions & 1 deletion gaphor/RAAML/fta/conditionalevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def update_shapes(self, event=None):
),
Text(
text=lambda: self.subject.name or "",
width=lambda: self.width - 4,
style={
"font-weight": FontWeight.BOLD,
"font-style": FontStyle.NORMAL,
Expand Down
1 change: 0 additions & 1 deletion gaphor/RAAML/fta/dormantevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def update_shapes(self, event=None):
),
Text(
text=lambda: self.subject.name or "",
width=lambda: self.width - 4,
style={
"font-weight": FontWeight.BOLD,
"font-style": FontStyle.NORMAL,
Expand Down
1 change: 0 additions & 1 deletion gaphor/RAAML/fta/houseevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def update_shapes(self, event=None):
),
Text(
text=lambda: self.subject.name or "",
width=lambda: self.width - 4,
style={
"font-weight": FontWeight.BOLD,
"font-style": FontStyle.NORMAL,
Expand Down
1 change: 0 additions & 1 deletion gaphor/RAAML/fta/inhibitgate.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def update_shapes(self, event=None):
),
Text(
text=lambda: self.subject.name or "",
width=lambda: self.width - 4,
style={
"font-weight": FontWeight.BOLD,
"font-style": FontStyle.NORMAL,
Expand Down
1 change: 0 additions & 1 deletion gaphor/RAAML/fta/intermediateevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def update_shapes(self, event=None):
),
Text(
text=lambda: self.subject.name or "",
width=lambda: self.width - 4,
style={
"font-weight": FontWeight.BOLD,
"font-style": FontStyle.NORMAL,
Expand Down
1 change: 0 additions & 1 deletion gaphor/RAAML/fta/majorityvotegate.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ def update_shapes(self, event=None):
),
Text(
text=lambda: self.subject.name or "",
width=lambda: self.width - 4,
style={
"font-weight": FontWeight.BOLD,
"font-style": FontStyle.NORMAL,
Expand Down
1 change: 0 additions & 1 deletion gaphor/RAAML/fta/notgate.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def update_shapes(self, event=None):
),
Text(
text=lambda: self.subject.name or "",
width=lambda: self.width - 4,
style={
"font-weight": FontWeight.BOLD,
"font-style": FontStyle.NORMAL,
Expand Down
1 change: 0 additions & 1 deletion gaphor/RAAML/fta/orgate.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ def update_shapes(self, event=None):
),
Text(
text=lambda: self.subject.name or "",
width=lambda: self.width - 4,
style={
"font-weight": FontWeight.BOLD,
"font-style": FontStyle.NORMAL,
Expand Down
1 change: 0 additions & 1 deletion gaphor/RAAML/fta/seqgate.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ def update_shapes(self, event=None):
),
Text(
text=lambda: self.subject.name or "",
width=lambda: self.width - 4,
style={
"font-weight": FontWeight.BOLD,
"font-style": FontStyle.NORMAL,
Expand Down
1 change: 0 additions & 1 deletion gaphor/RAAML/fta/topevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def update_shapes(self, event=None):
),
Text(
text=lambda: self.subject.name or "",
width=lambda: self.width - 4,
style={
"font-weight": FontWeight.BOLD,
"font-style": FontStyle.NORMAL,
Expand Down
1 change: 0 additions & 1 deletion gaphor/RAAML/fta/transferin.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def update_shapes(self, event=None):
),
Text(
text=lambda: self.subject.name or "",
width=lambda: self.width - 4,
style={
"font-weight": FontWeight.BOLD,
"font-style": FontStyle.NORMAL,
Expand Down
1 change: 0 additions & 1 deletion gaphor/RAAML/fta/transferout.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ def update_shapes(self, event=None):
),
Text(
text=lambda: self.subject.name or "",
width=lambda: self.width - 4,
style={
"font-weight": FontWeight.BOLD,
"font-style": FontStyle.NORMAL,
Expand Down
1 change: 0 additions & 1 deletion gaphor/RAAML/fta/undevelopedevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def update_shapes(self, event=None):
),
Text(
text=lambda: self.subject.name or "",
width=lambda: self.width - 4,
style={
"font-weight": FontWeight.BOLD,
"font-style": FontStyle.NORMAL,
Expand Down
1 change: 0 additions & 1 deletion gaphor/RAAML/fta/xorgate.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ def update_shapes(self, event=None):
),
Text(
text=lambda: self.subject.name or "",
width=lambda: self.width - 4,
style={
"font-weight": FontWeight.BOLD,
"font-style": FontStyle.NORMAL,
Expand Down
1 change: 0 additions & 1 deletion gaphor/RAAML/fta/zeroevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ def update_shapes(self, event=None):
),
Text(
text=lambda: self.subject.name or "",
width=lambda: self.width - 4,
style={
"font-weight": FontWeight.BOLD,
"font-style": FontStyle.NORMAL,
Expand Down
1 change: 0 additions & 1 deletion gaphor/RAAML/stpa/controlaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def update_shapes(self, event=None):
),
Text(
text=lambda: self.subject.name or "",
width=lambda: self.width - 4,
style={
"font-weight": FontWeight.BOLD,
"font-style": FontStyle.NORMAL,
Expand Down
1 change: 0 additions & 1 deletion gaphor/RAAML/stpa/operationalsituation.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def update_shapes(self, event=None):
),
Text(
text=lambda: self.subject.name or "",
width=lambda: self.width - 4,
style={
"font-weight": FontWeight.BOLD,
"font-style": FontStyle.NORMAL,
Expand Down
1 change: 0 additions & 1 deletion gaphor/RAAML/stpa/unsafecontrolaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def update_shapes(self, event=None):
),
Text(
text=lambda: self.subject.name or "",
width=lambda: self.width - 4,
style={
"font-weight": FontWeight.BOLD,
"font-style": FontStyle.NORMAL,
Expand Down
18 changes: 15 additions & 3 deletions gaphor/SysML/blocks/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
JustifyContent,
Text,
TextAlign,
WhiteSpace,
draw_border,
draw_top_separator,
)
Expand Down Expand Up @@ -73,7 +74,6 @@ def update_shapes(self, event=None):
),
Text(
text=lambda: self.subject.name or "",
width=lambda: self.width - 4,
style={
"font-weight": FontWeight.BOLD,
"font-style": FontStyle.ITALIC
Expand Down Expand Up @@ -162,7 +162,13 @@ def lazy_format(attribute):
},
),
*(
Text(text=lazy_format(attribute), style={"text-align": TextAlign.LEFT})
Text(
text=lazy_format(attribute),
style={
"text-align": TextAlign.LEFT,
"white-space": WhiteSpace.NOWRAP,
},
)
for attribute in self.subject.ownedAttribute
if predicate(attribute)
),
Expand Down Expand Up @@ -190,7 +196,13 @@ def lazy_format(operation):
},
),
*(
Text(text=lazy_format(operation), style={"text-align": TextAlign.LEFT})
Text(
text=lazy_format(operation),
style={
"text-align": TextAlign.LEFT,
"white-space": WhiteSpace.NOWRAP,
},
)
for operation in self.subject.ownedOperation
),
style={
Expand Down
1 change: 0 additions & 1 deletion gaphor/SysML/blocks/interfaceblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ def update_shapes(self, event=None):
),
Text(
text=lambda: self.subject.name or "",
width=lambda: self.width - 4,
style={
"font-weight": FontWeight.BOLD,
"font-style": FontStyle.ITALIC
Expand Down
3 changes: 2 additions & 1 deletion gaphor/SysML/blocks/property.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from gaphor.diagram.shapes import Box, Text, draw_border
from gaphor.diagram.support import represents
from gaphor.UML.classes.stereotype import stereotype_compartments
from gaphor.UML.recipes import stereotypes_str
from gaphor.UML.umlfmt import format_property


Expand Down Expand Up @@ -45,7 +46,7 @@ def update_shapes(self, event=None):
self.shape = Box(
Box(
Text(
text=lambda: UML.recipes.stereotypes_str(self.subject),
text=lambda: stereotypes_str(self.subject),
),
Text(
text=lambda: format_property(
Expand Down
2 changes: 0 additions & 2 deletions gaphor/SysML/requirements/requirement.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ def update_shapes(self, event=None):
),
Text(
text=lambda: self.subject.name or "",
width=lambda: self.width - 4,
style={
"font-weight": FontWeight.BOLD,
"font-style": FontStyle.ITALIC
Expand Down Expand Up @@ -114,7 +113,6 @@ def id_and_text_compartment(self):
[
Text(
text=lambda: f"Text: {subject.text}",
width=lambda: self.width - 8,
style={"text-align": TextAlign.LEFT},
)
]
Expand Down
3 changes: 0 additions & 3 deletions gaphor/UML/actions/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ def __init__(self, diagram, id=None):
),
Text(
text=lambda: self.subject.name or "",
width=lambda: self.width - 4,
),
style={
"padding": (4, 12, 4, 12),
Expand All @@ -45,7 +44,6 @@ def __init__(self, diagram, id=None):
),
Text(
text=lambda: self.subject.value or "",
width=lambda: self.width - 4,
),
style={
"padding": (4, 12, 4, 12),
Expand All @@ -68,7 +66,6 @@ def __init__(self, diagram, id=None):
),
Text(
text=lambda: format_call_behavior_action_name(self.subject),
width=lambda: self.width - 4,
),
style={
"padding": (4, 24, 4, 12),
Expand Down
3 changes: 1 addition & 2 deletions gaphor/UML/actions/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,8 @@ def __init__(self, diagram, id=None):
shape=Box(
Text(
text=lambda: self.subject.parameter.name or "",
width=120,
),
style={"padding": (4, 12, 4, 12)},
style={"padding": (4, 12, 4, 12), "min-width": 120},
draw=draw_border,
),
)
Expand Down
3 changes: 2 additions & 1 deletion gaphor/UML/classes/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from gaphor.diagram.shapes import Box, Text, cairo_state, draw_border
from gaphor.diagram.support import represents
from gaphor.UML.classes.stereotype import stereotype_compartments
from gaphor.UML.recipes import stereotypes_str


@represents(UML.Component)
Expand All @@ -30,7 +31,7 @@ def update_shapes(self, event=None):
self.shape = Box(
Box(
Text(
text=lambda: UML.recipes.stereotypes_str(self.subject),
text=lambda: stereotypes_str(self.subject),
),
Text(
text=lambda: self.subject.name or "",
Expand Down
3 changes: 2 additions & 1 deletion gaphor/UML/classes/datatype.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
operations_compartment,
)
from gaphor.UML.classes.stereotype import stereotype_compartments, stereotype_watches
from gaphor.UML.recipes import stereotypes_str

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -64,7 +65,7 @@ def update_shapes(self, event=None):
self.shape = Box(
Box(
Text(
text=lambda: UML.recipes.stereotypes_str(
text=lambda: stereotypes_str(
self.subject, self.additional_stereotypes()
),
),
Expand Down
3 changes: 2 additions & 1 deletion gaphor/UML/classes/enumeration.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
operations_compartment,
)
from gaphor.UML.classes.stereotype import stereotype_compartments, stereotype_watches
from gaphor.UML.recipes import stereotypes_str

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -63,7 +64,7 @@ def update_shapes(self, event=None):
self.shape = Box(
Box(
Text(
text=lambda: UML.recipes.stereotypes_str(
text=lambda: stereotypes_str(
self.subject,
[
self.diagram.gettext("valueType")
Expand Down
5 changes: 3 additions & 2 deletions gaphor/UML/classes/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
operations_compartment,
)
from gaphor.UML.classes.stereotype import stereotype_compartments
from gaphor.UML.recipes import stereotypes_str


class Folded(Enum):
Expand Down Expand Up @@ -278,7 +279,7 @@ def class_shape(self):
return Box(
Box(
Text(
text=lambda: UML.recipes.stereotypes_str(
text=lambda: stereotypes_str(
self.subject, (self.diagram.gettext("interface"),)
),
),
Expand Down Expand Up @@ -325,7 +326,7 @@ def ball_and_socket_shape(self, connectors=None):
draw=self.draw_interface_ball_and_socket,
),
Text(
text=lambda: UML.recipes.stereotypes_str(self.subject),
text=lambda: stereotypes_str(self.subject),
),
Text(
text=lambda: self.subject.name or "",
Expand Down
Loading