diff --git a/src/net/sourceforge/plantuml/cheneer/command/CommandCreateAttribute.java b/src/net/sourceforge/plantuml/cheneer/command/CommandCreateAttribute.java index e7a98e8a1..af29e951e 100644 --- a/src/net/sourceforge/plantuml/cheneer/command/CommandCreateAttribute.java +++ b/src/net/sourceforge/plantuml/cheneer/command/CommandCreateAttribute.java @@ -50,8 +50,8 @@ import net.sourceforge.plantuml.plasma.Quark; import net.sourceforge.plantuml.regex.IRegex; import net.sourceforge.plantuml.regex.RegexConcat; import net.sourceforge.plantuml.regex.RegexLeaf; -import net.sourceforge.plantuml.regex.RegexOptional; import net.sourceforge.plantuml.regex.RegexResult; +import net.sourceforge.plantuml.stereo.Stereotype; import net.sourceforge.plantuml.utils.LineLocation; public class CommandCreateAttribute extends SingleLineCommand2 { @@ -63,15 +63,11 @@ public class CommandCreateAttribute extends SingleLineCommand2 { private static IRegex getRegexConcat() { return RegexConcat.build(CommandCreateEntity.class.getName(), RegexLeaf.start(), // RegexLeaf.spaceZeroOrMore(), - new RegexLeaf("NAME", "([^<>{}-]+)"), // - new RegexOptional(// - new RegexConcat( - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREOTYPE", "(<<.+>>)"))), // - new RegexOptional(// - new RegexConcat( // - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("COMPOSITE", "(\\{)"))), // + new RegexLeaf("NAME", "([^<>{}=-]+)"), // + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("STEREO", "(<<.*>>)?"), // + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("COMPOSITE", "(\\{)?"), // RegexLeaf.end()); } @@ -86,10 +82,9 @@ public class CommandCreateAttribute extends SingleLineCommand2 { final LeafType type = LeafType.CHEN_ATTRIBUTE; final String name = diagram.cleanId(arg.get("NAME", 0).trim()); final String id = owner.getName() + "/" + name; + final String stereo = arg.get("STEREO", 0); final boolean composite = arg.get("COMPOSITE", 0) != null; - // TODO: stereotypes: multi, derived, key, partial key - final Quark quark = diagram.quarkInContext(true, id); Entity entity = quark.getData(); @@ -100,6 +95,11 @@ public class CommandCreateAttribute extends SingleLineCommand2 { return CommandExecutionResult.error("Attribute already exists"); } + if (stereo != null) { + entity.setStereotype(Stereotype.build(stereo)); + entity.setStereostyle(stereo); + } + final LinkType linkType = new LinkType(LinkDecor.NONE, LinkDecor.NONE); final Link link = new Link(diagram.getEntityFactory(), diagram.getCurrentStyleBuilder(), entity, owner, linkType, LinkArg.build(Display.NULL, 2)); diff --git a/src/net/sourceforge/plantuml/cheneer/command/CommandCreateEntity.java b/src/net/sourceforge/plantuml/cheneer/command/CommandCreateEntity.java index ceb5e7c38..3fbb090d1 100644 --- a/src/net/sourceforge/plantuml/cheneer/command/CommandCreateEntity.java +++ b/src/net/sourceforge/plantuml/cheneer/command/CommandCreateEntity.java @@ -46,8 +46,8 @@ import net.sourceforge.plantuml.plasma.Quark; import net.sourceforge.plantuml.regex.IRegex; import net.sourceforge.plantuml.regex.RegexConcat; import net.sourceforge.plantuml.regex.RegexLeaf; -import net.sourceforge.plantuml.regex.RegexOptional; import net.sourceforge.plantuml.regex.RegexResult; +import net.sourceforge.plantuml.stereo.Stereotype; import net.sourceforge.plantuml.utils.LineLocation; public class CommandCreateEntity extends SingleLineCommand2 { @@ -61,10 +61,8 @@ public class CommandCreateEntity extends SingleLineCommand2 { new RegexLeaf("TYPE", "(entity|relationship)"), // RegexLeaf.spaceOneOrMore(), // new RegexLeaf("NAME", "([^<>{}]+)"), // - new RegexOptional(// - new RegexConcat( - RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("STEREOTYPE", "(<<.+>>)"))), // + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("STEREO", "(<<.+>>)?"), // RegexLeaf.spaceZeroOrMore(), // new RegexLeaf("\\{"), // RegexLeaf.end()); @@ -75,17 +73,18 @@ public class CommandCreateEntity extends SingleLineCommand2 { throws NoSuchColorException { LeafType type; switch (arg.get("TYPE", 0)) { - case "entity": - type = LeafType.CHEN_ENTITY; - break; - case "relationship": - type = LeafType.CHEN_RELATIONSHIP; - break; - default: - throw new IllegalStateException(); + case "entity": + type = LeafType.CHEN_ENTITY; + break; + case "relationship": + type = LeafType.CHEN_RELATIONSHIP; + break; + default: + throw new IllegalStateException(); } final String name = diagram.cleanId(arg.get("NAME", 0).trim()); + final String stereo = arg.get("STEREO", 0); final Quark quark = diagram.quarkInContext(true, name); Entity entity = quark.getData(); @@ -98,6 +97,11 @@ public class CommandCreateEntity extends SingleLineCommand2 { return CommandExecutionResult.error("Bad name"); } + if (stereo != null) { + entity.setStereotype(Stereotype.build(stereo)); + entity.setStereostyle(stereo); + } + diagram.pushOwner(entity); return CommandExecutionResult.ok(); diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageChenAttribute.java b/src/net/sourceforge/plantuml/svek/image/EntityImageChenAttribute.java index 609377531..b69ba154b 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageChenAttribute.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageChenAttribute.java @@ -67,14 +67,25 @@ public class EntityImageChenAttribute extends AbstractEntityImage { final static private int MARGIN = 6; + final private boolean isKey; + final private boolean isMulti; + final private boolean isDerived; + final private TextBlock title; final private Url url; public EntityImageChenAttribute(Entity entity, ISkinParam skinParam) { super(entity, skinParam); - final FontConfiguration titleFontConfiguration = getStyleTitle(entity, skinParam) + isKey = hasStereotype("<>"); + isMulti = hasStereotype("<>"); + isDerived = hasStereotype("<>"); + + FontConfiguration titleFontConfiguration = getStyleTitle(entity, skinParam) .getFontConfiguration(getSkinParam().getIHtmlColorSet(), entity.getColors()); + if (isKey) { + titleFontConfiguration = titleFontConfiguration.underline(); + } title = entity.getDisplay().create8(titleFontConfiguration, HorizontalAlignment.CENTER, skinParam, CreoleMode.FULL, getStyle().wrapWidth()); @@ -82,6 +93,10 @@ public class EntityImageChenAttribute extends AbstractEntityImage { url = entity.getUrl99(); } + private boolean hasStereotype(String stereotype) { + return getEntity().getStereotype() != null && getEntity().getStereotype().toString().contains(stereotype); + } + private Style getStyle() { return getStyle(getEntity(), getSkinParam()); } @@ -117,10 +132,17 @@ public class EntityImageChenAttribute extends AbstractEntityImage { final XDimension2D dimTotal = calculateDimension(ug.getStringBounder()); final XDimension2D dimTitle = title.calculateDimension(ug.getStringBounder()); - final UStroke stroke = getStyle().getStroke(getEntity().getColors()); + UStroke stroke = getStyle().getStroke(getEntity().getColors()); + if (isDerived) { + stroke = new UStroke(10, 10, stroke.getThickness()); + } + ug = applyColor(ug); ug = ug.apply(stroke); ug.draw(getShape(dimTotal)); + if (isMulti) { + ug.apply(new UTranslate(3, 3)).draw(getShape(dimTotal.delta(-6))); + } final double xTitle = (dimTotal.getWidth() - dimTitle.getWidth()) / 2; final double yTitle = MARGIN; diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageChenEntity.java b/src/net/sourceforge/plantuml/svek/image/EntityImageChenEntity.java index 766b6fbab..a86b97676 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageChenEntity.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageChenEntity.java @@ -63,12 +63,16 @@ import net.sourceforge.plantuml.url.Url; public class EntityImageChenEntity extends AbstractEntityImage { + final private boolean isWeak; + final private TextBlock title; final private Url url; public EntityImageChenEntity(Entity entity, ISkinParam skinParam) { super(entity, skinParam); + isWeak = hasStereotype("<>"); + final FontConfiguration titleFontConfiguration = getStyleStateTitle(entity, skinParam) .getFontConfiguration(getSkinParam().getIHtmlColorSet(), entity.getColors()); @@ -78,6 +82,10 @@ public class EntityImageChenEntity extends AbstractEntityImage { url = entity.getUrl99(); } + private boolean hasStereotype(String stereotype) { + return getEntity().getStereotype() != null && getEntity().getStereotype().toString().contains(stereotype); + } + private Style getStyleState() { return getStyleState(getEntity(), getSkinParam()); } @@ -117,6 +125,9 @@ public class EntityImageChenEntity extends AbstractEntityImage { ug = applyColor(ug); ug = ug.apply(stroke); ug.draw(getShape(dimTotal)); + if (isWeak) { + ug.apply(new UTranslate(3, 3)).draw(getShape(dimTotal.delta(-6))); + } final double xTitle = (dimTotal.getWidth() - dimTitle.getWidth()) / 2; final double yTitle = MARGIN + MARGIN_LINE; diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageChenRelationship.java b/src/net/sourceforge/plantuml/svek/image/EntityImageChenRelationship.java index 6b72bb2b5..8bf58c962 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageChenRelationship.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageChenRelationship.java @@ -54,7 +54,6 @@ import net.sourceforge.plantuml.klimt.geom.HorizontalAlignment; import net.sourceforge.plantuml.klimt.geom.XDimension2D; import net.sourceforge.plantuml.klimt.geom.XPoint2D; import net.sourceforge.plantuml.klimt.shape.TextBlock; -import net.sourceforge.plantuml.klimt.shape.TextBlockInEllipse; import net.sourceforge.plantuml.klimt.shape.UPolygon; import net.sourceforge.plantuml.style.ISkinParam; import net.sourceforge.plantuml.style.PName; @@ -67,12 +66,16 @@ import net.sourceforge.plantuml.url.Url; public class EntityImageChenRelationship extends AbstractEntityImage { + final private boolean isIdentifying; + final private TextBlock title; final private Url url; public EntityImageChenRelationship(Entity entity, ISkinParam skinParam) { super(entity, skinParam); + isIdentifying = hasStereotype("<>"); + final FontConfiguration titleFontConfiguration = getStyleTitle(entity, skinParam) .getFontConfiguration(getSkinParam().getIHtmlColorSet(), entity.getColors()); @@ -82,6 +85,10 @@ public class EntityImageChenRelationship extends AbstractEntityImage { url = entity.getUrl99(); } + private boolean hasStereotype(String stereotype) { + return getEntity().getStereotype() != null && getEntity().getStereotype().toString().contains(stereotype); + } + private Style getStyle() { return getStyle(getEntity(), getSkinParam()); } @@ -126,6 +133,9 @@ public class EntityImageChenRelationship extends AbstractEntityImage { ug = applyColor(ug); ug = ug.apply(stroke); ug.draw(getShape(dimTotal)); + if (isIdentifying) { + ug.apply(new UTranslate(10, 5)).draw(getShape(dimTotal.delta(-20, -10))); + } final double xTitle = (dimTotal.getWidth() - dimTitle.getWidth()) / 2; final double yTitle = (dimTotal.getHeight() - dimTitle.getHeight()) / 2;