1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-11-25 22:37:33 +00:00

add support for Protocol and Struct in class diagram

This commit is contained in:
Bob Jacobsen 2022-06-02 14:50:03 -04:00
parent a5952259b7
commit 2b337ac940
7 changed files with 47 additions and 30 deletions

View File

@ -5,12 +5,12 @@
* (C) Copyright 2009-2023, Arnaud Roques * (C) Copyright 2009-2023, Arnaud Roques
* *
* Project Info: http://plantuml.com * Project Info: http://plantuml.com
* *
* If you like this project or if you find it useful, you can support us at: * If you like this project or if you find it useful, you can support us at:
* *
* http://plantuml.com/patreon (only 1$ per month!) * http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal * http://plantuml.com/paypal
* *
* This file is part of PlantUML. * This file is part of PlantUML.
* *
* PlantUML is free software; you can redistribute it and/or modify it * PlantUML is free software; you can redistribute it and/or modify it
@ -80,7 +80,7 @@ public class CommandCreateClass extends SingleLineCommand2<ClassDiagram> {
private static IRegex getRegexConcat() { private static IRegex getRegexConcat() {
return RegexConcat.build(CommandCreateClass.class.getName(), RegexLeaf.start(), // return RegexConcat.build(CommandCreateClass.class.getName(), RegexLeaf.start(), //
new RegexLeaf("TYPE", // new RegexLeaf("TYPE", //
"(interface|enum|annotation|abstract[%s]+class|abstract|class|entity|circle|diamond)"), // "(interface|enum|annotation|abstract[%s]+class|abstract|class|entity|circle|diamond|protocol|struct)"), //
RegexLeaf.spaceOneOrMore(), // RegexLeaf.spaceOneOrMore(), //
new RegexOr(// new RegexOr(//
new RegexConcat(// new RegexConcat(//

View File

@ -5,12 +5,12 @@
* (C) Copyright 2009-2023, Arnaud Roques * (C) Copyright 2009-2023, Arnaud Roques
* *
* Project Info: http://plantuml.com * Project Info: http://plantuml.com
* *
* If you like this project or if you find it useful, you can support us at: * If you like this project or if you find it useful, you can support us at:
* *
* http://plantuml.com/patreon (only 1$ per month!) * http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal * http://plantuml.com/paypal
* *
* This file is part of PlantUML. * This file is part of PlantUML.
* *
* PlantUML is free software; you can redistribute it and/or modify it * PlantUML is free software; you can redistribute it and/or modify it
@ -92,7 +92,7 @@ public class CommandCreateClassMultilines extends CommandMultilines2<ClassDiagra
private static IRegex getRegexConcat() { private static IRegex getRegexConcat() {
return RegexConcat.build(CommandCreateClassMultilines.class.getName(), RegexLeaf.start(), // return RegexConcat.build(CommandCreateClassMultilines.class.getName(), RegexLeaf.start(), //
new RegexLeaf("VISIBILITY", "(" + VisibilityModifier.regexForVisibilityCharacterInClassName() + ")?"), // new RegexLeaf("VISIBILITY", "(" + VisibilityModifier.regexForVisibilityCharacterInClassName() + ")?"), //
new RegexLeaf("TYPE", "(interface|enum|annotation|abstract[%s]+class|abstract|class|entity)"), // new RegexLeaf("TYPE", "(interface|enum|annotation|abstract[%s]+class|abstract|class|entity|protocol|struct)"), //
RegexLeaf.spaceOneOrMore(), // RegexLeaf.spaceOneOrMore(), //
new RegexOr(// new RegexOr(//
new RegexConcat(// new RegexConcat(//

View File

@ -5,12 +5,12 @@
* (C) Copyright 2009-2023, Arnaud Roques * (C) Copyright 2009-2023, Arnaud Roques
* *
* Project Info: http://plantuml.com * Project Info: http://plantuml.com
* *
* If you like this project or if you find it useful, you can support us at: * If you like this project or if you find it useful, you can support us at:
* *
* http://plantuml.com/patreon (only 1$ per month!) * http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal * http://plantuml.com/paypal
* *
* This file is part of PlantUML. * This file is part of PlantUML.
* *
* PlantUML is free software; you can redistribute it and/or modify it * PlantUML is free software; you can redistribute it and/or modify it
@ -163,6 +163,10 @@ public class CommandHideShowByGender extends SingleLineCommand2<UmlDiagram> {
gender = EntityGenderUtils.byEntityType(LeafType.ABSTRACT_CLASS); gender = EntityGenderUtils.byEntityType(LeafType.ABSTRACT_CLASS);
} else if (arg1.equalsIgnoreCase("annotation")) { } else if (arg1.equalsIgnoreCase("annotation")) {
gender = EntityGenderUtils.byEntityType(LeafType.ANNOTATION); gender = EntityGenderUtils.byEntityType(LeafType.ANNOTATION);
} else if (arg1.equalsIgnoreCase("protocol")) {
gender = EntityGenderUtils.byEntityType(LeafType.PROTOCOL);
} else if (arg1.equalsIgnoreCase("struct")) {
gender = EntityGenderUtils.byEntityType(LeafType.STRUCT);
} else if (arg1.startsWith("<<")) { } else if (arg1.startsWith("<<")) {
gender = EntityGenderUtils.byStereotype(arg1); gender = EntityGenderUtils.byStereotype(arg1);
} else { } else {

View File

@ -5,12 +5,12 @@
* (C) Copyright 2009-2023, Arnaud Roques * (C) Copyright 2009-2023, Arnaud Roques
* *
* Project Info: http://plantuml.com * Project Info: http://plantuml.com
* *
* If you like this project or if you find it useful, you can support us at: * If you like this project or if you find it useful, you can support us at:
* *
* http://plantuml.com/patreon (only 1$ per month!) * http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal * http://plantuml.com/paypal
* *
* This file is part of PlantUML. * This file is part of PlantUML.
* *
* PlantUML is free software; you can redistribute it and/or modify it * PlantUML is free software; you can redistribute it and/or modify it
@ -95,7 +95,7 @@ final public class CommandLinkLollipop extends SingleLineCommand2<AbstractClassO
private static String optionalKeywords(UmlDiagramType type) { private static String optionalKeywords(UmlDiagramType type) {
if (type == UmlDiagramType.CLASS) { if (type == UmlDiagramType.CLASS) {
return "(interface|enum|annotation|abstract[%s]+class|abstract|class|entity)"; return "(interface|enum|annotation|abstract[%s]+class|abstract|class|entity|protocol|struct)";
} }
if (type == UmlDiagramType.OBJECT) { if (type == UmlDiagramType.OBJECT) {
return "(object)"; return "(object)";

View File

@ -5,12 +5,12 @@
* (C) Copyright 2009-2023, Arnaud Roques * (C) Copyright 2009-2023, Arnaud Roques
* *
* Project Info: http://plantuml.com * Project Info: http://plantuml.com
* *
* If you like this project or if you find it useful, you can support us at: * If you like this project or if you find it useful, you can support us at:
* *
* http://plantuml.com/patreon (only 1$ per month!) * http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal * http://plantuml.com/paypal
* *
* This file is part of PlantUML. * This file is part of PlantUML.
* *
* PlantUML is free software; you can redistribute it and/or modify it * PlantUML is free software; you can redistribute it and/or modify it
@ -42,7 +42,9 @@ public enum LeafType {
EMPTY_PACKAGE, EMPTY_PACKAGE,
ABSTRACT_CLASS, CLASS, INTERFACE, ANNOTATION, LOLLIPOP_FULL, LOLLIPOP_HALF, NOTE, TIPS, OBJECT, MAP, JSON, ASSOCIATION, ABSTRACT_CLASS, CLASS, INTERFACE, ANNOTATION,
PROTOCOL, STRUCT,
LOLLIPOP_FULL, LOLLIPOP_HALF, NOTE, TIPS, OBJECT, MAP, JSON, ASSOCIATION,
ENUM, CIRCLE, ENUM, CIRCLE,
USECASE, USECASE_BUSINESS, USECASE, USECASE_BUSINESS,
@ -76,7 +78,8 @@ public enum LeafType {
public boolean isLikeClass() { public boolean isLikeClass() {
return this == LeafType.ANNOTATION || this == LeafType.ABSTRACT_CLASS || this == LeafType.CLASS return this == LeafType.ANNOTATION || this == LeafType.ABSTRACT_CLASS || this == LeafType.CLASS
|| this == LeafType.INTERFACE || this == LeafType.ENUM || this == LeafType.ENTITY; || this == LeafType.INTERFACE || this == LeafType.ENUM || this == LeafType.ENTITY
|| this == LeafType.PROTOCOL || this == LeafType.STRUCT;
} }
public String toHtml() { public String toHtml() {

View File

@ -5,12 +5,12 @@
* (C) Copyright 2009-2023, Arnaud Roques * (C) Copyright 2009-2023, Arnaud Roques
* *
* Project Info: http://plantuml.com * Project Info: http://plantuml.com
* *
* If you like this project or if you find it useful, you can support us at: * If you like this project or if you find it useful, you can support us at:
* *
* http://plantuml.com/patreon (only 1$ per month!) * http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal * http://plantuml.com/paypal
* *
* This file is part of PlantUML. * This file is part of PlantUML.
* *
* PlantUML is free software; you can redistribute it and/or modify it * PlantUML is free software; you can redistribute it and/or modify it
@ -129,7 +129,7 @@ public enum SName {
undone, // undone, //
unstarted, // unstarted, //
usecase, // usecase, //
visibilityIcon, // visibilityIcon, //
private_, // private_, //
protected_, // protected_, //
@ -139,14 +139,16 @@ public enum SName {
spotAnnotation, // spotAnnotation, //
spotInterface, // spotInterface, //
spotEnum, // spotEnum, //
spotProtocol, //
spotStruct, //
spotEntity, // spotEntity, //
spotClass, // spotClass, //
spotAbstractClass, // spotAbstractClass, //
wbsDiagram, // wbsDiagram, //
yamlDiagram; // yamlDiagram; //
public static String depth(int level) { public static String depth(int level) {
return "depth(" + level + ")"; return "depth(" + level + ")";
} }
} }

View File

@ -5,12 +5,12 @@
* (C) Copyright 2009-2023, Arnaud Roques * (C) Copyright 2009-2023, Arnaud Roques
* *
* Project Info: http://plantuml.com * Project Info: http://plantuml.com
* *
* If you like this project or if you find it useful, you can support us at: * If you like this project or if you find it useful, you can support us at:
* *
* http://plantuml.com/patreon (only 1$ per month!) * http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal * http://plantuml.com/paypal
* *
* This file is part of PlantUML. * This file is part of PlantUML.
* *
* PlantUML is free software; you can redistribute it and/or modify it * PlantUML is free software; you can redistribute it and/or modify it
@ -30,7 +30,7 @@
* *
* *
* Original Author: Arnaud Roques * Original Author: Arnaud Roques
* *
* *
*/ */
package net.sourceforge.plantuml.svek.image; package net.sourceforge.plantuml.svek.image;
@ -194,6 +194,10 @@ public class EntityImageClassHeader extends AbstractEntityImage {
return StyleSignatureBasic.of(SName.root, SName.element, SName.spot, SName.spotEnum); return StyleSignatureBasic.of(SName.root, SName.element, SName.spot, SName.spotEnum);
case ENTITY: case ENTITY:
return StyleSignatureBasic.of(SName.root, SName.element, SName.spot, SName.spotEntity); return StyleSignatureBasic.of(SName.root, SName.element, SName.spot, SName.spotEntity);
case PROTOCOL:
return StyleSignatureBasic.of(SName.root, SName.element, SName.spot, SName.spotProtocol);
case STRUCT:
return StyleSignatureBasic.of(SName.root, SName.element, SName.spot, SName.spotStruct);
} }
throw new IllegalStateException(); throw new IllegalStateException();
} }
@ -212,6 +216,10 @@ public class EntityImageClassHeader extends AbstractEntityImage {
return 'E'; return 'E';
case ENTITY: case ENTITY:
return 'E'; return 'E';
case PROTOCOL:
return 'P';
case STRUCT:
return 'S';
} }
assert false; assert false;
return '?'; return '?';