From 83b10aa5c64b66b2cfc100022d97e02e6411afd2 Mon Sep 17 00:00:00 2001 From: Dietrich Travkin Date: Wed, 8 May 2024 00:18:11 +0200 Subject: [PATCH] Fix #1768 Also consider "hide stereotype" statement (without given stereotype name) --- src/net/atmp/CucaDiagram.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/net/atmp/CucaDiagram.java b/src/net/atmp/CucaDiagram.java index c91cc88d63a..e6c89daaf1d 100644 --- a/src/net/atmp/CucaDiagram.java +++ b/src/net/atmp/CucaDiagram.java @@ -533,6 +533,7 @@ public List getVisibleStereotypeLabels(Entity entity) { return null; } + // collect hide or show statements on stereotypes List commands = new ArrayList<>(); for (EntityHideOrShow hideOrShowEntry : hideOrShows) { if (hideOrShowEntry.portion == EntityPortion.STEREOTYPE) { @@ -542,7 +543,7 @@ public List getVisibleStereotypeLabels(Entity entity) { List visibleStereotypeLabels = new ArrayList<>(); for (String stereoTypeLabel : entity.getStereotype().getLabels(Guillemet.DOUBLE_COMPARATOR)) { - if (isHiddenStereotypeLabel(stereoTypeLabel, commands)) { + if (!isHiddenStereotypeLabel(stereoTypeLabel, commands)) { visibleStereotypeLabels.add(stereoTypeLabel); } } @@ -552,12 +553,16 @@ public List getVisibleStereotypeLabels(Entity entity) { private boolean isHiddenStereotypeLabel(String stereoTypeLabel, List commands) { for (EntityHideOrShow cmd : commands) { + // gender is here the stereotype name given in the hide or show command String gender = cmd.gender.getGender(); if (gender != null && gender.equals(stereoTypeLabel)) { - return false; + return !cmd.show; + } else if (gender == null) { + // we have a hide or show command without a stereotype name => hide or show all stereotypes + return !cmd.show; } } - return true; + return false; } public final void hideOrShow(EntityGender gender, EntityPortion portions, boolean show) {