mirror of
https://github.com/enzet/map-machine.git
synced 2025-06-06 04:41:54 +02:00
Fix label mode argument.
This commit is contained in:
parent
b086b0d108
commit
b0de6754c1
4 changed files with 36 additions and 15 deletions
|
@ -154,19 +154,31 @@ class Point(Tagged):
|
|||
return True
|
||||
|
||||
def draw_texts(
|
||||
self, svg: svgwrite.Drawing, occupied: Optional[Occupied] = None
|
||||
self,
|
||||
svg: svgwrite.Drawing,
|
||||
occupied: Optional[Occupied] = None,
|
||||
label_mode: str = "main",
|
||||
) -> None:
|
||||
"""
|
||||
Draw all labels.
|
||||
"""
|
||||
for text_struct in self.labels: # type: Label
|
||||
text = text_struct.text
|
||||
labels: List[Label]
|
||||
|
||||
if label_mode == "main":
|
||||
labels = self.labels[:1]
|
||||
elif label_mode == "all":
|
||||
labels = self.labels
|
||||
else:
|
||||
return
|
||||
|
||||
for label in labels:
|
||||
text = label.text
|
||||
text = text.replace(""", '"')
|
||||
text = text.replace("&", '&')
|
||||
text = text[:26] + ("..." if len(text) > 26 else "")
|
||||
self.draw_text(
|
||||
svg, text, self.point + np.array((0, self.y)),
|
||||
occupied, text_struct.fill, size=text_struct.size
|
||||
occupied, label.fill, size=label.size
|
||||
)
|
||||
|
||||
def draw_text(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue