diff --git a/pom.xml b/pom.xml index 6b4f66779..c58f20590 100644 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,7 @@ net.sourceforge.plantuml plantuml - 1.2020.18-SNAPSHOT + 1.2020.19-SNAPSHOT jar PlantUML diff --git a/src/net/sourceforge/plantuml/EmbeddedDiagram.java b/src/net/sourceforge/plantuml/EmbeddedDiagram.java index 4a4c41d97..995ed7a26 100644 --- a/src/net/sourceforge/plantuml/EmbeddedDiagram.java +++ b/src/net/sourceforge/plantuml/EmbeddedDiagram.java @@ -60,6 +60,29 @@ import net.sourceforge.plantuml.ugraphic.UShape; public class EmbeddedDiagram implements CharSequence { + public static String getEmbeddedType(CharSequence s) { + if (s == null) { + return null; + } + s = StringUtils.trin(s.toString()); + if (s.equals("{{")) { + return "uml"; + } + if (s.equals("{{uml")) { + return "uml"; + } + if (s.equals("{{wbs")) { + return "wbs"; + } + if (s.equals("{{mindmap")) { + return "mindmap"; + } + if (s.equals("{{gantt")) { + return "gantt"; + } + return null; + } + private final Display system; public EmbeddedDiagram(Display system) { @@ -131,10 +154,12 @@ public class EmbeddedDiagram implements CharSequence { } private String getImageSvg() throws IOException, InterruptedException { + final boolean sav = SkinParam.USE_STYLES(); final Diagram system = getSystem(); final ByteArrayOutputStream os = new ByteArrayOutputStream(); system.exportDiagram(os, 0, new FileFormatOption(FileFormat.SVG)); os.close(); + SkinParam.setBetaStyle(sav); return new String(os.toByteArray()); } diff --git a/src/net/sourceforge/plantuml/ISkinParam.java b/src/net/sourceforge/plantuml/ISkinParam.java index 2322e5660..950d69023 100644 --- a/src/net/sourceforge/plantuml/ISkinParam.java +++ b/src/net/sourceforge/plantuml/ISkinParam.java @@ -126,8 +126,6 @@ public interface ISkinParam extends ISkinSimple { public ConditionEndStyle getConditionEndStyle(); - public double minClassWidth(); - public boolean sameClassWidth(); public Rankdir getRankdir(); diff --git a/src/net/sourceforge/plantuml/ISkinSimple.java b/src/net/sourceforge/plantuml/ISkinSimple.java index 5a86337d5..54f4c32d4 100644 --- a/src/net/sourceforge/plantuml/ISkinSimple.java +++ b/src/net/sourceforge/plantuml/ISkinSimple.java @@ -62,4 +62,6 @@ public interface ISkinSimple extends SpriteContainer { public void copyAllFrom(ISkinSimple other); + public double minClassWidth(); + } \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/PSystemBuilder.java b/src/net/sourceforge/plantuml/PSystemBuilder.java index 18dc21a62..f7f559e12 100644 --- a/src/net/sourceforge/plantuml/PSystemBuilder.java +++ b/src/net/sourceforge/plantuml/PSystemBuilder.java @@ -78,7 +78,7 @@ import net.sourceforge.plantuml.openiconic.PSystemListOpenIconicFactory; import net.sourceforge.plantuml.openiconic.PSystemOpenIconicFactory; import net.sourceforge.plantuml.oregon.PSystemOregonFactory; import net.sourceforge.plantuml.project.GanttDiagramFactory; -import net.sourceforge.plantuml.salt.PSystemSaltFactory; +import net.sourceforge.plantuml.salt.PSystemSaltFactory2; import net.sourceforge.plantuml.security.SecurityProfile; import net.sourceforge.plantuml.security.SecurityUtils; import net.sourceforge.plantuml.sequencediagram.SequenceDiagramFactory; @@ -168,8 +168,8 @@ public class PSystemBuilder { factories.add(new PSystemOpenIconicFactory()); factories.add(new PSystemListOpenIconicFactory()); factories.add(new PSystemListInternalSpritesFactory()); - factories.add(new PSystemSaltFactory(DiagramType.SALT)); - factories.add(new PSystemSaltFactory(DiagramType.UML)); + factories.add(new PSystemSaltFactory2(DiagramType.SALT)); + factories.add(new PSystemSaltFactory2(DiagramType.UML)); factories.add(new PSystemDotFactory(DiagramType.DOT)); factories.add(new PSystemDotFactory(DiagramType.UML)); factories.add(new NwDiagramFactory()); diff --git a/src/net/sourceforge/plantuml/Run.java b/src/net/sourceforge/plantuml/Run.java index 284efe355..8a903e1db 100644 --- a/src/net/sourceforge/plantuml/Run.java +++ b/src/net/sourceforge/plantuml/Run.java @@ -59,7 +59,7 @@ import net.sourceforge.plantuml.classdiagram.ClassDiagramFactory; import net.sourceforge.plantuml.code.NoPlantumlCompressionException; import net.sourceforge.plantuml.code.Transcoder; import net.sourceforge.plantuml.code.TranscoderUtil; -import net.sourceforge.plantuml.command.UmlDiagramFactory; +import net.sourceforge.plantuml.command.PSystemCommandFactory; import net.sourceforge.plantuml.descdiagram.DescriptionDiagramFactory; import net.sourceforge.plantuml.ftp.FtpServer; import net.sourceforge.plantuml.png.MetadataTag; @@ -349,7 +349,7 @@ public class Run { // printPattern(new ObjectDiagramFactory(null)); } - private static void printPattern(UmlDiagramFactory factory) { + private static void printPattern(PSystemCommandFactory factory) { System.out.println(); System.out.println(factory.getClass().getSimpleName().replaceAll("Factory", "")); final List descriptions = factory.getDescription(); diff --git a/src/net/sourceforge/plantuml/SpriteContainerEmpty.java b/src/net/sourceforge/plantuml/SpriteContainerEmpty.java index a5361f1c5..1e9a7de0a 100644 --- a/src/net/sourceforge/plantuml/SpriteContainerEmpty.java +++ b/src/net/sourceforge/plantuml/SpriteContainerEmpty.java @@ -94,4 +94,8 @@ public class SpriteContainerEmpty implements SpriteContainer, ISkinSimple { throw new UnsupportedOperationException(); } + public double minClassWidth() { + return 0; + } + } \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/TitledDiagram.java b/src/net/sourceforge/plantuml/TitledDiagram.java index 9de2ceb7a..671d811d7 100644 --- a/src/net/sourceforge/plantuml/TitledDiagram.java +++ b/src/net/sourceforge/plantuml/TitledDiagram.java @@ -37,10 +37,7 @@ package net.sourceforge.plantuml; import java.io.IOException; -import net.sourceforge.plantuml.command.BlocLines; -import net.sourceforge.plantuml.command.CommandControl; import net.sourceforge.plantuml.command.CommandExecutionResult; -import net.sourceforge.plantuml.command.CommandSkinParamMultilines; import net.sourceforge.plantuml.core.Diagram; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.DisplayPositionned; @@ -48,6 +45,7 @@ import net.sourceforge.plantuml.cucadiagram.DisplaySection; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.VerticalAlignment; import net.sourceforge.plantuml.sprite.Sprite; +import net.sourceforge.plantuml.style.StyleBuilder; public abstract class TitledDiagram extends AbstractPSystem implements Diagram, Annotated { @@ -61,10 +59,20 @@ public abstract class TitledDiagram extends AbstractPSystem implements Diagram, private final SkinParam skinParam; + private final Pragma pragma = new Pragma(); + + public Pragma getPragma() { + return pragma; + } + public TitledDiagram() { this.skinParam = SkinParam.create(getUmlDiagramType()); } + public final StyleBuilder getCurrentStyleBuilder() { + return skinParam.getCurrentStyleBuilder(); + } + public TitledDiagram(ISkinSimple orig) { this(); if (orig != null) { @@ -179,4 +187,25 @@ public abstract class TitledDiagram extends AbstractPSystem implements Diagram, return mainFrame; } + private boolean useJDot; + + public void setUseJDot(boolean useJDot) { + this.useJDot = useJDot; + } + + public static final boolean FORCE_JDOT = false; + + public boolean isUseJDot() { + if (FORCE_JDOT) + return true; + return useJDot; + } + + public final double getScaleCoef(FileFormatOption fileFormatOption) { + if (getSkinParam().getDpi() == 96) { + return fileFormatOption.getScaleCoef(); + } + return getSkinParam().getDpi() * fileFormatOption.getScaleCoef() / 96.0; + } + } diff --git a/src/net/sourceforge/plantuml/UmlDiagram.java b/src/net/sourceforge/plantuml/UmlDiagram.java index 615f2efc4..390701037 100644 --- a/src/net/sourceforge/plantuml/UmlDiagram.java +++ b/src/net/sourceforge/plantuml/UmlDiagram.java @@ -55,10 +55,7 @@ import javax.script.ScriptException; import net.sourceforge.plantuml.anim.Animation; import net.sourceforge.plantuml.anim.AnimationDecoder; import net.sourceforge.plantuml.api.ImageDataSimple; -import net.sourceforge.plantuml.command.BlocLines; -import net.sourceforge.plantuml.command.CommandControl; import net.sourceforge.plantuml.command.CommandExecutionResult; -import net.sourceforge.plantuml.command.CommandSkinParamMultilines; import net.sourceforge.plantuml.core.Diagram; import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.core.UmlSource; @@ -75,7 +72,6 @@ import net.sourceforge.plantuml.pdf.PdfConverter; import net.sourceforge.plantuml.security.ImageIO; import net.sourceforge.plantuml.security.SFile; import net.sourceforge.plantuml.security.SecurityUtils; -import net.sourceforge.plantuml.sprite.Sprite; import net.sourceforge.plantuml.svek.EmptySvgException; import net.sourceforge.plantuml.svek.GraphvizCrash; import net.sourceforge.plantuml.svek.TextBlockBackcolored; @@ -97,7 +93,6 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot private int minwidth = Integer.MAX_VALUE; - private final Pragma pragma = new Pragma(); private Animation animation; public UmlDiagram() { @@ -134,10 +129,6 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot throw new IllegalArgumentException(); } - public Pragma getPragma() { - return pragma; - } - final public void setAnimation(Iterable animationData) { try { final AnimationDecoder animationDecoder = new AnimationDecoder(animationData); @@ -152,13 +143,6 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot return animation; } - public final double getScaleCoef(FileFormatOption fileFormatOption) { - if (getSkinParam().getDpi() == 96) { - return fileFormatOption.getScaleCoef(); - } - return getSkinParam().getDpi() * fileFormatOption.getScaleCoef() / 96.0; - } - public final boolean isHideUnlinkedData() { return hideUnlinkedData; } @@ -242,8 +226,7 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot graphicStrings.drawU(ug); final double height = graphicStrings.calculateDimension(ug.getStringBounder()).getHeight(); ug = ug.apply(UTranslate.dy(height)); - ug.draw(new UImage(new PixelImage(im, AffineTransformType.TYPE_NEAREST_NEIGHBOR)) - .scale(3)); + ug.draw(new UImage(new PixelImage(im, AffineTransformType.TYPE_NEAREST_NEIGHBOR)).scale(3)); } }); } @@ -327,7 +310,7 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot private ImageData exportDiagramInternalPdf(OutputStream os, int index) throws IOException { final File svg = FileUtils.createTempFileLegacy("pdf", ".svf"); final File pdfFile = FileUtils.createTempFileLegacy("pdf", ".pdf"); - final OutputStream fos = new BufferedOutputStream(new FileOutputStream(svg));; + final OutputStream fos = new BufferedOutputStream(new FileOutputStream(svg)); final ImageData result = exportDiagram(fos, index, new FileFormatOption(FileFormat.SVG)); fos.close(); PdfConverter.convert(svg, pdfFile); @@ -384,21 +367,6 @@ public abstract class UmlDiagram extends TitledDiagram implements Diagram, Annot return null; } - private boolean useJDot; - - public void setUseJDot(boolean useJDot) { - this.useJDot = useJDot; - } - - public static final boolean FORCE_JDOT = false; - - public boolean isUseJDot() { - if (FORCE_JDOT) - return true; - return useJDot; - } - - public void setHideEmptyDescription(boolean hideEmptyDescription) { } diff --git a/src/net/sourceforge/plantuml/UmlDiagramType.java b/src/net/sourceforge/plantuml/UmlDiagramType.java index d6482a84a..c49c34366 100644 --- a/src/net/sourceforge/plantuml/UmlDiagramType.java +++ b/src/net/sourceforge/plantuml/UmlDiagramType.java @@ -39,7 +39,7 @@ import net.sourceforge.plantuml.style.SName; public enum UmlDiagramType { SEQUENCE, STATE, CLASS, OBJECT, ACTIVITY, DESCRIPTION, COMPOSITE, FLOW, TIMING, BPM, NWDIAG, MINDMAP, WBS, WIRE, - HELP, GANTT; + HELP, GANTT, SALT; public SName getStyleName() { if (this == SEQUENCE) { @@ -72,6 +72,9 @@ public enum UmlDiagramType { if (this == GANTT) { return SName.ganttDiagram; } + if (this == SALT) { + return SName.saltDiagram; + } return SName.activityDiagram; } } diff --git a/src/net/sourceforge/plantuml/activitydiagram/ActivityDiagramFactory.java b/src/net/sourceforge/plantuml/activitydiagram/ActivityDiagramFactory.java index 7d6c7a750..2d41edda5 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/ActivityDiagramFactory.java +++ b/src/net/sourceforge/plantuml/activitydiagram/ActivityDiagramFactory.java @@ -50,11 +50,11 @@ import net.sourceforge.plantuml.classdiagram.command.CommandHideShow2; import net.sourceforge.plantuml.command.Command; import net.sourceforge.plantuml.command.CommandFootboxIgnored; import net.sourceforge.plantuml.command.CommandRankDir; -import net.sourceforge.plantuml.command.UmlDiagramFactory; +import net.sourceforge.plantuml.command.PSystemCommandFactory; import net.sourceforge.plantuml.command.note.CommandFactoryNoteActivity; import net.sourceforge.plantuml.command.note.CommandFactoryNoteOnLink; -public class ActivityDiagramFactory extends UmlDiagramFactory { +public class ActivityDiagramFactory extends PSystemCommandFactory { private final ISkinSimple skinParam; diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagramFactory3.java b/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagramFactory3.java index 2ef005d91..ac20baa83 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagramFactory3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagramFactory3.java @@ -86,9 +86,9 @@ import net.sourceforge.plantuml.activitydiagram3.command.CommandWhileEnd3; import net.sourceforge.plantuml.command.Command; import net.sourceforge.plantuml.command.CommandDecoratorMultine; import net.sourceforge.plantuml.command.CommandFootboxIgnored; -import net.sourceforge.plantuml.command.UmlDiagramFactory; +import net.sourceforge.plantuml.command.PSystemCommandFactory; -public class ActivityDiagramFactory3 extends UmlDiagramFactory { +public class ActivityDiagramFactory3 extends PSystemCommandFactory { private final ISkinSimple skinParam; diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionRepeat.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionRepeat.java index 09fa40353..98216f238 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionRepeat.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionRepeat.java @@ -52,7 +52,7 @@ import net.sourceforge.plantuml.ugraphic.color.HColor; public class InstructionRepeat implements Instruction { - private final InstructionList repeatList = new InstructionList(); + private final InstructionList repeatList; private final Instruction parent; private final LinkRendering nextLinkRenderer; private final Swimlane swimlane; @@ -78,6 +78,7 @@ public class InstructionRepeat implements Instruction { public InstructionRepeat(Swimlane swimlane, Instruction parent, LinkRendering nextLinkRenderer, HColor color, Display startLabel, BoxStyle boxStyleIn, Colors colors) { + this.repeatList = new InstructionList(swimlane); this.boxStyleIn = boxStyleIn; this.startLabel = startLabel; this.parent = parent; diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/EntityImageLegend.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/EntityImageLegend.java index 59e0a826c..9fa01647b 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/EntityImageLegend.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/EntityImageLegend.java @@ -39,12 +39,16 @@ import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.LineParam; +import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlockUtils; 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; import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.color.HColor; @@ -52,6 +56,13 @@ public class EntityImageLegend { public static TextBlock create(Display note, ISkinParam skinParam) { + if (SkinParam.USE_STYLES()) { + final Style style = StyleSignature + .of(SName.root, skinParam.getUmlDiagramType().getStyleName(), SName.legend) + .getMergedStyle(skinParam.getCurrentStyleBuilder()); + return style.createTextBlockBordered(note, skinParam.getIHtmlColorSet(), skinParam); + } + final TextBlock textBlock = note.create(new FontConfiguration(skinParam, FontParam.LEGEND, null), HorizontalAlignment.LEFT, skinParam); final Rose rose = new Rose(); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNoteOpale.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNoteOpale.java index 27b3d9e3b..26fe74505 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNoteOpale.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNoteOpale.java @@ -218,7 +218,7 @@ public class FtileWithNoteOpale extends AbstractFtile implements Stencil, Stylea final Point2D pp2 = new Point2D.Double(-suppSpace, dimNote.getHeight() / 2); opale.setOpale(strategy, pp1, pp2); } - if (swimlaneNote == null || intoSw == swimlaneNote) { + if (ug instanceof UGraphicInterceptorOneSwimlane == false || swimlaneNote == null || intoSw == swimlaneNote) { opale.drawU(ug.apply(getTranslateForOpale(ug))); } ug.apply(getTranslate(stringBounder)).draw(tile); diff --git a/src/net/sourceforge/plantuml/bpm/BpmDiagram.java b/src/net/sourceforge/plantuml/bpm/BpmDiagram.java index 7ecf1d131..baee43741 100644 --- a/src/net/sourceforge/plantuml/bpm/BpmDiagram.java +++ b/src/net/sourceforge/plantuml/bpm/BpmDiagram.java @@ -92,8 +92,9 @@ public class BpmDiagram extends UmlDiagram { margin1 = 10; margin2 = 10; } - final ImageBuilder imageBuilder = ImageBuilder.buildD(getSkinParam(), ClockwiseTopRightBottomLeft.margin1margin2((double) margin1, (double) margin2), getAnimation(), fileFormatOption.isWithMetadata() ? getMetadata() : null, - getWarningOrError(), dpiFactor); + final ImageBuilder imageBuilder = ImageBuilder.buildD(getSkinParam(), + ClockwiseTopRightBottomLeft.margin1margin2(margin1, margin2), getAnimation(), + fileFormatOption.isWithMetadata() ? getMetadata() : null, getWarningOrError(), dpiFactor); imageBuilder.setUDrawable(getUDrawable()); return imageBuilder.writeImageTOBEMOVED(fileFormatOption, seed(), os); diff --git a/src/net/sourceforge/plantuml/bpm/BpmDiagramFactory.java b/src/net/sourceforge/plantuml/bpm/BpmDiagramFactory.java index 4144b8826..53373b871 100644 --- a/src/net/sourceforge/plantuml/bpm/BpmDiagramFactory.java +++ b/src/net/sourceforge/plantuml/bpm/BpmDiagramFactory.java @@ -40,10 +40,10 @@ import java.util.List; import net.sourceforge.plantuml.AbstractPSystem; import net.sourceforge.plantuml.command.Command; -import net.sourceforge.plantuml.command.UmlDiagramFactory; +import net.sourceforge.plantuml.command.PSystemCommandFactory; import net.sourceforge.plantuml.core.DiagramType; -public class BpmDiagramFactory extends UmlDiagramFactory { +public class BpmDiagramFactory extends PSystemCommandFactory { public BpmDiagramFactory(DiagramType type) { super(DiagramType.BPM); diff --git a/src/net/sourceforge/plantuml/classdiagram/ClassDiagram.java b/src/net/sourceforge/plantuml/classdiagram/ClassDiagram.java index 5fcaba017..570f6da17 100644 --- a/src/net/sourceforge/plantuml/classdiagram/ClassDiagram.java +++ b/src/net/sourceforge/plantuml/classdiagram/ClassDiagram.java @@ -208,10 +208,10 @@ public class ClassDiagram extends AbstractClassOrObjectDiagram { final int margin2; if (SkinParam.USE_STYLES()) { margin1 = SkinParam.zeroMargin(0); - margin2 = SkinParam.zeroMargin(10); + margin2 = SkinParam.zeroMargin(0); } else { margin1 = 0; - margin2 = 10; + margin2 = 0; } final ImageBuilder imageBuilder = ImageBuilder.buildD(getSkinParam(), ClockwiseTopRightBottomLeft.margin1margin2(margin1, margin2), null, null, null, 1); diff --git a/src/net/sourceforge/plantuml/classdiagram/ClassDiagramFactory.java b/src/net/sourceforge/plantuml/classdiagram/ClassDiagramFactory.java index 486522aba..279d66bc2 100644 --- a/src/net/sourceforge/plantuml/classdiagram/ClassDiagramFactory.java +++ b/src/net/sourceforge/plantuml/classdiagram/ClassDiagramFactory.java @@ -65,7 +65,7 @@ import net.sourceforge.plantuml.command.CommandPackage; import net.sourceforge.plantuml.command.CommandPackageEmpty; import net.sourceforge.plantuml.command.CommandPage; import net.sourceforge.plantuml.command.CommandRankDir; -import net.sourceforge.plantuml.command.UmlDiagramFactory; +import net.sourceforge.plantuml.command.PSystemCommandFactory; import net.sourceforge.plantuml.command.note.CommandConstraintOnLinks; import net.sourceforge.plantuml.command.note.CommandFactoryNote; import net.sourceforge.plantuml.command.note.CommandFactoryNoteOnEntity; @@ -80,7 +80,7 @@ import net.sourceforge.plantuml.objectdiagram.command.CommandCreateEntityObject; import net.sourceforge.plantuml.objectdiagram.command.CommandCreateEntityObjectMultilines; import net.sourceforge.plantuml.objectdiagram.command.CommandCreateMap; -public class ClassDiagramFactory extends UmlDiagramFactory { +public class ClassDiagramFactory extends PSystemCommandFactory { private final ISkinSimple skinParam; diff --git a/src/net/sourceforge/plantuml/command/CommandFooter.java b/src/net/sourceforge/plantuml/command/CommandFooter.java index aa20585d1..cbf5720ce 100644 --- a/src/net/sourceforge/plantuml/command/CommandFooter.java +++ b/src/net/sourceforge/plantuml/command/CommandFooter.java @@ -39,7 +39,6 @@ import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.TitledDiagram; -import net.sourceforge.plantuml.UmlDiagram; import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; @@ -72,13 +71,11 @@ public class CommandFooter extends SingleLineCommand2 { final String align = arg.get("POSITION", 0); HorizontalAlignment ha = HorizontalAlignment.fromString(align, HorizontalAlignment.CENTER); if (SkinParam.USE_STYLES() && align == null) { - ha = FontParam.FOOTER.getStyleDefinition(null) - .getMergedStyle(((UmlDiagram) diagram).getSkinParam().getCurrentStyleBuilder()) + ha = FontParam.FOOTER.getStyleDefinition(null).getMergedStyle(diagram.getCurrentStyleBuilder()) .getHorizontalAlignment(); } diagram.getFooter().putDisplay(Display.getWithNewlines(arg.get("LABEL", 0)), ha); - return CommandExecutionResult.ok(); } } diff --git a/src/net/sourceforge/plantuml/command/CommandHeader.java b/src/net/sourceforge/plantuml/command/CommandHeader.java index 64ed2fe62..0894bcab7 100644 --- a/src/net/sourceforge/plantuml/command/CommandHeader.java +++ b/src/net/sourceforge/plantuml/command/CommandHeader.java @@ -39,7 +39,6 @@ import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.TitledDiagram; -import net.sourceforge.plantuml.UmlDiagram; import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; @@ -74,8 +73,7 @@ public class CommandHeader extends SingleLineCommand2 { final String align = arg.get("POSITION", 0); HorizontalAlignment ha = HorizontalAlignment.fromString(align, HorizontalAlignment.RIGHT); if (SkinParam.USE_STYLES() && align == null) { - ha = FontParam.HEADER.getStyleDefinition(null) - .getMergedStyle(((UmlDiagram) diagram).getSkinParam().getCurrentStyleBuilder()) + ha = FontParam.HEADER.getStyleDefinition(null).getMergedStyle(diagram.getCurrentStyleBuilder()) .getHorizontalAlignment(); } diagram.getHeader().putDisplay(Display.getWithNewlines(arg.get("LABEL", 0)), ha); diff --git a/src/net/sourceforge/plantuml/command/CommandPragma.java b/src/net/sourceforge/plantuml/command/CommandPragma.java index 260772c09..e1491b980 100644 --- a/src/net/sourceforge/plantuml/command/CommandPragma.java +++ b/src/net/sourceforge/plantuml/command/CommandPragma.java @@ -37,7 +37,7 @@ package net.sourceforge.plantuml.command; import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.StringUtils; -import net.sourceforge.plantuml.UmlDiagram; +import net.sourceforge.plantuml.TitledDiagram; import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; @@ -45,7 +45,7 @@ import net.sourceforge.plantuml.command.regex.RegexOptional; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.dot.GraphvizUtils; -public class CommandPragma extends SingleLineCommand2 { +public class CommandPragma extends SingleLineCommand2 { public CommandPragma() { super(getRegexConcat()); @@ -64,7 +64,7 @@ public class CommandPragma extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(UmlDiagram system, LineLocation location, RegexResult arg) { + protected CommandExecutionResult executeArg(TitledDiagram system, LineLocation location, RegexResult arg) { final String name = StringUtils.goLowerCase(arg.get("NAME", 0)); final String value = arg.get("VALUE", 0); system.getPragma().define(name, value); diff --git a/src/net/sourceforge/plantuml/command/CommandSkinParam.java b/src/net/sourceforge/plantuml/command/CommandSkinParam.java index addbcc238..52060fd96 100644 --- a/src/net/sourceforge/plantuml/command/CommandSkinParam.java +++ b/src/net/sourceforge/plantuml/command/CommandSkinParam.java @@ -36,13 +36,13 @@ package net.sourceforge.plantuml.command; import net.sourceforge.plantuml.LineLocation; -import net.sourceforge.plantuml.UmlDiagram; +import net.sourceforge.plantuml.TitledDiagram; 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 class CommandSkinParam extends SingleLineCommand2 { +public class CommandSkinParam extends SingleLineCommand2 { public CommandSkinParam() { super(getRegexConcat()); @@ -58,7 +58,7 @@ public class CommandSkinParam extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(UmlDiagram diagram, LineLocation location, RegexResult arg) { + protected CommandExecutionResult executeArg(TitledDiagram diagram, LineLocation location, RegexResult arg) { // arg.get(0).endsWith("locked"); diagram.setParam(arg.get("NAME", 0), arg.get("VALUE", 0)); return CommandExecutionResult.ok(); diff --git a/src/net/sourceforge/plantuml/command/CommandSkinParamMultilines.java b/src/net/sourceforge/plantuml/command/CommandSkinParamMultilines.java index 53746101d..ef034bb74 100644 --- a/src/net/sourceforge/plantuml/command/CommandSkinParamMultilines.java +++ b/src/net/sourceforge/plantuml/command/CommandSkinParamMultilines.java @@ -36,11 +36,11 @@ package net.sourceforge.plantuml.command; import net.sourceforge.plantuml.StringUtils; -import net.sourceforge.plantuml.UmlDiagram; +import net.sourceforge.plantuml.TitledDiagram; import net.sourceforge.plantuml.command.regex.Matcher2; import net.sourceforge.plantuml.command.regex.MyPattern; -public class CommandSkinParamMultilines extends CommandMultilinesBracket { +public class CommandSkinParamMultilines extends CommandMultilinesBracket { public CommandSkinParamMultilines() { super("(?i)^skinparam[%s]*(?:[%s]+([\\w.]*(?:\\<\\<.*\\>\\>)?[\\w.]*))?[%s]*\\{$"); @@ -60,7 +60,7 @@ public class CommandSkinParamMultilines extends CommandMultilinesBracket { +public class CommandSpriteFile extends SingleLineCommand2 { public CommandSpriteFile() { super(getRegexConcat()); @@ -73,7 +73,7 @@ public class CommandSpriteFile extends SingleLineCommand2 { } @Override - protected CommandExecutionResult executeArg(UmlDiagram system, LineLocation location, RegexResult arg) { + protected CommandExecutionResult executeArg(TitledDiagram system, LineLocation location, RegexResult arg) { final String src = arg.get("FILE", 0); final Sprite sprite; try { diff --git a/src/net/sourceforge/plantuml/command/UmlDiagramFactory.java b/src/net/sourceforge/plantuml/command/PSystemCommandFactory.java similarity index 98% rename from src/net/sourceforge/plantuml/command/UmlDiagramFactory.java rename to src/net/sourceforge/plantuml/command/PSystemCommandFactory.java index 4fb89d33d..801c1658c 100644 --- a/src/net/sourceforge/plantuml/command/UmlDiagramFactory.java +++ b/src/net/sourceforge/plantuml/command/PSystemCommandFactory.java @@ -59,15 +59,15 @@ import net.sourceforge.plantuml.style.CommandStyleMultilinesCSS; import net.sourceforge.plantuml.utils.StartUtils; import net.sourceforge.plantuml.version.IteratorCounter2; -public abstract class UmlDiagramFactory extends PSystemAbstractFactory { +public abstract class PSystemCommandFactory extends PSystemAbstractFactory { private List cmds; - protected UmlDiagramFactory() { + protected PSystemCommandFactory() { this(DiagramType.UML); } - protected UmlDiagramFactory(DiagramType type) { + protected PSystemCommandFactory(DiagramType type) { super(type); } diff --git a/src/net/sourceforge/plantuml/command/SkinLoader.java b/src/net/sourceforge/plantuml/command/SkinLoader.java index 4bba6aee9..ae341ee93 100644 --- a/src/net/sourceforge/plantuml/command/SkinLoader.java +++ b/src/net/sourceforge/plantuml/command/SkinLoader.java @@ -39,7 +39,7 @@ import java.util.ArrayList; import java.util.List; import net.sourceforge.plantuml.StringLocated; -import net.sourceforge.plantuml.UmlDiagram; +import net.sourceforge.plantuml.TitledDiagram; import net.sourceforge.plantuml.command.regex.Matcher2; import net.sourceforge.plantuml.command.regex.MyPattern; import net.sourceforge.plantuml.command.regex.Pattern2; @@ -50,9 +50,9 @@ public class SkinLoader { .cmpile("^([\\w.]*(?:\\<\\<.*\\>\\>)?[\\w.]*)[%s]+(?:(\\{)|(.*))$|^\\}?$"); final private List context = new ArrayList(); - final private UmlDiagram diagram; + final private TitledDiagram diagram; - public SkinLoader(UmlDiagram diagram) { + public SkinLoader(TitledDiagram diagram) { this.diagram = diagram; } diff --git a/src/net/sourceforge/plantuml/compositediagram/CompositeDiagramFactory.java b/src/net/sourceforge/plantuml/compositediagram/CompositeDiagramFactory.java index 5cf0fd123..7b855debf 100644 --- a/src/net/sourceforge/plantuml/compositediagram/CompositeDiagramFactory.java +++ b/src/net/sourceforge/plantuml/compositediagram/CompositeDiagramFactory.java @@ -40,13 +40,13 @@ import java.util.List; import net.sourceforge.plantuml.ISkinSimple; import net.sourceforge.plantuml.command.Command; -import net.sourceforge.plantuml.command.UmlDiagramFactory; +import net.sourceforge.plantuml.command.PSystemCommandFactory; import net.sourceforge.plantuml.compositediagram.command.CommandCreateBlock; import net.sourceforge.plantuml.compositediagram.command.CommandCreatePackageBlock; import net.sourceforge.plantuml.compositediagram.command.CommandEndPackageBlock; import net.sourceforge.plantuml.compositediagram.command.CommandLinkBlock; -public class CompositeDiagramFactory extends UmlDiagramFactory { +public class CompositeDiagramFactory extends PSystemCommandFactory { private final ISkinSimple skinParam; diff --git a/src/net/sourceforge/plantuml/creole/Parser.java b/src/net/sourceforge/plantuml/creole/Parser.java index 469b85195..0876c115f 100644 --- a/src/net/sourceforge/plantuml/creole/Parser.java +++ b/src/net/sourceforge/plantuml/creole/Parser.java @@ -58,8 +58,15 @@ public class Parser { return new CreoleParser(fontConfiguration, horizontalAlignment, skinParam, creoleMode, stereotype); } + public static boolean isCodeStart(String line) { + return line.equals(""); + } + + public static boolean isCodeEnd(String line) { + return line.equals(""); + } + public static boolean isTreeStart(String line) { - // return false; return line.startsWith("|_"); } diff --git a/src/net/sourceforge/plantuml/creole/legacy/CreoleParser.java b/src/net/sourceforge/plantuml/creole/legacy/CreoleParser.java index 8ead08824..28c62c8ec 100644 --- a/src/net/sourceforge/plantuml/creole/legacy/CreoleParser.java +++ b/src/net/sourceforge/plantuml/creole/legacy/CreoleParser.java @@ -75,6 +75,16 @@ public class CreoleParser implements SheetBuilder { private Stripe createStripe(String line, CreoleContext context, Stripe lastStripe, FontConfiguration fontConfiguration) { + if (lastStripe instanceof StripeCode) { + final StripeCode code = (StripeCode) lastStripe; + if (code.isTerminated()) { + lastStripe = null; + } else { + final boolean terminated = code.addAndCheckTermination(line); + return null; + } + } + if (lastStripe instanceof StripeTable && isTableLine(line)) { final StripeTable table = (StripeTable) lastStripe; table.analyzeAndAddLine(line); @@ -87,6 +97,8 @@ public class CreoleParser implements SheetBuilder { return new StripeTable(fontConfiguration, skinParam, line); } else if (Parser.isTreeStart(line)) { return new StripeTree(fontConfiguration, skinParam, line); + } else if (Parser.isCodeStart(line)) { + return new StripeCode(fontConfiguration.changeFamily(Parser.MONOSPACED), skinParam, line); } return new CreoleStripeSimpleParser(line, context, fontConfiguration, skinParam, creoleMode) .createStripe(context); diff --git a/src/net/sourceforge/plantuml/creole/legacy/StripeCode.java b/src/net/sourceforge/plantuml/creole/legacy/StripeCode.java new file mode 100644 index 000000000..40dc04563 --- /dev/null +++ b/src/net/sourceforge/plantuml/creole/legacy/StripeCode.java @@ -0,0 +1,116 @@ +/* ======================================================================== + * 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.creole.legacy; + +import java.awt.geom.Dimension2D; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import net.sourceforge.plantuml.Dimension2DDouble; +import net.sourceforge.plantuml.ISkinSimple; +import net.sourceforge.plantuml.creole.Parser; +import net.sourceforge.plantuml.creole.Stripe; +import net.sourceforge.plantuml.creole.atom.Atom; +import net.sourceforge.plantuml.graphic.FontConfiguration; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UText; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public class StripeCode implements Stripe, Atom { + + final private FontConfiguration fontConfiguration; + private final List raw = new ArrayList(); + + private boolean terminated; + + public StripeCode(FontConfiguration fontConfiguration, ISkinSimple skinParam, String line) { +// this.skinParam = skinParam; + this.fontConfiguration = fontConfiguration; + } + + public List getAtoms() { + return Collections.singletonList(this); + } + + public Atom getLHeader() { + return null; + } + + public boolean addAndCheckTermination(String line) { + if (Parser.isCodeEnd(line)) { + this.terminated = true; + return true; + } + this.raw.add(line); + return false; + } + + public final boolean isTerminated() { + return terminated; + } + + public Dimension2D calculateDimension(StringBounder stringBounder) { + double width = 0; + double height = 0; + for (String s : raw) { + final Dimension2D dim = stringBounder.calculateDimension(fontConfiguration.getFont(), s); + width = Math.max(width, dim.getWidth()); + height += dim.getHeight(); + } + return new Dimension2DDouble(width, height); + } + + public double getStartingAltitude(StringBounder stringBounder) { + return 0; + } + + public void drawU(UGraphic ug) { + double y = 0; + for (String s : raw) { + final UText shape = new UText(s, fontConfiguration); + final Dimension2D dim = ug.getStringBounder().calculateDimension(fontConfiguration.getFont(), s); + y += dim.getHeight(); + ug.apply(UTranslate.dy(y - shape.getDescent())).draw(shape); + } + } + + public List splitInTwo(StringBounder stringBounder, double width) { + throw new UnsupportedOperationException(); + } + +} diff --git a/src/net/sourceforge/plantuml/cucadiagram/BodierImpl.java b/src/net/sourceforge/plantuml/cucadiagram/BodierImpl.java index dfa77c68b..221021b0c 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/BodierImpl.java +++ b/src/net/sourceforge/plantuml/cucadiagram/BodierImpl.java @@ -209,7 +209,9 @@ public class BodierImpl implements Bodier { if (showFields == false) { return new TextBlockLineBefore(TextBlockUtils.empty(0, 0)); } - return fields.asBlockMemberImpl(); + // return fields.asBlockMemberImpl(); + return new BodyEnhanced(rawBodyWithoutHidden(), fontParam, skinParam, manageModifier, stereotype, leaf, + SName.objectDiagram); } if (type.isLikeClass() == false) { throw new UnsupportedOperationException(); diff --git a/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced.java b/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced.java index c08bce958..f08bc7335 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced.java +++ b/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced.java @@ -164,9 +164,11 @@ public class BodyEnhanced extends AbstractTextBlock implements TextBlock, WithPo for (ListIterator it = rawBody.listIterator(); it.hasNext();) { final CharSequence s2 = it.next(); if (s2 instanceof EmbeddedDiagram) { - if (members.size() > 0) { + if (members.size() > 0 || separator != 0) { blocks.add(decorate(stringBounder, new MethodsOrFieldsArea(members, fontParam, skinParam, align, stereotype, entity, diagramType), separator, title)); + separator = 0; + title = null; members = new ArrayList(); } blocks.add(((EmbeddedDiagram) s2).asDraw(skinParam)); @@ -183,6 +185,8 @@ public class BodyEnhanced extends AbstractTextBlock implements TextBlock, WithPo blocks.add(decorate(stringBounder, new MethodsOrFieldsArea(members, fontParam, skinParam, align, stereotype, entity, diagramType), separator, title)); } + separator = 0; + title = null; members = new ArrayList(); final List allTree = buildAllTree(s, it); final TextBlock bloc = Display.create(allTree).create7(fontParam.getFontConfiguration(skinParam), diff --git a/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced2.java b/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced2.java index 4199147c4..adfa7f8ab 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced2.java +++ b/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced2.java @@ -40,6 +40,7 @@ import java.util.ArrayList; import java.util.List; import net.sourceforge.plantuml.FontParam; +import net.sourceforge.plantuml.Guillemet; import net.sourceforge.plantuml.ISkinSimple; import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.StringUtils; @@ -55,21 +56,23 @@ import net.sourceforge.plantuml.ugraphic.UGraphic; public class BodyEnhanced2 extends AbstractTextBlock implements TextBlock { - private TextBlock area2; + private TextBlock area; private final FontConfiguration titleConfig; - private final Display rawBody2; + private final Display rawBody; private final ISkinSimple spriteContainer; private final HorizontalAlignment align; private final LineBreakStrategy lineBreakStrategy; + private final double minClassWidth; // private final List urls = new ArrayList(); public BodyEnhanced2(Display rawBody, FontParam fontParam, ISkinSimple spriteContainer, HorizontalAlignment align, - FontConfiguration titleConfig, LineBreakStrategy lineBreakStrategy) { - this.rawBody2 = rawBody; + FontConfiguration titleConfig, LineBreakStrategy lineBreakStrategy, double minClassWidth) { + this.rawBody = rawBody; this.lineBreakStrategy = lineBreakStrategy; this.spriteContainer = spriteContainer; + this.minClassWidth = minClassWidth; this.titleConfig = titleConfig; this.align = align; @@ -93,38 +96,45 @@ public class BodyEnhanced2 extends AbstractTextBlock implements TextBlock { } private TextBlock getArea(StringBounder stringBounder) { - if (area2 != null) { - return area2; + if (area != null) { + return area; } // urls.clear(); final List blocks = new ArrayList(); char separator = 0; TextBlock title = null; - Display members2 = Display.empty(); - for (CharSequence s : rawBody2) { + Display display = Display.empty(); + for (CharSequence s : rawBody) { if (isBlockSeparator(s.toString())) { - blocks.add(decorate(stringBounder, getTextBlock(members2, stringBounder), separator, title)); + blocks.add(decorate(stringBounder, getTextBlock(display, stringBounder), separator, title)); separator = s.charAt(0); title = getTitle(s.toString(), spriteContainer); - members2 = Display.empty(); + display = Display.empty(); } else { - members2 = members2.add(s); + if (s instanceof String) { + s = Guillemet.GUILLEMET.manageGuillemet(s.toString()); + } + display = display.add(s); } } - blocks.add(decorate(stringBounder, getTextBlock(members2, stringBounder), separator, title)); + blocks.add(decorate(stringBounder, getTextBlock(display, stringBounder), separator, title)); if (blocks.size() == 1) { - this.area2 = blocks.get(0); + this.area = blocks.get(0); } else { - this.area2 = new TextBlockVertical2(blocks, align); + this.area = new TextBlockVertical2(blocks, align); } - return area2; + if (minClassWidth > 0) { + this.area = TextBlockUtils.withMinWidth(this.area, minClassWidth, align); + } + + return area; } - private TextBlock getTextBlock(Display members2, StringBounder stringBounder) { - final TextBlock result = members2.create9(titleConfig, align, spriteContainer, lineBreakStrategy); + private TextBlock getTextBlock(Display display, StringBounder stringBounder) { + final TextBlock result = display.create9(titleConfig, align, spriteContainer, lineBreakStrategy); return result; } diff --git a/src/net/sourceforge/plantuml/cucadiagram/Display.java b/src/net/sourceforge/plantuml/cucadiagram/Display.java index e5487b5b9..d26955344 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/Display.java +++ b/src/net/sourceforge/plantuml/cucadiagram/Display.java @@ -237,9 +237,10 @@ public class Display implements Iterable { final Iterator it = strings.iterator(); while (it.hasNext()) { CharSequence s = it.next(); - if (s != null && StringUtils.trin(s.toString()).equals("{{")) { + final String type = EmbeddedDiagram.getEmbeddedType(s); + if (type != null) { final List other = new ArrayList(); - other.add("@startuml"); + other.add("@start" + type); while (it.hasNext()) { CharSequence s2 = it.next(); if (s2 != null && StringUtils.trin(s2.toString()).equals("}}")) { @@ -247,7 +248,7 @@ public class Display implements Iterable { } other.add(s2); } - other.add("@enduml"); + other.add("@end" + type); s = new EmbeddedDiagram(Display.create(other)); } result.add(s); diff --git a/src/net/sourceforge/plantuml/cucadiagram/LinkArrow.java b/src/net/sourceforge/plantuml/cucadiagram/LinkArrow.java index cccf70219..f67a8b677 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/LinkArrow.java +++ b/src/net/sourceforge/plantuml/cucadiagram/LinkArrow.java @@ -61,6 +61,10 @@ public enum LinkArrow { public Direction getArrowDirection() { return guide.getArrowDirection().getInv(); } + + public double getArrowDirection2() { + return Math.PI + guide.getArrowDirection2(); + } }; } diff --git a/src/net/sourceforge/plantuml/cucadiagram/Member.java b/src/net/sourceforge/plantuml/cucadiagram/Member.java index 427502ad9..83f08b444 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/Member.java +++ b/src/net/sourceforge/plantuml/cucadiagram/Member.java @@ -101,8 +101,8 @@ public class Member { this.visibilityModifier = null; this.abstractModifier = false; tmpDisplay = StringUtils.trin(tmpDisplay); - this.display = tmpDisplay.length() == 0 ? " " : Guillemet.GUILLEMET.manageGuillemet(StringUtils - .trin(tmpDisplay)); + this.display = tmpDisplay.length() == 0 ? " " + : Guillemet.GUILLEMET.manageGuillemet(StringUtils.trin(tmpDisplay)); } } @@ -114,7 +114,8 @@ public class Member { } private String getDisplayWithoutVisibilityChar() { - // assert display.length() == 0 || VisibilityModifier.isVisibilityCharacter(display.charAt(0)) == false; + // assert display.length() == 0 || + // VisibilityModifier.isVisibilityCharacter(display.charAt(0)) == false; return display; } @@ -193,13 +194,13 @@ public class Member { } public static boolean isMethod(String s) { - // s = UrlBuilder.purgeUrl(s); - if (s.contains("{method}")) { + final String purged = s.replaceAll(UrlBuilder.getRegexp(), ""); + if (purged.contains("{method}")) { return true; } - if (s.contains("{field}")) { + if (purged.contains("{field}")) { return false; } - return s.contains("(") || s.contains(")"); + return purged.contains("(") || purged.contains(")"); } } diff --git a/src/net/sourceforge/plantuml/cucadiagram/MethodsOrFieldsArea.java b/src/net/sourceforge/plantuml/cucadiagram/MethodsOrFieldsArea.java index 3318b6548..608f6ac5d 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/MethodsOrFieldsArea.java +++ b/src/net/sourceforge/plantuml/cucadiagram/MethodsOrFieldsArea.java @@ -61,7 +61,6 @@ import net.sourceforge.plantuml.skin.VisibilityModifier; 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; import net.sourceforge.plantuml.svek.Ports; import net.sourceforge.plantuml.svek.WithPorts; import net.sourceforge.plantuml.ugraphic.PlacementStrategy; diff --git a/src/net/sourceforge/plantuml/cute/PSystemCute.java b/src/net/sourceforge/plantuml/cute/PSystemCute.java index 6a737491c..bf4b2d261 100644 --- a/src/net/sourceforge/plantuml/cute/PSystemCute.java +++ b/src/net/sourceforge/plantuml/cute/PSystemCute.java @@ -97,8 +97,8 @@ public class PSystemCute extends AbstractPSystem { margin1 = 10; margin2 = 10; } - final ImageBuilder builder = ImageBuilder.buildB(new ColorMapperIdentity(), false, ClockwiseTopRightBottomLeft.margin1margin2((double) margin1, (double) margin2), - null, null, null, 1.0, null); + final ImageBuilder builder = ImageBuilder.buildB(new ColorMapperIdentity(), false, + ClockwiseTopRightBottomLeft.margin1margin2(margin1, margin2), null, null, null, 1.0, null); builder.setUDrawable(root); return builder.writeImageTOBEMOVED(fileFormat, seed, os); } diff --git a/src/net/sourceforge/plantuml/dedication/2.png b/src/net/sourceforge/plantuml/dedication/2.png new file mode 100644 index 000000000..c37934ee8 Binary files /dev/null and b/src/net/sourceforge/plantuml/dedication/2.png differ diff --git a/src/net/sourceforge/plantuml/dedication/Dedications.java b/src/net/sourceforge/plantuml/dedication/Dedications.java index edb3139f6..f800c39a1 100644 --- a/src/net/sourceforge/plantuml/dedication/Dedications.java +++ b/src/net/sourceforge/plantuml/dedication/Dedications.java @@ -35,7 +35,6 @@ */ package net.sourceforge.plantuml.dedication; -import java.io.IOException; import java.io.InputStream; import java.util.HashMap; import java.util.Map; @@ -54,6 +53,7 @@ public class Dedications { addNormal("Boundaries allow discipline to create true strength", "boundaries"); addCrypted("0", "pOhci6rKgPXw32AeYXhOpSY0suoauHq5VUSwFqHLHsLYgSO6WaJ7BW5vtHBAoU6ePbcW7d8Flx99MWjPSKQTDm00"); addCrypted("1", "LTxN3hdnhSJ515qcA7IQ841axt4GXfUd3n2wgNirYCdLnyX2360Gv1OEOnJ1-gwFzRW5B3HAqLBkR6Ge0WW_Z000"); + addCrypted("2", "lZqLduj4j1yRqSfAvkhbqVpqK8diklatiFeenDUXSdna9bKYQTzdS264YfUBScUVDYCp2Vcq04updoN98RwxE000"); } private static void addNormal(String sentence, String name) { @@ -82,13 +82,13 @@ public class Dedications { if (signature.equals(ent.getKey())) { return dedication; } - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } finally { try { if (is != null) is.close(); - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } } diff --git a/src/net/sourceforge/plantuml/descdiagram/DescriptionDiagramFactory.java b/src/net/sourceforge/plantuml/descdiagram/DescriptionDiagramFactory.java index 098e63917..fab486126 100644 --- a/src/net/sourceforge/plantuml/descdiagram/DescriptionDiagramFactory.java +++ b/src/net/sourceforge/plantuml/descdiagram/DescriptionDiagramFactory.java @@ -48,7 +48,7 @@ import net.sourceforge.plantuml.command.CommandEndPackage; import net.sourceforge.plantuml.command.CommandFootboxIgnored; import net.sourceforge.plantuml.command.CommandPage; import net.sourceforge.plantuml.command.CommandRankDir; -import net.sourceforge.plantuml.command.UmlDiagramFactory; +import net.sourceforge.plantuml.command.PSystemCommandFactory; import net.sourceforge.plantuml.command.note.CommandFactoryNote; import net.sourceforge.plantuml.command.note.CommandFactoryNoteOnEntity; import net.sourceforge.plantuml.command.note.CommandFactoryNoteOnLink; @@ -62,7 +62,7 @@ import net.sourceforge.plantuml.descdiagram.command.CommandLinkElement; import net.sourceforge.plantuml.descdiagram.command.CommandNewpage; import net.sourceforge.plantuml.descdiagram.command.CommandPackageWithUSymbol; -public class DescriptionDiagramFactory extends UmlDiagramFactory { +public class DescriptionDiagramFactory extends PSystemCommandFactory { private final ISkinSimple skinParam; diff --git a/src/net/sourceforge/plantuml/descdiagram/command/CommandNewpage.java b/src/net/sourceforge/plantuml/descdiagram/command/CommandNewpage.java index ae7aa9439..59d7de2f9 100644 --- a/src/net/sourceforge/plantuml/descdiagram/command/CommandNewpage.java +++ b/src/net/sourceforge/plantuml/descdiagram/command/CommandNewpage.java @@ -40,7 +40,7 @@ import net.sourceforge.plantuml.NewpagedDiagram; import net.sourceforge.plantuml.UmlDiagram; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; -import net.sourceforge.plantuml.command.UmlDiagramFactory; +import net.sourceforge.plantuml.command.PSystemCommandFactory; import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; @@ -48,9 +48,9 @@ import net.sourceforge.plantuml.command.regex.RegexResult; public class CommandNewpage extends SingleLineCommand2 { - private final UmlDiagramFactory factory; + private final PSystemCommandFactory factory; - public CommandNewpage(UmlDiagramFactory factory) { + public CommandNewpage(PSystemCommandFactory factory) { super(getRegexConcat()); this.factory = factory; } diff --git a/src/net/sourceforge/plantuml/descdiagram/command/StringWithArrow.java b/src/net/sourceforge/plantuml/descdiagram/command/StringWithArrow.java index 1d72b7459..6e2e08003 100644 --- a/src/net/sourceforge/plantuml/descdiagram/command/StringWithArrow.java +++ b/src/net/sourceforge/plantuml/descdiagram/command/StringWithArrow.java @@ -35,7 +35,6 @@ */ package net.sourceforge.plantuml.descdiagram.command; -import net.sourceforge.plantuml.Direction; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.cucadiagram.Display; @@ -43,10 +42,9 @@ import net.sourceforge.plantuml.cucadiagram.LinkArrow; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.graphic.TextBlockArrow; +import net.sourceforge.plantuml.graphic.TextBlockArrow2; import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.graphic.VerticalAlignment; -import net.sourceforge.plantuml.svek.DirectionalTextBlock; import net.sourceforge.plantuml.svek.GuideLine; public class StringWithArrow { @@ -104,18 +102,17 @@ public class StringWithArrow { } static public TextBlock addMagicArrow(TextBlock label, GuideLine guide, FontConfiguration font) { - final TextBlock arrowRight = new TextBlockArrow(Direction.RIGHT, font); - final TextBlock arrowLeft = new TextBlockArrow(Direction.LEFT, font); - final TextBlock arrowUp = new TextBlockArrow(Direction.UP, font); - final TextBlock arrowDown = new TextBlockArrow(Direction.DOWN, font); - final TextBlock right = TextBlockUtils.mergeLR(label, arrowRight, VerticalAlignment.CENTER); - final TextBlock left = TextBlockUtils.mergeLR(arrowLeft, label, VerticalAlignment.CENTER); - final TextBlock up = TextBlockUtils.mergeTB(arrowUp, label, HorizontalAlignment.CENTER); - final TextBlock down = TextBlockUtils.mergeTB(label, arrowDown, HorizontalAlignment.CENTER); - return new DirectionalTextBlock(guide, right, left, up, down); + final TextBlock arrow = new TextBlockArrow2(guide, font); + return TextBlockUtils.mergeLR(arrow, label, VerticalAlignment.CENTER); } static private TextBlock addMagicArrow2(TextBlock label, GuideLine guide, FontConfiguration font) { + final TextBlock arrow = new TextBlockArrow2(guide, font); + return TextBlockUtils.mergeLR(arrow, label, VerticalAlignment.CENTER); + } + + /* + static public TextBlock addMagicArrow2(TextBlock label, GuideLine guide, FontConfiguration font) { final TextBlock arrowRight = new TextBlockArrow(Direction.RIGHT, font); final TextBlock arrowLeft = new TextBlockArrow(Direction.LEFT, font); final TextBlock arrowUp = new TextBlockArrow(Direction.UP, font); @@ -127,6 +124,27 @@ public class StringWithArrow { return new DirectionalTextBlock(guide, right, left, up, down); } + static public TextBlock addMagicArrow(TextBlock label, GuideLine guide, FontConfiguration font) { + final TextBlock arrow = new TextBlockArrow2(guide, font); + return TextBlockUtils.mergeLR(label, arrow, VerticalAlignment.CENTER); + } + + public static TextBlock addSeveralMagicArrows(Display label, GuideLine guide, FontConfiguration font, + HorizontalAlignment alignment, ISkinParam skinParam) { + TextBlock result = TextBlockUtils.EMPTY_TEXT_BLOCK; + for (CharSequence cs : label) { + StringWithArrow tmp = new StringWithArrow(cs.toString()); + TextBlock block = tmp.getDisplay().create9(font, alignment, skinParam, skinParam.maxMessageSize()); + if (tmp.getLinkArrow() != LinkArrow.NONE_OR_SEVERAL) { + block = StringWithArrow.addMagicArrow(block, tmp.getLinkArrow().mute(guide), font); + } + result = TextBlockUtils.mergeTB(result, block, alignment); + } + return result; + } + + */ + public static TextBlock addSeveralMagicArrows(Display label, GuideLine guide, FontConfiguration font, HorizontalAlignment alignment, ISkinParam skinParam) { TextBlock result = TextBlockUtils.EMPTY_TEXT_BLOCK; diff --git a/src/net/sourceforge/plantuml/donors/PSystemDonors.java b/src/net/sourceforge/plantuml/donors/PSystemDonors.java index 474608ec2..4241a0ad5 100644 --- a/src/net/sourceforge/plantuml/donors/PSystemDonors.java +++ b/src/net/sourceforge/plantuml/donors/PSystemDonors.java @@ -74,26 +74,27 @@ public class PSystemDonors extends AbstractPSystem { private static final int COLS = 6; private static final int FREE_LINES = 6; - public static final String DONORS = "6peC02mFU3XMJbc44wzsvvsjcZxOY0eHBCyJYiF08fxk1iGVuDxfSR-H_YAwqhrlcX5jsPhYF6DGBGXw" - + "F3NN3DlSsmFFQdxwAlbcQdI5gJ0auIuaB6JOJp-fCgG4ptAz-MSKutlkfA5Pjis5a1j8l_2-CpRFJkEB" - + "LuycQ2FmOs1V_TyrhQoxLrLXI9TLZQbHfoiSmeZ84VuVTPkwHMsSJ6qQFQ1JELTmKvsAj0LlUgALD1Da" - + "NEiu7ysQLCL4caZnr4OA7ZcPeRqcgy-JAttG-QL-W3QjtJN4SmOKnqhfqVsrqVxp1DklaFYGS8POi5bW" - + "3fKSrYSeVcswqN6A8A5r5jdOwYktF371u8SM-kOFPNB5UqXabY55n-KA57WynW39dDIk2MU7RWPKrOCj" - + "-ZK8rULnu-uQX-MfP3OQRW4B5mjg1se8yZ_e4pwjx_p8v5o78fQGfqdSbcr0_LdoFkvDHT_CgqaWV6qV" - + "cXdYAbEr7jBOyZFMgqQ7t3LarUXVnXg57C6ytysbOFxH0laHwA4-4KdyBFkDXGI4QqlzqBlEJITN5k6K" - + "3YaLw_HRR7aj-K9NOB5nqQmEbkYxyUjoKoBOGbScbw47MbMvhVE9aj9G_x_8ew7hl-2QAhLxXsWzq-Oy" - + "-x_hbcQ6uW0Txs8MT2qW44RJgg_OG0I7XIuFkGcG0wXk9hVYPdaHU-G716yk6NI5ZPGEYEUNa9iSGfY6" - + "BjrSeWAOFQNKHSTjWOSwdO9kHPLyUfcxFgP9oxHjO-O-QOFdxGPZ5CTqGld4_JONk8LXbLeq9qzh7s6M" - + "u74-JlEg-npCg-Ysj_2UzY4qhsJ0hp1dHAJITELvfdt4tTGHc4LRy58NszrjSF3GNGjEiMW5CzgqGvQ0" - + "oOLarDAlA3ur6FuEGZPXhqr5li3MS9qQmin8WzTBarjgSaJ7QJhBiR4DmAilNh4hA9mYHDlIajcwbZ0r" - + "O_KaLCZlb4zWgQmBInisjhiApyGy2l9mtYEhB_LZIN5RGFMnJ92N5a9V8KKHjZV8m5X9ptAROFjJEnRK" - + "RJrouPX3yMqJRJTkY64AJ4_XVf4W4gCJIOLUOf8eu7j-_4gzQAw3ZU_iQSKuI5f88g2As7Bg1yPAG_L8" - + "JMEzHlzVQ-rksVdpxtLaarE7t_Cp1T5pK3J-ZHJ0KKuWWwU1hoPVbBoLi98LoY33bMkLdWOI5kp2ErTH" - + "3vOPrJjHB3Uh5gsYVQYgt-xACN0sDgouoASeLjzYbBMxUb05RT_rncAHW-0_H9L9cLoD9gin4Zg3BCxT" - + "sFTAnJmtDe45lMCoWRPVVNQQnat6dAz8AWsF0Fb-Zqn9MWyjhAbfNJuHs2ITwtiBsvH8wt_1Y7v1hPFZ" - + "KJsq3t9texj0mxS-f7P19XWkaayKoBTpJZHmyus2kgWMoiJIZXbsZc25_iP_H1GIZjd61u8iSx6iTaSE" - + "sKBsyTue-a1HKsWW6ulr-anYePJZWHH9mPhPCfv7sg1jsDSJW5CKpFVtDeHB9ffVa5dxUlP6CfT-xiKP" - + "H3gSdqrYqvIj3Jcm7scvREkEtFw-I8UT-k_4ZlETZwXR1n740Z7I25wF2UlcncxL5ZuZpwqQ7CTbEWuc" + "FuoJc9O0"; + public static final String DONORS = "6rqC0AmEU9ELAujmujswMQFgmN9H8OBbUK9n65Z4qzs0-0FSEptkDz9VH5UwzqqpeYsRKvfd5TM2eE5u" + + "ctROvizU27Dcl0Zkp17qVFW0KHArbH-f8zkv1sAfPFqs5TCdNSg6oFYiDq8te7FUXlUTiNbs6b-yUZH1" + + "6u4V0_lg_owThRjNLM6MxbQj4JNgT8KRcxdN_r45TKJ1Jb2Wfn_JgHogmw6A2koem6DV-LKtpaUD9gjY" + + "GYbIdBKH0gSOpD2Gazudo2zzKFYXta2RrkeQOha7AOwPqgFhiTgEVGV3BvJuaB05Nv1PO4vAEKmNA7vk" + + "kg5Wuu53tIfcOqjAZZpHG-255lBc3qLIqdg8PvN1HS6kX1GuFOm2aj6eGHFE3Xm6LDo3BJeqSDNbVcDk" + + "deVbgNWc3JU2XPq5jO0QWlmFUa6dzvMtJEvpKzWIyZQ9LxULg3zBtaxThEWRNPe4pDVMKpEjNrdAraCQ" + + "Mzxd_AkpaxnfoChP7qOVgHn1lH_caZ6_jK3j27JVcB0alhzqFrX8GAYsr9lUTQu-ARC89sH8gLWdRsBB" + + "Q_4_TFaw6n39sS4IVjVzN6wA1rleogIOz8PMSQfrFf2J6khlBtarTRuBhYaMkpUFUw9JeI7wVzSjpGp5" + + "0Jemn2pe6e4XpAPLUx6127OBdPta9a0se7oPtFANvPVe8ouaU7E9e2jif3I2Fx-4tENWGdIawveKAu3P" + + "KqgzA3YSOA5SXw2RKIMPNkQkds7IicpPcBbFsk1vgy4O-J6TK5oOR-O2zp0iLelc-6xjGwmIFCh7IJvr" + + "d_sv2d1fuJtYnhL-oO2VOSw8I9dfYdrFkyNSrM6OHPrpLHVTm-tavg6R5vp5ebdCQ9E7B0QDKycegOy8" + + "RMWm_Es7RCnUgxDQ1vl3TKfmCoCDhYzDRgZ94GMRvIp7p1O0bx7un2w_S0d16fQQoDQrXCWHgySXGtud" + + "sWIMohJGD63dS5VWcR17GHpEUs3LgRvDoSu5L17J14bfmOmPakLXQu4Cp3NfcMa3x7PfnuAopKzs774e" + + "lcsYhSOD4Ko1wIRS1mv4OhWXAT5BJ181-FvSdb8lFDV1ndVrj68S92qaCL15k3lb1wMdxhg5fh5Uel_7" + + "MZiiEt_-lOviScgqUzrD43q7SG68y08DvNuXWhS1xuCDtO03Ld3HamXNhbfw6aXOi9dMsKNTlyoetF5Y" + + "kJ6vQENveOf_kYX7WTE-8SL5Cba--n8bhHtgGUMtVVCNYuiS1FyILOPaSbKRhsGaT09cSMx7hZCLTTj8" + + "0nQCZie4wfvwUZvCuoLZhbSeDGqF0_bkYmm9UWyjhAbfULm8h9RE_jx2DiJJ-xzWH3-_rl7pgXuQJc9q" + + "VRj0mxScf75E91WkaWy4oDLpJZHevfi4yg9QA0DBssROMOCLyXlu4Lv8E68R7mXocelcR0Too1Qo3un6" + + "rWVoQa83MLYiq6iI2wKS3wH82kQSBUDPf9sq0Njw1D0e2iR_xoq85myqFoEpzddrHZ2NPkx6CuXqk7y6" + + "YKsdRFN8XlrGvhBDAt8xnY8STkA_uplEjp-YRfv440d4K1AyLXFIuSOErIOsGyzr6jp7PMxSJ7u1bwAT" + + "9ndO6eejo58s0oMU1000"; /* * Special thanks to our sponsors and donors: diff --git a/src/net/sourceforge/plantuml/flowdiagram/FlowDiagramFactory.java b/src/net/sourceforge/plantuml/flowdiagram/FlowDiagramFactory.java index 8c88e37e7..4e18b8def 100644 --- a/src/net/sourceforge/plantuml/flowdiagram/FlowDiagramFactory.java +++ b/src/net/sourceforge/plantuml/flowdiagram/FlowDiagramFactory.java @@ -39,10 +39,10 @@ import java.util.ArrayList; import java.util.List; import net.sourceforge.plantuml.command.Command; -import net.sourceforge.plantuml.command.UmlDiagramFactory; +import net.sourceforge.plantuml.command.PSystemCommandFactory; import net.sourceforge.plantuml.core.DiagramType; -public class FlowDiagramFactory extends UmlDiagramFactory { +public class FlowDiagramFactory extends PSystemCommandFactory { public FlowDiagramFactory() { super(DiagramType.FLOW); diff --git a/src/net/sourceforge/plantuml/graphic/QuoteUtils.java b/src/net/sourceforge/plantuml/graphic/QuoteUtils.java index 53a618831..eb51f24c7 100644 --- a/src/net/sourceforge/plantuml/graphic/QuoteUtils.java +++ b/src/net/sourceforge/plantuml/graphic/QuoteUtils.java @@ -262,7 +262,7 @@ public class QuoteUtils { "Gur terngrfg rarzl bs xabjyrqtr vf abg vtabenapr; vg vf gur vyyhfvba bs xabjyrqtr", "N fghql sbhaq gung vtabenag crbcyr ner zber yvxryl gb oryvrir gurl'er oevyyvnag", "Dh'rfg-pr dh'ba n qbap n fbaare pbzzr pn, pr zngva ?", "Ernyvgl vf gur bayl guvat gung'f erny", - "V jbhyq tvir zlfrys na N+", "Lbh rire unir frpbaq gubhtugf nobhg fbzrguvat ?", + "V jbhyq tvir zlfrys na N+ ba fbsgjner qrirybczrag", "Lbh rire unir frpbaq gubhtugf nobhg fbzrguvat ?", "V oryvrir vg'f n ebhtu fvghngvba bire gurer", "Whfg fb lbh xabj, V tbg zl yvprafr fhfcraqrq", "Gunax lbh sbe pubbfvat Bprnavp Nveyvarf", "4-8-15-16-23-42", "...naq gnk phgf. Gung'yy fubj gurz znegvnaf.", @@ -276,7 +276,7 @@ public class QuoteUtils { "Vs lbh ner abg rzoneenffrq ol gur svefg irefvba bs lbhe cebqhpg, lbh'ir ynhapurq gbb yngr", "Zvfgnxrf znqr zl fhpprff: V znxr ehoore renfre", "Ovt Oebgure vf Jngpuvat Lbh.", "Ab bar'f gnyxvat nobhg yrnivat gur fvatyr znexrg", "...rnfvrfg oht gb svk va uhzna uvfgbel", - "Arire nggevohgr gb znyvpr jung pna or rkcynvarq ol fghcvqvgl"); + "Arire nggevohgr gb znyvpr jung pna or rkcynvarq ol fghcvqvgl", "Guvf oht nssrpgf iveghnyyl abobql"); private QuoteUtils() { } diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockArrow.java b/src/net/sourceforge/plantuml/graphic/TextBlockArrow.java index 3ff14b3d2..5d53c3fa9 100644 --- a/src/net/sourceforge/plantuml/graphic/TextBlockArrow.java +++ b/src/net/sourceforge/plantuml/graphic/TextBlockArrow.java @@ -69,11 +69,7 @@ public class TextBlockArrow extends AbstractTextBlock implements TextBlock { triSize--; } final UPolygon triangle = getTriangle(triSize); - if (arrow == Direction.RIGHT || arrow == Direction.LEFT) { - ug.apply(new UTranslate(2, (size - triSize) - 2)).draw(triangle); - } else { - ug.apply(new UTranslate(2, (size - triSize) - 2)).draw(triangle); - } + ug.apply(new UTranslate(2, (size - triSize) - 2)).draw(triangle); } private UPolygon getTriangle(int triSize) { diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockArrow2.java b/src/net/sourceforge/plantuml/graphic/TextBlockArrow2.java new file mode 100644 index 000000000..00a594138 --- /dev/null +++ b/src/net/sourceforge/plantuml/graphic/TextBlockArrow2.java @@ -0,0 +1,91 @@ +/* ======================================================================== + * 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.graphic; + +import java.awt.geom.Dimension2D; +import java.awt.geom.Point2D; + +import net.sourceforge.plantuml.Dimension2DDouble; +import net.sourceforge.plantuml.svek.GuideLine; +import net.sourceforge.plantuml.ugraphic.UEllipse; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UPolygon; +import net.sourceforge.plantuml.ugraphic.UTranslate; +import net.sourceforge.plantuml.ugraphic.color.HColor; + +public class TextBlockArrow2 extends AbstractTextBlock implements TextBlock { + + private final double size; + private final GuideLine angle; + private final HColor color; + + public TextBlockArrow2(GuideLine angle, FontConfiguration fontConfiguration) { + if (angle == null) { + throw new IllegalArgumentException(); + } + this.angle = angle; + this.size = fontConfiguration.getFont().getSize2D(); + this.color = fontConfiguration.getColor(); + + } + + public void drawU(UGraphic ug) { + // final double triSize = size * .80; + final int triSize = (int) (size * .80); + + ug = ug.apply(color); + ug = ug.apply(color.bg()); + ug = ug.apply(new UTranslate(triSize / 2, size / 2)); + + final UPolygon triangle = new UPolygon(); + final double beta = Math.PI * 4 / 5; + triangle.addPoint(getPoint(triSize / 2, angle.getArrowDirection2())); + triangle.addPoint(getPoint(triSize / 2, angle.getArrowDirection2() + beta)); + triangle.addPoint(getPoint(triSize / 2, angle.getArrowDirection2() - beta)); + triangle.addPoint(getPoint(triSize / 2, angle.getArrowDirection2())); + ug.draw(triangle); + } + + private Point2D getPoint(double len, double alpha) { + final double dx = len * Math.sin(alpha); + final double dy = len * Math.cos(alpha); + return new Point2D.Double(dx, dy); + } + + public Dimension2D calculateDimension(StringBounder stringBounder) { + return new Dimension2DDouble(size, size); + } +} \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockMarged.java b/src/net/sourceforge/plantuml/graphic/TextBlockMarged.java index ad154e8bd..0ff11b94c 100644 --- a/src/net/sourceforge/plantuml/graphic/TextBlockMarged.java +++ b/src/net/sourceforge/plantuml/graphic/TextBlockMarged.java @@ -42,6 +42,7 @@ import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft; import net.sourceforge.plantuml.svek.Ports; import net.sourceforge.plantuml.svek.WithPorts; +import net.sourceforge.plantuml.ugraphic.UEmpty; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; @@ -75,8 +76,14 @@ class TextBlockMarged extends AbstractTextBlock implements TextBlock, WithPorts } public void drawU(UGraphic ug) { - final UTranslate translate = new UTranslate(left, top); - textBlock.drawU(ug.apply(translate)); + // ug.apply(HColorUtils.BLUE).draw(new + // URectangle(calculateDimension(ug.getStringBounder()))); + final Dimension2D dim = calculateDimension(ug.getStringBounder()); + if (dim.getWidth() > 0) { + ug.draw(new UEmpty(dim)); + final UTranslate translate = new UTranslate(left, top); + textBlock.drawU(ug.apply(translate)); + } } @Override diff --git a/src/net/sourceforge/plantuml/graphic/USymbol.java b/src/net/sourceforge/plantuml/graphic/USymbol.java index 05ff6ef7a..c20a1c65e 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbol.java +++ b/src/net/sourceforge/plantuml/graphic/USymbol.java @@ -83,8 +83,8 @@ public abstract class USymbol { public final static USymbol COMPONENT2 = record("COMPONENT2", SkinParameter.COMPONENT2, new USymbolComponent2()); public final static USymbol BOUNDARY = record("BOUNDARY", SkinParameter.BOUNDARY, new USymbolBoundary()); public final static USymbol ENTITY_DOMAIN = record("ENTITY_DOMAIN", SkinParameter.ENTITY, - new USymbolEntityDomain(2)); - public final static USymbol CONTROL = record("CONTROL", SkinParameter.CONTROL, new USymbolControl(2)); + new USymbolEntityDomain()); + public final static USymbol CONTROL = record("CONTROL", SkinParameter.CONTROL, new USymbolControl()); public final static USymbol INTERFACE = record("INTERFACE", SkinParameter.INTERFACE, new USymbolInterface()); public final static USymbol QUEUE = record("QUEUE", SkinParameter.QUEUE, new USymbolQueue()); public final static USymbol STACK = record("STACK", SkinParameter.STACK, new USymbolStack()); diff --git a/src/net/sourceforge/plantuml/graphic/USymbolActor.java b/src/net/sourceforge/plantuml/graphic/USymbolActor.java index 6f6d3431e..320b08281 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolActor.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolActor.java @@ -36,7 +36,6 @@ package net.sourceforge.plantuml.graphic; import net.sourceforge.plantuml.skin.ActorStyle; -import net.sourceforge.plantuml.ugraphic.UStroke; class USymbolActor extends USymbolSimpleAbstract { @@ -54,8 +53,8 @@ class USymbolActor extends USymbolSimpleAbstract { @Override protected TextBlock getDrawing(SymbolContext symbolContext) { - final double deltaShadow = symbolContext.isShadowing() ? 4.0 : 0.0; - final SymbolContext tmp = symbolContext.withDeltaShadow(deltaShadow).withStroke(new UStroke(2)); + // final double deltaShadow = symbolContext.isShadowing() ? 4.0 : 0.0; + // final SymbolContext tmp = symbolContext.withDeltaShadow(deltaShadow).withStroke(new UStroke(2)); return actorStyle.getTextBlock(symbolContext); } diff --git a/src/net/sourceforge/plantuml/graphic/USymbolBoundary.java b/src/net/sourceforge/plantuml/graphic/USymbolBoundary.java index c67922a62..b28cf0ec6 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolBoundary.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolBoundary.java @@ -36,7 +36,6 @@ package net.sourceforge.plantuml.graphic; import net.sourceforge.plantuml.svek.Boundary; -import net.sourceforge.plantuml.ugraphic.UStroke; class USymbolBoundary extends USymbolSimpleAbstract { @@ -45,10 +44,8 @@ class USymbolBoundary extends USymbolSimpleAbstract { return SkinParameter.BOUNDARY; } - @Override - protected TextBlock getDrawing(final SymbolContext symbolContext) { - return new Boundary(symbolContext.withDeltaShadow(symbolContext.isShadowing() ? 4.0 : 0.0).withStroke( - new UStroke(2))); + protected TextBlock getDrawing(SymbolContext symbolContext) { + return new Boundary(symbolContext.withDeltaShadow(symbolContext.isShadowing() ? 4.0 : 0.0)); } } \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/graphic/USymbolControl.java b/src/net/sourceforge/plantuml/graphic/USymbolControl.java index 6ea7865b1..0bdaa45ac 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolControl.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolControl.java @@ -36,26 +36,17 @@ package net.sourceforge.plantuml.graphic; import net.sourceforge.plantuml.svek.Control; -import net.sourceforge.plantuml.ugraphic.UStroke; class USymbolControl extends USymbolSimpleAbstract { - private final double thickness; - - public USymbolControl(double thickness) { - this.thickness = thickness; - } - @Override public SkinParameter getSkinParameter() { return SkinParameter.CONTROL; } - @Override protected TextBlock getDrawing(final SymbolContext symbolContext) { - return new Control(symbolContext.withDeltaShadow(symbolContext.isShadowing() ? 4.0 : 0.0).withStroke( - new UStroke(thickness))); + return new Control(symbolContext.withDeltaShadow(symbolContext.isShadowing() ? 4.0 : 0.0)); } } \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/graphic/USymbolEntityDomain.java b/src/net/sourceforge/plantuml/graphic/USymbolEntityDomain.java index d7b6ddb89..52f34df5b 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolEntityDomain.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolEntityDomain.java @@ -36,25 +36,16 @@ package net.sourceforge.plantuml.graphic; import net.sourceforge.plantuml.svek.EntityDomain; -import net.sourceforge.plantuml.ugraphic.UStroke; class USymbolEntityDomain extends USymbolSimpleAbstract { - private final double thickness; - - public USymbolEntityDomain(double thickness) { - this.thickness = thickness; - } - @Override public SkinParameter getSkinParameter() { return SkinParameter.ENTITY; } - @Override protected TextBlock getDrawing(final SymbolContext symbolContext) { - return new EntityDomain(symbolContext.withDeltaShadow(symbolContext.isShadowing() ? 4.0 : 0.0).withStroke( - new UStroke(thickness))); + return new EntityDomain(symbolContext.withDeltaShadow(symbolContext.isShadowing() ? 4.0 : 0.0)); } } \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/graphic/USymbolSimpleAbstract.java b/src/net/sourceforge/plantuml/graphic/USymbolSimpleAbstract.java index a7665cc90..704545a4b 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolSimpleAbstract.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolSimpleAbstract.java @@ -39,6 +39,8 @@ import java.awt.geom.Dimension2D; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UGraphicStencil; +import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UTranslate; abstract class USymbolSimpleAbstract extends USymbol { @@ -66,9 +68,9 @@ abstract class USymbolSimpleAbstract extends USymbol { final double labelY = dimStickMan.getHeight() + dimStereo.getHeight(); // Actor bug? - // final UGraphic ug2 = UGraphicStencil.create(ug, getRectangleStencil(dimLabel), new UStroke()); - // label.drawU(ug2.apply(new UTranslate(labelX, labelY))); - label.drawU(ug.apply(new UTranslate(labelX, labelY))); + final UGraphic ug2 = UGraphicStencil.create(ug, getRectangleStencil(dimLabel), new UStroke()); + label.drawU(ug2.apply(new UTranslate(labelX, labelY))); + // label.drawU(ug.apply(new UTranslate(labelX, labelY))); final double stereoX = (dimTotal.getWidth() - dimStereo.getWidth()) / 2; stereotype.drawU(ug.apply(UTranslate.dx(stereoX))); diff --git a/src/net/sourceforge/plantuml/help/HelpFactory.java b/src/net/sourceforge/plantuml/help/HelpFactory.java index e10a418f0..da0220382 100644 --- a/src/net/sourceforge/plantuml/help/HelpFactory.java +++ b/src/net/sourceforge/plantuml/help/HelpFactory.java @@ -39,9 +39,9 @@ import java.util.ArrayList; import java.util.List; import net.sourceforge.plantuml.command.Command; -import net.sourceforge.plantuml.command.UmlDiagramFactory; +import net.sourceforge.plantuml.command.PSystemCommandFactory; -public class HelpFactory extends UmlDiagramFactory { +public class HelpFactory extends PSystemCommandFactory { @Override public Help createEmptyDiagram() { diff --git a/src/net/sourceforge/plantuml/jdot/CucaDiagramFileMakerJDot.java b/src/net/sourceforge/plantuml/jdot/CucaDiagramFileMakerJDot.java index 271020af6..47aef8780 100644 --- a/src/net/sourceforge/plantuml/jdot/CucaDiagramFileMakerJDot.java +++ b/src/net/sourceforge/plantuml/jdot/CucaDiagramFileMakerJDot.java @@ -423,10 +423,10 @@ public class CucaDiagramFileMakerJDot implements CucaDiagramFileMaker { final int margin2; if (SkinParam.USE_STYLES()) { margin1 = SkinParam.zeroMargin(0); - margin2 = SkinParam.zeroMargin(10); + margin2 = SkinParam.zeroMargin(0); } else { margin1 = 0; - margin2 = 10; + margin2 = 0; } final ImageBuilder imageBuilder = ImageBuilder.buildD(diagram.getSkinParam(), ClockwiseTopRightBottomLeft.margin1margin2(margin1, margin2), diagram.getAnimation(), diff --git a/src/net/sourceforge/plantuml/jungle/PSystemTree.java b/src/net/sourceforge/plantuml/jungle/PSystemTree.java index 78589201c..0fc8eac64 100644 --- a/src/net/sourceforge/plantuml/jungle/PSystemTree.java +++ b/src/net/sourceforge/plantuml/jungle/PSystemTree.java @@ -76,8 +76,8 @@ public class PSystemTree extends AbstractPSystem { margin1 = 5; margin2 = 5; } - final ImageBuilder builder = ImageBuilder.buildB(new ColorMapperIdentity(), false, ClockwiseTopRightBottomLeft.margin1margin2((double) margin1, (double) margin2), - null, null, null, 1.0, HColorUtils.WHITE); + final ImageBuilder builder = ImageBuilder.buildB(new ColorMapperIdentity(), false, + ClockwiseTopRightBottomLeft.margin1margin2(margin1, margin2), null, null, null, 1.0, HColorUtils.WHITE); if (rendering == Rendering.NEEDLE) { final UDrawable tmp = Needle.getNeedle(root, 200, 0, 60); final LimitFinder limitFinder = new LimitFinder(fileFormat.getDefaultStringBounder(), true); diff --git a/src/net/sourceforge/plantuml/jungle/PSystemTreeFactory.java b/src/net/sourceforge/plantuml/jungle/PSystemTreeFactory.java index a461fb2fa..8cb3e7653 100644 --- a/src/net/sourceforge/plantuml/jungle/PSystemTreeFactory.java +++ b/src/net/sourceforge/plantuml/jungle/PSystemTreeFactory.java @@ -38,10 +38,10 @@ import java.util.ArrayList; import java.util.List; import net.sourceforge.plantuml.command.Command; -import net.sourceforge.plantuml.command.UmlDiagramFactory; +import net.sourceforge.plantuml.command.PSystemCommandFactory; import net.sourceforge.plantuml.core.DiagramType; -public class PSystemTreeFactory extends UmlDiagramFactory { +public class PSystemTreeFactory extends PSystemCommandFactory { public PSystemTreeFactory(DiagramType type) { super(type); diff --git a/src/net/sourceforge/plantuml/mindmap/MindMapDiagramFactory.java b/src/net/sourceforge/plantuml/mindmap/MindMapDiagramFactory.java index 90ccea6bd..fc42ac378 100644 --- a/src/net/sourceforge/plantuml/mindmap/MindMapDiagramFactory.java +++ b/src/net/sourceforge/plantuml/mindmap/MindMapDiagramFactory.java @@ -39,10 +39,10 @@ import java.util.ArrayList; import java.util.List; import net.sourceforge.plantuml.command.Command; -import net.sourceforge.plantuml.command.UmlDiagramFactory; +import net.sourceforge.plantuml.command.PSystemCommandFactory; import net.sourceforge.plantuml.core.DiagramType; -public class MindMapDiagramFactory extends UmlDiagramFactory { +public class MindMapDiagramFactory extends PSystemCommandFactory { public MindMapDiagramFactory() { super(DiagramType.MINDMAP); diff --git a/src/net/sourceforge/plantuml/nwdiag/NwDiagramFactory.java b/src/net/sourceforge/plantuml/nwdiag/NwDiagramFactory.java index 603c9cfae..1544ded57 100644 --- a/src/net/sourceforge/plantuml/nwdiag/NwDiagramFactory.java +++ b/src/net/sourceforge/plantuml/nwdiag/NwDiagramFactory.java @@ -39,9 +39,9 @@ import java.util.ArrayList; import java.util.List; import net.sourceforge.plantuml.command.Command; -import net.sourceforge.plantuml.command.UmlDiagramFactory; +import net.sourceforge.plantuml.command.PSystemCommandFactory; -public class NwDiagramFactory extends UmlDiagramFactory { +public class NwDiagramFactory extends PSystemCommandFactory { @Override public NwDiagram createEmptyDiagram() { diff --git a/src/net/sourceforge/plantuml/openiconic/PSystemOpenIconic.java b/src/net/sourceforge/plantuml/openiconic/PSystemOpenIconic.java index 4217d922a..e55921f21 100644 --- a/src/net/sourceforge/plantuml/openiconic/PSystemOpenIconic.java +++ b/src/net/sourceforge/plantuml/openiconic/PSystemOpenIconic.java @@ -73,8 +73,8 @@ public class PSystemOpenIconic extends AbstractPSystem { margin1 = 5; margin2 = 5; } - final ImageBuilder imageBuilder = ImageBuilder.buildB(new ColorMapperIdentity(), false, ClockwiseTopRightBottomLeft.margin1margin2((double) margin1, (double) margin2), - null, null, null, 1.0, null); + final ImageBuilder imageBuilder = ImageBuilder.buildB(new ColorMapperIdentity(), false, + ClockwiseTopRightBottomLeft.margin1margin2(margin1, margin2), null, null, null, 1.0, null); imageBuilder.setUDrawable(icon.asTextBlock(HColorUtils.BLACK, factor)); return imageBuilder.writeImageTOBEMOVED(fileFormat, seed, os); @@ -89,7 +89,8 @@ public class PSystemOpenIconic extends AbstractPSystem { // private GraphicStrings getGraphicStrings() throws IOException { // final UFont font = new UFont("SansSerif", Font.PLAIN, 12); - // final GraphicStrings result = new GraphicStrings(strings, font, HtmlColorUtils.BLACK, HtmlColorUtils.WHITE, + // final GraphicStrings result = new GraphicStrings(strings, font, + // HtmlColorUtils.BLACK, HtmlColorUtils.WHITE, // UAntiAliasing.ANTI_ALIASING_ON); // return result; // } diff --git a/src/net/sourceforge/plantuml/postit/PostIdDiagramFactory.java b/src/net/sourceforge/plantuml/postit/PostIdDiagramFactory.java index 6bd057fc6..b2b17951e 100644 --- a/src/net/sourceforge/plantuml/postit/PostIdDiagramFactory.java +++ b/src/net/sourceforge/plantuml/postit/PostIdDiagramFactory.java @@ -39,9 +39,9 @@ import java.util.ArrayList; import java.util.List; import net.sourceforge.plantuml.command.Command; -import net.sourceforge.plantuml.command.UmlDiagramFactory; +import net.sourceforge.plantuml.command.PSystemCommandFactory; -public class PostIdDiagramFactory extends UmlDiagramFactory { +public class PostIdDiagramFactory extends PSystemCommandFactory { @Override protected List createCommands() { diff --git a/src/net/sourceforge/plantuml/project/ConstantPlan.java b/src/net/sourceforge/plantuml/project/ConstantPlan.java index 2e7326264..0b9928633 100644 --- a/src/net/sourceforge/plantuml/project/ConstantPlan.java +++ b/src/net/sourceforge/plantuml/project/ConstantPlan.java @@ -35,7 +35,7 @@ */ package net.sourceforge.plantuml.project; -import net.sourceforge.plantuml.project.time.Wink; +import net.sourceforge.plantuml.project.time.Day; public class ConstantPlan implements LoadPlanable { @@ -53,7 +53,7 @@ public class ConstantPlan implements LoadPlanable { return new ConstantPlan(load); } - public int getLoadAt(Wink instant) { + public int getLoadAt(Day instant) { return loadPerInstant; } diff --git a/src/net/sourceforge/plantuml/project/DaysAsDates.java b/src/net/sourceforge/plantuml/project/DaysAsDates.java index 9fb8f7560..f52c70455 100644 --- a/src/net/sourceforge/plantuml/project/DaysAsDates.java +++ b/src/net/sourceforge/plantuml/project/DaysAsDates.java @@ -56,7 +56,7 @@ public class DaysAsDates implements Iterable { if (gantt.isOpen(tmp)) { count--; } - tmp = tmp.next(); + tmp = tmp.increment(); } this.date2 = tmp; } @@ -75,7 +75,7 @@ public class DaysAsDates implements Iterable { public Day next() { final Day result = current; - current = current.next(); + current = current.increment(); return result; } diff --git a/src/net/sourceforge/plantuml/project/GanttArrow.java b/src/net/sourceforge/plantuml/project/GanttArrow.java index bd8ac7303..fda24c1c9 100644 --- a/src/net/sourceforge/plantuml/project/GanttArrow.java +++ b/src/net/sourceforge/plantuml/project/GanttArrow.java @@ -98,13 +98,13 @@ public class GanttArrow implements UDrawable { ug = ug.apply(color.bg()).apply(color).apply(style.getStroke3(new UStroke(1.5))); double x1 = getX(source.withDelta(0), atStart); - double y1 = getSource().getY(atStart).getValue(); + double y1 = getSource().getY(atStart); final double x2 = getX(dest, atEnd.getInv()); - final double y2 = getDestination().getY(atEnd).getValue(); + final double y2 = getDestination().getY(atEnd); if (atStart == Direction.DOWN && y2 < y1) { - y1 = getSource().getY(atStart.getInv()).getValue(); + y1 = getSource().getY(atStart.getInv()); } if (this.atStart == Direction.DOWN && this.atEnd == Direction.RIGHT) { @@ -115,7 +115,7 @@ public class GanttArrow implements UDrawable { drawLine(ug, x1, y1, x1, y2, x2, y2); } else { x1 = getX(source.withDelta(0), Direction.RIGHT); - y1 = getSource().getY(Direction.RIGHT).getValue(); + y1 = getSource().getY(Direction.RIGHT); drawLine(ug, x1, y1, x1 + 6, y1, x1 + 6, y1 + 8, x2 - 8, y1 + 8, x2 - 8, y2, x2, y2); } } else if (this.atStart == Direction.RIGHT && this.atEnd == Direction.LEFT) { diff --git a/src/net/sourceforge/plantuml/project/GanttConstraint.java b/src/net/sourceforge/plantuml/project/GanttConstraint.java index 53fa4cf39..d087ef4c7 100644 --- a/src/net/sourceforge/plantuml/project/GanttConstraint.java +++ b/src/net/sourceforge/plantuml/project/GanttConstraint.java @@ -40,7 +40,7 @@ import net.sourceforge.plantuml.cucadiagram.LinkType; import net.sourceforge.plantuml.cucadiagram.WithLinkType; import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.project.core.TaskInstant; -import net.sourceforge.plantuml.project.time.Wink; +import net.sourceforge.plantuml.project.time.Day; import net.sourceforge.plantuml.project.timescale.TimeScale; import net.sourceforge.plantuml.ugraphic.color.HColor; @@ -72,7 +72,7 @@ public class GanttConstraint extends WithLinkType { return new GanttArrow(timeScale, source, dest, getSpecificColor(), getType(), toTaskDraw); } - public boolean isHidden(Wink min, Wink max) { + public boolean isHidden(Day min, Day max) { if (isHidden(source.getInstantPrecise(), min, max)) { return true; } @@ -82,7 +82,7 @@ public class GanttConstraint extends WithLinkType { return false; } - private boolean isHidden(Wink now, Wink min, Wink max) { + private boolean isHidden(Day now, Day min, Day max) { if (now.compareTo(min) < 0) { return true; } diff --git a/src/net/sourceforge/plantuml/project/GanttDiagram.java b/src/net/sourceforge/plantuml/project/GanttDiagram.java index d4a8a1fc9..7bb89880d 100644 --- a/src/net/sourceforge/plantuml/project/GanttDiagram.java +++ b/src/net/sourceforge/plantuml/project/GanttDiagram.java @@ -57,6 +57,7 @@ import net.sourceforge.plantuml.Scale; import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.TitledDiagram; import net.sourceforge.plantuml.UmlDiagramType; +import net.sourceforge.plantuml.WithSprite; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.ImageData; @@ -85,12 +86,9 @@ import net.sourceforge.plantuml.project.draw.TimeHeaderDaily; import net.sourceforge.plantuml.project.draw.TimeHeaderMonthly; import net.sourceforge.plantuml.project.draw.TimeHeaderSimple; import net.sourceforge.plantuml.project.draw.TimeHeaderWeekly; -import net.sourceforge.plantuml.project.draw.YMovable; import net.sourceforge.plantuml.project.lang.CenterBorderColor; import net.sourceforge.plantuml.project.time.Day; import net.sourceforge.plantuml.project.time.DayOfWeek; -import net.sourceforge.plantuml.project.time.GCalendar; -import net.sourceforge.plantuml.project.time.Wink; import net.sourceforge.plantuml.project.timescale.TimeScale; import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft; import net.sourceforge.plantuml.svek.TextBlockBackcolored; @@ -103,7 +101,7 @@ import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColorSet; import net.sourceforge.plantuml.ugraphic.color.HColorUtils; -public class GanttDiagram extends TitledDiagram implements ToTaskDraw { +public class GanttDiagram extends TitledDiagram implements ToTaskDraw, WithSprite { private final Map tasks = new LinkedHashMap(); private final Map byShortName = new HashMap(); @@ -120,10 +118,10 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw { private PrintScale printScale = PrintScale.DAILY; private Day today; - private GCalendar calendar; + private Day calendar; private double totalHeight; - private Wink min = new Wink(0); - private Wink max; + private Day min = Day.create(0); + private Day max; private Day printStart; private Day printEnd; @@ -213,8 +211,8 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw { if (printStart == null) { initMinMax(); } else { - this.min = calendar.fromDayAsDate(printStart); - this.max = calendar.fromDayAsDate(printEnd); + this.min = printStart; + this.max = printEnd; } final TimeHeader timeHeader; if (calendar == null) { @@ -262,7 +260,7 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw { private void drawTasksRect(UGraphic ug) { for (Task task : tasks.values()) { final TaskDraw draw = draws.get(task); - final UTranslate move = UTranslate.dy(draw.getY().getValue()); + final UTranslate move = UTranslate.dy(draw.getY()); draw.drawU(ug.apply(move)); } } @@ -282,7 +280,7 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw { continue; } final TaskDraw draw = draws.get(task); - final UTranslate move = UTranslate.dy(draw.getY().getValue()); + final UTranslate move = UTranslate.dy(draw.getY()); draw.drawTitle(ug1.apply(move)); } } @@ -297,11 +295,10 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw { public final LoadPlanable getDefaultPlan() { return new LoadPlanable() { - public int getLoadAt(Wink instant) { + public int getLoadAt(Day day) { if (calendar == null) { return 100; } - final Day day = calendar.toDayAsDate((Wink) instant); if (isClosed(day)) { return 0; } @@ -333,7 +330,7 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw { private final Map draws = new LinkedHashMap(); private void initTaskAndResourceDraws(TimeScale timeScale, double headerHeight, StringBounder stringBounder) { - YMovable y = new YMovable(headerHeight); + double y = headerHeight; for (Task task : tasks.values()) { final TaskDraw draw; if (task instanceof TaskSeparator) { @@ -352,30 +349,36 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw { draw.setColorsAndCompletion(tmp.getColors(), tmp.getCompletion(), tmp.getUrl(), tmp.getNote()); } if (task.getRow() == null) { - y = y.add(draw.getHeightTask()); + y += draw.getHeightTask(); } draws.put(task, draw); } - magicPush(stringBounder); - y = lastY(stringBounder); - for (Resource res : resources.values()) { - final ResourceDraw draw = new ResourceDraw(this, res, timeScale, y, min, max); - res.setTaskDraw(draw); - y = y.add(draw.getHeight()); - + while (magicPushOnce(stringBounder)) { + // } - this.totalHeight = y.getValue(); + if (lastY(stringBounder) != 0) { + y = lastY(stringBounder); + for (Resource res : resources.values()) { + final ResourceDraw draw = new ResourceDraw(this, res, timeScale, y, min, max); + res.setTaskDraw(draw); + y += draw.getHeight(); + } + } + this.totalHeight = y; } - private YMovable lastY(StringBounder stringBounder) { + private double lastY(StringBounder stringBounder) { TaskDraw last = null; for (TaskDraw td : draws.values()) { last = td; } - return last.getY().add(last.getHeightMax(stringBounder)); + if (last == null) { + return 0; + } + return last.getY() + last.getHeightMax(stringBounder); } - private boolean magicPush(StringBounder stringBounder) { + private boolean magicPushOnce(StringBounder stringBounder) { final List notes = new ArrayList(); for (TaskDraw td : draws.values()) { final FingerPrint taskPrint = td.getFingerPrint(); @@ -397,29 +400,32 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw { private void pushIncluding(TaskDraw first, double deltaY) { boolean skipping = true; + if (first.getTrueRow() != null) { + first = first.getTrueRow(); + } for (TaskDraw td : draws.values()) { if (td == first) skipping = false; if (skipping) continue; - td.getY().pushMe(deltaY + 1); + td.pushMe(deltaY + 1); } } - private Wink getStart(final TaskImpl tmp) { + private Day getStart(final TaskImpl tmp) { if (printStart == null) { return tmp.getStart(); } - return Wink.max(min, tmp.getStart()); + return Day.max(min, tmp.getStart()); } - private Wink getEnd(final TaskImpl tmp) { + private Day getEnd(final TaskImpl tmp) { if (printStart == null) { return tmp.getEnd(); } - return Wink.min(max, tmp.getEnd()); + return Day.min(max, tmp.getEnd()); } private void initMinMax() { @@ -431,8 +437,8 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw { if (task instanceof TaskSeparator) { continue; } - final Wink start = task.getStart(); - final Wink end = task.getEnd(); + final Day start = task.getStart(); + final Day end = task.getEnd(); // if (min.compareTo(start) > 0) { // min = start; // } @@ -443,15 +449,13 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw { } if (calendar != null) { for (Day d : colorDays.keySet()) { - final Wink instant = calendar.fromDayAsDate(d); - if (instant.compareTo(max) > 0) { - max = instant; + if (d.compareTo(max) > 0) { + max = d; } } for (Day d : nameDays.keySet()) { - final Wink instant = calendar.fromDayAsDate(d); - if (instant.compareTo(max) > 0) { - max = instant; + if (d.compareTo(max) > 0) { + max = d; } } } @@ -547,33 +551,27 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw { } public void setStartingDate(Day start) { - this.calendar = new GCalendar(start); + this.calendar = start; + this.min = start; } public Day getStartingDate() { - if (this.calendar == null) { - return null; - } - return this.calendar.getStartingDate(); + return this.calendar; } public Day getStartingDate(int nday) { if (this.calendar == null) { return null; } - return this.calendar.toDayAsDate(new Wink(nday)); + return this.calendar.addDays(nday); } public int daysInWeek() { return 7 - closedDayOfWeek.size(); } - public Wink convert(Day day) { - return calendar.fromDayAsDate(day); - } - public boolean isOpen(Day day) { - return getDefaultPlan().getLoadAt(convert(day)) > 0; + return getDefaultPlan().getLoadAt(day) > 0; } public void affectResource(Task result, String description) { @@ -593,13 +591,13 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw { public Resource getResource(String resourceName) { Resource resource = resources.get(resourceName); if (resource == null) { - resource = new Resource(resourceName, getDefaultPlan(), calendar); + resource = new Resource(resourceName, getDefaultPlan()); } resources.put(resourceName, resource); return resource; } - public int getLoadForResource(Resource res, Wink i) { + public int getLoadForResource(Resource res, Day i) { int result = 0; for (Task task : tasks.values()) { if (task instanceof TaskSeparator) { @@ -624,7 +622,7 @@ public class GanttDiagram extends TitledDiagram implements ToTaskDraw { end = max(end, ent.getKey()); } if (start != null) { - result = new MomentImpl(convert(start), convert(end)); + result = new MomentImpl(start, end); } } return result; diff --git a/src/net/sourceforge/plantuml/project/GanttDiagramFactory.java b/src/net/sourceforge/plantuml/project/GanttDiagramFactory.java index 1b9c6d2c1..25638c31a 100644 --- a/src/net/sourceforge/plantuml/project/GanttDiagramFactory.java +++ b/src/net/sourceforge/plantuml/project/GanttDiagramFactory.java @@ -42,8 +42,7 @@ import java.util.List; import net.sourceforge.plantuml.command.Command; import net.sourceforge.plantuml.command.CommandNope; -import net.sourceforge.plantuml.command.CommandScale; -import net.sourceforge.plantuml.command.UmlDiagramFactory; +import net.sourceforge.plantuml.command.PSystemCommandFactory; import net.sourceforge.plantuml.core.DiagramType; import net.sourceforge.plantuml.project.command.CommandColorTask; import net.sourceforge.plantuml.project.command.CommandGanttArrow; @@ -69,7 +68,7 @@ import net.sourceforge.plantuml.project.lang.SubjectToday; import net.sourceforge.plantuml.style.CommandStyleImport; import net.sourceforge.plantuml.style.CommandStyleMultilinesCSS; -public class GanttDiagramFactory extends UmlDiagramFactory { +public class GanttDiagramFactory extends PSystemCommandFactory { static private final List subjects() { return Arrays.asList(new SubjectTask(), new SubjectProject(), new SubjectDayOfWeek(), @@ -85,6 +84,7 @@ public class GanttDiagramFactory extends UmlDiagramFactory { protected List createCommands() { final List cmds = new ArrayList(); addTitleCommands(cmds); + addCommonCommands2(cmds); cmds.add(new CommandStyleMultilinesCSS()); cmds.add(new CommandStyleImport()); @@ -101,7 +101,6 @@ public class GanttDiagramFactory extends UmlDiagramFactory { cmds.add(new CommandPrintScale()); cmds.add(new CommandPrintBetween()); - cmds.add(new CommandScale()); cmds.add(new CommandPage()); cmds.add(new CommandNoteBottom()); diff --git a/src/net/sourceforge/plantuml/project/LoadPlanable.java b/src/net/sourceforge/plantuml/project/LoadPlanable.java index 64d004759..50c01f1a1 100644 --- a/src/net/sourceforge/plantuml/project/LoadPlanable.java +++ b/src/net/sourceforge/plantuml/project/LoadPlanable.java @@ -35,9 +35,9 @@ */ package net.sourceforge.plantuml.project; -import net.sourceforge.plantuml.project.time.Wink; +import net.sourceforge.plantuml.project.time.Day; public interface LoadPlanable { - public int getLoadAt(Wink instant); + public int getLoadAt(Day instant); } diff --git a/src/net/sourceforge/plantuml/project/PlanUtils.java b/src/net/sourceforge/plantuml/project/PlanUtils.java index 9ad264ffa..354044747 100644 --- a/src/net/sourceforge/plantuml/project/PlanUtils.java +++ b/src/net/sourceforge/plantuml/project/PlanUtils.java @@ -35,7 +35,7 @@ */ package net.sourceforge.plantuml.project; -import net.sourceforge.plantuml.project.time.Wink; +import net.sourceforge.plantuml.project.time.Day; public class PlanUtils { @@ -45,7 +45,7 @@ public class PlanUtils { public static LoadPlanable minOf(final LoadPlanable p1, final LoadPlanable p2) { return new LoadPlanable() { - public int getLoadAt(Wink instant) { + public int getLoadAt(Day instant) { return Math.min(p1.getLoadAt(instant), p2.getLoadAt(instant)); } }; @@ -53,7 +53,7 @@ public class PlanUtils { public static LoadPlanable multiply(final LoadPlanable p1, final LoadPlanable p2) { return new LoadPlanable() { - public int getLoadAt(Wink instant) { + public int getLoadAt(Day instant) { return p1.getLoadAt(instant) * p2.getLoadAt(instant) / 100; } }; diff --git a/src/net/sourceforge/plantuml/project/Solver.java b/src/net/sourceforge/plantuml/project/Solver.java index a6b7679d1..06d273d85 100644 --- a/src/net/sourceforge/plantuml/project/Solver.java +++ b/src/net/sourceforge/plantuml/project/Solver.java @@ -41,7 +41,7 @@ import java.util.Map; import java.util.Map.Entry; import net.sourceforge.plantuml.project.core.TaskAttribute; -import net.sourceforge.plantuml.project.time.Wink; +import net.sourceforge.plantuml.project.time.Day; public class Solver { @@ -56,8 +56,8 @@ public class Solver { public void setData(TaskAttribute attribute, Value value) { final Value previous = values.remove(attribute); if (previous != null && attribute == TaskAttribute.START) { - final Wink previousInstant = (Wink) previous; - if (previousInstant.compareTo((Wink) value) > 0) { + final Day previousInstant = (Day) previous; + if (previousInstant.compareTo((Day) value) > 0) { value = previous; } } @@ -90,8 +90,8 @@ public class Solver { return result; } - private Wink computeEnd() { - Wink current = (Wink) values.get(TaskAttribute.START); + private Day computeEnd() { + Day current = (Day) values.get(TaskAttribute.START); int fullLoad = ((Load) values.get(TaskAttribute.LOAD)).getFullLoad(); while (fullLoad > 0) { fullLoad -= loadPlanable.getLoadAt(current); @@ -100,13 +100,13 @@ public class Solver { return current.decrement(); } - private Wink computeStart() { - Wink current = (Wink) values.get(TaskAttribute.END); + private Day computeStart() { + Day current = (Day) values.get(TaskAttribute.END); int fullLoad = ((Load) values.get(TaskAttribute.LOAD)).getFullLoad(); while (fullLoad > 0) { fullLoad -= loadPlanable.getLoadAt(current); current = current.decrement(); - if (current.getWink() <= 0) { + if (current.getMillis() <= 0) { return current; } } diff --git a/src/net/sourceforge/plantuml/project/ToTaskDraw.java b/src/net/sourceforge/plantuml/project/ToTaskDraw.java index 18b9c3959..19eed5c1e 100644 --- a/src/net/sourceforge/plantuml/project/ToTaskDraw.java +++ b/src/net/sourceforge/plantuml/project/ToTaskDraw.java @@ -42,4 +42,6 @@ public interface ToTaskDraw { public TaskDraw getTaskDraw(Task task); + public LoadPlanable getDefaultPlan(); + } diff --git a/src/net/sourceforge/plantuml/project/command/CommandGanttArrow.java b/src/net/sourceforge/plantuml/project/command/CommandGanttArrow.java index 409ed7706..671bbb441 100644 --- a/src/net/sourceforge/plantuml/project/command/CommandGanttArrow.java +++ b/src/net/sourceforge/plantuml/project/command/CommandGanttArrow.java @@ -46,8 +46,6 @@ import net.sourceforge.plantuml.descdiagram.command.CommandLinkElement; import net.sourceforge.plantuml.project.GanttConstraint; import net.sourceforge.plantuml.project.GanttDiagram; import net.sourceforge.plantuml.project.core.Task; -import net.sourceforge.plantuml.project.core.TaskAttribute; -import net.sourceforge.plantuml.project.core.TaskInstant; public class CommandGanttArrow extends SingleLineCommand2 { diff --git a/src/net/sourceforge/plantuml/project/core/Moment.java b/src/net/sourceforge/plantuml/project/core/Moment.java index 47ec59be4..503d50f67 100644 --- a/src/net/sourceforge/plantuml/project/core/Moment.java +++ b/src/net/sourceforge/plantuml/project/core/Moment.java @@ -35,12 +35,12 @@ */ package net.sourceforge.plantuml.project.core; -import net.sourceforge.plantuml.project.time.Wink; +import net.sourceforge.plantuml.project.time.Day; public interface Moment { - public Wink getStart(); + public Day getStart(); - public Wink getEnd(); + public Day getEnd(); } diff --git a/src/net/sourceforge/plantuml/project/core/MomentImpl.java b/src/net/sourceforge/plantuml/project/core/MomentImpl.java index 8fe2d00fa..21dcea7da 100644 --- a/src/net/sourceforge/plantuml/project/core/MomentImpl.java +++ b/src/net/sourceforge/plantuml/project/core/MomentImpl.java @@ -35,23 +35,23 @@ */ package net.sourceforge.plantuml.project.core; -import net.sourceforge.plantuml.project.time.Wink; +import net.sourceforge.plantuml.project.time.Day; public class MomentImpl implements Moment { - private final Wink start; - private final Wink end; + private final Day start; + private final Day end; - public MomentImpl(Wink start, Wink end) { + public MomentImpl(Day start, Day end) { this.start = start; this.end = end; } - public Wink getStart() { + public Day getStart() { return start; } - public Wink getEnd() { + public Day getEnd() { return end; } diff --git a/src/net/sourceforge/plantuml/project/core/Resource.java b/src/net/sourceforge/plantuml/project/core/Resource.java index e6234e07e..7dd1c32fa 100644 --- a/src/net/sourceforge/plantuml/project/core/Resource.java +++ b/src/net/sourceforge/plantuml/project/core/Resource.java @@ -44,22 +44,18 @@ import net.sourceforge.plantuml.project.LoadPlanable; import net.sourceforge.plantuml.project.draw.ResourceDraw; import net.sourceforge.plantuml.project.time.Day; import net.sourceforge.plantuml.project.time.DayOfWeek; -import net.sourceforge.plantuml.project.time.GCalendar; -import net.sourceforge.plantuml.project.time.Wink; public class Resource { private final String name; private ResourceDraw draw; - private final Set closed = new TreeSet(); - private final Set forcedOn = new TreeSet(); - private final GCalendar calendar; + private final Set closed = new TreeSet(); + private final Set forcedOn = new TreeSet(); private final Collection closedDayOfWeek = EnumSet.noneOf(DayOfWeek.class); - public Resource(String name, LoadPlanable loadPlanable, GCalendar calendar) { + public Resource(String name, LoadPlanable loadPlanable) { this.name = name; - this.calendar = calendar; } @Override @@ -90,24 +86,23 @@ public class Resource { this.draw = draw; } - public boolean isClosedAt(Wink instant) { + public boolean isClosedAt(Day instant) { if (this.forcedOn.contains(instant)) { return false; } - if (closedDayOfWeek.size() > 0 && calendar != null) { - final Day d = calendar.toDayAsDate((Wink) instant); - if (closedDayOfWeek.contains(d.getDayOfWeek())) { + if (closedDayOfWeek.size() > 0) { + if (closedDayOfWeek.contains(instant.getDayOfWeek())) { return true; } } return this.closed.contains(instant); } - public void addCloseDay(Wink instant) { + public void addCloseDay(Day instant) { this.closed.add(instant); } - public void addForceOnDay(Wink instant) { + public void addForceOnDay(Day instant) { this.forcedOn.add(instant); } diff --git a/src/net/sourceforge/plantuml/project/core/Task.java b/src/net/sourceforge/plantuml/project/core/Task.java index c2e323e86..6bac103c2 100644 --- a/src/net/sourceforge/plantuml/project/core/Task.java +++ b/src/net/sourceforge/plantuml/project/core/Task.java @@ -39,24 +39,24 @@ import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.project.Load; import net.sourceforge.plantuml.project.lang.CenterBorderColor; +import net.sourceforge.plantuml.project.time.Day; import net.sourceforge.plantuml.project.time.DayOfWeek; -import net.sourceforge.plantuml.project.time.Wink; public interface Task extends Moment { public TaskCode getCode(); - public Wink getStart(); + public Day getStart(); - public Wink getEnd(); + public Day getEnd(); public Load getLoad(); public void setLoad(Load load); - public void setStart(Wink start); + public void setStart(Day start); - public void setEnd(Wink end); + public void setEnd(Day end); public void setColors(CenterBorderColor colors); @@ -74,7 +74,7 @@ public interface Task extends Moment { public Task getRow(); - public void addPause(Wink pause); + public void addPause(Day pause); public void addPause(DayOfWeek pause); diff --git a/src/net/sourceforge/plantuml/project/core/TaskImpl.java b/src/net/sourceforge/plantuml/project/core/TaskImpl.java index 653b23a25..ad149880d 100644 --- a/src/net/sourceforge/plantuml/project/core/TaskImpl.java +++ b/src/net/sourceforge/plantuml/project/core/TaskImpl.java @@ -54,17 +54,14 @@ import net.sourceforge.plantuml.project.Solver; import net.sourceforge.plantuml.project.lang.CenterBorderColor; import net.sourceforge.plantuml.project.time.Day; import net.sourceforge.plantuml.project.time.DayOfWeek; -import net.sourceforge.plantuml.project.time.GCalendar; -import net.sourceforge.plantuml.project.time.Wink; public class TaskImpl extends AbstractTask implements Task, LoadPlanable { - private final SortedSet pausedDay = new TreeSet(); + private final SortedSet pausedDay = new TreeSet(); private final Set pausedDayOfWeek = new HashSet(); private final Solver solver; private final Map resources = new LinkedHashMap(); private final LoadPlanable defaultPlan; - private final GCalendar calendar; private boolean diamond; private int completion = 100; @@ -77,16 +74,19 @@ public class TaskImpl extends AbstractTask implements Task, LoadPlanable { this.url = url; } - public TaskImpl(TaskCode code, LoadPlanable defaultPlan, GCalendar calendar) { + public TaskImpl(TaskCode code, LoadPlanable defaultPlan, Day calendar) { super(code); - this.calendar = calendar; this.defaultPlan = defaultPlan; this.solver = new Solver(this); - setStart(new Wink(0)); + if (calendar == null) { + setStart(Day.create(0)); + } else { + setStart(calendar); + } setLoad(Load.inWinks(1)); } - public int getLoadAt(Wink instant) { + public int getLoadAt(Day instant) { if (pausedDay.contains(instant)) { return 0; } @@ -101,16 +101,16 @@ public class TaskImpl extends AbstractTask implements Task, LoadPlanable { return result.getLoadAt(instant); } - private boolean pausedDayOfWeek(Wink instant) { + private boolean pausedDayOfWeek(Day instant) { for (DayOfWeek dayOfWeek : pausedDayOfWeek) { - if (calendar.toDayAsDate(instant).getDayOfWeek() == dayOfWeek) { + if (instant.getDayOfWeek() == dayOfWeek) { return true; } } return false; } - public int loadForResource(Resource res, Wink instant) { + public int loadForResource(Resource res, Day instant) { if (resources.keySet().contains(res) && instant.compareTo(getStart()) >= 0 && instant.compareTo(getEnd()) <= 0) { if (res.isClosedAt(instant)) { @@ -121,7 +121,7 @@ public class TaskImpl extends AbstractTask implements Task, LoadPlanable { return 0; } - public void addPause(Wink pause) { + public void addPause(Day pause) { this.pausedDay.add(pause); } @@ -134,7 +134,7 @@ public class TaskImpl extends AbstractTask implements Task, LoadPlanable { throw new IllegalStateException(); } return new LoadPlanable() { - public int getLoadAt(Wink instant) { + public int getLoadAt(Day instant) { int result = 0; for (Map.Entry ent : resources.entrySet()) { final Resource res = ent.getKey(); @@ -184,16 +184,16 @@ public class TaskImpl extends AbstractTask implements Task, LoadPlanable { return code; } - public Wink getStart() { - Wink result = (Wink) solver.getData(TaskAttribute.START); + public Day getStart() { + Day result = (Day) solver.getData(TaskAttribute.START); while (getLoadAt(result) == 0) { result = result.increment(); } return result; } - public Wink getEnd() { - return (Wink) solver.getData(TaskAttribute.END); + public Day getEnd() { + return (Day) solver.getData(TaskAttribute.END); } public Load getLoad() { @@ -204,11 +204,11 @@ public class TaskImpl extends AbstractTask implements Task, LoadPlanable { solver.setData(TaskAttribute.LOAD, load); } - public void setStart(Wink start) { + public void setStart(Day start) { solver.setData(TaskAttribute.START, start); } - public void setEnd(Wink end) { + public void setEnd(Day end) { solver.setData(TaskAttribute.END, end); } @@ -244,20 +244,20 @@ public class TaskImpl extends AbstractTask implements Task, LoadPlanable { return completion; } - public final Collection getAllPaused() { - final SortedSet result = new TreeSet(pausedDay); + public final Collection getAllPaused() { + final SortedSet result = new TreeSet(pausedDay); for (DayOfWeek dayOfWeek : pausedDayOfWeek) { addAll(result, dayOfWeek); } return Collections.unmodifiableCollection(result); } - private void addAll(SortedSet result, DayOfWeek dayOfWeek) { - final Day start = calendar.toDayAsDate(getStart()); - final Day end = calendar.toDayAsDate(getEnd()); - for (Day current = start; current.compareTo(end) <= 0; current = current.next()) { + private void addAll(SortedSet result, DayOfWeek dayOfWeek) { + final Day start = getStart(); + final Day end = getEnd(); + for (Day current = start; current.compareTo(end) <= 0; current = current.increment()) { if (current.getDayOfWeek() == dayOfWeek) { - result.add(calendar.fromDayAsDate(current)); + result.add(current); } } } diff --git a/src/net/sourceforge/plantuml/project/core/TaskInstant.java b/src/net/sourceforge/plantuml/project/core/TaskInstant.java index d28942515..e8645bcdb 100644 --- a/src/net/sourceforge/plantuml/project/core/TaskInstant.java +++ b/src/net/sourceforge/plantuml/project/core/TaskInstant.java @@ -35,7 +35,7 @@ */ package net.sourceforge.plantuml.project.core; -import net.sourceforge.plantuml.project.time.Wink; +import net.sourceforge.plantuml.project.time.Day; public class TaskInstant { @@ -60,7 +60,7 @@ public class TaskInstant { return new TaskInstant(task, attribute, newDelta); } - private Wink manageDelta(Wink value) { + private Day manageDelta(Day value) { if (delta > 0) { for (int i = 0; i < delta; i++) { value = value.increment(); @@ -74,7 +74,7 @@ public class TaskInstant { return value; } - public Wink getInstantPrecise() { + public Day getInstantPrecise() { if (attribute == TaskAttribute.START) { return manageDelta(task.getStart()); } @@ -84,7 +84,7 @@ public class TaskInstant { throw new IllegalStateException(); } - public Wink getInstantTheorical() { + public Day getInstantTheorical() { if (attribute == TaskAttribute.START) { return manageDelta(task.getStart()); } diff --git a/src/net/sourceforge/plantuml/project/core/TaskSeparator.java b/src/net/sourceforge/plantuml/project/core/TaskSeparator.java index 65e895b88..1ab603be2 100644 --- a/src/net/sourceforge/plantuml/project/core/TaskSeparator.java +++ b/src/net/sourceforge/plantuml/project/core/TaskSeparator.java @@ -39,8 +39,8 @@ import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.project.Load; import net.sourceforge.plantuml.project.lang.CenterBorderColor; +import net.sourceforge.plantuml.project.time.Day; import net.sourceforge.plantuml.project.time.DayOfWeek; -import net.sourceforge.plantuml.project.time.Wink; public class TaskSeparator extends AbstractTask implements Task { @@ -55,19 +55,19 @@ public class TaskSeparator extends AbstractTask implements Task { return code; } - public Wink getStart() { + public Day getStart() { throw new UnsupportedOperationException(); } - public Wink getEnd() { + public Day getEnd() { throw new UnsupportedOperationException(); } - public void setStart(Wink start) { + public void setStart(Day start) { throw new UnsupportedOperationException(); } - public void setEnd(Wink end) { + public void setEnd(Day end) { throw new UnsupportedOperationException(); } @@ -107,7 +107,7 @@ public class TaskSeparator extends AbstractTask implements Task { throw new UnsupportedOperationException(); } - public void addPause(Wink pause) { + public void addPause(Day pause) { throw new UnsupportedOperationException(); } diff --git a/src/net/sourceforge/plantuml/project/core2/Hole.java b/src/net/sourceforge/plantuml/project/core2/Hole.java index 264886dc9..f2c9b0c9a 100644 --- a/src/net/sourceforge/plantuml/project/core2/Hole.java +++ b/src/net/sourceforge/plantuml/project/core2/Hole.java @@ -35,6 +35,8 @@ */ package net.sourceforge.plantuml.project.core2; +import net.sourceforge.plantuml.project.time.DayOfWeek; + public class Hole implements Comparable { private final long start; @@ -48,6 +50,11 @@ public class Hole implements Comparable { this.end = end; } + @Override + public String toString() { + return DayOfWeek.timeToString(start) + " --> " + DayOfWeek.timeToString(end); + } + public final long getStart() { return start; } diff --git a/src/net/sourceforge/plantuml/project/core2/HolesList.java b/src/net/sourceforge/plantuml/project/core2/HolesList.java index c76bb23af..84ccd425b 100644 --- a/src/net/sourceforge/plantuml/project/core2/HolesList.java +++ b/src/net/sourceforge/plantuml/project/core2/HolesList.java @@ -44,11 +44,15 @@ public class HolesList implements Iterable { private final List list = new ArrayList(); - public void add(Hole tooth) { + public void addHole(Hole tooth) { list.add(tooth); Collections.sort(list); } + public int size() { + return list.size(); + } + @Override public String toString() { return list.toString(); @@ -66,4 +70,15 @@ public class HolesList implements Iterable { return Collections.unmodifiableList(list).iterator(); } + public HolesList negate() { + final HolesList result = new HolesList(); + long i = 0; + for (Hole hole : list) { + result.addHole(new Hole(i, hole.getStart())); + i = hole.getEnd(); + } + result.addHole(new Hole(i, 1000L * Integer.MAX_VALUE)); + return result; + } + } diff --git a/src/net/sourceforge/plantuml/project/core2/Slice.java b/src/net/sourceforge/plantuml/project/core2/Slice.java index fe2237a65..2daf38028 100644 --- a/src/net/sourceforge/plantuml/project/core2/Slice.java +++ b/src/net/sourceforge/plantuml/project/core2/Slice.java @@ -79,18 +79,25 @@ public class Slice { public List intersectWith(HolesList holes) { final List result = new ArrayList(); - for (Hole hole : holes) { + for (Hole hole : holes.negate()) { final Slice inter = intersectWith(hole); - + if (inter != null) { + result.add(inter); + } } return Collections.unmodifiableList(result); } private Slice intersectWith(Hole hole) { - if (hole.getEnd() <= start || hole.getStart() <= end) { +// if (hole.getEnd() <= start || hole.getStart() <= end) { +// return null; +// } + final long newStart = Math.max(start, hole.getStart()); + final long newEnd = Math.min(end, hole.getEnd()); + if (newEnd <= newStart) { return null; } - return new Slice(Math.max(start, hole.getStart()), Math.min(end, hole.getEnd()), workLoad); + return new Slice(newStart, newEnd, workLoad); } } diff --git a/src/net/sourceforge/plantuml/project/core2/WorkLoadWithHoles.java b/src/net/sourceforge/plantuml/project/core2/WorkLoadWithHoles.java index 96b5ab20b..23a6221e3 100644 --- a/src/net/sourceforge/plantuml/project/core2/WorkLoadWithHoles.java +++ b/src/net/sourceforge/plantuml/project/core2/WorkLoadWithHoles.java @@ -35,7 +35,6 @@ */ package net.sourceforge.plantuml.project.core2; -import java.util.ArrayList; import java.util.List; public class WorkLoadWithHoles implements WorkLoad { @@ -44,7 +43,7 @@ public class WorkLoadWithHoles implements WorkLoad { private final HolesList holes = new HolesList(); public void addHole(long start, long end) { - this.holes.add(new Hole(start, end)); + this.holes.addHole(new Hole(start, end)); } public WorkLoadWithHoles(WorkLoad source) { @@ -61,6 +60,8 @@ public class WorkLoadWithHoles implements WorkLoad { public Slice next() { final Slice candidat = slices.next(); + final List pending = candidat.intersectWith(holes); + System.err.println("pending=" + pending); throw new UnsupportedOperationException(); } } diff --git a/src/net/sourceforge/plantuml/project/core3/Histogram.java b/src/net/sourceforge/plantuml/project/core3/Histogram.java new file mode 100644 index 000000000..48fedb0b7 --- /dev/null +++ b/src/net/sourceforge/plantuml/project/core3/Histogram.java @@ -0,0 +1,42 @@ +/* ======================================================================== + * 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.project.core3; + +public interface Histogram extends TimeLine { + + public long getValueAt(long moment); + +} diff --git a/src/net/sourceforge/plantuml/project/time/Wink.java b/src/net/sourceforge/plantuml/project/core3/HistogramSimple.java similarity index 62% rename from src/net/sourceforge/plantuml/project/time/Wink.java rename to src/net/sourceforge/plantuml/project/core3/HistogramSimple.java index 45566c9ea..40351a662 100644 --- a/src/net/sourceforge/plantuml/project/time/Wink.java +++ b/src/net/sourceforge/plantuml/project/core3/HistogramSimple.java @@ -33,55 +33,43 @@ * * */ -package net.sourceforge.plantuml.project.time; +package net.sourceforge.plantuml.project.core3; -import net.sourceforge.plantuml.project.Value; +import java.util.Map; +import java.util.Map.Entry; +import java.util.TreeMap; -public class Wink implements Value, Comparable { +public class HistogramSimple implements Histogram { - private final int wink; + private final Map events = new TreeMap(); - public Wink(int wink) { - this.wink = wink; + public long getNext(long moment) { + for (long e : events.keySet()) { + if (e > moment) { + return e; + } + } + return 1000L * Integer.MAX_VALUE; + } + + public void put(long event, long value) { + this.events.put(event, value); } @Override public String toString() { - return "(Wink +" + wink + ")"; + return events.toString(); } - public Wink increment() { - return new Wink(wink + 1); - } - - public Wink decrement() { - return new Wink(wink - 1); - } - - public final int getWink() { - return wink; - } - - public int compareTo(Wink other) { - return this.wink - other.wink; - } - - public String toShortString() { - return "" + (wink + 1); - } - - public static Wink min(Wink wink1, Wink wink2) { - if (wink2.wink < wink1.wink) { - return wink2; + public long getValueAt(long moment) { + long last = 0; + for (Entry ent : events.entrySet()) { + if (ent.getKey() > moment) { + return last; + } + last = ent.getValue(); } - return wink1; - } - - public static Wink max(Wink wink1, Wink wink2) { - if (wink2.wink > wink1.wink) { - return wink2; - } - return wink1; + return last; } } diff --git a/src/net/sourceforge/plantuml/project/core3/Solver10.java b/src/net/sourceforge/plantuml/project/core3/Solver10.java new file mode 100644 index 000000000..c70d75392 --- /dev/null +++ b/src/net/sourceforge/plantuml/project/core3/Solver10.java @@ -0,0 +1,72 @@ +/* ======================================================================== + * 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.project.core3; + +public class Solver10 { + + private final Histogram workLoad; + + public Solver10(Histogram workLoad) { + this.workLoad = workLoad; + } + + public TaskLoad solver(long totalLoad) { + final HistogramSimple resultLoad = new HistogramSimple(); + final TaskLoadImpl result = new TaskLoadImpl(resultLoad); + + final long start = workLoad.getNext(0); + result.setStart(start); + long currentTime = start; + while (totalLoad > 0) { + final long tmpWorkLoad = workLoad.getValueAt(currentTime); + final long nextChange = workLoad.getNext(currentTime); + final long duration = nextChange - currentTime; + final long partialLoad = duration * tmpWorkLoad; + resultLoad.put(currentTime, tmpWorkLoad); + + if (partialLoad >= totalLoad) { + final long end = currentTime + totalLoad / tmpWorkLoad; + result.setEnd(end); + resultLoad.put(end, 0); + return result; + } + totalLoad -= partialLoad; + currentTime = nextChange; + } + throw new UnsupportedOperationException(); + } + +} diff --git a/src/net/sourceforge/plantuml/project/draw/YMovable.java b/src/net/sourceforge/plantuml/project/core3/TaskLoad.java similarity index 80% rename from src/net/sourceforge/plantuml/project/draw/YMovable.java rename to src/net/sourceforge/plantuml/project/core3/TaskLoad.java index 78bc87cc5..9206dfd2e 100644 --- a/src/net/sourceforge/plantuml/project/draw/YMovable.java +++ b/src/net/sourceforge/plantuml/project/core3/TaskLoad.java @@ -33,27 +33,14 @@ * * */ -package net.sourceforge.plantuml.project.draw; +package net.sourceforge.plantuml.project.core3; -public class YMovable { +public interface TaskLoad { - private double y; + public long getStart(); - public YMovable(double y) { - this.y = y; - } + public long getEnd(); - public YMovable add(double v) { - return new YMovable(y + v); - } - - public final double getValue() { - return y; - } - - public void pushMe(double delta) { - this.y += delta; - - } + public Histogram getLoad(); } diff --git a/src/net/sourceforge/plantuml/project/time/GCalendar.java b/src/net/sourceforge/plantuml/project/core3/TaskLoadImpl.java similarity index 68% rename from src/net/sourceforge/plantuml/project/time/GCalendar.java rename to src/net/sourceforge/plantuml/project/core3/TaskLoadImpl.java index c0f359524..947c52b23 100644 --- a/src/net/sourceforge/plantuml/project/time/GCalendar.java +++ b/src/net/sourceforge/plantuml/project/core3/TaskLoadImpl.java @@ -33,40 +33,36 @@ * * */ -package net.sourceforge.plantuml.project.time; +package net.sourceforge.plantuml.project.core3; -public class GCalendar { +class TaskLoadImpl implements TaskLoad { - private final Day start; + private long start; + private long end; + private final Histogram load; - public GCalendar(Day start) { - this.start = start; + public TaskLoadImpl(Histogram load) { + this.load = load; } - public Day toDayAsDate(Wink day) { - Day result = start; - final int target = day.getWink(); - int work = 0; - while (work < target) { - result = result.next(); - work++; - } - return result; - } - - public Wink fromDayAsDate(Day day) { - if (day.compareTo(start) < 0) { - throw new IllegalArgumentException(); - } - Wink result = new Wink(0); - while (toDayAsDate(result).equals(day) == false) { - result = result.increment(); - } - return result; - } - - public Day getStartingDate() { + public final long getStart() { return start; } + public final void setStart(long start) { + this.start = start; + } + + public final long getEnd() { + return end; + } + + public final void setEnd(long end) { + this.end = end; + } + + public final Histogram getLoad() { + return load; + } + } diff --git a/src/net/sourceforge/plantuml/project/core3/TimeLine.java b/src/net/sourceforge/plantuml/project/core3/TimeLine.java new file mode 100644 index 000000000..be39e76c2 --- /dev/null +++ b/src/net/sourceforge/plantuml/project/core3/TimeLine.java @@ -0,0 +1,42 @@ +/* ======================================================================== + * 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.project.core3; + +public interface TimeLine { + + public long getNext(long moment); + +} diff --git a/src/net/sourceforge/plantuml/project/core3/TimeLineSimple.java b/src/net/sourceforge/plantuml/project/core3/TimeLineSimple.java new file mode 100644 index 000000000..3d4fb5d8e --- /dev/null +++ b/src/net/sourceforge/plantuml/project/core3/TimeLineSimple.java @@ -0,0 +1,60 @@ +/* ======================================================================== + * 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.project.core3; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class TimeLineSimple implements TimeLine { + + private final List events = new ArrayList(); + + public long getNext(long moment) { + for (long e : events) { + if (e > moment) { + return e; + } + } + return Long.MAX_VALUE; + } + + public void add(long event) { + this.events.add(event); + Collections.sort(events); + } + +} diff --git a/src/net/sourceforge/plantuml/project/draw/AbstractTaskDraw.java b/src/net/sourceforge/plantuml/project/draw/AbstractTaskDraw.java index 48e76231a..91272855d 100644 --- a/src/net/sourceforge/plantuml/project/draw/AbstractTaskDraw.java +++ b/src/net/sourceforge/plantuml/project/draw/AbstractTaskDraw.java @@ -43,7 +43,7 @@ import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.project.ToTaskDraw; import net.sourceforge.plantuml.project.core.Task; import net.sourceforge.plantuml.project.lang.CenterBorderColor; -import net.sourceforge.plantuml.project.time.Wink; +import net.sourceforge.plantuml.project.time.Day; import net.sourceforge.plantuml.project.timescale.TimeScale; import net.sourceforge.plantuml.style.PName; import net.sourceforge.plantuml.style.Style; @@ -56,15 +56,20 @@ public abstract class AbstractTaskDraw implements TaskDraw { protected Url url; protected Display note; protected final TimeScale timeScale; - protected final YMovable y; + private double y; protected final String prettyDisplay; - protected final Wink start; + protected final Day start; protected final ISkinParam skinParam; private final Task task; private final ToTaskDraw toTaskDraw; protected final double margin = 2; + @Override + final public String toString() { + return super.toString() + " " + task; + } + final public void setColorsAndCompletion(CenterBorderColor colors, int completion, Url url, Display note) { this.colors = colors; this.completion = completion; @@ -72,7 +77,7 @@ public abstract class AbstractTaskDraw implements TaskDraw { this.note = note; } - public AbstractTaskDraw(TimeScale timeScale, YMovable y, String prettyDisplay, Wink start, ISkinParam skinParam, + public AbstractTaskDraw(TimeScale timeScale, double y, String prettyDisplay, Day start, ISkinParam skinParam, Task task, ToTaskDraw toTaskDraw) { this.y = y; this.toTaskDraw = toTaskDraw; @@ -105,25 +110,35 @@ public abstract class AbstractTaskDraw implements TaskDraw { return getFontConfiguration().getFont().getSize2D() + 5; } - final public YMovable getY() { + public TaskDraw getTrueRow() { + return toTaskDraw.getTaskDraw(task.getRow()); + } + + final public double getY() { if (task.getRow() == null) { return y; } - return toTaskDraw.getTaskDraw(task.getRow()).getY(); + return getTrueRow().getY(); + } + + public void pushMe(double deltaY) { + if (task.getRow() == null) { + this.y += deltaY; + } } public final Task getTask() { return task; } - public final YMovable getY(Direction direction) { + public final double getY(Direction direction) { if (direction == Direction.UP) { return getY(); } if (direction == Direction.DOWN) { - return getY().add(getHeightTask()); + return getY() + getHeightTask(); } - return getY().add(getHeightTask() / 2); + return getY() + getHeightTask() / 2; } } diff --git a/src/net/sourceforge/plantuml/project/draw/ResourceDraw.java b/src/net/sourceforge/plantuml/project/draw/ResourceDraw.java index a2e8d5f55..d7c86c9b8 100644 --- a/src/net/sourceforge/plantuml/project/draw/ResourceDraw.java +++ b/src/net/sourceforge/plantuml/project/draw/ResourceDraw.java @@ -43,7 +43,7 @@ import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.project.GanttDiagram; import net.sourceforge.plantuml.project.core.Resource; -import net.sourceforge.plantuml.project.time.Wink; +import net.sourceforge.plantuml.project.time.Day; import net.sourceforge.plantuml.project.timescale.TimeScale; import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.UGraphic; @@ -56,12 +56,12 @@ public class ResourceDraw implements UDrawable { private final Resource res; private final TimeScale timeScale; - private final YMovable y; - private final Wink min; - private final Wink max; + private final double y; + private final Day min; + private final Day max; private final GanttDiagram gantt; - public ResourceDraw(GanttDiagram gantt, Resource res, TimeScale timeScale, YMovable y, Wink min, Wink max) { + public ResourceDraw(GanttDiagram gantt, Resource res, TimeScale timeScale, double y, Day min, Day max) { this.res = res; this.timeScale = timeScale; this.y = y; @@ -81,7 +81,7 @@ public class ResourceDraw implements UDrawable { double startingPosition = -1; int totalLoad = 0; int totalLimit = 0; - for (Wink i = min; i.compareTo(max) <= 0; i = i.increment()) { + for (Day i = min; i.compareTo(max) <= 0; i = i.increment()) { final boolean isBreaking = timeScale.isBreaking(i); totalLoad += gantt.getLoadForResource(res, i); totalLimit += 100; @@ -123,8 +123,8 @@ public class ResourceDraw implements UDrawable { return 16 * 2; } - public double getY() { - return y.getValue(); + public final double getY() { + return y; } } diff --git a/src/net/sourceforge/plantuml/project/draw/TaskDraw.java b/src/net/sourceforge/plantuml/project/draw/TaskDraw.java index 101caa0da..603bb3e77 100644 --- a/src/net/sourceforge/plantuml/project/draw/TaskDraw.java +++ b/src/net/sourceforge/plantuml/project/draw/TaskDraw.java @@ -46,12 +46,16 @@ import net.sourceforge.plantuml.ugraphic.UGraphic; public interface TaskDraw extends UDrawable { + public TaskDraw getTrueRow(); + public void setColorsAndCompletion(CenterBorderColor colors, int completion, Url url, Display note); - public YMovable getY(); + public double getY(); - public YMovable getY(Direction direction); + public double getY(Direction direction); + public void pushMe(double deltaY); + public void drawTitle(UGraphic ug); public double getHeightTask(); @@ -64,4 +68,5 @@ public interface TaskDraw extends UDrawable { public FingerPrint getFingerPrintNote(StringBounder stringBounder); + } diff --git a/src/net/sourceforge/plantuml/project/draw/TaskDrawDiamond.java b/src/net/sourceforge/plantuml/project/draw/TaskDrawDiamond.java index 7194ebeeb..8f4add48c 100644 --- a/src/net/sourceforge/plantuml/project/draw/TaskDrawDiamond.java +++ b/src/net/sourceforge/plantuml/project/draw/TaskDrawDiamond.java @@ -43,7 +43,7 @@ import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.project.ToTaskDraw; import net.sourceforge.plantuml.project.core.Task; -import net.sourceforge.plantuml.project.time.Wink; +import net.sourceforge.plantuml.project.time.Day; import net.sourceforge.plantuml.project.timescale.TimeScale; import net.sourceforge.plantuml.style.SName; import net.sourceforge.plantuml.style.Style; @@ -55,7 +55,7 @@ import net.sourceforge.plantuml.ugraphic.UTranslate; public class TaskDrawDiamond extends AbstractTaskDraw { - public TaskDrawDiamond(TimeScale timeScale, YMovable y, String prettyDisplay, Wink start, ISkinParam skinParam, + public TaskDrawDiamond(TimeScale timeScale, double y, String prettyDisplay, Day start, ISkinParam skinParam, Task task, ToTaskDraw toTaskDraw) { super(timeScale, y, prettyDisplay, start, skinParam, task, toTaskDraw); } @@ -108,7 +108,7 @@ public class TaskDrawDiamond extends AbstractTaskDraw { public FingerPrint getFingerPrint() { final double h = getHeightTask(); final double startPos = timeScale.getStartingPosition(start); - return new FingerPrint(startPos, y.getValue(), startPos + h, y.getValue() + h); + return new FingerPrint(startPos, getY(), startPos + h, getY() + h); } private UShape getDiamond() { diff --git a/src/net/sourceforge/plantuml/project/draw/TaskDrawRegular.java b/src/net/sourceforge/plantuml/project/draw/TaskDrawRegular.java index 95d77304b..4f00030e5 100644 --- a/src/net/sourceforge/plantuml/project/draw/TaskDrawRegular.java +++ b/src/net/sourceforge/plantuml/project/draw/TaskDrawRegular.java @@ -37,6 +37,7 @@ package net.sourceforge.plantuml.project.draw; import java.awt.geom.Dimension2D; import java.util.Collection; +import java.util.TreeSet; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; @@ -54,7 +55,7 @@ import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.project.ToTaskDraw; import net.sourceforge.plantuml.project.core.Task; import net.sourceforge.plantuml.project.core.TaskImpl; -import net.sourceforge.plantuml.project.time.Wink; +import net.sourceforge.plantuml.project.time.Day; import net.sourceforge.plantuml.project.timescale.TimeScale; import net.sourceforge.plantuml.style.PName; import net.sourceforge.plantuml.style.SName; @@ -72,20 +73,27 @@ import net.sourceforge.plantuml.ugraphic.color.HColorUtils; public class TaskDrawRegular extends AbstractTaskDraw { - private final Wink end; + private final Day end; private final boolean oddStart; private final boolean oddEnd; - private final Collection paused; + private final Collection paused; private final double margin = 2; - public TaskDrawRegular(TimeScale timeScale, YMovable y, String prettyDisplay, Wink start, Wink end, - boolean oddStart, boolean oddEnd, ISkinParam skinParam, Task task, ToTaskDraw toTaskDraw) { + public TaskDrawRegular(TimeScale timeScale, double y, String prettyDisplay, Day start, Day end, boolean oddStart, + boolean oddEnd, ISkinParam skinParam, Task task, ToTaskDraw toTaskDraw) { super(timeScale, y, prettyDisplay, start, skinParam, task, toTaskDraw); this.end = end; this.oddStart = oddStart; this.oddEnd = oddEnd; - this.paused = ((TaskImpl) task).getAllPaused(); + this.paused = new TreeSet(((TaskImpl) task).getAllPaused()); + for (Day tmp = start; tmp.compareTo(end) <= 0; tmp = tmp.increment()) { + final int load = toTaskDraw.getDefaultPlan().getLoadAt(tmp); + if (load == 0) { + this.paused.add(tmp); + } + + } } public void drawTitle(UGraphic ug) { @@ -156,7 +164,7 @@ public class TaskDrawRegular extends AbstractTaskDraw { final double h = getHeightTask(); final double startPos = timeScale.getStartingPosition(start); final double endPos = timeScale.getEndingPosition(end); - return new FingerPrint(startPos, y.getValue(), endPos - startPos, h); + return new FingerPrint(startPos, getY(), endPos - startPos, h); } public FingerPrint getFingerPrintNote(StringBounder stringBounder) { @@ -166,7 +174,7 @@ public class TaskDrawRegular extends AbstractTaskDraw { final Dimension2D dim = getOpaleNote().calculateDimension(stringBounder); final double startPos = timeScale.getStartingPosition(start); // final double endPos = timeScale.getEndingPosition(end); - return new FingerPrint(startPos, y.getValue() + getYNotePosition(), dim.getWidth(), dim.getHeight()); + return new FingerPrint(startPos, getY() + getYNotePosition(), dim.getWidth(), dim.getHeight()); } private UGraphic applyColors(UGraphic ug) { @@ -213,8 +221,8 @@ public class TaskDrawRegular extends AbstractTaskDraw { if (url != null) { ug.closeUrl(); } - Wink begin = null; - for (Wink pause : paused) { + Day begin = null; + for (Day pause : paused) { if (paused.contains(pause.increment())) { if (begin == null) begin = pause; @@ -228,7 +236,7 @@ public class TaskDrawRegular extends AbstractTaskDraw { } } - private void drawPause(UGraphic ug, Wink start1, Wink end) { + private void drawPause(UGraphic ug, Day start1, Day end) { final double x1 = timeScale.getStartingPosition(start1); final double x2 = timeScale.getEndingPosition(end); final URectangle small = new URectangle(x2 - x1 - 1, getShapeHeight() + 1); diff --git a/src/net/sourceforge/plantuml/project/draw/TaskDrawSeparator.java b/src/net/sourceforge/plantuml/project/draw/TaskDrawSeparator.java index ec6fade96..f38f56b99 100644 --- a/src/net/sourceforge/plantuml/project/draw/TaskDrawSeparator.java +++ b/src/net/sourceforge/plantuml/project/draw/TaskDrawSeparator.java @@ -46,7 +46,7 @@ import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.project.core.Task; import net.sourceforge.plantuml.project.lang.CenterBorderColor; -import net.sourceforge.plantuml.project.time.Wink; +import net.sourceforge.plantuml.project.time.Day; import net.sourceforge.plantuml.project.timescale.TimeScale; import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.UGraphic; @@ -57,12 +57,12 @@ import net.sourceforge.plantuml.ugraphic.color.HColorUtils; public class TaskDrawSeparator implements TaskDraw { private final TimeScale timeScale; - private final YMovable y; - private final Wink min; - private final Wink max; + private double y; + private final Day min; + private final Day max; private final String name; - public TaskDrawSeparator(String name, TimeScale timeScale, YMovable y, Wink min, Wink max) { + public TaskDrawSeparator(String name, TimeScale timeScale, double y, Day min, Day max) { this.name = name; this.y = y; this.timeScale = timeScale; @@ -112,17 +112,25 @@ public class TaskDrawSeparator implements TaskDraw { public FingerPrint getFingerPrint() { final double h = getHeightTask(); final double end = timeScale.getEndingPosition(max); - return new FingerPrint(0, y.getValue(), end, y.getValue() + h); + return new FingerPrint(0, y, end, y + h); } public double getHeightTask() { return 16; } - public YMovable getY() { + public double getY() { return y; } + public void pushMe(double deltaY) { + this.y += deltaY; + } + + public TaskDraw getTrueRow() { + return null; + } + public void setColorsAndCompletion(CenterBorderColor colors, int completion, Url url, Display note) { } @@ -130,7 +138,7 @@ public class TaskDrawSeparator implements TaskDraw { throw new UnsupportedOperationException(); } - public YMovable getY(Direction direction) { + public double getY(Direction direction) { throw new UnsupportedOperationException(); } diff --git a/src/net/sourceforge/plantuml/project/draw/TimeHeader.java b/src/net/sourceforge/plantuml/project/draw/TimeHeader.java index 80bc698ba..4a3ad4813 100644 --- a/src/net/sourceforge/plantuml/project/draw/TimeHeader.java +++ b/src/net/sourceforge/plantuml/project/draw/TimeHeader.java @@ -40,7 +40,7 @@ import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.project.time.Wink; +import net.sourceforge.plantuml.project.time.Day; import net.sourceforge.plantuml.project.timescale.TimeScale; import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.UGraphic; @@ -55,10 +55,10 @@ public abstract class TimeHeader { protected static final int Y_POS_ROW28 = 28; private final TimeScale timeScale; - protected final Wink min; - protected final Wink max; + protected final Day min; + protected final Day max; - public TimeHeader(Wink min, Wink max, TimeScale timeScale) { + public TimeHeader(Day min, Day max, TimeScale timeScale) { this.timeScale = timeScale; this.min = min; this.max = max; diff --git a/src/net/sourceforge/plantuml/project/draw/TimeHeaderDaily.java b/src/net/sourceforge/plantuml/project/draw/TimeHeaderDaily.java index 7a3db976e..f69ecb5e1 100644 --- a/src/net/sourceforge/plantuml/project/draw/TimeHeaderDaily.java +++ b/src/net/sourceforge/plantuml/project/draw/TimeHeaderDaily.java @@ -40,9 +40,7 @@ import java.util.Map; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.project.LoadPlanable; import net.sourceforge.plantuml.project.time.Day; -import net.sourceforge.plantuml.project.time.GCalendar; import net.sourceforge.plantuml.project.time.MonthYear; -import net.sourceforge.plantuml.project.time.Wink; import net.sourceforge.plantuml.project.timescale.TimeScaleDaily; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.ULine; @@ -62,15 +60,13 @@ public class TimeHeaderDaily extends TimeHeader { private final HColor veryLightGray = HColorSet.instance().getColorIfValid("#E0E8E8"); private final HColor lightGray = HColorSet.instance().getColorIfValid("#909898"); - private final GCalendar calendar; private final LoadPlanable defaultPlan; private final Map colorDays; private final Map nameDays; - public TimeHeaderDaily(GCalendar calendar, Wink min, Wink max, LoadPlanable defaultPlan, Map colorDays, + public TimeHeaderDaily(Day calendar, Day min, Day max, LoadPlanable defaultPlan, Map colorDays, Map nameDays, Day printStart, Day printEnd) { super(min, max, new TimeScaleDaily(calendar, printStart)); - this.calendar = calendar; this.defaultPlan = defaultPlan; this.colorDays = colorDays; this.nameDays = nameDays; @@ -87,7 +83,6 @@ public class TimeHeaderDaily extends TimeHeader { private void drawCalendar(final UGraphic ug, double totalHeight) { drawTexts(ug, totalHeight); drawMonths(ug); - drawNonWorking(ug, totalHeight); drawVBars(ug, totalHeight); drawVbar(ug, getTimeScale().getStartingPosition(max.increment()), Y_POS_ROW16, totalHeight); printNamedDays(ug); @@ -96,37 +91,38 @@ public class TimeHeaderDaily extends TimeHeader { private void drawTexts(final UGraphic ug, double totalHeight) { final double height = totalHeight - getFullHeaderHeight(); - for (Wink wink = min; wink.compareTo(max) <= 0; wink = wink.increment()) { + for (Day wink = min; wink.compareTo(max) <= 0; wink = wink.increment()) { final double x1 = getTimeScale().getStartingPosition(wink); final double x2 = getTimeScale().getEndingPosition(wink); - final Day day = calendar.toDayAsDate(wink); HColor textColor = HColorUtils.BLACK; if (defaultPlan.getLoadAt(wink) <= 0) { textColor = lightGray; } - final HColor back = colorDays.get(day); + HColor back = colorDays.get(wink); + if (back == null && defaultPlan.getLoadAt(wink) == 0) { + back = veryLightGray; + } if (back != null) { drawRectangle(ug.apply(back.bg()), height, x1, x2); } printCentered(ug.apply(UTranslate.dy(Y_POS_ROW16)), - getTextBlock(day.getDayOfWeek().shortName(), 10, false, textColor), x1, x2); + getTextBlock(wink.getDayOfWeek().shortName(), 10, false, textColor), x1, x2); printCentered(ug.apply(UTranslate.dy(Y_POS_ROW28)), - getTextBlock("" + day.getDayOfMonth(), 10, false, textColor), x1, x2); + getTextBlock("" + wink.getDayOfMonth(), 10, false, textColor), x1, x2); } } private void drawMonths(final UGraphic ug) { MonthYear last = null; double lastChangeMonth = -1; - for (Wink wink = min; wink.compareTo(max) <= 0; wink = wink.increment()) { + for (Day wink = min; wink.compareTo(max) <= 0; wink = wink.increment()) { final double x1 = getTimeScale().getStartingPosition(wink); - final Day day = calendar.toDayAsDate(wink); - if (day.monthYear().equals(last) == false) { + if (wink.monthYear().equals(last) == false) { if (last != null) { printMonth(ug, last, lastChangeMonth, x1); } lastChangeMonth = x1; - last = day.monthYear(); + last = wink.monthYear(); } } final double x1 = getTimeScale().getStartingPosition(max.increment()); @@ -135,17 +131,6 @@ public class TimeHeaderDaily extends TimeHeader { } } - private void drawNonWorking(final UGraphic ug, double totalHeight) { - final double height = totalHeight - getFullHeaderHeight(); - for (Wink wink = min; wink.compareTo(max) <= 0; wink = wink.increment()) { - final double x1 = getTimeScale().getStartingPosition(wink); - final double x2 = getTimeScale().getEndingPosition(wink); - if (defaultPlan.getLoadAt(wink) == 0) { - drawRectangle(ug.apply(veryLightGray.bg()), height, x1, x2); - } - } - } - private void drawRectangle(UGraphic ug, double height, double x1, double x2) { if (height == 0) { return; @@ -157,12 +142,11 @@ public class TimeHeaderDaily extends TimeHeader { private void drawVBars(final UGraphic ug, double totalHeight) { MonthYear last = null; - for (Wink wink = min; wink.compareTo(max) <= 0; wink = wink.increment()) { + for (Day wink = min; wink.compareTo(max) <= 0; wink = wink.increment()) { double startingY = getFullHeaderHeight(); - final Day day = calendar.toDayAsDate(wink); - if (day.monthYear().equals(last) == false) { + if (wink.monthYear().equals(last) == false) { startingY = 0; - last = day.monthYear(); + last = wink.monthYear(); } drawVbar(ug, getTimeScale().getStartingPosition(wink), startingY, totalHeight); } @@ -183,9 +167,8 @@ public class TimeHeaderDaily extends TimeHeader { private void printNamedDays(final UGraphic ug) { if (nameDays.size() > 0) { String last = null; - for (Wink wink = min; wink.compareTo(max.increment()) <= 0; wink = wink.increment()) { - final Day tmpday = calendar.toDayAsDate(wink); - final String name = nameDays.get(tmpday); + for (Day wink = min; wink.compareTo(max.increment()) <= 0; wink = wink.increment()) { + final String name = nameDays.get(wink); if (name != null && name.equals(last) == false) { final double x1 = getTimeScale().getStartingPosition(wink); final double x2 = getTimeScale().getEndingPosition(wink); diff --git a/src/net/sourceforge/plantuml/project/draw/TimeHeaderMonthly.java b/src/net/sourceforge/plantuml/project/draw/TimeHeaderMonthly.java index 8261b4888..e5a6563ba 100644 --- a/src/net/sourceforge/plantuml/project/draw/TimeHeaderMonthly.java +++ b/src/net/sourceforge/plantuml/project/draw/TimeHeaderMonthly.java @@ -41,9 +41,7 @@ import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.project.LoadPlanable; import net.sourceforge.plantuml.project.core.PrintScale; import net.sourceforge.plantuml.project.time.Day; -import net.sourceforge.plantuml.project.time.GCalendar; import net.sourceforge.plantuml.project.time.MonthYear; -import net.sourceforge.plantuml.project.time.Wink; import net.sourceforge.plantuml.project.timescale.TimeScaleCompressed; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.ULine; @@ -57,12 +55,9 @@ public class TimeHeaderMonthly extends TimeHeader { return Y_POS_ROW16 + 13; } - private final GCalendar calendar; - - public TimeHeaderMonthly(GCalendar calendar, Wink min, Wink max, LoadPlanable defaultPlan, - Map colorDays, Map nameDays) { + public TimeHeaderMonthly(Day calendar, Day min, Day max, LoadPlanable defaultPlan, Map colorDays, + Map nameDays) { super(min, max, new TimeScaleCompressed(calendar, PrintScale.MONTHLY.getCompress())); - this.calendar = calendar; } @Override @@ -82,16 +77,15 @@ public class TimeHeaderMonthly extends TimeHeader { private void drawYears(final UGraphic ug) { MonthYear last = null; double lastChange = -1; - for (Wink wink = min; wink.compareTo(max) < 0; wink = wink.increment()) { - final Day day = calendar.toDayAsDate(wink); + for (Day wink = min; wink.compareTo(max) < 0; wink = wink.increment()) { final double x1 = getTimeScale().getStartingPosition(wink); - if (last == null || day.monthYear().year() != last.year()) { + if (last == null || wink.monthYear().year() != last.year()) { drawVbar(ug, x1, 0, Y_POS_ROW16); if (last != null) { printYear(ug, last, lastChange, x1); } lastChange = x1; - last = day.monthYear(); + last = wink.monthYear(); } } final double x1 = getTimeScale().getStartingPosition(max.increment()); @@ -103,16 +97,15 @@ public class TimeHeaderMonthly extends TimeHeader { private void drawMonths(final UGraphic ug) { MonthYear last = null; double lastChange = -1; - for (Wink wink = min; wink.compareTo(max) < 0; wink = wink.increment()) { - final Day day = calendar.toDayAsDate(wink); + for (Day wink = min; wink.compareTo(max) < 0; wink = wink.increment()) { final double x1 = getTimeScale().getStartingPosition(wink); - if (day.monthYear().equals(last) == false) { + if (wink.monthYear().equals(last) == false) { drawVbar(ug, x1, Y_POS_ROW16, Y_POS_ROW28); if (last != null) { printMonth(ug.apply(UTranslate.dy(Y_POS_ROW16)), last, lastChange, x1); } lastChange = x1; - last = day.monthYear(); + last = wink.monthYear(); } } final double x1 = getTimeScale().getStartingPosition(max.increment()); diff --git a/src/net/sourceforge/plantuml/project/draw/TimeHeaderSimple.java b/src/net/sourceforge/plantuml/project/draw/TimeHeaderSimple.java index 671838c1c..5e6b6ce1d 100644 --- a/src/net/sourceforge/plantuml/project/draw/TimeHeaderSimple.java +++ b/src/net/sourceforge/plantuml/project/draw/TimeHeaderSimple.java @@ -39,7 +39,7 @@ import net.sourceforge.plantuml.SpriteContainerEmpty; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.project.time.Wink; +import net.sourceforge.plantuml.project.time.Day; import net.sourceforge.plantuml.project.timescale.TimeScale; import net.sourceforge.plantuml.project.timescale.TimeScaleWink; import net.sourceforge.plantuml.ugraphic.UGraphic; @@ -62,7 +62,7 @@ public class TimeHeaderSimple extends TimeHeader { return 0; } - public TimeHeaderSimple(Wink min, Wink max) { + public TimeHeaderSimple(Day min, Day max) { super(min, max, new TimeScaleWink()); } @@ -72,16 +72,17 @@ public class TimeHeaderSimple extends TimeHeader { final double xmax = getTimeScale().getEndingPosition(max); drawSimpleDayCounter(ug, getTimeScale(), totalHeight); ug.apply(HColorUtils.LIGHT_GRAY).draw(ULine.hline(xmax - xmin)); - ug.apply(HColorUtils.LIGHT_GRAY).apply(UTranslate.dy(getFullHeaderHeight() - 3)) - .draw(ULine.hline(xmax - xmin)); + ug.apply(HColorUtils.LIGHT_GRAY).apply(UTranslate.dy(getFullHeaderHeight() - 3)).draw(ULine.hline(xmax - xmin)); } private void drawSimpleDayCounter(final UGraphic ug, TimeScale timeScale, double totalHeight) { final ULine vbar = ULine.vline(totalHeight); - for (Wink i = min; i.compareTo(max.increment()) <= 0; i = i.increment()) { - final TextBlock num = Display.getWithNewlines(i.toShortString()).create(getFontConfiguration(10, false, HColorUtils.BLACK), - HorizontalAlignment.LEFT, new SpriteContainerEmpty()); + for (Day i = min; i.compareTo(max.increment()) <= 0; i = i.increment()) { + final String number = "" + (i.getAbsoluteDayNum() + 1); + final TextBlock num = Display.getWithNewlines(number).create( + getFontConfiguration(10, false, HColorUtils.BLACK), HorizontalAlignment.LEFT, + new SpriteContainerEmpty()); final double x1 = timeScale.getStartingPosition(i); final double x2 = timeScale.getEndingPosition(i); final double width = num.calculateDimension(ug.getStringBounder()).getWidth(); diff --git a/src/net/sourceforge/plantuml/project/draw/TimeHeaderWeekly.java b/src/net/sourceforge/plantuml/project/draw/TimeHeaderWeekly.java index 3fbdf9691..0070c4937 100644 --- a/src/net/sourceforge/plantuml/project/draw/TimeHeaderWeekly.java +++ b/src/net/sourceforge/plantuml/project/draw/TimeHeaderWeekly.java @@ -42,9 +42,7 @@ import net.sourceforge.plantuml.project.LoadPlanable; import net.sourceforge.plantuml.project.core.PrintScale; import net.sourceforge.plantuml.project.time.Day; import net.sourceforge.plantuml.project.time.DayOfWeek; -import net.sourceforge.plantuml.project.time.GCalendar; import net.sourceforge.plantuml.project.time.MonthYear; -import net.sourceforge.plantuml.project.time.Wink; import net.sourceforge.plantuml.project.timescale.TimeScaleCompressed; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.ULine; @@ -58,12 +56,9 @@ public class TimeHeaderWeekly extends TimeHeader { return Y_POS_ROW16 + 13; } - private final GCalendar calendar; - - public TimeHeaderWeekly(GCalendar calendar, Wink min, Wink max, LoadPlanable defaultPlan, - Map colorDays, Map nameDays) { + public TimeHeaderWeekly(Day calendar, Day min, Day max, LoadPlanable defaultPlan, Map colorDays, + Map nameDays) { super(min, max, new TimeScaleCompressed(calendar, PrintScale.WEEKLY.getCompress())); - this.calendar = calendar; } @Override @@ -84,16 +79,15 @@ public class TimeHeaderWeekly extends TimeHeader { private void printMonths(final UGraphic ug) { MonthYear last = null; double lastChangeMonth = -1; - for (Wink wink = min; wink.compareTo(max) < 0; wink = wink.increment()) { - final Day day = calendar.toDayAsDate(wink); + for (Day wink = min; wink.compareTo(max) < 0; wink = wink.increment()) { final double x1 = getTimeScale().getStartingPosition(wink); - if (day.monthYear().equals(last) == false) { + if (wink.monthYear().equals(last) == false) { drawVbar(ug, x1, 0, Y_POS_ROW16); if (last != null) { printMonth(ug, last, lastChangeMonth, x1); } lastChangeMonth = x1; - last = day.monthYear(); + last = wink.monthYear(); } } final double x1 = getTimeScale().getStartingPosition(max.increment()); @@ -103,18 +97,18 @@ public class TimeHeaderWeekly extends TimeHeader { } private void printSmallVbars(final UGraphic ug, double totalHeight) { - for (Wink wink = min; wink.compareTo(max) <= 0; wink = wink.increment()) { - if (calendar.toDayAsDate(wink).getDayOfWeek() == DayOfWeek.MONDAY) { + for (Day wink = min; wink.compareTo(max) <= 0; wink = wink.increment()) { + if (wink.getDayOfWeek() == DayOfWeek.MONDAY) { drawVbar(ug, getTimeScale().getStartingPosition(wink), Y_POS_ROW16, totalHeight); } } } private void printDaysOfMonth(final UGraphic ug) { - for (Wink wink = min; wink.compareTo(max) < 0; wink = wink.increment()) { - final Day day = calendar.toDayAsDate(wink); - if (day.getDayOfWeek() == DayOfWeek.MONDAY) { - printLeft(ug.apply(UTranslate.dy(Y_POS_ROW16)), getTextBlock("" + day.getDayOfMonth(), 10, false, HColorUtils.BLACK), + for (Day wink = min; wink.compareTo(max) < 0; wink = wink.increment()) { + if (wink.getDayOfWeek() == DayOfWeek.MONDAY) { + printLeft(ug.apply(UTranslate.dy(Y_POS_ROW16)), + getTextBlock("" + wink.getDayOfMonth(), 10, false, HColorUtils.BLACK), getTimeScale().getStartingPosition(wink) + 5); } } diff --git a/src/net/sourceforge/plantuml/project/lang/SentenceHappensDate.java b/src/net/sourceforge/plantuml/project/lang/SentenceHappensDate.java index 79b7fa52a..5390f3abf 100644 --- a/src/net/sourceforge/plantuml/project/lang/SentenceHappensDate.java +++ b/src/net/sourceforge/plantuml/project/lang/SentenceHappensDate.java @@ -56,7 +56,7 @@ public class SentenceHappensDate extends SentenceSimple { if (startingDate == null) { return CommandExecutionResult.error("No starting date for the project"); } - task.setStart(start.asInstantDay(startingDate)); + task.setStart(start); task.setDiamond(true); return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/project/lang/SentencePausesDate.java b/src/net/sourceforge/plantuml/project/lang/SentencePausesDate.java index 49c5468d2..1960a01a7 100644 --- a/src/net/sourceforge/plantuml/project/lang/SentencePausesDate.java +++ b/src/net/sourceforge/plantuml/project/lang/SentencePausesDate.java @@ -37,7 +37,6 @@ package net.sourceforge.plantuml.project.lang; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.project.GanttDiagram; -import net.sourceforge.plantuml.project.Load; import net.sourceforge.plantuml.project.core.Task; import net.sourceforge.plantuml.project.time.Day; @@ -55,7 +54,7 @@ public class SentencePausesDate extends SentenceSimple { if (startingDate == null) { return CommandExecutionResult.error("No starting date for the project"); } - task.addPause(pause.asInstantDay(startingDate)); + task.addPause(pause); return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/project/timescale/UnusedTimeScaleWithoutWeekEnd.java b/src/net/sourceforge/plantuml/project/lang/SentencePausesDates.java similarity index 52% rename from src/net/sourceforge/plantuml/project/timescale/UnusedTimeScaleWithoutWeekEnd.java rename to src/net/sourceforge/plantuml/project/lang/SentencePausesDates.java index c5d53d7e9..c729c980e 100644 --- a/src/net/sourceforge/plantuml/project/timescale/UnusedTimeScaleWithoutWeekEnd.java +++ b/src/net/sourceforge/plantuml/project/lang/SentencePausesDates.java @@ -33,50 +33,32 @@ * * */ -package net.sourceforge.plantuml.project.timescale; +package net.sourceforge.plantuml.project.lang; +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.project.DaysAsDates; +import net.sourceforge.plantuml.project.GanttDiagram; +import net.sourceforge.plantuml.project.core.Task; import net.sourceforge.plantuml.project.time.Day; -import net.sourceforge.plantuml.project.time.DayOfWeek; -import net.sourceforge.plantuml.project.time.GCalendar; -import net.sourceforge.plantuml.project.time.Wink; -public class UnusedTimeScaleWithoutWeekEnd implements TimeScale { +public class SentencePausesDates extends SentenceSimple { - private final double scale = 16.0; - private final GCalendar calendar; + public SentencePausesDates() { + super(new SubjectTask(), Verbs.pauses(), new ComplementDates()); + } - public UnusedTimeScaleWithoutWeekEnd(GCalendar calendar) { - if (calendar == null) { - throw new IllegalArgumentException(); + @Override + public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { + final Task task = (Task) subject; + final DaysAsDates pauses = (DaysAsDates) complement; + final Day startingDate = project.getStartingDate(); + if (startingDate == null) { + return CommandExecutionResult.error("No starting date for the project"); } - this.calendar = calendar; - } - - public double getStartingPosition(Wink instant) { - double result = 0; - Wink current = (Wink) instant; - while (current.getWink() > 0) { - current = current.decrement(); - result += getWidth(current); + for (Day day : pauses) { + task.addPause(day); } - return result; - } - - public double getWidth(Wink instant) { - final Day day = calendar.toDayAsDate((Wink) instant); - final DayOfWeek dayOfWeek = day.getDayOfWeek(); - if (dayOfWeek == DayOfWeek.SATURDAY || dayOfWeek == DayOfWeek.SUNDAY) { - return 1; - } - return scale; - } - - public double getEndingPosition(Wink instant) { - throw new UnsupportedOperationException(); - } - - public boolean isBreaking(Wink instant) { - throw new UnsupportedOperationException(); + return CommandExecutionResult.ok(); } } diff --git a/src/net/sourceforge/plantuml/project/lang/SentenceTaskEndsAbsolute.java b/src/net/sourceforge/plantuml/project/lang/SentenceTaskEndsAbsolute.java index a08dd404b..a38f1cc3c 100644 --- a/src/net/sourceforge/plantuml/project/lang/SentenceTaskEndsAbsolute.java +++ b/src/net/sourceforge/plantuml/project/lang/SentenceTaskEndsAbsolute.java @@ -54,7 +54,7 @@ public class SentenceTaskEndsAbsolute extends SentenceSimple { if (startingDate == null) { return CommandExecutionResult.error("No starting date for the project"); } - task.setEnd(end.asInstantDay(startingDate)); + task.setEnd(end); return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/project/lang/SentenceTaskStartsAbsolute.java b/src/net/sourceforge/plantuml/project/lang/SentenceTaskStartsAbsolute.java index 1d27dea58..b072e6120 100644 --- a/src/net/sourceforge/plantuml/project/lang/SentenceTaskStartsAbsolute.java +++ b/src/net/sourceforge/plantuml/project/lang/SentenceTaskStartsAbsolute.java @@ -54,7 +54,7 @@ public class SentenceTaskStartsAbsolute extends SentenceSimple { if (startingDate == null) { return CommandExecutionResult.error("No starting date for the project"); } - task.setStart(start.asInstantDay(startingDate)); + task.setStart(start); return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/project/lang/SubjectResource.java b/src/net/sourceforge/plantuml/project/lang/SubjectResource.java index 60ebd5246..fc47a9d7b 100644 --- a/src/net/sourceforge/plantuml/project/lang/SubjectResource.java +++ b/src/net/sourceforge/plantuml/project/lang/SubjectResource.java @@ -77,7 +77,7 @@ public class SubjectResource implements Subject { public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { final Resource resource = (Resource) subject; final Day when = (Day) complement; - resource.addCloseDay(project.convert(when)); + resource.addCloseDay(when); return CommandExecutionResult.ok(); } @@ -93,7 +93,7 @@ public class SubjectResource implements Subject { public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { final Resource resource = (Resource) subject; for (Day when : (DaysAsDates) complement) { - resource.addCloseDay(project.convert(when)); + resource.addCloseDay(when); } return CommandExecutionResult.ok(); } @@ -125,7 +125,7 @@ public class SubjectResource implements Subject { public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { final Resource resource = (Resource) subject; final Day when = (Day) complement; - resource.addForceOnDay(project.convert(when)); + resource.addForceOnDay(when); return CommandExecutionResult.ok(); } @@ -141,7 +141,7 @@ public class SubjectResource implements Subject { public CommandExecutionResult execute(GanttDiagram project, Object subject, Object complement) { final Resource resource = (Resource) subject; for (Day when : (DaysAsDates) complement) { - resource.addForceOnDay(project.convert(when)); + resource.addForceOnDay(when); } return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/project/lang/SubjectTask.java b/src/net/sourceforge/plantuml/project/lang/SubjectTask.java index 9883384ce..148f83b2b 100644 --- a/src/net/sourceforge/plantuml/project/lang/SubjectTask.java +++ b/src/net/sourceforge/plantuml/project/lang/SubjectTask.java @@ -76,7 +76,7 @@ public class SubjectTask implements Subject { new SentenceTaskStartsAbsolute(), new SentenceHappens(), new SentenceHappensDate(), new SentenceEnds(), new SentenceTaskEndsAbsolute(), new SentenceIsColored(), new SentenceIsDeleted(), new SentenceIsForTask(), new SentenceLinksTo(), new SentenceOccurs(), new SentenceDisplayOnSameRowAs(), - new SentencePausesDate(), new SentencePausesDayOfWeek()); + new SentencePausesDate(), new SentencePausesDates(), new SentencePausesDayOfWeek()); } public IRegex toRegex() { diff --git a/src/net/sourceforge/plantuml/project/lang/Verbs.java b/src/net/sourceforge/plantuml/project/lang/Verbs.java index b19f52cb1..089166963 100644 --- a/src/net/sourceforge/plantuml/project/lang/Verbs.java +++ b/src/net/sourceforge/plantuml/project/lang/Verbs.java @@ -68,7 +68,7 @@ public class Verbs { } public static IRegex pauses() { - return new RegexLeaf("pauses?[%s]*(at[%s]*|the[%s]*|on[%s]*)*"); + return new RegexLeaf("pauses?[%s]*(at[%s]*|the[%s]*|on[%s]*|from[%s]*)*"); } public static IRegex isDeleted() { diff --git a/src/net/sourceforge/plantuml/project/time/Day.java b/src/net/sourceforge/plantuml/project/time/Day.java index 8496e58e8..51cce4736 100644 --- a/src/net/sourceforge/plantuml/project/time/Day.java +++ b/src/net/sourceforge/plantuml/project/time/Day.java @@ -35,12 +35,19 @@ */ package net.sourceforge.plantuml.project.time; -import java.util.Date; +import java.util.Calendar; +import java.util.TimeZone; -public class Day implements Comparable { +import net.sourceforge.plantuml.project.Value; + +public class Day implements Comparable, Value { + + static final public long MILLISECONDS_PER_DAY = 1000L * 3600L * 24; + static final private Calendar gmt = Calendar.getInstance(TimeZone.getTimeZone("GMT")); private final int dayOfMonth; private final MonthYear monthYear; + private final long ms1; public static Day create(int year, String month, int dayOfMonth) { return new Day(year, Month.fromString(month), dayOfMonth); @@ -50,21 +57,56 @@ public class Day implements Comparable { return new Day(year, Month.values()[month - 1], dayOfMonth); } + public static Day create(long ms) { + return new Day(ms); + } + public static Day today() { - final Date now = new Date(); - final int year = now.getYear() + 1900; - final int month = now.getMonth() + 1; - final int dayOfMonth = now.getDate(); - return create(year, month, dayOfMonth); + return create(System.currentTimeMillis()); } private Day(int year, Month month, int dayOfMonth) { - this(MonthYear.create(year, month), dayOfMonth); + this.dayOfMonth = dayOfMonth; + this.monthYear = MonthYear.create(year, month); + synchronized (gmt) { + gmt.clear(); + gmt.set(year, month.ordinal(), dayOfMonth); + this.ms1 = gmt.getTimeInMillis(); + } } - private Day(MonthYear monthYear, int dayOfMonth) { - this.dayOfMonth = dayOfMonth; - this.monthYear = monthYear; + private Day(long ms) { + this.ms1 = ms; + synchronized (gmt) { + gmt.clear(); + gmt.setTimeInMillis(ms); + final int year = gmt.get(Calendar.YEAR); + final int month = gmt.get(Calendar.MONTH); + final int dayOfMonth = gmt.get(Calendar.DAY_OF_MONTH); + this.dayOfMonth = dayOfMonth; + this.monthYear = MonthYear.create(year, Month.values()[month]); + } + + } + + public Day increment() { + return addDays(1); + } + + public Day decrement() { + return addDays(-1); + } + + public Day addDays(int nday) { + return create(MILLISECONDS_PER_DAY * (getAbsoluteDayNum() + nday)); + } + + public final int getAbsoluteDayNum() { + return (int) (ms1 / MILLISECONDS_PER_DAY); + } + + public final long getMillis() { + return ms1; } public int year() { @@ -99,15 +141,6 @@ public class Day implements Comparable { return month().getDaysPerMonth(year()); } - public Day next() { - int newDayOfMonth = dayOfMonth + 1; - if (newDayOfMonth <= daysPerMonth()) { - return new Day(year(), month(), newDayOfMonth); - } - assert newDayOfMonth > daysPerMonth(); - return new Day(monthYear.next(), 1); - } - public Month month() { return monthYear.month(); } @@ -127,60 +160,22 @@ public class Day implements Comparable { return DayOfWeek.fromH(h); } - public static int DOW(int y_, int m_, int d_) { - final int q = d_; - final int m = 3 + (m_ - 1 + 10) % 12; - final int y = m >= 13 ? y_ - 1 : y_; - final int k = y % 100; - final int j = y / 100; - final int h = ((q + 13 * (m + 1) / 5) + k + k / 4 + j / 4 + 5 * j) % 7; - return h; - } - - public Wink asInstantDay(Day reference) { - // if (this.compareTo(reference) < 0) { - // throw new IllegalArgumentException(); - // } - int cmp = 0; - Day current = reference; - while (current.compareTo(this) < 0) { - current = current.next(); - cmp++; - } - return new Wink(cmp); - } - - // https://www.staff.science.uu.nl/~gent0113/calendar/isocalendar_text_5.htm - // https://en.wikipedia.org/wiki/ISO_week_date - // http://www.proesite.com/timex/wkcalc.htm - public int ISO_WN() { - final int y = year(); - int m = month().ordinal() + 1; - int d = dayOfMonth; - int dow = DOW(y, m, d); - int dow0101 = DOW(y, 1, 1); - - if (m == 1 && 3 < dow0101 && dow0101 < 7 - (d - 1)) { - // days before week 1 of the current year have the same week number as - // the last day of the last week of the previous year - - dow = dow0101 - 1; - dow0101 = DOW(y - 1, 1, 1); - m = 12; - d = 31; - } else if (m == 12 && 30 - (d - 1) < DOW(y + 1, 1, 1) && DOW(y + 1, 1, 1) < 4) { - // days after the last week of the current year have the same week number as - // the first day of the next year, (i.e. 1) - - return 1; - } - - return (DOW(y, 1, 1) < 4) ? 1 : 0 + 4 * (m - 1) + (2 * (m - 1) + (d - 1) + dow0101 - dow + 6) * 36 / 256; - - } - public int compareTo(Day other) { return this.internalNumber() - other.internalNumber(); } + public static Day min(Day wink1, Day wink2) { + if (wink2.internalNumber() < wink1.internalNumber()) { + return wink2; + } + return wink1; + } + + public static Day max(Day wink1, Day wink2) { + if (wink2.internalNumber() > wink1.internalNumber()) { + return wink2; + } + return wink1; + } + } diff --git a/src/net/sourceforge/plantuml/project/timescale/TimeScale.java b/src/net/sourceforge/plantuml/project/timescale/TimeScale.java index 4f519b7b8..824982664 100644 --- a/src/net/sourceforge/plantuml/project/timescale/TimeScale.java +++ b/src/net/sourceforge/plantuml/project/timescale/TimeScale.java @@ -35,16 +35,16 @@ */ package net.sourceforge.plantuml.project.timescale; -import net.sourceforge.plantuml.project.time.Wink; +import net.sourceforge.plantuml.project.time.Day; public interface TimeScale { - public double getStartingPosition(Wink instant); + public double getStartingPosition(Day instant); - public double getEndingPosition(Wink instant); + public double getEndingPosition(Day instant); - public double getWidth(Wink instant); + public double getWidth(Day instant); - public boolean isBreaking(Wink instant); + public boolean isBreaking(Day instant); } diff --git a/src/net/sourceforge/plantuml/project/timescale/TimeScaleCompressed.java b/src/net/sourceforge/plantuml/project/timescale/TimeScaleCompressed.java index 24888ee8e..f2278432c 100644 --- a/src/net/sourceforge/plantuml/project/timescale/TimeScaleCompressed.java +++ b/src/net/sourceforge/plantuml/project/timescale/TimeScaleCompressed.java @@ -37,36 +37,31 @@ package net.sourceforge.plantuml.project.timescale; import net.sourceforge.plantuml.project.time.Day; import net.sourceforge.plantuml.project.time.DayOfWeek; -import net.sourceforge.plantuml.project.time.GCalendar; -import net.sourceforge.plantuml.project.time.Wink; public class TimeScaleCompressed implements TimeScale { private final int compress; private final TimeScale daily; - private final GCalendar calendar; - public TimeScaleCompressed(GCalendar calendar, int compress) { + public TimeScaleCompressed(Day calendar, int compress) { this.daily = new TimeScaleDaily(calendar, null); this.compress = compress; - this.calendar = calendar; } - public double getStartingPosition(Wink instant) { + public double getStartingPosition(Day instant) { return daily.getStartingPosition(instant) / compress; } - public double getEndingPosition(Wink instant) { + public double getEndingPosition(Day instant) { return daily.getEndingPosition(instant) / compress; } - public double getWidth(Wink instant) { + public double getWidth(Day instant) { return daily.getWidth(instant) / compress; } - public boolean isBreaking(Wink instant) { - final Day day = calendar.toDayAsDate(instant); - return day.getDayOfWeek() == DayOfWeek.SUNDAY; + public boolean isBreaking(Day instant) { + return instant.getDayOfWeek() == DayOfWeek.SUNDAY; } } diff --git a/src/net/sourceforge/plantuml/project/timescale/TimeScaleDaily.java b/src/net/sourceforge/plantuml/project/timescale/TimeScaleDaily.java index ade9a8461..6b86aa204 100644 --- a/src/net/sourceforge/plantuml/project/timescale/TimeScaleDaily.java +++ b/src/net/sourceforge/plantuml/project/timescale/TimeScaleDaily.java @@ -36,37 +36,35 @@ package net.sourceforge.plantuml.project.timescale; import net.sourceforge.plantuml.project.time.Day; -import net.sourceforge.plantuml.project.time.GCalendar; -import net.sourceforge.plantuml.project.time.Wink; public final class TimeScaleDaily implements TimeScale { private final TimeScaleWink basic; private final double delta; - public TimeScaleDaily(GCalendar calendar, Day zeroDay) { + public TimeScaleDaily(Day calendar, Day zeroDay) { this.basic = new TimeScaleWink(); if (zeroDay == null) { - this.delta = 0; + this.delta = basic.getStartingPosition(calendar); } else { - this.delta = basic.getStartingPosition(calendar.fromDayAsDate(zeroDay)); + this.delta = basic.getStartingPosition(zeroDay); } } - public double getStartingPosition(Wink instant) { + public double getStartingPosition(Day instant) { return basic.getStartingPosition(instant) - delta; } - public double getEndingPosition(Wink instant) { + public double getEndingPosition(Day instant) { return basic.getEndingPosition(instant) - delta; } - public double getWidth(Wink instant) { + public double getWidth(Day instant) { return basic.getWidth(instant); } - public boolean isBreaking(Wink instant) { + public boolean isBreaking(Day instant) { return true; } diff --git a/src/net/sourceforge/plantuml/project/timescale/TimeScaleWink.java b/src/net/sourceforge/plantuml/project/timescale/TimeScaleWink.java index ce0af8d66..4410ea230 100644 --- a/src/net/sourceforge/plantuml/project/timescale/TimeScaleWink.java +++ b/src/net/sourceforge/plantuml/project/timescale/TimeScaleWink.java @@ -35,26 +35,26 @@ */ package net.sourceforge.plantuml.project.timescale; -import net.sourceforge.plantuml.project.time.Wink; +import net.sourceforge.plantuml.project.time.Day; public class TimeScaleWink implements TimeScale { private final double scale = 16.0; - public double getStartingPosition(Wink instant) { - final int wink = instant.getWink(); - return wink * scale; + public double getStartingPosition(Day instant) { + final long wink = instant.getMillis(); + return wink * scale / Day.MILLISECONDS_PER_DAY; } - public double getEndingPosition(Wink instant) { + public double getEndingPosition(Day instant) { return getStartingPosition(instant) + getWidth(instant); } - public double getWidth(Wink instant) { + public double getWidth(Day instant) { return scale; } - public boolean isBreaking(Wink instant) { + public boolean isBreaking(Day instant) { return true; } diff --git a/src/net/sourceforge/plantuml/salt/CommandAnything.java b/src/net/sourceforge/plantuml/salt/CommandAnything.java new file mode 100644 index 000000000..c2e3a9e28 --- /dev/null +++ b/src/net/sourceforge/plantuml/salt/CommandAnything.java @@ -0,0 +1,72 @@ +/* ======================================================================== + * 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.salt; + +import net.sourceforge.plantuml.LineLocation; +import net.sourceforge.plantuml.StringUtils; +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 class CommandAnything extends SingleLineCommand2 { + + public CommandAnything() { + super(false, getRegexConcat()); + } + + static IRegex getRegexConcat() { + return RegexConcat.build(CommandAnything.class.getName(), RegexLeaf.start(), // + new RegexLeaf("ALL", "(.*)"), // + RegexLeaf.end()); + } + + @Override + protected CommandExecutionResult executeArg(PSystemSalt diagram, LineLocation location, RegexResult arg) { + final String s = arg.get("ALL", 0); + if (diagram.isIamSalt() == false) { + if (StringUtils.isEmpty(s)) { + return CommandExecutionResult.ok(); + } + return CommandExecutionResult.error("Not ready"); + } + diagram.add(s); + return CommandExecutionResult.ok(); + } + +} diff --git a/src/net/sourceforge/plantuml/salt/CommandSalt.java b/src/net/sourceforge/plantuml/salt/CommandSalt.java new file mode 100644 index 000000000..6b4c64383 --- /dev/null +++ b/src/net/sourceforge/plantuml/salt/CommandSalt.java @@ -0,0 +1,66 @@ +/* ======================================================================== + * 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.salt; + +import net.sourceforge.plantuml.LineLocation; +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 class CommandSalt extends SingleLineCommand2 { + + public CommandSalt() { + super(false, getRegexConcat()); + } + + static IRegex getRegexConcat() { + return RegexConcat.build(CommandSalt.class.getName(), RegexLeaf.start(), // + RegexLeaf.spaceZeroOrMore(), // + new RegexLeaf("salt"), // + RegexLeaf.spaceZeroOrMore(), // + RegexLeaf.end()); + } + + @Override + protected CommandExecutionResult executeArg(PSystemSalt diagram, LineLocation location, RegexResult arg) { + diagram.setIamSalt(true); + return CommandExecutionResult.ok(); + } + +} diff --git a/src/net/sourceforge/plantuml/salt/Dictionary.java b/src/net/sourceforge/plantuml/salt/Dictionary.java index d07f47806..12174086a 100644 --- a/src/net/sourceforge/plantuml/salt/Dictionary.java +++ b/src/net/sourceforge/plantuml/salt/Dictionary.java @@ -121,4 +121,8 @@ public class Dictionary implements SpriteContainer, ISkinSimple { throw new UnsupportedOperationException(); } + public double minClassWidth() { + return 0; + } + } diff --git a/src/net/sourceforge/plantuml/salt/PSystemSalt.java b/src/net/sourceforge/plantuml/salt/PSystemSalt.java index c66107240..5fb1dacf8 100644 --- a/src/net/sourceforge/plantuml/salt/PSystemSalt.java +++ b/src/net/sourceforge/plantuml/salt/PSystemSalt.java @@ -36,6 +36,7 @@ package net.sourceforge.plantuml.salt; import java.awt.geom.Dimension2D; +import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.OutputStream; import java.util.ArrayList; @@ -43,13 +44,17 @@ import java.util.Collection; import java.util.Iterator; import java.util.List; -import net.sourceforge.plantuml.AbstractPSystem; +import net.sourceforge.plantuml.AnnotatedWorker; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.FileFormatOption; +import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.Log; +import net.sourceforge.plantuml.Scale; import net.sourceforge.plantuml.ScaleSimple; import net.sourceforge.plantuml.SkinParam; +import net.sourceforge.plantuml.TitledDiagram; import net.sourceforge.plantuml.UmlDiagram; +import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.WithSprite; import net.sourceforge.plantuml.api.ImageDataSimple; import net.sourceforge.plantuml.command.BlocLines; @@ -58,7 +63,10 @@ import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.CommandFactorySprite; import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.ImageData; -import net.sourceforge.plantuml.graphic.UDrawable; +import net.sourceforge.plantuml.graphic.AbstractTextBlock; +import net.sourceforge.plantuml.graphic.InnerStrategy; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.salt.element.Element; import net.sourceforge.plantuml.salt.factory.AbstractElementFactoryComplex; import net.sourceforge.plantuml.salt.factory.ElementFactory; @@ -81,12 +89,14 @@ import net.sourceforge.plantuml.salt.factory.ElementFactoryTextField; import net.sourceforge.plantuml.salt.factory.ElementFactoryTree; import net.sourceforge.plantuml.sprite.Sprite; import net.sourceforge.plantuml.style.ClockwiseTopRightBottomLeft; +import net.sourceforge.plantuml.svek.TextBlockBackcolored; import net.sourceforge.plantuml.ugraphic.ImageBuilder; +import net.sourceforge.plantuml.ugraphic.MinMax; import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.color.ColorMapperIdentity; +import net.sourceforge.plantuml.ugraphic.color.HColor; import net.sourceforge.plantuml.ugraphic.color.HColorUtils; -public class PSystemSalt extends AbstractPSystem implements WithSprite { +public class PSystemSalt extends TitledDiagram implements WithSprite { private final List data; private final Dictionary dictionary = new Dictionary(); @@ -105,20 +115,19 @@ public class PSystemSalt extends AbstractPSystem implements WithSprite { } @Override - final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed) + final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormatOption, long seed) throws IOException { try { final Element salt = createElement(manageSprite()); - final Dimension2D size = salt.getPreferredDimension(fileFormat.getDefaultStringBounder(), 0, 0); + final Dimension2D size = salt.getPreferredDimension(fileFormatOption.getDefaultStringBounder(), 0, 0); - double scale = 1; - if (getScale() != null) { - scale = getScale().getScale(size.getWidth(), size.getHeight()); - } + final Scale scale = getScale(); + final double dpiFactor = scale == null ? getScaleCoef(fileFormatOption) : scale.getScale(100, 100); + final ISkinParam skinParam = getSkinParam(); - final int margin1; - final int margin2; + final double margin1; + final double margin2; if (SkinParam.USE_STYLES()) { margin1 = SkinParam.zeroMargin(5); margin2 = SkinParam.zeroMargin(5); @@ -127,25 +136,52 @@ public class PSystemSalt extends AbstractPSystem implements WithSprite { margin2 = 5; } - final ImageBuilder builder = ImageBuilder.buildB(new ColorMapperIdentity(), false, - ClockwiseTopRightBottomLeft.margin1margin2(margin1, margin2), null, getMetadata(), null, scale, - HColorUtils.WHITE); - builder.setUDrawable(new UDrawable() { + final ImageBuilder imageBuilder = ImageBuilder.buildB(skinParam.getColorMapper(), skinParam.handwritten(), + ClockwiseTopRightBottomLeft.margin1margin2(margin1, margin2), null, + fileFormatOption.isWithMetadata() ? getMetadata() : null, "", dpiFactor, + skinParam.getBackgroundColor(false)); - public void drawU(UGraphic ug) { - ug = ug.apply(HColorUtils.BLACK); - salt.drawU(ug, 0, new Dimension2DDouble(size.getWidth(), size.getHeight())); - salt.drawU(ug, 1, new Dimension2DDouble(size.getWidth(), size.getHeight())); - } - }); - return builder.writeImageTOBEMOVED(fileFormat, seed, os); + TextBlock result = getTextBlock(salt, size); + + result = new AnnotatedWorker(this, skinParam, fileFormatOption.getDefaultStringBounder()).addAdd(result); + imageBuilder.setUDrawable(result); + + return imageBuilder.writeImageTOBEMOVED(fileFormatOption, seed(), os); } catch (Exception e) { e.printStackTrace(); - UmlDiagram.exportDiagramError(os, e, fileFormat, seed, getMetadata(), "none", new ArrayList()); + UmlDiagram.exportDiagramError(os, e, fileFormatOption, seed, getMetadata(), "none", + new ArrayList()); return ImageDataSimple.error(); } } + private TextBlockBackcolored getTextBlock(final Element salt, final Dimension2D size) { + return new TextBlockBackcolored() { + + public void drawU(UGraphic ug) { + ug = ug.apply(HColorUtils.BLACK); + salt.drawU(ug, 0, new Dimension2DDouble(size.getWidth(), size.getHeight())); + salt.drawU(ug, 1, new Dimension2DDouble(size.getWidth(), size.getHeight())); + } + + public Dimension2D calculateDimension(StringBounder stringBounder) { + return size; + } + + public MinMax getMinMax(StringBounder stringBounder) { + throw new UnsupportedOperationException(); + } + + public Rectangle2D getInnerPosition(String member, StringBounder stringBounder, InnerStrategy strategy) { + return null; + } + + public HColor getBackcolor() { + return getSkinParam().getBackgroundColor(false); + } + }; + } + public DiagramDescription getDescription() { return new DiagramDescription("(Salt)"); } @@ -233,4 +269,19 @@ public class PSystemSalt extends AbstractPSystem implements WithSprite { cpxFactory.addFactory(new ElementFactoryText(source, dictionary)); } + private boolean iamSalt; + + public void setIamSalt(boolean iamSalt) { + this.iamSalt = true; + } + + @Override + public UmlDiagramType getUmlDiagramType() { + return UmlDiagramType.SALT; + } + + public final boolean isIamSalt() { + return iamSalt; + } + } diff --git a/src/net/sourceforge/plantuml/salt/PSystemSaltFactory2.java b/src/net/sourceforge/plantuml/salt/PSystemSaltFactory2.java new file mode 100644 index 000000000..69c934179 --- /dev/null +++ b/src/net/sourceforge/plantuml/salt/PSystemSaltFactory2.java @@ -0,0 +1,74 @@ +/* ======================================================================== + * 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.salt; + +import java.util.ArrayList; +import java.util.List; + +import net.sourceforge.plantuml.command.Command; +import net.sourceforge.plantuml.command.PSystemCommandFactory; +import net.sourceforge.plantuml.core.DiagramType; + +public class PSystemSaltFactory2 extends PSystemCommandFactory { + + public PSystemSaltFactory2(DiagramType init) { + super(init); + } + + @Override + protected List createCommands() { + + final List cmds = new ArrayList(); + if (getDiagramType() == DiagramType.UML) { + cmds.add(new CommandSalt()); + } + addCommonCommands2(cmds); + addTitleCommands(cmds); + cmds.add(new CommandAnything()); + + return cmds; + } + + @Override + public PSystemSalt createEmptyDiagram() { + final PSystemSalt result = new PSystemSalt(); + if (getDiagramType() == DiagramType.SALT) { + result.setIamSalt(true); + } + return result; + } + +} diff --git a/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagramFactory.java b/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagramFactory.java index db24a20c1..e24d84f75 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagramFactory.java +++ b/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagramFactory.java @@ -40,7 +40,7 @@ import java.util.List; import net.sourceforge.plantuml.ISkinSimple; import net.sourceforge.plantuml.command.Command; -import net.sourceforge.plantuml.command.UmlDiagramFactory; +import net.sourceforge.plantuml.command.PSystemCommandFactory; import net.sourceforge.plantuml.command.note.sequence.FactorySequenceNoteAcrossCommand; import net.sourceforge.plantuml.command.note.sequence.FactorySequenceNoteCommand; import net.sourceforge.plantuml.command.note.sequence.FactorySequenceNoteOnArrowCommand; @@ -77,7 +77,7 @@ import net.sourceforge.plantuml.sequencediagram.command.CommandReferenceOverSeve import net.sourceforge.plantuml.sequencediagram.command.CommandReturn; import net.sourceforge.plantuml.sequencediagram.command.CommandUrl; -public class SequenceDiagramFactory extends UmlDiagramFactory { +public class SequenceDiagramFactory extends PSystemCommandFactory { private final ISkinSimple skinParam; diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramFileMakerPuma2.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramFileMakerPuma2.java index 9002ff842..99cae55c7 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramFileMakerPuma2.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramFileMakerPuma2.java @@ -51,10 +51,8 @@ import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.activitydiagram3.ftile.EntityImageLegend; import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.DisplayPositionned; import net.sourceforge.plantuml.cucadiagram.DisplaySection; import net.sourceforge.plantuml.graphic.FontConfiguration; -import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlockUtils; @@ -200,18 +198,17 @@ public class SequenceDiagramFileMakerPuma2 implements FileMaker { final String metadata = fileFormatOption.isWithMetadata() ? diagram.getMetadata() : null; - final int margin1; - final int margin2; + final ClockwiseTopRightBottomLeft margins; if (SkinParam.USE_STYLES()) { - margin1 = SkinParam.zeroMargin(3); - margin2 = SkinParam.zeroMargin(10); + final Style style = StyleSignature.of(SName.root, SName.sequenceDiagram, SName.document) + .getMergedStyle(diagram.getSkinParam().getCurrentStyleBuilder()); + // margins = style.getMargin(); + margins = ClockwiseTopRightBottomLeft.topRightBottomLeft(5, 5, 5, 0); } else { - margin1 = 3; - margin2 = 10; + margins = ClockwiseTopRightBottomLeft.topRightBottomLeft(5, 5, 5, 0); } - final ImageBuilder imageBuilder = ImageBuilder.buildD(diagram.getSkinParam(), - ClockwiseTopRightBottomLeft.margin1margin2(margin1, margin2), diagram.getAnimation(), metadata, null, - oneOf(scale, dpiFactor)); + final ImageBuilder imageBuilder = ImageBuilder.buildD(diagram.getSkinParam(), margins, diagram.getAnimation(), + metadata, null, oneOf(scale, dpiFactor)); imageBuilder.setUDrawable(new UDrawable() { public void drawU(UGraphic ug) { diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java index ed99f118f..b1ee438fa 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java @@ -151,17 +151,16 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker { final double scale = 1; final String metadata = fileFormatOption.isWithMetadata() ? diagram.getMetadata() : null; - final int margin1; - final int margin2; + final ClockwiseTopRightBottomLeft margins; if (SkinParam.USE_STYLES()) { - margin1 = SkinParam.zeroMargin(3); - margin2 = SkinParam.zeroMargin(10); + final Style style = StyleSignature.of(SName.root, SName.document) + .getMergedStyle(diagram.getSkinParam().getCurrentStyleBuilder()); + margins = style.getMargin(); } else { - margin1 = 3; - margin2 = 10; + margins = ClockwiseTopRightBottomLeft.topRightBottomLeft(5, 5, 5, 5); } - final ImageBuilder imageBuilder = ImageBuilder.buildD(diagram.getSkinParam(), - ClockwiseTopRightBottomLeft.margin1margin2((double) margin1, (double) margin2), diagram.getAnimation(), + + final ImageBuilder imageBuilder = ImageBuilder.buildD(diagram.getSkinParam(), margins, diagram.getAnimation(), metadata, null, oneOf(scale, dpiFactor)); imageBuilder.setUDrawable(new Foo(index)); diff --git a/src/net/sourceforge/plantuml/skin/AbstractTextualComponent.java b/src/net/sourceforge/plantuml/skin/AbstractTextualComponent.java index d0883b5b4..b8261ad30 100644 --- a/src/net/sourceforge/plantuml/skin/AbstractTextualComponent.java +++ b/src/net/sourceforge/plantuml/skin/AbstractTextualComponent.java @@ -112,7 +112,7 @@ public abstract class AbstractTextualComponent extends AbstractComponent { textBlock = new TextBlockEmpty(); } else if (enhanced) { textBlock = new BodyEnhanced2(this.display, FontParam.NOTE, spriteContainer, horizontalAlignment, fc, - maxMessageSize); + maxMessageSize, spriteContainer.minClassWidth()); } else { textBlock = this.display.create0(fc, horizontalAlignment, spriteContainer, maxMessageSize, CreoleMode.FULL, fontForStereotype, htmlColorForStereotype); diff --git a/src/net/sourceforge/plantuml/sprite/ListSpriteDiagram.java b/src/net/sourceforge/plantuml/sprite/ListSpriteDiagram.java index 70211eb15..102baac12 100644 --- a/src/net/sourceforge/plantuml/sprite/ListSpriteDiagram.java +++ b/src/net/sourceforge/plantuml/sprite/ListSpriteDiagram.java @@ -92,8 +92,9 @@ public class ListSpriteDiagram extends UmlDiagram { margin1 = 10; margin2 = 10; } - final ImageBuilder imageBuilder = ImageBuilder.buildD(getSkinParam(), ClockwiseTopRightBottomLeft.margin1margin2((double) margin1, (double) margin2), getAnimation(), fileFormatOption.isWithMetadata() ? getMetadata() : null, - getWarningOrError(), dpiFactor); + final ImageBuilder imageBuilder = ImageBuilder.buildD(getSkinParam(), + ClockwiseTopRightBottomLeft.margin1margin2(margin1, margin2), getAnimation(), + fileFormatOption.isWithMetadata() ? getMetadata() : null, getWarningOrError(), dpiFactor); imageBuilder.setUDrawable(result); return imageBuilder.writeImageTOBEMOVED(fileFormatOption, seed(), os); diff --git a/src/net/sourceforge/plantuml/sprite/ListSpriteDiagramFactory.java b/src/net/sourceforge/plantuml/sprite/ListSpriteDiagramFactory.java index 1f58ba03b..495276358 100644 --- a/src/net/sourceforge/plantuml/sprite/ListSpriteDiagramFactory.java +++ b/src/net/sourceforge/plantuml/sprite/ListSpriteDiagramFactory.java @@ -40,9 +40,9 @@ import java.util.List; import net.sourceforge.plantuml.ISkinSimple; import net.sourceforge.plantuml.command.Command; -import net.sourceforge.plantuml.command.UmlDiagramFactory; +import net.sourceforge.plantuml.command.PSystemCommandFactory; -public class ListSpriteDiagramFactory extends UmlDiagramFactory { +public class ListSpriteDiagramFactory extends PSystemCommandFactory { private final ISkinSimple skinParam; diff --git a/src/net/sourceforge/plantuml/sprite/StdlibDiagram.java b/src/net/sourceforge/plantuml/sprite/StdlibDiagram.java index 9ae7cd145..dda08f3f1 100644 --- a/src/net/sourceforge/plantuml/sprite/StdlibDiagram.java +++ b/src/net/sourceforge/plantuml/sprite/StdlibDiagram.java @@ -101,8 +101,9 @@ public class StdlibDiagram extends UmlDiagram { margin1 = 10; margin2 = 10; } - final ImageBuilder imageBuilder = ImageBuilder.buildD(getSkinParam(), ClockwiseTopRightBottomLeft.margin1margin2((double) margin1, (double) margin2), getAnimation(), fileFormatOption.isWithMetadata() ? getMetadata() : null, - getWarningOrError(), dpiFactor); + final ImageBuilder imageBuilder = ImageBuilder.buildD(getSkinParam(), + ClockwiseTopRightBottomLeft.margin1margin2(margin1, margin2), getAnimation(), + fileFormatOption.isWithMetadata() ? getMetadata() : null, getWarningOrError(), dpiFactor); imageBuilder.setUDrawable(result); return imageBuilder.writeImageTOBEMOVED(fileFormatOption, seed(), os); diff --git a/src/net/sourceforge/plantuml/sprite/StdlibDiagramFactory.java b/src/net/sourceforge/plantuml/sprite/StdlibDiagramFactory.java index b2d427689..cb26b6e32 100644 --- a/src/net/sourceforge/plantuml/sprite/StdlibDiagramFactory.java +++ b/src/net/sourceforge/plantuml/sprite/StdlibDiagramFactory.java @@ -40,9 +40,9 @@ import java.util.List; import net.sourceforge.plantuml.ISkinSimple; import net.sourceforge.plantuml.command.Command; -import net.sourceforge.plantuml.command.UmlDiagramFactory; +import net.sourceforge.plantuml.command.PSystemCommandFactory; -public class StdlibDiagramFactory extends UmlDiagramFactory { +public class StdlibDiagramFactory extends PSystemCommandFactory { private final ISkinSimple skinParam; diff --git a/src/net/sourceforge/plantuml/statediagram/StateDiagramFactory.java b/src/net/sourceforge/plantuml/statediagram/StateDiagramFactory.java index 0f54ec44b..2a6cccb93 100644 --- a/src/net/sourceforge/plantuml/statediagram/StateDiagramFactory.java +++ b/src/net/sourceforge/plantuml/statediagram/StateDiagramFactory.java @@ -46,7 +46,7 @@ import net.sourceforge.plantuml.classdiagram.command.CommandUrl; import net.sourceforge.plantuml.command.Command; import net.sourceforge.plantuml.command.CommandFootboxIgnored; import net.sourceforge.plantuml.command.CommandRankDir; -import net.sourceforge.plantuml.command.UmlDiagramFactory; +import net.sourceforge.plantuml.command.PSystemCommandFactory; import net.sourceforge.plantuml.command.note.CommandFactoryNote; import net.sourceforge.plantuml.command.note.CommandFactoryNoteOnEntity; import net.sourceforge.plantuml.command.note.CommandFactoryNoteOnLink; @@ -59,7 +59,7 @@ import net.sourceforge.plantuml.statediagram.command.CommandCreateState; import net.sourceforge.plantuml.statediagram.command.CommandEndState; import net.sourceforge.plantuml.statediagram.command.CommandLinkState; -public class StateDiagramFactory extends UmlDiagramFactory { +public class StateDiagramFactory extends PSystemCommandFactory { private final ISkinSimple skinParam; diff --git a/src/net/sourceforge/plantuml/style/ClockwiseTopRightBottomLeft.java b/src/net/sourceforge/plantuml/style/ClockwiseTopRightBottomLeft.java index ba02f6ac3..83bdb5a96 100644 --- a/src/net/sourceforge/plantuml/style/ClockwiseTopRightBottomLeft.java +++ b/src/net/sourceforge/plantuml/style/ClockwiseTopRightBottomLeft.java @@ -80,7 +80,11 @@ public class ClockwiseTopRightBottomLeft { } public static ClockwiseTopRightBottomLeft margin1margin2(double margin1, double margin2) { - return new ClockwiseTopRightBottomLeft(margin1, margin2, margin2, margin1); + return topRightBottomLeft(margin1, margin2, margin1, margin2); + } + + public static ClockwiseTopRightBottomLeft topRightBottomLeft(double top, double right, double bottom, double left) { + return new ClockwiseTopRightBottomLeft(top, right, bottom, left); } private ClockwiseTopRightBottomLeft(double top, double right, double bottom, double left) { diff --git a/src/net/sourceforge/plantuml/style/SName.java b/src/net/sourceforge/plantuml/style/SName.java index ba58f4afc..79fbc14d7 100644 --- a/src/net/sourceforge/plantuml/style/SName.java +++ b/src/net/sourceforge/plantuml/style/SName.java @@ -92,6 +92,7 @@ public enum SName { referenceHeader, // root, // rootNode, // + saltDiagram, // separator, // sequenceDiagram, // stack, // diff --git a/src/net/sourceforge/plantuml/svek/CircleInterface2.java b/src/net/sourceforge/plantuml/svek/CircleInterface2.java index 66906fded..c60b5ebca 100644 --- a/src/net/sourceforge/plantuml/svek/CircleInterface2.java +++ b/src/net/sourceforge/plantuml/svek/CircleInterface2.java @@ -43,7 +43,6 @@ import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.ugraphic.UEllipse; import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.color.HColor; @@ -55,7 +54,6 @@ public class CircleInterface2 extends AbstractTextBlock implements TextBlock { private final HColor backgroundColor; private final HColor foregroundColor; - private final float thickness = 2; private final double deltaShadow; @@ -70,8 +68,7 @@ public class CircleInterface2 extends AbstractTextBlock implements TextBlock { double y = 0; x += margin; y += margin; - ug = ug.apply(new UStroke(thickness)).apply(backgroundColor.bg()) - .apply(foregroundColor); + ug = ug.apply(backgroundColor.bg()).apply(foregroundColor); final UEllipse circle = new UEllipse(radius * 2, radius * 2); circle.setDeltaShadow(deltaShadow); ug.apply(new UTranslate(x, y)).draw(circle); diff --git a/src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek.java b/src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek.java index 953cac707..89218a566 100644 --- a/src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek.java +++ b/src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek.java @@ -134,7 +134,7 @@ public final class CucaDiagramFileMakerSvek implements CucaDiagramFileMaker { .getMergedStyle(diagram.getSkinParam().getCurrentStyleBuilder()); margins = style.getMargin(); } else { - margins = ClockwiseTopRightBottomLeft.margin1margin2(0, 10); + margins = ClockwiseTopRightBottomLeft.topRightBottomLeft(0, 5, 5, 0); } final ImageBuilder imageBuilder = ImageBuilder.buildC(diagram.getSkinParam(), margins, diagram.getAnimation(), fileFormatOption.isWithMetadata() ? diagram.getMetadata() : null, warningOrError, scale, backcolor); diff --git a/src/net/sourceforge/plantuml/svek/GuideLine.java b/src/net/sourceforge/plantuml/svek/GuideLine.java index b021f9c4e..18ef94b9b 100644 --- a/src/net/sourceforge/plantuml/svek/GuideLine.java +++ b/src/net/sourceforge/plantuml/svek/GuideLine.java @@ -41,4 +41,6 @@ public interface GuideLine { public Direction getArrowDirection(); + public double getArrowDirection2(); + } diff --git a/src/net/sourceforge/plantuml/svek/Line.java b/src/net/sourceforge/plantuml/svek/Line.java index 5cbd155bf..fa8f709eb 100644 --- a/src/net/sourceforge/plantuml/svek/Line.java +++ b/src/net/sourceforge/plantuml/svek/Line.java @@ -175,6 +175,24 @@ public class Line implements Moveable, Hideable, GuideLine { return end.getX() > start.getX() ? Direction.RIGHT : Direction.LEFT; } + public double getArrowDirection2() { + if (getLinkArrow() == LinkArrow.BACKWARD) { + return Math.PI + getArrowDirectionInternal2(); + } + return getArrowDirectionInternal2(); + } + + private double getArrowDirectionInternal2() { + if (isAutolink()) { + final double startAngle = dotPath.getStartAngle(); + return startAngle; + } + final Point2D start = dotPath.getStartPoint(); + final Point2D end = dotPath.getEndPoint(); + final double ang = Math.atan2(end.getX() - start.getX(), end.getY() - start.getY()); + return ang; + } + private Cluster getCluster2(Bibliotekon bibliotekon, IEntity entityMutable) { for (Cluster cl : bibliotekon.allCluster()) { if (cl.getGroups().contains(entityMutable)) { diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageDescription.java b/src/net/sourceforge/plantuml/svek/image/EntityImageDescription.java index 113fde69b..37dd130e7 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageDescription.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageDescription.java @@ -48,6 +48,7 @@ import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.SkinParamUtils; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.cucadiagram.BodyEnhanced; +import net.sourceforge.plantuml.cucadiagram.BodyEnhanced2; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.EntityPortion; import net.sourceforge.plantuml.cucadiagram.IEntity; @@ -100,8 +101,8 @@ public class EntityImageDescription extends AbstractEntityImage { public EntityImageDescription(ILeaf entity, ISkinParam skinParam, PortionShower portionShower, Collection links, SName styleName, UStroke forceStroke) { super(entity, entity.getColors(skinParam).mute(skinParam)); - this.useRankSame = skinParam.useRankSame(); - this.fixCircleLabelOverlapping = skinParam.fixCircleLabelOverlapping(); + this.useRankSame = getSkinParam().useRankSame(); + this.fixCircleLabelOverlapping = getSkinParam().fixCircleLabelOverlapping(); this.links = links; final Stereotype stereotype = entity.getStereotype(); @@ -109,23 +110,13 @@ public class EntityImageDescription extends AbstractEntityImage { if (symbol == USymbol.FOLDER) { this.shapeType = ShapeType.FOLDER; } else if (symbol == USymbol.INTERFACE) { - this.shapeType = skinParam.fixCircleLabelOverlapping() ? ShapeType.RECTANGLE_WITH_CIRCLE_INSIDE + this.shapeType = getSkinParam().fixCircleLabelOverlapping() ? ShapeType.RECTANGLE_WITH_CIRCLE_INSIDE : ShapeType.RECTANGLE; } else { this.shapeType = ShapeType.RECTANGLE; } this.hideText = symbol == USymbol.INTERFACE; - final Display codeDisplay = Display.getWithNewlines(entity.getCodeGetName()); - if ((entity.getDisplay().equals(codeDisplay) && symbol.getSkinParameter() == SkinParameter.PACKAGE) - || entity.getDisplay().isWhite()) { - desc = TextBlockUtils.empty(skinParam.minClassWidth(), 0); - } else { - desc = new BodyEnhanced(entity.getDisplay(), symbol.getFontParam(), getSkinParam(), - HorizontalAlignment.LEFT, stereotype, symbol.manageHorizontalLine(), false, entity, - skinParam.minClassWidth(), SName.componentDiagram); - } - this.url = entity.getUrl99(); final Colors colors = entity.getColors(skinParam); @@ -163,10 +154,26 @@ public class EntityImageDescription extends AbstractEntityImage { } assert getStereo() == stereotype; - + final SymbolContext ctx = new SymbolContext(backcolor, forecolor).withStroke(stroke).withShadow(deltaShadow) .withCorner(roundCorner, diagonalCorner); + final Display codeDisplay = Display.getWithNewlines(entity.getCodeGetName()); + if ((entity.getDisplay().equals(codeDisplay) && symbol.getSkinParameter() == SkinParameter.PACKAGE) + || entity.getDisplay().isWhite()) { + desc = TextBlockUtils.empty(getSkinParam().minClassWidth(), 0); + } else { + final FontConfiguration titleConfig = new FontConfiguration(getSkinParam(), symbol.getFontParam(), + stereotype); + + desc = new BodyEnhanced2(entity.getDisplay(), symbol.getFontParam(), getSkinParam(), + getSkinParam().getDefaultTextAlignment(HorizontalAlignment.LEFT), titleConfig, + getSkinParam().wrapWidth(), getSkinParam().minClassWidth()); +// desc = new BodyEnhanced(entity.getDisplay(), symbol.getFontParam(), getSkinParam(), +// HorizontalAlignment.LEFT, stereotype, symbol.manageHorizontalLine(), false, entity, +// skinParam.minClassWidth(), SName.componentDiagram); + } + stereo = TextBlockUtils.empty(0, 0); if (stereotype != null && stereotype.getSprite(getSkinParam()) != null) { diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageNote.java b/src/net/sourceforge/plantuml/svek/image/EntityImageNote.java index d8397af91..ac77b3728 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageNote.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageNote.java @@ -126,7 +126,8 @@ public class EntityImageNote extends AbstractEntityImage implements Stencil { textBlock = new TextBlockEmpty(); } else { textBlock = new BodyEnhanced2(strings, FontParam.NOTE, getSkinParam(), HorizontalAlignment.LEFT, - new FontConfiguration(getSkinParam(), FontParam.NOTE, null), getSkinParam().wrapWidth()); + new FontConfiguration(getSkinParam(), FontParam.NOTE, null), getSkinParam().wrapWidth(), + getSkinParam().minClassWidth()); } } diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageTips.java b/src/net/sourceforge/plantuml/svek/image/EntityImageTips.java index 79a8efa79..98ebf1c79 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageTips.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageTips.java @@ -162,8 +162,9 @@ public class EntityImageTips extends AbstractEntityImage { // final HtmlColor fontColor = rose.getFontColor(skinParam, FontParam.NOTE); // final UFont fontNote = skinParam.getFont(FontParam.NOTE, null, false); final TextBlock textBlock = new BodyEnhanced2(display, FontParam.NOTE, skinParam, HorizontalAlignment.LEFT, - new FontConfiguration(skinParam, FontParam.NOTE, null), LineBreakStrategy.NONE); - final double shadowing = skinParam.shadowing(getEntity().getStereotype())?4:0; + new FontConfiguration(skinParam, FontParam.NOTE, null), LineBreakStrategy.NONE, + skinParam.minClassWidth()); + final double shadowing = skinParam.shadowing(getEntity().getStereotype()) ? 4 : 0; final Opale opale = new Opale(shadowing, borderColor, noteBackgroundColor, textBlock, true); return opale; } diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageUseCase.java b/src/net/sourceforge/plantuml/svek/image/EntityImageUseCase.java index 4e8c40b47..9e9e19b2f 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageUseCase.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageUseCase.java @@ -42,6 +42,7 @@ import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.Guillemet; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.LineParam; +import net.sourceforge.plantuml.SkinParam; import net.sourceforge.plantuml.SkinParamUtils; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.creole.Stencil; @@ -58,7 +59,10 @@ import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.graphic.color.ColorType; +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.AbstractEntityImage; import net.sourceforge.plantuml.svek.ShapeType; import net.sourceforge.plantuml.ugraphic.AbstractUGraphicHorizontalLine; @@ -102,6 +106,10 @@ public class EntityImageUseCase extends AbstractEntityImage { } private UStroke getStroke() { + if (SkinParam.USE_STYLES()) { + final Style style = getDefaultStyleDefinition().getMergedStyle(getSkinParam().getCurrentStyleBuilder()); + return style.getStroke(); + } UStroke stroke = getSkinParam().getThickness(LineParam.usecaseBorder, getStereo()); if (stroke == null) { @@ -126,15 +134,9 @@ public class EntityImageUseCase extends AbstractEntityImage { } ug = ug.apply(getStroke()); - HColor linecolor = getEntity().getColors(getSkinParam()).getColor(ColorType.LINE); - if (linecolor == null) { - linecolor = SkinParamUtils.getColor(getSkinParam(), getStereo(), ColorParam.usecaseBorder); - } + final HColor linecolor = getLineColor(); ug = ug.apply(linecolor); - HColor backcolor = getEntity().getColors(getSkinParam()).getColor(ColorType.BACK); - if (backcolor == null) { - backcolor = SkinParamUtils.getColor(getSkinParam(), getStereo(), ColorParam.usecaseBackground); - } + final HColor backcolor = getBackColor(); ug = ug.apply(backcolor.bg()); final UGraphic ug2 = new MyUGraphicEllipse(ug, 0, 0, ellipse.getUEllipse()); @@ -145,6 +147,36 @@ public class EntityImageUseCase extends AbstractEntityImage { } } + private HColor getBackColor() { + HColor backcolor = getEntity().getColors(getSkinParam()).getColor(ColorType.BACK); + if (backcolor == null) { + if (SkinParam.USE_STYLES()) { + final Style style = getDefaultStyleDefinition().getMergedStyle(getSkinParam().getCurrentStyleBuilder()); + backcolor = style.value(PName.BackGroundColor).asColor(getSkinParam().getIHtmlColorSet()); + } else { + backcolor = SkinParamUtils.getColor(getSkinParam(), getStereo(), ColorParam.usecaseBackground); + } + } + return backcolor; + } + + private StyleSignature getDefaultStyleDefinition() { + return StyleSignature.of(SName.root, SName.element, SName.componentDiagram, SName.usecase); + } + + private HColor getLineColor() { + HColor linecolor = getEntity().getColors(getSkinParam()).getColor(ColorType.LINE); + if (linecolor == null) { + if (SkinParam.USE_STYLES()) { + final Style style = getDefaultStyleDefinition().getMergedStyle(getSkinParam().getCurrentStyleBuilder()); + linecolor = style.value(PName.LineColor).asColor(getSkinParam().getIHtmlColorSet()); + } else { + linecolor = SkinParamUtils.getColor(getSkinParam(), getStereo(), ColorParam.usecaseBorder); + } + } + return linecolor; + } + public ShapeType getShapeType() { return ShapeType.OVAL; } diff --git a/src/net/sourceforge/plantuml/svek/image/Footprint.java b/src/net/sourceforge/plantuml/svek/image/Footprint.java index 2935fae3b..7031efd61 100644 --- a/src/net/sourceforge/plantuml/svek/image/Footprint.java +++ b/src/net/sourceforge/plantuml/svek/image/Footprint.java @@ -44,6 +44,7 @@ import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.ugraphic.UBackground; import net.sourceforge.plantuml.ugraphic.UChange; +import net.sourceforge.plantuml.ugraphic.UEmpty; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphicNo; import net.sourceforge.plantuml.ugraphic.UHorizontalLine; @@ -125,6 +126,8 @@ public class Footprint { drawPath(x, y, (UPath) shape); } else if (shape instanceof URectangle) { drawRectangle(x, y, (URectangle) shape); + } else if (shape instanceof UEmpty) { + drawEmpty(x, y, (UEmpty) shape); } else { throw new UnsupportedOperationException(shape.getClass().toString()); } @@ -165,6 +168,11 @@ public class Footprint { addPoint(x + rect.getWidth(), y + rect.getHeight()); } + private void drawEmpty(double x, double y, UEmpty rect) { + addPoint(x, y); + addPoint(x + rect.getWidth(), y + rect.getHeight()); + } + public void flushUg() { } diff --git a/src/net/sourceforge/plantuml/syntax/LanguageDescriptor.java b/src/net/sourceforge/plantuml/syntax/LanguageDescriptor.java index 1b973ca8e..723fb3b64 100644 --- a/src/net/sourceforge/plantuml/syntax/LanguageDescriptor.java +++ b/src/net/sourceforge/plantuml/syntax/LanguageDescriptor.java @@ -161,7 +161,18 @@ public class LanguageDescriptor { keyword.add("stereotype"); keyword.add("split"); keyword.add("style"); - keyword.add("sprite"); + keyword.add("sprite"); + keyword.add("circle"); + keyword.add("empty"); + keyword.add("members"); + keyword.add("description"); + keyword.add("true"); + keyword.add("false"); + keyword.add("normal"); + keyword.add("italic"); + keyword.add("bold"); + keyword.add("plain"); + preproc.add("!exit"); preproc.add("!include"); diff --git a/src/net/sourceforge/plantuml/timingdiagram/TimingDiagram.java b/src/net/sourceforge/plantuml/timingdiagram/TimingDiagram.java index a357f3d49..c40b149de 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/TimingDiagram.java +++ b/src/net/sourceforge/plantuml/timingdiagram/TimingDiagram.java @@ -111,8 +111,9 @@ public class TimingDiagram extends UmlDiagram implements Clocks { margin1 = 10; margin2 = 10; } - final ImageBuilder imageBuilder = ImageBuilder.buildD(getSkinParam(), ClockwiseTopRightBottomLeft.margin1margin2((double) margin1, (double) margin2), getAnimation(), fileFormatOption.isWithMetadata() ? getMetadata() : null, - getWarningOrError(), dpiFactor); + final ImageBuilder imageBuilder = ImageBuilder.buildD(getSkinParam(), + ClockwiseTopRightBottomLeft.margin1margin2(margin1, margin2), getAnimation(), + fileFormatOption.isWithMetadata() ? getMetadata() : null, getWarningOrError(), dpiFactor); TextBlock result = getTextBlock(); final ISkinParam skinParam = getSkinParam(); diff --git a/src/net/sourceforge/plantuml/timingdiagram/TimingDiagramFactory.java b/src/net/sourceforge/plantuml/timingdiagram/TimingDiagramFactory.java index d86ee96b7..76df98d01 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/TimingDiagramFactory.java +++ b/src/net/sourceforge/plantuml/timingdiagram/TimingDiagramFactory.java @@ -40,7 +40,7 @@ import java.util.List; import net.sourceforge.plantuml.command.Command; import net.sourceforge.plantuml.command.CommandFootboxIgnored; -import net.sourceforge.plantuml.command.UmlDiagramFactory; +import net.sourceforge.plantuml.command.PSystemCommandFactory; import net.sourceforge.plantuml.timingdiagram.command.CommandAnalog; import net.sourceforge.plantuml.timingdiagram.command.CommandAtPlayer; import net.sourceforge.plantuml.timingdiagram.command.CommandAtTime; @@ -62,7 +62,7 @@ import net.sourceforge.plantuml.timingdiagram.command.CommandScalePixel; import net.sourceforge.plantuml.timingdiagram.command.CommandTicks; import net.sourceforge.plantuml.timingdiagram.command.CommandTimeMessage; -public class TimingDiagramFactory extends UmlDiagramFactory { +public class TimingDiagramFactory extends PSystemCommandFactory { @Override public TimingDiagram createEmptyDiagram() { diff --git a/src/net/sourceforge/plantuml/timingdiagram/command/CommandConstraint.java b/src/net/sourceforge/plantuml/timingdiagram/command/CommandConstraint.java index 2362f8b2d..264aba858 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/command/CommandConstraint.java +++ b/src/net/sourceforge/plantuml/timingdiagram/command/CommandConstraint.java @@ -84,6 +84,9 @@ public class CommandConstraint extends SingleLineCommand2 { } } else { player1 = diagram.getPlayer(part1); + if (player1 == null) { + return CommandExecutionResult.error("No such participant " + part1); + } } final TimeTick tick1 = TimeTickBuilder.parseTimeTick("TIME1", arg, diagram); diagram.updateNow(tick1); diff --git a/src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java b/src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java index 8a5f06105..3463aea4f 100644 --- a/src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java +++ b/src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java @@ -215,36 +215,7 @@ public class ImageBuilder { return writeImageInternal(fileFormatOption, seed, os, animation); } - private static Semaphore SEMAPHORE_SMALL; - private static Semaphore SEMAPHORE_BIG; - private static int MAX_PRICE = 0; - public static void setMaxPixel(int max) { - MAX_PRICE = max / 2; - SEMAPHORE_SMALL = new Semaphore(MAX_PRICE, true); - SEMAPHORE_BIG = new Semaphore(MAX_PRICE, true); - } - - private int getPrice(FileFormatOption fileFormatOption, Dimension2D dim) { - // if (fileFormatOption.getFileFormat() != FileFormat.PNG) { - // return 0; - // } - if (MAX_PRICE == 0) { - return 0; - } - final int price = Math.min(MAX_PRICE, - ((int) (dim.getHeight() * dpiFactor)) * ((int) (dim.getWidth() * dpiFactor))); - return price; - } - - private Semaphore getSemaphore(int price) { - if (price == 0) { - return null; - } - if (price == MAX_PRICE) { - return SEMAPHORE_BIG; - } - return SEMAPHORE_SMALL; } private ImageData writeImageInternal(FileFormatOption fileFormatOption, long seed, OutputStream os, @@ -260,57 +231,32 @@ public class ImageBuilder { dy = -minmax.getMinY(); } - final int price = getPrice(fileFormatOption, dim); - final Semaphore semaphore = getSemaphore(price); - if (semaphore != null) { - try { - semaphore.acquire(price); - } catch (InterruptedException e) { - e.printStackTrace(); - throw new IOException(e); + final UGraphic2 ug = createUGraphic(fileFormatOption, seed, dim, animationArg, dx, dy); + UGraphic ug2 = ug; + if (borderStroke != null) { + final HColor color = borderColor == null ? HColorUtils.BLACK : borderColor; + final URectangle shape = new URectangle(dim.getWidth() - borderStroke.getThickness(), + dim.getHeight() - borderStroke.getThickness()).rounded(borderCorner); + ug2.apply(color).apply(borderStroke).draw(shape); + } + if (randomPixel) { + drawRandomPoint(ug2); + } + ug2 = ug2.apply(new UTranslate(left, top)); + final UGraphic ugDecored = handwritten(ug2); + udrawable.drawU(ugDecored); + ugDecored.flushUg(); + ug.writeImageTOBEMOVED(os, metadata, 96); + os.flush(); + + if (ug instanceof UGraphicG2d) { + final Set urls = ((UGraphicG2d) ug).getAllUrlsEncountered(); + if (urls.size() > 0) { + final CMapData cmap = CMapData.cmapString(urls, dpiFactor); + return new ImageDataComplex(dim, cmap, warningOrError); } } - try { - final UGraphic2 ug = createUGraphic(fileFormatOption, seed, dim, animationArg, dx, dy); - UGraphic ug2 = ug; -// if (externalMargin1 > 0) { -// ug2 = ug2.apply(new UTranslate(externalMargin1, externalMargin1)); -// } - if (borderStroke != null) { - final HColor color = borderColor == null ? HColorUtils.BLACK : borderColor; -// final URectangle shape = new URectangle(dim.getWidth() - externalMargin() - borderStroke.getThickness(), -// dim.getHeight() - externalMargin() - borderStroke.getThickness()).rounded(borderCorner); - final URectangle shape = new URectangle(dim.getWidth() - borderStroke.getThickness(), - dim.getHeight() - borderStroke.getThickness()).rounded(borderCorner); - ug2.apply(color).apply(borderStroke).draw(shape); - } - if (randomPixel) { - drawRandomPoint(ug2); - } -// if (externalMargin1 > 0) { -// ug2 = ug2.apply(new UTranslate(externalMargin2, externalMargin2)); -// } - ug2 = ug2.apply(new UTranslate(left, top)); - final UGraphic ugDecored = handwritten(ug2); - udrawable.drawU(ugDecored); - ugDecored.flushUg(); - ug.writeImageTOBEMOVED(os, metadata, 96); - os.flush(); - - if (ug instanceof UGraphicG2d) { - final Set urls = ((UGraphicG2d) ug).getAllUrlsEncountered(); - if (urls.size() > 0) { - final CMapData cmap = CMapData.cmapString(urls, dpiFactor); - return new ImageDataComplex(dim, cmap, warningOrError); - } - } - return new ImageDataSimple(dim); - } finally { - if (semaphore != null) { - semaphore.release(price); - } - } - + return new ImageDataSimple(dim); } private void drawRandomPoint(UGraphic ug2) { @@ -324,10 +270,6 @@ public class ImageBuilder { } -// private double externalMargin() { -// return 2 * (externalMargin1 + externalMargin2); -// } - public Dimension2D getFinalDimension(StringBounder stringBounder) { final Dimension2D dim; @@ -335,8 +277,6 @@ public class ImageBuilder { udrawable.drawU(limitFinder); dim = new Dimension2DDouble(limitFinder.getMaxX(), limitFinder.getMaxY()); -// return new Dimension2DDouble(dim.getWidth() + 1 + margin1 + margin2 + externalMargin(), -// dim.getHeight() + 1 + margin1 + margin2 + externalMargin()); return new Dimension2DDouble(dim.getWidth() + 1 + left + right, dim.getHeight() + 1 + top + bottom); } @@ -467,8 +407,8 @@ public class ImageBuilder { preserveAspectRatio); } else { final String tmp = colorMapper.toSvg(backColor); - ug = new UGraphicSvg(svgDimensionStyle, dim, colorMapper, tmp, false, scale, - svgLinkTarget, hover, seed, preserveAspectRatio); + ug = new UGraphicSvg(svgDimensionStyle, dim, colorMapper, tmp, false, scale, svgLinkTarget, hover, seed, + preserveAspectRatio); } return ug; @@ -483,17 +423,10 @@ public class ImageBuilder { backColor = null; } - /* - * if (rotation) { builder = new EmptyImageBuilder((int) (dim.getHeight() * - * dpiFactor), (int) (dim.getWidth() * dpiFactor), backColor); graphics2D = - * builder.getGraphics2D(); graphics2D.rotate(-Math.PI / 2); - * graphics2D.translate(-builder.getBufferedImage().getHeight(), 0); } else { - */ final EmptyImageBuilder builder = new EmptyImageBuilder(watermark, (int) (dim.getWidth() * dpiFactor), (int) (dim.getHeight() * dpiFactor), backColor); final Graphics2D graphics2D = builder.getGraphics2D(); - // } final UGraphicG2d ug = new UGraphicG2d(colorMapper, graphics2D, dpiFactor, affineTransforms == null ? null : affineTransforms.getFirst(), dx, dy); ug.setBufferedImage(builder.getBufferedImage()); diff --git a/src/net/sourceforge/plantuml/ugraphic/UEmpty.java b/src/net/sourceforge/plantuml/ugraphic/UEmpty.java index bcfb10177..4eb90f444 100644 --- a/src/net/sourceforge/plantuml/ugraphic/UEmpty.java +++ b/src/net/sourceforge/plantuml/ugraphic/UEmpty.java @@ -34,6 +34,8 @@ */ package net.sourceforge.plantuml.ugraphic; +import java.awt.geom.Dimension2D; + public class UEmpty implements UShape { private final double width; @@ -47,6 +49,10 @@ public class UEmpty implements UShape { this.height = height; } + public UEmpty(Dimension2D dim) { + this(dim.getWidth(), dim.getHeight()); + } + public double getWidth() { return width; } diff --git a/src/net/sourceforge/plantuml/version/Version.java b/src/net/sourceforge/plantuml/version/Version.java index 58871d92b..622feefd2 100644 --- a/src/net/sourceforge/plantuml/version/Version.java +++ b/src/net/sourceforge/plantuml/version/Version.java @@ -44,7 +44,7 @@ public class Version { private static final int MAJOR_SEPARATOR = 1000000; public static int version() { - return 1202017; + return 1202018; } public static int versionPatched() { @@ -93,7 +93,7 @@ public class Version { } public static long compileTime() { - return 1600518611890L; + return 1601494844773L; } public static String compileTimeString() { diff --git a/src/net/sourceforge/plantuml/wbs/WBSDiagram.java b/src/net/sourceforge/plantuml/wbs/WBSDiagram.java index 0c0ab76df..c68e060ab 100644 --- a/src/net/sourceforge/plantuml/wbs/WBSDiagram.java +++ b/src/net/sourceforge/plantuml/wbs/WBSDiagram.java @@ -84,8 +84,8 @@ public class WBSDiagram extends UmlDiagram { final double dpiFactor = scale == null ? getScaleCoef(fileFormatOption) : scale.getScale(100, 100); final ISkinParam skinParam = getSkinParam(); - final int margin1; - final int margin2; + final double margin1; + final double margin2; if (SkinParam.USE_STYLES()) { margin1 = SkinParam.zeroMargin(10); margin2 = SkinParam.zeroMargin(10); @@ -93,8 +93,10 @@ public class WBSDiagram extends UmlDiagram { margin1 = 10; margin2 = 10; } - final ImageBuilder imageBuilder = ImageBuilder.buildB(skinParam.getColorMapper(), skinParam.handwritten(), ClockwiseTopRightBottomLeft.margin1margin2((double) margin1, (double) margin2), - null, fileFormatOption.isWithMetadata() ? getMetadata() : null, "", dpiFactor, skinParam.getBackgroundColor(false)); + final ImageBuilder imageBuilder = ImageBuilder.buildB(skinParam.getColorMapper(), skinParam.handwritten(), + ClockwiseTopRightBottomLeft.margin1margin2(margin1, margin2), null, + fileFormatOption.isWithMetadata() ? getMetadata() : null, "", dpiFactor, + skinParam.getBackgroundColor(false)); TextBlock result = getTextBlock(); result = new AnnotatedWorker(this, skinParam, fileFormatOption.getDefaultStringBounder()).addAdd(result); diff --git a/src/net/sourceforge/plantuml/wbs/WBSDiagramFactory.java b/src/net/sourceforge/plantuml/wbs/WBSDiagramFactory.java index 9ad83b855..c898d3545 100644 --- a/src/net/sourceforge/plantuml/wbs/WBSDiagramFactory.java +++ b/src/net/sourceforge/plantuml/wbs/WBSDiagramFactory.java @@ -39,10 +39,10 @@ import java.util.ArrayList; import java.util.List; import net.sourceforge.plantuml.command.Command; -import net.sourceforge.plantuml.command.UmlDiagramFactory; +import net.sourceforge.plantuml.command.PSystemCommandFactory; import net.sourceforge.plantuml.core.DiagramType; -public class WBSDiagramFactory extends UmlDiagramFactory { +public class WBSDiagramFactory extends PSystemCommandFactory { public WBSDiagramFactory() { super(DiagramType.WBS); diff --git a/src/net/sourceforge/plantuml/wire/WireDiagram.java b/src/net/sourceforge/plantuml/wire/WireDiagram.java index d41399c19..a47dbc9bb 100644 --- a/src/net/sourceforge/plantuml/wire/WireDiagram.java +++ b/src/net/sourceforge/plantuml/wire/WireDiagram.java @@ -83,7 +83,7 @@ public class WireDiagram extends UmlDiagram { final double dpiFactor = scale == null ? getScaleCoef(fileFormatOption) : scale.getScale(100, 100); final ISkinParam skinParam = getSkinParam(); - + final int margin1; final int margin2; if (SkinParam.USE_STYLES()) { @@ -93,8 +93,10 @@ public class WireDiagram extends UmlDiagram { margin1 = 10; margin2 = 10; } - final ImageBuilder imageBuilder = ImageBuilder.buildB(skinParam.getColorMapper(), skinParam.handwritten(), ClockwiseTopRightBottomLeft.margin1margin2((double) margin1, (double) margin2), - null, fileFormatOption.isWithMetadata() ? getMetadata() : null, "", dpiFactor, skinParam.getBackgroundColor(false)); + final ImageBuilder imageBuilder = ImageBuilder.buildB(skinParam.getColorMapper(), skinParam.handwritten(), + ClockwiseTopRightBottomLeft.margin1margin2(margin1, margin2), null, + fileFormatOption.isWithMetadata() ? getMetadata() : null, "", dpiFactor, + skinParam.getBackgroundColor(false)); TextBlock result = getTextBlock(); result = new AnnotatedWorker(this, skinParam, fileFormatOption.getDefaultStringBounder()).addAdd(result); diff --git a/src/net/sourceforge/plantuml/wire/WireDiagramFactory.java b/src/net/sourceforge/plantuml/wire/WireDiagramFactory.java index e15d2b5c4..954050c69 100644 --- a/src/net/sourceforge/plantuml/wire/WireDiagramFactory.java +++ b/src/net/sourceforge/plantuml/wire/WireDiagramFactory.java @@ -39,10 +39,10 @@ import java.util.ArrayList; import java.util.List; import net.sourceforge.plantuml.command.Command; -import net.sourceforge.plantuml.command.UmlDiagramFactory; +import net.sourceforge.plantuml.command.PSystemCommandFactory; import net.sourceforge.plantuml.core.DiagramType; -public class WireDiagramFactory extends UmlDiagramFactory { +public class WireDiagramFactory extends PSystemCommandFactory { public WireDiagramFactory() { super(DiagramType.WIRE);