mirror of
https://github.com/octoleo/plantuml.git
synced 2024-11-26 06:46:45 +00:00
Stereotype refactoring
This commit is contained in:
parent
c874842158
commit
637adfa6cb
@ -129,7 +129,7 @@ public class CommandLinkActivity extends SingleLineCommand2<ActivityDiagram> {
|
||||
return CommandExecutionResult.error("No such activity");
|
||||
}
|
||||
if (arg.get("STEREOTYPE", 0) != null) {
|
||||
entity1.setStereotype(new Stereotype(arg.get("STEREOTYPE", 0)));
|
||||
entity1.setStereotype(Stereotype.build(arg.get("STEREOTYPE", 0)));
|
||||
}
|
||||
if (arg.get("BACKCOLOR", 0) != null) {
|
||||
String s = arg.get("BACKCOLOR", 0);
|
||||
@ -147,7 +147,7 @@ public class CommandLinkActivity extends SingleLineCommand2<ActivityDiagram> {
|
||||
diagram.getSkinParam().getIHtmlColorSet().getColor(diagram.getSkinParam().getThemeStyle(), s));
|
||||
}
|
||||
if (arg.get("STEREOTYPE2", 0) != null) {
|
||||
entity2.setStereotype(new Stereotype(arg.get("STEREOTYPE2", 0)));
|
||||
entity2.setStereotype(Stereotype.build(arg.get("STEREOTYPE2", 0)));
|
||||
}
|
||||
|
||||
final Display linkLabel = Display.getWithNewlines(arg.get("BRACKET", 0));
|
||||
|
@ -126,7 +126,7 @@ public class CommandLinkLongActivity extends CommandMultilines2<ActivityDiagram>
|
||||
}
|
||||
|
||||
if (line0.get("STEREOTYPE", 0) != null) {
|
||||
entity1.setStereotype(new Stereotype(line0.get("STEREOTYPE", 0)));
|
||||
entity1.setStereotype(Stereotype.build(line0.get("STEREOTYPE", 0)));
|
||||
}
|
||||
final String stringColor = line0.get("BACKCOLOR", 0);
|
||||
if (stringColor != null) {
|
||||
@ -196,7 +196,7 @@ public class CommandLinkLongActivity extends CommandMultilines2<ActivityDiagram>
|
||||
}
|
||||
|
||||
if (lineLast.get(2) != null) {
|
||||
entity2.setStereotype(new Stereotype(lineLast.get(2)));
|
||||
entity2.setStereotype(Stereotype.build(lineLast.get(2)));
|
||||
}
|
||||
if (lineLast.get(4) != null) {
|
||||
String s = lineLast.get(4);
|
||||
|
@ -101,7 +101,7 @@ public class CommandPartition extends SingleLineCommand2<ActivityDiagram> {
|
||||
p.setColors(colors);
|
||||
}
|
||||
if (arg.get("STEREOTYPE", 0) != null) {
|
||||
p.setStereotype(new Stereotype(arg.get("STEREOTYPE", 0)));
|
||||
p.setStereotype(Stereotype.build(arg.get("STEREOTYPE", 0)));
|
||||
}
|
||||
|
||||
return CommandExecutionResult.ok();
|
||||
|
@ -118,7 +118,7 @@ public class CommandActivity3 extends SingleLineCommand2<ActivityDiagram3> {
|
||||
final String stereo = arg.get("STEREO", 0);
|
||||
Stereotype stereotype = null;
|
||||
if (stereo != null) {
|
||||
stereotype = new Stereotype(stereo);
|
||||
stereotype = Stereotype.build(stereo);
|
||||
colors = colors.applyStereotype(stereotype, diagram.getSkinParam(), ColorParam.activityBackground);
|
||||
}
|
||||
final BoxStyle style = BoxStyle.fromChar(arg.get("STYLE", 0).charAt(0));
|
||||
|
@ -129,7 +129,7 @@ public class CommandPartition3 extends SingleLineCommand2<ActivityDiagram3> {
|
||||
|
||||
final USymbol symbol = getUSymbol(arg.get("TYPE", 0));
|
||||
final String stereo = arg.get("STEREO", 0);
|
||||
final Stereotype stereotype = stereo == null ? null : new Stereotype(stereo);
|
||||
final Stereotype stereotype = stereo == null ? null : Stereotype.build(stereo);
|
||||
|
||||
final HColor backColorInSkinparam = diagram.getSkinParam().getHtmlColor(getColorParamBack(symbol), stereotype,
|
||||
false);
|
||||
|
@ -94,7 +94,7 @@ public class CommandRepeat3 extends SingleLineCommand2<ActivityDiagram3> {
|
||||
diagram.getSkinParam().getIHtmlColorSet());
|
||||
final String stereo = arg.get("STEREO", 0);
|
||||
if (stereo != null) {
|
||||
final Stereotype stereotype = new Stereotype(stereo);
|
||||
final Stereotype stereotype = Stereotype.build(stereo);
|
||||
colors = colors.applyStereotype(stereotype, diagram.getSkinParam(), ColorParam.activityBackground);
|
||||
}
|
||||
|
||||
|
@ -215,8 +215,15 @@ class FtileRepeat extends AbstractFtile {
|
||||
final StringBounder stringBounder = ug.getStringBounder();
|
||||
|
||||
final Snake snake = Snake.create(arrowColor, Arrows.asToDown()).withLabel(tbin, arrowHorizontalAlignment());
|
||||
snake.addPoint(getP1(stringBounder));
|
||||
snake.addPoint(getP2(stringBounder));
|
||||
final Point2D p1 = getP1(stringBounder);
|
||||
final Point2D p2 = getP2(stringBounder);
|
||||
snake.addPoint(p1);
|
||||
if (p1.getX() != p2.getX()) {
|
||||
final double my = (p1.getY() + p2.getY()) / 2;
|
||||
snake.addPoint(new Point2D.Double(p1.getX(), my));
|
||||
snake.addPoint(new Point2D.Double(p2.getX(), my));
|
||||
}
|
||||
snake.addPoint(p2);
|
||||
|
||||
ug.draw(snake);
|
||||
}
|
||||
|
@ -78,6 +78,8 @@ public class ConditionalBuilder {
|
||||
private final Swimlane swimlane;
|
||||
private final HColor borderColor;
|
||||
private final HColor backColor;
|
||||
private final LineBreakStrategy diamondLineBreak;
|
||||
private final LineBreakStrategy labelLineBreak;
|
||||
private final Rainbow arrowColor;
|
||||
private final FtileFactory ftileFactory;
|
||||
private final ConditionStyle conditionStyle;
|
||||
@ -110,6 +112,8 @@ public class ConditionalBuilder {
|
||||
.getMergedStyle(skinParam.getCurrentStyleBuilder());
|
||||
final Style styleDiamond = getDefaultStyleDefinitionDiamond()
|
||||
.getMergedStyle(skinParam.getCurrentStyleBuilder());
|
||||
this.diamondLineBreak = styleDiamond.wrapWidth();
|
||||
this.labelLineBreak = styleArrow.wrapWidth();
|
||||
this.borderColor = styleDiamond.value(PName.LineColor).asColor(skinParam.getThemeStyle(),
|
||||
skinParam.getIHtmlColorSet());
|
||||
this.backColor = styleDiamond.value(PName.BackGroundColor).asColor(skinParam.getThemeStyle(),
|
||||
@ -120,6 +124,8 @@ public class ConditionalBuilder {
|
||||
this.fontTest = styleDiamond.getFontConfiguration(skinParam.getThemeStyle(), skinParam.getIHtmlColorSet());
|
||||
this.fontArrow = styleArrow.getFontConfiguration(skinParam.getThemeStyle(), skinParam.getIHtmlColorSet());
|
||||
} else {
|
||||
this.diamondLineBreak = LineBreakStrategy.NONE;
|
||||
this.labelLineBreak = LineBreakStrategy.NONE;
|
||||
this.borderColor = borderColor;
|
||||
this.backColor = backColor;
|
||||
this.arrowColor = arrowColor;
|
||||
@ -242,7 +248,7 @@ public class ConditionalBuilder {
|
||||
|
||||
final Sheet sheet = Parser.build(fontTest, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT),
|
||||
skinParam, CreoleMode.FULL).createSheet(labelTest);
|
||||
final SheetBlock1 sheetBlock1 = new SheetBlock1(sheet, LineBreakStrategy.NONE, skinParam.getPadding());
|
||||
final SheetBlock1 sheetBlock1 = new SheetBlock1(sheet, diamondLineBreak, skinParam.getPadding());
|
||||
final TextBlock tbTest = new SheetBlock2(sheetBlock1, Diamond.asStencil(sheetBlock1), tile1.getThickness());
|
||||
|
||||
final Ftile diamond1;
|
||||
@ -277,8 +283,8 @@ public class ConditionalBuilder {
|
||||
}
|
||||
|
||||
private TextBlock getLabelPositive(Branch branch) {
|
||||
return branch.getLabelPositive().create7(fontArrow, HorizontalAlignment.LEFT, ftileFactory.skinParam(),
|
||||
CreoleMode.SIMPLE_LINE);
|
||||
return branch.getLabelPositive().create0(fontArrow, HorizontalAlignment.LEFT, ftileFactory.skinParam(),
|
||||
labelLineBreak, CreoleMode.SIMPLE_LINE, null, null);
|
||||
}
|
||||
|
||||
private Ftile getDiamond2(Branch branch1, Branch branch2, boolean useNorth) {
|
||||
|
@ -65,16 +65,13 @@ public class FtileIfWithDiamonds extends FtileIfNude {
|
||||
}
|
||||
|
||||
public int getYdelta1a(StringBounder stringBounder) {
|
||||
// if (getSwimlanes().size() > 1 && hasTwoBranches(stringBounder)) {
|
||||
if (getSwimlanes().size() > 1) {
|
||||
return 20;
|
||||
}
|
||||
return 10;
|
||||
// return hasTwoBranches(stringBounder) ? 6 : 6;
|
||||
}
|
||||
|
||||
public int getYdelta1b(StringBounder stringBounder) {
|
||||
// if (getSwimlanes().size() > 1 && hasTwoBranches(stringBounder)) {
|
||||
if (getSwimlanes().size() > 1) {
|
||||
return 10;
|
||||
}
|
||||
@ -98,9 +95,6 @@ public class FtileIfWithDiamonds extends FtileIfNude {
|
||||
|
||||
return all.addDim(0, getYdelta1a(stringBounder) + getYdelta1b(stringBounder));
|
||||
|
||||
// final double height = dimNude.getHeight() + dim1.getHeight() + dim2.getHeight() + getYdelta1a(stringBounder)
|
||||
// + getYdelta1b(stringBounder);
|
||||
// return new Dimension2DDouble(width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -115,22 +109,21 @@ public class FtileIfWithDiamonds extends FtileIfNude {
|
||||
@Override
|
||||
protected UTranslate getTranslate1(StringBounder stringBounder) {
|
||||
final FtileGeometry dimDiamond1 = diamond1.calculateDimension(stringBounder);
|
||||
return super.getTranslate1(stringBounder).compose(
|
||||
UTranslate.dy(dimDiamond1.getHeight() + getYdelta1a(stringBounder)));
|
||||
return super.getTranslate1(stringBounder)
|
||||
.compose(UTranslate.dy(dimDiamond1.getHeight() + getYdelta1a(stringBounder)));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected UTranslate getTranslate2(StringBounder stringBounder) {
|
||||
final FtileGeometry dimDiamond1 = diamond1.calculateDimension(stringBounder);
|
||||
return super.getTranslate2(stringBounder).compose(
|
||||
UTranslate.dy(dimDiamond1.getHeight() + getYdelta1a(stringBounder)));
|
||||
return super.getTranslate2(stringBounder)
|
||||
.compose(UTranslate.dy(dimDiamond1.getHeight() + getYdelta1a(stringBounder)));
|
||||
}
|
||||
|
||||
protected UTranslate getTranslateDiamond1(StringBounder stringBounder) {
|
||||
final double y1 = 0;
|
||||
final FtileGeometry dimTotal = calculateDimensionInternal(stringBounder);
|
||||
final FtileGeometry dimDiamond1 = diamond1.calculateDimension(stringBounder);
|
||||
// final double x1 = getLeft(stringBounder) - dimDiamond1.getWidth() / 2;
|
||||
final double x1 = dimTotal.getLeft() - dimDiamond1.getLeft();
|
||||
return new UTranslate(x1, y1);
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ public class CommandCreateClass extends SingleLineCommand2<ClassDiagram> {
|
||||
}
|
||||
}
|
||||
if (stereotype != null) {
|
||||
entity.setStereotype(new Stereotype(stereotype, diagram.getSkinParam().getCircledCharacterRadius(),
|
||||
entity.setStereotype(Stereotype.build(stereotype, diagram.getSkinParam().getCircledCharacterRadius(),
|
||||
diagram.getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER),
|
||||
diagram.getSkinParam().getIHtmlColorSet()));
|
||||
}
|
||||
|
@ -264,7 +264,7 @@ public class CommandCreateClassMultilines extends CommandMultilines2<ClassDiagra
|
||||
}
|
||||
result.setVisibilityModifier(visibilityModifier);
|
||||
if (stereotype != null) {
|
||||
result.setStereotype(new Stereotype(stereotype, diagram.getSkinParam().getCircledCharacterRadius(),
|
||||
result.setStereotype(Stereotype.build(stereotype, diagram.getSkinParam().getCircledCharacterRadius(),
|
||||
diagram.getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER),
|
||||
diagram.getSkinParam().getIHtmlColorSet()));
|
||||
}
|
||||
|
@ -211,7 +211,7 @@ public class CommandCreateElementFull2 extends SingleLineCommand2<ClassDiagram>
|
||||
entity.setDisplay(Display.getWithNewlines(display));
|
||||
entity.setUSymbol(usymbol);
|
||||
if (stereotype != null) {
|
||||
entity.setStereotype(new Stereotype(stereotype, diagram.getSkinParam().getCircledCharacterRadius(),
|
||||
entity.setStereotype(Stereotype.build(stereotype, diagram.getSkinParam().getCircledCharacterRadius(),
|
||||
diagram.getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER),
|
||||
diagram.getSkinParam().getIHtmlColorSet()));
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ public class CommandStereotype extends SingleLineCommand2<ClassDiagram> {
|
||||
final Code code = diagram.V1972() ? ident : diagram.buildCode(name);
|
||||
final String stereotype = arg.get("STEREO", 0);
|
||||
final IEntity entity = diagram.getOrCreateLeaf(ident, code, null, null);
|
||||
entity.setStereotype(new Stereotype(stereotype, diagram.getSkinParam().getCircledCharacterRadius(), diagram
|
||||
entity.setStereotype(Stereotype.build(stereotype, diagram.getSkinParam().getCircledCharacterRadius(), diagram
|
||||
.getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER), diagram.getSkinParam()
|
||||
.getIHtmlColorSet()));
|
||||
return CommandExecutionResult.ok();
|
||||
|
@ -98,7 +98,7 @@ public class CommandNamespace extends SingleLineCommand2<ClassDiagram> {
|
||||
final IEntity p = diagram.getCurrentGroup();
|
||||
final String stereotype = arg.get("STEREOTYPE", 0);
|
||||
if (stereotype != null) {
|
||||
p.setStereotype(new Stereotype(stereotype));
|
||||
p.setStereotype(Stereotype.build(stereotype));
|
||||
}
|
||||
|
||||
final String urlString = arg.get("URL", 0);
|
||||
|
@ -98,7 +98,7 @@ public class CommandNamespace2 extends SingleLineCommand2<ClassDiagram> {
|
||||
final IEntity p = diagram.getCurrentGroup();
|
||||
final String stereotype = arg.get("STEREOTYPE", 0);
|
||||
if (stereotype != null) {
|
||||
p.setStereotype(new Stereotype(stereotype));
|
||||
p.setStereotype(Stereotype.build(stereotype));
|
||||
}
|
||||
|
||||
final String urlString = arg.get("URL", 0);
|
||||
|
@ -92,7 +92,7 @@ public class CommandNamespaceEmpty extends SingleLineCommand2<ClassDiagram> {
|
||||
final IEntity p = diagram.getCurrentGroup();
|
||||
final String stereotype = arg.get("STEREOTYPE", 0);
|
||||
if (stereotype != null) {
|
||||
p.setStereotype(new Stereotype(stereotype));
|
||||
p.setStereotype(Stereotype.build(stereotype));
|
||||
}
|
||||
|
||||
final String urlString = arg.get("URL", 0);
|
||||
|
@ -141,7 +141,7 @@ public class CommandPackage extends SingleLineCommand2<AbstractEntityDiagram> {
|
||||
final USymbol usymbol = USymbol.fromString(stereotype, diagram.getSkinParam().actorStyle(),
|
||||
diagram.getSkinParam().componentStyle(), diagram.getSkinParam().packageStyle());
|
||||
if (usymbol == null) {
|
||||
p.setStereotype(new Stereotype(stereotype));
|
||||
p.setStereotype(Stereotype.build(stereotype));
|
||||
} else {
|
||||
p.setUSymbol(usymbol);
|
||||
}
|
||||
|
@ -242,7 +242,7 @@ public final class CommandFactoryNoteOnEntity implements SingleMultiFactoryComma
|
||||
|
||||
final String stereotypeString = line0.get("STEREO", 0);
|
||||
if (stereotypeString != null) {
|
||||
final Stereotype stereotype = new Stereotype(stereotypeString);
|
||||
final Stereotype stereotype = Stereotype.build(stereotypeString);
|
||||
colors = colors.applyStereotypeForNote(stereotype, diagram.getSkinParam(), FontParam.NOTE,
|
||||
ColorParam.noteBackground, ColorParam.noteBorder);
|
||||
note.setStereotype(stereotype);
|
||||
|
@ -159,7 +159,7 @@ public final class FactorySequenceNoteAcrossCommand implements SingleMultiFactor
|
||||
diagram.getSkinParam().getIHtmlColorSet());
|
||||
final String stereotypeString = line0.get("STEREO", 0);
|
||||
if (stereotypeString != null) {
|
||||
final Stereotype stereotype = new Stereotype(stereotypeString);
|
||||
final Stereotype stereotype = Stereotype.build(stereotypeString);
|
||||
colors = colors.applyStereotypeForNote(stereotype, diagram.getSkinParam(), FontParam.NOTE,
|
||||
ColorParam.noteBackground, ColorParam.noteBorder);
|
||||
note.setStereotype(stereotype);
|
||||
|
@ -158,7 +158,7 @@ public final class FactorySequenceNoteCommand implements SingleMultiFactoryComma
|
||||
diagram.getSkinParam().getIHtmlColorSet());
|
||||
final String stereotypeString = arg.get("STEREO", 0);
|
||||
if (stereotypeString != null) {
|
||||
final Stereotype stereotype = new Stereotype(stereotypeString);
|
||||
final Stereotype stereotype = Stereotype.build(stereotypeString);
|
||||
colors = colors.applyStereotypeForNote(stereotype, diagram.getSkinParam(), FontParam.NOTE,
|
||||
ColorParam.noteBackground, ColorParam.noteBorder);
|
||||
note.setStereotype(stereotype);
|
||||
|
@ -153,7 +153,7 @@ public final class FactorySequenceNoteOnArrowCommand implements SingleMultiFacto
|
||||
final Note note = new Note(display, position, style, diagram.getSkinParam().getCurrentStyleBuilder());
|
||||
final String stereotypeString = line0.get("STEREO", 0);
|
||||
if (stereotypeString != null) {
|
||||
final Stereotype stereotype = new Stereotype(stereotypeString);
|
||||
final Stereotype stereotype = Stereotype.build(stereotypeString);
|
||||
colors = colors.applyStereotypeForNote(stereotype, diagram.getSkinParam(), FontParam.NOTE,
|
||||
ColorParam.noteBackground, ColorParam.noteBorder);
|
||||
note.setStereotype(stereotype);
|
||||
|
@ -169,7 +169,7 @@ public final class FactorySequenceNoteOverSeveralCommand implements SingleMultiF
|
||||
diagram.getSkinParam().getIHtmlColorSet());
|
||||
final String stereotypeString = line0.get("STEREO", 0);
|
||||
if (stereotypeString != null) {
|
||||
final Stereotype stereotype = new Stereotype(stereotypeString);
|
||||
final Stereotype stereotype = Stereotype.build(stereotypeString);
|
||||
colors = colors.applyStereotypeForNote(stereotype, diagram.getSkinParam(), FontParam.NOTE,
|
||||
ColorParam.noteBackground, ColorParam.noteBorder);
|
||||
note.setStereotype(stereotype);
|
||||
|
@ -45,191 +45,100 @@ import java.util.regex.Pattern;
|
||||
|
||||
import net.sourceforge.plantuml.Guillemet;
|
||||
import net.sourceforge.plantuml.SpriteContainer;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.command.regex.Matcher2;
|
||||
import net.sourceforge.plantuml.command.regex.MyPattern;
|
||||
import net.sourceforge.plantuml.command.regex.Pattern2;
|
||||
import net.sourceforge.plantuml.command.regex.RegexComposed;
|
||||
import net.sourceforge.plantuml.command.regex.RegexConcat;
|
||||
import net.sourceforge.plantuml.command.regex.RegexLeaf;
|
||||
import net.sourceforge.plantuml.command.regex.RegexOptional;
|
||||
import net.sourceforge.plantuml.command.regex.RegexResult;
|
||||
import net.sourceforge.plantuml.creole.Parser;
|
||||
import net.sourceforge.plantuml.graphic.TextBlock;
|
||||
import net.sourceforge.plantuml.sprite.Sprite;
|
||||
import net.sourceforge.plantuml.sprite.SpriteUtils;
|
||||
import net.sourceforge.plantuml.style.Style;
|
||||
import net.sourceforge.plantuml.style.StyleBuilder;
|
||||
import net.sourceforge.plantuml.svek.PackageStyle;
|
||||
import net.sourceforge.plantuml.ugraphic.UFont;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColor;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColorSet;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
|
||||
import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException;
|
||||
|
||||
public class Stereotype implements CharSequence {
|
||||
private final static RegexComposed circleChar = new RegexConcat( //
|
||||
new RegexLeaf("\\<\\<"), //
|
||||
RegexLeaf.spaceZeroOrMore(), //
|
||||
new RegexLeaf("\\(?"), //
|
||||
new RegexLeaf("CHAR", "(\\S)"), //
|
||||
RegexLeaf.spaceZeroOrMore(), //
|
||||
new RegexLeaf(","), //
|
||||
RegexLeaf.spaceZeroOrMore(), //
|
||||
new RegexLeaf("COLOR", "(#[0-9a-fA-F]{6}|\\w+)"), //
|
||||
RegexLeaf.spaceZeroOrMore(), //
|
||||
new RegexOptional(new RegexLeaf("LABEL", "[),](.*?)")), //
|
||||
new RegexLeaf("\\>\\>") //
|
||||
);
|
||||
|
||||
private final static RegexComposed circleSprite = new RegexConcat( //
|
||||
new RegexLeaf("\\<\\<"), //
|
||||
RegexLeaf.spaceZeroOrMore(), //
|
||||
new RegexLeaf("\\(?\\$"), //
|
||||
new RegexLeaf("NAME", "(" + SpriteUtils.SPRITE_NAME + ")"), //
|
||||
new RegexLeaf("SCALE", "((?:\\{scale=|\\*)([0-9.]+)\\}?)?"), //
|
||||
RegexLeaf.spaceZeroOrMore(), //
|
||||
new RegexOptional( //
|
||||
new RegexConcat( //
|
||||
new RegexLeaf(","), //
|
||||
RegexLeaf.spaceZeroOrMore(), //
|
||||
new RegexLeaf("COLOR", "(#[0-9a-fA-F]{6}|\\w+)") //
|
||||
)), //
|
||||
RegexLeaf.spaceZeroOrMore(), //
|
||||
new RegexOptional(new RegexLeaf("LABEL", "[),](.*?)")), //
|
||||
new RegexLeaf("\\>\\>") //
|
||||
);
|
||||
|
||||
private final double radius;
|
||||
private final UFont circledFont;
|
||||
private final boolean automaticPackageStyle;
|
||||
private final StereotypeDecoration decoration;
|
||||
|
||||
private String label;
|
||||
private HColor htmlColor;
|
||||
private char character;
|
||||
private String spriteName;
|
||||
private double spriteScale;
|
||||
|
||||
public Stereotype(String label, double radius, UFont circledFont, HColorSet htmlColorSet) throws NoSuchColorException {
|
||||
this(label, radius, circledFont, true, htmlColorSet);
|
||||
}
|
||||
|
||||
public Stereotype(String label, boolean automaticPackageStyle) {
|
||||
this.automaticPackageStyle = automaticPackageStyle;
|
||||
this.label = label;
|
||||
this.htmlColor = null;
|
||||
this.character = '\0';
|
||||
this.radius = 0;
|
||||
this.circledFont = null;
|
||||
if (label.startsWith("<<$") && label.endsWith(">>")) {
|
||||
final RegexResult mCircleSprite = circleSprite.matcher(label);
|
||||
this.spriteName = mCircleSprite.get("NAME", 0);
|
||||
this.spriteScale = Parser.getScale(mCircleSprite.get("SCALE", 0), 1);
|
||||
} else {
|
||||
this.spriteName = null;
|
||||
}
|
||||
}
|
||||
|
||||
public Stereotype(String label, double radius, UFont circledFont, boolean automaticPackageStyle,
|
||||
HColorSet htmlColorSet) throws NoSuchColorException {
|
||||
Objects.requireNonNull(label);
|
||||
if (label.startsWith("<<") == false || label.endsWith(">>") == false) {
|
||||
throw new IllegalArgumentException(label);
|
||||
}
|
||||
private Stereotype(boolean automaticPackageStyle, String label, StereotypeDecoration decoration, double radius,
|
||||
UFont circledFont) {
|
||||
this.automaticPackageStyle = automaticPackageStyle;
|
||||
this.radius = radius;
|
||||
this.circledFont = circledFont;
|
||||
this.decoration = decoration;
|
||||
|
||||
final StringBuilder tmpLabel = new StringBuilder();
|
||||
}
|
||||
|
||||
final List<String> list = cutLabels(label, Guillemet.DOUBLE_COMPARATOR);
|
||||
for (String local : list) {
|
||||
final RegexResult mCircleChar = circleChar.matcher(local);
|
||||
final RegexResult mCircleSprite = circleSprite.matcher(local);
|
||||
if (mCircleSprite != null) {
|
||||
if (StringUtils.isNotEmpty(mCircleSprite.get("LABEL", 0))) {
|
||||
local = "<<" + mCircleSprite.get("LABEL", 0) + ">>";
|
||||
} else {
|
||||
local = null;
|
||||
}
|
||||
final String colName = mCircleSprite.get("COLOR", 0);
|
||||
final HColor col = colName == null ? null : htmlColorSet.getColorLEGACY(colName);
|
||||
this.htmlColor = col == null ? HColorUtils.BLACK : col;
|
||||
this.spriteName = mCircleSprite.get("NAME", 0);
|
||||
this.character = '\0';
|
||||
this.spriteScale = Parser.getScale(mCircleSprite.get("SCALE", 0), 1);
|
||||
} else if (mCircleChar != null) {
|
||||
if (StringUtils.isNotEmpty(mCircleChar.get("LABEL", 0))) {
|
||||
local = "<<" + mCircleChar.get("LABEL", 0) + ">>";
|
||||
} else {
|
||||
local = null;
|
||||
}
|
||||
final String colName = mCircleChar.get("COLOR", 0);
|
||||
this.htmlColor = colName == null ? null : htmlColorSet.getColorLEGACY(colName);
|
||||
this.character = mCircleChar.get("CHAR", 0).charAt(0);
|
||||
this.spriteName = null;
|
||||
}
|
||||
if (local != null) {
|
||||
tmpLabel.append(local);
|
||||
}
|
||||
}
|
||||
if (tmpLabel.length() > 0) {
|
||||
this.label = tmpLabel.toString();
|
||||
private static void checkLabel(String label) {
|
||||
if (label.startsWith("<<") == false || label.endsWith(">>") == false) {
|
||||
throw new IllegalArgumentException(label);
|
||||
}
|
||||
}
|
||||
|
||||
public Stereotype(String label) {
|
||||
this(label, true);
|
||||
public static Stereotype build(String label) {
|
||||
return build(label, true);
|
||||
}
|
||||
|
||||
public static Stereotype build(String label, boolean automaticPackageStyle) {
|
||||
checkLabel(label);
|
||||
final StereotypeDecoration decoration = StereotypeDecoration.buildSimple(label);
|
||||
return new Stereotype(automaticPackageStyle, label, decoration, 0, null);
|
||||
}
|
||||
|
||||
public static Stereotype build(String label, double radius, UFont circledFont, HColorSet htmlColorSet)
|
||||
throws NoSuchColorException {
|
||||
checkLabel(label);
|
||||
final StereotypeDecoration decoration = StereotypeDecoration.buildComplex(label, htmlColorSet);
|
||||
return new Stereotype(true, label, decoration, radius, circledFont);
|
||||
}
|
||||
|
||||
public HColor getHtmlColor() {
|
||||
return htmlColor;
|
||||
return decoration.htmlColor;
|
||||
}
|
||||
|
||||
public char getCharacter() {
|
||||
return character;
|
||||
return decoration.character;
|
||||
}
|
||||
|
||||
public final TextBlock getSprite(SpriteContainer container) {
|
||||
if (spriteName == null || container == null) {
|
||||
if (decoration.spriteName == null || container == null) {
|
||||
return null;
|
||||
}
|
||||
final Sprite tmp = container.getSprite(spriteName);
|
||||
final Sprite tmp = container.getSprite(decoration.spriteName);
|
||||
if (tmp == null) {
|
||||
return null;
|
||||
}
|
||||
return tmp.asTextBlock(getHtmlColor(), spriteScale);
|
||||
return tmp.asTextBlock(getHtmlColor(), decoration.spriteScale);
|
||||
}
|
||||
|
||||
public boolean isWithOOSymbol() {
|
||||
return "<<O-O>>".equalsIgnoreCase(label);
|
||||
return "<<O-O>>".equalsIgnoreCase(decoration.label);
|
||||
}
|
||||
|
||||
public List<String> getMultipleLabels() {
|
||||
final List<String> result = new ArrayList<>();
|
||||
if (label != null) {
|
||||
final Pattern p = Pattern.compile("\\<\\<\\s?((?:\\<&\\w+\\>|[^<>])+?)\\s?\\>\\>");
|
||||
final Matcher m = p.matcher(label);
|
||||
while (m.find()) {
|
||||
result.add(m.group(1));
|
||||
}
|
||||
|
||||
final Pattern p = Pattern.compile("\\<\\<\\s?((?:\\<&\\w+\\>|[^<>])+?)\\s?\\>\\>");
|
||||
final Matcher m = p.matcher(decoration.label);
|
||||
while (m.find()) {
|
||||
result.add(m.group(1));
|
||||
}
|
||||
|
||||
return Collections.unmodifiableList(result);
|
||||
}
|
||||
|
||||
public boolean isSpotted() {
|
||||
return character != 0;
|
||||
return decoration.character != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (label == null) {
|
||||
return "" + character;
|
||||
if (decoration.character == 0) {
|
||||
return decoration.label;
|
||||
}
|
||||
if (character == 0) {
|
||||
return label;
|
||||
}
|
||||
return character + " " + label;
|
||||
return decoration.character + " " + decoration.label;
|
||||
}
|
||||
|
||||
public char charAt(int arg0) {
|
||||
@ -253,14 +162,13 @@ public class Stereotype implements CharSequence {
|
||||
}
|
||||
|
||||
public String getLabel(Guillemet guillemet) {
|
||||
assert label == null || label.length() > 0;
|
||||
if (isWithOOSymbol()) {
|
||||
return null;
|
||||
}
|
||||
if (spriteName != null && spriteName.startsWith("archimate/")) {
|
||||
return guillemet.manageGuillemet("<<" + spriteName.substring("archimate/".length()) + ">>");
|
||||
if (decoration.spriteName != null && decoration.spriteName.startsWith("archimate/")) {
|
||||
return guillemet.manageGuillemet("<<" + decoration.spriteName.substring("archimate/".length()) + ">>");
|
||||
}
|
||||
return guillemet.manageGuillemet(label);
|
||||
return guillemet.manageGuillemet(decoration.label);
|
||||
}
|
||||
|
||||
public List<String> getLabels(Guillemet guillemet) {
|
||||
@ -268,7 +176,7 @@ public class Stereotype implements CharSequence {
|
||||
if (labelLocal == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return cutLabels(labelLocal, guillemet);
|
||||
return StereotypeDecoration.cutLabels(labelLocal, guillemet);
|
||||
}
|
||||
|
||||
public List<Style> getStyles(StyleBuilder builder) {
|
||||
@ -289,22 +197,12 @@ public class Stereotype implements CharSequence {
|
||||
return Collections.unmodifiableList(labels);
|
||||
}
|
||||
|
||||
private static List<String> cutLabels(final String label, Guillemet guillemet) {
|
||||
final List<String> result = new ArrayList<>();
|
||||
final Pattern2 p = MyPattern.cmpile("\\<\\<.*?\\>\\>");
|
||||
final Matcher2 m = p.matcher(label);
|
||||
while (m.find()) {
|
||||
result.add(guillemet.manageGuillemetStrict(m.group()));
|
||||
}
|
||||
return Collections.unmodifiableList(result);
|
||||
}
|
||||
|
||||
public PackageStyle getPackageStyle() {
|
||||
if (automaticPackageStyle == false) {
|
||||
return null;
|
||||
}
|
||||
for (PackageStyle p : EnumSet.allOf(PackageStyle.class)) {
|
||||
if (("<<" + p + ">>").equalsIgnoreCase(label)) {
|
||||
if (("<<" + p + ">>").equalsIgnoreCase(decoration.label)) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
@ -312,27 +210,28 @@ public class Stereotype implements CharSequence {
|
||||
}
|
||||
|
||||
public boolean isBiddableOrUncertain() {
|
||||
return label.equalsIgnoreCase("<<B>>") || label.equalsIgnoreCase("<<Biddable>>")
|
||||
|| label.equalsIgnoreCase("<<Uncertain>>");
|
||||
return decoration.label.equalsIgnoreCase("<<B>>") || decoration.label.equalsIgnoreCase("<<Biddable>>")
|
||||
|| decoration.label.equalsIgnoreCase("<<Uncertain>>");
|
||||
}
|
||||
|
||||
public boolean isCausal() {
|
||||
return label.equalsIgnoreCase("<<C>>") || label.equalsIgnoreCase("<<Causal>>");
|
||||
return decoration.label.equalsIgnoreCase("<<C>>") || decoration.label.equalsIgnoreCase("<<Causal>>");
|
||||
}
|
||||
|
||||
public boolean isLexicalOrGiven() {
|
||||
return label.equalsIgnoreCase("<<L>>") || label.equalsIgnoreCase("<<Lexical>>")
|
||||
|| label.equalsIgnoreCase("<<X>>") || label.equalsIgnoreCase("<<Given>>");
|
||||
return decoration.label.equalsIgnoreCase("<<L>>") || decoration.label.equalsIgnoreCase("<<Lexical>>")
|
||||
|| decoration.label.equalsIgnoreCase("<<X>>") || decoration.label.equalsIgnoreCase("<<Given>>");
|
||||
}
|
||||
|
||||
public boolean isDesignedOrSolved() {
|
||||
return label.equalsIgnoreCase("<<D>>") || label.equalsIgnoreCase("<<Designed>>")
|
||||
|| label.equalsIgnoreCase("<<Nested>>") || label.equalsIgnoreCase("<<Solved>>");
|
||||
return decoration.label.equalsIgnoreCase("<<D>>") || decoration.label.equalsIgnoreCase("<<Designed>>")
|
||||
|| decoration.label.equalsIgnoreCase("<<Nested>>") || decoration.label.equalsIgnoreCase("<<Solved>>");
|
||||
}
|
||||
|
||||
public boolean isMachineOrSpecification() {
|
||||
return label.equalsIgnoreCase("M") || label.equalsIgnoreCase("<<Machine>>") || label.equalsIgnoreCase("<<S>>")
|
||||
|| label.equalsIgnoreCase("<<Spec>>") || label.equalsIgnoreCase("<<Specification>>");
|
||||
return decoration.label.equalsIgnoreCase("M") || decoration.label.equalsIgnoreCase("<<Machine>>")
|
||||
|| decoration.label.equalsIgnoreCase("<<S>>") || decoration.label.equalsIgnoreCase("<<Spec>>")
|
||||
|| decoration.label.equalsIgnoreCase("<<Specification>>");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,175 @@
|
||||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2020, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.com
|
||||
*
|
||||
* 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/paypal
|
||||
*
|
||||
* This file is part of PlantUML.
|
||||
*
|
||||
* PlantUML is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlantUML distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.cucadiagram;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.Guillemet;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.command.regex.Matcher2;
|
||||
import net.sourceforge.plantuml.command.regex.MyPattern;
|
||||
import net.sourceforge.plantuml.command.regex.Pattern2;
|
||||
import net.sourceforge.plantuml.command.regex.RegexComposed;
|
||||
import net.sourceforge.plantuml.command.regex.RegexConcat;
|
||||
import net.sourceforge.plantuml.command.regex.RegexLeaf;
|
||||
import net.sourceforge.plantuml.command.regex.RegexOptional;
|
||||
import net.sourceforge.plantuml.command.regex.RegexResult;
|
||||
import net.sourceforge.plantuml.creole.Parser;
|
||||
import net.sourceforge.plantuml.sprite.SpriteUtils;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColor;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColorSet;
|
||||
import net.sourceforge.plantuml.ugraphic.color.HColorUtils;
|
||||
import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException;
|
||||
|
||||
public class StereotypeDecoration {
|
||||
private final static RegexComposed circleChar = new RegexConcat( //
|
||||
new RegexLeaf("\\<\\<"), //
|
||||
RegexLeaf.spaceZeroOrMore(), //
|
||||
new RegexLeaf("\\(?"), //
|
||||
new RegexLeaf("CHAR", "(\\S)"), //
|
||||
RegexLeaf.spaceZeroOrMore(), //
|
||||
new RegexLeaf(","), //
|
||||
RegexLeaf.spaceZeroOrMore(), //
|
||||
new RegexLeaf("COLOR", "(#[0-9a-fA-F]{6}|\\w+)"), //
|
||||
RegexLeaf.spaceZeroOrMore(), //
|
||||
new RegexOptional(new RegexLeaf("LABEL", "[),](.*?)")), //
|
||||
new RegexLeaf("\\>\\>") //
|
||||
);
|
||||
|
||||
private final static RegexComposed circleSprite = new RegexConcat( //
|
||||
new RegexLeaf("\\<\\<"), //
|
||||
RegexLeaf.spaceZeroOrMore(), //
|
||||
new RegexLeaf("\\(?\\$"), //
|
||||
new RegexLeaf("NAME", "(" + SpriteUtils.SPRITE_NAME + ")"), //
|
||||
new RegexLeaf("SCALE", "((?:\\{scale=|\\*)([0-9.]+)\\}?)?"), //
|
||||
RegexLeaf.spaceZeroOrMore(), //
|
||||
new RegexOptional( //
|
||||
new RegexConcat( //
|
||||
new RegexLeaf(","), //
|
||||
RegexLeaf.spaceZeroOrMore(), //
|
||||
new RegexLeaf("COLOR", "(#[0-9a-fA-F]{6}|\\w+)") //
|
||||
)), //
|
||||
RegexLeaf.spaceZeroOrMore(), //
|
||||
new RegexOptional(new RegexLeaf("LABEL", "[),](.*?)")), //
|
||||
new RegexLeaf("\\>\\>") //
|
||||
);
|
||||
|
||||
final String label;
|
||||
final HColor htmlColor;
|
||||
final char character;
|
||||
final String spriteName;
|
||||
final double spriteScale;
|
||||
|
||||
private StereotypeDecoration(String label, HColor htmlColor, char character, String spriteName,
|
||||
double spriteScale) {
|
||||
this.label = label;
|
||||
this.htmlColor = htmlColor;
|
||||
this.character = character;
|
||||
this.spriteName = spriteName;
|
||||
this.spriteScale = spriteScale;
|
||||
}
|
||||
|
||||
static StereotypeDecoration buildSimple(String name) {
|
||||
final String spriteName;
|
||||
final double spriteScale;
|
||||
if (name.startsWith("<<$") && name.endsWith(">>")) {
|
||||
final RegexResult mCircleSprite = StereotypeDecoration.circleSprite.matcher(name);
|
||||
spriteName = mCircleSprite.get("NAME", 0);
|
||||
spriteScale = Parser.getScale(mCircleSprite.get("SCALE", 0), 1);
|
||||
} else {
|
||||
spriteName = null;
|
||||
spriteScale = 0;
|
||||
}
|
||||
return new StereotypeDecoration(name, null, '\0', spriteName, spriteScale);
|
||||
}
|
||||
|
||||
public static StereotypeDecoration buildComplex(String full, HColorSet htmlColorSet) throws NoSuchColorException {
|
||||
|
||||
String label = "";
|
||||
HColor htmlColor = null;
|
||||
char character = '\0';
|
||||
String spriteName = null;
|
||||
double spriteScale = 0;
|
||||
|
||||
final List<String> list = cutLabels(full, Guillemet.DOUBLE_COMPARATOR);
|
||||
for (String name : list) {
|
||||
final RegexResult mCircleChar = circleChar.matcher(name);
|
||||
final RegexResult mCircleSprite = circleSprite.matcher(name);
|
||||
|
||||
if (mCircleSprite != null) {
|
||||
if (StringUtils.isNotEmpty(mCircleSprite.get("LABEL", 0)))
|
||||
name = "<<" + mCircleSprite.get("LABEL", 0) + ">>";
|
||||
else
|
||||
name = "";
|
||||
|
||||
final String colName = mCircleSprite.get("COLOR", 0);
|
||||
final HColor col = colName == null ? null : htmlColorSet.getColorLEGACY(colName);
|
||||
htmlColor = col == null ? HColorUtils.BLACK : col;
|
||||
character = '\0';
|
||||
spriteName = mCircleSprite.get("NAME", 0);
|
||||
spriteScale = Parser.getScale(mCircleSprite.get("SCALE", 0), 1);
|
||||
} else if (mCircleChar != null) {
|
||||
if (StringUtils.isNotEmpty(mCircleChar.get("LABEL", 0)))
|
||||
name = "<<" + mCircleChar.get("LABEL", 0) + ">>";
|
||||
else
|
||||
name = "";
|
||||
|
||||
final String colName = mCircleChar.get("COLOR", 0);
|
||||
htmlColor = colName == null ? null : htmlColorSet.getColorLEGACY(colName);
|
||||
character = mCircleChar.get("CHAR", 0).charAt(0);
|
||||
}
|
||||
|
||||
label = label + name;
|
||||
}
|
||||
|
||||
return new StereotypeDecoration(label, htmlColor, character, spriteName, spriteScale);
|
||||
}
|
||||
|
||||
static List<String> cutLabels(final String label, Guillemet guillemet) {
|
||||
final List<String> result = new ArrayList<>();
|
||||
final Pattern2 p = MyPattern.cmpile("\\<{2,3}.*?\\>{2,3}");
|
||||
final Matcher2 m = p.matcher(label);
|
||||
while (m.find()) {
|
||||
final String group = m.group();
|
||||
if (group.startsWith("<<<") == false)
|
||||
result.add(guillemet.manageGuillemetStrict(group));
|
||||
}
|
||||
return Collections.unmodifiableList(result);
|
||||
}
|
||||
|
||||
}
|
@ -121,7 +121,7 @@ public class CommandCreateDomain extends SingleLineCommand2<DescriptionDiagram>
|
||||
type.equalsIgnoreCase("domain") ? LeafType.DOMAIN : LeafType.REQUIREMENT, null);
|
||||
}
|
||||
if (stereotype != null) {
|
||||
entity.setStereotype(new Stereotype(stereotype, diagram.getSkinParam().getCircledCharacterRadius(),
|
||||
entity.setStereotype(Stereotype.build(stereotype, diagram.getSkinParam().getCircledCharacterRadius(),
|
||||
diagram.getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER),
|
||||
diagram.getSkinParam().getIHtmlColorSet()));
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ public class CommandArchimate extends SingleLineCommand2<DescriptionDiagram> {
|
||||
entity.setUSymbol(USymbol.ARCHIMATE);
|
||||
if (icon != null) {
|
||||
entity.setStereotype(
|
||||
new Stereotype("<<$archimate/" + icon + ">>", diagram.getSkinParam().getCircledCharacterRadius(),
|
||||
Stereotype.build("<<$archimate/" + icon + ">>", diagram.getSkinParam().getCircledCharacterRadius(),
|
||||
diagram.getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER),
|
||||
diagram.getSkinParam().getIHtmlColorSet()));
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ public class CommandArchimateMultilines extends CommandMultilines2<AbstractEntit
|
||||
entity.setUSymbol(USymbol.RECTANGLE);
|
||||
if (icon != null) {
|
||||
entity.setStereotype(
|
||||
new Stereotype("<<$archimate/" + icon + ">>", diagram.getSkinParam().getCircledCharacterRadius(),
|
||||
Stereotype.build("<<$archimate/" + icon + ">>", diagram.getSkinParam().getCircledCharacterRadius(),
|
||||
diagram.getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER),
|
||||
diagram.getSkinParam().getIHtmlColorSet()));
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ public class CommandCreateElementFull extends SingleLineCommand2<DescriptionDiag
|
||||
entity.setDisplay(Display.getWithNewlines(display));
|
||||
entity.setUSymbol(usymbol);
|
||||
if (stereotype != null) {
|
||||
entity.setStereotype(new Stereotype(stereotype, diagram.getSkinParam().getCircledCharacterRadius(),
|
||||
entity.setStereotype(Stereotype.build(stereotype, diagram.getSkinParam().getCircledCharacterRadius(),
|
||||
diagram.getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER),
|
||||
diagram.getSkinParam().getIHtmlColorSet()));
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ public class CommandCreateElementMultilines extends CommandMultilines2<AbstractE
|
||||
}
|
||||
result.setUSymbol(usymbol);
|
||||
if (stereotype != null) {
|
||||
result.setStereotype(new Stereotype(stereotype, diagram.getSkinParam().getCircledCharacterRadius(),
|
||||
result.setStereotype(Stereotype.build(stereotype, diagram.getSkinParam().getCircledCharacterRadius(),
|
||||
diagram.getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER),
|
||||
diagram.getSkinParam().getIHtmlColorSet()));
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ public class CommandCreateElementParenthesis extends SingleLineCommand2<ClassDia
|
||||
entity.setDisplay(Display.getWithNewlines(display));
|
||||
entity.setUSymbol(usymbol);
|
||||
if (stereotype != null) {
|
||||
entity.setStereotype(new Stereotype(stereotype, diagram.getSkinParam().getCircledCharacterRadius(),
|
||||
entity.setStereotype(Stereotype.build(stereotype, diagram.getSkinParam().getCircledCharacterRadius(),
|
||||
diagram.getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER),
|
||||
diagram.getSkinParam().getIHtmlColorSet()));
|
||||
}
|
||||
|
@ -273,7 +273,7 @@ public class CommandLinkElement extends SingleLineCommand2<DescriptionDiagram> {
|
||||
diagram.getSkinParam().getIHtmlColorSet()));
|
||||
link.applyStyle(diagram.getSkinParam().getThemeStyle(), arg.getLazzy("ARROW_STYLE", 0));
|
||||
if (arg.get("STEREOTYPE", 0) != null) {
|
||||
final Stereotype stereotype = new Stereotype(arg.get("STEREOTYPE", 0));
|
||||
final Stereotype stereotype = Stereotype.build(arg.get("STEREOTYPE", 0));
|
||||
if (UseStyle.useBetaStyle()) {
|
||||
link.setStereotype(stereotype);
|
||||
} else {
|
||||
|
@ -166,7 +166,7 @@ public class CommandPackageWithUSymbol extends SingleLineCommand2<AbstractEntity
|
||||
diagram.getSkinParam().componentStyle(), diagram.getSkinParam().packageStyle()));
|
||||
final String stereotype = arg.getLazzy("STEREOTYPE", 0);
|
||||
if (stereotype != null) {
|
||||
p.setStereotype(new Stereotype(stereotype, false));
|
||||
p.setStereotype(Stereotype.build(stereotype, false));
|
||||
}
|
||||
final String urlString = arg.get("URL", 0);
|
||||
if (urlString != null) {
|
||||
|
@ -90,7 +90,7 @@ public class CommandCreateEntityObject extends SingleLineCommand2<AbstractClassO
|
||||
}
|
||||
final IEntity entity = diagram.createLeaf(ident, code, Display.getWithNewlines(display), LeafType.OBJECT, null);
|
||||
if (stereotype != null) {
|
||||
entity.setStereotype(new Stereotype(stereotype, diagram.getSkinParam().getCircledCharacterRadius(),
|
||||
entity.setStereotype(Stereotype.build(stereotype, diagram.getSkinParam().getCircledCharacterRadius(),
|
||||
diagram.getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER),
|
||||
diagram.getSkinParam().getIHtmlColorSet()));
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ public class CommandCreateEntityObjectMultilines extends CommandMultilines2<Abst
|
||||
}
|
||||
final IEntity entity = diagram.createLeaf(ident, code, Display.getWithNewlines(display), LeafType.OBJECT, null);
|
||||
if (stereotype != null) {
|
||||
entity.setStereotype(new Stereotype(stereotype, diagram.getSkinParam().getCircledCharacterRadius(),
|
||||
entity.setStereotype(Stereotype.build(stereotype, diagram.getSkinParam().getCircledCharacterRadius(),
|
||||
diagram.getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER),
|
||||
diagram.getSkinParam().getIHtmlColorSet()));
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ public class CommandCreateMap extends CommandMultilines2<AbstractClassOrObjectDi
|
||||
}
|
||||
final IEntity entity = diagram.createLeaf(ident, code, Display.getWithNewlines(display), LeafType.MAP, null);
|
||||
if (stereotype != null) {
|
||||
entity.setStereotype(new Stereotype(stereotype, diagram.getSkinParam().getCircledCharacterRadius(),
|
||||
entity.setStereotype(Stereotype.build(stereotype, diagram.getSkinParam().getCircledCharacterRadius(),
|
||||
diagram.getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER),
|
||||
diagram.getSkinParam().getIHtmlColorSet()));
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ public class CommandBoxStart extends SingleLineCommand2<SequenceDiagram> {
|
||||
Stereotype stereotype = null;
|
||||
if (stereo != null) {
|
||||
final ISkinParam skinParam = diagram.getSkinParam();
|
||||
stereotype = new Stereotype(stereo);
|
||||
stereotype = Stereotype.build(stereo);
|
||||
}
|
||||
|
||||
// final HtmlColor color =
|
||||
|
@ -120,7 +120,7 @@ public abstract class CommandParticipant extends SingleLineCommand2<SequenceDiag
|
||||
final ISkinParam skinParam = diagram.getSkinParam();
|
||||
final boolean stereotypePositionTop = skinParam.stereotypePositionTop();
|
||||
final UFont font = skinParam.getFont(null, false, FontParam.CIRCLED_CHARACTER);
|
||||
participant.setStereotype(new Stereotype(stereotype, skinParam.getCircledCharacterRadius(), font,
|
||||
participant.setStereotype(Stereotype.build(stereotype, skinParam.getCircledCharacterRadius(), font,
|
||||
diagram.getSkinParam().getIHtmlColorSet()), stereotypePositionTop);
|
||||
}
|
||||
final String s = arg.get("COLOR", 0);
|
||||
|
@ -123,7 +123,7 @@ public class CommandCreatePackageState extends SingleLineCommand2<StateDiagram>
|
||||
final IEntity p = diagram.getCurrentGroup();
|
||||
final String stereotype = arg.get("STEREOTYPE", 0);
|
||||
if (stereotype != null) {
|
||||
p.setStereotype(new Stereotype(stereotype));
|
||||
p.setStereotype(Stereotype.build(stereotype));
|
||||
}
|
||||
final String urlString = arg.get("URL", 0);
|
||||
if (urlString != null) {
|
||||
|
@ -123,7 +123,7 @@ public class CommandCreateState extends SingleLineCommand2<StateDiagram> {
|
||||
ent.setDisplay(Display.getWithNewlines(display));
|
||||
|
||||
if (stereotype != null) {
|
||||
ent.setStereotype(new Stereotype(stereotype));
|
||||
ent.setStereotype(Stereotype.build(stereotype));
|
||||
}
|
||||
final String urlString = arg.get("URL", 0);
|
||||
if (urlString != null) {
|
||||
|
@ -114,7 +114,7 @@ public class CommandLinkState extends SingleLineCommand2<StateDiagram> {
|
||||
}
|
||||
|
||||
if (arg.get("ENT1", 1) != null) {
|
||||
cl1.setStereotype(new Stereotype(arg.get("ENT1", 1)));
|
||||
cl1.setStereotype(Stereotype.build(arg.get("ENT1", 1)));
|
||||
}
|
||||
if (arg.get("ENT1", 2) != null) {
|
||||
final String s = arg.get("ENT1", 2);
|
||||
@ -122,7 +122,7 @@ public class CommandLinkState extends SingleLineCommand2<StateDiagram> {
|
||||
diagram.getSkinParam().getIHtmlColorSet().getColor(diagram.getSkinParam().getThemeStyle(), s));
|
||||
}
|
||||
if (arg.get("ENT2", 1) != null) {
|
||||
cl2.setStereotype(new Stereotype(arg.get("ENT2", 1)));
|
||||
cl2.setStereotype(Stereotype.build(arg.get("ENT2", 1)));
|
||||
}
|
||||
if (arg.get("ENT2", 2) != null) {
|
||||
final String s = arg.get("ENT2", 2);
|
||||
|
@ -111,17 +111,6 @@ public class PlayerClock extends Player {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
private double getPulseCoef() {
|
||||
if (pulse == 0) {
|
||||
return 0.5;
|
||||
}
|
||||
return 1.0 * pulse / period;
|
||||
}
|
||||
|
||||
private double getOffsetCoef() {
|
||||
return 1.0 * offset / period;
|
||||
}
|
||||
|
||||
public final int getPeriod() {
|
||||
return period;
|
||||
}
|
||||
@ -143,41 +132,53 @@ public class PlayerClock extends Player {
|
||||
|
||||
public UDrawable getPart2() {
|
||||
return new UDrawable() {
|
||||
|
||||
private void drawHline(UGraphic ug, double value1, double value2) {
|
||||
final double x1 = getX(value1);
|
||||
final double x2 = Math.min(ruler.getWidth(), getX(value2));
|
||||
|
||||
final ULine hline = ULine.hline(x2 - x1);
|
||||
ug.apply(UTranslate.dx(x1)).draw(hline);
|
||||
}
|
||||
|
||||
private void drawVline(UGraphic ug, final ULine vline, double value) {
|
||||
ug.apply(new UTranslate(getX(value), ymargin)).draw(vline);
|
||||
}
|
||||
|
||||
private double getX(double value) {
|
||||
return ruler.getPosInPixel(new TimeTick(new BigDecimal(value), TimingFormat.DECIMAL));
|
||||
}
|
||||
|
||||
public void drawU(UGraphic ug) {
|
||||
ug = getContext().apply(ug);
|
||||
ug = ug.apply(UTranslate.dy(getTitleHeight(ug.getStringBounder())));
|
||||
final ULine vline = ULine.vline(getLineHeight(ug.getStringBounder()));
|
||||
int i = 0;
|
||||
double lastx = -Double.MAX_VALUE;
|
||||
while (i < 1000) {
|
||||
final double x = ruler
|
||||
.getPosInPixel(new TimeTick(new BigDecimal(i * period), TimingFormat.DECIMAL));
|
||||
if (x > ruler.getWidth()) {
|
||||
return;
|
||||
}
|
||||
i++;
|
||||
if (x > lastx) {
|
||||
final double dx = x - lastx;
|
||||
|
||||
final ULine hline1 = ULine.hline(dx * getOffsetCoef());
|
||||
final ULine hline2 = ULine.hline(dx * getPulseCoef());
|
||||
final ULine hline3 = ULine.hline(dx * (1 - getPulseCoef() - getOffsetCoef()));
|
||||
|
||||
final double x2 = lastx + dx * getOffsetCoef();
|
||||
final double x3 = lastx + dx * (getOffsetCoef() + getPulseCoef());
|
||||
|
||||
if (offset > 0)
|
||||
ug.apply(new UTranslate(lastx, ymargin + vline.getDY())).draw(hline1);
|
||||
ug.apply(new UTranslate(x2, ymargin)).draw(hline2);
|
||||
ug.apply(new UTranslate(x3, ymargin + vline.getDY())).draw(hline3);
|
||||
|
||||
ug.apply(new UTranslate(x2, ymargin)).draw(vline);
|
||||
ug.apply(new UTranslate(x3, ymargin)).draw(vline);
|
||||
|
||||
}
|
||||
lastx = x;
|
||||
double value = 0;
|
||||
if (offset != 0) {
|
||||
drawHline(ug.apply(UTranslate.dy(ymargin + vline.getDY())), value, offset);
|
||||
value += offset;
|
||||
}
|
||||
if (getX(value) > ruler.getWidth())
|
||||
return;
|
||||
drawVline(ug, vline, value);
|
||||
|
||||
final double vpulse = pulse == 0 ? period / 2.0 : pulse;
|
||||
final double remain = period - vpulse;
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
drawHline(ug.apply(UTranslate.dy(ymargin)), value, value + vpulse);
|
||||
value += vpulse;
|
||||
if (getX(value) > ruler.getWidth())
|
||||
return;
|
||||
drawVline(ug, vline, value);
|
||||
drawHline(ug.apply(UTranslate.dy(ymargin + vline.getDY())), value, value + remain);
|
||||
value += remain;
|
||||
if (getX(value) > ruler.getWidth())
|
||||
return;
|
||||
drawVline(ug, vline, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user