diff --git a/pom.xml b/pom.xml index 0005cf2c7..d6f7bfdb6 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,8 @@ Script Author: Julien Eluard --> - + 4.0.0 net.sourceforge.plantuml diff --git a/skin/debug.skin b/skin/debug.skin index 114cf9021..f477820a4 100644 --- a/skin/debug.skin +++ b/skin/debug.skin @@ -1,4 +1,4 @@ -style root { +root { FontName SansSerif HyperLinkColor red FontColor green @@ -13,57 +13,57 @@ style root { Shadowing 0.0 } -style stereotype { +stereotype { FontColor blue FontSize 8 FontStyle bold } -style title { +title { HorizontalAlignment right FontSize 24 FontColor blue } -style header { +header { HorizontalAlignment center FontSize 26 FontColor purple } -style footer { +footer { HorizontalAlignment left FontSize 28 FontColor red } -style legend { +legend { FontSize 30 BackGroundColor yellow Margin 30 Padding 50 } -style caption { +caption { FontSize 32 } -style element { +element { BackGroundColor #CEFEFE } -style sequenceDiagram { +sequenceDiagram { } -style classDiagram { +classDiagram { } -style activityDiagram { +activityDiagram { } -style group { +group { LineThickness 3.5 BackGroundColor MistyRose LineColor DarkOrange @@ -73,7 +73,7 @@ style group { FontColor red } -style groupHeader { +groupHeader { BackGroundColor tan LineThickness 0.5 LineColor yellow @@ -83,15 +83,15 @@ style groupHeader { FontColor blue } -style lifeLine { +lifeLine { BackGroundColor gold } -style destroy { +destroy { LineColor red } -style reference { +reference { LineColor red FontSize 10 FontStyle bold @@ -100,7 +100,7 @@ style reference { HorizontalAlignment right } -style box { +box { LineThickness 0.1 LineColor FireBrick BackGroundColor PowderBlue @@ -110,7 +110,7 @@ style box { FontColor Maroon } -style separator { +separator { LineColor red BackGroundColor green @@ -119,51 +119,103 @@ style separator { FontColor white } -style delay { +delay { FontSize 22 FontStyle italic } -style participant { +participant { LineThickness 2.5 } -style actor { +actor { LineThickness 0.5 } -style boundary { +boundary { LineThickness 1.5 } -style control { +control { LineThickness 1.5 } -style entity { +entity { LineThickness 1.5 } -style queue { +queue { LineThickness 1.5 } -style database { +database { LineThickness 1.5 } -style collections { +collections { LineThickness 1.5 } -style message { +arrow { + FontSize 13 + LineColor Lime } -style note { +note { BackGroundColor GoldenRod } -style swimlane { +diamond { +} + +swimlane { +} + +activity { + BackgroundColor #33668E + BorderColor #33668E + FontColor #888 + FontName arial } +activityDiagram { + diamond { + BackgroundColor #dae4f1 + BorderColor #33668E + FontColor red + FontName arial + FontSize 5 + } + arrow { + FontColor gold + FontName arial + FontSize 15 + } + partition { + LineColor red + FontColor green + RoundCorner 30 + BackColor PeachPuff + } + note { + FontColor Blue + LineColor yellow + } +} + +circle { + LineColor yellow +} + +activityBar { + LineColor lightGreen +} + +mindmapDiagram { + Padding 10 + Margin 10 +} + +node { +} diff --git a/skin/plantuml.skin b/skin/plantuml.skin index 97c731130..b5c837e0f 100644 --- a/skin/plantuml.skin +++ b/skin/plantuml.skin @@ -1,6 +1,6 @@ -style root { +root { FontName SansSerif - HyperLinkColor red + HyperLinkColor blue FontColor black FontSize 14 FontStyle plain @@ -13,11 +13,11 @@ style root { Shadowing 0.0 } -style stereotype { +stereotype { FontStyle italic } -style title { +title { HorizontalAlignment center FontSize 14 FontStyle bold @@ -27,19 +27,23 @@ style title { BackGroundColor none } -style header { +header { + HorizontalAlignment right + FontSize 10 + FontColor #888888 + BackGroundColor none + LineColor none +} + +footer { HorizontalAlignment center FontSize 10 FontColor #888888 + BackGroundColor none + LineColor none } -style footer { - HorizontalAlignment left - FontSize 10 - FontColor #888888 -} - -style legend { +legend { LineColor black BackGroundColor #DDDDDD FontSize 14 @@ -48,7 +52,7 @@ style legend { Margin 8 } -style caption { +caption { HorizontalAlignment center FontSize 14 Padding 0 @@ -58,21 +62,19 @@ style caption { } -style element { +element { Shadowing 4.0 } -style sequenceDiagram { +sequenceDiagram { } -style classDiagram { +classDiagram { } -style activityDiagram { -} -style group { - BackGroundColor none +group { + BackGroundColor white LineColor black LineThickness 2.0 FontSize 11 @@ -80,7 +82,7 @@ style group { FontStyle bold } -style groupHeader { +groupHeader { BackGroundColor #EEEEEE LineColor black @@ -88,30 +90,38 @@ style groupHeader { FontStyle bold } -style lifeLine { - BackGroundColor none +lifeLine { + BackGroundColor white } -style destroy { +destroy { } -style reference { - LineColor red - FontSize 10 +reference { + FontSize 12 + LineColor black + BackGroundColor while + LineThickness 2.0 + HorizontalAlignment center +} + +referenceHeader { + LineColor black + BackGroundColor #EEEEEE + FontColor black + FontSize 13 FontStyle bold - FontColor blue - BackGroundColor gold - HorizontalAlignment right + LineThickness 2.0 } -style box { +box { BackGroundColor #DDDDDD FontSize 13 FontStyle bold } -style separator { +separator { LineColor black LineThickness 2.0 BackGroundColor #EEEEEE @@ -120,45 +130,116 @@ style separator { FontStyle bold } -style delay { - FontSize 22 - FontStyle italic +delay { + FontSize 11 + FontStyle plain + HorizontalAlignment center } -style participant { +participant { LineThickness 1.5 } -style actor { +actor { LineThickness 2.0 } -style boundary { +boundary { } -style control { +control { } -style entity { +entity { } -style queue { +queue { } -style database { +database { } -style collections { +collections { } -style swimlane { +swimlane { + BackGroundColor none + LineColor black + LineThickness 2 + FontSize 18 } -style message { +diamond { + Shadowing 3.0 +} + +arrow { FontSize 13 } -style note { +note { FontSize 13 BackGroundColor #FBFB77 -} \ No newline at end of file +} + +partition { +} + +circle { +} + +mindmapDiagram { +} + +mindmapDiagram { + node { + Padding 10 + Margin 10 + RoundCorner 25 + LineThickness 1.5 + } + arrow { + LineThickness 1.0 + } +} + + +wbsDiagram { + Padding 10 + Margin 15 + RoundCorner 0 + LineThickness 1.5 + FontSize 12 +} + +activityDiagram { + Shadowing 3.0 +} + +activityDiagram { + activity { + LineThickness 1.5 + Padding 10 + FontSize 12 + RoundCorner 25 + } + partition { + LineColor black + BackgroundColor none + } + diamond { + FontSize 11 + } + arrow { + FontSize 11 + } +} + +activityBar { + LineColor black +} + +circle { + LineColor black + Shadowing 3.0 +} diff --git a/src/net/sourceforge/plantuml/AnnotatedWorker.java b/src/net/sourceforge/plantuml/AnnotatedWorker.java index 1e294f53e..7f7996a1b 100644 --- a/src/net/sourceforge/plantuml/AnnotatedWorker.java +++ b/src/net/sourceforge/plantuml/AnnotatedWorker.java @@ -54,7 +54,7 @@ import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.graphic.USymbol; import net.sourceforge.plantuml.style.SName; import net.sourceforge.plantuml.style.Style; -import net.sourceforge.plantuml.style.StyleDefinition; +import net.sourceforge.plantuml.style.StyleSignature; import net.sourceforge.plantuml.svek.DecorateEntityImage; import net.sourceforge.plantuml.svek.TextBlockBackcolored; import net.sourceforge.plantuml.ugraphic.MinMax; @@ -82,6 +82,10 @@ public class AnnotatedWorker { return (TextBlockBackcolored) result; } + public boolean hasMainFrame() { + return annotated.getMainFrame() != null; + } + public TextBlock addFrame(final TextBlock original) { final Display mainFrame = annotated.getMainFrame(); if (mainFrame == null) { @@ -94,33 +98,37 @@ public class AnnotatedWorker { final double y2 = 10; final SymbolContext symbolContext = new SymbolContext(getSkinParam().getBackgroundColor(), HtmlColorUtils.BLACK) - .withShadow(getSkinParam().shadowing(null)); + .withShadow(getSkinParam().shadowing(null) ? 3 : 0); + final MinMax originalMinMax = TextBlockUtils.getMinMax(original, stringBounder); final TextBlock title = mainFrame.create(new FontConfiguration(getSkinParam(), FontParam.CAPTION, null), HorizontalAlignment.CENTER, getSkinParam()); final Dimension2D dimTitle = title.calculateDimension(stringBounder); - final Dimension2D dimOriginal = original.calculateDimension(stringBounder); - final double width = x1 + Math.max(dimOriginal.getWidth(), dimTitle.getWidth()) + x2; - final double height = dimTitle.getHeight() + y1 + dimOriginal.getHeight() + y2; - final TextBlock result = USymbol.FRAME.asBig(title, HorizontalAlignment.LEFT, TextBlockUtils.empty(0, 0), - width, height, symbolContext, skinParam.getStereotypeAlignment()); + // final Dimension2D dimOriginal = original.calculateDimension(stringBounder); + final double width = x1 + Math.max(originalMinMax.getWidth(), dimTitle.getWidth()) + x2; + final double height = dimTitle.getHeight() + y1 + originalMinMax.getHeight() + y2; + final TextBlock frame = USymbol.FRAME.asBig(title, HorizontalAlignment.LEFT, TextBlockUtils.empty(0, 0), width, + height, symbolContext, skinParam.getStereotypeAlignment()); return new TextBlockBackcolored() { public void drawU(UGraphic ug) { - result.drawU(ug); + frame.drawU(ug.apply(new UTranslate(originalMinMax.getMinX(), 0))); original.drawU(ug.apply(new UTranslate(x1, y1 + dimTitle.getHeight()))); + // original.drawU(ug); } public MinMax getMinMax(StringBounder stringBounder) { - return TextBlockUtils.getMinMax(result, stringBounder); + return TextBlockUtils.getMinMax(this, stringBounder); } public Rectangle2D getInnerPosition(String member, StringBounder stringBounder, InnerStrategy strategy) { - return result.getInnerPosition(member, stringBounder, strategy); + final Rectangle2D rect = original.getInnerPosition(member, stringBounder, strategy); + return new Rectangle2D.Double(rect.getX() + x1, rect.getY() + y1 + dimTitle.getHeight(), + rect.getWidth(), rect.getHeight()); } public Dimension2D calculateDimension(StringBounder stringBounder) { - return result.calculateDimension(stringBounder); + return original.calculateDimension(stringBounder); } public HtmlColor getBackcolor() { @@ -158,7 +166,7 @@ public class AnnotatedWorker { return TextBlockUtils.empty(0, 0); } if (SkinParam.USE_STYLES()) { - final Style style = StyleDefinition.of(SName.root, SName.caption).getMergedStyle( + final Style style = StyleSignature.of(SName.root, SName.caption).getMergedStyle( skinParam.getCurrentStyleBuilder()); return style.createTextBlockBordered(caption.getDisplay(), skinParam.getIHtmlColorSet(), skinParam); } @@ -171,13 +179,18 @@ public class AnnotatedWorker { if (title.isNull()) { return original; } - ISkinParam skinParam = getSkinParam(); - // if (SkinParam.USE_STYLES()) { - // throw new UnsupportedOperationException(); - // } - final FontConfiguration fontConfiguration = new FontConfiguration(skinParam, FontParam.TITLE, null); - final TextBlock block = TextBlockUtils.title(fontConfiguration, title.getDisplay(), skinParam); + final TextBlock block; + if (SkinParam.USE_STYLES()) { + final Style style = StyleSignature.of(SName.root, SName.title).getMergedStyle( + skinParam.getCurrentStyleBuilder()); + block = style.createTextBlockBordered(title.getDisplay(), skinParam.getIHtmlColorSet(), skinParam); + } else { + final ISkinParam skinParam = getSkinParam(); + final FontConfiguration fontConfiguration = new FontConfiguration(skinParam, FontParam.TITLE, null); + block = TextBlockUtils.title(fontConfiguration, title.getDisplay(), skinParam); + } + return DecorateEntityImage.addTop(original, block, HorizontalAlignment.CENTER); } diff --git a/src/net/sourceforge/plantuml/BlockUml.java b/src/net/sourceforge/plantuml/BlockUml.java index 9b448360a..9daf8de32 100644 --- a/src/net/sourceforge/plantuml/BlockUml.java +++ b/src/net/sourceforge/plantuml/BlockUml.java @@ -113,7 +113,7 @@ public class BlockUml { final TimLoader timLoader = new TimLoader(mode.getImportedFiles(), defines, mode.getCharset(), (DefinitionsContainer) mode); timLoader.load(strings); - this.data = timLoader.getResult(); + this.data = timLoader.getResultList(); this.debug = timLoader.getDebug(); this.preprocessorError = timLoader.isPreprocessorError(); } else { diff --git a/src/net/sourceforge/plantuml/FontParam.java b/src/net/sourceforge/plantuml/FontParam.java index cd8cb4eb4..a29fc1215 100644 --- a/src/net/sourceforge/plantuml/FontParam.java +++ b/src/net/sourceforge/plantuml/FontParam.java @@ -39,7 +39,7 @@ import java.awt.Font; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.style.SName; -import net.sourceforge.plantuml.style.StyleDefinition; +import net.sourceforge.plantuml.style.StyleSignature; interface FontParamConstant { String FAMILY = "SansSerif"; @@ -181,15 +181,15 @@ public enum FontParam { return new FontConfiguration(skinParam, this, null); } - public StyleDefinition getStyleDefinition() { + public StyleSignature getStyleDefinition() { if (this == FOOTER) { - return StyleDefinition.of(SName.root, SName.footer); + return StyleSignature.of(SName.root, SName.footer); } if (this == HEADER) { - return StyleDefinition.of(SName.root, SName.header); + return StyleSignature.of(SName.root, SName.header); } if (this == TITLE) { - return StyleDefinition.of(SName.root, SName.title); + return StyleSignature.of(SName.root, SName.title); } System.err.println("Warning " + this); return null; diff --git a/src/net/sourceforge/plantuml/ISkinParam.java b/src/net/sourceforge/plantuml/ISkinParam.java index 0f18a50cd..cd191cae2 100644 --- a/src/net/sourceforge/plantuml/ISkinParam.java +++ b/src/net/sourceforge/plantuml/ISkinParam.java @@ -35,6 +35,8 @@ */ package net.sourceforge.plantuml; +import java.util.Collection; + import net.sourceforge.plantuml.cucadiagram.Rankdir; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.cucadiagram.dot.DotSplines; @@ -177,4 +179,11 @@ public interface ISkinParam extends ISkinSimple { public void muteStyle(Style modifiedStyle); + public Collection getAllSpriteNames(); + + public String getDefaultSkin(); + + public void setDefaultSkin(String newSkin); + + } \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/PSystemBuilder.java b/src/net/sourceforge/plantuml/PSystemBuilder.java index 28d27aaf4..8cb2bec94 100644 --- a/src/net/sourceforge/plantuml/PSystemBuilder.java +++ b/src/net/sourceforge/plantuml/PSystemBuilder.java @@ -38,9 +38,6 @@ package net.sourceforge.plantuml; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; import net.sourceforge.plantuml.acearth.PSystemXearthFactory; import net.sourceforge.plantuml.activitydiagram.ActivityDiagramFactory; @@ -48,7 +45,6 @@ import net.sourceforge.plantuml.activitydiagram3.ActivityDiagramFactory3; import net.sourceforge.plantuml.api.PSystemFactory; import net.sourceforge.plantuml.bpm.BpmDiagramFactory; import net.sourceforge.plantuml.classdiagram.ClassDiagramFactory; -import net.sourceforge.plantuml.command.UmlDiagramFactory; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.compositediagram.CompositeDiagramFactory; import net.sourceforge.plantuml.core.Diagram; @@ -83,11 +79,12 @@ import net.sourceforge.plantuml.oregon.PSystemOregonFactory; import net.sourceforge.plantuml.project3.GanttDiagramFactory; import net.sourceforge.plantuml.salt.PSystemSaltFactory; import net.sourceforge.plantuml.sequencediagram.SequenceDiagramFactory; +import net.sourceforge.plantuml.sprite.ListSpriteDiagramFactory; +import net.sourceforge.plantuml.sprite.PSystemListInternalSpritesFactory; import net.sourceforge.plantuml.statediagram.StateDiagramFactory; import net.sourceforge.plantuml.stats.StatsUtilsIncrement; import net.sourceforge.plantuml.sudoku.PSystemSudokuFactory; import net.sourceforge.plantuml.timingdiagram.TimingDiagramFactory; -import net.sourceforge.plantuml.ugraphic.sprite.PSystemListInternalSpritesFactory; import net.sourceforge.plantuml.version.License; import net.sourceforge.plantuml.version.PSystemLicenseFactory; import net.sourceforge.plantuml.version.PSystemVersionFactory; @@ -148,6 +145,7 @@ public class PSystemBuilder { final List factories = new ArrayList(); factories.add(new PSystemWelcomeFactory()); factories.add(new PSystemColorsFactory()); + factories.add(new ListSpriteDiagramFactory(skinParam)); factories.add(new SequenceDiagramFactory(skinParam)); factories.add(new ClassDiagramFactory(skinParam)); factories.add(new ActivityDiagramFactory(skinParam)); diff --git a/src/net/sourceforge/plantuml/Run.java b/src/net/sourceforge/plantuml/Run.java index 03c25594a..9715273b2 100644 --- a/src/net/sourceforge/plantuml/Run.java +++ b/src/net/sourceforge/plantuml/Run.java @@ -66,12 +66,12 @@ import net.sourceforge.plantuml.objectdiagram.ObjectDiagramFactory; import net.sourceforge.plantuml.png.MetadataTag; import net.sourceforge.plantuml.preproc.Stdlib; import net.sourceforge.plantuml.sequencediagram.SequenceDiagramFactory; +import net.sourceforge.plantuml.sprite.SpriteGrayLevel; +import net.sourceforge.plantuml.sprite.SpriteUtils; import net.sourceforge.plantuml.statediagram.StateDiagramFactory; import net.sourceforge.plantuml.stats.StatsUtils; import net.sourceforge.plantuml.swing.MainWindow2; import net.sourceforge.plantuml.syntax.LanguageDescriptor; -import net.sourceforge.plantuml.ugraphic.sprite.SpriteGrayLevel; -import net.sourceforge.plantuml.ugraphic.sprite.SpriteUtils; import net.sourceforge.plantuml.utils.Cypher; import net.sourceforge.plantuml.version.Version; @@ -479,10 +479,18 @@ public class Run { } final ISourceFileReader sourceFileReader; if (option.getOutputFile() == null) { - sourceFileReader = new SourceFileReader(option.getDefaultDefines(f), f, option.getOutputDir(), - option.getConfig(), option.getCharset(), option.getFileFormatOption()); + File outputDir = option.getOutputDir(); + if (outputDir != null && outputDir.getPath().endsWith("$")) { + final String path = outputDir.getPath(); + outputDir = new File(path.substring(0, path.length() - 1)).getAbsoluteFile(); + sourceFileReader = new SourceFileReaderCopyCat(option.getDefaultDefines(f), f, outputDir, + option.getConfig(), option.getCharset(), option.getFileFormatOption()); + } else { + sourceFileReader = new SourceFileReader(option.getDefaultDefines(f), f, outputDir, option.getConfig(), + option.getCharset(), option.getFileFormatOption()); + } } else { - sourceFileReader = new SourceFileReader2(option.getDefaultDefines(f), f, option.getOutputFile(), + sourceFileReader = new SourceFileReaderHardFile(option.getDefaultDefines(f), f, option.getOutputFile(), option.getConfig(), option.getCharset(), option.getFileFormatOption()); } sourceFileReader.setCheckMetadata(option.isCheckMetadata()); diff --git a/src/net/sourceforge/plantuml/SkinParam.java b/src/net/sourceforge/plantuml/SkinParam.java index 0eed4dcfc..6f75d7f10 100644 --- a/src/net/sourceforge/plantuml/SkinParam.java +++ b/src/net/sourceforge/plantuml/SkinParam.java @@ -64,6 +64,8 @@ import net.sourceforge.plantuml.graphic.SkinParameter; import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.skin.ArrowDirection; import net.sourceforge.plantuml.skin.Padder; +import net.sourceforge.plantuml.sprite.Sprite; +import net.sourceforge.plantuml.sprite.SpriteImage; import net.sourceforge.plantuml.style.FromSkinparamToStyle; import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.style.StyleBuilder; @@ -78,24 +80,77 @@ import net.sourceforge.plantuml.ugraphic.ColorMapperReverse; import net.sourceforge.plantuml.ugraphic.ColorOrder; import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.UStroke; -import net.sourceforge.plantuml.ugraphic.sprite.Sprite; -import net.sourceforge.plantuml.ugraphic.sprite.SpriteImage; public class SkinParam implements ISkinParam { - public static final String DEFAULT_STYLE = "plantuml.skin"; + // private String skin = "debug.skin"; - // public static final String DEFAULT_STYLE = "debug.skin"; - - static public boolean USE_STYLES() { - return USE_STYLE2.get(); - } - - private static ThreadLocal USE_STYLE2 = new ThreadLocal(); + private String skin = "plantuml.skin"; private SkinParam(UmlDiagramType type) { USE_STYLE2.set(false); this.type = type; + if (type == UmlDiagramType.MINDMAP) { + USE_STYLE2.set(true); + } + if (type == UmlDiagramType.WBS) { + USE_STYLE2.set(true); + } + // if (type == UmlDiagramType.SEQUENCE) { + // skin = "debug.skin"; + // USE_STYLE2.set(true); + // } + // if (type == UmlDiagramType.ACTIVITY) { + // skin = "debug.skin"; + // USE_STYLE2.set(true); + // } + } + + private StyleBuilder styleBuilder; + + public StyleBuilder getCurrentStyleBuilder() { + if (styleBuilder == null && SkinParam.USE_STYLES()) { + try { + this.styleBuilder = getCurrentStyleBuilderInternal(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return styleBuilder; + } + + public void muteStyle(Style modifiedStyle) { + if (SkinParam.USE_STYLES()) { + styleBuilder = getCurrentStyleBuilder().muteStyle(modifiedStyle); + } + } + + public String getDefaultSkin() { + return skin; + } + + public void setDefaultSkin(String newSkin) { + this.skin = newSkin; + } + + public StyleBuilder getCurrentStyleBuilderInternal() throws IOException { + final StyleLoader tmp = new StyleLoader(this); + StyleBuilder result = tmp.loadSkin(this.getDefaultSkin()); + if (result == null) { + result = tmp.loadSkin("plantuml.skin"); + } + + return result; + } + + private static ThreadLocal USE_STYLE2 = new ThreadLocal(); + + static public boolean USE_STYLES() { + final Boolean result = USE_STYLE2.get(); + if (result == null) { + return false; + } + return result; } private static final String stereoPatternString = "\\<\\<(.*?)\\>\\>"; @@ -696,6 +751,10 @@ public class SkinParam implements ISkinParam { private final Map sprites = new HashMap(); + public Collection getAllSpriteNames() { + return Collections.unmodifiableCollection(new TreeSet(sprites.keySet())); + } + public void addSprite(String name, Sprite sprite) { sprites.put(name, sprite); } @@ -1123,22 +1182,4 @@ public class SkinParam implements ISkinParam { .withBorderColor(border).withRoundCorner(roundCorner); } - private StyleBuilder styleBuilder; - - public StyleBuilder getCurrentStyleBuilder() { - if (styleBuilder == null && SkinParam.USE_STYLES()) { - try { - this.styleBuilder = StyleLoader.mainStyle(this); - } catch (IOException e) { - e.printStackTrace(); - } - } - return styleBuilder; - } - - public void muteStyle(Style modifiedStyle) { - if (SkinParam.USE_STYLES()) { - styleBuilder = getCurrentStyleBuilder().muteStyle(modifiedStyle); - } - } } diff --git a/src/net/sourceforge/plantuml/SkinParamColors.java b/src/net/sourceforge/plantuml/SkinParamColors.java index 17b0b3002..4233e68eb 100644 --- a/src/net/sourceforge/plantuml/SkinParamColors.java +++ b/src/net/sourceforge/plantuml/SkinParamColors.java @@ -42,6 +42,10 @@ import net.sourceforge.plantuml.graphic.color.Colors; public class SkinParamColors extends SkinParamDelegator { + public final Colors getColors() { + return colors; + } + final private Colors colors; public SkinParamColors(ISkinParam skinParam, Colors colors) { diff --git a/src/net/sourceforge/plantuml/SkinParamDelegator.java b/src/net/sourceforge/plantuml/SkinParamDelegator.java index 05551fd92..cf6f1a8c9 100644 --- a/src/net/sourceforge/plantuml/SkinParamDelegator.java +++ b/src/net/sourceforge/plantuml/SkinParamDelegator.java @@ -35,6 +35,7 @@ */ package net.sourceforge.plantuml; +import java.util.Collection; import java.util.Map; import net.sourceforge.plantuml.cucadiagram.Rankdir; @@ -47,6 +48,7 @@ import net.sourceforge.plantuml.graphic.SkinParameter; import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.skin.ArrowDirection; import net.sourceforge.plantuml.skin.Padder; +import net.sourceforge.plantuml.sprite.Sprite; import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.style.StyleBuilder; import net.sourceforge.plantuml.svek.ConditionEndStyle; @@ -55,7 +57,6 @@ import net.sourceforge.plantuml.svek.PackageStyle; import net.sourceforge.plantuml.ugraphic.ColorMapper; import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.UStroke; -import net.sourceforge.plantuml.ugraphic.sprite.Sprite; public class SkinParamDelegator implements ISkinParam { @@ -342,4 +343,16 @@ public class SkinParamDelegator implements ISkinParam { skinParam.muteStyle(modifiedStyle); } + public Collection getAllSpriteNames() { + return skinParam.getAllSpriteNames(); + } + + public String getDefaultSkin() { + return skinParam.getDefaultSkin(); + } + + public void setDefaultSkin(String newFileName) { + skinParam.setDefaultSkin(newFileName); + } + } diff --git a/src/net/sourceforge/plantuml/SourceFileReaderCopyCat.java b/src/net/sourceforge/plantuml/SourceFileReaderCopyCat.java new file mode 100644 index 000000000..0d7ef2304 --- /dev/null +++ b/src/net/sourceforge/plantuml/SourceFileReaderCopyCat.java @@ -0,0 +1,84 @@ +/* ======================================================================== + * 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; + +import java.io.File; +import java.io.IOException; +import java.util.Collections; +import java.util.List; + +import net.sourceforge.plantuml.preproc.Defines; +import net.sourceforge.plantuml.preproc.FileWithSuffix; + +public class SourceFileReaderCopyCat extends SourceFileReaderAbstract implements ISourceFileReader { + + public SourceFileReaderCopyCat(Defines defines, final File file, File outputDirectory, List config, + String charset, FileFormatOption fileFormatOption) throws IOException { + this.file = file; + this.fileFormatOption = fileFormatOption; + if (file.exists() == false) { + throw new IllegalArgumentException(); + } + final String path = file.getParentFile().getPath(); + // System.err.println("SourceFileReaderCopyCat::path=" + path); + // System.err.println("SourceFileReaderCopyCat::outputDirectory=" + outputDirectory); + this.outputDirectory = new File(outputDirectory, path).getAbsoluteFile(); + if (outputDirectory.exists() == false) { + outputDirectory.mkdirs(); + } + // System.err.println("SourceFileReaderCopyCat=" + this.outputDirectory.getPath() + " " + // + this.outputDirectory.getAbsolutePath()); + builder = new BlockUmlBuilder(config, charset, defines, getReader(charset), file.getAbsoluteFile() + .getParentFile(), FileWithSuffix.getFileName(file)); + } + + @Override + protected SuggestedFile getSuggestedFile(BlockUml blockUml) { + final String newName = blockUml.getFileOrDirname(); + SuggestedFile suggested = null; + if (newName == null) { + suggested = SuggestedFile.fromOutputFile(new File(outputDirectory, file.getName()), + fileFormatOption.getFileFormat(), cpt++); + } else { + suggested = SuggestedFile.fromOutputFile(new File(outputDirectory, newName), + fileFormatOption.getFileFormat(), cpt++); + } + // System.err.println("SourceFileReaderCopyCat::suggested=" + suggested); + suggested.getParentFile().mkdirs(); + return suggested; + } + +} diff --git a/src/net/sourceforge/plantuml/SourceFileReader2.java b/src/net/sourceforge/plantuml/SourceFileReaderHardFile.java similarity index 85% rename from src/net/sourceforge/plantuml/SourceFileReader2.java rename to src/net/sourceforge/plantuml/SourceFileReaderHardFile.java index e79f1440e..3f9a74003 100644 --- a/src/net/sourceforge/plantuml/SourceFileReader2.java +++ b/src/net/sourceforge/plantuml/SourceFileReaderHardFile.java @@ -42,9 +42,9 @@ import java.util.List; import net.sourceforge.plantuml.preproc.Defines; import net.sourceforge.plantuml.preproc.FileWithSuffix; -public class SourceFileReader2 extends SourceFileReaderAbstract implements ISourceFileReader { +public class SourceFileReaderHardFile extends SourceFileReaderAbstract implements ISourceFileReader { - public SourceFileReader2(Defines defines, final File file, File outputFile, List config, String charset, + public SourceFileReaderHardFile(Defines defines, final File file, File outputFile, List config, String charset, FileFormatOption fileFormatOption) throws IOException { this.file = file; this.fileFormatOption = fileFormatOption; @@ -54,8 +54,9 @@ public class SourceFileReader2 extends SourceFileReaderAbstract implements ISour } FileSystem.getInstance().setCurrentDir(file.getAbsoluteFile().getParentFile()); - builder = new BlockUmlBuilder(config, charset, defines, getReader(charset), file.getAbsoluteFile() - .getParentFile(), FileWithSuffix.getFileName(file)); + final File parentFile = file.getAbsoluteFile().getParentFile(); + builder = new BlockUmlBuilder(config, charset, defines, getReader(charset), parentFile, + FileWithSuffix.getFileName(file)); } @Override diff --git a/src/net/sourceforge/plantuml/SpriteContainer.java b/src/net/sourceforge/plantuml/SpriteContainer.java index 97b3c111d..4b630aa4f 100644 --- a/src/net/sourceforge/plantuml/SpriteContainer.java +++ b/src/net/sourceforge/plantuml/SpriteContainer.java @@ -35,7 +35,7 @@ */ package net.sourceforge.plantuml; -import net.sourceforge.plantuml.ugraphic.sprite.Sprite; +import net.sourceforge.plantuml.sprite.Sprite; public interface SpriteContainer { diff --git a/src/net/sourceforge/plantuml/SpriteContainerEmpty.java b/src/net/sourceforge/plantuml/SpriteContainerEmpty.java index f131b72ef..b217641d1 100644 --- a/src/net/sourceforge/plantuml/SpriteContainerEmpty.java +++ b/src/net/sourceforge/plantuml/SpriteContainerEmpty.java @@ -40,10 +40,10 @@ import java.util.Map; import net.sourceforge.plantuml.creole.CommandCreoleMonospaced; import net.sourceforge.plantuml.graphic.HtmlColorSetSimple; import net.sourceforge.plantuml.graphic.IHtmlColorSet; +import net.sourceforge.plantuml.sprite.Sprite; +import net.sourceforge.plantuml.sprite.SpriteImage; import net.sourceforge.plantuml.ugraphic.ColorMapper; import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity; -import net.sourceforge.plantuml.ugraphic.sprite.Sprite; -import net.sourceforge.plantuml.ugraphic.sprite.SpriteImage; public class SpriteContainerEmpty implements SpriteContainer, ISkinSimple { diff --git a/src/net/sourceforge/plantuml/StringLocated.java b/src/net/sourceforge/plantuml/StringLocated.java index e0949efc4..e29c77b0f 100644 --- a/src/net/sourceforge/plantuml/StringLocated.java +++ b/src/net/sourceforge/plantuml/StringLocated.java @@ -49,7 +49,7 @@ final public class StringLocated { @Override public String toString() { - return super.toString() + " " + s; + return s; } public StringLocated(String s, LineLocation location, String preprocessorError) { diff --git a/src/net/sourceforge/plantuml/UmlDiagram.java b/src/net/sourceforge/plantuml/UmlDiagram.java index e177a673c..b3850c9e6 100644 --- a/src/net/sourceforge/plantuml/UmlDiagram.java +++ b/src/net/sourceforge/plantuml/UmlDiagram.java @@ -77,6 +77,7 @@ import net.sourceforge.plantuml.graphic.HtmlColorUtils; import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.mjpeg.MJPEGGenerator; import net.sourceforge.plantuml.pdf.PdfConverter; +import net.sourceforge.plantuml.sprite.Sprite; import net.sourceforge.plantuml.svek.EmptySvgException; import net.sourceforge.plantuml.svek.GraphvizCrash; import net.sourceforge.plantuml.svek.TextBlockBackcolored; @@ -85,7 +86,6 @@ import net.sourceforge.plantuml.ugraphic.ImageBuilder; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UImage; import net.sourceforge.plantuml.ugraphic.UTranslate; -import net.sourceforge.plantuml.ugraphic.sprite.Sprite; import net.sourceforge.plantuml.version.Version; public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annotated, WithSprite { @@ -406,39 +406,40 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot return useJDot; } - public CommandExecutionResult loadSkin(String filename) throws IOException { - - final String res = "/skin/" + filename + ".skin"; - final InputStream internalIs = UmlDiagram.class.getResourceAsStream(res); - if (internalIs != null) { - final BlocLines lines2 = BlocLines.load(internalIs, new LineLocationImpl(filename, null)); - return loadSkinInternal(lines2); - } - if (OptionFlags.ALLOW_INCLUDE == false) { - return CommandExecutionResult.ok(); - } - final File f = FileSystem.getInstance().getFile(filename + ".skin"); - if (f == null || f.exists() == false || f.canRead() == false) { - return CommandExecutionResult.error("Cannot load skin from " + filename); - } - final BlocLines lines = BlocLines.load(f, new LineLocationImpl(f.getName(), null)); - return loadSkinInternal(lines); - } - - private CommandExecutionResult loadSkinInternal(final BlocLines lines) { - final CommandSkinParam cmd1 = new CommandSkinParam(); - final CommandSkinParamMultilines cmd2 = new CommandSkinParamMultilines(); - for (int i = 0; i < lines.size(); i++) { - final BlocLines ext1 = lines.subList(i, i + 1); - if (cmd1.isValid(ext1) == CommandControl.OK) { - cmd1.execute(this, ext1); - } else if (cmd2.isValid(ext1) == CommandControl.OK_PARTIAL) { - i = tryMultilines(cmd2, i, lines); - } - } + public CommandExecutionResult loadSkin(String newSkin) throws IOException { + getSkinParam().setDefaultSkin(newSkin + ".skin"); return CommandExecutionResult.ok(); + // final String res = "/skin/" + filename + ".skin"; + // final InputStream internalIs = UmlDiagram.class.getResourceAsStream(res); + // if (internalIs != null) { + // final BlocLines lines2 = BlocLines.load(internalIs, new LineLocationImpl(filename, null)); + // return loadSkinInternal(lines2); + // } + // if (OptionFlags.ALLOW_INCLUDE == false) { + // return CommandExecutionResult.ok(); + // } + // final File f = FileSystem.getInstance().getFile(filename + ".skin"); + // if (f == null || f.exists() == false || f.canRead() == false) { + // return CommandExecutionResult.error("Cannot load skin from " + filename); + // } + // final BlocLines lines = BlocLines.load(f, new LineLocationImpl(f.getName(), null)); + // return loadSkinInternal(lines); } + // private CommandExecutionResult loadSkinInternal(final BlocLines lines) { + // final CommandSkinParam cmd1 = new CommandSkinParam(); + // final CommandSkinParamMultilines cmd2 = new CommandSkinParamMultilines(); + // for (int i = 0; i < lines.size(); i++) { + // final BlocLines ext1 = lines.subList(i, i + 1); + // if (cmd1.isValid(ext1) == CommandControl.OK) { + // cmd1.execute(this, ext1); + // } else if (cmd2.isValid(ext1) == CommandControl.OK_PARTIAL) { + // i = tryMultilines(cmd2, i, lines); + // } + // } + // return CommandExecutionResult.ok(); + // } + private int tryMultilines(CommandSkinParamMultilines cmd2, int i, BlocLines lines) { for (int j = i + 1; j <= lines.size(); j++) { final BlocLines ext1 = lines.subList(i, j); @@ -451,9 +452,8 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot } return i; } - + public void setHideEmptyDescription(boolean hideEmptyDescription) { } - } diff --git a/src/net/sourceforge/plantuml/WithSprite.java b/src/net/sourceforge/plantuml/WithSprite.java index c06ebde3f..56ce8c938 100644 --- a/src/net/sourceforge/plantuml/WithSprite.java +++ b/src/net/sourceforge/plantuml/WithSprite.java @@ -36,7 +36,7 @@ package net.sourceforge.plantuml; import net.sourceforge.plantuml.core.Diagram; -import net.sourceforge.plantuml.ugraphic.sprite.Sprite; +import net.sourceforge.plantuml.sprite.Sprite; public interface WithSprite extends Diagram { diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandPartition.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandPartition.java index 3a59f2961..62a19d23a 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/command/CommandPartition.java +++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandPartition.java @@ -51,6 +51,7 @@ import net.sourceforge.plantuml.cucadiagram.GroupType; import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.cucadiagram.IGroup; import net.sourceforge.plantuml.cucadiagram.NamespaceStrategy; +import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.color.ColorParser; import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.graphic.color.Colors; @@ -71,7 +72,9 @@ public class CommandPartition extends SingleLineCommand2 { color().getRegex(), // new RegexLeaf("LEGACYCOLORIGNORED", "(#[0-9a-fA-F]{6}|#?\\w+)?")), // RegexLeaf.spaceZeroOrMore(), // - new RegexLeaf("\\{?"), + new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), // + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("\\{?"), // RegexLeaf.end()); } @@ -91,12 +94,10 @@ public class CommandPartition extends SingleLineCommand2 { if (colors.isEmpty() == false) { p.setColors(colors); } + if (arg.get("STEREOTYPE", 0) != null) { + p.setStereotype(new Stereotype(arg.get("STEREOTYPE", 0))); + } - // final String color = arg.get("COLOR", 0); - // if (color != null) { - // p.setSpecificColorTOBEREMOVED(ColorType.BACK, - // diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(color)); - // } return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/Branch.java b/src/net/sourceforge/plantuml/activitydiagram3/Branch.java index 524c7b797..79b742408 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/Branch.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/Branch.java @@ -38,6 +38,7 @@ package net.sourceforge.plantuml.activitydiagram3; import java.util.Collection; import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; @@ -48,6 +49,11 @@ import net.sourceforge.plantuml.graphic.Rainbow; import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.sequencediagram.NotePosition; import net.sourceforge.plantuml.sequencediagram.NoteType; +import net.sourceforge.plantuml.style.PName; +import net.sourceforge.plantuml.style.SName; +import net.sourceforge.plantuml.style.Style; +import net.sourceforge.plantuml.style.StyleBuilder; +import net.sourceforge.plantuml.style.StyleSignature; public class Branch { @@ -60,11 +66,20 @@ public class Branch { private Ftile ftile; + public StyleSignature getDefaultStyleDefinitionArrow() { + return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.arrow); + } + + public StyleSignature getDefaultStyleDefinitionDiamond() { + return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.activity, SName.diamond); + } + public boolean containsBreak() { return list.containsBreak(); } - public Branch(Swimlane swimlane, Display labelPositive, Display labelTest, HtmlColor color, Display inlabel) { + public Branch(StyleBuilder styleBuilder, Swimlane swimlane, Display labelPositive, Display labelTest, + HtmlColor color, Display inlabel) { if (labelPositive == null) { throw new IllegalArgumentException(); } @@ -74,11 +89,18 @@ public class Branch { if (inlabel == null) { throw new IllegalArgumentException(); } + if (SkinParam.USE_STYLES()) { + final Style style = getDefaultStyleDefinitionDiamond().getMergedStyle(styleBuilder); + this.color = color == null ? style.value(PName.BackGroundColor).asColor( + styleBuilder.getSkinParam().getIHtmlColorSet()) : color; + } else { + this.color = color; + } + this.inlabel = inlabel; this.list = new InstructionList(swimlane); this.labelTest = labelTest; this.labelPositive = labelPositive; - this.color = color; } public Collection getWeldingPoints() { @@ -166,5 +188,4 @@ public class Branch { return special; } - } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionFork.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionFork.java index 667885667..fcfb5a412 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionFork.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionFork.java @@ -91,7 +91,7 @@ public class InstructionFork extends WithNote implements Instruction { for (InstructionList list : forks) { all.add(list.createFtile(factory)); } - Ftile result = factory.createParallel(getSwimlaneIn(), all, style, label); + Ftile result = factory.createParallel(all, style, label); if (getPositionedNotes().size() > 0) { result = FtileWithNoteOpale.create(result, getPositionedNotes(), skinParam, false); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java index 739306570..b19a94c39 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java @@ -93,7 +93,8 @@ public class InstructionIf extends WithNote implements Instruction, InstructionC throw new IllegalArgumentException(); } this.swimlane = swimlane; - this.thens.add(new Branch(swimlane, whenThen, labelTest, color, Display.NULL)); + this.thens.add(new Branch(skinParam.getCurrentStyleBuilder(), swimlane, whenThen, labelTest, color, + Display.NULL)); this.current = this.thens.get(0); } @@ -106,7 +107,8 @@ public class InstructionIf extends WithNote implements Instruction, InstructionC branch.updateFtile(factory); } if (elseBranch == null) { - this.elseBranch = new Branch(swimlane, Display.NULL, Display.NULL, null, Display.NULL); + this.elseBranch = new Branch(skinParam.getCurrentStyleBuilder(), swimlane, Display.NULL, Display.NULL, + null, Display.NULL); } elseBranch.updateFtile(factory); Ftile result = factory.createIf(swimlane, thens, elseBranch, afterEndwhile, topInlinkRendering, url); @@ -133,7 +135,8 @@ public class InstructionIf extends WithNote implements Instruction, InstructionC return false; } this.current.setInlinkRendering(nextLinkRenderer); - this.elseBranch = new Branch(swimlane, whenElse, Display.NULL, null, Display.NULL); + this.elseBranch = new Branch(skinParam.getCurrentStyleBuilder(), swimlane, whenElse, Display.NULL, null, + Display.NULL); this.current = elseBranch; return true; } @@ -145,7 +148,7 @@ public class InstructionIf extends WithNote implements Instruction, InstructionC } // this.current.setInlinkRendering(nextLinkRenderer); this.current.setSpecial(nextLinkRenderer); - this.current = new Branch(swimlane, whenThen, test, color, inlabel); + this.current = new Branch(skinParam.getCurrentStyleBuilder(), swimlane, whenThen, test, color, inlabel); this.thens.add(current); return true; @@ -154,7 +157,8 @@ public class InstructionIf extends WithNote implements Instruction, InstructionC public void endif(LinkRendering nextLinkRenderer) { endifCalled = true; if (elseBranch == null) { - this.elseBranch = new Branch(swimlane, Display.NULL, Display.NULL, null, Display.NULL); + this.elseBranch = new Branch(skinParam.getCurrentStyleBuilder(), swimlane, Display.NULL, Display.NULL, + null, Display.NULL); } this.elseBranch.setSpecial(nextLinkRenderer); this.current.setInlinkRendering(nextLinkRenderer); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionSplit.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionSplit.java index c6abe32ea..4254b79f0 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionSplit.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionSplit.java @@ -88,7 +88,7 @@ public class InstructionSplit implements Instruction { for (InstructionList list : splits) { all.add(list.createFtile(factory)); } - return factory.createParallel(getSwimlaneIn(), all, ForkStyle.SPLIT, null); + return factory.createParallel(all, ForkStyle.SPLIT, null); } public Instruction getParent() { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionSwitch.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionSwitch.java index a1a973a39..63ca781e4 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionSwitch.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionSwitch.java @@ -137,7 +137,7 @@ public class InstructionSwitch extends WithNote implements Instruction, Instruct } public boolean switchCase(Display labelCase, LinkRendering nextLinkRenderer) { - this.current = new Branch(swimlane, labelCase, labelCase, null, labelCase); + this.current = new Branch(skinParam.getCurrentStyleBuilder(), swimlane, labelCase, labelCase, null, labelCase); this.branches.add(this.current); return true; } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivity3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivity3.java index 88e2f04b5..5a44f1d5b 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivity3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivity3.java @@ -35,6 +35,7 @@ */ package net.sourceforge.plantuml.activitydiagram3.command; +import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.UrlBuilder; @@ -48,6 +49,7 @@ import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.color.ColorParser; import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.graphic.color.Colors; @@ -65,6 +67,8 @@ public class CommandActivity3 extends SingleLineCommand2 { new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), // color().getRegex(), // RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("STEREO", "(\\<{2}.*\\>{2})?"), // + RegexLeaf.spaceZeroOrMore(), // new RegexLeaf(":"), // new RegexLeaf("LABEL", "(.*)"), // new RegexLeaf("STYLE", ENDING_GROUP), // @@ -86,7 +90,12 @@ public class CommandActivity3 extends SingleLineCommand2 { url = urlBuilder.getUrl(arg.get("URL", 0)); } - final Colors colors = color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet()); + Colors colors = color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet()); + final String stereo = arg.get("STEREO", 0); + if (stereo != null) { + final Stereotype stereotype = new Stereotype(stereo); + colors = colors.applyStereotype(stereotype, diagram.getSkinParam(), ColorParam.activityBackground); + } final BoxStyle style = BoxStyle.fromChar(arg.get("STYLE", 0).charAt(0)); diagram.addActivity(Display.getWithNewlines(arg.get("LABEL", 0)), style, url, colors); return CommandExecutionResult.ok(); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandArrowLong3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandArrowLong3.java index 3c7397c1c..4cedf4c5a 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandArrowLong3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandArrowLong3.java @@ -75,7 +75,7 @@ public class CommandArrowLong3 extends CommandMultilines2 { lines = lines.removeEmptyColumns(); final RegexResult line0 = getStartingPattern().matcher(lines.getFirst499().getTrimmed().getString()); // final HtmlColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(line0.get("COLOR", 0)); - // diagram.setColorNextArrow(HtmlColorAndStyle.fromColor(color)); + // diagram.setColorNextArrow(Rainbow.fromColor(color)); final String colorString = line0.get("COLOR", 0); if (colorString != null) { Rainbow rainbow = Rainbow.build(diagram.getSkinParam(), colorString, diagram.getSkinParam() diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandLink3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandLink3.java index c2f364433..b4b99b2df 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandLink3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandLink3.java @@ -44,7 +44,7 @@ import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.HtmlColorAndStyle; +import net.sourceforge.plantuml.graphic.Rainbow; public class CommandLink3 extends SingleLineCommand2 { @@ -65,7 +65,7 @@ public class CommandLink3 extends SingleLineCommand2 { protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) { final HtmlColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0)); if (color != null) { - diagram.setColorNextArrow(HtmlColorAndStyle.fromColor(color)); + diagram.setColorNextArrow(Rainbow.fromColor(color)); } return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandPartition3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandPartition3.java index aa4478fe4..77d479830 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandPartition3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandPartition3.java @@ -37,6 +37,7 @@ package net.sourceforge.plantuml.activitydiagram3.command; import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.LineLocation; +import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; import net.sourceforge.plantuml.command.CommandExecutionResult; @@ -54,6 +55,10 @@ import net.sourceforge.plantuml.graphic.USymbol; import net.sourceforge.plantuml.graphic.color.ColorParser; import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.graphic.color.Colors; +import net.sourceforge.plantuml.style.PName; +import net.sourceforge.plantuml.style.SName; +import net.sourceforge.plantuml.style.Style; +import net.sourceforge.plantuml.style.StyleSignature; public class CommandPartition3 extends SingleLineCommand2 { @@ -126,20 +131,33 @@ public class CommandPartition3 extends SingleLineCommand2 { final HtmlColor backColorInSkinparam = diagram.getSkinParam().getHtmlColor(getColorParamBack(symbol), stereotype, false); - final HtmlColor backColor; + HtmlColor backColor; if (backColorInSkinparam == null) { backColor = colors.getColor(ColorType.BACK); } else { backColor = backColorInSkinparam; } - final HtmlColor titleColor = colors.getColor(ColorType.HEADER); + HtmlColor titleColor = colors.getColor(ColorType.HEADER); // Warning : titleColor unused in FTileGroupW HtmlColor borderColor = diagram.getSkinParam().getHtmlColor(getColorParamBorder(symbol), stereotype, false); if (borderColor == null) { borderColor = HtmlColorUtils.BLACK; } - final double roundCorner = symbol.getSkinParameter().getRoundCorner(diagram.getSkinParam(), stereotype); + double roundCorner = symbol.getSkinParameter().getRoundCorner(diagram.getSkinParam(), stereotype); + + if (SkinParam.USE_STYLES()) { + final Style stylePartition = getDefaultStyleDefinitionPartition().getMergedStyle( + diagram.getSkinParam().getCurrentStyleBuilder()); + borderColor = stylePartition.value(PName.LineColor).asColor(diagram.getSkinParam().getIHtmlColorSet()); + backColor = colors.getColor(ColorType.BACK); + if (backColor == null) { + backColor = stylePartition.value(PName.BackGroundColor).asColor( + diagram.getSkinParam().getIHtmlColorSet()); + } + titleColor = HtmlColorUtils.BLUE;// stylePartition.value(PName.FontColor).asColor(diagram.getSkinParam().getIHtmlColorSet()); + roundCorner = stylePartition.value(PName.RoundCorner).asDouble(); + } diagram.startGroup(Display.getWithNewlines(partitionTitle), backColor, titleColor, borderColor, symbol, roundCorner); @@ -147,4 +165,8 @@ public class CommandPartition3 extends SingleLineCommand2 { return CommandExecutionResult.ok(); } + final public StyleSignature getDefaultStyleDefinitionPartition() { + return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.partition); + } + } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/AbstractFtile.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/AbstractFtile.java index 79f90cb9a..0977926b7 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/AbstractFtile.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/AbstractFtile.java @@ -45,6 +45,7 @@ import net.sourceforge.plantuml.LineParam; import net.sourceforge.plantuml.activitydiagram3.LinkRendering; import net.sourceforge.plantuml.graphic.AbstractTextBlock; import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.graphic.IHtmlColorSet; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.ugraphic.MinMax; import net.sourceforge.plantuml.ugraphic.UStroke; @@ -65,6 +66,10 @@ public abstract class AbstractFtile extends AbstractTextBlock implements Ftile { return skinParam; } + final public IHtmlColorSet getIHtmlColorSet() { + return skinParam.getIHtmlColorSet(); + } + public LinkRendering getInLinkRendering() { return LinkRendering.none(); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/BoxStyle.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/BoxStyle.java index 22e7afc37..4bddf93a3 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/BoxStyle.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/BoxStyle.java @@ -49,13 +49,13 @@ import net.sourceforge.plantuml.ugraphic.UTranslate; public enum BoxStyle { PLAIN { @Override - protected Shadowable getShape(double width, double height) { - return new URectangle(width, height, CORNER, CORNER); + protected Shadowable getShape(double width, double height, double roundCorner) { + return new URectangle(width, height, roundCorner, roundCorner); } }, SDL_INPUT('<') { @Override - protected Shadowable getShape(double width, double height) { + protected Shadowable getShape(double width, double height, double roundCorner) { final UPolygon result = new UPolygon(); result.addPoint(0, 0); result.addPoint(width + DELTA_INPUT_OUTPUT, 0); @@ -67,7 +67,7 @@ public enum BoxStyle { }, SDL_OUTPUT('>') { @Override - protected Shadowable getShape(double width, double height) { + protected Shadowable getShape(double width, double height, double roundCorner) { final UPolygon result = new UPolygon(); result.addPoint(0.0, 0.0); result.addPoint(width, 0.0); @@ -79,11 +79,9 @@ public enum BoxStyle { }, SDL_PROCEDURE('|') { @Override - protected void drawInternal(UGraphic ug, double width, double height, boolean shadowing) { + protected void drawInternal(UGraphic ug, double width, double height, double shadowing, double roundCorner) { final URectangle rect = new URectangle(width, height); - if (shadowing) { - rect.setDeltaShadow(3); - } + rect.setDeltaShadow(shadowing); ug.draw(rect); final ULine vline = new ULine(0, height); ug.apply(new UTranslate(PADDING, 0)).draw(vline); @@ -92,7 +90,7 @@ public enum BoxStyle { }, SDL_SAVE('\\') { @Override - protected Shadowable getShape(double width, double height) { + protected Shadowable getShape(double width, double height, double roundCorner) { final UPolygon result = new UPolygon(); result.addPoint(0.0, 0.0); result.addPoint(width - DELTA_INPUT_OUTPUT, 0.0); @@ -103,7 +101,7 @@ public enum BoxStyle { }, SDL_ANTISAVE('/') { @Override - protected Shadowable getShape(double width, double height) { + protected Shadowable getShape(double width, double height, double roundCorner) { final UPolygon result = new UPolygon(); result.addPoint(DELTA_INPUT_OUTPUT, 0.0); result.addPoint(width, 0.0); @@ -114,7 +112,7 @@ public enum BoxStyle { }, SDL_CONTINUOUS('}') { @Override - protected Shadowable getShape(double width, double height) { + protected Shadowable getShape(double width, double height, double roundCorner) { final UPath result = new UPath(); final double c1[] = { DELTA_CONTINUOUS, 0 }; final double c2[] = { 0, height / 2 }; @@ -136,12 +134,11 @@ public enum BoxStyle { }, SDL_TASK(']') { @Override - protected Shadowable getShape(double width, double height) { + protected Shadowable getShape(double width, double height, double roundCorner) { return new URectangle(width, height); } }; - private static final int CORNER = 25; private final char style; private static int DELTA_INPUT_OUTPUT = 10; private static double DELTA_CONTINUOUS = 5.0; @@ -164,23 +161,22 @@ public enum BoxStyle { return PLAIN; } - public final UDrawable getUDrawable(final double width, final double height, final boolean shadowing) { + public final UDrawable getUDrawable(final double width, final double height, final double shadowing, + final double roundCorner) { return new UDrawable() { public void drawU(UGraphic ug) { - drawInternal(ug, width, height, shadowing); + drawInternal(ug, width, height, shadowing, roundCorner); } }; } - protected Shadowable getShape(double width, double height) { + protected Shadowable getShape(double width, double height, double roundCorner) { return null; } - protected void drawInternal(UGraphic ug, double width, double height, boolean shadowing) { - final Shadowable s = getShape(width, height); - if (shadowing) { - s.setDeltaShadow(3); - } + protected void drawInternal(UGraphic ug, double width, double height, double shadowing, double roundCorner) { + final Shadowable s = getShape(width, height, roundCorner); + s.setDeltaShadow(shadowing); ug.draw(s); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/Diamond.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Diamond.java index 07db26bc9..514cebb8d 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/Diamond.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Diamond.java @@ -46,7 +46,7 @@ public class Diamond { final static public double diamondHalfSize = 12; - public static UPolygon asPolygon(boolean shadowing) { + public static UPolygon asPolygon(double shadowing) { final UPolygon diams = new UPolygon(); diams.addPoint(diamondHalfSize, 0); @@ -55,14 +55,15 @@ public class Diamond { diams.addPoint(0, diamondHalfSize); diams.addPoint(diamondHalfSize, 0); - if (shadowing) { - diams.setDeltaShadow(3); - } + // if (shadowing) { + // diams.setDeltaShadow(3); + // } + diams.setDeltaShadow(shadowing); return diams; } - public static UPolygon asPolygon(boolean shadowing, double width, double height) { + public static UPolygon asPolygon(double shadowing, double width, double height) { final UPolygon diams = new UPolygon(); diams.addPoint(diamondHalfSize, 0); @@ -73,9 +74,10 @@ public class Diamond { diams.addPoint(0, height / 2); diams.addPoint(diamondHalfSize, 0); - if (shadowing) { - diams.setDeltaShadow(3); - } + // if (shadowing) { + // diams.setDeltaShadow(3); + // } + diams.setDeltaShadow(shadowing); return diams; } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/EntityImageLegend.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/EntityImageLegend.java index 78ff7379f..28e07855b 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/EntityImageLegend.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/EntityImageLegend.java @@ -38,18 +38,14 @@ package net.sourceforge.plantuml.activitydiagram3.ftile; import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; -import net.sourceforge.plantuml.ISkinSimple; import net.sourceforge.plantuml.LineParam; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.IHtmlColorSet; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.skin.rose.Rose; -import net.sourceforge.plantuml.style.PName; -import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.ugraphic.UStroke; public class EntityImageLegend { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactory.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactory.java index 8683a4a74..4134c680a 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactory.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactory.java @@ -90,7 +90,7 @@ public interface FtileFactory { public Ftile createSwitch(Swimlane swimlane, List branches, LinkRendering afterEndwhile, LinkRendering topInlinkRendering, Display labelTest); - public Ftile createParallel(Swimlane swimlane, List all, ForkStyle style, String label); + public Ftile createParallel(List all, ForkStyle style, String label); public Ftile createGroup(Ftile list, Display name, HtmlColor backColor, HtmlColor titleColor, PositionedNote note, HtmlColor borderColor, USymbol type, double roundCorner); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactoryDelegator.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactoryDelegator.java index fcbf080c9..0198b0265 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactoryDelegator.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactoryDelegator.java @@ -40,6 +40,7 @@ import java.util.List; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.activitydiagram3.Branch; import net.sourceforge.plantuml.activitydiagram3.ForkStyle; @@ -51,13 +52,15 @@ import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.HtmlColorAndStyle; import net.sourceforge.plantuml.graphic.Rainbow; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.USymbol; import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.skin.rose.Rose; +import net.sourceforge.plantuml.style.SName; +import net.sourceforge.plantuml.style.Style; +import net.sourceforge.plantuml.style.StyleSignature; public class FtileFactoryDelegator implements FtileFactory { @@ -65,16 +68,40 @@ public class FtileFactoryDelegator implements FtileFactory { private final Rose rose = new Rose(); + final public StyleSignature getDefaultStyleDefinitionActivity() { + return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.activity); + } + + final public StyleSignature getDefaultStyleDefinitionDiamond() { + return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.activity, SName.diamond); + } + + final public StyleSignature getDefaultStyleDefinitionArrow() { + return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.arrow); + } + protected final Rainbow getInLinkRenderingColor(Ftile tile) { Rainbow color; final LinkRendering linkRendering = tile.getInLinkRendering(); if (linkRendering == null) { - color = HtmlColorAndStyle.build(skinParam()); + if (SkinParam.USE_STYLES()) { + final Style style = getDefaultStyleDefinitionArrow().getMergedStyle( + skinParam().getCurrentStyleBuilder()); + return Rainbow.build(style, skinParam().getIHtmlColorSet()); + } else { + color = Rainbow.build(skinParam()); + } } else { color = linkRendering.getRainbow(); } if (color.size() == 0) { - color = HtmlColorAndStyle.build(skinParam()); + if (SkinParam.USE_STYLES()) { + final Style style = getDefaultStyleDefinitionArrow().getMergedStyle( + skinParam().getCurrentStyleBuilder()); + return Rainbow.build(style, skinParam().getIHtmlColorSet()); + } else { + color = Rainbow.build(skinParam()); + } } return color; } @@ -84,7 +111,13 @@ public class FtileFactoryDelegator implements FtileFactory { if (Display.isNull(display)) { return null; } - final FontConfiguration fontConfiguration = new FontConfiguration(skinParam(), FontParam.ARROW, null); + final FontConfiguration fontConfiguration; + if (SkinParam.USE_STYLES()) { + final Style style = getDefaultStyleDefinitionArrow().getMergedStyle(skinParam().getCurrentStyleBuilder()); + fontConfiguration = style.getFontConfiguration(skinParam().getIHtmlColorSet()); + } else { + fontConfiguration = new FontConfiguration(skinParam(), FontParam.ARROW, null); + } return display.create(fontConfiguration, HorizontalAlignment.LEFT, skinParam(), CreoleMode.SIMPLE_LINE); } @@ -168,8 +201,8 @@ public class FtileFactoryDelegator implements FtileFactory { return factory.createSwitch(swimlane, branches, afterEndwhile, topInlinkRendering, labelTest); } - public Ftile createParallel(Swimlane swimlane, List all, ForkStyle style, String label) { - return factory.createParallel(swimlane, all, style, label); + public Ftile createParallel(List all, ForkStyle style, String label) { + return factory.createParallel(all, style, label); } public Ftile createGroup(Ftile list, Display name, HtmlColor backColor, HtmlColor titleColor, PositionedNote note, diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/SwimlanesA.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/SwimlanesA.java index 09c9b6adc..7554fe81c 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/SwimlanesA.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/SwimlanesA.java @@ -41,7 +41,6 @@ import java.util.List; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.Pragma; -import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.activitydiagram3.Instruction; import net.sourceforge.plantuml.activitydiagram3.InstructionList; import net.sourceforge.plantuml.activitydiagram3.LinkRendering; @@ -66,7 +65,7 @@ import net.sourceforge.plantuml.graphic.UGraphicDelegator; import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.style.SName; import net.sourceforge.plantuml.style.Style; -import net.sourceforge.plantuml.style.StyleDefinition; +import net.sourceforge.plantuml.style.StyleSignature; import net.sourceforge.plantuml.style.Styleable; import net.sourceforge.plantuml.svek.UGraphicForSnake; import net.sourceforge.plantuml.ugraphic.LimitFinder; @@ -95,8 +94,8 @@ public class SwimlanesA extends AbstractTextBlock implements TextBlock, Styleabl private LinkRendering nextLinkRenderer = LinkRendering.none(); private Style style; - public StyleDefinition getDefaultStyleDefinition() { - return StyleDefinition.of(SName.root, SName.element, SName.classDiagram, SName.swimlane); + public StyleSignature getDefaultStyleDefinition() { + return StyleSignature.of(SName.root, SName.element, SName.classDiagram, SName.swimlane); } public SwimlanesA(ISkinParam skinParam, Pragma pragma) { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/SwimlanesB.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/SwimlanesB.java index fbb852959..2a33556e8 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/SwimlanesB.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/SwimlanesB.java @@ -44,7 +44,6 @@ import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.HtmlColorUtils; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.style.PName; @@ -75,6 +74,7 @@ public class SwimlanesB extends SwimlanesA { if (color != null) { final double titleHeight = getTitlesHeight(stringBounder); final URectangle back = new URectangle(getTitlesWidth(stringBounder), titleHeight); + back.setIgnoreForCompression(true); ug.apply(new UChangeBackColor(color)).apply(new UChangeColor(color)).draw(back); } for (Swimlane swimlane : swimlanes) { @@ -95,14 +95,18 @@ public class SwimlanesB extends SwimlanesA { } private TextBlock getTitle(Swimlane swimlane) { - final FontConfiguration fontConfiguration = new FontConfiguration(skinParam, FontParam.SWIMLANE_TITLE, null); + final HorizontalAlignment horizontalAlignment = HorizontalAlignment.LEFT; + FontConfiguration fontConfiguration = new FontConfiguration(skinParam, FontParam.SWIMLANE_TITLE, null); + if (SkinParam.USE_STYLES()) { + fontConfiguration = getStyle().getFontConfiguration(skinParam.getIHtmlColorSet()); + } LineBreakStrategy wrap = getWrap(); if (wrap.isAuto()) { wrap = new LineBreakStrategy("" + ((int) swimlane.getActualWidth())); } - return swimlane.getDisplay().create(fontConfiguration, HorizontalAlignment.LEFT, skinParam, wrap); + return swimlane.getDisplay().create(fontConfiguration, horizontalAlignment, skinParam, wrap); } private LineBreakStrategy getWrap() { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/SwimlanesC.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/SwimlanesC.java index cf9e08b55..b84c49cf8 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/SwimlanesC.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/SwimlanesC.java @@ -41,10 +41,12 @@ import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.LineParam; import net.sourceforge.plantuml.Pragma; +import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.skin.rose.Rose; +import net.sourceforge.plantuml.style.PName; import net.sourceforge.plantuml.ugraphic.UChangeColor; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.ULine; @@ -82,7 +84,11 @@ public class SwimlanesC extends SwimlanesB { if (color == null) { color = ColorParam.swimlaneBorder.getDefaultValue(); } - final UStroke thickness = Rose.getStroke(skinParam, LineParam.swimlaneBorder, 2); + UStroke thickness = Rose.getStroke(skinParam, LineParam.swimlaneBorder, 2); + if (SkinParam.USE_STYLES()) { + color = getStyle().value(PName.LineColor).asColor(skinParam.getIHtmlColorSet()); + thickness = getStyle().getStroke(); + } ug.apply(thickness).apply(new UChangeColor(color)).draw(new ULine(0, height)); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelFtilesBuilder.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/AbstractParallelFtilesBuilder.java similarity index 75% rename from src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelFtilesBuilder.java rename to src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/AbstractParallelFtilesBuilder.java index c9d886e73..6f8b775b1 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelFtilesBuilder.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/AbstractParallelFtilesBuilder.java @@ -40,6 +40,7 @@ import java.util.List; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.activitydiagram3.LinkRendering; import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry; @@ -51,8 +52,11 @@ import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.skin.rose.Rose; +import net.sourceforge.plantuml.style.SName; +import net.sourceforge.plantuml.style.Style; +import net.sourceforge.plantuml.style.StyleSignature; -public abstract class ParallelFtilesBuilder { +public abstract class AbstractParallelFtilesBuilder { protected final double barHeight = 6; @@ -64,16 +68,22 @@ public abstract class ParallelFtilesBuilder { private final List list; private final Ftile middle; private final FtileGeometry middleDimension; - private final Swimlane swimlane; - public ParallelFtilesBuilder(ISkinParam skinParam, StringBounder stringBounder, final List list, - Ftile middle, Swimlane swimlane) { + public StyleSignature getDefaultStyleDefinition() { + return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.activity); + } + + final public StyleSignature getDefaultStyleDefinitionArrow() { + return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.arrow); + } + + public AbstractParallelFtilesBuilder(ISkinParam skinParam, StringBounder stringBounder, final List list, + Ftile middle) { this.skinParam = skinParam; this.stringBounder = stringBounder; this.list = list; this.middle = middle; this.middleDimension = middle.calculateDimension(getStringBounder()); - this.swimlane = swimlane; } public final Ftile build() { @@ -102,7 +112,13 @@ public abstract class ParallelFtilesBuilder { if (Display.isNull(display)) { return null; } - final FontConfiguration fontConfiguration = new FontConfiguration(skinParam(), FontParam.ARROW, null); + final FontConfiguration fontConfiguration; + if (SkinParam.USE_STYLES()) { + final Style style = getDefaultStyleDefinitionArrow().getMergedStyle(skinParam().getCurrentStyleBuilder()); + fontConfiguration = style.getFontConfiguration(skinParam().getIHtmlColorSet()); + } else { + fontConfiguration = new FontConfiguration(skinParam(), FontParam.ARROW, null); + } return display.create(fontConfiguration, HorizontalAlignment.LEFT, skinParam(), CreoleMode.SIMPLE_LINE); } @@ -124,8 +140,8 @@ public abstract class ParallelFtilesBuilder { return middleDimension.getHeight(); } - protected final Swimlane swimlane() { - return swimlane; + protected final Swimlane swimlaneOutForStep2() { + return list.get(list.size() - 1).getSwimlaneOut(); } } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FloatingNote.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FloatingNote.java index 4e9117226..0670a2b58 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FloatingNote.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FloatingNote.java @@ -76,7 +76,8 @@ public class FloatingNote extends AbstractTextBlock implements Stencil, TextBloc skinParam, CreoleMode.FULL).createSheet(note); final SheetBlock2 sheetBlock2 = new SheetBlock2(new SheetBlock1(sheet, LineBreakStrategy.NONE, skinParam.getPadding()), this, new UStroke(1)); - this.opale = new Opale(borderColor, noteBackgroundColor, sheetBlock2, skinParam.shadowing(null), false); + final double shadowing;shadowing = skinParam.shadowing(null)?4:0; + this.opale = new Opale(shadowing, borderColor, noteBackgroundColor, sheetBlock2, false); // this.text = sheetBlock2; diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateParallel.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateParallel.java index 04ae4a42c..54f3bb1ee 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateParallel.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateParallel.java @@ -61,25 +61,25 @@ public class FtileFactoryDelegatorCreateParallel extends FtileFactoryDelegator { } @Override - public Ftile createParallel(Swimlane swimlane, List all, ForkStyle style, String label) { + public Ftile createParallel(List all, ForkStyle style, String label) { - final Dimension2D dimSuper = super.createParallel(swimlane, all, style, label).calculateDimension(getStringBounder()); + final Dimension2D dimSuper = super.createParallel(all, style, label).calculateDimension(getStringBounder()); final double height1 = dimSuper.getHeight() + 2 * spaceArroundBlackBar; final List list = new ArrayList(); for (Ftile tmp : all) { list.add(new FtileHeightFixed(FtileUtils.addHorizontalMargin(tmp, xMargin), height1)); } - final Ftile inner = super.createParallel(swimlane, list, style, label); + final Ftile inner = super.createParallel(list, style, label); - ParallelFtilesBuilder builder; + AbstractParallelFtilesBuilder builder; if (style == ForkStyle.SPLIT) { - builder = new ParallelBuilderSplit2(skinParam(), getStringBounder(), list, inner, swimlane); + builder = new ParallelBuilderSplit(skinParam(), getStringBounder(), list, inner); } else if (style == ForkStyle.MERGE) { - builder = new ParallelBuilderMerge(skinParam(), getStringBounder(), list, inner, swimlane); + builder = new ParallelBuilderMerge(skinParam(), getStringBounder(), list, inner); } else if (style == ForkStyle.FORK) { - builder = new ParallelBuilderFork(skinParam(), getStringBounder(), list, inner, swimlane, label); + builder = new ParallelBuilderFork(skinParam(), getStringBounder(), list, inner, label); } else { throw new IllegalStateException(); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateParallel1.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateParallel1.java deleted file mode 100644 index 7effdd825..000000000 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateParallel1.java +++ /dev/null @@ -1,75 +0,0 @@ -/* ======================================================================== - * 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.activitydiagram3.ftile.vcompact; - -import java.util.List; - -import net.sourceforge.plantuml.activitydiagram3.ForkStyle; -import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; -import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; -import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactoryDelegator; -import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; - -public class FtileFactoryDelegatorCreateParallel1 extends FtileFactoryDelegator { - - public FtileFactoryDelegatorCreateParallel1(FtileFactory factory) { - super(factory); - } - - private Ftile allOverlapped(Swimlane swimlane, List all, ForkStyle style, String label) { - return new FtileForkInnerOverlapped(all); - } - - @Override - public Ftile createParallel(Swimlane swimlane, List list, ForkStyle style, String label) { - - final Ftile inner = super.createParallel(swimlane, list, style, label); - - ParallelFtilesBuilder builder; - - if (style == ForkStyle.SPLIT) { - builder = new ParallelBuilderSplit(skinParam(), getStringBounder(), list, inner, swimlane); - } else if (style == ForkStyle.MERGE) { - builder = new ParallelBuilderMerge(skinParam(), getStringBounder(), list, inner, swimlane); - } else if (style == ForkStyle.FORK) { - builder = new ParallelBuilderFork(skinParam(), getStringBounder(), list, inner, swimlane, label); - } else { - throw new IllegalStateException(); - } - return builder.build(); - } - -} diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateParallelAddingMargin.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateParallelAddingMargin.java index 59985feed..52130cf70 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateParallelAddingMargin.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateParallelAddingMargin.java @@ -45,7 +45,6 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactoryDelegator; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileHeightFixed; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils; -import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; public class FtileFactoryDelegatorCreateParallelAddingMargin extends FtileFactoryDelegator { @@ -57,17 +56,16 @@ public class FtileFactoryDelegatorCreateParallelAddingMargin extends FtileFactor } @Override - public Ftile createParallel(Swimlane swimlane, List all, ForkStyle style, String label) { + public Ftile createParallel(List all, ForkStyle style, String label) { - final Dimension2D dimSuper = super.createParallel(swimlane, all, style, label).calculateDimension( - getStringBounder()); + final Dimension2D dimSuper = super.createParallel(all, style, label).calculateDimension(getStringBounder()); final double height1 = dimSuper.getHeight() + 2 * spaceArroundBlackBar; final List list = new ArrayList(); for (Ftile tmp : all) { list.add(new FtileHeightFixed(FtileUtils.addHorizontalMargin(tmp, xMargin), height1)); } - return super.createParallel(swimlane, list, style, label); + return super.createParallel(list, style, label); } } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorIf.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorIf.java index dcd2437c5..af97283dd 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorIf.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorIf.java @@ -40,6 +40,7 @@ import java.util.List; import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.Pragma; +import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.activitydiagram3.Branch; import net.sourceforge.plantuml.activitydiagram3.LinkRendering; @@ -50,8 +51,9 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.cond.ConditionalBuilder; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.HtmlColorAndStyle; import net.sourceforge.plantuml.graphic.Rainbow; +import net.sourceforge.plantuml.style.PName; +import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.svek.ConditionEndStyle; import net.sourceforge.plantuml.svek.ConditionStyle; @@ -72,17 +74,33 @@ public class FtileFactoryDelegatorIf extends FtileFactoryDelegator { final ConditionEndStyle conditionEndStyle = skinParam().getConditionEndStyle(); final Branch branch0 = thens.get(0); - final HtmlColor borderColor = getRose().getHtmlColor(skinParam(), ColorParam.activityDiamondBorder); - final HtmlColor backColor = branch0.getColor() == null ? getRose().getHtmlColor(skinParam(), - ColorParam.activityDiamondBackground) : branch0.getColor(); - final Rainbow arrowColor = HtmlColorAndStyle.build(skinParam()); - - final FontConfiguration fcArrow = new FontConfiguration(skinParam(), FontParam.ARROW, null); - + final HtmlColor borderColor; + final HtmlColor backColor; + final Rainbow arrowColor; + final FontConfiguration fcTest; final FontParam testParam = conditionStyle == ConditionStyle.INSIDE ? FontParam.ACTIVITY_DIAMOND : FontParam.ARROW; - final FontConfiguration fcTest = new FontConfiguration(skinParam(), testParam, null) - .changeColor(fontColor(FontParam.ACTIVITY_DIAMOND)); + final FontConfiguration fcArrow; + if (SkinParam.USE_STYLES()) { + final Style styleArrow = getDefaultStyleDefinitionArrow().getMergedStyle( + skinParam().getCurrentStyleBuilder()); + final Style styleDiamond = getDefaultStyleDefinitionDiamond().getMergedStyle( + skinParam().getCurrentStyleBuilder()); + borderColor = styleDiamond.value(PName.LineColor).asColor(skinParam().getIHtmlColorSet()); + backColor = branch0.getColor() == null ? styleDiamond.value(PName.BackGroundColor).asColor( + skinParam().getIHtmlColorSet()) : branch0.getColor(); + arrowColor = Rainbow.build(styleArrow, skinParam().getIHtmlColorSet()); + fcTest = styleDiamond.getFontConfiguration(skinParam().getIHtmlColorSet()); + fcArrow = styleArrow.getFontConfiguration(skinParam().getIHtmlColorSet()); + } else { + borderColor = getRose().getHtmlColor(skinParam(), ColorParam.activityDiamondBorder); + backColor = branch0.getColor() == null ? getRose().getHtmlColor(skinParam(), + ColorParam.activityDiamondBackground) : branch0.getColor(); + arrowColor = Rainbow.build(skinParam()); + fcTest = new FontConfiguration(skinParam(), testParam, null) + .changeColor(fontColor(FontParam.ACTIVITY_DIAMOND)); + fcArrow = new FontConfiguration(skinParam(), FontParam.ARROW, null); + } if (thens.size() > 1) { if (pragma.useVerticalIf()/* OptionFlags.USE_IF_VERTICAL */) diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorRepeat.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorRepeat.java index fc1e43277..94266dd75 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorRepeat.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorRepeat.java @@ -40,6 +40,7 @@ import java.util.List; import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.FontParam; +import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.activitydiagram3.LinkRendering; import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows; import net.sourceforge.plantuml.activitydiagram3.ftile.BoxStyle; @@ -57,9 +58,10 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamond; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.HtmlColorAndStyle; import net.sourceforge.plantuml.graphic.Rainbow; import net.sourceforge.plantuml.graphic.color.Colors; +import net.sourceforge.plantuml.style.PName; +import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.svek.ConditionStyle; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; @@ -77,17 +79,33 @@ public class FtileFactoryDelegatorRepeat extends FtileFactoryDelegator { final ConditionStyle conditionStyle = skinParam().getConditionStyle(); - final HtmlColor borderColor = getRose().getHtmlColor(skinParam(), ColorParam.activityDiamondBorder); - final HtmlColor backColor = color == null ? getRose().getHtmlColor(skinParam(), - ColorParam.activityDiamondBackground) : color; - final Rainbow arrowColor = HtmlColorAndStyle.build(skinParam()); + final HtmlColor borderColor; + final HtmlColor backColor; + final Rainbow arrowColor; + final FontConfiguration fcDiamond; + final FontConfiguration fcArrow; + if (SkinParam.USE_STYLES()) { + final Style styleArrow = getDefaultStyleDefinitionArrow().getMergedStyle( + skinParam().getCurrentStyleBuilder()); + final Style styleDiamond = getDefaultStyleDefinitionDiamond().getMergedStyle( + skinParam().getCurrentStyleBuilder()); + borderColor = styleDiamond.value(PName.LineColor).asColor(skinParam().getIHtmlColorSet()); + backColor = styleDiamond.value(PName.BackGroundColor).asColor(skinParam().getIHtmlColorSet()); + arrowColor = Rainbow.build(styleArrow, skinParam().getIHtmlColorSet()); + fcDiamond = styleDiamond.getFontConfiguration(skinParam().getIHtmlColorSet()); + fcArrow = styleArrow.getFontConfiguration(skinParam().getIHtmlColorSet()); + } else { + borderColor = getRose().getHtmlColor(skinParam(), ColorParam.activityDiamondBorder); + backColor = color == null ? getRose().getHtmlColor(skinParam(), ColorParam.activityDiamondBackground) + : color; + arrowColor = Rainbow.build(skinParam()); + fcDiamond = new FontConfiguration(skinParam(), FontParam.ACTIVITY_DIAMOND, null); + fcArrow = new FontConfiguration(skinParam(), FontParam.ARROW, null); + } final LinkRendering endRepeatLinkRendering = repeat.getOutLinkRendering(); final Rainbow endRepeatLinkColor = endRepeatLinkRendering == null ? null : endRepeatLinkRendering.getRainbow(); - final FontConfiguration fcDiamond = new FontConfiguration(skinParam(), FontParam.ACTIVITY_DIAMOND, null); - final FontConfiguration fcArrow = new FontConfiguration(skinParam(), FontParam.ARROW, null); - final Ftile backStart = Display.isNull(startLabel) ? null : this.activity(startLabel, swimlane, BoxStyle.PLAIN, Colors.empty()); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorSwitch.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorSwitch.java index 1507edec9..2897197c4 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorSwitch.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorSwitch.java @@ -49,14 +49,13 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.FtileMinWidth; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.cond.FtileSwitchNude; import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.cond.FtileSwitchWithDiamonds; -import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.cond.FtileSwitchWithOneLink; import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.cond.FtileSwitchWithManyLinks; +import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.cond.FtileSwitchWithOneLink; import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamondInside; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.HtmlColorAndStyle; import net.sourceforge.plantuml.graphic.Rainbow; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlockUtils; @@ -101,7 +100,7 @@ public class FtileFactoryDelegatorSwitch extends FtileFactoryDelegator { for (Branch branch : branches) { ftiles.add(new FtileMinWidth(branch.getFtile(), 30)); } - final Rainbow arrowColor = HtmlColorAndStyle.build(skinParam()); + final Rainbow arrowColor = Rainbow.build(skinParam()); if (ftiles.size() == 1) { final FtileSwitchWithOneLink result = new FtileSwitchWithOneLink(ftiles, branches, swimlane, diamond1, diamond2, getStringBounder(), arrowColor); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorWhile.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorWhile.java index 537a0929a..dd2c6704d 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorWhile.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorWhile.java @@ -39,6 +39,7 @@ import java.util.List; import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.FontParam; +import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.activitydiagram3.Instruction; import net.sourceforge.plantuml.activitydiagram3.LinkRendering; import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows; @@ -56,8 +57,9 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.WeldingPoint; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.HtmlColorAndStyle; import net.sourceforge.plantuml.graphic.Rainbow; +import net.sourceforge.plantuml.style.PName; +import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.svek.ConditionStyle; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; @@ -71,22 +73,38 @@ public class FtileFactoryDelegatorWhile extends FtileFactoryDelegator { @Override public Ftile createWhile(Swimlane swimlane, Ftile whileBlock, Display test, Display yes, Display out, LinkRendering afterEndwhile, HtmlColor color, Instruction specialOut) { - final HtmlColor borderColor = getRose().getHtmlColor(skinParam(), ColorParam.activityDiamondBorder); - final HtmlColor backColor = color == null ? getRose().getHtmlColor(skinParam(), - ColorParam.activityDiamondBackground) : color; - final Rainbow arrowColor = HtmlColorAndStyle.build(skinParam()); + final HtmlColor borderColor; + final HtmlColor backColor; + final Rainbow arrowColor; + final FontConfiguration fontArrow; + final FontConfiguration fcTest; final ConditionStyle conditionStyle = skinParam().getConditionStyle(); final FontParam testParam = conditionStyle == ConditionStyle.INSIDE ? FontParam.ACTIVITY_DIAMOND : FontParam.ARROW; - final FontConfiguration fcTest = new FontConfiguration(skinParam(), testParam, null); + if (SkinParam.USE_STYLES()) { + final Style styleArrow = getDefaultStyleDefinitionArrow().getMergedStyle( + skinParam().getCurrentStyleBuilder()); + final Style styleDiamond = getDefaultStyleDefinitionDiamond().getMergedStyle( + skinParam().getCurrentStyleBuilder()); + borderColor = styleDiamond.value(PName.LineColor).asColor(skinParam().getIHtmlColorSet()); + backColor = styleDiamond.value(PName.BackGroundColor).asColor(skinParam().getIHtmlColorSet()); + arrowColor = Rainbow.build(styleArrow, skinParam().getIHtmlColorSet()); + fontArrow = styleArrow.getFontConfiguration(skinParam().getIHtmlColorSet()); + fcTest = styleDiamond.getFontConfiguration(skinParam().getIHtmlColorSet()); + } else { + borderColor = getRose().getHtmlColor(skinParam(), ColorParam.activityDiamondBorder); + backColor = color == null ? getRose().getHtmlColor(skinParam(), ColorParam.activityDiamondBackground) + : color; + arrowColor = Rainbow.build(skinParam()); + fontArrow = new FontConfiguration(skinParam(), FontParam.ARROW, null); + fcTest = new FontConfiguration(skinParam(), testParam, null); + } final LinkRendering endInlinkRendering = whileBlock.getOutLinkRendering(); final Rainbow endInlinkColor = endInlinkRendering == null || endInlinkRendering.getRainbow().size() == 0 ? arrowColor : endInlinkRendering.getRainbow(); - final FontConfiguration fontArrow = new FontConfiguration(skinParam(), FontParam.ARROW, null); - Ftile result = FtileWhile.create(swimlane, whileBlock, test, borderColor, backColor, arrowColor, yes, out, endInlinkColor, afterEndwhile, fontArrow, getFactory(), conditionStyle, fcTest, specialOut); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileGroup.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileGroup.java index 1a1dce4bf..978acf8e1 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileGroup.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileGroup.java @@ -43,6 +43,7 @@ import net.sourceforge.plantuml.AlignmentParam; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.LineParam; +import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.activitydiagram3.LinkRendering; import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile; import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; @@ -60,6 +61,10 @@ import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.graphic.UGraphicInterceptorUDrawable; import net.sourceforge.plantuml.graphic.USymbol; +import net.sourceforge.plantuml.style.PName; +import net.sourceforge.plantuml.style.SName; +import net.sourceforge.plantuml.style.Style; +import net.sourceforge.plantuml.style.StyleSignature; import net.sourceforge.plantuml.svek.UGraphicForSnake; import net.sourceforge.plantuml.ugraphic.LimitFinder; import net.sourceforge.plantuml.ugraphic.MinMax; @@ -77,10 +82,15 @@ public class FtileGroup extends AbstractFtile { private final TextBlock headerNote; private final HtmlColor borderColor; private final HtmlColor backColor; + private final double shadowing; private final UStroke stroke; private final USymbol type; private final double roundCorner; + final public StyleSignature getDefaultStyleDefinitionPartition() { + return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.partition); + } + public FtileGroup(Ftile inner, Display title, Display displayNote, HtmlColor arrowColor, HtmlColor backColor, HtmlColor titleColor, ISkinParam skinParam, HtmlColor borderColor, USymbol type, double roundCorner) { super(inner.skinParam()); @@ -89,11 +99,19 @@ public class FtileGroup extends AbstractFtile { this.backColor = backColor == null ? HtmlColorUtils.WHITE : backColor; this.inner = FtileUtils.addHorizontalMargin(inner, 10); this.borderColor = borderColor == null ? HtmlColorUtils.BLACK : borderColor; - final UFont font = skinParam.getFont(null, false, FontParam.PARTITION); - final HtmlColor fontColor = skinParam.getFontHtmlColor(null, FontParam.PARTITION); - final FontConfiguration fc = new FontConfiguration(font, fontColor, skinParam.getHyperlinkColor(), - skinParam.useUnderlineForHyperlink(), skinParam.getTabSize()); + final FontConfiguration fc; + if (SkinParam.USE_STYLES()) { + final Style style = getDefaultStyleDefinitionPartition().getMergedStyle(skinParam.getCurrentStyleBuilder()); + fc = style.getFontConfiguration(getIHtmlColorSet()); + this.shadowing = style.value(PName.Shadowing).asDouble(); + } else { + final UFont font = skinParam.getFont(null, false, FontParam.PARTITION); + final HtmlColor fontColor = skinParam.getFontHtmlColor(null, FontParam.PARTITION); + fc = new FontConfiguration(font, fontColor, skinParam.getHyperlinkColor(), + skinParam.useUnderlineForHyperlink(), skinParam.getTabSize()); + this.shadowing = skinParam().shadowing(null) ? 3 : 0; + } if (title == null) { this.name = TextBlockUtils.empty(0, 0); } else { @@ -108,7 +126,7 @@ public class FtileGroup extends AbstractFtile { final UStroke thickness = skinParam.getThickness(LineParam.partitionBorder, null); this.stroke = thickness == null ? new UStroke(2) : thickness; } - + @Override public Collection getMyChildren() { return inner.getMyChildren(); @@ -205,11 +223,12 @@ public class FtileGroup extends AbstractFtile { final Dimension2D dimTotal = calculateDimension(stringBounder); // final double roundCorner = type.getSkinParameter().getRoundCorner(skinParam(), null); - final SymbolContext symbolContext = new SymbolContext(backColor, borderColor) - .withShadow(skinParam().shadowing(null)).withStroke(stroke).withCorner(roundCorner, 0); + final SymbolContext symbolContext = new SymbolContext(backColor, borderColor).withShadow(shadowing) + .withStroke(stroke).withCorner(roundCorner, 0); type.asBig(name, inner.skinParam().getHorizontalAlignment(AlignmentParam.packageTitleAlignment, null, false), - TextBlockUtils.empty(0, 0), dimTotal.getWidth(), dimTotal.getHeight(), symbolContext, skinParam().getStereotypeAlignment()).drawU(ug); + TextBlockUtils.empty(0, 0), dimTotal.getWidth(), dimTotal.getHeight(), symbolContext, + skinParam().getStereotypeAlignment()).drawU(ug); final Dimension2D dimHeaderNote = headerNote.calculateDimension(stringBounder); headerNote.drawU(ug.apply(new UTranslate(dimTotal.getWidth() - dimHeaderNote.getWidth() - 10, diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileNoteAlone.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileNoteAlone.java index c93e525d1..d8e2d5c11 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileNoteAlone.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileNoteAlone.java @@ -44,6 +44,7 @@ import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.LineBreakStrategy; +import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile; import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry; @@ -61,16 +62,25 @@ import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.skin.rose.Rose; +import net.sourceforge.plantuml.style.PName; +import net.sourceforge.plantuml.style.SName; +import net.sourceforge.plantuml.style.Style; +import net.sourceforge.plantuml.style.StyleSignature; +import net.sourceforge.plantuml.style.Styleable; import net.sourceforge.plantuml.svek.image.Opale; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UStroke; -public class FtileNoteAlone extends AbstractFtile implements Stencil { +public class FtileNoteAlone extends AbstractFtile implements Stencil, Styleable { private final Opale opale; private final boolean withOutPoint; private final Swimlane swimlane; - + + public StyleSignature getDefaultStyleDefinition() { + return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.note); + } + @Override public Collection getMyChildren() { return Collections.emptyList(); @@ -97,15 +107,27 @@ public class FtileNoteAlone extends AbstractFtile implements Stencil { this.withOutPoint = withOutPoint; final Rose rose = new Rose(); - final HtmlColor noteBackgroundColor = rose.getHtmlColor(skinParam, ColorParam.noteBackground); - final HtmlColor borderColor = rose.getHtmlColor(skinParam, ColorParam.noteBorder); + final HtmlColor noteBackgroundColor; + final HtmlColor borderColor; + final double shadowing; + if (SkinParam.USE_STYLES()) { + final Style style = getDefaultStyleDefinition().getMergedStyle(skinParam.getCurrentStyleBuilder()); + noteBackgroundColor = style.value(PName.BackGroundColor).asColor(getIHtmlColorSet()); + borderColor = style.value(PName.LineColor).asColor(getIHtmlColorSet()); + shadowing = style.value(PName.Shadowing).asDouble(); + } else { + noteBackgroundColor = rose.getHtmlColor(skinParam, ColorParam.noteBackground); + borderColor = rose.getHtmlColor(skinParam, ColorParam.noteBorder); + shadowing = skinParam.shadowing(null) ? 4 : 0; + } final FontConfiguration fc = new FontConfiguration(skinParam, FontParam.NOTE, null); final Sheet sheet = new CreoleParser(fc, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT), skinParam, CreoleMode.FULL).createSheet(note); - final TextBlock text = new SheetBlock2(new SheetBlock1(sheet, LineBreakStrategy.NONE, skinParam.getPadding()), this, new UStroke(1)); - opale = new Opale(borderColor, noteBackgroundColor, text, skinParam.shadowing(null), false); + final TextBlock text = new SheetBlock2(new SheetBlock1(sheet, LineBreakStrategy.NONE, skinParam.getPadding()), + this, new UStroke(1)); + opale = new Opale(shadowing, borderColor, noteBackgroundColor, text, false); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNoteOpale.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNoteOpale.java index 0a97d06eb..c68cfff91 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNoteOpale.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNoteOpale.java @@ -48,6 +48,7 @@ import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.Direction; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.activitydiagram3.PositionedNote; import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile; import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; @@ -67,12 +68,17 @@ import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.sequencediagram.NotePosition; import net.sourceforge.plantuml.sequencediagram.NoteType; import net.sourceforge.plantuml.skin.rose.Rose; +import net.sourceforge.plantuml.style.PName; +import net.sourceforge.plantuml.style.SName; +import net.sourceforge.plantuml.style.Style; +import net.sourceforge.plantuml.style.StyleSignature; +import net.sourceforge.plantuml.style.Styleable; import net.sourceforge.plantuml.svek.image.Opale; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UTranslate; -public class FtileWithNoteOpale extends AbstractFtile implements Stencil { +public class FtileWithNoteOpale extends AbstractFtile implements Stencil, Styleable { private final Ftile tile; private final Opale opale; @@ -82,6 +88,10 @@ public class FtileWithNoteOpale extends AbstractFtile implements Stencil { private final double suppSpace = 20; private final Swimlane swimlaneNote; + public StyleSignature getDefaultStyleDefinition() { + return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.note); + } + public Set getSwimlanes() { if (swimlaneNote != null) { final Set result = new HashSet(tile.getSwimlanes()); @@ -128,16 +138,30 @@ public class FtileWithNoteOpale extends AbstractFtile implements Stencil { final Rose rose = new Rose(); - final HtmlColor noteBackgroundColor = rose.getHtmlColor(skinParam, ColorParam.noteBackground); - final HtmlColor borderColor = rose.getHtmlColor(skinParam, ColorParam.noteBorder); + final HtmlColor noteBackgroundColor; + final HtmlColor borderColor; + final FontConfiguration fc; - final FontConfiguration fc = new FontConfiguration(skinParam, FontParam.NOTE, null); + final double shadowing; + if (SkinParam.USE_STYLES()) { + final Style style = getDefaultStyleDefinition().getMergedStyle(skinParam.getCurrentStyleBuilder()).eventuallyOverride(note.getColors()); + noteBackgroundColor = style.value(PName.BackGroundColor).asColor(getIHtmlColorSet()); + borderColor = style.value(PName.LineColor).asColor(getIHtmlColorSet()); + fc = style.getFontConfiguration(getIHtmlColorSet()); + shadowing = style.value(PName.Shadowing).asDouble(); + } else { + noteBackgroundColor = rose.getHtmlColor(skinParam, ColorParam.noteBackground); + borderColor = rose.getHtmlColor(skinParam, ColorParam.noteBorder); + fc = new FontConfiguration(skinParam, FontParam.NOTE, null); + shadowing = skinParam.shadowing(null) ? 4 : 0; + } - final HorizontalAlignment align = skinParam.getHorizontalAlignment(AlignmentParam.noteTextAlignment, null, false); + final HorizontalAlignment align = skinParam.getHorizontalAlignment(AlignmentParam.noteTextAlignment, null, + false); final Sheet sheet = new CreoleParser(fc, align, skinParam, CreoleMode.FULL).createSheet(note.getDisplay()); final TextBlock text = new SheetBlock2(new SheetBlock1(sheet, skinParam.wrapWidth(), skinParam.getPadding()), this, new UStroke(1)); - opale = new Opale(borderColor, noteBackgroundColor, text, skinParam.shadowing(null), withLink); + opale = new Opale(shadowing, borderColor, noteBackgroundColor, text, withLink); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNotes.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNotes.java index 0e7e8c17a..b8d499d41 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNotes.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNotes.java @@ -44,6 +44,7 @@ import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.LineBreakStrategy; +import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.activitydiagram3.PositionedNote; import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile; import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; @@ -63,6 +64,10 @@ import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.sequencediagram.NotePosition; import net.sourceforge.plantuml.skin.rose.Rose; +import net.sourceforge.plantuml.style.PName; +import net.sourceforge.plantuml.style.SName; +import net.sourceforge.plantuml.style.Style; +import net.sourceforge.plantuml.style.StyleSignature; import net.sourceforge.plantuml.svek.image.Opale; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UStroke; @@ -78,6 +83,10 @@ public class FtileWithNotes extends AbstractFtile { private final double suppSpace = 20; + public StyleSignature getDefaultStyleDefinition() { + return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.note); + } + public Set getSwimlanes() { return tile.getSwimlanes(); } @@ -96,12 +105,30 @@ public class FtileWithNotes extends AbstractFtile { final Rose rose = new Rose(); - final HtmlColor noteBackgroundColor = rose.getHtmlColor(skinParam, ColorParam.noteBackground); - final HtmlColor borderColor = rose.getHtmlColor(skinParam, ColorParam.noteBorder); - - final FontConfiguration fc = new FontConfiguration(skinParam, FontParam.NOTE, null); - for (PositionedNote note : notes) { + ISkinParam skinParam2 = skinParam; + if (note.getColors() != null) { + skinParam2 = note.getColors().mute(skinParam2); + } + final HtmlColor noteBackgroundColor; + final HtmlColor borderColor; + final FontConfiguration fc; + final double shadowing; + + if (SkinParam.USE_STYLES()) { + final Style style = getDefaultStyleDefinition().getMergedStyle(skinParam.getCurrentStyleBuilder()) + .eventuallyOverride(note.getColors()); + noteBackgroundColor = style.value(PName.BackGroundColor).asColor(getIHtmlColorSet()); + borderColor = style.value(PName.LineColor).asColor(getIHtmlColorSet()); + fc = style.getFontConfiguration(getIHtmlColorSet()); + shadowing = style.value(PName.Shadowing).asDouble(); + } else { + noteBackgroundColor = rose.getHtmlColor(skinParam2, ColorParam.noteBackground); + borderColor = rose.getHtmlColor(skinParam2, ColorParam.noteBorder); + fc = new FontConfiguration(skinParam, FontParam.NOTE, null); + shadowing = skinParam.shadowing(null) ? 4 : 0; + } + final Sheet sheet = new CreoleParser(fc, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT), skinParam, CreoleMode.FULL).createSheet(note.getDisplay()); final SheetBlock1 sheet1 = new SheetBlock1(sheet, LineBreakStrategy.NONE, skinParam.getPadding()); @@ -116,7 +143,7 @@ public class FtileWithNotes extends AbstractFtile { } }, new UStroke()); - final Opale opale = new Opale(borderColor, noteBackgroundColor, sheet2, skinParam.shadowing(null), false); + final Opale opale = new Opale(shadowing, borderColor, noteBackgroundColor, sheet2, false); final TextBlock opaleMarged = TextBlockUtils.withMargin(opale, 10, 10); if (note.getNotePosition() == NotePosition.LEFT) { if (left == null) { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderFork.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderFork.java index effcc085d..d2a90fe07 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderFork.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderFork.java @@ -42,6 +42,7 @@ import java.util.List; import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractConnection; import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows; import net.sourceforge.plantuml.activitydiagram3.ftile.Connection; @@ -54,19 +55,19 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.Snake; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileBlackBlock; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.graphic.HtmlColorAndStyle; import net.sourceforge.plantuml.graphic.Rainbow; import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; -public class ParallelBuilderFork extends ParallelFtilesBuilder { +public class ParallelBuilderFork extends AbstractParallelFtilesBuilder { private final String label; - public ParallelBuilderFork(ISkinParam skinParam, StringBounder stringBounder, - final List list, Ftile inner, Swimlane swimlane, String label) { - super(skinParam, stringBounder, list, inner, swimlane); + public ParallelBuilderFork(ISkinParam skinParam, StringBounder stringBounder, final List list, Ftile inner, + String label) { + super(skinParam, stringBounder, list, inner); this.label = label; } @@ -79,13 +80,21 @@ public class ParallelBuilderFork extends ParallelFtilesBuilder { double x = 0; for (Ftile tmp : getList()) { final Dimension2D dim = tmp.calculateDimension(getStringBounder()); - conns.add(new ConnectionIn(black, tmp, x, tmp.getInLinkRendering().getRainbow( - HtmlColorAndStyle.build(skinParam())))); + final Rainbow def; + if (SkinParam.USE_STYLES()) { + Style style = getDefaultStyleDefinition().getMergedStyle(skinParam().getCurrentStyleBuilder()); + def = Rainbow.build(style, skinParam().getIHtmlColorSet()); + } else { + def = Rainbow.build(skinParam()); + } + final Rainbow rainbow = tmp.getInLinkRendering().getRainbow(def); + conns.add(new ConnectionIn(black, tmp, x, rainbow)); x += dim.getWidth(); } result = FtileUtils.addConnection(result, conns); - ((FtileBlackBlock) black).setBlackBlockDimension(result.calculateDimension(getStringBounder()).getWidth(), barHeight); + ((FtileBlackBlock) black).setBlackBlockDimension(result.calculateDimension(getStringBounder()).getWidth(), + barHeight); return new FtileAssemblySimple(black, result); } @@ -94,7 +103,8 @@ public class ParallelBuilderFork extends ParallelFtilesBuilder { protected Ftile doStep2(Ftile result) { final Ftile out = new FtileBlackBlock(skinParam(), getRose().getHtmlColor(skinParam(), ColorParam.activityBar), getList().get(0).getSwimlaneIn()); - ((FtileBlackBlock) out).setBlackBlockDimension(result.calculateDimension(getStringBounder()).getWidth(), barHeight); + ((FtileBlackBlock) out).setBlackBlockDimension(result.calculateDimension(getStringBounder()).getWidth(), + barHeight); if (label != null) { ((FtileBlackBlock) out).setLabel(getTextBlock(Display.getWithNewlines(label))); } @@ -104,8 +114,15 @@ public class ParallelBuilderFork extends ParallelFtilesBuilder { for (Ftile tmp : getList()) { final UTranslate translate0 = new UTranslate(0, barHeight); final Dimension2D dim = tmp.calculateDimension(getStringBounder()); - conns.add(new ConnectionOut(translate0, tmp, out, x, tmp.getOutLinkRendering().getRainbow( - HtmlColorAndStyle.build(skinParam())), getHeightOfMiddle())); + final Rainbow def; + if (SkinParam.USE_STYLES()) { + Style style = getDefaultStyleDefinitionArrow().getMergedStyle(skinParam().getCurrentStyleBuilder()); + def = Rainbow.build(style, skinParam().getIHtmlColorSet()); + } else { + def = Rainbow.build(skinParam()); + } + final Rainbow rainbow = tmp.getOutLinkRendering().getRainbow(def); + conns.add(new ConnectionOut(translate0, tmp, out, x, rainbow, getHeightOfMiddle())); x += dim.getWidth(); } result = FtileUtils.addConnection(result, conns); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderMerge.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderMerge.java index 4bb4d106f..c908b5359 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderMerge.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderMerge.java @@ -42,6 +42,7 @@ import java.util.List; import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractConnection; import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows; import net.sourceforge.plantuml.activitydiagram3.ftile.Connection; @@ -51,23 +52,21 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.FtileAssemblySimple; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils; import net.sourceforge.plantuml.activitydiagram3.ftile.Snake; -import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileBlackBlock; import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamond; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.HtmlColorAndStyle; import net.sourceforge.plantuml.graphic.Rainbow; import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UPolygon; import net.sourceforge.plantuml.ugraphic.UTranslate; -public class ParallelBuilderMerge extends ParallelFtilesBuilder { +public class ParallelBuilderMerge extends AbstractParallelFtilesBuilder { - public ParallelBuilderMerge(ISkinParam skinParam, StringBounder stringBounder, - final List list, Ftile inner, Swimlane swimlane) { - super(skinParam, stringBounder, list, inner, swimlane); + public ParallelBuilderMerge(ISkinParam skinParam, StringBounder stringBounder, final List list, Ftile inner) { + super(skinParam, stringBounder, list, inner); } @Override @@ -80,22 +79,30 @@ public class ParallelBuilderMerge extends ParallelFtilesBuilder { double x = 0; for (Ftile tmp : getList()) { final Dimension2D dim = tmp.calculateDimension(getStringBounder()); - conns.add(new ConnectionIn(black, tmp, x, tmp.getInLinkRendering().getRainbow( - HtmlColorAndStyle.build(skinParam())))); + final Rainbow def; + if (SkinParam.USE_STYLES()) { + Style style = getDefaultStyleDefinition().getMergedStyle(skinParam().getCurrentStyleBuilder()); + def = Rainbow.build(style, skinParam().getIHtmlColorSet()); + } else { + def = Rainbow.build(skinParam()); + } + final Rainbow rainbow = tmp.getInLinkRendering().getRainbow(def); + conns.add(new ConnectionIn(black, tmp, x, rainbow)); x += dim.getWidth(); } result = FtileUtils.addConnection(result, conns); - ((FtileBlackBlock) black).setBlackBlockDimension(result.calculateDimension(getStringBounder()).getWidth(), barHeight); + ((FtileBlackBlock) black).setBlackBlockDimension(result.calculateDimension(getStringBounder()).getWidth(), + barHeight); return new FtileAssemblySimple(black, result); } @Override - protected Ftile doStep2(Ftile result) { + protected Ftile doStep2(Ftile result) { final HtmlColor borderColor = getRose().getHtmlColor(skinParam(), ColorParam.activityDiamondBorder); final HtmlColor backColor = getRose().getHtmlColor(skinParam(), ColorParam.activityDiamondBackground); - final Ftile out = new FtileDiamond(skinParam(), backColor, borderColor, swimlane()); + final Ftile out = new FtileDiamond(skinParam(), backColor, borderColor, swimlaneOutForStep2()); result = new FtileAssemblySimple(result, out); final List conns = new ArrayList(); final UTranslate diamondTranslate = result.getTranslateFor(out, getStringBounder()); @@ -104,8 +111,15 @@ public class ParallelBuilderMerge extends ParallelFtilesBuilder { for (Ftile tmp : getList()) { final Dimension2D dim = tmp.calculateDimension(getStringBounder()); final UTranslate translate0 = new UTranslate(x, barHeight); - conns.add(new ConnectionHorizontalThenVertical(tmp, out, tmp.getOutLinkRendering().getRainbow( - HtmlColorAndStyle.build(skinParam())), translate0, diamondTranslate, i)); + final Rainbow def; + if (SkinParam.USE_STYLES()) { + Style style = getDefaultStyleDefinition().getMergedStyle(skinParam().getCurrentStyleBuilder()); + def = Rainbow.build(style, skinParam().getIHtmlColorSet()); + } else { + def = Rainbow.build(skinParam()); + } + final Rainbow rainbow = tmp.getOutLinkRendering().getRainbow(def); + conns.add(new ConnectionHorizontalThenVertical(tmp, out, rainbow, translate0, diamondTranslate, i)); x += dim.getWidth(); i++; } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderSplit.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderSplit.java index 048e0ce4b..ae15edbde 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderSplit.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderSplit.java @@ -35,243 +35,281 @@ */ package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact; -import java.awt.geom.Dimension2D; +import java.awt.geom.Point2D; import java.util.ArrayList; import java.util.List; import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.SkinParam; +import net.sourceforge.plantuml.activitydiagram3.LinkRendering; import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractConnection; import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows; import net.sourceforge.plantuml.activitydiagram3.ftile.Connection; import net.sourceforge.plantuml.activitydiagram3.ftile.ConnectionTranslatable; import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; +import net.sourceforge.plantuml.activitydiagram3.ftile.FtileAssemblySimple; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileKilled; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils; -import net.sourceforge.plantuml.activitydiagram3.ftile.MergeStrategy; import net.sourceforge.plantuml.activitydiagram3.ftile.Snake; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; -import net.sourceforge.plantuml.graphic.HtmlColorAndStyle; +import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileThinSplit; +import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.Rainbow; import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.graphic.TextBlock; +import net.sourceforge.plantuml.style.SName; +import net.sourceforge.plantuml.style.Style; +import net.sourceforge.plantuml.style.StyleSignature; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; -public class ParallelBuilderSplit extends ParallelFtilesBuilder { +public class ParallelBuilderSplit extends AbstractParallelFtilesBuilder { - public ParallelBuilderSplit(ISkinParam skinParam, StringBounder stringBounder, - final List list, Ftile inner, Swimlane swimlane) { - super(skinParam, stringBounder, list, inner, swimlane); + public ParallelBuilderSplit(ISkinParam skinParam, StringBounder stringBounder, final List list, Ftile inner) { + super(skinParam, stringBounder, list, inner); + } + + @Override + public StyleSignature getDefaultStyleDefinition() { + return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.arrow); } @Override protected Ftile doStep1() { Ftile result = getMiddle(); final List conns = new ArrayList(); - - double x1 = 0; - for (Ftile tmp : getList()) { - final Dimension2D dim = tmp.calculateDimension(getStringBounder()); - conns.add(new ConnectionIn(tmp, x1, tmp.getInLinkRendering().getRainbow( - HtmlColorAndStyle.build(skinParam())), getTextBlock(tmp.getInLinkRendering()))); - x1 += dim.getWidth(); + final Rainbow thinColor; + if (SkinParam.USE_STYLES()) { + Style style = getDefaultStyleDefinition().getMergedStyle(skinParam().getCurrentStyleBuilder()); + thinColor = Rainbow.build(style, skinParam().getIHtmlColorSet()); + } else { + thinColor = result.getInLinkRendering().getRainbow(Rainbow.build(skinParam())); } - final double totalWidth1 = result.calculateDimension(getStringBounder()).getWidth(); - conns.add(new ConnectionHline2(result, HtmlColorAndStyle.build(skinParam()), 0, getList(), totalWidth1)); + final Ftile thin = new FtileThinSplit(skinParam(), getThin1Color(thinColor), getList().get(0).getSwimlaneIn()); + double x = 0; + double first = 0; + double last = 0; + for (Ftile tmp : getList()) { + final FtileGeometry dim = tmp.calculateDimension(getStringBounder()); + if (first == 0) { + first = x + dim.getLeft(); + } + last = x + dim.getLeft(); + + final LinkRendering inLinkRendering = tmp.getInLinkRendering(); + final Rainbow rainbow; + if (SkinParam.USE_STYLES()) { + Style style = getDefaultStyleDefinition().getMergedStyle(skinParam().getCurrentStyleBuilder()); + rainbow = inLinkRendering.getRainbow(Rainbow.build(style, skinParam().getIHtmlColorSet())); + } else { + rainbow = inLinkRendering.getRainbow(Rainbow.build(skinParam())); + } + + conns.add(new ConnectionIn(thin, tmp, x, rainbow)); + x += dim.getWidth(); + } + result = FtileUtils.addConnection(result, conns); - return result; + final FtileGeometry geom = result.calculateDimension(getStringBounder()); + if (last < geom.getLeft()) { + last = geom.getLeft(); + } + if (first > geom.getLeft()) { + first = geom.getLeft(); + } + ((FtileThinSplit) thin).setGeom(first, last, result.calculateDimension(getStringBounder()).getWidth()); + + return new FtileAssemblySimple(thin, result); + } + + private HtmlColor getThin1Color(final Rainbow thinColor) { + for (Ftile tmp : getList()) { + final Rainbow rainbow; + final LinkRendering inLinkRendering = tmp.getInLinkRendering(); + if (SkinParam.USE_STYLES()) { + Style style = getDefaultStyleDefinition().getMergedStyle(skinParam().getCurrentStyleBuilder()); + rainbow = inLinkRendering.getRainbow(Rainbow.build(style, skinParam().getIHtmlColorSet())); + } else { + rainbow = inLinkRendering.getRainbow(Rainbow.build(skinParam())); + } + if (rainbow.isInvisible() == false) { + return thinColor.getColor(); + } + } + return null; + } + + private boolean hasOut() { + for (Ftile tmp : getList()) { + final boolean hasOutTmp = tmp.calculateDimension(getStringBounder()).hasPointOut(); + if (hasOutTmp) { + return true; + } + } + return false; } @Override protected Ftile doStep2(Ftile result) { - final List conns2 = new ArrayList(); - double x2 = 0; - boolean hasOut = false; - for (Ftile tmp : getList()) { - final Dimension2D dim = tmp.calculateDimension(getStringBounder()); - final boolean hasOutTmp = tmp.calculateDimension(getStringBounder()).hasPointOut(); - if (hasOutTmp) { - conns2.add(new ConnectionOut(tmp, x2, tmp.getOutLinkRendering().getRainbow( - HtmlColorAndStyle.build(skinParam())), getHeightOfMiddle(), getTextBlock(tmp - .getOutLinkRendering()))); - hasOut = true; - } - x2 += dim.getWidth(); + + final FtileGeometry geom = result.calculateDimension(getStringBounder()); + if (hasOut() == false) { + return new FtileKilled(result); } - if (hasOut) { - final double totalWidth2 = result.calculateDimension(getStringBounder()).getWidth(); - conns2.add(new ConnectionHline2(result, HtmlColorAndStyle.build(skinParam()), getHeightOfMiddle(), - getList(), totalWidth2)); - result = FtileUtils.addConnection(result, conns2); + final Rainbow thinColor; + final LinkRendering inLinkRendering = result.getInLinkRendering(); + if (SkinParam.USE_STYLES()) { + Style style = getDefaultStyleDefinition().getMergedStyle(skinParam().getCurrentStyleBuilder()); + thinColor = inLinkRendering.getRainbow(Rainbow.build(style, skinParam().getIHtmlColorSet())); } else { - result = new FtileKilled(result); + thinColor = inLinkRendering.getRainbow(Rainbow.build(skinParam())); } + + final Ftile out = new FtileThinSplit(skinParam(), thinColor.getColor(), swimlaneOutForStep2()); + result = new FtileAssemblySimple(result, out); + final List conns = new ArrayList(); + double x = 0; + double first = 0; + double last = 0; + for (Ftile tmp : getList()) { + final UTranslate translate0 = new UTranslate(0, 1.5); + final FtileGeometry dim = tmp.calculateDimension(getStringBounder()); + if (dim.hasPointOut()) { + if (first == 0) { + first = x + dim.getLeft(); + } + last = x + dim.getLeft(); + } + + final Rainbow rainbow; + final LinkRendering outLinkRendering = tmp.getOutLinkRendering(); + if (SkinParam.USE_STYLES()) { + Style style = getDefaultStyleDefinition().getMergedStyle(skinParam().getCurrentStyleBuilder()); + rainbow = outLinkRendering.getRainbow(Rainbow.build(style, skinParam().getIHtmlColorSet())); + } else { + rainbow = outLinkRendering.getRainbow(Rainbow.build(skinParam())); + } + + conns.add(new ConnectionOut(translate0, tmp, out, x, rainbow, getHeightOfMiddle())); + x += dim.getWidth(); + } + if (last < geom.getLeft()) { + last = geom.getLeft(); + } + if (first > geom.getLeft()) { + first = geom.getLeft(); + } + ((FtileThinSplit) out).setGeom(first, last, geom.getWidth()); + result = FtileUtils.addConnection(result, conns); return result; } - static class ConnectionHline2 extends AbstractConnection { - - private final Ftile inner; - private final double y; - private final Rainbow arrowColor; - private final List list; - private final double totalWidth; - - public ConnectionHline2(Ftile inner, Rainbow arrowColor, double y, List list, double totalWidth) { - super(null, null); - this.inner = inner; - this.y = y; - this.arrowColor = arrowColor; - this.list = list; - this.totalWidth = totalWidth; - } - - public void drawU(UGraphic ug) { - double minX = Double.MAX_VALUE; - double maxX = 0; - if (y == 0 && ug instanceof UGraphicInterceptorOneSwimlane) { - final Swimlane intoSw = ((UGraphicInterceptorOneSwimlane) ug).getSwimlane(); - boolean found = false; - for (Ftile tmp : list) { - if (tmp.getSwimlaneIn() == intoSw) { - found = true; - } - } - if (found == false) { - return; - } - } - final StringBounder stringBounder = ug.getStringBounder(); - for (Ftile tmp : list) { - if (y > 0 && tmp.calculateDimension(stringBounder).hasPointOut() == false) { - continue; - } - final UTranslate ut = inner.getTranslateFor(tmp, stringBounder); - if (ut == null) { - continue; - } - final double middle = tmp.calculateDimension(stringBounder).translate(ut).getLeft(); - minX = Math.min(minX, middle); - maxX = Math.max(maxX, middle); - } - if (minX > totalWidth / 2) { - minX = totalWidth / 2; - } - if (maxX < totalWidth / 2) { - maxX = totalWidth / 2; - } - - final Snake s = new Snake(arrowHorizontalAlignment(), arrowColor); - s.goUnmergeable(MergeStrategy.NONE); - s.addPoint(minX, y); - s.addPoint(maxX, y); - ug.draw(s); - } - } - - static class ConnectionHline3 extends AbstractConnection implements ConnectionTranslatable { - - private final Ftile inner; - private final double y; - private final Rainbow arrowColor; - private final List list; - private final double totalWidth; - - public ConnectionHline3(Ftile inner, Rainbow arrowColor, double y, List list, double totalWidth) { - super(null, null); - this.inner = inner; - this.y = y; - this.arrowColor = arrowColor; - this.list = list; - this.totalWidth = totalWidth; - } - - public void drawU(UGraphic ug) { - throw new UnsupportedOperationException(); - } - - public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) { - final StringBounder stringBounder = ug.getStringBounder(); - final UTranslate left = inner.getSwimlaneIn().getTranslate(); - double minX = inner.calculateDimension(stringBounder).getLeft() + left.getDx(); - double maxX = minX; - - for (Ftile tmp : list) { - final FtileGeometry tmpGeom = tmp.calculateDimension(stringBounder); - final UTranslate tpos = inner.getTranslateFor(tmp, stringBounder); - for (Swimlane sw : tmp.getSwimlanes()) { - final double x = tmpGeom.translate(sw.getTranslate().compose(tpos)).getLeft(); - minX = Math.min(minX, x); - maxX = Math.max(maxX, x); - } - } - final Dimension2D dimInner = inner.calculateDimension(stringBounder); - - final Snake s = new Snake(arrowHorizontalAlignment(), arrowColor); - // final Snake s = new Snake(HtmlColorUtils.GREEN); - s.goUnmergeable(MergeStrategy.LIMITED); - s.addPoint(minX, y); - s.addPoint(maxX, y); - ug.draw(s); - } - } - - static class ConnectionIn extends AbstractConnection { + class ConnectionIn extends AbstractConnection implements ConnectionTranslatable { private final double x; private final Rainbow arrowColor; - private final TextBlock text; + private final Display label; - public ConnectionIn(Ftile tmp, double x, Rainbow arrowColor, TextBlock text) { - super(null, tmp); + public ConnectionIn(Ftile ftile1, Ftile ftile2, double x, Rainbow arrowColor) { + super(ftile1, ftile2); + label = ftile2.getInLinkRendering().getDisplay(); this.x = x; this.arrowColor = arrowColor; - this.text = text; } public void drawU(UGraphic ug) { ug = ug.apply(new UTranslate(x, 0)); - final FtileGeometry geo = getFtile2().calculateDimension(ug.getStringBounder()); - final double left = geo.getLeft(); - final Snake s = new Snake(arrowHorizontalAlignment(), arrowColor, Arrows.asToDown()); - s.setLabel(text); - s.addPoint(left, 0); - s.addPoint(left, geo.getInY()); - ug.draw(s); + final FtileGeometry geo = getFtile2().calculateDimension(getStringBounder()); + final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, Arrows.asToDown()); + if (Display.isNull(label) == false) { + snake.setLabel(getTextBlock(label)); + } + snake.addPoint(geo.getLeft(), 0); + snake.addPoint(geo.getLeft(), geo.getInY()); + ug.draw(snake); + } + + public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) { + ug = ug.apply(new UTranslate(x, 0)); + final FtileGeometry geo = getFtile2().calculateDimension(getStringBounder()); + final Point2D p1 = new Point2D.Double(geo.getLeft(), 0); + final Point2D p2 = new Point2D.Double(geo.getLeft(), geo.getInY()); + + final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, Arrows.asToDown()); + if (Display.isNull(label) == false) { + snake.setLabel(getTextBlock(label)); + } + final Point2D mp1a = translate1.getTranslated(p1); + final Point2D mp2b = translate2.getTranslated(p2); + final double middle = mp1a.getY() + 4; + snake.addPoint(mp1a); + snake.addPoint(mp1a.getX(), middle); + snake.addPoint(mp2b.getX(), middle); + snake.addPoint(mp2b); + ug.draw(snake); } } - static class ConnectionOut extends AbstractConnection { + class ConnectionOut extends AbstractConnection implements ConnectionTranslatable { private final double x; private final Rainbow arrowColor; private final double height; - private final TextBlock text; + private final Display label; + private final UTranslate translate0; - public ConnectionOut(Ftile tmp, double x, Rainbow arrowColor, double height, TextBlock text) { - super(tmp, null); + public ConnectionOut(UTranslate translate0, Ftile ftile1, Ftile ftile2, double x, Rainbow arrowColor, + double height) { + super(ftile1, ftile2); + this.translate0 = translate0; + this.label = ftile1.getOutLinkRendering().getDisplay(); this.x = x; this.arrowColor = arrowColor; this.height = height; - this.text = text; } public void drawU(UGraphic ug) { ug = ug.apply(new UTranslate(x, 0)); - final FtileGeometry geo = getFtile1().calculateDimension(ug.getStringBounder()); + final FtileGeometry geo = getFtile1().calculateDimension(getStringBounder()); if (geo.hasPointOut() == false) { - assert false; return; } - final Snake s = new Snake(arrowHorizontalAlignment(), arrowColor, Arrows.asToDown()); - s.setLabel(text); - s.goUnmergeable(MergeStrategy.NONE); - s.addPoint(geo.getLeft(), geo.getOutY()); - s.addPoint(geo.getLeft(), height); - ug.draw(s); + final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, Arrows.asToDown()); + if (Display.isNull(label) == false) { + snake.setLabel(getTextBlock(label)); + } + final Point2D p1 = translate0.getTranslated(new Point2D.Double(geo.getLeft(), geo.getOutY())); + final Point2D p2 = translate0.getTranslated(new Point2D.Double(geo.getLeft(), height)); + snake.addPoint(p1); + snake.addPoint(p2); + ug.draw(snake); } + + public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) { + ug = ug.apply(new UTranslate(x, 0)); + final FtileGeometry geo = getFtile1().calculateDimension(getStringBounder()); + if (geo.hasPointOut() == false) { + return; + } + final Point2D p1 = translate0.getTranslated(new Point2D.Double(geo.getLeft(), geo.getOutY())); + final Point2D p2 = translate0.getTranslated(new Point2D.Double(geo.getLeft(), height)); + + final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, Arrows.asToDown()); + if (Display.isNull(label) == false) { + snake.setLabel(getTextBlock(label)); + } + final Point2D mp1a = translate1.getTranslated(p1); + final Point2D mp2b = translate2.getTranslated(p2); + final double middle = mp2b.getY() - 14; + snake.addPoint(mp1a); + snake.addPoint(mp1a.getX(), middle); + snake.addPoint(mp2b.getX(), middle); + snake.addPoint(mp2b); + ug.draw(snake); + } + } } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderSplit2.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderSplit2.java deleted file mode 100644 index 8801ab6d5..000000000 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ParallelBuilderSplit2.java +++ /dev/null @@ -1,269 +0,0 @@ -/* ======================================================================== - * 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.activitydiagram3.ftile.vcompact; - -import java.awt.geom.Point2D; -import java.util.ArrayList; -import java.util.List; - -import net.sourceforge.plantuml.ISkinParam; -import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractConnection; -import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows; -import net.sourceforge.plantuml.activitydiagram3.ftile.Connection; -import net.sourceforge.plantuml.activitydiagram3.ftile.ConnectionTranslatable; -import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; -import net.sourceforge.plantuml.activitydiagram3.ftile.FtileAssemblySimple; -import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry; -import net.sourceforge.plantuml.activitydiagram3.ftile.FtileKilled; -import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils; -import net.sourceforge.plantuml.activitydiagram3.ftile.Snake; -import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; -import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileThinSplit; -import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.HtmlColorAndStyle; -import net.sourceforge.plantuml.graphic.Rainbow; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.UTranslate; - -public class ParallelBuilderSplit2 extends ParallelFtilesBuilder { - - public ParallelBuilderSplit2(ISkinParam skinParam, StringBounder stringBounder, final List list, - Ftile inner, Swimlane swimlane) { - super(skinParam, stringBounder, list, inner, swimlane); - } - - @Override - protected Ftile doStep1() { - Ftile result = getMiddle(); - final List conns = new ArrayList(); - final Rainbow thinColor = result.getInLinkRendering().getRainbow(HtmlColorAndStyle.build(skinParam())); - final Ftile thin = new FtileThinSplit(skinParam(), getThin1Color(thinColor), getList().get(0).getSwimlaneIn()); - double x = 0; - double first = 0; - double last = 0; - for (Ftile tmp : getList()) { - final FtileGeometry dim = tmp.calculateDimension(getStringBounder()); - if (first == 0) { - first = x + dim.getLeft(); - } - last = x + dim.getLeft(); - final Rainbow rainbow = tmp.getInLinkRendering().getRainbow(HtmlColorAndStyle.build(skinParam())); - conns.add(new ConnectionIn(thin, tmp, x, rainbow)); - x += dim.getWidth(); - } - - result = FtileUtils.addConnection(result, conns); - final FtileGeometry geom = result.calculateDimension(getStringBounder()); - if (last < geom.getLeft()) { - last = geom.getLeft(); - } - if (first > geom.getLeft()) { - first = geom.getLeft(); - } - ((FtileThinSplit) thin).setGeom(first, last, result.calculateDimension(getStringBounder()).getWidth()); - - return new FtileAssemblySimple(thin, result); - } - - private HtmlColor getThin1Color(final Rainbow thinColor) { - for (Ftile tmp : getList()) { - final Rainbow rainbow = tmp.getInLinkRendering().getRainbow(HtmlColorAndStyle.build(skinParam())); - if (rainbow.isInvisible() == false) { - return thinColor.getColor(); - } - } - return null; - } - - private boolean hasOut() { - for (Ftile tmp : getList()) { - final boolean hasOutTmp = tmp.calculateDimension(getStringBounder()).hasPointOut(); - if (hasOutTmp) { - return true; - } - } - return false; - } - - @Override - protected Ftile doStep2(Ftile result) { - - final FtileGeometry geom = result.calculateDimension(getStringBounder()); - if (hasOut() == false) { - return new FtileKilled(result); - } - - final Rainbow thinColor = result.getInLinkRendering().getRainbow(HtmlColorAndStyle.build(skinParam())); - // final Ftile out = new FtileThinSplit(skinParam(), thinColor.getColor(), getList().get(0).getSwimlaneIn()); - final Ftile out = new FtileThinSplit(skinParam(), thinColor.getColor(), swimlane()); - result = new FtileAssemblySimple(result, out); - final List conns = new ArrayList(); - double x = 0; - double first = 0; - double last = 0; - for (Ftile tmp : getList()) { - final UTranslate translate0 = new UTranslate(0, 1.5); - final FtileGeometry dim = tmp.calculateDimension(getStringBounder()); - if (dim.hasPointOut()) { - if (first == 0) { - first = x + dim.getLeft(); - } - last = x + dim.getLeft(); - } - conns.add(new ConnectionOut(translate0, tmp, out, x, tmp.getOutLinkRendering().getRainbow( - HtmlColorAndStyle.build(skinParam())), getHeightOfMiddle())); - x += dim.getWidth(); - } - if (last < geom.getLeft()) { - last = geom.getLeft(); - } - if (first > geom.getLeft()) { - first = geom.getLeft(); - } - ((FtileThinSplit) out).setGeom(first, last, geom.getWidth()); - result = FtileUtils.addConnection(result, conns); - return result; - } - - class ConnectionIn extends AbstractConnection implements ConnectionTranslatable { - - private final double x; - private final Rainbow arrowColor; - private final Display label; - - public ConnectionIn(Ftile ftile1, Ftile ftile2, double x, Rainbow arrowColor) { - super(ftile1, ftile2); - label = ftile2.getInLinkRendering().getDisplay(); - this.x = x; - this.arrowColor = arrowColor; - } - - public void drawU(UGraphic ug) { - ug = ug.apply(new UTranslate(x, 0)); - final FtileGeometry geo = getFtile2().calculateDimension(getStringBounder()); - final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, Arrows.asToDown()); - if (Display.isNull(label) == false) { - snake.setLabel(getTextBlock(label)); - } - snake.addPoint(geo.getLeft(), 0); - snake.addPoint(geo.getLeft(), geo.getInY()); - ug.draw(snake); - } - - public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) { - ug = ug.apply(new UTranslate(x, 0)); - final FtileGeometry geo = getFtile2().calculateDimension(getStringBounder()); - final Point2D p1 = new Point2D.Double(geo.getLeft(), 0); - final Point2D p2 = new Point2D.Double(geo.getLeft(), geo.getInY()); - - final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, Arrows.asToDown()); - if (Display.isNull(label) == false) { - snake.setLabel(getTextBlock(label)); - } - final Point2D mp1a = translate1.getTranslated(p1); - final Point2D mp2b = translate2.getTranslated(p2); - final double middle = mp1a.getY() + 4; - snake.addPoint(mp1a); - snake.addPoint(mp1a.getX(), middle); - snake.addPoint(mp2b.getX(), middle); - snake.addPoint(mp2b); - ug.draw(snake); - } - } - - class ConnectionOut extends AbstractConnection implements ConnectionTranslatable { - - private final double x; - private final Rainbow arrowColor; - private final double height; - private final Display label; - private final UTranslate translate0; - - public ConnectionOut(UTranslate translate0, Ftile ftile1, Ftile ftile2, double x, Rainbow arrowColor, - double height) { - super(ftile1, ftile2); - this.translate0 = translate0; - this.label = ftile1.getOutLinkRendering().getDisplay(); - this.x = x; - this.arrowColor = arrowColor; - this.height = height; - } - - public void drawU(UGraphic ug) { - ug = ug.apply(new UTranslate(x, 0)); - final FtileGeometry geo = getFtile1().calculateDimension(getStringBounder()); - if (geo.hasPointOut() == false) { - return; - } - final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, Arrows.asToDown()); - if (Display.isNull(label) == false) { - snake.setLabel(getTextBlock(label)); - } - final Point2D p1 = translate0.getTranslated(new Point2D.Double(geo.getLeft(), geo.getOutY())); - final Point2D p2 = translate0.getTranslated(new Point2D.Double(geo.getLeft(), height)); - snake.addPoint(p1); - snake.addPoint(p2); - ug.draw(snake); - } - - public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) { - ug = ug.apply(new UTranslate(x, 0)); - final FtileGeometry geo = getFtile1().calculateDimension(getStringBounder()); - if (geo.hasPointOut() == false) { - return; - } - final Point2D p1 = translate0.getTranslated(new Point2D.Double(geo.getLeft(), geo.getOutY())); - final Point2D p2 = translate0.getTranslated(new Point2D.Double(geo.getLeft(), height)); - - final Snake snake = new Snake(arrowHorizontalAlignment(), arrowColor, Arrows.asToDown()); - if (Display.isNull(label) == false) { - snake.setLabel(getTextBlock(label)); - } - final Point2D mp1a = translate1.getTranslated(p1); - final Point2D mp2b = translate2.getTranslated(p2); - final double middle = mp2b.getY() - 14; - snake.addPoint(mp1a); - snake.addPoint(mp1a.getX(), middle); - snake.addPoint(mp2b.getX(), middle); - snake.addPoint(mp2b); - ug.draw(snake); - } - - } - -} diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/VCompactFactory.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/VCompactFactory.java index fb35db333..6f55d0622 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/VCompactFactory.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/VCompactFactory.java @@ -42,6 +42,7 @@ import java.util.List; import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.activitydiagram3.Branch; import net.sourceforge.plantuml.activitydiagram3.ForkStyle; @@ -66,6 +67,11 @@ import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.USymbol; import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.skin.rose.Rose; +import net.sourceforge.plantuml.style.PName; +import net.sourceforge.plantuml.style.SName; +import net.sourceforge.plantuml.style.Style; +import net.sourceforge.plantuml.style.StyleBuilder; +import net.sourceforge.plantuml.style.StyleSignature; import net.sourceforge.plantuml.ugraphic.UFont; public class VCompactFactory implements FtileFactory { @@ -78,19 +84,41 @@ public class VCompactFactory implements FtileFactory { return stringBounder; } + public StyleBuilder getCurrentStyleBuilder() { + return skinParam.getCurrentStyleBuilder(); + } + public VCompactFactory(ISkinParam skinParam, StringBounder stringBounder) { this.skinParam = skinParam; this.stringBounder = stringBounder; } + final public StyleSignature getDefaultStyleDefinitionCircle() { + return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.circle); + } + public Ftile start(Swimlane swimlane) { - final HtmlColor color = rose.getHtmlColor(skinParam, ColorParam.activityStart); - return new FtileCircleStart(skinParam(), color, swimlane); + final HtmlColor color; + Style style = null; + if (SkinParam.USE_STYLES()) { + style = getDefaultStyleDefinitionCircle().getMergedStyle(skinParam.getCurrentStyleBuilder()); + color = style.value(PName.LineColor).asColor(skinParam.getIHtmlColorSet()); + } else { + color = rose.getHtmlColor(skinParam, ColorParam.activityStart); + } + return new FtileCircleStart(skinParam(), color, swimlane, style); } public Ftile stop(Swimlane swimlane) { - final HtmlColor color = rose.getHtmlColor(skinParam, ColorParam.activityEnd); - return new FtileCircleStop(skinParam(), color, swimlane); + final HtmlColor color; + Style style = null; + if (SkinParam.USE_STYLES()) { + style = getDefaultStyleDefinitionCircle().getMergedStyle(skinParam.getCurrentStyleBuilder()); + color = style.value(PName.LineColor).asColor(skinParam.getIHtmlColorSet()); + } else { + color = rose.getHtmlColor(skinParam, ColorParam.activityEnd); + } + return new FtileCircleStop(skinParam(), color, swimlane, style); } public Ftile spot(Swimlane swimlane, String spot) { @@ -100,16 +128,23 @@ public class VCompactFactory implements FtileFactory { } public Ftile end(Swimlane swimlane) { - final HtmlColor color = rose.getHtmlColor(skinParam, ColorParam.activityEnd); - return new FtileCircleEnd(skinParam(), color, swimlane); + final HtmlColor color; + Style style = null; + if (SkinParam.USE_STYLES()) { + style = getDefaultStyleDefinitionCircle().getMergedStyle(skinParam.getCurrentStyleBuilder()); + color = style.value(PName.LineColor).asColor(skinParam.getIHtmlColorSet()); + } else { + color = rose.getHtmlColor(skinParam, ColorParam.activityEnd); + } + return new FtileCircleEnd(skinParam(), color, swimlane, style); } - public Ftile activity(Display label, Swimlane swimlane, BoxStyle style, Colors colors) { + public Ftile activity(Display label, Swimlane swimlane, BoxStyle boxStyle, Colors colors) { // final HtmlColor borderColor = rose.getHtmlColor(skinParam, ColorParam.activityBorder); // final HtmlColor backColor = color == null ? rose.getHtmlColor(skinParam, ColorParam.activityBackground) : // color; final UFont font = skinParam.getFont(null, false, FontParam.ACTIVITY); - return new FtileBox(colors.mute(skinParam), label, font, swimlane, style); + return FtileBox.create(colors.mute(skinParam), label, swimlane, boxStyle); } public Ftile addNote(Ftile ftile, Swimlane swimlane, Collection notes) { @@ -154,7 +189,7 @@ public class VCompactFactory implements FtileFactory { return new FtileForkInner(ftiles); } - public Ftile createParallel(Swimlane swimlane, List all, ForkStyle style, String label) { + public Ftile createParallel(List all, ForkStyle style, String label) { return new FtileForkInner(all); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/ConditionalBuilder.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/ConditionalBuilder.java index fc0d75573..67f5ca270 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/ConditionalBuilder.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/cond/ConditionalBuilder.java @@ -39,6 +39,7 @@ import java.awt.geom.Dimension2D; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.LineBreakStrategy; +import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.activitydiagram3.Branch; import net.sourceforge.plantuml.activitydiagram3.ftile.Diamond; @@ -64,6 +65,10 @@ import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.Rainbow; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; +import net.sourceforge.plantuml.style.PName; +import net.sourceforge.plantuml.style.SName; +import net.sourceforge.plantuml.style.Style; +import net.sourceforge.plantuml.style.StyleSignature; import net.sourceforge.plantuml.svek.ConditionEndStyle; import net.sourceforge.plantuml.svek.ConditionStyle; @@ -87,23 +92,44 @@ public class ConditionalBuilder { private final Ftile tile2; private final Url url; + public StyleSignature getDefaultStyleDefinitionDiamond() { + return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.activity, SName.diamond); + } + + public StyleSignature getDefaultStyleDefinitionArrow() { + return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.arrow); + } + public ConditionalBuilder(Swimlane swimlane, HtmlColor borderColor, HtmlColor backColor, Rainbow arrowColor, FtileFactory ftileFactory, ConditionStyle conditionStyle, ConditionEndStyle conditionEndStyle, Branch branch1, Branch branch2, ISkinParam skinParam, StringBounder stringBounder, FontConfiguration fontArrow, FontConfiguration fontTest, Url url) { - this.swimlane = swimlane; - this.borderColor = borderColor; - this.backColor = backColor; - this.arrowColor = arrowColor; + if (SkinParam.USE_STYLES()) { + final Style styleArrow = getDefaultStyleDefinitionArrow() + .getMergedStyle(skinParam.getCurrentStyleBuilder()); + final Style styleDiamond = getDefaultStyleDefinitionDiamond().getMergedStyle( + skinParam.getCurrentStyleBuilder()); + this.borderColor = styleDiamond.value(PName.LineColor).asColor(skinParam.getIHtmlColorSet()); + this.backColor = styleDiamond.value(PName.BackGroundColor).asColor(skinParam.getIHtmlColorSet()); + this.arrowColor = Rainbow + .fromColor(styleArrow.value(PName.LineColor).asColor(skinParam.getIHtmlColorSet())); + this.fontTest = styleDiamond.getFontConfiguration(skinParam.getIHtmlColorSet()); + this.fontArrow = styleArrow.getFontConfiguration(skinParam.getIHtmlColorSet()); + } else { + this.borderColor = borderColor; + this.backColor = backColor; + this.arrowColor = arrowColor; + this.fontTest = fontTest; + this.fontArrow = fontArrow; + } this.ftileFactory = ftileFactory; + this.swimlane = swimlane; this.conditionStyle = conditionStyle; this.conditionEndStyle = conditionEndStyle; this.branch1 = branch1; this.branch2 = branch2; this.skinParam = skinParam; this.stringBounder = stringBounder; - this.fontArrow = fontArrow; - this.fontTest = fontTest; this.url = url; this.tile1 = new FtileMinWidth(branch1.getFtile(), 30); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBox.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBox.java index 259887521..40080df27 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBox.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBox.java @@ -44,6 +44,9 @@ import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.LineBreakStrategy; +import net.sourceforge.plantuml.SkinParam; +import net.sourceforge.plantuml.SkinParamColors; import net.sourceforge.plantuml.SkinParamUtils; import net.sourceforge.plantuml.activitydiagram3.LinkRendering; import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile; @@ -61,30 +64,54 @@ import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.HtmlColorAndStyle; +import net.sourceforge.plantuml.graphic.Rainbow; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.UDrawable; +import net.sourceforge.plantuml.graphic.color.ColorType; +import net.sourceforge.plantuml.graphic.color.Colors; +import net.sourceforge.plantuml.style.PName; +import net.sourceforge.plantuml.style.SName; +import net.sourceforge.plantuml.style.Style; +import net.sourceforge.plantuml.style.StyleBuilder; +import net.sourceforge.plantuml.style.StyleSignature; import net.sourceforge.plantuml.ugraphic.UChangeBackColor; import net.sourceforge.plantuml.ugraphic.UChangeColor; -import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UTranslate; public class FtileBox extends AbstractFtile { - private static final int MARGIN = 10; + private double padding() { + return padding; + } + private double padding = 10; private final TextBlock tb; + private double roundCorner = 25; + private final double shadowing; + private final HorizontalAlignment horizontalAlignment; + private double minimumWidth = 0; - private final LinkRendering inRenreding; + private final LinkRendering inRendering; private final Swimlane swimlane; - private final BoxStyle style; - // private final ISkinParam skinParam; + private final BoxStyle boxStyle; + + private final HtmlColor borderColor; + private final HtmlColor backColor; + private final Style style; + + static public StyleSignature getDefaultStyleDefinitionActivity() { + return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.activity); + } + + static public StyleSignature getDefaultStyleDefinitionArrow() { + return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.arrow); + } final public LinkRendering getInLinkRendering() { - return inRenreding; + return inRendering; } public Set getSwimlanes() { @@ -105,27 +132,96 @@ public class FtileBox extends AbstractFtile { class MyStencil implements Stencil { public double getStartingX(StringBounder stringBounder, double y) { - return -MARGIN; + return -padding(); } public double getEndingX(StringBounder stringBounder, double y) { final Dimension2D dim = calculateDimension(stringBounder); - return dim.getWidth() - MARGIN; + return dim.getWidth() - padding(); } } - public FtileBox(ISkinParam skinParam, Display label, UFont font, Swimlane swimlane, BoxStyle style) { + public static FtileBox create(ISkinParam skinParam, Display label, Swimlane swimlane, BoxStyle boxStyle) { + Style style = null; + Style styleArrow = null; + if (SkinParam.USE_STYLES()) { + style = getDefaultStyleDefinitionActivity().getMergedStyle(skinParam.getCurrentStyleBuilder()); + styleArrow = getDefaultStyleDefinitionArrow().getMergedStyle(skinParam.getCurrentStyleBuilder()); + } + return new FtileBox(skinParam, label, swimlane, boxStyle, style, styleArrow); + } + + public static FtileBox createWbs(StyleBuilder styleBuilder, ISkinParam skinParam, Display label, + StyleSignature styleDefinition) { + Style style = null; + Style styleArrow = null; + if (SkinParam.USE_STYLES()) { + style = styleDefinition.getMergedStyle(styleBuilder); + styleArrow = style; + } + return new FtileBox(skinParam, label, null, BoxStyle.PLAIN, style, styleArrow); + } + + public static FtileBox createWbs(Style style, ISkinParam skinParam, Display label) { + Style styleArrow = null; + if (SkinParam.USE_STYLES()) { + styleArrow = style; + } + return new FtileBox(skinParam, label, null, BoxStyle.PLAIN, style, styleArrow); + } + + public static FtileBox createMindMap(StyleBuilder styleBuilder, ISkinParam skinParam, Display label, + StyleSignature styleDefinition) { + Style style = null; + Style styleArrow = null; + if (SkinParam.USE_STYLES()) { + style = styleDefinition.getMergedStyle(styleBuilder); + styleArrow = style; + } + return new FtileBox(skinParam, label, null, BoxStyle.PLAIN, style, styleArrow); + } + + private FtileBox(ISkinParam skinParam, Display label, Swimlane swimlane, BoxStyle boxStyle, Style style, + Style styleArrow) { super(skinParam); this.style = style; - // this.skinParam = skinParam; + this.boxStyle = boxStyle; this.swimlane = swimlane; - this.inRenreding = new LinkRendering(HtmlColorAndStyle.build(skinParam)); - final FontConfiguration fc = new FontConfiguration(skinParam, FontParam.ACTIVITY, null); - final Sheet sheet = new CreoleParser(fc, skinParam.getDefaultTextAlignment(HorizontalAlignment.LEFT), - skinParam, CreoleMode.FULL).createSheet(label); - this.tb = new SheetBlock2(new SheetBlock1(sheet, skinParam.wrapWidth(), skinParam.getPadding()), new MyStencil(), new UStroke(1)); + final FontConfiguration fc; + final LineBreakStrategy wrapWidth; + if (SkinParam.USE_STYLES()) { + this.inRendering = new LinkRendering(Rainbow.build(styleArrow, getIHtmlColorSet())); + Colors specBack = null; + if (skinParam instanceof SkinParamColors) { + specBack = ((SkinParamColors) skinParam).getColors(); + } + style = style.eventuallyOverride(specBack); + this.borderColor = style.value(PName.LineColor).asColor(getIHtmlColorSet()); + this.backColor = style.value(PName.BackGroundColor).asColor(getIHtmlColorSet()); + fc = style.getFontConfiguration(getIHtmlColorSet()); + horizontalAlignment = style.getHorizontalAlignment(); + this.padding = style.getPadding().asDouble(); + this.roundCorner = style.value(PName.RoundCorner).asDouble(); + this.shadowing = style.value(PName.Shadowing).asDouble(); + wrapWidth = style.wrapWidth(); + this.minimumWidth = style.value(PName.MinimumWidth).asDouble(); + } else { + this.inRendering = new LinkRendering(Rainbow.build(skinParam)); + this.borderColor = SkinParamUtils.getColor(skinParam(), null, ColorParam.activityBorder); + this.backColor = SkinParamUtils.getColor(skinParam(), null, ColorParam.activityBackground); + fc = new FontConfiguration(skinParam, FontParam.ACTIVITY, null); + horizontalAlignment = HorizontalAlignment.LEFT; + this.shadowing = skinParam().shadowing(null) ? 3.0 : 0.0; + wrapWidth = skinParam.wrapWidth(); + + } + final Sheet sheet = new CreoleParser(fc, skinParam.getDefaultTextAlignment(horizontalAlignment), skinParam, + CreoleMode.FULL).createSheet(label); + this.tb = new SheetBlock2(new SheetBlock1(sheet, wrapWidth, skinParam.getPadding()), new MyStencil(), + new UStroke(1)); this.print = label.toString(); + } final private String print; @@ -139,22 +235,35 @@ public class FtileBox extends AbstractFtile { final Dimension2D dimTotal = calculateDimension(ug.getStringBounder()); final double widthTotal = dimTotal.getWidth(); final double heightTotal = dimTotal.getHeight(); - final UDrawable rect = style.getUDrawable(widthTotal, heightTotal, skinParam().shadowing(null)); + final UDrawable rect = boxStyle.getUDrawable(widthTotal, heightTotal, shadowing, roundCorner); - final HtmlColor borderColor = SkinParamUtils.getColor(skinParam(), null, ColorParam.activityBorder); - final HtmlColor backColor = SkinParamUtils.getColor(skinParam(), null, ColorParam.activityBackground); + final UStroke thickness; + if (SkinParam.USE_STYLES()) { + thickness = style.getStroke(); + } else { + thickness = getThickness(); + } - ug = ug.apply(new UChangeColor(borderColor)).apply(new UChangeBackColor(backColor)).apply(getThickness()); + ug = ug.apply(new UChangeColor(borderColor)).apply(new UChangeBackColor(backColor)).apply(thickness); rect.drawU(ug); - tb.drawU(ug.apply(new UTranslate(MARGIN, MARGIN))); + if (horizontalAlignment == HorizontalAlignment.LEFT) { + tb.drawU(ug.apply(new UTranslate(padding(), padding()))); + } else if (horizontalAlignment == HorizontalAlignment.RIGHT) { + final Dimension2D dimTb = tb.calculateDimension(ug.getStringBounder()); + tb.drawU(ug.apply(new UTranslate(dimTotal.getWidth() - dimTb.getWidth() - padding(), padding()))); + } else if (horizontalAlignment == HorizontalAlignment.CENTER) { + final Dimension2D dimTb = tb.calculateDimension(ug.getStringBounder()); + tb.drawU(ug.apply(new UTranslate((dimTotal.getWidth() - dimTb.getWidth()) / 2, padding()))); + } } @Override protected FtileGeometry calculateDimensionFtile(StringBounder stringBounder) { - final Dimension2D dim = tb.calculateDimension(stringBounder); - return new FtileGeometry(Dimension2DDouble.delta(dim, 2 * MARGIN, 2 * MARGIN), dim.getWidth() / 2 + MARGIN, 0, - dim.getHeight() + 2 * MARGIN); + Dimension2D dim = tb.calculateDimension(stringBounder); + dim = Dimension2DDouble.delta(dim, 2 * padding(), 2 * padding()); + dim = Dimension2DDouble.atLeast(dim, minimumWidth, 0); + return new FtileGeometry(dim, dim.getWidth() / 2, 0, dim.getHeight()); } public Collection getMyChildren() { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileCircleEnd.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileCircleEnd.java index 303f190be..6ea30151a 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileCircleEnd.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileCircleEnd.java @@ -40,6 +40,7 @@ import java.util.Collections; import java.util.Set; import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile; import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry; @@ -47,6 +48,8 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.HtmlColorUtils; import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.style.PName; +import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.ugraphic.UChangeBackColor; import net.sourceforge.plantuml.ugraphic.UChangeColor; import net.sourceforge.plantuml.ugraphic.UEllipse; @@ -61,16 +64,24 @@ public class FtileCircleEnd extends AbstractFtile { private final HtmlColor backColor; private final Swimlane swimlane; + private double shadowing; @Override public Collection getMyChildren() { return Collections.emptyList(); } - public FtileCircleEnd(ISkinParam skinParam, HtmlColor backColor, Swimlane swimlane) { + public FtileCircleEnd(ISkinParam skinParam, HtmlColor backColor, Swimlane swimlane, Style style) { super(skinParam); this.backColor = backColor; this.swimlane = swimlane; + if (SkinParam.USE_STYLES()) { + this.shadowing = style.value(PName.Shadowing).asDouble(); + } else { + if (skinParam().shadowing(null)) { + this.shadowing = 3; + } + } } public Set getSwimlanes() { @@ -95,9 +106,7 @@ public class FtileCircleEnd extends AbstractFtile { yTheoricalPosition = Math.round(yTheoricalPosition); final UEllipse circle = new UEllipse(SIZE, SIZE); - if (skinParam().shadowing(null)) { - circle.setDeltaShadow(3); - } + circle.setDeltaShadow(shadowing); ug = ug.apply(new UChangeColor(backColor)); final double thickness = 2.5; ug.apply(new UChangeBackColor(HtmlColorUtils.WHITE)).apply(new UStroke(1.5)) diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileCircleStart.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileCircleStart.java index 0bda043bc..a192adf47 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileCircleStart.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileCircleStart.java @@ -40,12 +40,15 @@ import java.util.Collections; import java.util.Set; import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile; import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.style.PName; +import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.ugraphic.UChangeBackColor; import net.sourceforge.plantuml.ugraphic.UChangeColor; import net.sourceforge.plantuml.ugraphic.UEllipse; @@ -57,11 +60,20 @@ public class FtileCircleStart extends AbstractFtile { private final HtmlColor backColor; private final Swimlane swimlane; + private double shadowing; - public FtileCircleStart(ISkinParam skinParam, HtmlColor backColor, Swimlane swimlane) { + public FtileCircleStart(ISkinParam skinParam, HtmlColor backColor, Swimlane swimlane, Style style) { super(skinParam); this.backColor = backColor; this.swimlane = swimlane; + if (SkinParam.USE_STYLES()) { + this.shadowing = style.value(PName.Shadowing).asDouble(); + } else { + if (skinParam().shadowing(null)) { + this.shadowing = 3; + } + } + } @Override @@ -86,9 +98,7 @@ public class FtileCircleStart extends AbstractFtile { public void drawU(UGraphic ug) { final UEllipse circle = new UEllipse(SIZE, SIZE); - if (skinParam().shadowing(null)) { - circle.setDeltaShadow(3); - } + circle.setDeltaShadow(shadowing); ug.apply(new UChangeColor(null)).apply(new UChangeBackColor(backColor)).draw(circle); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileCircleStop.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileCircleStop.java index a60e3ae7f..12b1dedd3 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileCircleStop.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileCircleStop.java @@ -40,6 +40,7 @@ import java.util.Collections; import java.util.Set; import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile; import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry; @@ -48,6 +49,8 @@ import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.HtmlColorMiddle; import net.sourceforge.plantuml.graphic.HtmlColorUtils; import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.style.PName; +import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.ugraphic.UChangeBackColor; import net.sourceforge.plantuml.ugraphic.UChangeColor; import net.sourceforge.plantuml.ugraphic.UEllipse; @@ -60,16 +63,24 @@ public class FtileCircleStop extends AbstractFtile { private final HtmlColor backColor; private final Swimlane swimlane; + private double shadowing; @Override public Collection getMyChildren() { return Collections.emptyList(); } - public FtileCircleStop(ISkinParam skinParam, HtmlColor backColor, Swimlane swimlane) { + public FtileCircleStop(ISkinParam skinParam, HtmlColor backColor, Swimlane swimlane, Style style) { super(skinParam); this.backColor = backColor; this.swimlane = swimlane; + if (SkinParam.USE_STYLES()) { + this.shadowing = style.value(PName.Shadowing).asDouble(); + } else { + if (skinParam().shadowing(null)) { + this.shadowing = 3; + } + } } public Set getSwimlanes() { @@ -89,9 +100,7 @@ public class FtileCircleStop extends AbstractFtile { public void drawU(UGraphic ug) { final UEllipse circle = new UEllipse(SIZE, SIZE); - if (skinParam().shadowing(null)) { - circle.setDeltaShadow(3); - } + circle.setDeltaShadow(shadowing); ug.apply(new UChangeColor(backColor)).apply(new UChangeBackColor(HtmlColorUtils.WHITE)).draw(circle); final double delta = 5; diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamond.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamond.java index 12879920f..66f880166 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamond.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamond.java @@ -42,6 +42,7 @@ import java.util.Set; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile; import net.sourceforge.plantuml.activitydiagram3.ftile.Diamond; import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; @@ -51,6 +52,10 @@ import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlockUtils; +import net.sourceforge.plantuml.style.PName; +import net.sourceforge.plantuml.style.SName; +import net.sourceforge.plantuml.style.Style; +import net.sourceforge.plantuml.style.StyleSignature; import net.sourceforge.plantuml.ugraphic.UChangeBackColor; import net.sourceforge.plantuml.ugraphic.UChangeColor; import net.sourceforge.plantuml.ugraphic.UGraphic; @@ -65,12 +70,17 @@ public class FtileDiamond extends AbstractFtile { private final TextBlock south; private final TextBlock west1; private final TextBlock east1; + private final double shadowing; public FtileDiamond(ISkinParam skinParam, HtmlColor backColor, HtmlColor borderColor, Swimlane swimlane) { this(skinParam, backColor, borderColor, swimlane, TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0)); } - + + public StyleSignature getDefaultStyleDefinitionDiamond() { + return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.diamond); + } + @Override public Collection getMyChildren() { return Collections.emptyList(); @@ -101,6 +111,13 @@ public class FtileDiamond extends AbstractFtile { private FtileDiamond(ISkinParam skinParam, HtmlColor backColor, HtmlColor borderColor, Swimlane swimlane, TextBlock north, TextBlock south, TextBlock east1, TextBlock west1) { super(skinParam); + if (SkinParam.USE_STYLES()) { + Style style = getDefaultStyleDefinitionDiamond().getMergedStyle(skinParam.getCurrentStyleBuilder()); + shadowing = style.value(PName.Shadowing).asDouble(); + } else { + shadowing = skinParam().shadowing(null) ? 3 : 0; + } + this.backColor = backColor; this.swimlane = swimlane; this.borderColor = borderColor; @@ -130,7 +147,7 @@ public class FtileDiamond extends AbstractFtile { final double suppY1 = north.calculateDimension(ug.getStringBounder()).getHeight(); ug = ug.apply(new UTranslate(0, suppY1)); ug.apply(new UChangeColor(borderColor)).apply(getThickness()).apply(new UChangeBackColor(backColor)) - .draw(Diamond.asPolygon(skinParam().shadowing(null))); + .draw(Diamond.asPolygon(shadowing)); // final Dimension2D dimNorth = north.calculateDimension(ug.getStringBounder()); north.drawU(ug.apply(new UTranslate(Diamond.diamondHalfSize * 1.5, -suppY1))); @@ -162,11 +179,10 @@ public class FtileDiamond extends AbstractFtile { final Dimension2D dimEast = east1.calculateDimension(stringBounder); return dimEast.getWidth(); } - + public double getSouthLabelHeight(StringBounder stringBounder) { final Dimension2D dimSouth = south.calculateDimension(stringBounder); return dimSouth.getHeight(); } - } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondInside.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondInside.java index 86302878c..14d6b47e6 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondInside.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondInside.java @@ -42,6 +42,7 @@ import java.util.Set; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile; import net.sourceforge.plantuml.activitydiagram3.ftile.Diamond; import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile; @@ -51,12 +52,17 @@ import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlockUtils; +import net.sourceforge.plantuml.style.PName; +import net.sourceforge.plantuml.style.SName; +import net.sourceforge.plantuml.style.Style; +import net.sourceforge.plantuml.style.StyleSignature; +import net.sourceforge.plantuml.style.Styleable; import net.sourceforge.plantuml.ugraphic.UChangeBackColor; import net.sourceforge.plantuml.ugraphic.UChangeColor; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; -public class FtileDiamondInside extends AbstractFtile { +public class FtileDiamondInside extends AbstractFtile implements Styleable { private final HtmlColor backColor; private final HtmlColor borderColor; @@ -66,12 +72,17 @@ public class FtileDiamondInside extends AbstractFtile { private final TextBlock east; private final TextBlock north; private final TextBlock south; + private final double shadowing; @Override public Collection getMyChildren() { return Collections.emptyList(); } + public StyleSignature getDefaultStyleDefinition() { + return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.activity, SName.diamond); + } + public FtileDiamondInside(ISkinParam skinParam, HtmlColor backColor, HtmlColor borderColor, Swimlane swimlane, TextBlock label) { this(skinParam, backColor, borderColor, swimlane, label, TextBlockUtils.empty(0, 0), @@ -101,9 +112,17 @@ public class FtileDiamondInside extends AbstractFtile { private FtileDiamondInside(ISkinParam skinParam, HtmlColor backColor, HtmlColor borderColor, Swimlane swimlane, TextBlock label, TextBlock north, TextBlock south, TextBlock west, TextBlock east) { super(skinParam); - this.backColor = backColor; + if (SkinParam.USE_STYLES()) { + final Style style = getDefaultStyleDefinition().getMergedStyle(skinParam.getCurrentStyleBuilder()); + this.borderColor = style.value(PName.LineColor).asColor(getIHtmlColorSet()); + this.backColor = style.value(PName.BackGroundColor).asColor(getIHtmlColorSet()); + this.shadowing = style.value(PName.Shadowing).asDouble(); + } else { + this.backColor = backColor; + this.borderColor = borderColor; + this.shadowing = skinParam().shadowing(null) ? 3 : 0; + } this.swimlane = swimlane; - this.borderColor = borderColor; this.label = label; this.west = west; this.east = east; @@ -131,7 +150,7 @@ public class FtileDiamondInside extends AbstractFtile { final Dimension2D dimLabel = label.calculateDimension(stringBounder); final Dimension2D dimTotal = calculateDimensionAlone(stringBounder); ug = ug.apply(new UChangeColor(borderColor)).apply(getThickness()).apply(new UChangeBackColor(backColor)); - ug.draw(Diamond.asPolygon(skinParam().shadowing(null), dimTotal.getWidth(), dimTotal.getHeight())); + ug.draw(Diamond.asPolygon(shadowing, dimTotal.getWidth(), dimTotal.getHeight())); north.drawU(ug.apply(new UTranslate(4 + dimTotal.getWidth() / 2, dimTotal.getHeight()))); south.drawU(ug.apply(new UTranslate(4 + dimTotal.getWidth() / 2, dimTotal.getHeight()))); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondInside2.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondInside2.java index 83a750657..d32b92e79 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondInside2.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondInside2.java @@ -41,6 +41,7 @@ import java.util.Set; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile; import net.sourceforge.plantuml.activitydiagram3.ftile.Diamond; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry; @@ -49,6 +50,10 @@ import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlockUtils; +import net.sourceforge.plantuml.style.PName; +import net.sourceforge.plantuml.style.SName; +import net.sourceforge.plantuml.style.Style; +import net.sourceforge.plantuml.style.StyleSignature; import net.sourceforge.plantuml.ugraphic.UChangeBackColor; import net.sourceforge.plantuml.ugraphic.UChangeColor; import net.sourceforge.plantuml.ugraphic.UGraphic; @@ -64,6 +69,7 @@ public class FtileDiamondInside2 extends AbstractFtile { private final TextBlock east; private final TextBlock north; private final TextBlock south; + private final double shadowing; public FtileDiamondInside2(ISkinParam skinParam, HtmlColor backColor, HtmlColor borderColor, Swimlane swimlane, TextBlock label) { @@ -86,10 +92,20 @@ public class FtileDiamondInside2 extends AbstractFtile { public FtileDiamondInside2 withSouth(TextBlock south) { return new FtileDiamondInside2(skinParam(), backColor, borderColor, swimlane, label, north, south, west, east); } + + public StyleSignature getDefaultStyleDefinition() { + return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.activity, SName.diamond); + } private FtileDiamondInside2(ISkinParam skinParam, HtmlColor backColor, HtmlColor borderColor, Swimlane swimlane, TextBlock label, TextBlock north, TextBlock south, TextBlock west, TextBlock east) { super(skinParam); + if (SkinParam.USE_STYLES()) { + final Style style = getDefaultStyleDefinition().getMergedStyle(skinParam.getCurrentStyleBuilder()); + this.shadowing = style.value(PName.Shadowing).asDouble(); + } else { + this.shadowing = skinParam().shadowing(null) ? 3 : 0; + } this.backColor = backColor; this.swimlane = swimlane; this.borderColor = borderColor; @@ -120,7 +136,7 @@ public class FtileDiamondInside2 extends AbstractFtile { final Dimension2D dimLabel = label.calculateDimension(stringBounder); final Dimension2D dimTotal = calculateDimensionAlone(stringBounder); ug = ug.apply(new UChangeColor(borderColor)).apply(getThickness()).apply(new UChangeBackColor(backColor)); - ug.draw(Diamond.asPolygon(skinParam().shadowing(null), dimTotal.getWidth(), dimTotal.getHeight())); + ug.draw(Diamond.asPolygon(shadowing, dimTotal.getWidth(), dimTotal.getHeight())); north.drawU(ug.apply(new UTranslate(4 + dimTotal.getWidth() / 2, dimTotal.getHeight()))); south.drawU(ug.apply(new UTranslate(4 + dimTotal.getWidth() / 2, dimTotal.getHeight()))); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondInside3.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondInside3.java index 223b724a3..71848e5ba 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondInside3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondInside3.java @@ -122,17 +122,18 @@ public class FtileDiamondInside3 extends AbstractFtile implements FtileOverpassi final Dimension2D dimLabel = label.calculateDimension(stringBounder); final Dimension2D dimTotal = calculateDimensionAlone(stringBounder); ug = ug.apply(new UChangeColor(borderColor)).apply(getThickness()).apply(new UChangeBackColor(backColor)); - ug.draw(Diamond.asPolygon(skinParam().shadowing(null), dimTotal.getWidth(), dimTotal.getHeight())); + final double shadowing = skinParam().shadowing(null) ? 3 : 0; + ug.draw(Diamond.asPolygon(shadowing, dimTotal.getWidth(), dimTotal.getHeight())); - north.drawU(ug.apply(new UTranslate(4 + dimTotal.getWidth() / 2, dimTotal.getHeight()))); - south.drawU(ug.apply(new UTranslate(4 + dimTotal.getWidth() / 2, dimTotal.getHeight()))); + north.drawU(ug.apply(new UTranslate(4 + dimTotal.getWidth() / 2, dimTotal.getHeight()))); + south.drawU(ug.apply(new UTranslate(4 + dimTotal.getWidth() / 2, dimTotal.getHeight()))); final double lx = (dimTotal.getWidth() - dimLabel.getWidth()) / 2; final double ly = (dimTotal.getHeight() - dimLabel.getHeight()) / 2; label.drawU(ug.apply(new UTranslate(lx, ly))); final Dimension2D dimWeat = west.calculateDimension(stringBounder); - west.drawU(ug.apply(new UTranslate(-dimWeat.getWidth(), -dimWeat.getHeight() + dimTotal.getHeight() / 2))); + west.drawU(ug.apply(new UTranslate(-dimWeat.getWidth(), -dimWeat.getHeight() + dimTotal.getHeight() / 2))); final Dimension2D dimEast = east.calculateDimension(stringBounder); east.drawU(ug.apply(new UTranslate(dimTotal.getWidth(), -dimEast.getHeight() + dimTotal.getHeight() / 2))); @@ -168,7 +169,7 @@ public class FtileDiamondInside3 extends AbstractFtile implements FtileOverpassi final Dimension2D north = this.north.calculateDimension(stringBounder); final Dimension2D east = this.east.calculateDimension(stringBounder); final Dimension2D west = this.west.calculateDimension(stringBounder); - final double height = total.getHeight(); // + north.getHeight(); + final double height = total.getHeight(); // + north.getHeight(); final double left = total.getWidth() / 2; final double supp = MathUtils.max(north.getWidth(), east.getWidth(), west.getWidth()); // final double width = supp > left ? left + supp : diamond.getWidth(); diff --git a/src/net/sourceforge/plantuml/asciiart/AbstractComponentText.java b/src/net/sourceforge/plantuml/asciiart/AbstractComponentText.java index 1dbc3fb64..65ca48d06 100644 --- a/src/net/sourceforge/plantuml/asciiart/AbstractComponentText.java +++ b/src/net/sourceforge/plantuml/asciiart/AbstractComponentText.java @@ -41,7 +41,7 @@ import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.skin.Component; import net.sourceforge.plantuml.style.Style; -import net.sourceforge.plantuml.style.StyleDefinition; +import net.sourceforge.plantuml.style.StyleSignature; public abstract class AbstractComponentText implements Component { @@ -55,7 +55,7 @@ public abstract class AbstractComponentText implements Component { throw new UnsupportedOperationException(); } - public StyleDefinition getDefaultStyleDefinition() { + public StyleSignature getDefaultStyleDefinition() { throw new UnsupportedOperationException(); } diff --git a/src/net/sourceforge/plantuml/bpm/BpmElement.java b/src/net/sourceforge/plantuml/bpm/BpmElement.java index 58c39a97b..5e293534f 100644 --- a/src/net/sourceforge/plantuml/bpm/BpmElement.java +++ b/src/net/sourceforge/plantuml/bpm/BpmElement.java @@ -138,7 +138,7 @@ public class BpmElement extends AbstractConnectorPuzzle implements ConnectorPuzz public TextBlock toTextBlockInternal(ISkinParam skinParam) { if (type == BpmElementType.START) { - return new FtileCircleStart(skinParam, HtmlColorUtils.BLACK, null); + return new FtileCircleStart(skinParam, HtmlColorUtils.BLACK, null, null); } if (type == BpmElementType.MERGE) { final HtmlColor borderColor = SkinParamUtils.getColor(skinParam, null, ColorParam.activityBorder); @@ -147,7 +147,7 @@ public class BpmElement extends AbstractConnectorPuzzle implements ConnectorPuzz } if (type == BpmElementType.DOCKED_EVENT) { final UFont font = UFont.serif(14); - return new FtileBox(skinParam, display, font, null, BoxStyle.PLAIN); + return FtileBox.create(skinParam, display, null, BoxStyle.PLAIN); } final UFont font = UFont.serif(14); final FontConfiguration fc = new FontConfiguration(font, HtmlColorUtils.RED, HtmlColorUtils.RED, false); diff --git a/src/net/sourceforge/plantuml/classdiagram/ClassDiagram.java b/src/net/sourceforge/plantuml/classdiagram/ClassDiagram.java index fc24089bc..065aa150e 100644 --- a/src/net/sourceforge/plantuml/classdiagram/ClassDiagram.java +++ b/src/net/sourceforge/plantuml/classdiagram/ClassDiagram.java @@ -67,21 +67,6 @@ public class ClassDiagram extends AbstractClassOrObjectDiagram { return getNamespace(fullyCode, fullyCode.getSeparator()); } - private final String getNamespace(Code fullyCode, String separator) { - String name = fullyCode.getFullName(); - if (separator == null) { - throw new IllegalArgumentException(toString()); - } - do { - final int x = name.lastIndexOf(separator); - if (x == -1) { - return null; - } - name = name.substring(0, x); - } while (entityFactory.getLeafsget(Code.of(name, separator)) != null); - return name; - } - public final Code getShortName(Code code) { final String separator = code.getSeparator(); if (separator == null) { diff --git a/src/net/sourceforge/plantuml/command/BlocLines.java b/src/net/sourceforge/plantuml/command/BlocLines.java index 9e82a399f..c450201b3 100644 --- a/src/net/sourceforge/plantuml/command/BlocLines.java +++ b/src/net/sourceforge/plantuml/command/BlocLines.java @@ -55,33 +55,6 @@ public class BlocLines implements Iterable { private List lines; - private void check() { - // for (CharSequence s : lines) { - // // if (s == null) { - // // continue; - // // } - // if (s instanceof String) { - // continue; - // } - // // if (s instanceof Stereotype) { - // // continue; - // // } - // if (s instanceof CharSequence2) { - // continue; - // } - // // if (s instanceof MessageNumber) { - // // continue; - // // } - // // if (s instanceof EmbeddedDiagram) { - // // continue; - // // } - // System.err.println("PB2=" + s); - // System.err.println("PB=" + s.getClass()); - // Thread.dumpStack(); - // System.exit(0); - // } - } - @Override public String toString() { return lines.toString(); @@ -109,7 +82,6 @@ public class BlocLines implements Iterable { private BlocLines(List lines) { this.lines = Collections.unmodifiableList(lines); - this.check(); } public Display toDisplay() { diff --git a/src/net/sourceforge/plantuml/command/CommandFooter.java b/src/net/sourceforge/plantuml/command/CommandFooter.java index 29018a800..bd35ad294 100644 --- a/src/net/sourceforge/plantuml/command/CommandFooter.java +++ b/src/net/sourceforge/plantuml/command/CommandFooter.java @@ -37,7 +37,6 @@ package net.sourceforge.plantuml.command; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.LineLocation; -import net.sourceforge.plantuml.OptionFlags; import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.TitledDiagram; import net.sourceforge.plantuml.UmlDiagram; @@ -76,7 +75,7 @@ public class CommandFooter extends SingleLineCommand2 { if (SkinParam.USE_STYLES()) { defaultAlign = FontParam.FOOTER.getStyleDefinition() .getMergedStyle(((UmlDiagram) diagram).getSkinParam().getCurrentStyleBuilder()) - .value(PName.HorizontalAlignment).asHorizontalAlignment(); + .getHorizontalAlignment(); } diagram.getFooter().putDisplay(Display.getWithNewlines(arg.get("LABEL", 0)), HorizontalAlignment.fromString(align, defaultAlign)); diff --git a/src/net/sourceforge/plantuml/command/CommandHeader.java b/src/net/sourceforge/plantuml/command/CommandHeader.java index f58136a47..da2232dc8 100644 --- a/src/net/sourceforge/plantuml/command/CommandHeader.java +++ b/src/net/sourceforge/plantuml/command/CommandHeader.java @@ -37,7 +37,6 @@ package net.sourceforge.plantuml.command; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.LineLocation; -import net.sourceforge.plantuml.OptionFlags; import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.TitledDiagram; import net.sourceforge.plantuml.UmlDiagram; @@ -78,7 +77,7 @@ public class CommandHeader extends SingleLineCommand2 { if (SkinParam.USE_STYLES()) { defaultAlign = FontParam.HEADER.getStyleDefinition() .getMergedStyle(((UmlDiagram) diagram).getSkinParam().getCurrentStyleBuilder()) - .value(PName.HorizontalAlignment).asHorizontalAlignment(); + .getHorizontalAlignment(); } diagram.getHeader().putDisplay(Display.getWithNewlines(arg.get("LABEL", 0)), HorizontalAlignment.fromString(align, defaultAlign)); diff --git a/src/net/sourceforge/plantuml/command/CommandMultilinesFooter.java b/src/net/sourceforge/plantuml/command/CommandMultilinesFooter.java index d21fb031c..2fedf5bc2 100644 --- a/src/net/sourceforge/plantuml/command/CommandMultilinesFooter.java +++ b/src/net/sourceforge/plantuml/command/CommandMultilinesFooter.java @@ -36,7 +36,6 @@ package net.sourceforge.plantuml.command; import net.sourceforge.plantuml.FontParam; -import net.sourceforge.plantuml.OptionFlags; import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.TitledDiagram; import net.sourceforge.plantuml.UmlDiagram; @@ -70,7 +69,7 @@ public class CommandMultilinesFooter extends CommandMultilines { if (SkinParam.USE_STYLES()) { defaultAlign = FontParam.FOOTER.getStyleDefinition() .getMergedStyle(((UmlDiagram) diagram).getSkinParam().getCurrentStyleBuilder()) - .value(PName.HorizontalAlignment).asHorizontalAlignment(); + .getHorizontalAlignment(); } diagram.getFooter().putDisplay(strings, HorizontalAlignment.fromString(align, defaultAlign)); return CommandExecutionResult.ok(); diff --git a/src/net/sourceforge/plantuml/command/CommandMultilinesHeader.java b/src/net/sourceforge/plantuml/command/CommandMultilinesHeader.java index f164a3454..5b11944c1 100644 --- a/src/net/sourceforge/plantuml/command/CommandMultilinesHeader.java +++ b/src/net/sourceforge/plantuml/command/CommandMultilinesHeader.java @@ -36,7 +36,6 @@ package net.sourceforge.plantuml.command; import net.sourceforge.plantuml.FontParam; -import net.sourceforge.plantuml.OptionFlags; import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.TitledDiagram; import net.sourceforge.plantuml.UmlDiagram; @@ -70,7 +69,7 @@ public class CommandMultilinesHeader extends CommandMultilines { if (SkinParam.USE_STYLES()) { defaultAlign = FontParam.HEADER.getStyleDefinition() .getMergedStyle(((UmlDiagram) diagram).getSkinParam().getCurrentStyleBuilder()) - .value(PName.HorizontalAlignment).asHorizontalAlignment(); + .getHorizontalAlignment(); } diagram.getHeader().putDisplay(strings, HorizontalAlignment.fromString(align, defaultAlign)); return CommandExecutionResult.ok(); diff --git a/src/net/sourceforge/plantuml/command/CommandSpriteFile.java b/src/net/sourceforge/plantuml/command/CommandSpriteFile.java index 44c51b749..c96820378 100644 --- a/src/net/sourceforge/plantuml/command/CommandSpriteFile.java +++ b/src/net/sourceforge/plantuml/command/CommandSpriteFile.java @@ -54,9 +54,9 @@ import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.preproc.FileWithSuffix; -import net.sourceforge.plantuml.ugraphic.sprite.Sprite; -import net.sourceforge.plantuml.ugraphic.sprite.SpriteImage; -import net.sourceforge.plantuml.ugraphic.sprite.SpriteSvg; +import net.sourceforge.plantuml.sprite.Sprite; +import net.sourceforge.plantuml.sprite.SpriteImage; +import net.sourceforge.plantuml.sprite.SpriteSvg; public class CommandSpriteFile extends SingleLineCommand2 { diff --git a/src/net/sourceforge/plantuml/command/FactorySpriteCommand.java b/src/net/sourceforge/plantuml/command/FactorySpriteCommand.java index ab1bd6128..7c9bc6e5b 100644 --- a/src/net/sourceforge/plantuml/command/FactorySpriteCommand.java +++ b/src/net/sourceforge/plantuml/command/FactorySpriteCommand.java @@ -48,9 +48,9 @@ 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.ugraphic.sprite.Sprite; -import net.sourceforge.plantuml.ugraphic.sprite.SpriteColorBuilder4096; -import net.sourceforge.plantuml.ugraphic.sprite.SpriteGrayLevel; +import net.sourceforge.plantuml.sprite.Sprite; +import net.sourceforge.plantuml.sprite.SpriteColorBuilder4096; +import net.sourceforge.plantuml.sprite.SpriteGrayLevel; public final class FactorySpriteCommand implements SingleMultiFactoryCommand { diff --git a/src/net/sourceforge/plantuml/command/UmlDiagramFactory.java b/src/net/sourceforge/plantuml/command/UmlDiagramFactory.java index cfd2f7b09..0cc7fd893 100644 --- a/src/net/sourceforge/plantuml/command/UmlDiagramFactory.java +++ b/src/net/sourceforge/plantuml/command/UmlDiagramFactory.java @@ -44,7 +44,6 @@ import net.sourceforge.plantuml.AbstractPSystem; import net.sourceforge.plantuml.ErrorUml; import net.sourceforge.plantuml.ErrorUmlType; import net.sourceforge.plantuml.LineLocation; -import net.sourceforge.plantuml.Log; import net.sourceforge.plantuml.StringLocated; import net.sourceforge.plantuml.classdiagram.command.CommandHideShowByGender; import net.sourceforge.plantuml.classdiagram.command.CommandHideShowByVisibility; @@ -54,8 +53,9 @@ import net.sourceforge.plantuml.core.UmlSource; import net.sourceforge.plantuml.error.PSystemError; import net.sourceforge.plantuml.error.PSystemErrorUtils; import net.sourceforge.plantuml.sequencediagram.command.CommandSkin; +import net.sourceforge.plantuml.sprite.CommandListSprite; import net.sourceforge.plantuml.statediagram.command.CommandHideEmptyDescription; -import net.sourceforge.plantuml.style.CommandStyleMultilines; +import net.sourceforge.plantuml.style.CommandStyleMultilinesCSS; import net.sourceforge.plantuml.utils.StartUtils; import net.sourceforge.plantuml.version.IteratorCounter2; @@ -219,11 +219,12 @@ public abstract class UmlDiagramFactory extends PSystemAbstractFactory { addTitleCommands(cmds); addCommonCommands2(cmds); addCommonHides(cmds); - cmds.add(new CommandStyleMultilines()); + cmds.add(new CommandStyleMultilinesCSS()); } final protected void addCommonCommands2(List cmds) { + cmds.add(new CommandListSprite()); cmds.add(new CommandNope()); cmds.add(new CommandPragma()); diff --git a/src/net/sourceforge/plantuml/creole/AtomSprite.java b/src/net/sourceforge/plantuml/creole/AtomSprite.java index 9e09e7b2c..0ebaab39c 100644 --- a/src/net/sourceforge/plantuml/creole/AtomSprite.java +++ b/src/net/sourceforge/plantuml/creole/AtomSprite.java @@ -43,8 +43,8 @@ import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.sprite.Sprite; import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.sprite.Sprite; public class AtomSprite extends AbstractAtom implements Atom { diff --git a/src/net/sourceforge/plantuml/creole/AtomText.java b/src/net/sourceforge/plantuml/creole/AtomText.java index f732da461..e3b085d30 100644 --- a/src/net/sourceforge/plantuml/creole/AtomText.java +++ b/src/net/sourceforge/plantuml/creole/AtomText.java @@ -39,6 +39,7 @@ import java.awt.font.LineMetrics; import java.awt.geom.Dimension2D; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.StringTokenizer; @@ -62,10 +63,10 @@ import net.sourceforge.plantuml.graphic.Splitter; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.openiconic.OpenIcon; +import net.sourceforge.plantuml.sprite.Sprite; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UText; import net.sourceforge.plantuml.ugraphic.UTranslate; -import net.sourceforge.plantuml.ugraphic.sprite.Sprite; import net.sourceforge.plantuml.utils.CharHidder; public class AtomText extends AbstractAtom implements Atom { @@ -335,6 +336,53 @@ public class AtomText extends AbstractAtom implements Atom { @Override public List splitInTwo(StringBounder stringBounder, double width) { + final StringBuilder tmp = new StringBuilder(); + for (String token : splitted()) { + if (tmp.length() > 0 && getWidth(stringBounder, tmp.toString() + token) > width) { + final Atom part1 = new AtomText(tmp.toString(), fontConfiguration, url, marginLeft, marginRight); + String remain = text.substring(tmp.length()); + while (remain.startsWith(" ")) { + remain = remain.substring(1); + } + + final Atom part2 = new AtomText(remain, fontConfiguration, url, marginLeft, marginRight); + return Arrays.asList(part1, part2); + } + tmp.append(token); + } + return Collections.singletonList((Atom) this); + } + + private Collection splitted() { + final List result = new ArrayList(); + for (int i = 0; i < text.length(); i++) { + final char ch = text.charAt(i); + if (Character.isLetter(ch)) { + final StringBuilder tmp = new StringBuilder(); + tmp.append(ch); + while (i + 1 < text.length() && Character.isLetter(text.charAt(i + 1))) { + i++; + tmp.append(text.charAt(i)); + } + result.add(tmp.toString()); + } else { + result.add("" + text.charAt(i)); + } + } + return result; + } + + private Collection splittedOld() { + final List result = new ArrayList(); + final StringTokenizer st = new StringTokenizer(text, " ", true); + while (st.hasMoreTokens()) { + final String token = st.nextToken(); + result.add(token); + } + return result; + } + + private List splitInTwoOld(StringBounder stringBounder, double width) { final StringTokenizer st = new StringTokenizer(text, " ", true); final StringBuilder tmp = new StringBuilder(); while (st.hasMoreTokens()) { @@ -358,27 +406,6 @@ public class AtomText extends AbstractAtom implements Atom { return Arrays.asList(add); } - private List splitLong2(StringBounder stringBounder, double maxWidth, String add) { - final List result = new ArrayList(); - if (getWidth(stringBounder, add) <= maxWidth) { - result.add(add); - return result; - } - final StringBuilder current = new StringBuilder(); - for (int i = 0; i < add.length(); i++) { - final char c = add.charAt(i); - if (getWidth(stringBounder, current.toString() + c) > maxWidth) { - result.add(current.toString()); - current.setLength(0); - } - current.append(c); - } - if (current.length() > 0) { - result.add(current.toString()); - } - return result; - } - public final String getText() { return text; } diff --git a/src/net/sourceforge/plantuml/creole/StripeSimple.java b/src/net/sourceforge/plantuml/creole/StripeSimple.java index 1919bb932..15a26ab6a 100644 --- a/src/net/sourceforge/plantuml/creole/StripeSimple.java +++ b/src/net/sourceforge/plantuml/creole/StripeSimple.java @@ -50,7 +50,7 @@ import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.ImgValign; import net.sourceforge.plantuml.math.ScientificEquationSafe; import net.sourceforge.plantuml.openiconic.OpenIcon; -import net.sourceforge.plantuml.ugraphic.sprite.Sprite; +import net.sourceforge.plantuml.sprite.Sprite; import net.sourceforge.plantuml.utils.CharHidder; public class StripeSimple implements Stripe { diff --git a/src/net/sourceforge/plantuml/cucadiagram/Code.java b/src/net/sourceforge/plantuml/cucadiagram/Code.java index 0aa3cd3d0..e67633499 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/Code.java +++ b/src/net/sourceforge/plantuml/cucadiagram/Code.java @@ -123,4 +123,9 @@ public class Code implements Comparable { return separator; } + public String getLastPart() { + final int x = this.fullName.lastIndexOf(separator); + return this.fullName.substring(x + separator.length()); + } + } diff --git a/src/net/sourceforge/plantuml/cucadiagram/CucaDiagram.java b/src/net/sourceforge/plantuml/cucadiagram/CucaDiagram.java index 8c965300f..54fcfa688 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/CucaDiagram.java +++ b/src/net/sourceforge/plantuml/cucadiagram/CucaDiagram.java @@ -80,7 +80,6 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, public abstract IEntity getOrCreateLeaf(Code code, LeafType type, USymbol symbol); - public CucaDiagram(ISkinSimple orig) { super(orig); } @@ -172,7 +171,7 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, if (getNamespaceSeparator() != null) { code = getFullyQualifiedCode(code.withSeparator(getNamespaceSeparator())); } - gotoGroupInternal(code, display, code, type, parent); + gotoGroupInternalWithNamespace(code, display, code, type, parent); } else if (strategy == NamespaceStrategy.SINGLE) { gotoGroupInternal(code, display, null, type, parent); } else { @@ -180,6 +179,47 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, } } + protected final String getNamespace(Code fullyCode, String separator) { + String name = fullyCode.getFullName(); + if (separator == null) { + throw new IllegalArgumentException(toString()); + } + do { + final int x = name.lastIndexOf(separator); + if (x == -1) { + return null; + } + name = name.substring(0, x); + } while (entityFactory.getLeafsget(Code.of(name, separator)) != null); + return name; + } + + final protected void gotoGroupInternalWithNamespace(final Code code, Display display, final Code namespace2, + GroupType type, IGroup parent) { + if (getNamespaceSeparator() == null) { + gotoGroupInternal(code, display, namespace2, type, parent); + return; + } + + final String namespace = getNamespace(code, getNamespaceSeparator()); + if (namespace == null) { + gotoGroupInternal(code, display, namespace2, type, parent); + return; + } + final IGroup realParent = entityFactory.getGroupsget(Code.of(namespace)); + if (realParent == null) { + gotoGroupInternal(code, display, namespace2, type, parent); + return; + } + display = Display.create(code.getLastPart()); + IGroup result = entityFactory.createGroup(code, display, namespace2, type, realParent, getHides(), + getNamespaceSeparator()); + + entityFactory.addGroup(result); + currentGroup = result; + + } + final protected void gotoGroupInternal(final Code code, Display display, final Code namespace2, GroupType type, IGroup parent) { IGroup result = entityFactory.getGroupsget(code); diff --git a/src/net/sourceforge/plantuml/cucadiagram/Display.java b/src/net/sourceforge/plantuml/cucadiagram/Display.java index ec7109841..f48c47f1d 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/Display.java +++ b/src/net/sourceforge/plantuml/cucadiagram/Display.java @@ -71,6 +71,7 @@ import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.graphic.VerticalAlignment; import net.sourceforge.plantuml.sequencediagram.MessageNumber; import net.sourceforge.plantuml.skin.VisibilityModifier; +import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.UStroke; @@ -83,12 +84,12 @@ public class Display implements Iterable { public final static Display NULL = new Display(null, null, true, CreoleMode.FULL); - public Display withoutStereotype() { + public Display withoutStereotype(Style usedStyle) { final List copy = new ArrayList(displayData); final Display result = new Display(naturalHorizontalAlignment, isNull, defaultCreoleMode); for (Iterator it = copy.iterator(); it.hasNext();) { final CharSequence cs = it.next(); - if (cs instanceof Stereotype) { + if (cs instanceof Stereotype && usedStyle.getSignature().match(((Stereotype) cs))) { it.remove(); } } diff --git a/src/net/sourceforge/plantuml/cucadiagram/DisplaySection.java b/src/net/sourceforge/plantuml/cucadiagram/DisplaySection.java index 1e13f8869..24d8ecefc 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/DisplaySection.java +++ b/src/net/sourceforge/plantuml/cucadiagram/DisplaySection.java @@ -39,7 +39,6 @@ import java.util.EnumMap; import java.util.Map; import net.sourceforge.plantuml.ISkinSimple; -import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.TextBlock; diff --git a/src/net/sourceforge/plantuml/cucadiagram/Link.java b/src/net/sourceforge/plantuml/cucadiagram/Link.java index 305d77050..ba2d410df 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/Link.java +++ b/src/net/sourceforge/plantuml/cucadiagram/Link.java @@ -54,6 +54,7 @@ import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.skin.VisibilityModifier; import net.sourceforge.plantuml.style.StyleBuilder; import net.sourceforge.plantuml.svek.Bibliotekon; +import net.sourceforge.plantuml.ugraphic.UComment; import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.utils.UniqueSequence; @@ -99,6 +100,28 @@ public class Link extends WithLinkType implements Hideable, Removeable { private Url url; + public String idCommentForSvg() { + if (type.looksLikeRevertedForSvg()) { + final String comment = getEntity1().getCode().getFullName() + "<-" + getEntity2().getCode().getFullName(); + return comment; + } + if (type.looksLikeNoDecorAtAllSvg()) { + final String comment = getEntity1().getCode().getFullName() + "-" + getEntity2().getCode().getFullName(); + return comment; + } + final String comment = getEntity1().getCode().getFullName() + "->" + getEntity2().getCode().getFullName(); + return comment; + } + + public UComment commentForSvg() { + if (type.looksLikeRevertedForSvg()) { + return new UComment("reverse link " + getEntity1().getCode().getFullName() + " to " + + getEntity2().getCode().getFullName()); + } + return new UComment("link " + getEntity1().getCode().getFullName() + " to " + + getEntity2().getCode().getFullName()); + } + public Link(IEntity cl1, IEntity cl2, LinkType type, Display label, int length, StyleBuilder styleBuilder) { this(cl1, cl2, type, label, length, null, null, null, null, null, styleBuilder); } diff --git a/src/net/sourceforge/plantuml/cucadiagram/LinkType.java b/src/net/sourceforge/plantuml/cucadiagram/LinkType.java index 45614b1c8..2351f1459 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/LinkType.java +++ b/src/net/sourceforge/plantuml/cucadiagram/LinkType.java @@ -50,6 +50,23 @@ public class LinkType { return decor1 != LinkDecor.NONE && decor2 != LinkDecor.NONE; } + public boolean looksLikeRevertedForSvg() { + if (this.decor1 == LinkDecor.NONE && this.decor2 != LinkDecor.NONE) { + return true; + } + return false; + } + + public boolean looksLikeNoDecorAtAllSvg() { + if (this.decor1 == LinkDecor.NONE && this.decor2 == LinkDecor.NONE) { + return true; + } + if (this.decor1 != LinkDecor.NONE && this.decor2 != LinkDecor.NONE) { + return true; + } + return false; + } + public LinkType(LinkDecor decor1, LinkDecor decor2) { this(LinkHat.NONE, decor1, decor2, LinkHat.NONE); } @@ -99,18 +116,6 @@ public class LinkType { this.hat2 = hat2; } - // private boolean isDashed() { - // return style == LinkStyle.DASHED; - // } - // - // private boolean isDotted() { - // return style == LinkStyle.DOTTED; - // } - // - // private boolean isBold() { - // return style == LinkStyle.BOLD; - // } - public boolean isInvisible() { return style.isInvisible(); } @@ -131,14 +136,6 @@ public class LinkType { return new LinkType(hat1, decor1, LinkStyle.BOLD(), middleDecor, decor2, hat2); } - // public LinkType getInterfaceProvider() { - // return new LinkType(hat1, decor1, LinkStyle.__toremove_INTERFACE_PROVIDER, middleDecor, decor2, hat2); - // } - // - // public LinkType getInterfaceUser() { - // return new LinkType(hat1, decor1, LinkStyle.__toremove_INTERFACE_USER, middleDecor, decor2, hat2); - // } - public LinkType getInversed() { return new LinkType(hat2, decor2, style, middleDecor, decor1, hat1); } diff --git a/src/net/sourceforge/plantuml/cucadiagram/Stereotype.java b/src/net/sourceforge/plantuml/cucadiagram/Stereotype.java index a82530f95..d8e260e33 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/Stereotype.java +++ b/src/net/sourceforge/plantuml/cucadiagram/Stereotype.java @@ -58,12 +58,12 @@ import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.HtmlColorUtils; import net.sourceforge.plantuml.graphic.IHtmlColorSet; 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.sprite.Sprite; -import net.sourceforge.plantuml.ugraphic.sprite.SpriteUtils; public class Stereotype implements CharSequence { private final static RegexComposed circleChar = new RegexConcat( // diff --git a/src/net/sourceforge/plantuml/donors/PSystemDonors.java b/src/net/sourceforge/plantuml/donors/PSystemDonors.java index 7ed320bb2..603711039 100644 --- a/src/net/sourceforge/plantuml/donors/PSystemDonors.java +++ b/src/net/sourceforge/plantuml/donors/PSystemDonors.java @@ -89,6 +89,12 @@ public class PSystemDonors extends AbstractPSystem { + "b3kGXTfnVAZuJog6mzInmVABPPAYso0dTRs8ErLGzlKlmaaEXSyxHPKTHLoNoZqn8fdO-L6S-TXdJu6R" + "c-1cwePB1FgU_cwOn45jpHSfDGm7GvwAIAETpri3"; + /* + * Special thanks to our sponsors and donors: + * + * - Noam Tamim + */ + @Override final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed) throws IOException { diff --git a/src/net/sourceforge/plantuml/eps/EpsGraphics.java b/src/net/sourceforge/plantuml/eps/EpsGraphics.java index e63f1d7e5..410ac679a 100644 --- a/src/net/sourceforge/plantuml/eps/EpsGraphics.java +++ b/src/net/sourceforge/plantuml/eps/EpsGraphics.java @@ -218,10 +218,6 @@ public class EpsGraphics { return dashSpace != 0 && dashVisible != 0; } - private boolean isDashed4() { - return dashSpace == 0 && dashVisible == 0; - } - public void closepathDot() { final boolean dashed = isDashed(); append("stroke", true); @@ -481,15 +477,10 @@ public class EpsGraphics { if (isDashed3()) { append("[" + dashSpace + " " + dashVisible + "] 0 setdash", true); } - if (isDashed4() || fill) { + // if (isDashed3() || fill) { append(format(width) + " " + format(height) + " " + format(x) + " " + format(y) + " simplerect", true); simplerectUsed = true; - // } else { - // epsVLine(y, x, x + width); - // epsVLine(y + height, x, x + width); - // epsHLine(x, y, y + height); - // epsHLine(x + width, y, y + height); - } + // } } public void epsEllipse(double x, double y, double xRadius, double yRadius, double start, double extend) { diff --git a/src/net/sourceforge/plantuml/fun/IconLoader.java b/src/net/sourceforge/plantuml/fun/IconLoader.java index 4e3b7b04a..4d16ff679 100644 --- a/src/net/sourceforge/plantuml/fun/IconLoader.java +++ b/src/net/sourceforge/plantuml/fun/IconLoader.java @@ -37,6 +37,9 @@ package net.sourceforge.plantuml.fun; import java.awt.image.BufferedImage; import java.io.IOException; import java.io.InputStream; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -44,19 +47,29 @@ import javax.imageio.ImageIO; public class IconLoader { - private static final int NUMBER_OF_ICONS = 29; - + private static final int NUMBER_OF_ICONS = 30; + private final static Map all = new ConcurrentHashMap(); + static private final List tmp = new ArrayList(); public static BufferedImage getRandom() { - // return addTransparent(getIcon("sprite028.png")); + // return addTransparent(getIcon("sprite029.png")); return addTransparent(getIcon(getSomeQuote())); } private static String getSomeQuote() { - final int v = (int) (System.currentTimeMillis() / 1000L); - final int n = v % NUMBER_OF_ICONS; - return "sprite" + String.format("%03d", n) + ".png"; + synchronized (tmp) { + if (tmp.size() == 0) { + for (int i = 0; i < NUMBER_OF_ICONS; i++) { + tmp.add("sprite" + String.format("%03d", i) + ".png"); + } + Collections.shuffle(tmp); + } + final int size = tmp.size(); + final String result = tmp.get(size - 1); + tmp.remove(size - 1); + return result; + } } private static BufferedImage getIcon(String name) { diff --git a/src/net/sourceforge/plantuml/fun/sprite021.png b/src/net/sourceforge/plantuml/fun/sprite021.png index ef4522ed4..3b6b5418f 100644 Binary files a/src/net/sourceforge/plantuml/fun/sprite021.png and b/src/net/sourceforge/plantuml/fun/sprite021.png differ diff --git a/src/net/sourceforge/plantuml/fun/sprite022.png b/src/net/sourceforge/plantuml/fun/sprite022.png index 664051211..eb90ab9f8 100644 Binary files a/src/net/sourceforge/plantuml/fun/sprite022.png and b/src/net/sourceforge/plantuml/fun/sprite022.png differ diff --git a/src/net/sourceforge/plantuml/fun/sprite023.png b/src/net/sourceforge/plantuml/fun/sprite023.png index 1af6a883b..fc2749e21 100644 Binary files a/src/net/sourceforge/plantuml/fun/sprite023.png and b/src/net/sourceforge/plantuml/fun/sprite023.png differ diff --git a/src/net/sourceforge/plantuml/fun/sprite024.png b/src/net/sourceforge/plantuml/fun/sprite024.png index 0a7599d86..53ea06ccd 100644 Binary files a/src/net/sourceforge/plantuml/fun/sprite024.png and b/src/net/sourceforge/plantuml/fun/sprite024.png differ diff --git a/src/net/sourceforge/plantuml/fun/sprite025.png b/src/net/sourceforge/plantuml/fun/sprite025.png index 81a90a69a..0bbed6e1d 100644 Binary files a/src/net/sourceforge/plantuml/fun/sprite025.png and b/src/net/sourceforge/plantuml/fun/sprite025.png differ diff --git a/src/net/sourceforge/plantuml/fun/sprite026.png b/src/net/sourceforge/plantuml/fun/sprite026.png index 5c8cc8477..165d71828 100644 Binary files a/src/net/sourceforge/plantuml/fun/sprite026.png and b/src/net/sourceforge/plantuml/fun/sprite026.png differ diff --git a/src/net/sourceforge/plantuml/fun/sprite027.png b/src/net/sourceforge/plantuml/fun/sprite027.png index f1d203684..b460f5007 100644 Binary files a/src/net/sourceforge/plantuml/fun/sprite027.png and b/src/net/sourceforge/plantuml/fun/sprite027.png differ diff --git a/src/net/sourceforge/plantuml/fun/sprite028.png b/src/net/sourceforge/plantuml/fun/sprite028.png index e86483d8a..a0bce63da 100644 Binary files a/src/net/sourceforge/plantuml/fun/sprite028.png and b/src/net/sourceforge/plantuml/fun/sprite028.png differ diff --git a/src/net/sourceforge/plantuml/fun/sprite029.png b/src/net/sourceforge/plantuml/fun/sprite029.png new file mode 100644 index 000000000..f8e8a9111 Binary files /dev/null and b/src/net/sourceforge/plantuml/fun/sprite029.png differ diff --git a/src/net/sourceforge/plantuml/graphic/HorizontalAlignment.java b/src/net/sourceforge/plantuml/graphic/HorizontalAlignment.java index d70a2dc44..e0c453ebc 100644 --- a/src/net/sourceforge/plantuml/graphic/HorizontalAlignment.java +++ b/src/net/sourceforge/plantuml/graphic/HorizontalAlignment.java @@ -35,7 +35,11 @@ */ package net.sourceforge.plantuml.graphic; +import java.awt.geom.Dimension2D; + import net.sourceforge.plantuml.StringUtils; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UTranslate; public enum HorizontalAlignment { @@ -73,4 +77,17 @@ public enum HorizontalAlignment { return toString().substring(0, 1).toLowerCase(); } + public void draw(UGraphic ug, TextBlock tb, double padding, Dimension2D dimTotal) { + if (this == HorizontalAlignment.LEFT) { + tb.drawU(ug.apply(new UTranslate(padding, padding))); + } else if (this == HorizontalAlignment.RIGHT) { + final Dimension2D dimTb = tb.calculateDimension(ug.getStringBounder()); + tb.drawU(ug.apply(new UTranslate(dimTotal.getWidth() - dimTb.getWidth() - padding, padding))); + } else if (this == HorizontalAlignment.CENTER) { + final Dimension2D dimTb = tb.calculateDimension(ug.getStringBounder()); + tb.drawU(ug.apply(new UTranslate((dimTotal.getWidth() - dimTb.getWidth()) / 2, padding))); + } + + } + } \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/graphic/HtmlColorAndStyle.java b/src/net/sourceforge/plantuml/graphic/HtmlColorAndStyle.java index a3a5a2317..afe11da01 100644 --- a/src/net/sourceforge/plantuml/graphic/HtmlColorAndStyle.java +++ b/src/net/sourceforge/plantuml/graphic/HtmlColorAndStyle.java @@ -35,15 +35,16 @@ */ package net.sourceforge.plantuml.graphic; -import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.cucadiagram.LinkStyle; -import net.sourceforge.plantuml.skin.rose.Rose; +import net.sourceforge.plantuml.style.PName; +import net.sourceforge.plantuml.style.SName; +import net.sourceforge.plantuml.style.Style; +import net.sourceforge.plantuml.style.StyleSignature; public class HtmlColorAndStyle { - private final static Rose rose = new Rose(); - private final HtmlColor color; private final LinkStyle style; @@ -52,18 +53,7 @@ public class HtmlColorAndStyle { return color + " " + style; } - public static Rainbow fromColor(HtmlColor color) { - if (color == null) { - return Rainbow.none(); - } - return Rainbow.build(new HtmlColorAndStyle(color)); - } - - public static Rainbow build(ISkinParam skinParam) { - return fromColor(rose.getHtmlColor(skinParam, ColorParam.arrow)); - } - - private HtmlColorAndStyle(HtmlColor color) { + public HtmlColorAndStyle(HtmlColor color) { this(color, LinkStyle.NORMAL()); } @@ -83,8 +73,18 @@ public class HtmlColorAndStyle { return style; } + static final public StyleSignature getDefaultStyleDefinitionArrow() { + return StyleSignature.of(SName.root, SName.element, SName.activityDiagram, SName.arrow); + } + public static HtmlColorAndStyle build(ISkinParam skinParam, String definition) { - HtmlColor color = build(skinParam).getColors().get(0).color; + HtmlColor color; + if (SkinParam.USE_STYLES()) { + final Style style = getDefaultStyleDefinitionArrow().getMergedStyle(skinParam.getCurrentStyleBuilder()); + color = style.value(PName.LineColor).asColor(skinParam.getIHtmlColorSet()); + } else { + color = Rainbow.build(skinParam).getColors().get(0).color; + } LinkStyle style = LinkStyle.NORMAL(); final IHtmlColorSet set = skinParam.getIHtmlColorSet(); for (String s : definition.split(",")) { diff --git a/src/net/sourceforge/plantuml/graphic/QuoteUtils.java b/src/net/sourceforge/plantuml/graphic/QuoteUtils.java index 0b40fa611..caf40f4ac 100644 --- a/src/net/sourceforge/plantuml/graphic/QuoteUtils.java +++ b/src/net/sourceforge/plantuml/graphic/QuoteUtils.java @@ -35,7 +35,9 @@ */ package net.sourceforge.plantuml.graphic; +import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; public class QuoteUtils { @@ -315,13 +317,31 @@ public class QuoteUtils { "Whfg zragnyyl gubhtu... ner lbh bxnl ?", "Jr xabj fur'f bxnl orpnhfr fur'f oybaq", "Gh oyhssrf Znegbav", "Lbh thlf ner trggvat cnvq?", "Gurer'f n erq guvatl zbivat gbjneqf gur terra guvatl... V guvax jr'er gur terra guvatl", - "Nyy flfgrzf ner shapgvbavat Pbzznaqre"); + "Nyy flfgrzf ner shapgvbavat Pbzznaqre", "V erzrzore gung fbhaq! Gung'f n onq fbhaq!", + "V xabj vg'f uneq sbe lbh gb haqrefgnaq rira fubeg fragraprf", + "Gur havirefr vf shyy bs vagryyvtrag yvsr. Vg'f whfg orra gbb vagryyvtrag gb pbzr urer.", + "Uryyb, jbhyq lbh yvxr gb urne n GPC wbxr ?", + "Rirel snvel gnyr arrqf n tbbq byq-snfuvbarq ivyynva", + "Fvapr gurer'f ab pbapyhfvba gb gur cnenqbk gurbel, gurer'f ab jnl gb cebir gurer'f ab cnenqbk.", + "Gnxr zr guebhtu gur qnexarff gb gur oernx bs gur qnl", + "Vg znxrf gur gehgu rira zber vapbzcerurafvoyr orpnhfr rirelguvat vf arj", + "V qba'g xabj ubj ohg V fhqqrayl ybfr pbageby", "Gurer ner zbzragf jura V guvax V'z tbvat penml"); private QuoteUtils() { } + static private final List tmp = new ArrayList(); + public static String getSomeQuote() { - final int v = (int) (System.currentTimeMillis() / 1000L); - return quotes.get(v % quotes.size()); + synchronized (tmp) { + if (tmp.size() == 0) { + tmp.addAll(quotes); + Collections.shuffle(tmp); + } + final int size = tmp.size(); + final String result = tmp.get(size - 1); + tmp.remove(size - 1); + return result; + } } } diff --git a/src/net/sourceforge/plantuml/graphic/Rainbow.java b/src/net/sourceforge/plantuml/graphic/Rainbow.java index 7c95b50f3..270a491b3 100644 --- a/src/net/sourceforge/plantuml/graphic/Rainbow.java +++ b/src/net/sourceforge/plantuml/graphic/Rainbow.java @@ -39,10 +39,17 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.SkinParam; +import net.sourceforge.plantuml.skin.rose.Rose; +import net.sourceforge.plantuml.style.PName; +import net.sourceforge.plantuml.style.Style; public class Rainbow { + private final static Rose rose = new Rose(); + private final List colors = new ArrayList(); private final int colorArrowSeparationSpace; @@ -58,6 +65,27 @@ public class Rainbow { public static Rainbow none() { return new Rainbow(0); } + + public static Rainbow fromColor(HtmlColor color) { + if (color == null) { + return Rainbow.none(); + } + return Rainbow.build(new HtmlColorAndStyle(color)); + } + + public static Rainbow build(ISkinParam skinParam) { + if (SkinParam.USE_STYLES()) { + throw new IllegalStateException(); + } + return fromColor(rose.getHtmlColor(skinParam, ColorParam.arrow)); + } + + public static Rainbow build(Style style, IHtmlColorSet set) { + final HtmlColor color = style.value(PName.LineColor).asColor(set); + return fromColor(color); + } + + public Rainbow withDefault(Rainbow defaultColor) { if (this.size() == 0) { diff --git a/src/net/sourceforge/plantuml/graphic/SingleLine.java b/src/net/sourceforge/plantuml/graphic/SingleLine.java index 3c8400a0b..e0848297f 100644 --- a/src/net/sourceforge/plantuml/graphic/SingleLine.java +++ b/src/net/sourceforge/plantuml/graphic/SingleLine.java @@ -42,9 +42,9 @@ import java.util.List; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.SpriteContainer; import net.sourceforge.plantuml.Url; +import net.sourceforge.plantuml.sprite.Sprite; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; -import net.sourceforge.plantuml.ugraphic.sprite.Sprite; class SingleLine extends AbstractTextBlock implements Line { diff --git a/src/net/sourceforge/plantuml/graphic/Splitter.java b/src/net/sourceforge/plantuml/graphic/Splitter.java index 271539ef1..b0fa5f05d 100644 --- a/src/net/sourceforge/plantuml/graphic/Splitter.java +++ b/src/net/sourceforge/plantuml/graphic/Splitter.java @@ -46,7 +46,7 @@ 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.ugraphic.sprite.SpriteUtils; +import net.sourceforge.plantuml.sprite.SpriteUtils; public class Splitter { diff --git a/src/net/sourceforge/plantuml/graphic/SymbolContext.java b/src/net/sourceforge/plantuml/graphic/SymbolContext.java index 1b4d58bce..1f7820c7d 100644 --- a/src/net/sourceforge/plantuml/graphic/SymbolContext.java +++ b/src/net/sourceforge/plantuml/graphic/SymbolContext.java @@ -45,17 +45,15 @@ public class SymbolContext { private final HtmlColor backColor; private final HtmlColor foreColor; private final UStroke stroke; - private final boolean shadowing; private final double deltaShadow; private final double roundCorner; private final double diagonalCorner; - private SymbolContext(HtmlColor backColor, HtmlColor foreColor, UStroke stroke, boolean shadowing, - double deltaShadow, double roundCorner, double diagonalCorner) { + private SymbolContext(HtmlColor backColor, HtmlColor foreColor, UStroke stroke, double deltaShadow, + double roundCorner, double diagonalCorner) { this.backColor = backColor; this.foreColor = foreColor; this.stroke = stroke; - this.shadowing = shadowing; this.deltaShadow = deltaShadow; this.roundCorner = roundCorner; this.diagonalCorner = diagonalCorner; @@ -84,38 +82,37 @@ public class SymbolContext { public SymbolContext transparentBackColorToNull() { if (backColor instanceof HtmlColorTransparent) { - return new SymbolContext(null, foreColor, stroke, shadowing, deltaShadow, roundCorner, diagonalCorner); + return new SymbolContext(null, foreColor, stroke, deltaShadow, roundCorner, diagonalCorner); } return this; } public SymbolContext(HtmlColor backColor, HtmlColor foreColor) { - this(backColor, foreColor, new UStroke(), false, 0, 0, 0); + this(backColor, foreColor, new UStroke(), 0, 0, 0); } - public SymbolContext withShadow(boolean newShadow) { - return new SymbolContext(backColor, foreColor, stroke, newShadow, deltaShadow, roundCorner, diagonalCorner); + public SymbolContext withShadow(double deltaShadow2) { + return new SymbolContext(backColor, foreColor, stroke, deltaShadow2, roundCorner, diagonalCorner); } - public SymbolContext withDeltaShadow(double deltaShadow) { - return new SymbolContext(backColor, foreColor, stroke, deltaShadow != 0, deltaShadow, roundCorner, - diagonalCorner); + public SymbolContext withDeltaShadow(double deltaShadow2) { + return new SymbolContext(backColor, foreColor, stroke, deltaShadow2, roundCorner, diagonalCorner); } public SymbolContext withStroke(UStroke newStroke) { - return new SymbolContext(backColor, foreColor, newStroke, shadowing, deltaShadow, roundCorner, diagonalCorner); + return new SymbolContext(backColor, foreColor, newStroke, deltaShadow, roundCorner, diagonalCorner); } public SymbolContext withBackColor(HtmlColor backColor) { - return new SymbolContext(backColor, foreColor, stroke, shadowing, deltaShadow, roundCorner, diagonalCorner); + return new SymbolContext(backColor, foreColor, stroke, deltaShadow, roundCorner, diagonalCorner); } public SymbolContext withForeColor(HtmlColor foreColor) { - return new SymbolContext(backColor, foreColor, stroke, shadowing, deltaShadow, roundCorner, diagonalCorner); + return new SymbolContext(backColor, foreColor, stroke, deltaShadow, roundCorner, diagonalCorner); } public SymbolContext withCorner(double roundCorner, double diagonalCorner) { - return new SymbolContext(backColor, foreColor, stroke, shadowing, deltaShadow, roundCorner, diagonalCorner); + return new SymbolContext(backColor, foreColor, stroke, deltaShadow, roundCorner, diagonalCorner); } public HtmlColor getBackColor() { @@ -131,7 +128,7 @@ public class SymbolContext { } public boolean isShadowing() { - return shadowing || deltaShadow > 0; + return deltaShadow > 0; } public double getDeltaShadow() { diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockUtils.java b/src/net/sourceforge/plantuml/graphic/TextBlockUtils.java index d399407ae..8297b19d5 100644 --- a/src/net/sourceforge/plantuml/graphic/TextBlockUtils.java +++ b/src/net/sourceforge/plantuml/graphic/TextBlockUtils.java @@ -76,9 +76,9 @@ public class TextBlockUtils { } public static TextBlock title(FontConfiguration font, Display stringsToDisplay, ISkinParam skinParam) { - // if (SkinParam.USE_STYLES()) { - // throw new UnsupportedOperationException(); - // } + if (SkinParam.USE_STYLES()) { + throw new UnsupportedOperationException(); + } UStroke stroke = skinParam.getThickness(LineParam.titleBorder, null); final Rose rose = new Rose(); HtmlColor borderColor = rose.getHtmlColor(skinParam, ColorParam.titleBorder); diff --git a/src/net/sourceforge/plantuml/mindmap/FingerImpl.java b/src/net/sourceforge/plantuml/mindmap/FingerImpl.java index cdee30fe4..e0b531a8d 100644 --- a/src/net/sourceforge/plantuml/mindmap/FingerImpl.java +++ b/src/net/sourceforge/plantuml/mindmap/FingerImpl.java @@ -44,7 +44,8 @@ import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.Direction; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; -import net.sourceforge.plantuml.activitydiagram3.ftile.BoxStyle; +import net.sourceforge.plantuml.SkinParam; +import net.sourceforge.plantuml.SkinParamBackcolored; import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileBox; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; @@ -55,27 +56,54 @@ import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.graphic.color.Colors; +import net.sourceforge.plantuml.style.PName; +import net.sourceforge.plantuml.style.SName; +import net.sourceforge.plantuml.style.Style; +import net.sourceforge.plantuml.style.StyleBuilder; +import net.sourceforge.plantuml.style.StyleSignature; import net.sourceforge.plantuml.ugraphic.UChangeColor; import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UPath; +import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UTranslate; public class FingerImpl implements Finger, UDrawable { private final Display label; + private final HtmlColor backColor; private final ISkinParam skinParam; + private final StyleBuilder styleBuilder; private final IdeaShape shape; private final Direction direction; + private final int level; private boolean drawPhalanx = true; + private double margin = 10; private final List nail = new ArrayList(); + private Tetris tetris = null; + + public StyleSignature getDefaultStyleDefinitionNode() { + if (level == 0) { + return StyleSignature.of(SName.root, SName.element, SName.mindmapDiagram, SName.node, SName.rootNode); + } + if (nail.size() == 0) { + return StyleSignature.of(SName.root, SName.element, SName.mindmapDiagram, SName.node, SName.leafNode); + } + return StyleSignature.of(SName.root, SName.element, SName.mindmapDiagram, SName.node); + } + + public StyleSignature getDefaultStyleDefinitionArrow() { + return StyleSignature.of(SName.root, SName.element, SName.mindmapDiagram, SName.arrow); + } public static FingerImpl build(Idea idea, ISkinParam skinParam, Direction direction) { - final FingerImpl result = new FingerImpl(idea.getLabel(), skinParam, idea.getShape(), direction); + final FingerImpl result = new FingerImpl(idea.getStyleBuilder(), idea.getBackColor(), idea.getLabel(), + skinParam, idea.getShape(), direction, idea.getLevel()); for (Idea child : idea.getChildren()) { result.addInNail(build(child, skinParam, direction)); } + // System.err.println("End of build for " + idea); return result; } @@ -83,47 +111,17 @@ public class FingerImpl implements Finger, UDrawable { nail.add(child); } - private FingerImpl(Display label, ISkinParam skinParam, IdeaShape shape, Direction direction) { + private FingerImpl(StyleBuilder styleBuilder, HtmlColor backColor, Display label, ISkinParam skinParam, + IdeaShape shape, Direction direction, int level) { + this.backColor = backColor; + this.level = level; this.label = label; this.skinParam = skinParam; this.shape = shape; + this.styleBuilder = styleBuilder; this.direction = direction; - } - - public double getPhalanxThickness(StringBounder stringBounder) { - return getPhalanx().calculateDimension(stringBounder).getHeight(); - } - - public double getPhalanxElongation(StringBounder stringBounder) { - return getPhalanx().calculateDimension(stringBounder).getWidth(); - } - - public double getNailThickness(StringBounder stringBounder) { - double result = 0; - for (FingerImpl child : nail) { - result += child.getFullThickness(stringBounder); - } - return result; - } - - public double getNailElongation(StringBounder stringBounder) { - double result = 0; - for (FingerImpl child : nail) { - result = Math.max(result, child.getFullElongation(stringBounder)); - } - return result; - } - - public double getFullElongation(StringBounder stringBounder) { - return getPhalanxElongation(stringBounder) + marginX1 + getNailElongation(stringBounder); - } - - public double getFullThickness(StringBounder stringBounder) { - return Math.max(getPhalanxThickness(stringBounder), getNailThickness(stringBounder)); - } - - public void doNotDrawFirstPhalanx() { - this.drawPhalanx = false; + final Style styleNode = getDefaultStyleDefinitionNode().getMergedStyle(styleBuilder); + this.margin = styleNode.getMargin().asDouble(); } public void drawU(final UGraphic ug) { @@ -138,25 +136,35 @@ public class FingerImpl implements Finger, UDrawable { final Point2D p1 = new Point2D.Double(direction == Direction.RIGHT ? dimPhalanx.getWidth() : -dimPhalanx.getWidth(), 0); - double y = -getFullThickness(stringBounder) / 2; - for (FingerImpl child : nail) { - final double childThickness = child.getFullThickness(stringBounder); - final double x = direction == Direction.RIGHT ? dimPhalanx.getWidth() + marginX1 : -dimPhalanx.getWidth() - - marginX1; - child.drawU(ug.apply(new UTranslate(x, y + childThickness / 2))); - final Point2D p2 = new Point2D.Double(x, y + childThickness / 2); - drawLine(ug.apply(new UChangeColor(getLinkColor())), p1, p2); - y += childThickness; + for (int i = 0; i < nail.size(); i++) { + final FingerImpl child = nail.get(i); + final SymetricalTeePositioned stp = tetris(stringBounder).getElements().get(i); + final double x = direction == Direction.RIGHT ? dimPhalanx.getWidth() + getX12() : -dimPhalanx.getWidth() + - getX12(); + final Point2D p2 = new Point2D.Double(x, stp.getY()); + child.drawU(ug.apply(new UTranslate(p2))); + drawLine(ug.apply(new UChangeColor(getLinkColor())).apply(getUStroke()), p1, p2); } + } private HtmlColor getLinkColor() { - // return skinParam.getColors(ColorParam.activityBorder, null).getColor(ColorType.ARROW); + if (SkinParam.USE_STYLES()) { + final Style styleArrow = getDefaultStyleDefinitionArrow().getMergedStyle(styleBuilder); + return styleArrow.value(PName.LineColor).asColor(skinParam.getIHtmlColorSet()); + + } return ColorParam.activityBorder.getDefaultValue(); - // return HtmlColorUtils.BLACK; } - final private double marginX1 = 50; + private UStroke getUStroke() { + if (SkinParam.USE_STYLES()) { + final Style styleArrow = getDefaultStyleDefinitionArrow().getMergedStyle(styleBuilder); + return styleArrow.getStroke(); + + } + return new UStroke(); + } private void drawLine(UGraphic ug, Point2D p1, Point2D p2) { // final ULine line = new ULine(p1, p2); @@ -171,17 +179,97 @@ public class FingerImpl implements Finger, UDrawable { ug.draw(path); } + private Tetris tetris(StringBounder stringBounder) { + if (tetris == null) { + tetris = new Tetris(label.toString()); + for (FingerImpl child : nail) { + tetris.add(child.asSymetricalTee(stringBounder)); + } + tetris.balance(); + } + return tetris; + } + + private SymetricalTee asSymetricalTee(StringBounder stringBounder) { + final double thickness1 = getPhalanxThickness(stringBounder); + final double elongation1 = getPhalanxElongation(stringBounder); + if (nail.size() == 0) { + return new SymetricalTee(thickness1, elongation1, 0, 0); + } + final double thickness2 = getNailThickness(stringBounder); + final double elongation2 = getNailElongation(stringBounder); + return new SymetricalTee(thickness1, elongation1 + getX1(), thickness2, getX2() + elongation2); + } + + private double getX1() { + return margin(); + } + + private double getX2() { + return margin() + 30; + } + + public double getX12() { + return getX1() + getX2(); + } + + public double getPhalanxThickness(StringBounder stringBounder) { + return getPhalanx().calculateDimension(stringBounder).getHeight(); + } + + public double getPhalanxElongation(StringBounder stringBounder) { + return getPhalanx().calculateDimension(stringBounder).getWidth(); + } + private TextBlock getPhalanx() { if (drawPhalanx == false) { return TextBlockUtils.empty(0, 0); } - final UFont font = skinParam.getFont(null, false, FontParam.ACTIVITY); - if (shape == IdeaShape.BOX) { - final FtileBox box = new FtileBox(Colors.empty().mute(skinParam), label, font, null, BoxStyle.PLAIN); - return TextBlockUtils.withMargin(box, 0, 10); + final UFont font; + if (SkinParam.USE_STYLES()) { + final Style styleNode = getDefaultStyleDefinitionNode().getMergedStyle(styleBuilder); + font = styleNode.getUFont(); + } else { + font = skinParam.getFont(null, false, FontParam.ACTIVITY); } - return TextBlockUtils.withMargin( - label.create(FontConfiguration.blackBlueTrue(font), HorizontalAlignment.LEFT, skinParam), 5, 5); + if (shape == IdeaShape.BOX) { + final ISkinParam foo = new SkinParamBackcolored(Colors.empty().mute(skinParam), backColor); + final FtileBox box = FtileBox.createMindMap(styleBuilder, foo, label, getDefaultStyleDefinitionNode()); + return TextBlockUtils.withMargin(box, 0, 0, margin(), margin()); + } + + final TextBlock text = label.create(FontConfiguration.blackBlueTrue(font), HorizontalAlignment.LEFT, skinParam); + if (direction == Direction.RIGHT) { + return TextBlockUtils.withMargin(text, 3, 0, 1, 1); + } + return TextBlockUtils.withMargin(text, 0, 3, 1, 1); + } + + private double margin() { + return margin; + } + + public double getNailThickness(StringBounder stringBounder) { + return tetris(stringBounder).getHeight(); + } + + public double getNailElongation(StringBounder stringBounder) { + return tetris(stringBounder).getWidth(); + } + + public double getFullThickness(StringBounder stringBounder) { + final double thickness1 = getPhalanxThickness(stringBounder); + final double thickness2 = getNailThickness(stringBounder); + // System.err.println("thickness1=" + thickness1 + " thickness2=" + thickness2); + return Math.max(thickness1, thickness2); + } + + public double getFullElongation(StringBounder stringBounder) { + return getPhalanxElongation(stringBounder) + getNailElongation(stringBounder); + } + + public void doNotDrawFirstPhalanx() { + this.drawPhalanx = false; } } diff --git a/src/net/sourceforge/plantuml/mindmap/FingerImpl2.java b/src/net/sourceforge/plantuml/mindmap/FingerImpl2.java deleted file mode 100644 index 68a1788a5..000000000 --- a/src/net/sourceforge/plantuml/mindmap/FingerImpl2.java +++ /dev/null @@ -1,223 +0,0 @@ -/* ======================================================================== - * 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.mindmap; - -import java.awt.geom.Dimension2D; -import java.awt.geom.Point2D; -import java.util.ArrayList; -import java.util.List; - -import net.sourceforge.plantuml.ColorParam; -import net.sourceforge.plantuml.Direction; -import net.sourceforge.plantuml.FontParam; -import net.sourceforge.plantuml.ISkinParam; -import net.sourceforge.plantuml.SkinParamBackcolored; -import net.sourceforge.plantuml.activitydiagram3.ftile.BoxStyle; -import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileBox; -import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.graphic.FontConfiguration; -import net.sourceforge.plantuml.graphic.HorizontalAlignment; -import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.graphic.TextBlockUtils; -import net.sourceforge.plantuml.graphic.UDrawable; -import net.sourceforge.plantuml.graphic.color.Colors; -import net.sourceforge.plantuml.ugraphic.UChangeColor; -import net.sourceforge.plantuml.ugraphic.UFont; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.UPath; -import net.sourceforge.plantuml.ugraphic.UTranslate; - -public class FingerImpl2 implements Finger, UDrawable { - - private final Display label; - private final HtmlColor backColor; - private final ISkinParam skinParam; - private final IdeaShape shape; - private final Direction direction; - private boolean drawPhalanx = true; - - private final List nail = new ArrayList(); - private Tetris tetris = null; - - public static FingerImpl2 build(Idea idea, ISkinParam skinParam, Direction direction) { - final FingerImpl2 result = new FingerImpl2(idea.getBackColor(), idea.getLabel(), skinParam, idea.getShape(), - direction); - for (Idea child : idea.getChildren()) { - result.addInNail(build(child, skinParam, direction)); - } - // System.err.println("End of build for " + idea); - return result; - } - - public void addInNail(FingerImpl2 child) { - nail.add(child); - } - - private FingerImpl2(HtmlColor backColor, Display label, ISkinParam skinParam, IdeaShape shape, Direction direction) { - this.backColor = backColor; - this.label = label; - this.skinParam = skinParam; - this.shape = shape; - this.direction = direction; - } - - public void drawU(final UGraphic ug) { - final StringBounder stringBounder = ug.getStringBounder(); - final TextBlock phalanx = getPhalanx(); - final Dimension2D dimPhalanx = phalanx.calculateDimension(stringBounder); - if (drawPhalanx) { - final double posY = -getPhalanxThickness(stringBounder) / 2; - final double posX = direction == Direction.RIGHT ? 0 : -dimPhalanx.getWidth(); - phalanx.drawU(ug.apply(new UTranslate(posX, posY))); - } - final Point2D p1 = new Point2D.Double(direction == Direction.RIGHT ? dimPhalanx.getWidth() - : -dimPhalanx.getWidth(), 0); - - for (int i = 0; i < nail.size(); i++) { - final FingerImpl2 child = nail.get(i); - final SymetricalTeePositioned stp = tetris(stringBounder).getElements().get(i); - final double x = direction == Direction.RIGHT ? dimPhalanx.getWidth() + getX12() : -dimPhalanx.getWidth() - - getX12(); - final Point2D p2 = new Point2D.Double(x, stp.getY()); - child.drawU(ug.apply(new UTranslate(p2))); - drawLine(ug.apply(new UChangeColor(getLinkColor())), p1, p2); - } - - } - - private HtmlColor getLinkColor() { - return ColorParam.activityBorder.getDefaultValue(); - } - - private void drawLine(UGraphic ug, Point2D p1, Point2D p2) { - // final ULine line = new ULine(p1, p2); - // ug.apply(new UTranslate(p1)).draw(line); - final UPath path = new UPath(); - final double delta1 = direction == Direction.RIGHT ? 10 : -10; - final double delta2 = direction == Direction.RIGHT ? 25 : -25; - path.moveTo(p1); - path.lineTo(p1.getX() + delta1, p1.getY()); - path.cubicTo(p1.getX() + delta2, p1.getY(), p2.getX() - delta2, p2.getY(), p2.getX() - delta1, p2.getY()); - path.lineTo(p2); - ug.draw(path); - } - - private Tetris tetris(StringBounder stringBounder) { - if (tetris == null) { - tetris = new Tetris(label.toString()); - for (FingerImpl2 child : nail) { - tetris.add(child.asSymetricalTee(stringBounder)); - } - tetris.balance(); - } - return tetris; - } - - private SymetricalTee asSymetricalTee(StringBounder stringBounder) { - final double thickness1 = getPhalanxThickness(stringBounder); - final double elongation1 = getPhalanxElongation(stringBounder); - if (nail.size() == 0) { - return new SymetricalTee(thickness1, elongation1, 0, 0); - } - final double thickness2 = getNailThickness(stringBounder); - final double elongation2 = getNailElongation(stringBounder); - return new SymetricalTee(thickness1, elongation1 + getX1(), thickness2, getX2() + elongation2); - } - - private double getX1() { - return 10; - } - - private double getX2() { - return 40; - } - - public double getX12() { - return getX1() + getX2(); - } - - public double getPhalanxThickness(StringBounder stringBounder) { - return getPhalanx().calculateDimension(stringBounder).getHeight(); - } - - public double getPhalanxElongation(StringBounder stringBounder) { - return getPhalanx().calculateDimension(stringBounder).getWidth(); - } - - private TextBlock getPhalanx() { - if (drawPhalanx == false) { - return TextBlockUtils.empty(0, 0); - } - final UFont font = skinParam.getFont(null, false, FontParam.ACTIVITY); - if (shape == IdeaShape.BOX) { - final ISkinParam foo = new SkinParamBackcolored(Colors.empty().mute(skinParam), backColor); - final FtileBox box = new FtileBox(foo, label, font, null, BoxStyle.PLAIN); - return TextBlockUtils.withMargin(box, 0, 0, 10, 10); - } - - final TextBlock text = label.create(FontConfiguration.blackBlueTrue(font), HorizontalAlignment.LEFT, skinParam); - if (direction == Direction.RIGHT) { - return TextBlockUtils.withMargin(text, 3, 0, 1, 1); - } - return TextBlockUtils.withMargin(text, 0, 3, 1, 1); - } - - public double getNailThickness(StringBounder stringBounder) { - return tetris(stringBounder).getHeight(); - } - - public double getNailElongation(StringBounder stringBounder) { - return tetris(stringBounder).getWidth(); - } - - public double getFullThickness(StringBounder stringBounder) { - final double thickness1 = getPhalanxThickness(stringBounder); - final double thickness2 = getNailThickness(stringBounder); - // System.err.println("thickness1=" + thickness1 + " thickness2=" + thickness2); - return Math.max(thickness1, thickness2); - } - - public double getFullElongation(StringBounder stringBounder) { - return getPhalanxElongation(stringBounder) + getNailElongation(stringBounder); - } - - public void doNotDrawFirstPhalanx() { - this.drawPhalanx = false; - } - -} diff --git a/src/net/sourceforge/plantuml/mindmap/Idea.java b/src/net/sourceforge/plantuml/mindmap/Idea.java index 85114e158..42c9893e0 100644 --- a/src/net/sourceforge/plantuml/mindmap/Idea.java +++ b/src/net/sourceforge/plantuml/mindmap/Idea.java @@ -42,28 +42,44 @@ import java.util.List; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.HtmlColor; +import net.sourceforge.plantuml.style.StyleBuilder; class Idea { + // public StyleDefinition getDefaultStyleDefinition() { + // return StyleDefinition.of(SName.root, SName.element, SName.mindmapDiagram, SName.node); + // } + private final Display label; private final int level; private final Idea parent; private final List children = new ArrayList(); private final IdeaShape shape; private final HtmlColor backColor; + private final StyleBuilder styleBuilder; - public Idea(Display label, IdeaShape shape) { - this(null, 0, null, label, shape); + public Idea(StyleBuilder styleBuilder, Display label, IdeaShape shape) { + this(styleBuilder, null, 0, null, label, shape); } - public Idea createIdea(HtmlColor backColor, int newLevel, Display newDisplay, IdeaShape newShape) { - final Idea result = new Idea(backColor, newLevel, this, newDisplay, newShape); + public Idea createIdea(StyleBuilder styleBuilder, HtmlColor backColor, int newLevel, Display newDisplay, + IdeaShape newShape) { + final Idea result = new Idea(styleBuilder, backColor, newLevel, this, newDisplay, newShape); this.children.add(result); return result; } - private Idea(HtmlColor backColor, int level, Idea parent, Display label, IdeaShape shape) { + // public Style getStyle(StyleBuilder styleBuilder) { + // Style result = getDefaultStyleDefinition().getMergedStyle(styleBuilder); + // if (backColor != null) { + // result = result.eventuallyOverride(PName.BackGroundColor, backColor); + // } + // return result; + // } + + private Idea(StyleBuilder styleBuilder, HtmlColor backColor, int level, Idea parent, Display label, IdeaShape shape) { this.backColor = backColor; + this.styleBuilder = styleBuilder; this.label = label; this.level = level; this.parent = parent; @@ -103,4 +119,8 @@ class Idea { return backColor; } + public final StyleBuilder getStyleBuilder() { + return styleBuilder; + } + } diff --git a/src/net/sourceforge/plantuml/mindmap/MindMapDiagram.java b/src/net/sourceforge/plantuml/mindmap/MindMapDiagram.java index 74975b454..1da95f955 100644 --- a/src/net/sourceforge/plantuml/mindmap/MindMapDiagram.java +++ b/src/net/sourceforge/plantuml/mindmap/MindMapDiagram.java @@ -56,6 +56,7 @@ import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.InnerStrategy; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; +import net.sourceforge.plantuml.style.StyleBuilder; import net.sourceforge.plantuml.svek.TextBlockBackcolored; import net.sourceforge.plantuml.ugraphic.ImageBuilder; import net.sourceforge.plantuml.ugraphic.MinMax; @@ -138,6 +139,9 @@ public class MindMapDiagram extends UmlDiagram { } private void drawMe(UGraphic ug) { + if (left.root == null && right.root == null) { + return; + } computeFinger(); final StringBounder stringBounder = ug.getStringBounder(); @@ -146,7 +150,7 @@ public class MindMapDiagram extends UmlDiagram { final double y = Math.max(y1, y2); final double x = left.finger == null ? 0 : left.finger.getFullElongation(stringBounder) - + ((FingerImpl2) left.finger).getX12(); + + ((FingerImpl) left.finger).getX12(); if (right.finger != null) { right.finger.drawU(ug.apply(new UTranslate(x, y))); } @@ -158,10 +162,10 @@ public class MindMapDiagram extends UmlDiagram { private void computeFinger() { if (left.finger == null && right.finger == null) { if (left.root.hasChildren()) { - left.finger = FingerImpl2.build(left.root, getSkinParam(), Direction.LEFT); + left.finger = FingerImpl.build(left.root, getSkinParam(), Direction.LEFT); } if (left.finger == null || right.root.hasChildren()) { - right.finger = FingerImpl2.build(right.root, getSkinParam(), Direction.RIGHT); + right.finger = FingerImpl.build(right.root, getSkinParam(), Direction.RIGHT); } if (left.finger != null && right.finger != null) { left.finger.doNotDrawFirstPhalanx(); @@ -180,14 +184,14 @@ public class MindMapDiagram extends UmlDiagram { return CommandExecutionResult .error("I don't know how to draw multi-root diagram. You should suggest an image so that the PlantUML team implements it :-)"); } - right.initRoot(label, shape); - left.initRoot(label, shape); + right.initRoot(getSkinParam().getCurrentStyleBuilder(), label, shape); + left.initRoot(getSkinParam().getCurrentStyleBuilder(), label, shape); return CommandExecutionResult.ok(); } if (direction == Direction.LEFT) { - return left.add(backColor, level, label, shape); + return left.add(getSkinParam().getCurrentStyleBuilder(), backColor, level, label, shape); } - return right.add(backColor, level, label, shape); + return right.add(getSkinParam().getCurrentStyleBuilder(), backColor, level, label, shape); } static class Branch { @@ -195,8 +199,8 @@ public class MindMapDiagram extends UmlDiagram { private Idea last; private Finger finger; - private void initRoot(String label, IdeaShape shape) { - root = new Idea(Display.getWithNewlines(label), shape); + private void initRoot(StyleBuilder styleBuilder, String label, IdeaShape shape) { + root = new Idea(styleBuilder, Display.getWithNewlines(label), shape); last = root; } @@ -208,15 +212,18 @@ public class MindMapDiagram extends UmlDiagram { return result; } - private CommandExecutionResult add(HtmlColor backColor, int level, String label, IdeaShape shape) { + private CommandExecutionResult add(StyleBuilder styleBuilder, HtmlColor backColor, int level, String label, + IdeaShape shape) { if (level == last.getLevel() + 1) { - final Idea newIdea = last.createIdea(backColor, level, Display.getWithNewlines(label), shape); + final Idea newIdea = last.createIdea(styleBuilder, backColor, level, Display.getWithNewlines(label), + shape); last = newIdea; return CommandExecutionResult.ok(); } if (level <= last.getLevel()) { final int diff = last.getLevel() - level + 1; - final Idea newIdea = getParentOfLast(diff).createIdea(backColor, level, Display.getWithNewlines(label), shape); + final Idea newIdea = getParentOfLast(diff).createIdea(styleBuilder, backColor, level, + Display.getWithNewlines(label), shape); last = newIdea; return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/nwdiag/DiagElement.java b/src/net/sourceforge/plantuml/nwdiag/DiagElement.java index afecba7b5..b7094ef8f 100644 --- a/src/net/sourceforge/plantuml/nwdiag/DiagElement.java +++ b/src/net/sourceforge/plantuml/nwdiag/DiagElement.java @@ -85,7 +85,7 @@ public class DiagElement { final TextBlock ad1 = toTextBlock(adress1); final TextBlock ad2 = toTextBlock(adress2); final SymbolContext symbolContext = new SymbolContext(ColorParam.activityBackground.getDefaultValue(), - ColorParam.activityBorder.getDefaultValue()).withShadow(true); + ColorParam.activityBorder.getDefaultValue()).withShadow(3); final TextBlock desc = toTextBlock(description); final TextBlock box = shape .asSmall(TextBlockUtils.empty(0, 0), desc, TextBlockUtils.empty(0, 0), symbolContext, HorizontalAlignment.CENTER); diff --git a/src/net/sourceforge/plantuml/posimo/Frame.java b/src/net/sourceforge/plantuml/posimo/Frame.java index c10239d94..4ad680a70 100644 --- a/src/net/sourceforge/plantuml/posimo/Frame.java +++ b/src/net/sourceforge/plantuml/posimo/Frame.java @@ -50,7 +50,7 @@ import net.sourceforge.plantuml.skin.Component; import net.sourceforge.plantuml.skin.Context2D; import net.sourceforge.plantuml.skin.rose.Rose; import net.sourceforge.plantuml.style.Style; -import net.sourceforge.plantuml.style.StyleDefinition; +import net.sourceforge.plantuml.style.StyleSignature; import net.sourceforge.plantuml.ugraphic.UChangeBackColor; import net.sourceforge.plantuml.ugraphic.UChangeColor; import net.sourceforge.plantuml.ugraphic.UFont; @@ -66,7 +66,7 @@ public class Frame implements Component { throw new UnsupportedOperationException(); } - public StyleDefinition getDefaultStyleDefinition() { + public StyleSignature getDefaultStyleDefinition() { throw new UnsupportedOperationException(); } diff --git a/src/net/sourceforge/plantuml/posimo/data.txt b/src/net/sourceforge/plantuml/posimo/data.txt new file mode 100644 index 000000000..2fe8aece5 --- /dev/null +++ b/src/net/sourceforge/plantuml/posimo/data.txt @@ -0,0 +1,38 @@ +@startuml +interface Positionable { + + Dimension2D getSize(); + + Point2D getPosition(); +} + +interface Clusterable { + +Cluster getParent(); +} + +Positionable <|-- Clusterable + +class Cluster + +Cluster *-- Cluster : subclusters +Clusterable <|.. Cluster +Cluster *-- Block +Clusterable <|.. Block + +Path *-- "2" Cluster +Path --> Label : has one +Positionable <|-- Label + +SimpleDrawer --> Cluster +SimpleDrawer *--> Path + +class GraphvizSolver { + + Dimension2D solve(Cluster root, Collection paths) +} +GraphvizSolver --> Cluster +GraphvizSolver *--> Path + + +'Clusterable --> Cluster : Parent + + + +@enduml diff --git a/src/net/sourceforge/plantuml/salt/Dictionary.java b/src/net/sourceforge/plantuml/salt/Dictionary.java index 158cdb6ad..3157d501f 100644 --- a/src/net/sourceforge/plantuml/salt/Dictionary.java +++ b/src/net/sourceforge/plantuml/salt/Dictionary.java @@ -47,9 +47,9 @@ import net.sourceforge.plantuml.graphic.HtmlColorSetSimple; import net.sourceforge.plantuml.graphic.IHtmlColorSet; import net.sourceforge.plantuml.salt.element.Element; import net.sourceforge.plantuml.salt.element.WrappedElement; +import net.sourceforge.plantuml.sprite.Sprite; import net.sourceforge.plantuml.ugraphic.ColorMapper; import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity; -import net.sourceforge.plantuml.ugraphic.sprite.Sprite; public class Dictionary implements SpriteContainer, ISkinSimple { diff --git a/src/net/sourceforge/plantuml/salt/PSystemSalt.java b/src/net/sourceforge/plantuml/salt/PSystemSalt.java index d36c64daa..e7fc050b6 100644 --- a/src/net/sourceforge/plantuml/salt/PSystemSalt.java +++ b/src/net/sourceforge/plantuml/salt/PSystemSalt.java @@ -79,11 +79,11 @@ import net.sourceforge.plantuml.salt.factory.ElementFactoryTab; import net.sourceforge.plantuml.salt.factory.ElementFactoryText; import net.sourceforge.plantuml.salt.factory.ElementFactoryTextField; import net.sourceforge.plantuml.salt.factory.ElementFactoryTree; +import net.sourceforge.plantuml.sprite.Sprite; import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity; import net.sourceforge.plantuml.ugraphic.ImageBuilder; import net.sourceforge.plantuml.ugraphic.UChangeColor; import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.sprite.Sprite; public class PSystemSalt extends AbstractPSystem implements WithSprite { diff --git a/src/net/sourceforge/plantuml/sequencediagram/AbstractMessage.java b/src/net/sourceforge/plantuml/sequencediagram/AbstractMessage.java index 1867a75e7..adbdc25fb 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/AbstractMessage.java +++ b/src/net/sourceforge/plantuml/sequencediagram/AbstractMessage.java @@ -48,7 +48,7 @@ import net.sourceforge.plantuml.skin.ArrowConfiguration; import net.sourceforge.plantuml.style.SName; import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.style.StyleBuilder; -import net.sourceforge.plantuml.style.StyleDefinition; +import net.sourceforge.plantuml.style.StyleSignature; import net.sourceforge.plantuml.style.WithStyle; public abstract class AbstractMessage implements EventWithDeactivate, WithStyle { @@ -57,9 +57,9 @@ public abstract class AbstractMessage implements EventWithDeactivate, WithStyle return new Style[] { getDefaultStyleDefinition().getMergedStyle(styleBuilder) }; } - public StyleDefinition getDefaultStyleDefinition() { - return StyleDefinition.of(SName.root, SName.element, SName.sequenceDiagram, - SName.message); + public StyleSignature getDefaultStyleDefinition() { + return StyleSignature.of(SName.root, SName.element, SName.sequenceDiagram, + SName.arrow); } private final Display label; diff --git a/src/net/sourceforge/plantuml/sequencediagram/Delay.java b/src/net/sourceforge/plantuml/sequencediagram/Delay.java index c94a6ffb3..ea9f4d419 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/Delay.java +++ b/src/net/sourceforge/plantuml/sequencediagram/Delay.java @@ -39,7 +39,7 @@ import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.skin.ComponentType; import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.style.StyleBuilder; -import net.sourceforge.plantuml.style.StyleDefinition; +import net.sourceforge.plantuml.style.StyleSignature; import net.sourceforge.plantuml.style.WithStyle; public class Delay extends AbstractEvent implements Event, WithStyle { @@ -48,7 +48,7 @@ public class Delay extends AbstractEvent implements Event, WithStyle { final private Style style; - public StyleDefinition getDefaultStyleDefinition() { + public StyleSignature getDefaultStyleDefinition() { return ComponentType.DELAY_TEXT.getDefaultStyleDefinition(); } diff --git a/src/net/sourceforge/plantuml/sequencediagram/Divider.java b/src/net/sourceforge/plantuml/sequencediagram/Divider.java index 88fd9ff6c..67f8f85e3 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/Divider.java +++ b/src/net/sourceforge/plantuml/sequencediagram/Divider.java @@ -39,7 +39,7 @@ import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.skin.ComponentType; import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.style.StyleBuilder; -import net.sourceforge.plantuml.style.StyleDefinition; +import net.sourceforge.plantuml.style.StyleSignature; import net.sourceforge.plantuml.style.WithStyle; public class Divider extends AbstractEvent implements Event, WithStyle { @@ -48,7 +48,7 @@ public class Divider extends AbstractEvent implements Event, WithStyle { final private Style style; - public StyleDefinition getDefaultStyleDefinition() { + public StyleSignature getDefaultStyleDefinition() { return ComponentType.DIVIDER.getDefaultStyleDefinition(); } diff --git a/src/net/sourceforge/plantuml/sequencediagram/Englober.java b/src/net/sourceforge/plantuml/sequencediagram/Englober.java index 9d992fa04..a23c31463 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/Englober.java +++ b/src/net/sourceforge/plantuml/sequencediagram/Englober.java @@ -56,7 +56,7 @@ import net.sourceforge.plantuml.skin.rose.Rose; import net.sourceforge.plantuml.style.PName; import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.style.StyleBuilder; -import net.sourceforge.plantuml.style.StyleDefinition; +import net.sourceforge.plantuml.style.StyleSignature; import net.sourceforge.plantuml.style.ValueImpl; import net.sourceforge.plantuml.style.WithStyle; import net.sourceforge.plantuml.ugraphic.UGraphic; @@ -73,7 +73,7 @@ public class Englober implements WithStyle { final private boolean isTeoz; private double marginX = 0; - public StyleDefinition getDefaultStyleDefinition() { + public StyleSignature getDefaultStyleDefinition() { return ComponentType.ENGLOBER.getDefaultStyleDefinition(); } diff --git a/src/net/sourceforge/plantuml/sequencediagram/Grouping.java b/src/net/sourceforge/plantuml/sequencediagram/Grouping.java index e53231487..1645dceba 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/Grouping.java +++ b/src/net/sourceforge/plantuml/sequencediagram/Grouping.java @@ -40,7 +40,7 @@ import net.sourceforge.plantuml.style.PName; import net.sourceforge.plantuml.style.SName; import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.style.StyleBuilder; -import net.sourceforge.plantuml.style.StyleDefinition; +import net.sourceforge.plantuml.style.StyleSignature; import net.sourceforge.plantuml.style.WithStyle; public abstract class Grouping implements Event, WithStyle { @@ -55,12 +55,12 @@ public abstract class Grouping implements Event, WithStyle { final private Style style; final private Style styleHeader; - public StyleDefinition getDefaultStyleDefinition() { - return StyleDefinition.of(SName.root, SName.element, SName.sequenceDiagram, SName.group); + public StyleSignature getDefaultStyleDefinition() { + return StyleSignature.of(SName.root, SName.element, SName.sequenceDiagram, SName.group); } - private StyleDefinition getHeaderStyleDefinition() { - return StyleDefinition.of(SName.root, SName.element, SName.sequenceDiagram, SName.groupHeader); + private StyleSignature getHeaderStyleDefinition() { + return StyleSignature.of(SName.root, SName.element, SName.sequenceDiagram, SName.groupHeader); } public Style[] getUsedStyles() { diff --git a/src/net/sourceforge/plantuml/sequencediagram/LinkAnchor.java b/src/net/sourceforge/plantuml/sequencediagram/LinkAnchor.java index 3262e43b7..47f119ec0 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/LinkAnchor.java +++ b/src/net/sourceforge/plantuml/sequencediagram/LinkAnchor.java @@ -93,7 +93,7 @@ public class LinkAnchor { final double ymax = Math.max(y1, y2); final HtmlColor color = new Rose().getHtmlColor(param, ColorParam.arrow); - final Rainbow rainbow = HtmlColorAndStyle.fromColor(color); + final Rainbow rainbow = Rainbow.fromColor(color); final Snake snake = new Snake(Arrows.asToUp(), HorizontalAlignment.CENTER, rainbow, Arrows.asToDown()); final Display display = Display.getWithNewlines(message); diff --git a/src/net/sourceforge/plantuml/sequencediagram/MessageExo.java b/src/net/sourceforge/plantuml/sequencediagram/MessageExo.java index d578a3d9d..321a2b3ad 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/MessageExo.java +++ b/src/net/sourceforge/plantuml/sequencediagram/MessageExo.java @@ -39,7 +39,7 @@ import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.skin.ArrowConfiguration; import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.style.StyleBuilder; -import net.sourceforge.plantuml.style.StyleDefinition; +import net.sourceforge.plantuml.style.StyleSignature; public class MessageExo extends AbstractMessage { diff --git a/src/net/sourceforge/plantuml/sequencediagram/Note.java b/src/net/sourceforge/plantuml/sequencediagram/Note.java index bfe3a6c94..cfea80bdd 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/Note.java +++ b/src/net/sourceforge/plantuml/sequencediagram/Note.java @@ -47,7 +47,7 @@ import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.style.StyleBuilder; -import net.sourceforge.plantuml.style.StyleDefinition; +import net.sourceforge.plantuml.style.StyleSignature; import net.sourceforge.plantuml.style.WithStyle; public class Note extends AbstractEvent implements Event, SpecificBackcolorable, WithStyle { @@ -66,7 +66,7 @@ public class Note extends AbstractEvent implements Event, SpecificBackcolorable, private Style style; - public StyleDefinition getDefaultStyleDefinition() { + public StyleSignature getDefaultStyleDefinition() { return noteStyle.getDefaultStyleDefinition(); } diff --git a/src/net/sourceforge/plantuml/sequencediagram/NoteStyle.java b/src/net/sourceforge/plantuml/sequencediagram/NoteStyle.java index 3b61745c7..632ff512a 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/NoteStyle.java +++ b/src/net/sourceforge/plantuml/sequencediagram/NoteStyle.java @@ -37,7 +37,7 @@ package net.sourceforge.plantuml.sequencediagram; import net.sourceforge.plantuml.skin.ComponentType; import net.sourceforge.plantuml.style.SName; -import net.sourceforge.plantuml.style.StyleDefinition; +import net.sourceforge.plantuml.style.StyleSignature; public enum NoteStyle { @@ -62,8 +62,8 @@ public enum NoteStyle { return ComponentType.NOTE; } - public StyleDefinition getDefaultStyleDefinition() { - return StyleDefinition.of(SName.root, SName.element, SName.sequenceDiagram, + public StyleSignature getDefaultStyleDefinition() { + return StyleSignature.of(SName.root, SName.element, SName.sequenceDiagram, SName.note); } diff --git a/src/net/sourceforge/plantuml/sequencediagram/Participant.java b/src/net/sourceforge/plantuml/sequencediagram/Participant.java index 87fb7b301..6c99bfb6c 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/Participant.java +++ b/src/net/sourceforge/plantuml/sequencediagram/Participant.java @@ -53,7 +53,7 @@ import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.style.SName; import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.style.StyleBuilder; -import net.sourceforge.plantuml.style.StyleDefinition; +import net.sourceforge.plantuml.style.StyleSignature; import net.sourceforge.plantuml.style.WithStyle; public class Participant implements SpecificBackcolorable, WithStyle { @@ -70,18 +70,19 @@ public class Participant implements SpecificBackcolorable, WithStyle { private final int order; private final StyleBuilder styleBuilder; - private Style style; + // private Style style; - public StyleDefinition getDefaultStyleDefinition() { + public StyleSignature getDefaultStyleDefinition() { return type.getDefaultStyleDefinition(); } public Style[] getUsedStyles() { - Style tmp = style; - if (tmp != null) { - tmp = tmp.eventuallyOverride(getColors(null)); + if (SkinParam.USE_STYLES() == false) { + return null; } - Style stereo = getDefaultStyleDefinition().with(stereotype).getMergedStyle(styleBuilder); + Style tmp = getDefaultStyleDefinition().with(stereotype).getMergedStyle(styleBuilder) + .eventuallyOverride(getColors(null)); + Style stereo = getDefaultStyleDefinition().withStereotype(stereotype).getMergedStyle(styleBuilder); if (tmp != null) { stereo = tmp.mergeWith(stereo); } @@ -105,9 +106,9 @@ public class Participant implements SpecificBackcolorable, WithStyle { this.code = code; this.type = type; this.display = display; - if (SkinParam.USE_STYLES()) { - this.style = getDefaultStyleDefinition().getMergedStyle(styleBuilder); - } + // if (SkinParam.USE_STYLES()) { + // this.style = getDefaultStyleDefinition().getMergedStyle(styleBuilder); + // } } public String getCode() { @@ -145,11 +146,11 @@ public class Participant implements SpecificBackcolorable, WithStyle { this.stereotype = stereotype; this.stereotypePositionTop = stereotypePositionTop; - if (SkinParam.USE_STYLES()) { - for (Style style : stereotype.getStyles(styleBuilder)) { - this.style = this.style.mergeWith(style); - } - } + // if (SkinParam.USE_STYLES()) { + // for (Style style : stereotype.getStyles(styleBuilder)) { + // this.style = this.style.mergeWith(style); + // } + // } } public final int getInitialLife() { diff --git a/src/net/sourceforge/plantuml/sequencediagram/ParticipantType.java b/src/net/sourceforge/plantuml/sequencediagram/ParticipantType.java index 45c7912b5..a4448c599 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/ParticipantType.java +++ b/src/net/sourceforge/plantuml/sequencediagram/ParticipantType.java @@ -38,7 +38,7 @@ package net.sourceforge.plantuml.sequencediagram; import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.style.SName; import net.sourceforge.plantuml.style.Styleable; -import net.sourceforge.plantuml.style.StyleDefinition; +import net.sourceforge.plantuml.style.StyleSignature; public enum ParticipantType implements Styleable { PARTICIPANT(ColorParam.participantBackground), // @@ -60,37 +60,37 @@ public enum ParticipantType implements Styleable { return background; } - public StyleDefinition getDefaultStyleDefinition() { + public StyleSignature getDefaultStyleDefinition() { if (this == PARTICIPANT) { - return StyleDefinition.of(SName.root, SName.element, + return StyleSignature.of(SName.root, SName.element, SName.sequenceDiagram, SName.participant); } if (this == ACTOR) { - return StyleDefinition.of(SName.root, SName.element, + return StyleSignature.of(SName.root, SName.element, SName.sequenceDiagram, SName.actor); } if (this == BOUNDARY) { - return StyleDefinition.of(SName.root, SName.element, + return StyleSignature.of(SName.root, SName.element, SName.sequenceDiagram, SName.boundary); } if (this == CONTROL) { - return StyleDefinition.of(SName.root, SName.element, + return StyleSignature.of(SName.root, SName.element, SName.sequenceDiagram, SName.control); } if (this == ENTITY) { - return StyleDefinition.of(SName.root, SName.element, + return StyleSignature.of(SName.root, SName.element, SName.sequenceDiagram, SName.entity); } if (this == QUEUE) { - return StyleDefinition.of(SName.root, SName.element, + return StyleSignature.of(SName.root, SName.element, SName.sequenceDiagram, SName.queue); } if (this == DATABASE) { - return StyleDefinition.of(SName.root, SName.element, + return StyleSignature.of(SName.root, SName.element, SName.sequenceDiagram, SName.database); } if (this == COLLECTIONS) { - return StyleDefinition.of(SName.root, SName.element, + return StyleSignature.of(SName.root, SName.element, SName.sequenceDiagram, SName.collections); } return null; diff --git a/src/net/sourceforge/plantuml/sequencediagram/Reference.java b/src/net/sourceforge/plantuml/sequencediagram/Reference.java index ab80106da..00265c0dd 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/Reference.java +++ b/src/net/sourceforge/plantuml/sequencediagram/Reference.java @@ -43,9 +43,11 @@ import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.skin.ComponentType; +import net.sourceforge.plantuml.style.PName; +import net.sourceforge.plantuml.style.SName; import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.style.StyleBuilder; -import net.sourceforge.plantuml.style.StyleDefinition; +import net.sourceforge.plantuml.style.StyleSignature; public class Reference extends AbstractEvent implements Event { @@ -57,13 +59,21 @@ public class Reference extends AbstractEvent implements Event { private final Display strings; final private Style style; + final private Style styleHeader; - public StyleDefinition getDefaultStyleDefinition() { - return ComponentType.REFERENCE.getDefaultStyleDefinition(); + public StyleSignature getDefaultStyleDefinition() { + return StyleSignature.of(SName.root, SName.element, SName.sequenceDiagram, SName.reference); + } + + private StyleSignature getHeaderStyleDefinition() { + return StyleSignature.of(SName.root, SName.element, SName.sequenceDiagram, SName.referenceHeader); } public Style[] getUsedStyles() { - return new Style[] { style }; + return new Style[] { + style, + styleHeader == null ? styleHeader : styleHeader.eventuallyOverride(PName.BackGroundColor, + backColorElement) }; } public Reference(List participants, Url url, Display strings, HtmlColor backColorGeneral, @@ -74,6 +84,7 @@ public class Reference extends AbstractEvent implements Event { this.backColorGeneral = backColorGeneral; this.backColorElement = backColorElement; this.style = getDefaultStyleDefinition().getMergedStyle(styleBuilder); + this.styleHeader = getHeaderStyleDefinition().getMergedStyle(styleBuilder); } public List getParticipant() { diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramFileMakerPuma2.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramFileMakerPuma2.java index c7cdabb53..f76166c40 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramFileMakerPuma2.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramFileMakerPuma2.java @@ -71,7 +71,7 @@ import net.sourceforge.plantuml.skin.ComponentType; import net.sourceforge.plantuml.skin.rose.Rose; import net.sourceforge.plantuml.style.SName; import net.sourceforge.plantuml.style.Style; -import net.sourceforge.plantuml.style.StyleDefinition; +import net.sourceforge.plantuml.style.StyleSignature; import net.sourceforge.plantuml.ugraphic.ImageBuilder; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; @@ -160,7 +160,7 @@ public class SequenceDiagramFileMakerPuma2 implements FileMaker { compTitle = null; } else { if (SkinParam.USE_STYLES()) { - final Style style = StyleDefinition.of(SName.root, SName.title).getMergedStyle( + final Style style = StyleSignature.of(SName.root, SName.title).getMergedStyle( diagram.getSkinParam().getCurrentStyleBuilder()); compTitle = style.createTextBlockBordered(page.getTitle(), diagram.getSkinParam().getIHtmlColorSet(), diagram.getSkinParam()); @@ -181,7 +181,7 @@ public class SequenceDiagramFileMakerPuma2 implements FileMaker { legendBlock = TextBlockUtils.empty(0, 0); } else { if (SkinParam.USE_STYLES()) { - final Style style = StyleDefinition.of(SName.root, SName.legend).getMergedStyle( + final Style style = StyleSignature.of(SName.root, SName.legend).getMergedStyle( diagram.getSkinParam().getCurrentStyleBuilder()); legendBlock = style.createTextBlockBordered(legend.getDisplay(), diagram.getSkinParam() .getIHtmlColorSet(), diagram.getSkinParam()); @@ -315,7 +315,7 @@ public class SequenceDiagramFileMakerPuma2 implements FileMaker { final DisplaySection display = diagram.getFooterOrHeaderTeoz(fontParam).withPage(page + 1, pages.size()); Style style = null; if (SkinParam.USE_STYLES()) { - final StyleDefinition def = fontParam.getStyleDefinition(); + final StyleSignature def = fontParam.getStyleDefinition(); style = def.getMergedStyle(skinParam.getCurrentStyleBuilder()); } return new PngTitler(titleColor, display, fontSize, fontFamily, hyperlinkColor, diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java index f49c6cff8..4a1825953 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java @@ -69,7 +69,7 @@ import net.sourceforge.plantuml.skin.rose.Rose; import net.sourceforge.plantuml.style.PName; import net.sourceforge.plantuml.style.SName; import net.sourceforge.plantuml.style.Style; -import net.sourceforge.plantuml.style.StyleDefinition; +import net.sourceforge.plantuml.style.StyleSignature; import net.sourceforge.plantuml.ugraphic.ImageBuilder; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; @@ -109,7 +109,7 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker { + heightEnglober2 + title.calculateDimension(stringBounder).getHeight() + header.calculateDimension(stringBounder).getHeight() + legend.calculateDimension(stringBounder).getHeight() - + footer.calculateDimension(stringBounder).getHeight(); + + footer.calculateDimension(stringBounder).getHeight() + (annotatedWorker.hasMainFrame() ? 10 : 0); this.dimTotal = new Dimension2DDouble(totalWidth, totalHeight); } @@ -223,7 +223,7 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker { } final TextBlock compTitle; if (SkinParam.USE_STYLES()) { - final Style style = StyleDefinition.of(SName.root, SName.title).getMergedStyle( + final Style style = StyleSignature.of(SName.root, SName.title).getMergedStyle( diagram.getSkinParam().getCurrentStyleBuilder()); compTitle = style.createTextBlockBordered(diagram.getTitle().getDisplay(), diagram.getSkinParam() .getIHtmlColorSet(), diagram.getSkinParam()); @@ -255,7 +255,7 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker { Style style = null; final ISkinParam skinParam = diagram.getSkinParam(); if (SkinParam.USE_STYLES()) { - final StyleDefinition def = param.getStyleDefinition(); + final StyleSignature def = param.getStyleDefinition(); style = def.getMergedStyle(skinParam.getCurrentStyleBuilder()); } final PngTitler pngTitler = new PngTitler(titleColor, display, fontSize, fontFamily, hyperlinkColor, @@ -280,9 +280,9 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker { HorizontalAlignment titleAlignment = HorizontalAlignment.CENTER; if (SkinParam.USE_STYLES()) { - final StyleDefinition def = FontParam.TITLE.getStyleDefinition(); + final StyleSignature def = FontParam.TITLE.getStyleDefinition(); titleAlignment = def.getMergedStyle(diagram.getSkinParam().getCurrentStyleBuilder()) - .value(PName.HorizontalAlignment).asHorizontalAlignment(); + .getHorizontalAlignment(); } printAligned(ug, titleAlignment, title); ug = goDown(ug, title); @@ -293,8 +293,10 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker { } ug = ug.apply(new UTranslate(0, heightEnglober1)); - printAligned(ug, HorizontalAlignment.CENTER, body); - ug = goDown(ug, body); + final TextBlock bodyFramed = annotatedWorker.addFrame(body); + printAligned(ug.apply(new UTranslate((annotatedWorker.hasMainFrame() ? 4 : 0), 0)), HorizontalAlignment.CENTER, + bodyFramed); + ug = goDown(ug, bodyFramed); ug = ug.apply(new UTranslate(0, heightEnglober2)); printAligned(ug, HorizontalAlignment.CENTER, caption); diff --git a/src/net/sourceforge/plantuml/skin/AbstractComponent.java b/src/net/sourceforge/plantuml/skin/AbstractComponent.java index e919222a7..33f0baa17 100644 --- a/src/net/sourceforge/plantuml/skin/AbstractComponent.java +++ b/src/net/sourceforge/plantuml/skin/AbstractComponent.java @@ -40,7 +40,7 @@ import java.awt.geom.Dimension2D; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.style.Style; -import net.sourceforge.plantuml.style.StyleDefinition; +import net.sourceforge.plantuml.style.StyleSignature; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; @@ -50,7 +50,7 @@ public abstract class AbstractComponent implements Component { throw new UnsupportedOperationException(); } - public StyleDefinition getDefaultStyleDefinition() { + public StyleSignature getDefaultStyleDefinition() { throw new UnsupportedOperationException(); } diff --git a/src/net/sourceforge/plantuml/skin/AbstractTextualComponent.java b/src/net/sourceforge/plantuml/skin/AbstractTextualComponent.java index b04b5895e..738cbbb19 100644 --- a/src/net/sourceforge/plantuml/skin/AbstractTextualComponent.java +++ b/src/net/sourceforge/plantuml/skin/AbstractTextualComponent.java @@ -41,7 +41,6 @@ import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.ISkinSimple; import net.sourceforge.plantuml.LineBreakStrategy; -import net.sourceforge.plantuml.OptionFlags; import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.creole.CreoleMode; import net.sourceforge.plantuml.cucadiagram.BodyEnhanced2; @@ -53,9 +52,8 @@ import net.sourceforge.plantuml.graphic.IHtmlColorSet; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlockEmpty; -import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.style.PName; -import net.sourceforge.plantuml.style.StyleKind; +import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.ugraphic.UFont; public abstract class AbstractTextualComponent extends AbstractComponent { @@ -92,23 +90,23 @@ public abstract class AbstractTextualComponent extends AbstractComponent { ISkinSimple spriteContainer, boolean enhanced, UFont fontForStereotype, HtmlColor htmlColorForStereotype) { super(style); this.spriteContainer = spriteContainer; - boolean keepStereotype = true; if (SkinParam.USE_STYLES()) { fc = style.getFontConfiguration(getIHtmlColorSet()); this.font = style.getUFont(); this.fontColor = style.value(PName.FontColor).asColor(getIHtmlColorSet()); - horizontalAlignment = style.value(PName.HorizontalAlignment).asHorizontalAlignment(); + horizontalAlignment = style.getHorizontalAlignment(); fontForStereotype = stereo.getUFont(); htmlColorForStereotype = stereo.value(PName.FontColor).asColor(getIHtmlColorSet()); - keepStereotype = style.getKind() == StyleKind.STEREOTYPE; + this.display = display.withoutStereotype(style); } else { this.font = fc.getFont(); this.fontColor = fc.getColor(); + this.display = display; } this.marginX1 = marginX1; this.marginX2 = marginX2; this.marginY = marginY; - this.display = keepStereotype ? display : display.withoutStereotype(); + // this.display = keepStereotype ? display : display.withoutStereotype(); if (this.display.size() == 1 && this.display.get(0).length() == 0) { textBlock = new TextBlockEmpty(); diff --git a/src/net/sourceforge/plantuml/skin/ComponentType.java b/src/net/sourceforge/plantuml/skin/ComponentType.java index 2e1517212..2d50dbea0 100644 --- a/src/net/sourceforge/plantuml/skin/ComponentType.java +++ b/src/net/sourceforge/plantuml/skin/ComponentType.java @@ -39,7 +39,7 @@ import net.sourceforge.plantuml.OptionFlags; import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.style.SName; import net.sourceforge.plantuml.style.Styleable; -import net.sourceforge.plantuml.style.StyleDefinition; +import net.sourceforge.plantuml.style.StyleSignature; public enum ComponentType implements Styleable { @@ -71,52 +71,52 @@ public enum ComponentType implements Styleable { return this == ARROW; } - public StyleDefinition getDefaultStyleDefinition() { + public StyleSignature getDefaultStyleDefinition() { if (this == PARTICIPANT_HEAD || this == PARTICIPANT_TAIL) { - return StyleDefinition.of(SName.root, SName.element, + return StyleSignature.of(SName.root, SName.element, SName.sequenceDiagram, SName.participant); } if (this == PARTICIPANT_LINE || this == CONTINUE_LINE) { - return StyleDefinition.of(SName.root, SName.element, - SName.sequenceDiagram); + return StyleSignature.of(SName.root, SName.element, + SName.sequenceDiagram, SName.lifeLine); } if (this == ALIVE_BOX_CLOSE_CLOSE || this == ALIVE_BOX_CLOSE_OPEN || this == ALIVE_BOX_OPEN_CLOSE || this == ALIVE_BOX_OPEN_OPEN) { - return StyleDefinition.of(SName.root, SName.element, + return StyleSignature.of(SName.root, SName.element, SName.sequenceDiagram, SName.lifeLine); } if (this == DESTROY) { - return StyleDefinition.of(SName.root, SName.element, + return StyleSignature.of(SName.root, SName.element, SName.sequenceDiagram, SName.lifeLine); } if (this == DIVIDER) { - return StyleDefinition.of(SName.root, SName.element, + return StyleSignature.of(SName.root, SName.element, SName.sequenceDiagram, SName.separator); } if (this == ENGLOBER) { - return StyleDefinition.of(SName.root, SName.element, + return StyleSignature.of(SName.root, SName.element, SName.sequenceDiagram, SName.box); } if (this == NOTE) { - return StyleDefinition.of(SName.root, SName.element, + return StyleSignature.of(SName.root, SName.element, SName.sequenceDiagram, SName.note); } if (this == DELAY_TEXT) { - return StyleDefinition.of(SName.root, SName.element, + return StyleSignature.of(SName.root, SName.element, SName.sequenceDiagram, SName.delay); } if (this == DELAY_LINE) { - return StyleDefinition.of(SName.root, SName.element, + return StyleSignature.of(SName.root, SName.element, SName.sequenceDiagram, SName.delay); } - if (this == REFERENCE) { - return StyleDefinition.of(SName.root, SName.element, - SName.sequenceDiagram, SName.reference); - } +// if (this == REFERENCE) { +// return StyleSignature.of(SName.root, SName.element, +// SName.sequenceDiagram, SName.reference); +// } if (SkinParam.USE_STYLES()) { throw new UnsupportedOperationException(toString()); } - return StyleDefinition.of(SName.root); + return StyleSignature.of(SName.root); } } diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/FillRoundShape.java b/src/net/sourceforge/plantuml/skin/bluemodern/FillRoundShape.java deleted file mode 100644 index 775ef5c56..000000000 --- a/src/net/sourceforge/plantuml/skin/bluemodern/FillRoundShape.java +++ /dev/null @@ -1,80 +0,0 @@ -/* ======================================================================== - * 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.skin.bluemodern; - -import java.awt.GradientPaint; -import java.awt.Graphics2D; -import java.awt.geom.RoundRectangle2D; - -import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.HtmlColorGradient; -import net.sourceforge.plantuml.ugraphic.ColorMapper; -import net.sourceforge.plantuml.ugraphic.UChangeBackColor; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.URectangle; - -public class FillRoundShape { - - final private double width; - final private double height; - final private double corner; - final private HtmlColor c1; - final private HtmlColor c2; - - public FillRoundShape(double width, double height, HtmlColor c1, HtmlColor c2, double corner) { - this.width = width; - this.height = height; - this.c1 = c1; - this.c2 = c2; - this.corner = corner; - - } - - public void draw(ColorMapper mapper, Graphics2D g2d) { - final GradientPaint paint = new GradientPaint(0, 0, mapper.getMappedColor(c1), (float) width, (float) height, - mapper.getMappedColor(c2)); - final RoundRectangle2D r = new RoundRectangle2D.Double(0, 0, width, height, corner * 2, corner * 2); - g2d.setPaint(paint); - g2d.fill(r); - } - - public void drawU(UGraphic ug) { - final HtmlColorGradient gradient = new HtmlColorGradient(c1, c2, '\\'); - final URectangle r = new URectangle(width, height, corner * 2, corner * 2); - ug.apply(new UChangeBackColor(gradient)).draw(r); - } - -} diff --git a/src/net/sourceforge/plantuml/skin/rose/AbstractComponentRoseArrow.java b/src/net/sourceforge/plantuml/skin/rose/AbstractComponentRoseArrow.java index 09d18cfe8..e0db3a396 100644 --- a/src/net/sourceforge/plantuml/skin/rose/AbstractComponentRoseArrow.java +++ b/src/net/sourceforge/plantuml/skin/rose/AbstractComponentRoseArrow.java @@ -38,7 +38,6 @@ package net.sourceforge.plantuml.skin.rose; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.ISkinSimple; import net.sourceforge.plantuml.LineBreakStrategy; -import net.sourceforge.plantuml.OptionFlags; import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; @@ -50,8 +49,9 @@ import net.sourceforge.plantuml.skin.AbstractTextualComponent; import net.sourceforge.plantuml.skin.ArrowComponent; import net.sourceforge.plantuml.skin.ArrowConfiguration; import net.sourceforge.plantuml.skin.Padder; -import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.style.PName; +import net.sourceforge.plantuml.style.Style; +import net.sourceforge.plantuml.ugraphic.UStroke; public abstract class AbstractComponentRoseArrow extends AbstractTextualComponent implements ArrowComponent { @@ -65,11 +65,13 @@ public abstract class AbstractComponentRoseArrow extends AbstractTextualComponen HorizontalAlignment textHorizontalAlignment, LineBreakStrategy maxMessageSize) { super(style, maxMessageSize, stringsToDisplay, font, textHorizontalAlignment, 7, 7, 1, spriteContainer, false, null, null); - this.arrowConfiguration = arrowConfiguration; if (SkinParam.USE_STYLES()) { this.foregroundColor = style.value(PName.LineColor).asColor(getIHtmlColorSet()); + final UStroke stroke = style.getStroke(); + this.arrowConfiguration = arrowConfiguration.withThickness(stroke.getThickness()); } else { this.foregroundColor = foregroundColor; + this.arrowConfiguration = arrowConfiguration; } } diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseArrow.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseArrow.java index ea88b1e6e..a8e1c1815 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseArrow.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseArrow.java @@ -77,7 +77,7 @@ public class ComponentRoseArrow extends AbstractComponentRoseArrow { super(style, foregroundColor, font, stringsToDisplay, arrowConfiguration, spriteContainer, textHorizontalAlignment, maxMessageSize); if (SkinParam.USE_STYLES()) { - messagePosition = style.value(PName.HorizontalAlignment).asHorizontalAlignment(); + messagePosition = style.getHorizontalAlignment(); } this.messagePosition = messagePosition; this.niceArrow = niceArrow; diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseDatabase.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseDatabase.java index 1879f475c..c2cd93cc2 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseDatabase.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseDatabase.java @@ -73,7 +73,7 @@ public class ComponentRoseDatabase extends AbstractTextualComponent { } final SymbolContext symbolContext = new SymbolContext(biColor.getBackColor(), biColor.getForeColor()) - .withStroke(new UStroke(1.5)).withShadow(biColor.getDeltaShadow() > 0); + .withStroke(new UStroke(1.5)).withShadow(biColor.getDeltaShadow()); this.stickman = USymbol.DATABASE.asSmall(null, TextBlockUtils.empty(16, 17), TextBlockUtils.empty(0, 0), symbolContext, HorizontalAlignment.CENTER); } diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingSpace.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingSpace.java index 428e651e0..438fa5a6e 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingSpace.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingSpace.java @@ -43,7 +43,7 @@ import net.sourceforge.plantuml.skin.Area; import net.sourceforge.plantuml.skin.Component; import net.sourceforge.plantuml.skin.Context2D; import net.sourceforge.plantuml.style.Style; -import net.sourceforge.plantuml.style.StyleDefinition; +import net.sourceforge.plantuml.style.StyleSignature; import net.sourceforge.plantuml.ugraphic.UGraphic; public class ComponentRoseGroupingSpace implements Component { @@ -52,7 +52,7 @@ public class ComponentRoseGroupingSpace implements Component { throw new UnsupportedOperationException(); } - public StyleDefinition getDefaultStyleDefinition() { + public StyleSignature getDefaultStyleDefinition() { throw new UnsupportedOperationException(); } diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseReference.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseReference.java index a0544c920..f74a8c23d 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseReference.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseReference.java @@ -39,7 +39,6 @@ import java.awt.geom.Dimension2D; import net.sourceforge.plantuml.ISkinSimple; import net.sourceforge.plantuml.LineBreakStrategy; -import net.sourceforge.plantuml.OptionFlags; import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; @@ -50,7 +49,6 @@ import net.sourceforge.plantuml.graphic.SymbolContext; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.skin.AbstractTextualComponent; import net.sourceforge.plantuml.skin.Area; -import net.sourceforge.plantuml.style.PName; import net.sourceforge.plantuml.style.Style; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UPolygon; @@ -60,30 +58,31 @@ import net.sourceforge.plantuml.ugraphic.UTranslate; public class ComponentRoseReference extends AbstractTextualComponent { - private final HtmlColor background; private final int cornersize = 10; private final TextBlock textHeader; private final double heightFooter = 5; private final double xMargin = 2; private final HorizontalAlignment position; - private final SymbolContext symbolContext; + private final SymbolContext symbolContextHeader; + private final SymbolContext symbolContextBody; - public ComponentRoseReference(Style style, FontConfiguration font, SymbolContext symbolContext, - FontConfiguration header, Display stringsToDisplay, HorizontalAlignment position, + public ComponentRoseReference(Style style, Style styleHeader, FontConfiguration font, SymbolContext symbolContext, + FontConfiguration fcHeader, Display stringsToDisplay, HorizontalAlignment position, ISkinSimple spriteContainer, HtmlColor background) { super(style, LineBreakStrategy.NONE, stringsToDisplay.subList(1, stringsToDisplay.size()), font, HorizontalAlignment.LEFT, 4, 4, 4, spriteContainer, false, null, null); if (SkinParam.USE_STYLES()) { - this.symbolContext = style.getSymbolContext(getIHtmlColorSet()); - this.background = style.value(PName.BackGroundColor).asColor(getIHtmlColorSet()); - this.position = style.value(PName.HorizontalAlignment).asHorizontalAlignment(); + this.symbolContextHeader = styleHeader.getSymbolContext(getIHtmlColorSet()); + this.symbolContextBody = style.getSymbolContext(getIHtmlColorSet()); + fcHeader = styleHeader.getFontConfiguration(getIHtmlColorSet()); + this.position = style.getHorizontalAlignment(); } else { - this.symbolContext = symbolContext; - this.background = background; + this.symbolContextHeader = symbolContext; + this.symbolContextBody = symbolContextHeader.withBackColor(background); this.position = position; } - this.textHeader = stringsToDisplay.subList(0, 1).create(header, HorizontalAlignment.LEFT, spriteContainer); + this.textHeader = stringsToDisplay.subList(0, 1).create(fcHeader, HorizontalAlignment.LEFT, spriteContainer); } @@ -94,11 +93,10 @@ public class ComponentRoseReference extends AbstractTextualComponent { final int textHeaderWidth = (int) (getHeaderWidth(stringBounder)); final int textHeaderHeight = (int) (getHeaderHeight(stringBounder)); - final URectangle rect = new URectangle( - dimensionToUse.getWidth() - xMargin * 2 - symbolContext.getDeltaShadow(), dimensionToUse.getHeight() - - heightFooter); - rect.setDeltaShadow(symbolContext.getDeltaShadow()); - ug = symbolContext.withBackColor(background).apply(ug); + final URectangle rect = new URectangle(dimensionToUse.getWidth() - xMargin * 2 + - symbolContextHeader.getDeltaShadow(), dimensionToUse.getHeight() - heightFooter); + rect.setDeltaShadow(symbolContextHeader.getDeltaShadow()); + ug = symbolContextBody.apply(ug); ug.apply(new UTranslate(xMargin, 0)).draw(rect); final UPolygon polygon = new UPolygon(); @@ -111,7 +109,7 @@ public class ComponentRoseReference extends AbstractTextualComponent { polygon.addPoint(0, textHeaderHeight); polygon.addPoint(0, 0); - ug = symbolContext.apply(ug); + ug = symbolContextHeader.apply(ug); ug.apply(new UTranslate(xMargin, 0)).draw(polygon); ug = ug.apply(new UStroke()); @@ -148,7 +146,7 @@ public class ComponentRoseReference extends AbstractTextualComponent { @Override public double getPreferredWidth(StringBounder stringBounder) { return Math.max(getTextWidth(stringBounder), getHeaderWidth(stringBounder)) + xMargin * 2 - + symbolContext.getDeltaShadow(); + + symbolContextHeader.getDeltaShadow(); } } diff --git a/src/net/sourceforge/plantuml/skin/rose/Rose.java b/src/net/sourceforge/plantuml/skin/rose/Rose.java index 00aa411cb..bbdc1d79c 100644 --- a/src/net/sourceforge/plantuml/skin/rose/Rose.java +++ b/src/net/sourceforge/plantuml/skin/rose/Rose.java @@ -279,10 +279,11 @@ public class Rose { ColorParam.sequenceDividerBorder)); } if (type == ComponentType.REFERENCE) { - return new ComponentRoseReference(styles == null ? null : styles[0], getUFont2(param, - FontParam.SEQUENCE_REFERENCE), getSymbolContext(param, ColorParam.sequenceReferenceBorder), - bigFont, stringsToDisplay, param.getHorizontalAlignment(AlignmentParam.sequenceReferenceAlignment, - null, false), param, getHtmlColor(param, ColorParam.sequenceReferenceBackground)); + return new ComponentRoseReference(styles == null ? null : styles[0], styles == null ? null : styles[1], + getUFont2(param, FontParam.SEQUENCE_REFERENCE), getSymbolContext(param, + ColorParam.sequenceReferenceBorder), bigFont, stringsToDisplay, + param.getHorizontalAlignment(AlignmentParam.sequenceReferenceAlignment, null, false), param, + getHtmlColor(param, ColorParam.sequenceReferenceBackground)); } if (type == ComponentType.ENGLOBER) { return new ComponentRoseEnglober(styles == null ? null : styles[0], getSymbolContext(param, diff --git a/src/net/sourceforge/plantuml/ugraphic/sprite/ColorPalette.java b/src/net/sourceforge/plantuml/sprite/ColorPalette.java similarity index 98% rename from src/net/sourceforge/plantuml/ugraphic/sprite/ColorPalette.java rename to src/net/sourceforge/plantuml/sprite/ColorPalette.java index 59d4bd5d1..dc6717ccf 100644 --- a/src/net/sourceforge/plantuml/ugraphic/sprite/ColorPalette.java +++ b/src/net/sourceforge/plantuml/sprite/ColorPalette.java @@ -33,7 +33,7 @@ * * */ -package net.sourceforge.plantuml.ugraphic.sprite; +package net.sourceforge.plantuml.sprite; import java.awt.Color; diff --git a/src/net/sourceforge/plantuml/ugraphic/sprite/ColorPalette4096.java b/src/net/sourceforge/plantuml/sprite/ColorPalette4096.java similarity index 98% rename from src/net/sourceforge/plantuml/ugraphic/sprite/ColorPalette4096.java rename to src/net/sourceforge/plantuml/sprite/ColorPalette4096.java index beb00a433..82779347d 100644 --- a/src/net/sourceforge/plantuml/ugraphic/sprite/ColorPalette4096.java +++ b/src/net/sourceforge/plantuml/sprite/ColorPalette4096.java @@ -33,7 +33,7 @@ * * */ -package net.sourceforge.plantuml.ugraphic.sprite; +package net.sourceforge.plantuml.sprite; import java.awt.Color; diff --git a/src/net/sourceforge/plantuml/style/StyleKind.java b/src/net/sourceforge/plantuml/sprite/CommandListSprite.java similarity index 56% rename from src/net/sourceforge/plantuml/style/StyleKind.java rename to src/net/sourceforge/plantuml/sprite/CommandListSprite.java index 30c0ad2aa..9af57cfe8 100644 --- a/src/net/sourceforge/plantuml/style/StyleKind.java +++ b/src/net/sourceforge/plantuml/sprite/CommandListSprite.java @@ -30,19 +30,35 @@ * * * Original Author: Arnaud Roques - * + * * */ -package net.sourceforge.plantuml.style; +package net.sourceforge.plantuml.sprite; -public enum StyleKind { - STYLE, STEREOTYPE; +import net.sourceforge.plantuml.LineLocation; +import net.sourceforge.plantuml.UmlDiagram; +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; +import net.sourceforge.plantuml.command.regex.RegexConcat; +import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexResult; - public StyleKind add(StyleKind other) { - if (this == STEREOTYPE || other == STEREOTYPE) { - return STEREOTYPE; - } - return STYLE; +public class CommandListSprite extends SingleLineCommand2 { + + public CommandListSprite() { + super(getRegexConcat()); } -} \ No newline at end of file + private static IRegex getRegexConcat() { + return RegexConcat.build(CommandListSprite.class.getName(), RegexLeaf.start(), // + new RegexLeaf("listsprites?"), // + RegexLeaf.end()); + } + + @Override + protected CommandExecutionResult executeArg(UmlDiagram system, LineLocation location, RegexResult arg) { + return CommandExecutionResult.ok(); + } + +} diff --git a/src/net/sourceforge/plantuml/sprite/ListSpriteDiagram.java b/src/net/sourceforge/plantuml/sprite/ListSpriteDiagram.java new file mode 100644 index 000000000..7ce43f5a5 --- /dev/null +++ b/src/net/sourceforge/plantuml/sprite/ListSpriteDiagram.java @@ -0,0 +1,125 @@ +/* ======================================================================== + * 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.sprite; + +import java.awt.geom.Dimension2D; +import java.io.IOException; +import java.io.OutputStream; + +import net.sourceforge.plantuml.Dimension2DDouble; +import net.sourceforge.plantuml.FileFormatOption; +import net.sourceforge.plantuml.ISkinSimple; +import net.sourceforge.plantuml.UmlDiagram; +import net.sourceforge.plantuml.UmlDiagramType; +import net.sourceforge.plantuml.core.DiagramDescription; +import net.sourceforge.plantuml.core.ImageData; +import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.graphic.AbstractTextBlock; +import net.sourceforge.plantuml.graphic.FontConfiguration; +import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.graphic.HtmlColorUtils; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.graphic.TextBlock; +import net.sourceforge.plantuml.graphic.TextBlockUtils; +import net.sourceforge.plantuml.ugraphic.ImageBuilder; +import net.sourceforge.plantuml.ugraphic.UFont; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public class ListSpriteDiagram extends UmlDiagram { + + public ListSpriteDiagram(ISkinSimple skinParam) { + super(skinParam); + } + + public DiagramDescription getDescription() { + return new DiagramDescription("(Sprites)"); + } + + @Override + public UmlDiagramType getUmlDiagramType() { + return UmlDiagramType.HELP; + } + + @Override + protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption) + throws IOException { + + final TextBlock result = getTable(); + final double margin = 10; + final double dpiFactor = 1; + + final ImageBuilder imageBuilder = new ImageBuilder(getSkinParam(), dpiFactor, + fileFormatOption.isWithMetadata() ? getMetadata() : null, getWarningOrError(), margin, margin, + getAnimation()); + imageBuilder.setUDrawable(result); + + return imageBuilder.writeImageTOBEMOVED(fileFormatOption, seed(), os); + } + + private TextBlock getTable() { + return new AbstractTextBlock() { + + public void drawU(UGraphic ug) { + double x = 0; + double y = 0; + double rawHeight = 0; + for (String n : getSkinParam().getAllSpriteNames()) { + final Sprite sprite = getSkinParam().getSprite(n); + TextBlock blockName = Display.create(n).create( + FontConfiguration.blackBlueTrue(UFont.sansSerif(14)), HorizontalAlignment.LEFT, + getSkinParam()); + TextBlock tb = sprite.asTextBlock(HtmlColorUtils.BLACK, 1.0); + tb = TextBlockUtils.mergeTB(tb, blockName, HorizontalAlignment.CENTER); + tb.drawU(ug.apply(new UTranslate(x, y))); + final Dimension2D dim = tb.calculateDimension(ug.getStringBounder()); + rawHeight = Math.max(rawHeight, dim.getHeight()); + x += dim.getWidth(); + x += 30; + if (x > 1024) { + x = 0; + y += rawHeight + 50; + rawHeight = 0; + } + } + } + + public Dimension2D calculateDimension(StringBounder stringBounder) { + return new Dimension2DDouble(1024, 1024); + } + }; + } +} diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ShadowShape.java b/src/net/sourceforge/plantuml/sprite/ListSpriteDiagramFactory.java similarity index 63% rename from src/net/sourceforge/plantuml/skin/bluemodern/ShadowShape.java rename to src/net/sourceforge/plantuml/sprite/ListSpriteDiagramFactory.java index ae92dc9b2..f09144cc0 100644 --- a/src/net/sourceforge/plantuml/skin/bluemodern/ShadowShape.java +++ b/src/net/sourceforge/plantuml/sprite/ListSpriteDiagramFactory.java @@ -30,18 +30,38 @@ * * * Original Author: Arnaud Roques - * + * * */ -package net.sourceforge.plantuml.skin.bluemodern; +package net.sourceforge.plantuml.sprite; -import net.sourceforge.plantuml.graphic.HtmlColorUtils; +import java.util.ArrayList; +import java.util.List; -public class ShadowShape extends FillRoundShape { +import net.sourceforge.plantuml.ISkinSimple; +import net.sourceforge.plantuml.command.Command; +import net.sourceforge.plantuml.command.UmlDiagramFactory; - public ShadowShape(double width, double height, double corner) { - super(width, height, HtmlColorUtils.LIGHT_GRAY, HtmlColorUtils.GRAY, corner); +public class ListSpriteDiagramFactory extends UmlDiagramFactory { + private final ISkinSimple skinParam; + + public ListSpriteDiagramFactory(ISkinSimple skinParam) { + this.skinParam = skinParam; + } + + @Override + protected List createCommands() { + + final List cmds = new ArrayList(); + addCommonCommands1(cmds); + addCommonCommands2(cmds); + return cmds; + } + + @Override + public ListSpriteDiagram createEmptyDiagram() { + return new ListSpriteDiagram(skinParam); } } diff --git a/src/net/sourceforge/plantuml/ugraphic/sprite/PSystemListInternalSprites.java b/src/net/sourceforge/plantuml/sprite/PSystemListInternalSprites.java similarity index 98% rename from src/net/sourceforge/plantuml/ugraphic/sprite/PSystemListInternalSprites.java rename to src/net/sourceforge/plantuml/sprite/PSystemListInternalSprites.java index 658e494c8..a4c040321 100644 --- a/src/net/sourceforge/plantuml/ugraphic/sprite/PSystemListInternalSprites.java +++ b/src/net/sourceforge/plantuml/sprite/PSystemListInternalSprites.java @@ -33,7 +33,7 @@ * * */ -package net.sourceforge.plantuml.ugraphic.sprite; +package net.sourceforge.plantuml.sprite; import java.io.IOException; import java.io.OutputStream; diff --git a/src/net/sourceforge/plantuml/ugraphic/sprite/PSystemListInternalSpritesFactory.java b/src/net/sourceforge/plantuml/sprite/PSystemListInternalSpritesFactory.java similarity index 97% rename from src/net/sourceforge/plantuml/ugraphic/sprite/PSystemListInternalSpritesFactory.java rename to src/net/sourceforge/plantuml/sprite/PSystemListInternalSpritesFactory.java index fcc8a627d..3da48d1a4 100644 --- a/src/net/sourceforge/plantuml/ugraphic/sprite/PSystemListInternalSpritesFactory.java +++ b/src/net/sourceforge/plantuml/sprite/PSystemListInternalSpritesFactory.java @@ -33,7 +33,7 @@ * * */ -package net.sourceforge.plantuml.ugraphic.sprite; +package net.sourceforge.plantuml.sprite; import net.sourceforge.plantuml.AbstractPSystem; import net.sourceforge.plantuml.StringUtils; diff --git a/src/net/sourceforge/plantuml/ugraphic/sprite/RessourcesUtils.java b/src/net/sourceforge/plantuml/sprite/RessourcesUtils.java similarity index 98% rename from src/net/sourceforge/plantuml/ugraphic/sprite/RessourcesUtils.java rename to src/net/sourceforge/plantuml/sprite/RessourcesUtils.java index 6bf3bfff1..51fb2b19b 100644 --- a/src/net/sourceforge/plantuml/ugraphic/sprite/RessourcesUtils.java +++ b/src/net/sourceforge/plantuml/sprite/RessourcesUtils.java @@ -33,7 +33,7 @@ * * */ -package net.sourceforge.plantuml.ugraphic.sprite; +package net.sourceforge.plantuml.sprite; import java.io.File; import java.io.IOException; diff --git a/src/net/sourceforge/plantuml/ugraphic/sprite/Sprite.java b/src/net/sourceforge/plantuml/sprite/Sprite.java similarity index 96% rename from src/net/sourceforge/plantuml/ugraphic/sprite/Sprite.java rename to src/net/sourceforge/plantuml/sprite/Sprite.java index 57a9fac20..f061d85dd 100644 --- a/src/net/sourceforge/plantuml/ugraphic/sprite/Sprite.java +++ b/src/net/sourceforge/plantuml/sprite/Sprite.java @@ -33,7 +33,7 @@ * * */ -package net.sourceforge.plantuml.ugraphic.sprite; +package net.sourceforge.plantuml.sprite; import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.TextBlock; diff --git a/src/net/sourceforge/plantuml/ugraphic/sprite/SpriteColor.java b/src/net/sourceforge/plantuml/sprite/SpriteColor.java similarity index 98% rename from src/net/sourceforge/plantuml/ugraphic/sprite/SpriteColor.java rename to src/net/sourceforge/plantuml/sprite/SpriteColor.java index 42aa49297..608830be8 100644 --- a/src/net/sourceforge/plantuml/ugraphic/sprite/SpriteColor.java +++ b/src/net/sourceforge/plantuml/sprite/SpriteColor.java @@ -33,7 +33,7 @@ * * */ -package net.sourceforge.plantuml.ugraphic.sprite; +package net.sourceforge.plantuml.sprite; import java.awt.Color; import java.awt.geom.Dimension2D; diff --git a/src/net/sourceforge/plantuml/ugraphic/sprite/SpriteColorBuilder.java b/src/net/sourceforge/plantuml/sprite/SpriteColorBuilder.java similarity index 98% rename from src/net/sourceforge/plantuml/ugraphic/sprite/SpriteColorBuilder.java rename to src/net/sourceforge/plantuml/sprite/SpriteColorBuilder.java index 7f89c1138..1a6096cd1 100644 --- a/src/net/sourceforge/plantuml/ugraphic/sprite/SpriteColorBuilder.java +++ b/src/net/sourceforge/plantuml/sprite/SpriteColorBuilder.java @@ -33,7 +33,7 @@ * * */ -package net.sourceforge.plantuml.ugraphic.sprite; +package net.sourceforge.plantuml.sprite; import java.awt.Color; import java.awt.image.BufferedImage; diff --git a/src/net/sourceforge/plantuml/ugraphic/sprite/SpriteColorBuilder4096.java b/src/net/sourceforge/plantuml/sprite/SpriteColorBuilder4096.java similarity index 98% rename from src/net/sourceforge/plantuml/ugraphic/sprite/SpriteColorBuilder4096.java rename to src/net/sourceforge/plantuml/sprite/SpriteColorBuilder4096.java index 6048000a5..ec0ccdcf5 100644 --- a/src/net/sourceforge/plantuml/ugraphic/sprite/SpriteColorBuilder4096.java +++ b/src/net/sourceforge/plantuml/sprite/SpriteColorBuilder4096.java @@ -33,7 +33,7 @@ * * */ -package net.sourceforge.plantuml.ugraphic.sprite; +package net.sourceforge.plantuml.sprite; import java.awt.Color; import java.awt.image.BufferedImage; diff --git a/src/net/sourceforge/plantuml/ugraphic/sprite/SpriteGrayLevel.java b/src/net/sourceforge/plantuml/sprite/SpriteGrayLevel.java similarity index 99% rename from src/net/sourceforge/plantuml/ugraphic/sprite/SpriteGrayLevel.java rename to src/net/sourceforge/plantuml/sprite/SpriteGrayLevel.java index 6c7381cd6..00b4d5213 100644 --- a/src/net/sourceforge/plantuml/ugraphic/sprite/SpriteGrayLevel.java +++ b/src/net/sourceforge/plantuml/sprite/SpriteGrayLevel.java @@ -33,7 +33,7 @@ * * */ -package net.sourceforge.plantuml.ugraphic.sprite; +package net.sourceforge.plantuml.sprite; import java.awt.Color; import java.awt.image.BufferedImage; diff --git a/src/net/sourceforge/plantuml/ugraphic/sprite/SpriteImage.java b/src/net/sourceforge/plantuml/sprite/SpriteImage.java similarity index 98% rename from src/net/sourceforge/plantuml/ugraphic/sprite/SpriteImage.java rename to src/net/sourceforge/plantuml/sprite/SpriteImage.java index 17cd87672..ae64e0503 100644 --- a/src/net/sourceforge/plantuml/ugraphic/sprite/SpriteImage.java +++ b/src/net/sourceforge/plantuml/sprite/SpriteImage.java @@ -33,7 +33,7 @@ * * */ -package net.sourceforge.plantuml.ugraphic.sprite; +package net.sourceforge.plantuml.sprite; import java.awt.geom.Dimension2D; import java.awt.image.BufferedImage; diff --git a/src/net/sourceforge/plantuml/ugraphic/sprite/SpriteMonochrome.java b/src/net/sourceforge/plantuml/sprite/SpriteMonochrome.java similarity index 99% rename from src/net/sourceforge/plantuml/ugraphic/sprite/SpriteMonochrome.java rename to src/net/sourceforge/plantuml/sprite/SpriteMonochrome.java index 5df43dda5..8f4cca647 100644 --- a/src/net/sourceforge/plantuml/ugraphic/sprite/SpriteMonochrome.java +++ b/src/net/sourceforge/plantuml/sprite/SpriteMonochrome.java @@ -33,7 +33,7 @@ * * */ -package net.sourceforge.plantuml.ugraphic.sprite; +package net.sourceforge.plantuml.sprite; import java.awt.Color; import java.awt.geom.Dimension2D; diff --git a/src/net/sourceforge/plantuml/ugraphic/sprite/SpriteSvg.java b/src/net/sourceforge/plantuml/sprite/SpriteSvg.java similarity index 98% rename from src/net/sourceforge/plantuml/ugraphic/sprite/SpriteSvg.java rename to src/net/sourceforge/plantuml/sprite/SpriteSvg.java index 01e62dd41..0544c569b 100644 --- a/src/net/sourceforge/plantuml/ugraphic/sprite/SpriteSvg.java +++ b/src/net/sourceforge/plantuml/sprite/SpriteSvg.java @@ -33,7 +33,7 @@ * * */ -package net.sourceforge.plantuml.ugraphic.sprite; +package net.sourceforge.plantuml.sprite; import java.awt.geom.Dimension2D; import java.io.File; diff --git a/src/net/sourceforge/plantuml/ugraphic/sprite/SpriteUtils.java b/src/net/sourceforge/plantuml/sprite/SpriteUtils.java similarity index 98% rename from src/net/sourceforge/plantuml/ugraphic/sprite/SpriteUtils.java rename to src/net/sourceforge/plantuml/sprite/SpriteUtils.java index a0e5d127c..3a27117f1 100644 --- a/src/net/sourceforge/plantuml/ugraphic/sprite/SpriteUtils.java +++ b/src/net/sourceforge/plantuml/sprite/SpriteUtils.java @@ -33,7 +33,7 @@ * * */ -package net.sourceforge.plantuml.ugraphic.sprite; +package net.sourceforge.plantuml.sprite; import java.awt.image.BufferedImage; import java.util.List; diff --git a/src/net/sourceforge/plantuml/style/ClockwiseTopRightBottomLeft.java b/src/net/sourceforge/plantuml/style/ClockwiseTopRightBottomLeft.java index d11821fd8..56cbe1677 100644 --- a/src/net/sourceforge/plantuml/style/ClockwiseTopRightBottomLeft.java +++ b/src/net/sourceforge/plantuml/style/ClockwiseTopRightBottomLeft.java @@ -37,4 +37,14 @@ package net.sourceforge.plantuml.style; public class ClockwiseTopRightBottomLeft { + private final double value; + + public ClockwiseTopRightBottomLeft(double value) { + this.value = value; + } + + public double asDouble() { + return value; + } + } \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/style/CommandStyleMultilines.java b/src/net/sourceforge/plantuml/style/CommandStyleMultilines.java deleted file mode 100644 index b2b8ae82c..000000000 --- a/src/net/sourceforge/plantuml/style/CommandStyleMultilines.java +++ /dev/null @@ -1,125 +0,0 @@ -/* ======================================================================== - * 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.style; - -import java.util.EnumMap; -import java.util.Map; - -import net.sourceforge.plantuml.SkinParam; -import net.sourceforge.plantuml.StringLocated; -import net.sourceforge.plantuml.UmlDiagram; -import net.sourceforge.plantuml.command.BlocLines; -import net.sourceforge.plantuml.command.CommandExecutionResult; -import net.sourceforge.plantuml.command.CommandMultilines2; -import net.sourceforge.plantuml.command.MultilinesStrategy; -import net.sourceforge.plantuml.command.regex.IRegex; -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.RegexConcat; -import net.sourceforge.plantuml.command.regex.RegexLeaf; -import net.sourceforge.plantuml.command.regex.RegexResult; - -public class CommandStyleMultilines extends CommandMultilines2 { - - public CommandStyleMultilines() { - super(getRegexConcat(), MultilinesStrategy.REMOVE_STARTING_QUOTE); - } - - @Override - public String getPatternEnd() { - return "(?i)^[%s]*\\}[%s]*$"; - } - - private static IRegex getRegexConcat() { - return RegexConcat.build(CommandStyleMultilines.class.getName(), RegexLeaf.start(), // - new RegexLeaf("TYPE", "(style|stereotype)"), // - RegexLeaf.spaceOneOrMore(), // - new RegexLeaf("NAME", "(\\w+(?:\\+\\w+)*)"), // - RegexLeaf.spaceOneOrMore(), // - new RegexLeaf("\\{"), // - RegexLeaf.end() // - ); - } - - @Override - public boolean syntaxWithFinalBracket() { - return true; - } - - protected CommandExecutionResult executeNow(UmlDiagram diagram, BlocLines lines) { - if (SkinParam.USE_STYLES()) { - lines = lines.trimSmart(1); - final Style modifiedStyle = getDeclaredStyle(lines, diagram.getSkinParam().getCurrentStyleBuilder()); - diagram.getSkinParam().muteStyle(modifiedStyle); - } - - return CommandExecutionResult.ok(); - } - - public final static Pattern2 p1 = MyPattern.cmpile("^([\\w]+)[%s]+(.*)$"); - - public Style getDeclaredStyle(BlocLines lines, AutomaticCounter counter) { - lines = lines.trimSmart(1); - final RegexResult line0 = getStartingPattern().matcher(lines.getFirst499().getTrimmed().getString()); - final String name = line0.get("NAME", 0); - final String kind = line0.get("TYPE", 0).toUpperCase(); - // System.err.println("name=" + name); - if (lines.size() > 1) { - lines = lines.subExtract(1, 1); - } - lines = lines.trim(true); - - final Map map = new EnumMap(PName.class); - for (StringLocated s : lines) { - assert s.getString().length() > 0; - - final Matcher2 m = p1.matcher(s.getString()); - if (m.find() == false) { - throw new IllegalStateException(); - } - final PName key = PName.getFromName(m.group(1)); - final String value = m.group(2); - // System.err.println("key=" + key + " " + value); - if (key != null) { - map.put(key, new ValueImpl(value, counter)); - } - } - - return new Style(StyleKind.valueOf(kind), name, map); - } - -} diff --git a/src/net/sourceforge/plantuml/style/CommandStyleMultilinesCSS.java b/src/net/sourceforge/plantuml/style/CommandStyleMultilinesCSS.java new file mode 100644 index 000000000..9547d2cbb --- /dev/null +++ b/src/net/sourceforge/plantuml/style/CommandStyleMultilinesCSS.java @@ -0,0 +1,172 @@ +/* ======================================================================== + * 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.style; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.EnumMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import net.sourceforge.plantuml.SkinParam; +import net.sourceforge.plantuml.StringLocated; +import net.sourceforge.plantuml.UmlDiagram; +import net.sourceforge.plantuml.command.BlocLines; +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.command.CommandMultilines2; +import net.sourceforge.plantuml.command.MultilinesStrategy; +import net.sourceforge.plantuml.command.regex.IRegex; +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.RegexConcat; +import net.sourceforge.plantuml.command.regex.RegexLeaf; + +public class CommandStyleMultilinesCSS extends CommandMultilines2 { + + public static final String STYLE_SELECTOR_SEPARATOR2 = "-&"; + + public CommandStyleMultilinesCSS() { + super(getRegexConcat(), MultilinesStrategy.REMOVE_STARTING_QUOTE); + } + + @Override + public String getPatternEnd() { + return "(?i)^[%s]*\\[%s]*$"; + } + + private static IRegex getRegexConcat() { + return RegexConcat.build(CommandStyleMultilinesCSS.class.getName(), RegexLeaf.start(), // + new RegexLeaf("\\"), // + RegexLeaf.end() // + ); + } + + private static final String NAME_USER = "[\\w()]+?"; + private final static Pattern2 userName = MyPattern.cmpile("^[.:]?(" + NAME_USER + ")([%s]+\\*)?[%s]*\\{$"); + private final static Pattern2 propertyAndValue = MyPattern.cmpile("^([\\w]+):?[%s]+(.*?);?$"); + private final static Pattern2 closeBracket = MyPattern.cmpile("^\\}$"); + + protected CommandExecutionResult executeNow(UmlDiagram diagram, BlocLines lines) { + if (SkinParam.USE_STYLES() == false) { + return CommandExecutionResult.ok(); + } + final StyleBuilder styleBuilder = diagram.getSkinParam().getCurrentStyleBuilder(); + for (Style modifiedStyle : getDeclaredStyles(lines.subExtract(1, 1), styleBuilder)) { + diagram.getSkinParam().muteStyle(modifiedStyle); + } + return CommandExecutionResult.ok(); + } + + public Collection