mirror of
https://github.com/octoleo/plantuml.git
synced 2024-12-22 02:49:06 +00:00
#1580 Fix hiding stereotypes
This commit is contained in:
parent
f8d87217a7
commit
f47ca8c339
@ -46,6 +46,7 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.sourceforge.plantuml.FileFormat;
|
||||
import net.sourceforge.plantuml.FileFormatOption;
|
||||
@ -84,10 +85,12 @@ import net.sourceforge.plantuml.security.SecurityUtils;
|
||||
import net.sourceforge.plantuml.skin.UmlDiagramType;
|
||||
import net.sourceforge.plantuml.skin.VisibilityModifier;
|
||||
import net.sourceforge.plantuml.statediagram.StateDiagram;
|
||||
import net.sourceforge.plantuml.stereo.Stereotype;
|
||||
import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft;
|
||||
import net.sourceforge.plantuml.svek.CucaDiagramFileMaker;
|
||||
import net.sourceforge.plantuml.svek.CucaDiagramFileMakerSvek;
|
||||
import net.sourceforge.plantuml.text.BackSlash;
|
||||
import net.sourceforge.plantuml.text.Guillemet;
|
||||
import net.sourceforge.plantuml.xmi.CucaDiagramXmiMaker;
|
||||
import net.sourceforge.plantuml.xmlsc.StateDiagramScxmlMaker;
|
||||
|
||||
@ -523,6 +526,35 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getVisibleStereotypeLabels(Entity entity) {
|
||||
Stereotype stereotype = entity.getStereotype();
|
||||
|
||||
if (stereotype == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<EntityHideOrShow> commands = hideOrShows.stream()
|
||||
.filter(cmd -> cmd.portion == EntityPortion.STEREOTYPE)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return entity.getStereotype()
|
||||
.getLabels(Guillemet.DOUBLE_COMPARATOR)
|
||||
.stream()
|
||||
.filter(stereoTypeLabel -> isHiddenStereotypeLabel(stereoTypeLabel, commands))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private boolean isHiddenStereotypeLabel(String stereoTypeLabel, List<EntityHideOrShow> commands) {
|
||||
for (EntityHideOrShow cmd : commands) {
|
||||
String gender = cmd.gender.getGender();
|
||||
if (gender != null && gender.equals(stereoTypeLabel)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public final void hideOrShow(EntityGender gender, EntityPortion portions, boolean show) {
|
||||
for (EntityPortion portion : portions.asSet())
|
||||
this.hideOrShows.add(new EntityHideOrShow(gender, portion, show));
|
||||
|
@ -37,4 +37,6 @@ package net.sourceforge.plantuml.abel;
|
||||
|
||||
public interface EntityGender {
|
||||
public boolean contains(Entity test);
|
||||
|
||||
public String getGender();
|
||||
}
|
||||
|
@ -44,6 +44,11 @@ public class EntityGenderUtils {
|
||||
public boolean contains(Entity test) {
|
||||
return test.getLeafType() == type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGender() {
|
||||
return type.name();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -52,6 +57,11 @@ public class EntityGenderUtils {
|
||||
public boolean contains(Entity test) {
|
||||
return test.getUid().equals(entity.getUid());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGender() {
|
||||
return entity.getUid();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -61,7 +71,12 @@ public class EntityGenderUtils {
|
||||
if (test.getStereotype() == null) {
|
||||
return false;
|
||||
}
|
||||
return stereotype.equals(test.getStereotype().getLabel(Guillemet.DOUBLE_COMPARATOR));
|
||||
return test.getStereotype().getLabels(Guillemet.DOUBLE_COMPARATOR).stream().anyMatch(stereotype::equals);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGender() {
|
||||
return stereotype;
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -80,6 +95,11 @@ public class EntityGenderUtils {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGender() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -88,6 +108,11 @@ public class EntityGenderUtils {
|
||||
public boolean contains(Entity test) {
|
||||
return g1.contains(test) && g2.contains(test);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGender() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -96,6 +121,11 @@ public class EntityGenderUtils {
|
||||
public boolean contains(Entity test) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGender() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -104,6 +134,11 @@ public class EntityGenderUtils {
|
||||
public boolean contains(Entity test) {
|
||||
return test.getBodier().getMethodsToDisplay().size() == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGender() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -112,6 +147,12 @@ public class EntityGenderUtils {
|
||||
public boolean contains(Entity test) {
|
||||
return test.getBodier().getFieldsToDisplay().size() == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGender() {
|
||||
return null;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,11 @@ package net.sourceforge.plantuml.cucadiagram;
|
||||
import net.sourceforge.plantuml.abel.Entity;
|
||||
import net.sourceforge.plantuml.abel.EntityPortion;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface PortionShower {
|
||||
|
||||
boolean showPortion(EntityPortion portion, Entity entity);
|
||||
|
||||
List<String> getVisibleStereotypeLabels(Entity entity);
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ package net.sourceforge.plantuml.dot;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@ -101,6 +102,11 @@ final public class DotData implements PortionShower {
|
||||
public boolean showPortion(EntityPortion portion, Entity entity) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<String> getVisibleStereotypeLabels(Entity entity) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
}, entityFactory, isHideEmptyDescriptionForState, dotMode, namespaceSeparator, pragma);
|
||||
}
|
||||
|
||||
@ -136,6 +142,10 @@ final public class DotData implements PortionShower {
|
||||
return portionShower.showPortion(portion, entity);
|
||||
}
|
||||
|
||||
public List<String> getVisibleStereotypeLabels(Entity entity) {
|
||||
return portionShower.getVisibleStereotypeLabels(entity);
|
||||
}
|
||||
|
||||
public Entity getRootGroup() {
|
||||
return entityFactory.getRootGroup();
|
||||
}
|
||||
|
@ -68,6 +68,8 @@ import net.sourceforge.plantuml.svek.HeaderLayout;
|
||||
import net.sourceforge.plantuml.svek.ShapeType;
|
||||
import net.sourceforge.plantuml.text.Guillemet;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class EntityImageClassHeader extends AbstractEntityImage {
|
||||
|
||||
final private HeaderLayout headerLayout;
|
||||
@ -112,11 +114,12 @@ public class EntityImageClassHeader extends AbstractEntityImage {
|
||||
}
|
||||
|
||||
final TextBlock stereo;
|
||||
List<String> stereotypeLabels = portionShower.getVisibleStereotypeLabels(entity);
|
||||
if (stereotype == null || stereotype.getLabel(Guillemet.DOUBLE_COMPARATOR) == null
|
||||
|| portionShower.showPortion(EntityPortion.STEREOTYPE, entity) == false)
|
||||
|| stereotypeLabels.isEmpty())
|
||||
stereo = null;
|
||||
else
|
||||
stereo = TextBlockUtils.withMargin(Display.create(stereotype.getLabels(skinParam.guillemet())).create(
|
||||
stereo = TextBlockUtils.withMargin(Display.create(stereotypeLabels).create(
|
||||
FontConfiguration.create(getSkinParam(), FontParam.CLASS_STEREOTYPE, stereotype),
|
||||
HorizontalAlignment.CENTER, skinParam), 1, 0);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user