summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Shadura <andrew@shadura.me>2015-07-21 14:52:03 +0200
committerAndrew Shadura <andrew@shadura.me>2015-07-21 14:52:03 +0200
commit26b872bb194ec7622997914bba53309a94b64d20 (patch)
treea79b966bf55dd61702b900b8ba40be4d2b3403db
Imported Upstream version 8024
-rw-r--r--COPYING27
-rw-r--r--README1
-rw-r--r--build.xml58
-rw-r--r--src/net/sourceforge/plantuml/AbstractPSystem.java118
-rw-r--r--src/net/sourceforge/plantuml/AlignParam.java55
-rw-r--r--src/net/sourceforge/plantuml/AnimatedGifEncoder.java1335
-rw-r--r--src/net/sourceforge/plantuml/BasicEnsureVisible.java77
-rw-r--r--src/net/sourceforge/plantuml/BlockUml.java101
-rw-r--r--src/net/sourceforge/plantuml/BlockUmlBuilder.java123
-rw-r--r--src/net/sourceforge/plantuml/CMapData.java93
-rw-r--r--src/net/sourceforge/plantuml/ColorParam.java173
-rw-r--r--src/net/sourceforge/plantuml/CounterOutputStream.java91
-rw-r--r--src/net/sourceforge/plantuml/Dimension2DDouble.java125
-rw-r--r--src/net/sourceforge/plantuml/DirWatcher.java129
-rw-r--r--src/net/sourceforge/plantuml/DirWatcher2.java128
-rw-r--r--src/net/sourceforge/plantuml/Direction.java120
-rw-r--r--src/net/sourceforge/plantuml/EmbededDiagram.java62
-rw-r--r--src/net/sourceforge/plantuml/EmptyImageBuilder.java88
-rw-r--r--src/net/sourceforge/plantuml/EnsureVisible.java41
-rw-r--r--src/net/sourceforge/plantuml/ErrorUml.java96
-rw-r--r--src/net/sourceforge/plantuml/ErrorUmlType.java40
-rw-r--r--src/net/sourceforge/plantuml/FileFormat.java118
-rw-r--r--src/net/sourceforge/plantuml/FileFormatOption.java203
-rw-r--r--src/net/sourceforge/plantuml/FileGroup.java177
-rw-r--r--src/net/sourceforge/plantuml/FileSystem.java119
-rw-r--r--src/net/sourceforge/plantuml/FileUtils.java114
-rw-r--r--src/net/sourceforge/plantuml/FileWatcher.java70
-rw-r--r--src/net/sourceforge/plantuml/FontParam.java150
-rw-r--r--src/net/sourceforge/plantuml/GeneratedImage.java93
-rw-r--r--src/net/sourceforge/plantuml/Hideable.java41
-rw-r--r--src/net/sourceforge/plantuml/ISkinParam.java125
-rw-r--r--src/net/sourceforge/plantuml/ISkinSimple.java44
-rw-r--r--src/net/sourceforge/plantuml/ISourceFileReader.java48
-rw-r--r--src/net/sourceforge/plantuml/LineConfigurable.java50
-rw-r--r--src/net/sourceforge/plantuml/LineParam.java50
-rw-r--r--src/net/sourceforge/plantuml/Log.java110
-rw-r--r--src/net/sourceforge/plantuml/NewpagedDiagram.java135
-rw-r--r--src/net/sourceforge/plantuml/NullOutputStream.java67
-rw-r--r--src/net/sourceforge/plantuml/Option.java416
-rw-r--r--src/net/sourceforge/plantuml/OptionFlags.java291
-rw-r--r--src/net/sourceforge/plantuml/OptionPrint.java199
-rw-r--r--src/net/sourceforge/plantuml/PSystemBuilder.java168
-rw-r--r--src/net/sourceforge/plantuml/PSystemError.java298
-rw-r--r--src/net/sourceforge/plantuml/PSystemUtils.java231
-rw-r--r--src/net/sourceforge/plantuml/Pragma.java74
-rw-r--r--src/net/sourceforge/plantuml/Removeable.java41
-rw-r--r--src/net/sourceforge/plantuml/Run.java411
-rw-r--r--src/net/sourceforge/plantuml/Scale.java40
-rw-r--r--src/net/sourceforge/plantuml/ScaleHeight.java48
-rw-r--r--src/net/sourceforge/plantuml/ScaleSimple.java48
-rw-r--r--src/net/sourceforge/plantuml/ScaleWidth.java48
-rw-r--r--src/net/sourceforge/plantuml/ScaleWidthAndHeight.java55
-rw-r--r--src/net/sourceforge/plantuml/SignatureUtils.java97
-rw-r--r--src/net/sourceforge/plantuml/SingleLine.java42
-rw-r--r--src/net/sourceforge/plantuml/SkinParam.java668
-rw-r--r--src/net/sourceforge/plantuml/SkinParamBackcolored.java87
-rw-r--r--src/net/sourceforge/plantuml/SkinParamBackcoloredReference.java62
-rw-r--r--src/net/sourceforge/plantuml/SkinParamDelegator.java217
-rw-r--r--src/net/sourceforge/plantuml/SkinParamForecolored.java52
-rw-r--r--src/net/sourceforge/plantuml/SkinParamSameClassWidth.java50
-rw-r--r--src/net/sourceforge/plantuml/SkinParamUtils.java58
-rw-r--r--src/net/sourceforge/plantuml/SourceFileReader.java185
-rw-r--r--src/net/sourceforge/plantuml/SourceFileReader2.java137
-rw-r--r--src/net/sourceforge/plantuml/SourceStringReader.java186
-rw-r--r--src/net/sourceforge/plantuml/SpecificBackcolorable.java45
-rw-r--r--src/net/sourceforge/plantuml/SpriteContainer.java45
-rw-r--r--src/net/sourceforge/plantuml/SpriteContainerEmpty.java57
-rw-r--r--src/net/sourceforge/plantuml/StringUtils.java499
-rw-r--r--src/net/sourceforge/plantuml/UmlDiagram.java430
-rw-r--r--src/net/sourceforge/plantuml/UmlDiagramType.java39
-rw-r--r--src/net/sourceforge/plantuml/Url.java120
-rw-r--r--src/net/sourceforge/plantuml/UrlBuilder.java100
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram/ActivityDiagram.java183
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram/ActivityDiagramFactory.java91
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram/ConditionalContext.java68
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram/command/CommandElse.java65
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram/command/CommandEndPartition.java60
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram/command/CommandEndif.java62
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram/command/CommandIf.java121
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram/command/CommandInnerConcurrent.java60
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkActivity.java258
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity.java203
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity2.java220
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram/command/CommandPartition.java69
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java450
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagramFactory3.java143
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/Branch.java124
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/Instruction.java55
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/InstructionFork.java110
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/InstructionGoto.java73
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/InstructionGroup.java103
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java166
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/InstructionLabel.java73
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/InstructionList.java158
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/InstructionPartition.java90
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/InstructionRepeat.java112
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/InstructionSimple.java100
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/InstructionSplit.java118
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/InstructionStart.java69
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/InstructionStop.java72
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/InstructionWhile.java133
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/LinkRendering.java87
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/MonoSwimable.java63
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivity3.java86
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivityLegacy1.java65
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivityLong3.java103
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/command/CommandArrow3.java78
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/command/CommandArrowLong3.java99
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/command/CommandElse3.java67
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/command/CommandElseIf2.java77
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/command/CommandElseLegacy1.java67
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/command/CommandEndPartition3.java58
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/command/CommandEndif3.java65
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/command/CommandFork3.java64
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/command/CommandForkAgain3.java63
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/command/CommandForkEnd3.java62
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/command/CommandGoto.java65
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/command/CommandGroup3.java65
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/command/CommandGroupEnd3.java61
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf2.java78
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf2Multilines.java95
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf4.java77
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/command/CommandIfLegacy1.java69
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/command/CommandKill3.java62
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/command/CommandLabel.java66
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/command/CommandLink3.java68
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/command/CommandNolink.java65
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/command/CommandNote3.java76
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/command/CommandNoteLong3.java83
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/command/CommandPartition3.java74
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeat3.java68
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeatWhile3.java97
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/command/CommandSplit3.java64
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/command/CommandSplitAgain3.java63
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/command/CommandSplitEnd3.java62
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/command/CommandStart3.java67
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/command/CommandStop3.java67
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/command/CommandStopLegacy1.java67
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/command/CommandSwimlane.java71
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/command/CommandSwimlane2.java71
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/command/CommandWhile3.java75
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/command/CommandWhileEnd3.java63
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/AbstractConnection.java60
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/AbstractFtile.java72
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/Arrows.java91
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/BoxStyle.java176
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/CollisionDetector.java225
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/Connection.java48
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/ConnectionCross.java63
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/ConnectionTranslatable.java44
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/Diamond.java120
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/EntityImageLegend.java129
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/Ftile.java58
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileAssemblySimple.java139
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileEmpty.java95
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactory.java83
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactoryDelegator.java174
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileGeometry.java144
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileGeometryMerger.java58
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileGoto.java56
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileHeightFixed.java94
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileKilled.java72
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileLabel.java50
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileMarged.java87
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileMargedVertically.java66
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileMinWidth.java101
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileUtils.java71
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileWithConnection.java83
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileWithSwimlanes.java60
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileWithUrl.java59
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/GotoInterceptor.java61
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/Snake.java415
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/SnakeDirection.java52
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/Swimable.java47
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/Swimlane.java95
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/Swimlanes.java358
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/TextBlockInterceptorUDrawable.java63
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/UGraphicInterceptorUDrawable2.java109
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ConnectionVerticalDown.java103
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FloatingNote.java98
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorAddNote.java66
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorAddUrl.java58
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorAssembly.java116
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateFork.java193
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateGroup.java60
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateSplit.java416
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorIf.java79
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorRepeat.java77
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorWhile.java75
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileForkInner.java121
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileGroup.java168
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIf.java595
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfAndStop.java319
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLong.java516
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLong2.java511
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileRepeat.java369
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileSplit1.java115
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWhile.java397
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNoteOpale.java187
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/UGraphicInterceptorGoto.java66
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/UGraphicInterceptorOneSwimlane.java99
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/VCompactFactory.java174
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBlackBlock.java92
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBox.java156
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileCircleStart.java90
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileCircleStop.java106
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDecorate.java106
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDecorateIn.java53
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDecorateOut.java53
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDecoratePointOut.java61
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamond.java145
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondFoo1.java147
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondInside.java161
-rw-r--r--src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondInside2.java161
-rw-r--r--src/net/sourceforge/plantuml/anim/AffineTransformation.java153
-rw-r--r--src/net/sourceforge/plantuml/anim/Animation.java98
-rw-r--r--src/net/sourceforge/plantuml/anim/AnimationDecoder.java78
-rw-r--r--src/net/sourceforge/plantuml/anim/AnimationScript.java77
-rw-r--r--src/net/sourceforge/plantuml/ant/PlantUmlTask.java363
-rw-r--r--src/net/sourceforge/plantuml/api/CountRate.java81
-rw-r--r--src/net/sourceforge/plantuml/api/INumberAnalyzed.java49
-rw-r--r--src/net/sourceforge/plantuml/api/ImageDataComplex.java81
-rw-r--r--src/net/sourceforge/plantuml/api/ImageDataSimple.java79
-rw-r--r--src/net/sourceforge/plantuml/api/MagicArray.java97
-rw-r--r--src/net/sourceforge/plantuml/api/MyRunnable.java42
-rw-r--r--src/net/sourceforge/plantuml/api/NiceNumber.java70
-rw-r--r--src/net/sourceforge/plantuml/api/NumberAnalyzed.java100
-rw-r--r--src/net/sourceforge/plantuml/api/PSystemFactory.java47
-rw-r--r--src/net/sourceforge/plantuml/api/PlantumlUtils.java59
-rw-r--r--src/net/sourceforge/plantuml/api/TimeoutExecutor.java87
-rw-r--r--src/net/sourceforge/plantuml/api/mda/option2/MDADiagram.java41
-rw-r--r--src/net/sourceforge/plantuml/api/mda/option2/MDAEntity.java40
-rw-r--r--src/net/sourceforge/plantuml/api/mda/option2/MDAPackage.java45
-rw-r--r--src/net/sourceforge/plantuml/api/mda/option2/MDAUtils.java44
-rw-r--r--src/net/sourceforge/plantuml/api/mda/option3/MDAVisitor.java38
-rw-r--r--src/net/sourceforge/plantuml/applet/VersionApplet.java58
-rw-r--r--src/net/sourceforge/plantuml/asciiart/AbstractComponentText.java51
-rw-r--r--src/net/sourceforge/plantuml/asciiart/BasicCharArea.java65
-rw-r--r--src/net/sourceforge/plantuml/asciiart/BasicCharAreaImpl.java177
-rw-r--r--src/net/sourceforge/plantuml/asciiart/ComponentTextActiveLine.java79
-rw-r--r--src/net/sourceforge/plantuml/asciiart/ComponentTextActor.java105
-rw-r--r--src/net/sourceforge/plantuml/asciiart/ComponentTextArrow.java122
-rw-r--r--src/net/sourceforge/plantuml/asciiart/ComponentTextDivider.java97
-rw-r--r--src/net/sourceforge/plantuml/asciiart/ComponentTextGroupingBody.java88
-rw-r--r--src/net/sourceforge/plantuml/asciiart/ComponentTextGroupingElse.java89
-rw-r--r--src/net/sourceforge/plantuml/asciiart/ComponentTextGroupingHeader.java110
-rw-r--r--src/net/sourceforge/plantuml/asciiart/ComponentTextGroupingTail.java83
-rw-r--r--src/net/sourceforge/plantuml/asciiart/ComponentTextLine.java75
-rw-r--r--src/net/sourceforge/plantuml/asciiart/ComponentTextNewpage.java75
-rw-r--r--src/net/sourceforge/plantuml/asciiart/ComponentTextNote.java84
-rw-r--r--src/net/sourceforge/plantuml/asciiart/ComponentTextParticipant.java97
-rw-r--r--src/net/sourceforge/plantuml/asciiart/ComponentTextSelfArrow.java105
-rw-r--r--src/net/sourceforge/plantuml/asciiart/TextSkin.java116
-rw-r--r--src/net/sourceforge/plantuml/asciiart/TextStringBounder.java49
-rw-r--r--src/net/sourceforge/plantuml/asciiart/TranslatedCharArea.java134
-rw-r--r--src/net/sourceforge/plantuml/asciiart/UmlCharArea.java58
-rw-r--r--src/net/sourceforge/plantuml/asciiart/UmlCharAreaImpl.java125
-rw-r--r--src/net/sourceforge/plantuml/braille/BrailleUtils.java43
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/AbstractEntityDiagram.java64
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/ClassDiagram.java234
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/ClassDiagramFactory.java167
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/FullLayout.java61
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/RowLayout.java71
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/command/CommandAddMethod.java63
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/command/CommandAllowMixing.java62
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java163
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java234
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/command/CommandCreateElementFull2.java224
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/command/CommandDiamondAssociation.java61
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/command/CommandHideShow.java188
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/command/CommandHideShow3.java140
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowSpecificClass.java79
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/command/CommandImport.java110
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/command/CommandLayoutNewLine.java62
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass.java516
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/command/CommandLinkLollipop.java224
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/command/CommandMouseOver.java123
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/command/CommandNamespaceSeparator.java59
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/command/CommandStereotype.java63
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/command/CommandUrl.java73
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/command/GenericRegexProducer.java56
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/command/JavaClass.java86
-rw-r--r--src/net/sourceforge/plantuml/classdiagram/command/JavaFile.java111
-rw-r--r--src/net/sourceforge/plantuml/code/ArobaseStringCompressor.java118
-rw-r--r--src/net/sourceforge/plantuml/code/AsciiEncoder.java120
-rw-r--r--src/net/sourceforge/plantuml/code/Base64Coder.java327
-rw-r--r--src/net/sourceforge/plantuml/code/Compression.java56
-rw-r--r--src/net/sourceforge/plantuml/code/CompressionGZip.java83
-rw-r--r--src/net/sourceforge/plantuml/code/CompressionHuffman.java76
-rw-r--r--src/net/sourceforge/plantuml/code/CompressionNone.java47
-rw-r--r--src/net/sourceforge/plantuml/code/CompressionZlib.java113
-rw-r--r--src/net/sourceforge/plantuml/code/StringCompressor.java45
-rw-r--r--src/net/sourceforge/plantuml/code/StringCompressorNone.java48
-rw-r--r--src/net/sourceforge/plantuml/code/Transcoder.java44
-rw-r--r--src/net/sourceforge/plantuml/code/TranscoderImpl.java76
-rw-r--r--src/net/sourceforge/plantuml/code/TranscoderSmart.java55
-rw-r--r--src/net/sourceforge/plantuml/code/TranscoderUtil.java43
-rw-r--r--src/net/sourceforge/plantuml/code/URLEncoder.java43
-rw-r--r--src/net/sourceforge/plantuml/command/Command.java49
-rw-r--r--src/net/sourceforge/plantuml/command/CommandAffineTransform.java55
-rw-r--r--src/net/sourceforge/plantuml/command/CommandAffineTransformMultiline.java58
-rw-r--r--src/net/sourceforge/plantuml/command/CommandComment.java52
-rw-r--r--src/net/sourceforge/plantuml/command/CommandControl.java40
-rw-r--r--src/net/sourceforge/plantuml/command/CommandEndPackage.java59
-rw-r--r--src/net/sourceforge/plantuml/command/CommandExecutionResult.java85
-rw-r--r--src/net/sourceforge/plantuml/command/CommandFootboxIgnored.java51
-rw-r--r--src/net/sourceforge/plantuml/command/CommandFooter.java60
-rw-r--r--src/net/sourceforge/plantuml/command/CommandHeader.java60
-rw-r--r--src/net/sourceforge/plantuml/command/CommandHideUnlinked.java53
-rw-r--r--src/net/sourceforge/plantuml/command/CommandMinwidth.java55
-rw-r--r--src/net/sourceforge/plantuml/command/CommandMultilines.java93
-rw-r--r--src/net/sourceforge/plantuml/command/CommandMultilines2.java103
-rw-r--r--src/net/sourceforge/plantuml/command/CommandMultilinesBracket.java108
-rw-r--r--src/net/sourceforge/plantuml/command/CommandMultilinesComment.java56
-rw-r--r--src/net/sourceforge/plantuml/command/CommandMultilinesFooter.java74
-rw-r--r--src/net/sourceforge/plantuml/command/CommandMultilinesHeader.java75
-rw-r--r--src/net/sourceforge/plantuml/command/CommandMultilinesLegend.java85
-rw-r--r--src/net/sourceforge/plantuml/command/CommandMultilinesTitle.java63
-rw-r--r--src/net/sourceforge/plantuml/command/CommandNamespace.java82
-rw-r--r--src/net/sourceforge/plantuml/command/CommandNope.java52
-rw-r--r--src/net/sourceforge/plantuml/command/CommandPackage.java112
-rw-r--r--src/net/sourceforge/plantuml/command/CommandPackageEmpty.java82
-rw-r--r--src/net/sourceforge/plantuml/command/CommandPage.java60
-rw-r--r--src/net/sourceforge/plantuml/command/CommandPragma.java54
-rw-r--r--src/net/sourceforge/plantuml/command/CommandRankDir.java58
-rw-r--r--src/net/sourceforge/plantuml/command/CommandRotate.java54
-rw-r--r--src/net/sourceforge/plantuml/command/CommandScale.java58
-rw-r--r--src/net/sourceforge/plantuml/command/CommandScaleWidthAndHeight.java56
-rw-r--r--src/net/sourceforge/plantuml/command/CommandScaleWidthOrHeight.java61
-rw-r--r--src/net/sourceforge/plantuml/command/CommandSkinParam.java54
-rw-r--r--src/net/sourceforge/plantuml/command/CommandSkinParamMultilines.java116
-rw-r--r--src/net/sourceforge/plantuml/command/CommandSpriteFile.java84
-rw-r--r--src/net/sourceforge/plantuml/command/CommandTitle.java54
-rw-r--r--src/net/sourceforge/plantuml/command/FactorySpriteCommand.java139
-rw-r--r--src/net/sourceforge/plantuml/command/MultilinesStrategy.java62
-rw-r--r--src/net/sourceforge/plantuml/command/PSystemAbstractFactory.java70
-rw-r--r--src/net/sourceforge/plantuml/command/PSystemBasicFactory.java93
-rw-r--r--src/net/sourceforge/plantuml/command/PSystemSingleLineFactory.java84
-rw-r--r--src/net/sourceforge/plantuml/command/Position.java64
-rw-r--r--src/net/sourceforge/plantuml/command/ProtectedCommand.java83
-rw-r--r--src/net/sourceforge/plantuml/command/SingleLineCommand.java112
-rw-r--r--src/net/sourceforge/plantuml/command/SingleLineCommand2.java112
-rw-r--r--src/net/sourceforge/plantuml/command/UmlDiagramFactory.java264
-rw-r--r--src/net/sourceforge/plantuml/command/note/FactoryNoteActivityCommand.java159
-rw-r--r--src/net/sourceforge/plantuml/command/note/FactoryNoteCommand.java121
-rw-r--r--src/net/sourceforge/plantuml/command/note/FactoryNoteOnEntityCommand.java183
-rw-r--r--src/net/sourceforge/plantuml/command/note/FactoryNoteOnLinkCommand.java131
-rw-r--r--src/net/sourceforge/plantuml/command/note/SingleMultiFactoryCommand.java46
-rw-r--r--src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteCommand.java129
-rw-r--r--src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOnArrowCommand.java129
-rw-r--r--src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOverSeveralCommand.java132
-rw-r--r--src/net/sourceforge/plantuml/command/regex/IRegex.java48
-rw-r--r--src/net/sourceforge/plantuml/command/regex/MatcherIterator.java61
-rw-r--r--src/net/sourceforge/plantuml/command/regex/MyPattern.java99
-rw-r--r--src/net/sourceforge/plantuml/command/regex/RegexComposed.java97
-rw-r--r--src/net/sourceforge/plantuml/command/regex/RegexConcat.java57
-rw-r--r--src/net/sourceforge/plantuml/command/regex/RegexLeaf.java85
-rw-r--r--src/net/sourceforge/plantuml/command/regex/RegexOptional.java56
-rw-r--r--src/net/sourceforge/plantuml/command/regex/RegexOr.java88
-rw-r--r--src/net/sourceforge/plantuml/command/regex/RegexPartialMatch.java71
-rw-r--r--src/net/sourceforge/plantuml/command/regex/RegexResult.java85
-rw-r--r--src/net/sourceforge/plantuml/compositediagram/CompositeDiagram.java62
-rw-r--r--src/net/sourceforge/plantuml/compositediagram/CompositeDiagramFactory.java65
-rw-r--r--src/net/sourceforge/plantuml/compositediagram/command/CommandCreateBlock.java64
-rw-r--r--src/net/sourceforge/plantuml/compositediagram/command/CommandCreatePackageBlock.java65
-rw-r--r--src/net/sourceforge/plantuml/compositediagram/command/CommandEndPackageBlock.java60
-rw-r--r--src/net/sourceforge/plantuml/compositediagram/command/CommandLinkBlock.java84
-rw-r--r--src/net/sourceforge/plantuml/core/Diagram.java93
-rw-r--r--src/net/sourceforge/plantuml/core/DiagramDescription.java45
-rw-r--r--src/net/sourceforge/plantuml/core/DiagramDescriptionImpl.java74
-rw-r--r--src/net/sourceforge/plantuml/core/DiagramType.java79
-rw-r--r--src/net/sourceforge/plantuml/core/ImageData.java88
-rw-r--r--src/net/sourceforge/plantuml/core/UmlSource.java189
-rw-r--r--src/net/sourceforge/plantuml/creole/Atom.java51
-rw-r--r--src/net/sourceforge/plantuml/creole/AtomEmbededSystem.java114
-rw-r--r--src/net/sourceforge/plantuml/creole/AtomImg.java137
-rw-r--r--src/net/sourceforge/plantuml/creole/AtomOpenIcon.java74
-rw-r--r--src/net/sourceforge/plantuml/creole/AtomSpace.java66
-rw-r--r--src/net/sourceforge/plantuml/creole/AtomSprite.java66
-rw-r--r--src/net/sourceforge/plantuml/creole/AtomTable.java209
-rw-r--r--src/net/sourceforge/plantuml/creole/AtomText.java250
-rw-r--r--src/net/sourceforge/plantuml/creole/AtomWithMargin.java68
-rw-r--r--src/net/sourceforge/plantuml/creole/Bullet.java110
-rw-r--r--src/net/sourceforge/plantuml/creole/Command.java42
-rw-r--r--src/net/sourceforge/plantuml/creole/CommandCreoleColorAndSizeChange.java96
-rw-r--r--src/net/sourceforge/plantuml/creole/CommandCreoleColorChange.java85
-rw-r--r--src/net/sourceforge/plantuml/creole/CommandCreoleExposantChange.java85
-rw-r--r--src/net/sourceforge/plantuml/creole/CommandCreoleFontFamilyChange.java83
-rw-r--r--src/net/sourceforge/plantuml/creole/CommandCreoleImg.java79
-rw-r--r--src/net/sourceforge/plantuml/creole/CommandCreoleMonospaced.java76
-rw-r--r--src/net/sourceforge/plantuml/creole/CommandCreoleOpenIcon.java73
-rw-r--r--src/net/sourceforge/plantuml/creole/CommandCreoleSizeChange.java84
-rw-r--r--src/net/sourceforge/plantuml/creole/CommandCreoleSpace.java78
-rw-r--r--src/net/sourceforge/plantuml/creole/CommandCreoleSprite.java73
-rw-r--r--src/net/sourceforge/plantuml/creole/CommandCreoleStyle.java102
-rw-r--r--src/net/sourceforge/plantuml/creole/CommandCreoleSvgAttributeChange.java88
-rw-r--r--src/net/sourceforge/plantuml/creole/CommandCreoleUrl.java87
-rw-r--r--src/net/sourceforge/plantuml/creole/CreoleContext.java61
-rw-r--r--src/net/sourceforge/plantuml/creole/CreoleHorizontalLine.java107
-rw-r--r--src/net/sourceforge/plantuml/creole/CreoleParser.java95
-rw-r--r--src/net/sourceforge/plantuml/creole/CreoleStripeSimpleParser.java143
-rw-r--r--src/net/sourceforge/plantuml/creole/Fission.java109
-rw-r--r--src/net/sourceforge/plantuml/creole/PSystemCreole.java91
-rw-r--r--src/net/sourceforge/plantuml/creole/PSystemCreoleFactory.java60
-rw-r--r--src/net/sourceforge/plantuml/creole/Position.java118
-rw-r--r--src/net/sourceforge/plantuml/creole/Sea.java130
-rw-r--r--src/net/sourceforge/plantuml/creole/Sheet.java71
-rw-r--r--src/net/sourceforge/plantuml/creole/SheetBlock1.java158
-rw-r--r--src/net/sourceforge/plantuml/creole/SheetBlock2.java74
-rw-r--r--src/net/sourceforge/plantuml/creole/Stencil.java45
-rw-r--r--src/net/sourceforge/plantuml/creole/Stripe.java43
-rw-r--r--src/net/sourceforge/plantuml/creole/StripeSimple.java201
-rw-r--r--src/net/sourceforge/plantuml/creole/StripeStyle.java73
-rw-r--r--src/net/sourceforge/plantuml/creole/StripeStyleType.java39
-rw-r--r--src/net/sourceforge/plantuml/creole/StripeTable.java133
-rw-r--r--src/net/sourceforge/plantuml/creole/UCreole.java41
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/BlockMember.java45
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/BlockMemberImpl.java64
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/Bodier.java169
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced.java187
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced2.java156
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/Code.java159
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/CucaDiagram.java590
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/Display.java271
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/Display2.java241
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/EntityGender.java39
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/EntityGenderUtils.java124
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/EntityPortion.java39
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/EntityPosition.java40
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/EntityUtils.java94
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/GroupHierarchy.java44
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/GroupPrinter.java97
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/GroupRoot.java281
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/GroupType.java40
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/IEntity.java96
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/IGroup.java75
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/ILeaf.java75
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/Ident.java78
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/LeafType.java84
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/Link.java498
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/LinkArrow.java51
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/LinkDecor.java111
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/LinkHat.java53
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/LinkMiddleDecor.java62
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/LinkStyle.java43
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/LinkType.java245
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/LongCode.java91
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/Magma.java111
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/MagmaList.java76
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/Member.java192
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/MethodsOrFieldsArea.java224
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/Namespace.java71
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/PortionShower.java41
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/Rankdir.java40
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/RuleType.java39
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/SquareLinker.java43
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/SquareMaker.java83
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/Stereotype.java236
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/UnparsableGraphvizException.java58
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/dot/AbstractGraphviz.java190
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramPngMaker3.java160
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramSimplifierActivity.java90
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramSimplifierState.java91
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramTxtMaker.java182
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/dot/DebugTrace.java70
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/dot/DotData.java229
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/dot/DotMaker2.java49
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/dot/DotSplines.java40
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/dot/Graphviz.java49
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizLayoutStrategy.java61
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizLinux.java56
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizUtils.java222
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizVersion.java44
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizVersionFinder.java108
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizVersions.java72
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizWindows.java94
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/dot/Neighborhood.java189
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/dot/OS.java51
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/dot/OSLinux.java69
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/dot/OSWindows.java97
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/dot/ProcessRunner.java284
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/dot/ProcessState.java101
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/entity/EntityFactory.java246
-rw-r--r--src/net/sourceforge/plantuml/cucadiagram/entity/EntityImpl.java652
-rw-r--r--src/net/sourceforge/plantuml/cute/ApolloniusSolver.java131
-rw-r--r--src/net/sourceforge/plantuml/cute/ApolloniusSolver2.java110
-rw-r--r--src/net/sourceforge/plantuml/cute/Arc.java114
-rw-r--r--src/net/sourceforge/plantuml/cute/Balloon.java124
-rw-r--r--src/net/sourceforge/plantuml/cute/BetweenCorners.java194
-rw-r--r--src/net/sourceforge/plantuml/cute/Cheese.java130
-rw-r--r--src/net/sourceforge/plantuml/cute/Circle.java65
-rw-r--r--src/net/sourceforge/plantuml/cute/Corner.java45
-rw-r--r--src/net/sourceforge/plantuml/cute/Crossing.java67
-rw-r--r--src/net/sourceforge/plantuml/cute/CrossingSimple.java90
-rw-r--r--src/net/sourceforge/plantuml/cute/CutePath.java179
-rw-r--r--src/net/sourceforge/plantuml/cute/CuteShape.java43
-rw-r--r--src/net/sourceforge/plantuml/cute/CuteShapeFactory.java81
-rw-r--r--src/net/sourceforge/plantuml/cute/Group.java125
-rw-r--r--src/net/sourceforge/plantuml/cute/InfiniteLine.java76
-rw-r--r--src/net/sourceforge/plantuml/cute/MyDouble.java90
-rw-r--r--src/net/sourceforge/plantuml/cute/MyPoint2D.java120
-rw-r--r--src/net/sourceforge/plantuml/cute/PSystemCute.java94
-rw-r--r--src/net/sourceforge/plantuml/cute/PSystemCuteFactory.java60
-rw-r--r--src/net/sourceforge/plantuml/cute/Positionned.java45
-rw-r--r--src/net/sourceforge/plantuml/cute/PositionnedImpl.java106
-rw-r--r--src/net/sourceforge/plantuml/cute/Rectangle.java105
-rw-r--r--src/net/sourceforge/plantuml/cute/RotationZoom.java128
-rw-r--r--src/net/sourceforge/plantuml/cute/Segment.java109
-rw-r--r--src/net/sourceforge/plantuml/cute/Stick.java99
-rw-r--r--src/net/sourceforge/plantuml/cute/Tension.java61
-rw-r--r--src/net/sourceforge/plantuml/cute/Triangle.java68
-rw-r--r--src/net/sourceforge/plantuml/cute/TriangleCorner.java142
-rw-r--r--src/net/sourceforge/plantuml/cute/TriangleCornerSimple.java116
-rw-r--r--src/net/sourceforge/plantuml/cute/VarArgs.java131
-rw-r--r--src/net/sourceforge/plantuml/descdiagram/DescriptionDiagram.java143
-rw-r--r--src/net/sourceforge/plantuml/descdiagram/DescriptionDiagramFactory.java128
-rw-r--r--src/net/sourceforge/plantuml/descdiagram/command/CommandCreateElementFull.java228
-rw-r--r--src/net/sourceforge/plantuml/descdiagram/command/CommandCreateElementMultilines.java129
-rw-r--r--src/net/sourceforge/plantuml/descdiagram/command/CommandLinkElement.java333
-rw-r--r--src/net/sourceforge/plantuml/descdiagram/command/CommandNamespaceSeparator.java59
-rw-r--r--src/net/sourceforge/plantuml/descdiagram/command/CommandNewpage.java67
-rw-r--r--src/net/sourceforge/plantuml/descdiagram/command/CommandPackageWithUSymbol.java108
-rw-r--r--src/net/sourceforge/plantuml/directdot/PSystemDot.java90
-rw-r--r--src/net/sourceforge/plantuml/directdot/PSystemDotFactory.java68
-rw-r--r--src/net/sourceforge/plantuml/donors/PSystemDonors.java121
-rw-r--r--src/net/sourceforge/plantuml/donors/PSystemDonorsFactory.java50
-rw-r--r--src/net/sourceforge/plantuml/eggs/EggUtils.java101
-rw-r--r--src/net/sourceforge/plantuml/eggs/GraphicsPath.java83
-rw-r--r--src/net/sourceforge/plantuml/eggs/PSystemAppleTwo.java732
-rw-r--r--src/net/sourceforge/plantuml/eggs/PSystemAppleTwoFactory.java60
-rw-r--r--src/net/sourceforge/plantuml/eggs/PSystemCharlie.java79
-rw-r--r--src/net/sourceforge/plantuml/eggs/PSystemCharlieFactory.java50
-rw-r--r--src/net/sourceforge/plantuml/eggs/PSystemEgg.java84
-rw-r--r--src/net/sourceforge/plantuml/eggs/PSystemEggFactory.java67
-rw-r--r--src/net/sourceforge/plantuml/eggs/PSystemLost.java81
-rw-r--r--src/net/sourceforge/plantuml/eggs/PSystemLostFactory.java50
-rw-r--r--src/net/sourceforge/plantuml/eggs/PSystemPath.java67
-rw-r--r--src/net/sourceforge/plantuml/eggs/PSystemPathFactory.java57
-rw-r--r--src/net/sourceforge/plantuml/eggs/PSystemRIP.java470
-rw-r--r--src/net/sourceforge/plantuml/eggs/PSystemRIPFactory.java58
-rw-r--r--src/net/sourceforge/plantuml/eggs/SentenceDecoder.java68
-rw-r--r--src/net/sourceforge/plantuml/eggs/SentenceProducer.java54
-rw-r--r--src/net/sourceforge/plantuml/eps/EpsGraphics.java760
-rw-r--r--src/net/sourceforge/plantuml/eps/EpsGraphicsMacro.java207
-rw-r--r--src/net/sourceforge/plantuml/eps/EpsGraphicsMacroAndText.java104
-rw-r--r--src/net/sourceforge/plantuml/eps/EpsStrategy.java58
-rw-r--r--src/net/sourceforge/plantuml/eps/PostScriptCommand.java41
-rw-r--r--src/net/sourceforge/plantuml/eps/PostScriptCommandCurveTo.java60
-rw-r--r--src/net/sourceforge/plantuml/eps/PostScriptCommandLineTo.java52
-rw-r--r--src/net/sourceforge/plantuml/eps/PostScriptCommandMacro.java77
-rw-r--r--src/net/sourceforge/plantuml/eps/PostScriptCommandMoveTo.java50
-rw-r--r--src/net/sourceforge/plantuml/eps/PostScriptCommandQuadTo.java56
-rw-r--r--src/net/sourceforge/plantuml/eps/PostScriptCommandRaw.java52
-rw-r--r--src/net/sourceforge/plantuml/eps/PostScriptData.java67
-rw-r--r--src/net/sourceforge/plantuml/flashcode/FlashCodeFactory.java53
-rw-r--r--src/net/sourceforge/plantuml/flashcode/FlashCodeUtils.java43
-rw-r--r--src/net/sourceforge/plantuml/flashcode/FlashCodeUtilsNone.java45
-rw-r--r--src/net/sourceforge/plantuml/flowdiagram/ActivityBox.java110
-rw-r--r--src/net/sourceforge/plantuml/flowdiagram/CommandLineSimple.java72
-rw-r--r--src/net/sourceforge/plantuml/flowdiagram/CommandLink.java69
-rw-r--r--src/net/sourceforge/plantuml/flowdiagram/FlowDiagram.java206
-rw-r--r--src/net/sourceforge/plantuml/flowdiagram/FlowDiagramFactory.java63
-rw-r--r--src/net/sourceforge/plantuml/font/PSystemListFonts.java94
-rw-r--r--src/net/sourceforge/plantuml/font/PSystemListFontsFactory.java54
-rw-r--r--src/net/sourceforge/plantuml/ftp/FtpConnexion.java187
-rw-r--r--src/net/sourceforge/plantuml/ftp/FtpLoop.java321
-rw-r--r--src/net/sourceforge/plantuml/ftp/FtpServer.java127
-rw-r--r--src/net/sourceforge/plantuml/fun/IconLoader.java105
-rw-r--r--src/net/sourceforge/plantuml/fun/sprite000.pngbin0 -> 223 bytes
-rw-r--r--src/net/sourceforge/plantuml/fun/sprite001.pngbin0 -> 229 bytes
-rw-r--r--src/net/sourceforge/plantuml/fun/sprite002.pngbin0 -> 227 bytes
-rw-r--r--src/net/sourceforge/plantuml/fun/sprite003.pngbin0 -> 309 bytes
-rw-r--r--src/net/sourceforge/plantuml/fun/sprite004.pngbin0 -> 236 bytes
-rw-r--r--src/net/sourceforge/plantuml/fun/sprite005.pngbin0 -> 216 bytes
-rw-r--r--src/net/sourceforge/plantuml/fun/sprite006.pngbin0 -> 249 bytes
-rw-r--r--src/net/sourceforge/plantuml/fun/sprite007.pngbin0 -> 338 bytes
-rw-r--r--src/net/sourceforge/plantuml/fun/sprite008.pngbin0 -> 534 bytes
-rw-r--r--src/net/sourceforge/plantuml/fun/sprite009.pngbin0 -> 223 bytes
-rw-r--r--src/net/sourceforge/plantuml/fun/sprite010.pngbin0 -> 240 bytes
-rw-r--r--src/net/sourceforge/plantuml/fun/sprite011.pngbin0 -> 285 bytes
-rw-r--r--src/net/sourceforge/plantuml/fun/sprite012.pngbin0 -> 3112 bytes
-rw-r--r--src/net/sourceforge/plantuml/fun/sprite013.pngbin0 -> 323 bytes
-rw-r--r--src/net/sourceforge/plantuml/fun/sprite014.pngbin0 -> 263 bytes
-rw-r--r--src/net/sourceforge/plantuml/fun/sprite015.pngbin0 -> 245 bytes
-rw-r--r--src/net/sourceforge/plantuml/fun/sprite016.pngbin0 -> 252 bytes
-rw-r--r--src/net/sourceforge/plantuml/fun/sprite017.pngbin0 -> 226 bytes
-rw-r--r--src/net/sourceforge/plantuml/fun/sprite018.pngbin0 -> 272 bytes
-rw-r--r--src/net/sourceforge/plantuml/fun/sprite019.pngbin0 -> 457 bytes
-rw-r--r--src/net/sourceforge/plantuml/geom/AbstractFigure.java314
-rw-r--r--src/net/sourceforge/plantuml/geom/AbstractLineSegment.java255
-rw-r--r--src/net/sourceforge/plantuml/geom/AbstractPolyline.java199
-rw-r--r--src/net/sourceforge/plantuml/geom/Box.java239
-rw-r--r--src/net/sourceforge/plantuml/geom/ClosedArea.java296
-rw-r--r--src/net/sourceforge/plantuml/geom/CollectionUtils.java85
-rw-r--r--src/net/sourceforge/plantuml/geom/Dijkstra.java129
-rw-r--r--src/net/sourceforge/plantuml/geom/InflateData.java66
-rw-r--r--src/net/sourceforge/plantuml/geom/InflationTransform.java210
-rw-r--r--src/net/sourceforge/plantuml/geom/Kingdom.java122
-rw-r--r--src/net/sourceforge/plantuml/geom/LineSegmentDouble.java110
-rw-r--r--src/net/sourceforge/plantuml/geom/LineSegmentInt.java267
-rw-r--r--src/net/sourceforge/plantuml/geom/Neighborhood.java118
-rw-r--r--src/net/sourceforge/plantuml/geom/Orientation.java41
-rw-r--r--src/net/sourceforge/plantuml/geom/Point2DInt.java121
-rw-r--r--src/net/sourceforge/plantuml/geom/Pointable.java39
-rw-r--r--src/net/sourceforge/plantuml/geom/Polyline.java49
-rw-r--r--src/net/sourceforge/plantuml/geom/PolylineBreakeable.java153
-rw-r--r--src/net/sourceforge/plantuml/geom/PolylineImpl.java99
-rw-r--r--src/net/sourceforge/plantuml/geom/Singularity.java153
-rw-r--r--src/net/sourceforge/plantuml/geom/SpiderWeb.java182
-rw-r--r--src/net/sourceforge/plantuml/geom/XMoveable.java41
-rw-r--r--src/net/sourceforge/plantuml/geom/kinetic/Frame.java117
-rw-r--r--src/net/sourceforge/plantuml/geom/kinetic/MoveObserver.java41
-rw-r--r--src/net/sourceforge/plantuml/geom/kinetic/Path.java163
-rw-r--r--src/net/sourceforge/plantuml/geom/kinetic/Point2DCharge.java104
-rw-r--r--src/net/sourceforge/plantuml/geom/kinetic/Quadrant.java81
-rw-r--r--src/net/sourceforge/plantuml/geom/kinetic/QuadrantMapper.java105
-rw-r--r--src/net/sourceforge/plantuml/geom/kinetic/SegmentCutter.java68
-rw-r--r--src/net/sourceforge/plantuml/geom/kinetic/VectorForce.java101
-rw-r--r--src/net/sourceforge/plantuml/geom/kinetic/World.java172
-rw-r--r--src/net/sourceforge/plantuml/golem/Magnet.java38
-rw-r--r--src/net/sourceforge/plantuml/golem/MinMaxDouble.java83
-rw-r--r--src/net/sourceforge/plantuml/golem/MinMaxGolem.java80
-rw-r--r--src/net/sourceforge/plantuml/golem/Path.java61
-rw-r--r--src/net/sourceforge/plantuml/golem/Position.java114
-rw-r--r--src/net/sourceforge/plantuml/golem/Square.java38
-rw-r--r--src/net/sourceforge/plantuml/golem/Tile.java100
-rw-r--r--src/net/sourceforge/plantuml/golem/TileArea.java54
-rw-r--r--src/net/sourceforge/plantuml/golem/TileGeometry.java74
-rw-r--r--src/net/sourceforge/plantuml/golem/TilesField.java302
-rw-r--r--src/net/sourceforge/plantuml/graph/ALink.java47
-rw-r--r--src/net/sourceforge/plantuml/graph/ALinkImpl.java72
-rw-r--r--src/net/sourceforge/plantuml/graph/ANode.java47
-rw-r--r--src/net/sourceforge/plantuml/graph/ANodeImpl.java77
-rw-r--r--src/net/sourceforge/plantuml/graph/AbstractEntityImage.java115
-rw-r--r--src/net/sourceforge/plantuml/graph/Board.java266
-rw-r--r--src/net/sourceforge/plantuml/graph/BoardCollection.java127
-rw-r--r--src/net/sourceforge/plantuml/graph/BoardExplorer.java85
-rw-r--r--src/net/sourceforge/plantuml/graph/CostComputer.java41
-rw-r--r--src/net/sourceforge/plantuml/graph/Elastane.java373
-rw-r--r--src/net/sourceforge/plantuml/graph/ElectricCharge.java69
-rw-r--r--src/net/sourceforge/plantuml/graph/ElectricWord.java67
-rw-r--r--src/net/sourceforge/plantuml/graph/EntityImageActivity.java104
-rw-r--r--src/net/sourceforge/plantuml/graph/EntityImageActivityBar.java65
-rw-r--r--src/net/sourceforge/plantuml/graph/EntityImageActivityBranch.java72
-rw-r--r--src/net/sourceforge/plantuml/graph/EntityImageActivityCircle.java69
-rw-r--r--src/net/sourceforge/plantuml/graph/EntityImageCircleInterface.java93
-rw-r--r--src/net/sourceforge/plantuml/graph/EntityImageComponent.java97
-rw-r--r--src/net/sourceforge/plantuml/graph/EntityImageDefault.java78
-rw-r--r--src/net/sourceforge/plantuml/graph/EntityImageFactory.java84
-rw-r--r--src/net/sourceforge/plantuml/graph/EntityImageNote.java99
-rw-r--r--src/net/sourceforge/plantuml/graph/EntityImageUsecase.java106
-rw-r--r--src/net/sourceforge/plantuml/graph/Galaxy4.java93
-rw-r--r--src/net/sourceforge/plantuml/graph/GeneralPathFactory.java157
-rw-r--r--src/net/sourceforge/plantuml/graph/Graph1.java80
-rw-r--r--src/net/sourceforge/plantuml/graph/Graph2.java100
-rw-r--r--src/net/sourceforge/plantuml/graph/Graph3.java479
-rw-r--r--src/net/sourceforge/plantuml/graph/Graph4.java266
-rw-r--r--src/net/sourceforge/plantuml/graph/Graph5.java191
-rw-r--r--src/net/sourceforge/plantuml/graph/Heap.java241
-rw-r--r--src/net/sourceforge/plantuml/graph/KenavoCostComputer.java77
-rw-r--r--src/net/sourceforge/plantuml/graph/LenghtLinkComparator.java60
-rw-r--r--src/net/sourceforge/plantuml/graph/LinkString.java66
-rw-r--r--src/net/sourceforge/plantuml/graph/MethodsOrFieldsArea.java97
-rw-r--r--src/net/sourceforge/plantuml/graph/Move.java77
-rw-r--r--src/net/sourceforge/plantuml/graph/Oven.java94
-rw-r--r--src/net/sourceforge/plantuml/graph/SimpleCostComputer.java59
-rw-r--r--src/net/sourceforge/plantuml/graph/SortedCollection.java45
-rw-r--r--src/net/sourceforge/plantuml/graph/SortedCollectionArrayList.java88
-rw-r--r--src/net/sourceforge/plantuml/graph/SortedCollectionLinked.java88
-rw-r--r--src/net/sourceforge/plantuml/graph/Zoda1.java167
-rw-r--r--src/net/sourceforge/plantuml/graph/Zoda2.java125
-rw-r--r--src/net/sourceforge/plantuml/graph2/CubicCurveFactory.java96
-rw-r--r--src/net/sourceforge/plantuml/graph2/Dijkstra.java155
-rw-r--r--src/net/sourceforge/plantuml/graph2/GeomUtils.java156
-rw-r--r--src/net/sourceforge/plantuml/graph2/IInflationTransform.java56
-rw-r--r--src/net/sourceforge/plantuml/graph2/IdentityInflationTransform.java69
-rw-r--r--src/net/sourceforge/plantuml/graph2/InflateData2.java125
-rw-r--r--src/net/sourceforge/plantuml/graph2/InflationTransform2.java239
-rw-r--r--src/net/sourceforge/plantuml/graph2/MagicPointsFactory.java74
-rw-r--r--src/net/sourceforge/plantuml/graph2/MagicPointsFactory2.java72
-rw-r--r--src/net/sourceforge/plantuml/graph2/Measurer.java39
-rw-r--r--src/net/sourceforge/plantuml/graph2/MyCurve.java172
-rw-r--r--src/net/sourceforge/plantuml/graph2/Neighborhood2.java189
-rw-r--r--src/net/sourceforge/plantuml/graph2/Plan.java254
-rw-r--r--src/net/sourceforge/plantuml/graph2/Polyline2.java110
-rw-r--r--src/net/sourceforge/plantuml/graph2/RectanglesCollection.java199
-rw-r--r--src/net/sourceforge/plantuml/graph2/Singularity2.java163
-rw-r--r--src/net/sourceforge/plantuml/graph2/SortedList.java45
-rw-r--r--src/net/sourceforge/plantuml/graph2/SortedListImpl.java128
-rw-r--r--src/net/sourceforge/plantuml/graphic/AddStyle.java60
-rw-r--r--src/net/sourceforge/plantuml/graphic/CircledCharacter.java115
-rw-r--r--src/net/sourceforge/plantuml/graphic/ColorAndSizeChange.java85
-rw-r--r--src/net/sourceforge/plantuml/graphic/ColorChange.java64
-rw-r--r--src/net/sourceforge/plantuml/graphic/DateEventUtils.java107
-rw-r--r--src/net/sourceforge/plantuml/graphic/DisplayUtils.java55
-rw-r--r--src/net/sourceforge/plantuml/graphic/EmbededSystemLine.java109
-rw-r--r--src/net/sourceforge/plantuml/graphic/ExposantChange.java49
-rw-r--r--src/net/sourceforge/plantuml/graphic/FontChange.java40
-rw-r--r--src/net/sourceforge/plantuml/graphic/FontConfiguration.java243
-rw-r--r--src/net/sourceforge/plantuml/graphic/FontFamilyChange.java60
-rw-r--r--src/net/sourceforge/plantuml/graphic/FontPosition.java73
-rw-r--r--src/net/sourceforge/plantuml/graphic/FontStyle.java162
-rw-r--r--src/net/sourceforge/plantuml/graphic/GraphicPosition.java41
-rw-r--r--src/net/sourceforge/plantuml/graphic/GraphicStrings.java188
-rw-r--r--src/net/sourceforge/plantuml/graphic/HorizontalAlignment.java54
-rw-r--r--src/net/sourceforge/plantuml/graphic/HtmlColor.java41
-rw-r--r--src/net/sourceforge/plantuml/graphic/HtmlColorGradient.java86
-rw-r--r--src/net/sourceforge/plantuml/graphic/HtmlColorSet.java45
-rw-r--r--src/net/sourceforge/plantuml/graphic/HtmlColorSetSimple.java284
-rw-r--r--src/net/sourceforge/plantuml/graphic/HtmlColorSimple.java78
-rw-r--r--src/net/sourceforge/plantuml/graphic/HtmlColorTransparent.java39
-rw-r--r--src/net/sourceforge/plantuml/graphic/HtmlColorUserDef.java39
-rw-r--r--src/net/sourceforge/plantuml/graphic/HtmlColorUtils.java115
-rw-r--r--src/net/sourceforge/plantuml/graphic/HtmlCommand.java38
-rw-r--r--src/net/sourceforge/plantuml/graphic/HtmlCommandFactory.java141
-rw-r--r--src/net/sourceforge/plantuml/graphic/IHtmlColorSet.java47
-rw-r--r--src/net/sourceforge/plantuml/graphic/Img.java153
-rw-r--r--src/net/sourceforge/plantuml/graphic/ImgValign.java39
-rw-r--r--src/net/sourceforge/plantuml/graphic/Line.java41
-rw-r--r--src/net/sourceforge/plantuml/graphic/QuoteUtils.java160
-rw-r--r--src/net/sourceforge/plantuml/graphic/RemoveStyle.java49
-rw-r--r--src/net/sourceforge/plantuml/graphic/ResetFont.java43
-rw-r--r--src/net/sourceforge/plantuml/graphic/SingleLine.java141
-rw-r--r--src/net/sourceforge/plantuml/graphic/SizeChange.java64
-rw-r--r--src/net/sourceforge/plantuml/graphic/SkinParameter.java131
-rw-r--r--src/net/sourceforge/plantuml/graphic/Splitter.java157
-rw-r--r--src/net/sourceforge/plantuml/graphic/SpriteCommand.java58
-rw-r--r--src/net/sourceforge/plantuml/graphic/StringBounder.java45
-rw-r--r--src/net/sourceforge/plantuml/graphic/StringBounderUtils.java57
-rw-r--r--src/net/sourceforge/plantuml/graphic/SvgAttributes.java81
-rw-r--r--src/net/sourceforge/plantuml/graphic/SvgAttributesChange.java59
-rw-r--r--src/net/sourceforge/plantuml/graphic/SymbolContext.java119
-rw-r--r--src/net/sourceforge/plantuml/graphic/Text.java61
-rw-r--r--src/net/sourceforge/plantuml/graphic/TextBlock.java45
-rw-r--r--src/net/sourceforge/plantuml/graphic/TextBlockArrow.java110
-rw-r--r--src/net/sourceforge/plantuml/graphic/TextBlockBordered.java65
-rw-r--r--src/net/sourceforge/plantuml/graphic/TextBlockCompressed.java73
-rw-r--r--src/net/sourceforge/plantuml/graphic/TextBlockCompressed2.java62
-rw-r--r--src/net/sourceforge/plantuml/graphic/TextBlockEmpty.java75
-rw-r--r--src/net/sourceforge/plantuml/graphic/TextBlockGeneric.java71
-rw-r--r--src/net/sourceforge/plantuml/graphic/TextBlockHorizontal.java75
-rw-r--r--src/net/sourceforge/plantuml/graphic/TextBlockLineBefore.java85
-rw-r--r--src/net/sourceforge/plantuml/graphic/TextBlockMarged.java68
-rw-r--r--src/net/sourceforge/plantuml/graphic/TextBlockMinWidth.java71
-rw-r--r--src/net/sourceforge/plantuml/graphic/TextBlockRecentred.java61
-rw-r--r--src/net/sourceforge/plantuml/graphic/TextBlockSimple.java203
-rw-r--r--src/net/sourceforge/plantuml/graphic/TextBlockSpotted.java81
-rw-r--r--src/net/sourceforge/plantuml/graphic/TextBlockUtils.java217
-rw-r--r--src/net/sourceforge/plantuml/graphic/TextBlockVertical2.java89
-rw-r--r--src/net/sourceforge/plantuml/graphic/TextBlockWidth.java44
-rw-r--r--src/net/sourceforge/plantuml/graphic/TextBlockWidthAdapter.java63
-rw-r--r--src/net/sourceforge/plantuml/graphic/TextLink.java58
-rw-r--r--src/net/sourceforge/plantuml/graphic/TileImage.java66
-rw-r--r--src/net/sourceforge/plantuml/graphic/TileImageSvg.java74
-rw-r--r--src/net/sourceforge/plantuml/graphic/TileText.java134
-rw-r--r--src/net/sourceforge/plantuml/graphic/UDrawable.java43
-rw-r--r--src/net/sourceforge/plantuml/graphic/UDrawableUtils.java50
-rw-r--r--src/net/sourceforge/plantuml/graphic/UGraphicDelegator.java91
-rw-r--r--src/net/sourceforge/plantuml/graphic/UGraphicInterceptorUDrawable.java61
-rw-r--r--src/net/sourceforge/plantuml/graphic/USymbol.java159
-rw-r--r--src/net/sourceforge/plantuml/graphic/USymbolActor.java54
-rw-r--r--src/net/sourceforge/plantuml/graphic/USymbolArtifact.java132
-rw-r--r--src/net/sourceforge/plantuml/graphic/USymbolBoundary.java53
-rw-r--r--src/net/sourceforge/plantuml/graphic/USymbolCard.java117
-rw-r--r--src/net/sourceforge/plantuml/graphic/USymbolCloud.java132
-rw-r--r--src/net/sourceforge/plantuml/graphic/USymbolComponent1.java99
-rw-r--r--src/net/sourceforge/plantuml/graphic/USymbolComponent2.java114
-rw-r--r--src/net/sourceforge/plantuml/graphic/USymbolControl.java60
-rw-r--r--src/net/sourceforge/plantuml/graphic/USymbolDatabase.java169
-rw-r--r--src/net/sourceforge/plantuml/graphic/USymbolEntityDomain.java59
-rw-r--r--src/net/sourceforge/plantuml/graphic/USymbolFolder.java150
-rw-r--r--src/net/sourceforge/plantuml/graphic/USymbolFrame.java138
-rw-r--r--src/net/sourceforge/plantuml/graphic/USymbolInterface.java52
-rw-r--r--src/net/sourceforge/plantuml/graphic/USymbolNode.java132
-rw-r--r--src/net/sourceforge/plantuml/graphic/USymbolQueue.java172
-rw-r--r--src/net/sourceforge/plantuml/graphic/USymbolRect.java113
-rw-r--r--src/net/sourceforge/plantuml/graphic/USymbolSimpleAbstract.java86
-rw-r--r--src/net/sourceforge/plantuml/graphic/USymbolStorage.java106
-rw-r--r--src/net/sourceforge/plantuml/graphic/UnusedSpace.java173
-rw-r--r--src/net/sourceforge/plantuml/graphic/VerticalAlignment.java52
-rw-r--r--src/net/sourceforge/plantuml/graphic/VerticalPosition.java41
-rw-r--r--src/net/sourceforge/plantuml/hector/Box2D.java80
-rw-r--r--src/net/sourceforge/plantuml/hector/CucaDiagramFileMakerHector.java106
-rw-r--r--src/net/sourceforge/plantuml/hector/CucaDiagramFileMakerHector2.java181
-rw-r--r--src/net/sourceforge/plantuml/hector/CucaDiagramFileMakerHector3.java182
-rw-r--r--src/net/sourceforge/plantuml/hector/CucaDiagramFileMakerHector4.java197
-rw-r--r--src/net/sourceforge/plantuml/hector/CucaDiagramFileMakerHectorB1.java169
-rw-r--r--src/net/sourceforge/plantuml/hector/CucaDiagramFileMakerHectorB2.java203
-rw-r--r--src/net/sourceforge/plantuml/hector/GrowingTree.java174
-rw-r--r--src/net/sourceforge/plantuml/hector/HectorPath.java71
-rw-r--r--src/net/sourceforge/plantuml/hector/Pin.java77
-rw-r--r--src/net/sourceforge/plantuml/hector/PinFactory.java67
-rw-r--r--src/net/sourceforge/plantuml/hector/PinLink.java77
-rw-r--r--src/net/sourceforge/plantuml/hector/PinLinksContinuousSet.java103
-rw-r--r--src/net/sourceforge/plantuml/hector/Skeleton.java84
-rw-r--r--src/net/sourceforge/plantuml/hector/SkeletonBuilder.java84
-rw-r--r--src/net/sourceforge/plantuml/hector/SkeletonConfiguration.java255
-rw-r--r--src/net/sourceforge/plantuml/hector/SkeletonConfigurationComparator.java59
-rw-r--r--src/net/sourceforge/plantuml/hector/SkeletonConfigurationEvaluator.java41
-rw-r--r--src/net/sourceforge/plantuml/hector/SkeletonConfigurationEvaluatorLineLenght.java47
-rw-r--r--src/net/sourceforge/plantuml/hector/SkeletonConfigurationSet.java89
-rw-r--r--src/net/sourceforge/plantuml/hector/SkeletonConfigurationUtils.java56
-rw-r--r--src/net/sourceforge/plantuml/hector/SkeletonConfigurations.java39
-rw-r--r--src/net/sourceforge/plantuml/hector/SkeletonMutation.java41
-rw-r--r--src/net/sourceforge/plantuml/hector/SmartConnection.java110
-rw-r--r--src/net/sourceforge/plantuml/hector/UnlinarCompressedPlan.java143
-rw-r--r--src/net/sourceforge/plantuml/hector/UnlinearCompression.java111
-rw-r--r--src/net/sourceforge/plantuml/hector2/CucaDiagramFileMakerHectorC1.java104
-rw-r--r--src/net/sourceforge/plantuml/hector2/MinMax.java98
-rw-r--r--src/net/sourceforge/plantuml/hector2/continuity/Skeleton.java188
-rw-r--r--src/net/sourceforge/plantuml/hector2/continuity/SkeletonBuilder.java86
-rw-r--r--src/net/sourceforge/plantuml/hector2/graphic/Foo1.java66
-rw-r--r--src/net/sourceforge/plantuml/hector2/graphic/Foo2.java106
-rw-r--r--src/net/sourceforge/plantuml/hector2/layering/Layer.java116
-rw-r--r--src/net/sourceforge/plantuml/hector2/layering/LayerFactory.java66
-rw-r--r--src/net/sourceforge/plantuml/hector2/mpos/Distribution.java113
-rw-r--r--src/net/sourceforge/plantuml/hector2/mpos/MutationLayer.java45
-rw-r--r--src/net/sourceforge/plantuml/hector2/mpos/MutationLayerMove.java66
-rw-r--r--src/net/sourceforge/plantuml/html/CucaDiagramHtmlMaker.java235
-rw-r--r--src/net/sourceforge/plantuml/html/LinkHtmlPrinter.java187
-rw-r--r--src/net/sourceforge/plantuml/jungle/CommandAddLevel.java64
-rw-r--r--src/net/sourceforge/plantuml/jungle/CommandEmpty.java60
-rw-r--r--src/net/sourceforge/plantuml/jungle/GNode.java66
-rw-r--r--src/net/sourceforge/plantuml/jungle/GNodeUtils.java55
-rw-r--r--src/net/sourceforge/plantuml/jungle/GTile.java43
-rw-r--r--src/net/sourceforge/plantuml/jungle/GTileGeometry.java75
-rw-r--r--src/net/sourceforge/plantuml/jungle/GTileLeftRight.java102
-rw-r--r--src/net/sourceforge/plantuml/jungle/GTileNode.java94
-rw-r--r--src/net/sourceforge/plantuml/jungle/GTileOneLevelFactory.java56
-rw-r--r--src/net/sourceforge/plantuml/jungle/GTileStack.java82
-rw-r--r--src/net/sourceforge/plantuml/jungle/Needle.java114
-rw-r--r--src/net/sourceforge/plantuml/jungle/PSystemTree.java106
-rw-r--r--src/net/sourceforge/plantuml/jungle/PSystemTreeFactory.java63
-rw-r--r--src/net/sourceforge/plantuml/jungle/Rendering.java41
-rw-r--r--src/net/sourceforge/plantuml/mda/MDADiagramImpl.java84
-rw-r--r--src/net/sourceforge/plantuml/mda/MDAEntityImpl.java52
-rw-r--r--src/net/sourceforge/plantuml/mda/MDAPackageImpl.java70
-rw-r--r--src/net/sourceforge/plantuml/mjpeg/MJPEGGenerator.java609
-rw-r--r--src/net/sourceforge/plantuml/objectdiagram/AbstractClassOrObjectDiagram.java235
-rw-r--r--src/net/sourceforge/plantuml/objectdiagram/ObjectDiagram.java59
-rw-r--r--src/net/sourceforge/plantuml/objectdiagram/ObjectDiagramFactory.java106
-rw-r--r--src/net/sourceforge/plantuml/objectdiagram/command/CommandAddData.java63
-rw-r--r--src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateEntityObject.java97
-rw-r--r--src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateEntityObjectMultilines.java115
-rw-r--r--src/net/sourceforge/plantuml/openiconic/Movement.java188
-rw-r--r--src/net/sourceforge/plantuml/openiconic/OpenIcon.java145
-rw-r--r--src/net/sourceforge/plantuml/openiconic/PSystemListOpenIconic.java99
-rw-r--r--src/net/sourceforge/plantuml/openiconic/PSystemListOpenIconicFactory.java52
-rw-r--r--src/net/sourceforge/plantuml/openiconic/PSystemOpenIconic.java88
-rw-r--r--src/net/sourceforge/plantuml/openiconic/PSystemOpenIconicFactory.java53
-rw-r--r--src/net/sourceforge/plantuml/openiconic/StringDecipher.java50
-rw-r--r--src/net/sourceforge/plantuml/openiconic/SvgCommand.java41
-rw-r--r--src/net/sourceforge/plantuml/openiconic/SvgCommandLetter.java114
-rw-r--r--src/net/sourceforge/plantuml/openiconic/SvgCommandNumber.java71
-rw-r--r--src/net/sourceforge/plantuml/openiconic/SvgPath.java215
-rw-r--r--src/net/sourceforge/plantuml/openiconic/SvgPosition.java89
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/DummyIcon.java39
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/account-login.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/account-logout.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/action-redo.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/action-undo.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/align-center.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/align-left.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/align-right.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/all.txt223
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/aperture.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/arrow-bottom.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/arrow-circle-bottom.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/arrow-circle-left.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/arrow-circle-right.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/arrow-circle-top.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/arrow-left.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/arrow-right.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/arrow-thick-bottom.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/arrow-thick-left.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/arrow-thick-right.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/arrow-thick-top.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/arrow-top.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/audio-spectrum.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/audio.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/badge.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/ban.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/bar-chart.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/basket.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/battery-empty.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/battery-full.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/beaker.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/bell.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/bluetooth.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/bold.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/bolt.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/book.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/bookmark.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/box.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/briefcase.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/british-pound.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/browser.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/brush.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/bug.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/bullhorn.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/calculator.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/calendar.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/camera-slr.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/caret-bottom.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/caret-left.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/caret-right.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/caret-top.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/cart.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/chat.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/check.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/chevron-bottom.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/chevron-left.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/chevron-right.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/chevron-top.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/circle-check.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/circle-x.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/clipboard.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/clock.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/cloud-download.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/cloud-upload.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/cloud.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/cloudy.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/code.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/cog.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/collapse-down.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/collapse-left.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/collapse-right.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/collapse-up.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/command.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/comment-square.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/compass.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/contrast.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/copywriting.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/credit-card.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/crop.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/dashboard.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/data-transfer-download.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/data-transfer-upload.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/delete.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/dial.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/document.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/dollar.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/double-quote-sans-left.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/double-quote-sans-right.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/double-quote-serif-left.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/double-quote-serif-right.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/droplet.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/eject.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/elevator.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/ellipses.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/envelope-closed.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/envelope-open.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/euro.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/excerpt.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/expand-down.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/expand-left.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/expand-right.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/expand-up.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/external-link.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/eye.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/eyedropper.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/file.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/fire.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/flag.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/flash.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/folder.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/fork.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/fullscreen-enter.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/fullscreen-exit.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/globe.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/graph.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/grid-four-up.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/grid-three-up.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/grid-two-up.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/hard-drive.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/header.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/headphones.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/heart.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/home.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/image.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/inbox.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/infinity.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/info.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/italic.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/justify-center.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/justify-left.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/justify-right.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/key.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/laptop.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/layers.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/lightbulb.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/link-broken.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/link-intact.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/list-rich.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/list.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/location.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/lock-locked.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/lock-unlocked.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/loop-circular.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/loop-square.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/loop.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/magnifying-glass.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/map-marker.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/map.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/media-pause.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/media-play.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/media-record.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/media-skip-backward.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/media-skip-forward.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/media-step-backward.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/media-step-forward.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/media-stop.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/medical-cross.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/menu.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/microphone.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/minus.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/monitor.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/moon.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/move.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/musical-note.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/paperclip.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/pencil.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/people.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/person.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/phone.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/pie-chart.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/pin.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/play-circle.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/plus.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/power-standby.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/print.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/project.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/pulse.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/puzzle-piece.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/question-mark.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/rain.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/random.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/reload.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/resize-both.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/resize-height.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/resize-width.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/rss-alt.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/rss.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/script.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/share-boxed.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/share.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/shield.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/signal.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/signpost.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/sort-ascending.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/sort-descending.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/spreadsheet.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/star.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/sun.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/tablet.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/tag.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/tags.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/target.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/task.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/terminal.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/text.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/thumb-down.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/thumb-up.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/timer.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/transfer.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/trash.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/underline.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/vertical-align-bottom.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/vertical-align-center.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/vertical-align-top.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/video.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/volume-high.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/volume-low.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/volume-off.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/warning.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/wifi.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/wrench.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/x.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/yen.svg3
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/zoom-in.svg4
-rw-r--r--src/net/sourceforge/plantuml/openiconic/data/zoom-out.svg4
-rw-r--r--src/net/sourceforge/plantuml/oregon/BasicGame.java42
-rw-r--r--src/net/sourceforge/plantuml/oregon/Keyboard.java41
-rw-r--r--src/net/sourceforge/plantuml/oregon/KeyboardList.java65
-rw-r--r--src/net/sourceforge/plantuml/oregon/MagicTable.java232
-rw-r--r--src/net/sourceforge/plantuml/oregon/NoInputException.java38
-rw-r--r--src/net/sourceforge/plantuml/oregon/OregonBasicGame.java939
-rw-r--r--src/net/sourceforge/plantuml/oregon/PSystemOregon.java118
-rw-r--r--src/net/sourceforge/plantuml/oregon/PSystemOregonFactory.java64
-rw-r--r--src/net/sourceforge/plantuml/oregon/Screen.java64
-rw-r--r--src/net/sourceforge/plantuml/oregon/SecureCoder.java71
-rw-r--r--src/net/sourceforge/plantuml/oregon/SmartKeyboard.java74
-rw-r--r--src/net/sourceforge/plantuml/pdf/PdfConverter.java77
-rw-r--r--src/net/sourceforge/plantuml/png/Metadata.java126
-rw-r--r--src/net/sourceforge/plantuml/png/MetadataTag.java118
-rw-r--r--src/net/sourceforge/plantuml/png/PngFlashcoder.java97
-rw-r--r--src/net/sourceforge/plantuml/png/PngIO.java107
-rw-r--r--src/net/sourceforge/plantuml/png/PngIOMetadata.java122
-rw-r--r--src/net/sourceforge/plantuml/png/PngRotation.java62
-rw-r--r--src/net/sourceforge/plantuml/png/PngSegment.java61
-rw-r--r--src/net/sourceforge/plantuml/png/PngSizer.java74
-rw-r--r--src/net/sourceforge/plantuml/png/PngSplitter.java109
-rw-r--r--src/net/sourceforge/plantuml/png/PngTitler.java111
-rw-r--r--src/net/sourceforge/plantuml/posimo/AbstractEntityImage2.java84
-rw-r--r--src/net/sourceforge/plantuml/posimo/BezierUtils.java181
-rw-r--r--src/net/sourceforge/plantuml/posimo/Block.java105
-rw-r--r--src/net/sourceforge/plantuml/posimo/Cluster.java160
-rw-r--r--src/net/sourceforge/plantuml/posimo/Clusterable.java41
-rw-r--r--src/net/sourceforge/plantuml/posimo/Decor.java44
-rw-r--r--src/net/sourceforge/plantuml/posimo/DecorInterfaceProvider.java79
-rw-r--r--src/net/sourceforge/plantuml/posimo/DotPath.java540
-rw-r--r--src/net/sourceforge/plantuml/posimo/DotxMaker.java135
-rw-r--r--src/net/sourceforge/plantuml/posimo/EntityImageNote2.java80
-rw-r--r--src/net/sourceforge/plantuml/posimo/Frame.java135
-rw-r--r--src/net/sourceforge/plantuml/posimo/GraphvizSolverB.java265
-rw-r--r--src/net/sourceforge/plantuml/posimo/IEntityImageBlock.java48
-rw-r--r--src/net/sourceforge/plantuml/posimo/Label.java91
-rw-r--r--src/net/sourceforge/plantuml/posimo/LabelImage.java86
-rw-r--r--src/net/sourceforge/plantuml/posimo/LineRectIntersection.java82
-rw-r--r--src/net/sourceforge/plantuml/posimo/LineSegmentIntersection.java80
-rw-r--r--src/net/sourceforge/plantuml/posimo/MargedBlock.java89
-rw-r--r--src/net/sourceforge/plantuml/posimo/Mirror.java53
-rw-r--r--src/net/sourceforge/plantuml/posimo/Moveable.java41
-rw-r--r--src/net/sourceforge/plantuml/posimo/Path.java97
-rw-r--r--src/net/sourceforge/plantuml/posimo/PathDrawer.java45
-rw-r--r--src/net/sourceforge/plantuml/posimo/PathDrawerInterface.java327
-rw-r--r--src/net/sourceforge/plantuml/posimo/Positionable.java46
-rw-r--r--src/net/sourceforge/plantuml/posimo/PositionableImpl.java67
-rw-r--r--src/net/sourceforge/plantuml/posimo/PositionableUtils.java177
-rw-r--r--src/net/sourceforge/plantuml/posimo/Racorder.java43
-rw-r--r--src/net/sourceforge/plantuml/posimo/RacorderAbstract.java57
-rw-r--r--src/net/sourceforge/plantuml/posimo/RacorderFollowTangeante.java72
-rw-r--r--src/net/sourceforge/plantuml/posimo/RacorderFollowTangeanteOld.java57
-rw-r--r--src/net/sourceforge/plantuml/posimo/RacorderInToCenter.java56
-rw-r--r--src/net/sourceforge/plantuml/posimo/RacorderOrthogonal.java82
-rw-r--r--src/net/sourceforge/plantuml/posimo/SimpleDrawer.java98
-rw-r--r--src/net/sourceforge/plantuml/posimo/TwoLinesIntersection.java72
-rw-r--r--src/net/sourceforge/plantuml/posimo/data.txt38
-rw-r--r--src/net/sourceforge/plantuml/postit/Area.java111
-rw-r--r--src/net/sourceforge/plantuml/postit/AreaLayout.java47
-rw-r--r--src/net/sourceforge/plantuml/postit/AreaLayoutFixedWidth.java74
-rw-r--r--src/net/sourceforge/plantuml/postit/CommandCreatePostIt.java66
-rw-r--r--src/net/sourceforge/plantuml/postit/CommandWidth.java56
-rw-r--r--src/net/sourceforge/plantuml/postit/Elastic.java45
-rw-r--r--src/net/sourceforge/plantuml/postit/PostIdDiagramFactory.java59
-rw-r--r--src/net/sourceforge/plantuml/postit/PostIt.java120
-rw-r--r--src/net/sourceforge/plantuml/postit/PostItDiagram.java140
-rw-r--r--src/net/sourceforge/plantuml/preproc/Defines.java134
-rw-r--r--src/net/sourceforge/plantuml/preproc/IfManager.java104
-rw-r--r--src/net/sourceforge/plantuml/preproc/IfManagerNegatif.java80
-rw-r--r--src/net/sourceforge/plantuml/preproc/IfManagerPositif.java72
-rw-r--r--src/net/sourceforge/plantuml/preproc/Preprocessor.java161
-rw-r--r--src/net/sourceforge/plantuml/preproc/PreprocessorInclude.java240
-rw-r--r--src/net/sourceforge/plantuml/preproc/ReadLine.java43
-rw-r--r--src/net/sourceforge/plantuml/preproc/ReadLineInsertable.java69
-rw-r--r--src/net/sourceforge/plantuml/preproc/ReadLineReader.java75
-rw-r--r--src/net/sourceforge/plantuml/preproc/StackReadLine.java58
-rw-r--r--src/net/sourceforge/plantuml/preproc/StartDiagramExtractReader.java139
-rw-r--r--src/net/sourceforge/plantuml/preproc/UncommentReadLine.java91
-rw-r--r--src/net/sourceforge/plantuml/printskin/PrintSkin.java171
-rw-r--r--src/net/sourceforge/plantuml/printskin/PrintSkinFactory.java58
-rw-r--r--src/net/sourceforge/plantuml/project/BasicInstantArithmetic.java83
-rw-r--r--src/net/sourceforge/plantuml/project/Constant.java57
-rw-r--r--src/net/sourceforge/plantuml/project/Day.java176
-rw-r--r--src/net/sourceforge/plantuml/project/DayClose.java41
-rw-r--r--src/net/sourceforge/plantuml/project/DayCloseNone.java43
-rw-r--r--src/net/sourceforge/plantuml/project/DayCloseOr.java57
-rw-r--r--src/net/sourceforge/plantuml/project/DayCloseWeekDay.java52
-rw-r--r--src/net/sourceforge/plantuml/project/Duration.java81
-rw-r--r--src/net/sourceforge/plantuml/project/Expression.java45
-rw-r--r--src/net/sourceforge/plantuml/project/Formal.java39
-rw-r--r--src/net/sourceforge/plantuml/project/FormalAddition.java59
-rw-r--r--src/net/sourceforge/plantuml/project/FormalAdditionInstantDuration.java66
-rw-r--r--src/net/sourceforge/plantuml/project/FreeVariable.java70
-rw-r--r--src/net/sourceforge/plantuml/project/IncompleteItem.java191
-rw-r--r--src/net/sourceforge/plantuml/project/Instant.java86
-rw-r--r--src/net/sourceforge/plantuml/project/InstantArithmetic.java44
-rw-r--r--src/net/sourceforge/plantuml/project/Item.java61
-rw-r--r--src/net/sourceforge/plantuml/project/ItemCaract.java72
-rw-r--r--src/net/sourceforge/plantuml/project/ItemComparator.java59
-rw-r--r--src/net/sourceforge/plantuml/project/Jalon.java94
-rw-r--r--src/net/sourceforge/plantuml/project/Load.java79
-rw-r--r--src/net/sourceforge/plantuml/project/Month.java89
-rw-r--r--src/net/sourceforge/plantuml/project/Numeric.java42
-rw-r--r--src/net/sourceforge/plantuml/project/NumericNumber.java76
-rw-r--r--src/net/sourceforge/plantuml/project/NumericType.java79
-rw-r--r--src/net/sourceforge/plantuml/project/PSystemProject.java124
-rw-r--r--src/net/sourceforge/plantuml/project/ParentItem.java132
-rw-r--r--src/net/sourceforge/plantuml/project/Project.java282
-rw-r--r--src/net/sourceforge/plantuml/project/Ressource.java59
-rw-r--r--src/net/sourceforge/plantuml/project/WeekDay.java61
-rw-r--r--src/net/sourceforge/plantuml/project/command/CommandAffectation.java59
-rw-r--r--src/net/sourceforge/plantuml/project/command/CommandCloseWeekDay.java57
-rw-r--r--src/net/sourceforge/plantuml/project/graphic/GanttDiagram.java139
-rw-r--r--src/net/sourceforge/plantuml/project/graphic/ItemHeader.java116
-rw-r--r--src/net/sourceforge/plantuml/project/graphic/TimeScale.java158
-rw-r--r--src/net/sourceforge/plantuml/project2/Day.java170
-rw-r--r--src/net/sourceforge/plantuml/project2/GanttDiagram2.java111
-rw-r--r--src/net/sourceforge/plantuml/project2/Knowledge.java115
-rw-r--r--src/net/sourceforge/plantuml/project2/PSystemProject2.java123
-rw-r--r--src/net/sourceforge/plantuml/project2/PSystemProjectFactory2.java71
-rw-r--r--src/net/sourceforge/plantuml/project2/Project2.java165
-rw-r--r--src/net/sourceforge/plantuml/project2/Ressource.java45
-rw-r--r--src/net/sourceforge/plantuml/project2/Row.java51
-rw-r--r--src/net/sourceforge/plantuml/project2/RowMerge.java100
-rw-r--r--src/net/sourceforge/plantuml/project2/RowOverwrite.java90
-rw-r--r--src/net/sourceforge/plantuml/project2/RowSimple.java112
-rw-r--r--src/net/sourceforge/plantuml/project2/RowUtils.java58
-rw-r--r--src/net/sourceforge/plantuml/project2/Task.java51
-rw-r--r--src/net/sourceforge/plantuml/project2/TaskAttribute.java63
-rw-r--r--src/net/sourceforge/plantuml/project2/TaskContainer.java41
-rw-r--r--src/net/sourceforge/plantuml/project2/TaskImpl.java89
-rw-r--r--src/net/sourceforge/plantuml/project2/TaskMerge.java75
-rw-r--r--src/net/sourceforge/plantuml/project2/TimeConverter.java45
-rw-r--r--src/net/sourceforge/plantuml/project2/TimeConverterDay.java111
-rw-r--r--src/net/sourceforge/plantuml/project2/TimeElement.java49
-rw-r--r--src/net/sourceforge/plantuml/project2/TimeHeaderDay.java101
-rw-r--r--src/net/sourceforge/plantuml/project2/TimeHeaderMonth.java118
-rw-r--r--src/net/sourceforge/plantuml/project2/TimeLine.java47
-rw-r--r--src/net/sourceforge/plantuml/project2/TimeLineDay.java71
-rw-r--r--src/net/sourceforge/plantuml/project2/TimeResolution.java39
-rw-r--r--src/net/sourceforge/plantuml/project2/TimeUtils.java65
-rw-r--r--src/net/sourceforge/plantuml/project2/Value.java38
-rw-r--r--src/net/sourceforge/plantuml/project2/ValueInt.java54
-rw-r--r--src/net/sourceforge/plantuml/project2/ValueTime.java48
-rw-r--r--src/net/sourceforge/plantuml/project2/command/CommandAffectation.java59
-rw-r--r--src/net/sourceforge/plantuml/project2/command/CommandCloseWeekDay.java55
-rw-r--r--src/net/sourceforge/plantuml/real/PositiveForce.java68
-rw-r--r--src/net/sourceforge/plantuml/real/Real.java51
-rw-r--r--src/net/sourceforge/plantuml/real/RealDelta.java73
-rw-r--r--src/net/sourceforge/plantuml/real/RealImpl.java74
-rw-r--r--src/net/sourceforge/plantuml/real/RealLine.java76
-rw-r--r--src/net/sourceforge/plantuml/real/RealMax.java85
-rw-r--r--src/net/sourceforge/plantuml/real/RealMiddle.java77
-rw-r--r--src/net/sourceforge/plantuml/real/RealMin.java89
-rw-r--r--src/net/sourceforge/plantuml/real/RealMoveable.java62
-rw-r--r--src/net/sourceforge/plantuml/real/RealUtils.java59
-rw-r--r--src/net/sourceforge/plantuml/salt/Cell.java85
-rw-r--r--src/net/sourceforge/plantuml/salt/DataSource.java42
-rw-r--r--src/net/sourceforge/plantuml/salt/DataSourceImpl.java114
-rw-r--r--src/net/sourceforge/plantuml/salt/Dictionary.java78
-rw-r--r--src/net/sourceforge/plantuml/salt/PSystemSalt.java131
-rw-r--r--src/net/sourceforge/plantuml/salt/PSystemSaltFactory.java69
-rw-r--r--src/net/sourceforge/plantuml/salt/Position.java66
-rw-r--r--src/net/sourceforge/plantuml/salt/Positionner2.java112
-rw-r--r--src/net/sourceforge/plantuml/salt/SaltUtils.java114
-rw-r--r--src/net/sourceforge/plantuml/salt/Terminated.java62
-rw-r--r--src/net/sourceforge/plantuml/salt/Terminator.java39
-rw-r--r--src/net/sourceforge/plantuml/salt/element/AbstractElement.java39
-rw-r--r--src/net/sourceforge/plantuml/salt/element/AbstractElementText.java114
-rw-r--r--src/net/sourceforge/plantuml/salt/element/Element.java48
-rw-r--r--src/net/sourceforge/plantuml/salt/element/ElementBorder.java106
-rw-r--r--src/net/sourceforge/plantuml/salt/element/ElementButton.java77
-rw-r--r--src/net/sourceforge/plantuml/salt/element/ElementDroplist.java121
-rw-r--r--src/net/sourceforge/plantuml/salt/element/ElementEmpty.java51
-rw-r--r--src/net/sourceforge/plantuml/salt/element/ElementImage.java73
-rw-r--r--src/net/sourceforge/plantuml/salt/element/ElementLine.java85
-rw-r--r--src/net/sourceforge/plantuml/salt/element/ElementMenuBar.java133
-rw-r--r--src/net/sourceforge/plantuml/salt/element/ElementMenuEntry.java101
-rw-r--r--src/net/sourceforge/plantuml/salt/element/ElementMenuPopup.java97
-rw-r--r--src/net/sourceforge/plantuml/salt/element/ElementPyramid.java151
-rw-r--r--src/net/sourceforge/plantuml/salt/element/ElementRadioCheckbox.java111
-rw-r--r--src/net/sourceforge/plantuml/salt/element/ElementTabBar.java151
-rw-r--r--src/net/sourceforge/plantuml/salt/element/ElementText.java81
-rw-r--r--src/net/sourceforge/plantuml/salt/element/ElementTextField.java71
-rw-r--r--src/net/sourceforge/plantuml/salt/element/ElementTree.java209
-rw-r--r--src/net/sourceforge/plantuml/salt/element/ElementTreeEntry.java90
-rw-r--r--src/net/sourceforge/plantuml/salt/element/Grid.java118
-rw-r--r--src/net/sourceforge/plantuml/salt/element/Grid2.java92
-rw-r--r--src/net/sourceforge/plantuml/salt/element/LeftFirst.java52
-rw-r--r--src/net/sourceforge/plantuml/salt/element/ListWidth.java81
-rw-r--r--src/net/sourceforge/plantuml/salt/element/Segment.java66
-rw-r--r--src/net/sourceforge/plantuml/salt/element/TableStrategy.java54
-rw-r--r--src/net/sourceforge/plantuml/salt/element/TopFirst.java52
-rw-r--r--src/net/sourceforge/plantuml/salt/element/WrappedElement.java58
-rw-r--r--src/net/sourceforge/plantuml/salt/factory/AbstractElementFactoryComplex.java78
-rw-r--r--src/net/sourceforge/plantuml/salt/factory/ElementFactory.java46
-rw-r--r--src/net/sourceforge/plantuml/salt/factory/ElementFactoryBorder.java101
-rw-r--r--src/net/sourceforge/plantuml/salt/factory/ElementFactoryButton.java71
-rw-r--r--src/net/sourceforge/plantuml/salt/factory/ElementFactoryCheckboxOff.java78
-rw-r--r--src/net/sourceforge/plantuml/salt/factory/ElementFactoryCheckboxOn.java78
-rw-r--r--src/net/sourceforge/plantuml/salt/factory/ElementFactoryDroplist.java71
-rw-r--r--src/net/sourceforge/plantuml/salt/factory/ElementFactoryImage.java78
-rw-r--r--src/net/sourceforge/plantuml/salt/factory/ElementFactoryLine.java80
-rw-r--r--src/net/sourceforge/plantuml/salt/factory/ElementFactoryMenu.java90
-rw-r--r--src/net/sourceforge/plantuml/salt/factory/ElementFactoryPyramid.java96
-rw-r--r--src/net/sourceforge/plantuml/salt/factory/ElementFactoryRadioOff.java78
-rw-r--r--src/net/sourceforge/plantuml/salt/factory/ElementFactoryRadioOn.java78
-rw-r--r--src/net/sourceforge/plantuml/salt/factory/ElementFactoryRetrieveFromDictonnary.java72
-rw-r--r--src/net/sourceforge/plantuml/salt/factory/ElementFactoryTab.java81
-rw-r--r--src/net/sourceforge/plantuml/salt/factory/ElementFactoryText.java78
-rw-r--r--src/net/sourceforge/plantuml/salt/factory/ElementFactoryTextField.java72
-rw-r--r--src/net/sourceforge/plantuml/salt/factory/ElementFactoryTree.java101
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/AbstractEvent.java53
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/AbstractMessage.java206
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/Delay.java54
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/Divider.java55
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/Event.java49
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/EventWithDeactivate.java46
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/Grouping.java81
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/GroupingLeaf.java117
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/GroupingStart.java96
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/GroupingType.java66
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/HSpace.java57
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/InGroupable.java47
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/InGroupableList.java219
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/LifeEvent.java108
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/LifeEventType.java40
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/Message.java78
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/MessageExo.java93
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/MessageExoType.java64
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/MessageNumber.java66
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/Newpage.java54
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/Note.java134
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/NotePosition.java39
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/NoteStyle.java50
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/Notes.java66
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/Participant.java162
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/ParticipantEnglober.java59
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/ParticipantEngloberContexted.java78
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/ParticipantType.java57
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/Reference.java103
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/SequenceDiagram.java451
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/SequenceDiagramFactory.java146
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandActivate.java66
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandActivate2.java63
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandArrow.java284
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandAutoNewpage.java54
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandAutoactivate.java54
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandAutonumber.java72
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandBoxEnd.java58
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandBoxStart.java62
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandDelay.java56
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandDivider.java56
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowAny.java162
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowLeft.java95
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowRight.java95
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandFootbox.java55
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandFootboxOld.java55
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandGrouping.java92
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandHSpace.java60
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandIgnoreNewpage.java54
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandNewpage.java56
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipant.java128
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA.java63
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA2.java64
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA3.java63
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA4.java62
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandReferenceMultilinesOverSeveral.java92
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandReferenceOverSeveral.java98
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandReturn.java85
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandSkin.java57
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/command/CommandUrl.java65
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/Arrow.java126
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/ArrowAndNoteBox.java138
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/ArrowAndParticipant.java148
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/Constraint.java78
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/ConstraintSet.java186
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSet.java461
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java613
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/FileMaker.java47
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/FreeYStrategy.java44
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/FreeYStrategyBasic.java48
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/Frontier.java43
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/FrontierComplex.java106
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/FrontierSimple.java60
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/FrontierStack.java44
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/FrontierStackImpl.java128
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalDelayText.java93
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalDivider.java79
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalElement.java70
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalElementLiveEvent.java62
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalHSpace.java69
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalNewpage.java81
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalReference.java117
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/GroupingGraphicalElement.java66
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/GroupingGraphicalElementElse.java106
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/GroupingGraphicalElementHeader.java99
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/GroupingGraphicalElementTail.java63
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/InGroupablesStack.java73
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/Lazy.java40
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/LifeDestroy.java77
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/LifeLine.java242
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/LifeSegmentVariation.java51
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/LivingParticipantBox.java122
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/MessageArrow.java190
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/MessageExoArrow.java210
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/MessageSelfArrow.java147
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/NoteBox.java160
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/NotesBoxes.java149
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/Page.java122
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/PageSplitter.java116
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantBox.java255
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantBoxSimple.java78
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantRange.java62
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/Pushable.java52
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/Segment.java125
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/SegmentColored.java159
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramArea.java145
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramFileMakerPuma2.java315
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramTxtMaker.java124
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/Stairs.java129
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/Step1Abstract.java151
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/Step1Message.java251
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/graphic/Step1MessageExo.java159
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/puma/FixedLink.java59
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/puma/PSegment.java72
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/puma/PUnivers.java70
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/puma/PushDirection.java40
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/puma/PushSide.java40
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/puma/PushStrategy.java40
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/puma/SegmentPosition.java56
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationExoTile.java149
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTile.java214
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileNoteLeft.java124
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileNoteRight.java125
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileSelf.java189
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileSelfNoteRight.java124
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/DelayTile.java126
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/DividerTile.java108
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/ElseTile.java111
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/EventsHistory.java186
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/EventsHistoryMode.java40
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/GroupingTile.java166
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/IntegerColored.java62
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/LifeEventTile.java96
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/LiveBoxFinder.java121
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/LiveBoxes.java120
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/LivingSpace.java205
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/LivingSpaces.java101
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/MainTile.java144
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/MutingLine.java84
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/NoteTile.java148
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/ReferenceTile.java130
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java243
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/Stairs2.java114
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/StairsPosition.java71
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/Tile.java55
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/TileArguments.java121
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/TileBuilder.java155
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/TileMarged.java84
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/TileUtils.java43
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/TileWithUpdateStairs.java42
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/UGraphicInterceptorTile.java70
-rw-r--r--src/net/sourceforge/plantuml/sequencediagram/teoz/YPositionedTile.java56
-rw-r--r--src/net/sourceforge/plantuml/skin/AbstractComponent.java98
-rw-r--r--src/net/sourceforge/plantuml/skin/AbstractTextualComponent.java147
-rw-r--r--src/net/sourceforge/plantuml/skin/Area.java71
-rw-r--r--src/net/sourceforge/plantuml/skin/ArrowBody.java39
-rw-r--r--src/net/sourceforge/plantuml/skin/ArrowComponent.java50
-rw-r--r--src/net/sourceforge/plantuml/skin/ArrowConfiguration.java213
-rw-r--r--src/net/sourceforge/plantuml/skin/ArrowDecoration.java39
-rw-r--r--src/net/sourceforge/plantuml/skin/ArrowDirection.java52
-rw-r--r--src/net/sourceforge/plantuml/skin/ArrowDressing.java81
-rw-r--r--src/net/sourceforge/plantuml/skin/ArrowHead.java39
-rw-r--r--src/net/sourceforge/plantuml/skin/ArrowPart.java39
-rw-r--r--src/net/sourceforge/plantuml/skin/CircleInterface.java80
-rw-r--r--src/net/sourceforge/plantuml/skin/Component.java52
-rw-r--r--src/net/sourceforge/plantuml/skin/ComponentType.java69
-rw-r--r--src/net/sourceforge/plantuml/skin/Context2D.java39
-rw-r--r--src/net/sourceforge/plantuml/skin/GrayComponent.java93
-rw-r--r--src/net/sourceforge/plantuml/skin/ProtectedSkin.java65
-rw-r--r--src/net/sourceforge/plantuml/skin/SimpleContext2D.java49
-rw-r--r--src/net/sourceforge/plantuml/skin/Skin.java46
-rw-r--r--src/net/sourceforge/plantuml/skin/SkinUtils.java79
-rw-r--r--src/net/sourceforge/plantuml/skin/StickMan.java114
-rw-r--r--src/net/sourceforge/plantuml/skin/VisibilityModifier.java235
-rw-r--r--src/net/sourceforge/plantuml/skin/bluemodern/AbstractComponentBlueModernArrow.java92
-rw-r--r--src/net/sourceforge/plantuml/skin/bluemodern/BlueModern.java185
-rw-r--r--src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernActiveLine.java81
-rw-r--r--src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernActor.java97
-rw-r--r--src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernArrow.java192
-rw-r--r--src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernDelayLine.java77
-rw-r--r--src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernDelayText.java82
-rw-r--r--src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernDivider.java112
-rw-r--r--src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernEnglober.java95
-rw-r--r--src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernGroupingHeader.java159
-rw-r--r--src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernLine.java75
-rw-r--r--src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernNewpage.java72
-rw-r--r--src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernNote.java117
-rw-r--r--src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernParticipant.java90
-rw-r--r--src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernSelfArrow.java148
-rw-r--r--src/net/sourceforge/plantuml/skin/bluemodern/FillRoundShape.java79
-rw-r--r--src/net/sourceforge/plantuml/skin/bluemodern/ShadowShape.java46
-rw-r--r--src/net/sourceforge/plantuml/skin/rose/AbstractComponentRoseArrow.java83
-rw-r--r--src/net/sourceforge/plantuml/skin/rose/ComponentRoseActiveLine.java102
-rw-r--r--src/net/sourceforge/plantuml/skin/rose/ComponentRoseActor.java99
-rw-r--r--src/net/sourceforge/plantuml/skin/rose/ComponentRoseArrow.java294
-rw-r--r--src/net/sourceforge/plantuml/skin/rose/ComponentRoseBoundary.java100
-rw-r--r--src/net/sourceforge/plantuml/skin/rose/ComponentRoseControl.java100
-rw-r--r--src/net/sourceforge/plantuml/skin/rose/ComponentRoseDatabase.java106
-rw-r--r--src/net/sourceforge/plantuml/skin/rose/ComponentRoseDelayLine.java75
-rw-r--r--src/net/sourceforge/plantuml/skin/rose/ComponentRoseDelayText.java81
-rw-r--r--src/net/sourceforge/plantuml/skin/rose/ComponentRoseDestroy.java75
-rw-r--r--src/net/sourceforge/plantuml/skin/rose/ComponentRoseDivider.java139
-rw-r--r--src/net/sourceforge/plantuml/skin/rose/ComponentRoseEnglober.java86
-rw-r--r--src/net/sourceforge/plantuml/skin/rose/ComponentRoseEntity.java100
-rw-r--r--src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingElse.java96
-rw-r--r--src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingHeader.java162
-rw-r--r--src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingSpace.java71
-rw-r--r--src/net/sourceforge/plantuml/skin/rose/ComponentRoseLine.java84
-rw-r--r--src/net/sourceforge/plantuml/skin/rose/ComponentRoseNewpage.java72
-rw-r--r--src/net/sourceforge/plantuml/skin/rose/ComponentRoseNote.java136
-rw-r--r--src/net/sourceforge/plantuml/skin/rose/ComponentRoseNoteBox.java104
-rw-r--r--src/net/sourceforge/plantuml/skin/rose/ComponentRoseNoteHexagonal.java115
-rw-r--r--src/net/sourceforge/plantuml/skin/rose/ComponentRoseParticipant.java98
-rw-r--r--src/net/sourceforge/plantuml/skin/rose/ComponentRoseReference.java143
-rw-r--r--src/net/sourceforge/plantuml/skin/rose/ComponentRoseSelfArrow.java191
-rw-r--r--src/net/sourceforge/plantuml/skin/rose/ComponentRoseTitle.java73
-rw-r--r--src/net/sourceforge/plantuml/skin/rose/Rose.java307
-rw-r--r--src/net/sourceforge/plantuml/statediagram/StateDiagram.java216
-rw-r--r--src/net/sourceforge/plantuml/statediagram/StateDiagramFactory.java145
-rw-r--r--src/net/sourceforge/plantuml/statediagram/command/CommandAddField.java74
-rw-r--r--src/net/sourceforge/plantuml/statediagram/command/CommandConcurrentState.java57
-rw-r--r--src/net/sourceforge/plantuml/statediagram/command/CommandCreatePackageState.java115
-rw-r--r--src/net/sourceforge/plantuml/statediagram/command/CommandCreateState.java141
-rw-r--r--src/net/sourceforge/plantuml/statediagram/command/CommandEndState.java60
-rw-r--r--src/net/sourceforge/plantuml/statediagram/command/CommandHideEmptyDescription.java55
-rw-r--r--src/net/sourceforge/plantuml/statediagram/command/CommandLinkState.java219
-rw-r--r--src/net/sourceforge/plantuml/suggest/SuggestEngine.java181
-rw-r--r--src/net/sourceforge/plantuml/suggest/SuggestEngineResult.java96
-rw-r--r--src/net/sourceforge/plantuml/suggest/SuggestEngineStatus.java40
-rw-r--r--src/net/sourceforge/plantuml/suggest/Variator.java42
-rw-r--r--src/net/sourceforge/plantuml/suggest/VariatorAddOneChar.java63
-rw-r--r--src/net/sourceforge/plantuml/suggest/VariatorAddOneCharBetweenWords.java77
-rw-r--r--src/net/sourceforge/plantuml/suggest/VariatorAddTwoChar.java68
-rw-r--r--src/net/sourceforge/plantuml/suggest/VariatorIteratorAdaptor.java67
-rw-r--r--src/net/sourceforge/plantuml/suggest/VariatorRemoveOneChar.java61
-rw-r--r--src/net/sourceforge/plantuml/suggest/VariatorSwapChar.java61
-rw-r--r--src/net/sourceforge/plantuml/suggest/VariatorSwapLetter.java75
-rw-r--r--src/net/sourceforge/plantuml/svek/AbstractEntityImage.java75
-rw-r--r--src/net/sourceforge/plantuml/svek/AbstractExtremityFactory.java51
-rw-r--r--src/net/sourceforge/plantuml/svek/ArithmeticStrategy.java43
-rw-r--r--src/net/sourceforge/plantuml/svek/ArithmeticStrategyMax.java51
-rw-r--r--src/net/sourceforge/plantuml/svek/ArithmeticStrategySum.java49
-rw-r--r--src/net/sourceforge/plantuml/svek/Bibliotekon.java184
-rw-r--r--src/net/sourceforge/plantuml/svek/Boundary.java102
-rw-r--r--src/net/sourceforge/plantuml/svek/CircleAndArrow.java99
-rw-r--r--src/net/sourceforge/plantuml/svek/CircleInterface2.java84
-rw-r--r--src/net/sourceforge/plantuml/svek/Cluster.java868
-rw-r--r--src/net/sourceforge/plantuml/svek/ClusterDecoration.java235
-rw-r--r--src/net/sourceforge/plantuml/svek/ClusterPosition.java191
-rw-r--r--src/net/sourceforge/plantuml/svek/ColorSequence.java47
-rw-r--r--src/net/sourceforge/plantuml/svek/ConditionStyle.java53
-rw-r--r--src/net/sourceforge/plantuml/svek/Control.java92
-rw-r--r--src/net/sourceforge/plantuml/svek/CucaDiagramFileMaker.java48
-rw-r--r--src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek.java238
-rw-r--r--src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek2.java579
-rw-r--r--src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek2InternalImage.java160
-rw-r--r--src/net/sourceforge/plantuml/svek/DecorateEntityImage.java156
-rw-r--r--src/net/sourceforge/plantuml/svek/DecorateEntityImage3.java66
-rw-r--r--src/net/sourceforge/plantuml/svek/DecorateTextBlock.java136
-rw-r--r--src/net/sourceforge/plantuml/svek/DotMode.java40
-rw-r--r--src/net/sourceforge/plantuml/svek/DotStringFactory.java423
-rw-r--r--src/net/sourceforge/plantuml/svek/EmptySvgException.java39
-rw-r--r--src/net/sourceforge/plantuml/svek/EntityDomain.java76
-rw-r--r--src/net/sourceforge/plantuml/svek/EntityImageProtected.java89
-rw-r--r--src/net/sourceforge/plantuml/svek/FrontierCalculator.java164
-rw-r--r--src/net/sourceforge/plantuml/svek/GraphvizCrash.java154
-rw-r--r--src/net/sourceforge/plantuml/svek/GroupPngMakerActivity.java140
-rw-r--r--src/net/sourceforge/plantuml/svek/GroupPngMakerState.java198
-rw-r--r--src/net/sourceforge/plantuml/svek/HeaderLayout.java119
-rw-r--r--src/net/sourceforge/plantuml/svek/IEntityImage.java49
-rw-r--r--src/net/sourceforge/plantuml/svek/IShapePseudo.java43
-rw-r--r--src/net/sourceforge/plantuml/svek/InnerActivity.java99
-rw-r--r--src/net/sourceforge/plantuml/svek/InnerStateAutonom.java148
-rw-r--r--src/net/sourceforge/plantuml/svek/Line.java849
-rw-r--r--src/net/sourceforge/plantuml/svek/MinFinder.java77
-rw-r--r--src/net/sourceforge/plantuml/svek/Oscillator.java88
-rw-r--r--src/net/sourceforge/plantuml/svek/PackageStyle.java294
-rw-r--r--src/net/sourceforge/plantuml/svek/PointAndAngle.java65
-rw-r--r--src/net/sourceforge/plantuml/svek/PointDirected.java59
-rw-r--r--src/net/sourceforge/plantuml/svek/RoundedContainer.java99
-rw-r--r--src/net/sourceforge/plantuml/svek/Shape.java264
-rw-r--r--src/net/sourceforge/plantuml/svek/ShapePseudoImpl.java60
-rw-r--r--src/net/sourceforge/plantuml/svek/ShapeType.java41
-rw-r--r--src/net/sourceforge/plantuml/svek/SingleStrategy.java87
-rw-r--r--src/net/sourceforge/plantuml/svek/SvekResult.java134
-rw-r--r--src/net/sourceforge/plantuml/svek/SvekUtils.java196
-rw-r--r--src/net/sourceforge/plantuml/svek/TextBlockBackcolored.java44
-rw-r--r--src/net/sourceforge/plantuml/svek/UGraphicForSnake.java143
-rw-r--r--src/net/sourceforge/plantuml/svek/Untranslated.java43
-rw-r--r--src/net/sourceforge/plantuml/svek/extremity/Extremity.java69
-rw-r--r--src/net/sourceforge/plantuml/svek/extremity/ExtremityArrow.java76
-rw-r--r--src/net/sourceforge/plantuml/svek/extremity/ExtremityArrowAndCircle.java78
-rw-r--r--src/net/sourceforge/plantuml/svek/extremity/ExtremityCircle.java59
-rw-r--r--src/net/sourceforge/plantuml/svek/extremity/ExtremityCircleConnect.java84
-rw-r--r--src/net/sourceforge/plantuml/svek/extremity/ExtremityCircleCross.java80
-rw-r--r--src/net/sourceforge/plantuml/svek/extremity/ExtremityDiamond.java69
-rw-r--r--src/net/sourceforge/plantuml/svek/extremity/ExtremityFactory.java45
-rw-r--r--src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryArrow.java49
-rw-r--r--src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryArrowAndCircle.java49
-rw-r--r--src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryCircle.java49
-rw-r--r--src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryCircleConnect.java49
-rw-r--r--src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryCircleCross.java49
-rw-r--r--src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryDiamond.java54
-rw-r--r--src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryParenthesis.java54
-rw-r--r--src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryPlus.java49
-rw-r--r--src/net/sourceforge/plantuml/svek/extremity/ExtremityFactorySquarre.java49
-rw-r--r--src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryTriangle.java50
-rw-r--r--src/net/sourceforge/plantuml/svek/extremity/ExtremityParenthesis.java63
-rw-r--r--src/net/sourceforge/plantuml/svek/extremity/ExtremityParenthesis2.java84
-rw-r--r--src/net/sourceforge/plantuml/svek/extremity/ExtremityPlus.java80
-rw-r--r--src/net/sourceforge/plantuml/svek/extremity/ExtremitySquarre.java59
-rw-r--r--src/net/sourceforge/plantuml/svek/extremity/ExtremityStateLine1.java93
-rw-r--r--src/net/sourceforge/plantuml/svek/extremity/ExtremityStateLine2.java74
-rw-r--r--src/net/sourceforge/plantuml/svek/extremity/ExtremityTriangle.java68
-rw-r--r--src/net/sourceforge/plantuml/svek/extremity/MiddleCircle.java53
-rw-r--r--src/net/sourceforge/plantuml/svek/extremity/MiddleCircleCircled.java80
-rw-r--r--src/net/sourceforge/plantuml/svek/extremity/MiddleCircleCircledMode.java41
-rw-r--r--src/net/sourceforge/plantuml/svek/extremity/MiddleFactory.java43
-rw-r--r--src/net/sourceforge/plantuml/svek/extremity/MiddleFactoryCircle.java45
-rw-r--r--src/net/sourceforge/plantuml/svek/extremity/MiddleFactoryCircleCircled.java51
-rw-r--r--src/net/sourceforge/plantuml/svek/image/Circle.java97
-rw-r--r--src/net/sourceforge/plantuml/svek/image/ConnectedCircle.java86
-rw-r--r--src/net/sourceforge/plantuml/svek/image/ContainingEllipse.java88
-rw-r--r--src/net/sourceforge/plantuml/svek/image/EntityImageActivity.java159
-rw-r--r--src/net/sourceforge/plantuml/svek/image/EntityImageArcCircle.java124
-rw-r--r--src/net/sourceforge/plantuml/svek/image/EntityImageAssociation.java89
-rw-r--r--src/net/sourceforge/plantuml/svek/image/EntityImageAssociationPoint.java77
-rw-r--r--src/net/sourceforge/plantuml/svek/image/EntityImageBranch.java89
-rw-r--r--src/net/sourceforge/plantuml/svek/image/EntityImageCircleEnd.java91
-rw-r--r--src/net/sourceforge/plantuml/svek/image/EntityImageCircleStart.java83
-rw-r--r--src/net/sourceforge/plantuml/svek/image/EntityImageClass.java209
-rw-r--r--src/net/sourceforge/plantuml/svek/image/EntityImageClassHeader2.java185
-rw-r--r--src/net/sourceforge/plantuml/svek/image/EntityImageComponent.java129
-rw-r--r--src/net/sourceforge/plantuml/svek/image/EntityImageEmptyPackage2.java117
-rw-r--r--src/net/sourceforge/plantuml/svek/image/EntityImageGroup.java73
-rw-r--r--src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterface.java116
-rw-r--r--src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterfaceEye1.java140
-rw-r--r--src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterfaceEye2.java146
-rw-r--r--src/net/sourceforge/plantuml/svek/image/EntityImageNote.java279
-rw-r--r--src/net/sourceforge/plantuml/svek/image/EntityImageNoteLink.java90
-rw-r--r--src/net/sourceforge/plantuml/svek/image/EntityImageObject.java223
-rw-r--r--src/net/sourceforge/plantuml/svek/image/EntityImagePseudoState.java110
-rw-r--r--src/net/sourceforge/plantuml/svek/image/EntityImageState.java201
-rw-r--r--src/net/sourceforge/plantuml/svek/image/EntityImageState2.java123
-rw-r--r--src/net/sourceforge/plantuml/svek/image/EntityImageStateBorder.java165
-rw-r--r--src/net/sourceforge/plantuml/svek/image/EntityImageStateEmptyDescription.java138
-rw-r--r--src/net/sourceforge/plantuml/svek/image/EntityImageSynchroBar.java86
-rw-r--r--src/net/sourceforge/plantuml/svek/image/EntityImageUseCase.java193
-rw-r--r--src/net/sourceforge/plantuml/svek/image/Footprint.java178
-rw-r--r--src/net/sourceforge/plantuml/svek/image/Opale.java220
-rw-r--r--src/net/sourceforge/plantuml/svek/image/SmallestEnclosingCircle.java83
-rw-r--r--src/net/sourceforge/plantuml/svek/image/YTransformer.java59
-rw-r--r--src/net/sourceforge/plantuml/svg/SvgData.java143
-rw-r--r--src/net/sourceforge/plantuml/svg/SvgGraphics.java699
-rw-r--r--src/net/sourceforge/plantuml/swing/AboutWindow.java154
-rw-r--r--src/net/sourceforge/plantuml/swing/ImageHelper.java173
-rw-r--r--src/net/sourceforge/plantuml/swing/ImageWindow2.java289
-rw-r--r--src/net/sourceforge/plantuml/swing/LicenseWindow.java142
-rw-r--r--src/net/sourceforge/plantuml/swing/MainWindow2.java406
-rw-r--r--src/net/sourceforge/plantuml/swing/ScrollablePicture.java130
-rw-r--r--src/net/sourceforge/plantuml/swing/SimpleLine2.java86
-rw-r--r--src/net/sourceforge/plantuml/swing/SpriteWindow.java164
-rw-r--r--src/net/sourceforge/plantuml/syntax/LanguageDescriptor.java165
-rw-r--r--src/net/sourceforge/plantuml/syntax/SyntaxChecker.java152
-rw-r--r--src/net/sourceforge/plantuml/syntax/SyntaxResult.java127
-rw-r--r--src/net/sourceforge/plantuml/telnet/AcceptTelnetClient.java91
-rw-r--r--src/net/sourceforge/plantuml/telnet/TelnetServer.java49
-rw-r--r--src/net/sourceforge/plantuml/tikz/TikzGraphics.java302
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/AbstractCommonUGraphic.java150
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/AbstractPlacementStrategy.java114
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/AbstractShadowable.java49
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/AbstractUGraphic.java97
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/AbstractUGraphicHorizontalLine.java74
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/ClipContainer.java39
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/ColorChangerMonochrome.java48
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/ColorMapper.java44
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/ColorMapperIdentity.java59
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/ColorMapperMonochrome.java51
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/ColorMapperTransparentWrapper.java63
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/CompressionTransform.java66
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/FontChecker.java246
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java304
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/InflaterSet.java68
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/LimitFinder.java228
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/MinMax.java135
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/MinMaxMutable.java104
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/PlacementStrategy.java48
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/PlacementStrategyVisibility.java71
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/PlacementStrategyX1X2.java66
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/PlacementStrategyX1Y2Y3.java88
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/PlacementStrategyY1Y2.java66
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/PlacementStrategyY1Y2Center.java66
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/PlacementStrategyY1Y2Left.java66
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/Scalable.java40
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/ShadowManager.java78
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/Shadowable.java43
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/Slot.java99
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/SlotFinder.java140
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/SlotFinderX.java151
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/SlotSet.java121
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/Sprite.java44
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/SpriteGrayLevel.java281
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/SpriteImage.java66
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/SpriteMonochrome.java119
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/SpriteUtils.java76
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/TextBlockInEllipse.java87
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/TextLimitFinder.java135
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UAntiAliasing.java53
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UCenteredCharacter.java55
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UChange.java41
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UChangeBackColor.java56
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UChangeColor.java50
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UClip.java154
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UDriver.java40
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UEllipse.java106
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UEmpty.java58
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UFont.java154
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UFontContext.java39
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UFontUser.java39
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UGraphic.java59
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UGraphic2.java43
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UGraphicCompress.java89
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UGraphicCompress2.java97
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UGraphicFilter.java61
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UGraphicNull.java76
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UGraphicStencil.java62
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UGraphicUtils.java127
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UHidden.java41
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UHorizontalLine.java181
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UImage.java59
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UImageSvg.java78
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/ULayoutGroup.java63
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/ULine.java73
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UMotif.java169
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UParam.java52
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UParamNull.java66
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UPath.java143
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UPattern.java41
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UPixel.java38
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UPolygon.java130
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/URectangle.java105
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UScale.java62
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/USegment.java62
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/USegmentType.java60
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UShape.java39
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UStroke.java95
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UText.java74
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UTranslate.java89
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/arc/ExtendedGeneralPath.java766
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/arc/ExtendedPathIterator.java133
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/eps/DriverCenteredCharacterEps.java66
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/eps/DriverDotPathEps.java57
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/eps/DriverEllipseEps.java86
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/eps/DriverImageEps.java71
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/eps/DriverLineEps.java79
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/eps/DriverPathEps.java57
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/eps/DriverPolygonEps.java93
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/eps/DriverRectangleEps.java98
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/eps/DriverTextEps.java225
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/eps/UGraphicEps.java143
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/g2d/DriverCenteredCharacterG2d.java63
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/g2d/DriverDotPathG2d.java64
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/g2d/DriverEllipseG2d.java143
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/g2d/DriverImageG2d.java61
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/g2d/DriverLineG2d.java82
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/g2d/DriverPathG2d.java158
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/g2d/DriverPathG2dLegacy.java157
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/g2d/DriverPathOldG2d.java156
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/g2d/DriverPixelG2d.java51
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/g2d/DriverPolygonG2d.java127
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/g2d/DriverRectangleG2d.java179
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/g2d/DriverShadowedG2d.java111
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/g2d/DriverTextAsPathG2d.java152
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/g2d/DriverTextG2d.java145
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/g2d/UGraphicG2d.java216
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/hand/HandJiggle.java152
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/hand/UDotPathHand.java60
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/hand/UEllipseHand.java90
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/hand/UGraphicHandwritten.java141
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/hand/ULineHand.java58
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/hand/UPathHand.java85
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/hand/UPolygonHand.java67
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/hand/URectangleHand.java78
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/html5/DriverLineHtml5.java82
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/html5/DriverNopHtml5.java46
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/html5/DriverRectangleHtml5.java99
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/html5/Html5Drawer.java134
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/html5/UGraphicHtml5.java141
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/svg/DriverCenteredCharacterSvg.java66
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/svg/DriverDotPathSvg.java60
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/svg/DriverEllipseSvg.java108
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/svg/DriverImagePng.java76
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/svg/DriverImageSvgSvg.java50
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/svg/DriverLineSvg.java87
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/svg/DriverPathSvg.java83
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/svg/DriverPolygonSvg.java89
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/svg/DriverRectangleSvg.java96
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/svg/DriverTextAsPathSvg.java105
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/svg/DriverTextSvg.java103
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/svg/UGraphicSvg.java174
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/tikz/DriverAtomTextTikz.java53
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/tikz/DriverCenteredCharacterTikz.java66
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/tikz/DriverDotPathTikz.java53
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/tikz/DriverEllipseTikz.java73
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/tikz/DriverLineTikz.java56
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/tikz/DriverNoneTikz.java48
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/tikz/DriverPolygonTikz.java57
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/tikz/DriverRectangleTikz.java58
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/tikz/DriverUPathTikz.java53
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/tikz/DriverUTextTikz.java53
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/tikz/UGraphicTikz.java124
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/txt/UGraphicTxt.java119
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/visio/DriverDotPathVdx.java50
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/visio/DriverLineVdx.java55
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/visio/DriverNoneVdx.java47
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/visio/DriverPolygonVdx.java50
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/visio/DriverRectangleVdx.java55
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/visio/DriverTextVdx.java80
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/visio/DriverUPathVdx.java52
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/visio/UGraphicVdx.java123
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/visio/VisioGraphics.java187
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/visio/VisioLine.java117
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/visio/VisioRectangle.java120
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/visio/VisioShape.java46
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/visio/VisioText.java128
-rw-r--r--src/net/sourceforge/plantuml/utils/CharHidder.java96
-rw-r--r--src/net/sourceforge/plantuml/utils/MathUtils.java66
-rw-r--r--src/net/sourceforge/plantuml/utils/StartUtils.java74
-rw-r--r--src/net/sourceforge/plantuml/utils/UniqueSequence.java57
-rw-r--r--src/net/sourceforge/plantuml/version/IteratorCounter.java43
-rw-r--r--src/net/sourceforge/plantuml/version/IteratorCounterImpl.java66
-rw-r--r--src/net/sourceforge/plantuml/version/License.java331
-rw-r--r--src/net/sourceforge/plantuml/version/PSystemLicense.java86
-rw-r--r--src/net/sourceforge/plantuml/version/PSystemLicenseFactory.java57
-rw-r--r--src/net/sourceforge/plantuml/version/PSystemVersion.java277
-rw-r--r--src/net/sourceforge/plantuml/version/PSystemVersionFactory.java83
-rw-r--r--src/net/sourceforge/plantuml/version/Version.java76
-rw-r--r--src/net/sourceforge/plantuml/version/charlie.pngbin0 -> 12170 bytes
-rw-r--r--src/net/sourceforge/plantuml/version/favicon.pngbin0 -> 670 bytes
-rw-r--r--src/net/sourceforge/plantuml/version/logo.pngbin0 -> 4121 bytes
-rw-r--r--src/net/sourceforge/plantuml/xmi/CucaDiagramXmiMaker.java84
-rw-r--r--src/net/sourceforge/plantuml/xmi/IXmiClassDiagram.java46
-rw-r--r--src/net/sourceforge/plantuml/xmi/XmiClassDiagramArgo.java289
-rw-r--r--src/net/sourceforge/plantuml/xmi/XmiClassDiagramStandard.java297
-rw-r--r--src/net/sourceforge/plantuml/xmi/XmiClassDiagramStar.java294
1838 files changed, 173968 insertions, 0 deletions
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..8f0d396
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,27 @@
+========================================================================
+PlantUML : a free UML diagram generator
+========================================================================
+
+(C) Copyright 2009-2014, Arnaud Roques
+
+PlantUML is free software; you can redistribute it and/or modify it under the
+terms of the MIT License.
+
+See http://opensource.org/licenses/MIT
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/README b/README
new file mode 100644
index 0000000..07f6d7d
--- /dev/null
+++ b/README
@@ -0,0 +1 @@
+Goto http://plantuml.sourceforge.net/ for product info
diff --git a/build.xml b/build.xml
new file mode 100644
index 0000000..87e1cc8
--- /dev/null
+++ b/build.xml
@@ -0,0 +1,58 @@
+<!--
+ ========================================================================
+ PlantUML : a free UML diagram generator
+ ========================================================================
+ (C) Copyright 2009-2013, Arnaud Roques
+
+ Project Info: http://plantuml.sourceforge.net
+
+ This file is part of PlantUML.
+
+ Original Author: Arnaud Roques
+ Script Author: Ilya V. Paramonov
+
+-->
+<project name="PlantUML" default="dist" basedir=".">
+ <description>
+ PlantUML Build File
+ </description>
+
+ <target name="compile">
+ <delete dir="build" />
+ <mkdir dir="build" />
+ <javac target="1.6" srcdir="src" destdir="build" />
+ <copy file="src/net/sourceforge/plantuml/version/logo.png"
+ todir="build/net/sourceforge/plantuml/version" />
+ <copy file="src/net/sourceforge/plantuml/version/favicon.png"
+ todir="build/net/sourceforge/plantuml/version" />
+ <copy todir="build/net/sourceforge/plantuml/version">
+ <fileset dir="src/net/sourceforge/plantuml/version">
+ <include name="*.png" />
+ </fileset>
+ </copy>
+ <copy todir="build/net/sourceforge/plantuml/openiconic/data">
+ <fileset dir="src/net/sourceforge/plantuml/openiconic/data">
+ <include name="*.txt" />
+ <include name="*.svg" />
+ </fileset>
+ </copy>
+ <copy todir="build/net/sourceforge/plantuml/fun">
+ <fileset dir="src/net/sourceforge/plantuml/fun">
+ <include name="*.png" />
+ </fileset>
+ </copy>
+ </target>
+
+ <target name="dist" depends="compile">
+ <delete dir="dist" />
+ <mkdir dir="dist" />
+ <jar jarfile="plantuml.jar" basedir="build">
+ <manifest>
+ <attribute name="Main-Class" value="net.sourceforge.plantuml.Run" />
+ </manifest>
+ </jar>
+ <delete dir="build" />
+ <delete dir="dist" />
+ </target>
+
+</project>
diff --git a/src/net/sourceforge/plantuml/AbstractPSystem.java b/src/net/sourceforge/plantuml/AbstractPSystem.java
new file mode 100644
index 0000000..c9d1d9a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/AbstractPSystem.java
@@ -0,0 +1,118 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Properties;
+
+import net.sourceforge.plantuml.command.Command;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.ProtectedCommand;
+import net.sourceforge.plantuml.core.Diagram;
+import net.sourceforge.plantuml.core.UmlSource;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.version.License;
+import net.sourceforge.plantuml.version.Version;
+
+public abstract class AbstractPSystem implements Diagram {
+
+ private UmlSource source;
+
+ private String getVersion() {
+ final StringBuilder toAppend = new StringBuilder();
+ toAppend.append("PlantUML version ");
+ toAppend.append(Version.versionString());
+ toAppend.append("(" + Version.compileTimeString() + ")\n");
+ toAppend.append("(" + License.getCurrent() + " source distribution)\n");
+ final Properties p = System.getProperties();
+ toAppend.append(p.getProperty("java.runtime.name"));
+ toAppend.append('\n');
+ toAppend.append(p.getProperty("java.vm.name"));
+ toAppend.append('\n');
+ toAppend.append(p.getProperty("java.runtime.version"));
+ toAppend.append('\n');
+ toAppend.append(p.getProperty("os.name"));
+
+ return toAppend.toString();
+ }
+
+ final public String getMetadata() {
+ if (source == null) {
+ return getVersion();
+ }
+ return source.getPlainString() + "\n" + getVersion();
+ }
+
+ final public UmlSource getSource() {
+ return source;
+ }
+
+ final public void setSource(UmlSource source) {
+ this.source = source;
+ }
+
+ public int getNbImages() {
+ return 1;
+ }
+
+ public Display getTitle() {
+ if (source == null) {
+ return Display.empty();
+ }
+ return source.getTitle();
+ }
+
+ public String getWarningOrError() {
+ return null;
+ }
+
+ public void makeDiagramReady() {
+ }
+
+ public boolean isOk() {
+ return true;
+ }
+
+ public CommandExecutionResult executeCommand(Command cmd, List<String> lines) {
+ cmd = new ProtectedCommand(cmd);
+ return cmd.execute(this, lines);
+ }
+
+ public boolean hasUrl() {
+ return false;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/AlignParam.java b/src/net/sourceforge/plantuml/AlignParam.java
new file mode 100644
index 0000000..cc021c4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/AlignParam.java
@@ -0,0 +1,55 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+
+
+public enum AlignParam {
+
+ SEQUENCE_MESSAGE_ALIGN(HorizontalAlignment.LEFT),
+ SEQUENCE_MESSAGETEXT_ALIGN(HorizontalAlignment.LEFT),
+ SEQUENCE_REFERENCE_ALIGN(HorizontalAlignment.CENTER);
+
+ private final HorizontalAlignment defaultValue;
+
+ private AlignParam(HorizontalAlignment defaultValue) {
+ this.defaultValue = defaultValue;
+ }
+
+ public final HorizontalAlignment getDefaultValue() {
+ return defaultValue;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/AnimatedGifEncoder.java b/src/net/sourceforge/plantuml/AnimatedGifEncoder.java
new file mode 100644
index 0000000..ab6ae7d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/AnimatedGifEncoder.java
@@ -0,0 +1,1335 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.image.BufferedImage;
+import java.awt.image.DataBufferByte;
+import java.io.BufferedOutputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * Class AnimatedGifEncoder - Encodes a GIF file consisting of one or more
+ * frames.
+ *
+ * <pre>
+ * Example:
+ * AnimatedGifEncoder e = new AnimatedGifEncoder();
+ * e.start(outputFileName);
+ * e.setDelay(1000); // 1 frame per sec
+ * e.addFrame(image1);
+ * e.addFrame(image2);
+ * e.finish();
+ * </pre>
+ *
+ * No copyright asserted on the source code of this class. May be used for any
+ * purpose, however, refer to the Unisys LZW patent for restrictions on use of
+ * the associated LZWEncoder class. Please forward any corrections to
+ * kweiner@fmsware.com.
+ *
+ * @author Kevin Weiner, FM Software
+ * @version 1.03 November 2003
+ *
+ */
+
+public class AnimatedGifEncoder {
+
+ protected int width; // image size
+
+ protected int height;
+
+ protected Color transparent = null; // transparent color if given
+
+ protected int transIndex; // transparent index in color table
+
+ protected int repeat = -1; // no repeat
+
+ protected int delay = 0; // frame delay (hundredths)
+
+ protected boolean started = false; // ready to output frames
+
+ protected OutputStream out;
+
+ protected BufferedImage image; // current frame
+
+ protected byte[] pixels; // BGR byte array from frame
+
+ protected byte[] indexedPixels; // converted frame indexed to palette
+
+ protected int colorDepth; // number of bit planes
+
+ protected byte[] colorTab; // RGB palette
+
+ protected boolean[] usedEntry = new boolean[256]; // active palette
+ // entries
+
+ protected int palSize = 7; // color table size (bits-1)
+
+ protected int dispose = -1; // disposal code (-1 = use default)
+
+ protected boolean closeStream = false; // close stream when finished
+
+ protected boolean firstFrame = true;
+
+ protected boolean sizeSet = false; // if false, get size from first frame
+
+ protected int sample = 10; // default sample interval for quantizer
+
+ /**
+ * Sets the delay time between each frame, or changes it for subsequent
+ * frames (applies to last frame added).
+ *
+ * @param ms
+ * int delay time in milliseconds
+ */
+ public void setDelay(int ms) {
+ delay = Math.round(ms / 10.0f);
+ }
+
+ /**
+ * Sets the GIF frame disposal code for the last added frame and any
+ * subsequent frames. Default is 0 if no transparent color has been set,
+ * otherwise 2.
+ *
+ * @param code
+ * int disposal code.
+ */
+ public void setDispose(int code) {
+ if (code >= 0) {
+ dispose = code;
+ }
+ }
+
+ /**
+ * Sets the number of times the set of GIF frames should be played. Default
+ * is 1; 0 means play indefinitely. Must be invoked before the first image
+ * is added.
+ *
+ * @param iter
+ * int number of iterations.
+ * @return
+ */
+ public void setRepeat(int iter) {
+ if (iter >= 0) {
+ repeat = iter;
+ }
+ }
+
+ /**
+ * Sets the transparent color for the last added frame and any subsequent
+ * frames. Since all colors are subject to modification in the quantization
+ * process, the color in the final palette for each frame closest to the
+ * given color becomes the transparent color for that frame. May be set to
+ * null to indicate no transparent color.
+ *
+ * @param c
+ * Color to be treated as transparent on display.
+ */
+ public void setTransparent(Color c) {
+ transparent = c;
+ }
+
+ /**
+ * Adds next GIF frame. The frame is not written immediately, but is
+ * actually deferred until the next frame is received so that timing data
+ * can be inserted. Invoking <code>finish()</code> flushes all frames. If
+ * <code>setSize</code> was not invoked, the size of the first image is
+ * used for all subsequent frames.
+ *
+ * @param im
+ * BufferedImage containing frame to write.
+ * @return true if successful.
+ */
+ public boolean addFrame(BufferedImage im) {
+ if ((im == null) || !started) {
+ return false;
+ }
+ boolean ok = true;
+ try {
+ if (!sizeSet) {
+ // use first frame's size
+ setSize(im.getWidth(), im.getHeight());
+ }
+ image = im;
+ getImagePixels(); // convert to correct format if necessary
+ analyzePixels(); // build color table & map pixels
+ if (firstFrame) {
+ writeLSD(); // logical screen descriptior
+ writePalette(); // global color table
+ if (repeat >= 0) {
+ // use NS app extension to indicate reps
+ writeNetscapeExt();
+ }
+ }
+ writeGraphicCtrlExt(); // write graphic control extension
+ writeImageDesc(); // image descriptor
+ if (!firstFrame) {
+ writePalette(); // local color table
+ }
+ writePixels(); // encode and write pixel data
+ firstFrame = false;
+ } catch (IOException e) {
+ ok = false;
+ }
+
+ return ok;
+ }
+
+ /**
+ * Flushes any pending data and closes output file. If writing to an
+ * OutputStream, the stream is not closed.
+ */
+ public boolean finish() {
+ if (!started)
+ return false;
+ boolean ok = true;
+ started = false;
+ try {
+ out.write(0x3b); // gif trailer
+ out.flush();
+ if (closeStream) {
+ out.close();
+ }
+ } catch (IOException e) {
+ ok = false;
+ }
+
+ // reset for subsequent use
+ transIndex = 0;
+ out = null;
+ image = null;
+ pixels = null;
+ indexedPixels = null;
+ colorTab = null;
+ closeStream = false;
+ firstFrame = true;
+
+ return ok;
+ }
+
+ /**
+ * Sets frame rate in frames per second. Equivalent to
+ * <code>setDelay(1000/fps)</code>.
+ *
+ * @param fps
+ * float frame rate (frames per second)
+ */
+ public void setFrameRate(float fps) {
+ if (fps != 0f) {
+ delay = Math.round(100f / fps);
+ }
+ }
+
+ /**
+ * Sets quality of color quantization (conversion of images to the maximum
+ * 256 colors allowed by the GIF specification). Lower values (minimum = 1)
+ * produce better colors, but slow processing significantly. 10 is the
+ * default, and produces good color mapping at reasonable speeds. Values
+ * greater than 20 do not yield significant improvements in speed.
+ *
+ * @param quality
+ * int greater than 0.
+ * @return
+ */
+ public void setQuality(int quality) {
+ if (quality < 1)
+ quality = 1;
+ sample = quality;
+ }
+
+ /**
+ * Sets the GIF frame size. The default size is the size of the first frame
+ * added if this method is not invoked.
+ *
+ * @param w
+ * int frame width.
+ * @param h
+ * int frame width.
+ */
+ public void setSize(int w, int h) {
+ if (started && !firstFrame)
+ return;
+ width = w;
+ height = h;
+ if (width < 1)
+ width = 320;
+ if (height < 1)
+ height = 240;
+ sizeSet = true;
+ }
+
+ /**
+ * Initiates GIF file creation on the given stream. The stream is not closed
+ * automatically.
+ *
+ * @param os
+ * OutputStream on which GIF images are written.
+ * @return false if initial write failed.
+ */
+ public boolean start(OutputStream os) {
+ if (os == null)
+ return false;
+ boolean ok = true;
+ closeStream = false;
+ out = os;
+ try {
+ writeString("GIF89a"); // header
+ } catch (IOException e) {
+ ok = false;
+ }
+ return started = ok;
+ }
+
+ /**
+ * Initiates writing of a GIF file with the specified name.
+ *
+ * @param file
+ * String containing output file name.
+ * @return false if open or initial write failed.
+ */
+ public boolean start(String file) {
+ boolean ok = true;
+ try {
+ out = new BufferedOutputStream(new FileOutputStream(file));
+ ok = start(out);
+ closeStream = true;
+ } catch (IOException e) {
+ ok = false;
+ }
+ return started = ok;
+ }
+
+ /**
+ * Analyzes image colors and creates color map.
+ */
+ protected void analyzePixels() {
+ int len = pixels.length;
+ int nPix = len / 3;
+ indexedPixels = new byte[nPix];
+ NeuQuant nq = new NeuQuant(pixels, len, sample);
+ // initialize quantizer
+ colorTab = nq.process(); // create reduced palette
+ // convert map from BGR to RGB
+ for (int i = 0; i < colorTab.length; i += 3) {
+ byte temp = colorTab[i];
+ colorTab[i] = colorTab[i + 2];
+ colorTab[i + 2] = temp;
+ usedEntry[i / 3] = false;
+ }
+ // map image pixels to new palette
+ int k = 0;
+ for (int i = 0; i < nPix; i++) {
+ int index = nq.map(pixels[k++] & 0xff, pixels[k++] & 0xff, pixels[k++] & 0xff);
+ usedEntry[index] = true;
+ indexedPixels[i] = (byte) index;
+ }
+ pixels = null;
+ colorDepth = 8;
+ palSize = 7;
+ // get closest match to transparent color if specified
+ if (transparent != null) {
+ transIndex = findClosest(transparent);
+ }
+ }
+
+ /**
+ * Returns index of palette color closest to c
+ *
+ */
+ protected int findClosest(Color c) {
+ if (colorTab == null)
+ return -1;
+ int r = c.getRed();
+ int g = c.getGreen();
+ int b = c.getBlue();
+ int minpos = 0;
+ int dmin = 256 * 256 * 256;
+ int len = colorTab.length;
+ for (int i = 0; i < len;) {
+ int dr = r - (colorTab[i++] & 0xff);
+ int dg = g - (colorTab[i++] & 0xff);
+ int db = b - (colorTab[i] & 0xff);
+ int d = dr * dr + dg * dg + db * db;
+ int index = i / 3;
+ if (usedEntry[index] && (d < dmin)) {
+ dmin = d;
+ minpos = index;
+ }
+ i++;
+ }
+ return minpos;
+ }
+
+ /**
+ * Extracts image pixels into byte array "pixels"
+ */
+ protected void getImagePixels() {
+ int w = image.getWidth();
+ int h = image.getHeight();
+ int type = image.getType();
+ if ((w != width) || (h != height) || (type != BufferedImage.TYPE_3BYTE_BGR)) {
+ // create new image with right size/format
+ BufferedImage temp = new BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR);
+ Graphics2D g = temp.createGraphics();
+ g.drawImage(image, 0, 0, null);
+ image = temp;
+ }
+ pixels = ((DataBufferByte) image.getRaster().getDataBuffer()).getData();
+ }
+
+ /**
+ * Writes Graphic Control Extension
+ */
+ protected void writeGraphicCtrlExt() throws IOException {
+ out.write(0x21); // extension introducer
+ out.write(0xf9); // GCE label
+ out.write(4); // data block size
+ int transp, disp;
+ if (transparent == null) {
+ transp = 0;
+ disp = 0; // dispose = no action
+ } else {
+ transp = 1;
+ disp = 2; // force clear if using transparent color
+ }
+ if (dispose >= 0) {
+ disp = dispose & 7; // user override
+ }
+ disp <<= 2;
+
+ // packed fields
+ out.write(0 | // 1:3 reserved
+ disp | // 4:6 disposal
+ 0 | // 7 user input - 0 = none
+ transp); // 8 transparency flag
+
+ writeShort(delay); // delay x 1/100 sec
+ out.write(transIndex); // transparent color index
+ out.write(0); // block terminator
+ }
+
+ /**
+ * Writes Image Descriptor
+ */
+ protected void writeImageDesc() throws IOException {
+ out.write(0x2c); // image separator
+ writeShort(0); // image position x,y = 0,0
+ writeShort(0);
+ writeShort(width); // image size
+ writeShort(height);
+ // packed fields
+ if (firstFrame) {
+ // no LCT - GCT is used for first (or only) frame
+ out.write(0);
+ } else {
+ // specify normal LCT
+ out.write(0x80 | // 1 local color table 1=yes
+ 0 | // 2 interlace - 0=no
+ 0 | // 3 sorted - 0=no
+ 0 | // 4-5 reserved
+ palSize); // 6-8 size of color table
+ }
+ }
+
+ /**
+ * Writes Logical Screen Descriptor
+ */
+ protected void writeLSD() throws IOException {
+ // logical screen size
+ writeShort(width);
+ writeShort(height);
+ // packed fields
+ out.write((0x80 | // 1 : global color table flag = 1 (gct used)
+ 0x70 | // 2-4 : color resolution = 7
+ 0x00 | // 5 : gct sort flag = 0
+ palSize)); // 6-8 : gct size
+
+ out.write(0); // background color index
+ out.write(0); // pixel aspect ratio - assume 1:1
+ }
+
+ /**
+ * Writes Netscape application extension to define repeat count.
+ */
+ protected void writeNetscapeExt() throws IOException {
+ out.write(0x21); // extension introducer
+ out.write(0xff); // app extension label
+ out.write(11); // block size
+ writeString("NETSCAPE" + "2.0"); // app id + auth code
+ out.write(3); // sub-block size
+ out.write(1); // loop sub-block id
+ writeShort(repeat); // loop count (extra iterations, 0=repeat forever)
+ out.write(0); // block terminator
+ }
+
+ /**
+ * Writes color table
+ */
+ protected void writePalette() throws IOException {
+ out.write(colorTab, 0, colorTab.length);
+ int n = (3 * 256) - colorTab.length;
+ for (int i = 0; i < n; i++) {
+ out.write(0);
+ }
+ }
+
+ /**
+ * Encodes and writes pixel data
+ */
+ protected void writePixels() throws IOException {
+ LZWEncoder encoder = new LZWEncoder(width, height, indexedPixels, colorDepth);
+ encoder.encode(out);
+ }
+
+ /**
+ * Write 16-bit value to output stream, LSB first
+ */
+ protected void writeShort(int value) throws IOException {
+ out.write(value & 0xff);
+ out.write((value >> 8) & 0xff);
+ }
+
+ /**
+ * Writes string to output stream
+ */
+ protected void writeString(String s) throws IOException {
+ for (int i = 0; i < s.length(); i++) {
+ out.write((byte) s.charAt(i));
+ }
+ }
+}
+
+/*
+ * NeuQuant Neural-Net Quantization Algorithm
+ * ------------------------------------------
+ *
+ * Copyright (c) 1994 Anthony Dekker
+ *
+ * NEUQUANT Neural-Net quantization algorithm by Anthony Dekker, 1994. See
+ * "Kohonen neural networks for optimal colour quantization" in "Network:
+ * Computation in Neural Systems" Vol. 5 (1994) pp 351-367. for a discussion of
+ * the algorithm.
+ *
+ * Any party obtaining a copy of these files from the author, directly or
+ * indirectly, is granted, free of charge, a full and unrestricted irrevocable,
+ * world-wide, paid up, royalty-free, nonexclusive right and license to deal in
+ * this software and documentation files (the "Software"), including without
+ * limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons who
+ * receive copies from any such party to do so, with the only requirement being
+ * that this copyright notice remain intact.
+ */
+
+// Ported to Java 12/00 K Weiner
+class NeuQuant {
+
+ protected static final int netsize = 256; /* number of colours used */
+
+ /* four primes near 500 - assume no image has a length so large */
+ /* that it is divisible by all four primes */
+ protected static final int prime1 = 499;
+
+ protected static final int prime2 = 491;
+
+ protected static final int prime3 = 487;
+
+ protected static final int prime4 = 503;
+
+ protected static final int minpicturebytes = (3 * prime4);
+
+ /* minimum size for input image */
+
+ /*
+ * Program Skeleton ---------------- [select samplefac in range 1..30] [read
+ * image from input file] pic = (unsigned char*) malloc(3*width*height);
+ * initnet(pic,3*width*height,samplefac); learn(); unbiasnet(); [write
+ * output image header, using writecolourmap(f)] inxbuild(); write output
+ * image using inxsearch(b,g,r)
+ */
+
+ /*
+ * Network Definitions -------------------
+ */
+
+ protected static final int maxnetpos = (netsize - 1);
+
+ protected static final int netbiasshift = 4; /* bias for colour values */
+
+ protected static final int ncycles = 100; /* no. of learning cycles */
+
+ /* defs for freq and bias */
+ protected static final int intbiasshift = 16; /* bias for fractions */
+
+ protected static final int intbias = (((int) 1) << intbiasshift);
+
+ protected static final int gammashift = 10; /* gamma = 1024 */
+
+ protected static final int gamma = (((int) 1) << gammashift);
+
+ protected static final int betashift = 10;
+
+ protected static final int beta = (intbias >> betashift); /* beta = 1/1024 */
+
+ protected static final int betagamma = (intbias << (gammashift - betashift));
+
+ /* defs for decreasing radius factor */
+ protected static final int initrad = (netsize >> 3); /*
+ * for 256 cols,
+ * radius starts
+ */
+
+ protected static final int radiusbiasshift = 6; /* at 32.0 biased by 6 bits */
+
+ protected static final int radiusbias = (((int) 1) << radiusbiasshift);
+
+ protected static final int initradius = (initrad * radiusbias); /*
+ * and
+ * decreases
+ * by a
+ */
+
+ protected static final int radiusdec = 30; /* factor of 1/30 each cycle */
+
+ /* defs for decreasing alpha factor */
+ protected static final int alphabiasshift = 10; /* alpha starts at 1.0 */
+
+ protected static final int initalpha = (((int) 1) << alphabiasshift);
+
+ protected int alphadec; /* biased by 10 bits */
+
+ /* radbias and alpharadbias used for radpower calculation */
+ protected static final int radbiasshift = 8;
+
+ protected static final int radbias = (((int) 1) << radbiasshift);
+
+ protected static final int alpharadbshift = (alphabiasshift + radbiasshift);
+
+ protected static final int alpharadbias = (((int) 1) << alpharadbshift);
+
+ /*
+ * Types and Global Variables --------------------------
+ */
+
+ protected byte[] thepicture; /* the input image itself */
+
+ protected int lengthcount; /* lengthcount = H*W*3 */
+
+ protected int samplefac; /* sampling factor 1..30 */
+
+ // typedef int pixel[4]; /* BGRc */
+ protected int[][] network; /* the network itself - [netsize][4] */
+
+ protected int[] netindex = new int[256];
+
+ /* for network lookup - really 256 */
+
+ protected int[] bias = new int[netsize];
+
+ /* bias and freq arrays for learning */
+ protected int[] freq = new int[netsize];
+
+ protected int[] radpower = new int[initrad];
+
+ /* radpower for precomputation */
+
+ /*
+ * Initialise network in range (0,0,0) to (255,255,255) and set parameters
+ * -----------------------------------------------------------------------
+ */
+ public NeuQuant(byte[] thepic, int len, int sample) {
+
+ int i;
+ int[] p;
+
+ thepicture = thepic;
+ lengthcount = len;
+ samplefac = sample;
+
+ network = new int[netsize][];
+ for (i = 0; i < netsize; i++) {
+ network[i] = new int[4];
+ p = network[i];
+ p[0] = p[1] = p[2] = (i << (netbiasshift + 8)) / netsize;
+ freq[i] = intbias / netsize; /* 1/netsize */
+ bias[i] = 0;
+ }
+ }
+
+ public byte[] colorMap() {
+ byte[] map = new byte[3 * netsize];
+ int[] index = new int[netsize];
+ for (int i = 0; i < netsize; i++)
+ index[network[i][3]] = i;
+ int k = 0;
+ for (int i = 0; i < netsize; i++) {
+ int j = index[i];
+ map[k++] = (byte) (network[j][0]);
+ map[k++] = (byte) (network[j][1]);
+ map[k++] = (byte) (network[j][2]);
+ }
+ return map;
+ }
+
+ /*
+ * Insertion sort of network and building of netindex[0..255] (to do after
+ * unbias)
+ * -------------------------------------------------------------------------------
+ */
+ public void inxbuild() {
+
+ int i, j, smallpos, smallval;
+ int[] p;
+ int[] q;
+ int previouscol, startpos;
+
+ previouscol = 0;
+ startpos = 0;
+ for (i = 0; i < netsize; i++) {
+ p = network[i];
+ smallpos = i;
+ smallval = p[1]; /* index on g */
+ /* find smallest in i..netsize-1 */
+ for (j = i + 1; j < netsize; j++) {
+ q = network[j];
+ if (q[1] < smallval) { /* index on g */
+ smallpos = j;
+ smallval = q[1]; /* index on g */
+ }
+ }
+ q = network[smallpos];
+ /* swap p (i) and q (smallpos) entries */
+ if (i != smallpos) {
+ j = q[0];
+ q[0] = p[0];
+ p[0] = j;
+ j = q[1];
+ q[1] = p[1];
+ p[1] = j;
+ j = q[2];
+ q[2] = p[2];
+ p[2] = j;
+ j = q[3];
+ q[3] = p[3];
+ p[3] = j;
+ }
+ /* smallval entry is now in position i */
+ if (smallval != previouscol) {
+ netindex[previouscol] = (startpos + i) >> 1;
+ for (j = previouscol + 1; j < smallval; j++)
+ netindex[j] = i;
+ previouscol = smallval;
+ startpos = i;
+ }
+ }
+ netindex[previouscol] = (startpos + maxnetpos) >> 1;
+ for (j = previouscol + 1; j < 256; j++)
+ netindex[j] = maxnetpos; /* really 256 */
+ }
+
+ /*
+ * Main Learning Loop ------------------
+ */
+ public void learn() {
+
+ int i, j, b, g, r;
+ int radius, rad, alpha, step, delta, samplepixels;
+ byte[] p;
+ int pix, lim;
+
+ if (lengthcount < minpicturebytes)
+ samplefac = 1;
+ alphadec = 30 + ((samplefac - 1) / 3);
+ p = thepicture;
+ pix = 0;
+ lim = lengthcount;
+ samplepixels = lengthcount / (3 * samplefac);
+ delta = samplepixels / ncycles;
+ alpha = initalpha;
+ radius = initradius;
+
+ rad = radius >> radiusbiasshift;
+ if (rad <= 1)
+ rad = 0;
+ for (i = 0; i < rad; i++)
+ radpower[i] = alpha * (((rad * rad - i * i) * radbias) / (rad * rad));
+
+ // fprintf(stderr,"beginning 1D learning: initial radius=%d\n", rad);
+
+ if (lengthcount < minpicturebytes)
+ step = 3;
+ else if ((lengthcount % prime1) != 0)
+ step = 3 * prime1;
+ else {
+ if ((lengthcount % prime2) != 0)
+ step = 3 * prime2;
+ else {
+ if ((lengthcount % prime3) != 0)
+ step = 3 * prime3;
+ else
+ step = 3 * prime4;
+ }
+ }
+
+ i = 0;
+ while (i < samplepixels) {
+ b = (p[pix + 0] & 0xff) << netbiasshift;
+ g = (p[pix + 1] & 0xff) << netbiasshift;
+ r = (p[pix + 2] & 0xff) << netbiasshift;
+ j = contest(b, g, r);
+
+ altersingle(alpha, j, b, g, r);
+ if (rad != 0)
+ alterneigh(rad, j, b, g, r); /* alter neighbours */
+
+ pix += step;
+ if (pix >= lim)
+ pix -= lengthcount;
+
+ i++;
+ if (delta == 0)
+ delta = 1;
+ if (i % delta == 0) {
+ alpha -= alpha / alphadec;
+ radius -= radius / radiusdec;
+ rad = radius >> radiusbiasshift;
+ if (rad <= 1)
+ rad = 0;
+ for (j = 0; j < rad; j++)
+ radpower[j] = alpha * (((rad * rad - j * j) * radbias) / (rad * rad));
+ }
+ }
+ // fprintf(stderr,"finished 1D learning: final alpha=%f
+ // !\n",((float)alpha)/initalpha);
+ }
+
+ /*
+ * Search for BGR values 0..255 (after net is unbiased) and return colour
+ * index
+ * ----------------------------------------------------------------------------
+ */
+ public int map(int b, int g, int r) {
+
+ int i, j, dist, a, bestd;
+ int[] p;
+ int best;
+
+ bestd = 1000; /* biggest possible dist is 256*3 */
+ best = -1;
+ i = netindex[g]; /* index on g */
+ j = i - 1; /* start at netindex[g] and work outwards */
+
+ while ((i < netsize) || (j >= 0)) {
+ if (i < netsize) {
+ p = network[i];
+ dist = p[1] - g; /* inx key */
+ if (dist >= bestd)
+ i = netsize; /* stop iter */
+ else {
+ i++;
+ if (dist < 0)
+ dist = -dist;
+ a = p[0] - b;
+ if (a < 0)
+ a = -a;
+ dist += a;
+ if (dist < bestd) {
+ a = p[2] - r;
+ if (a < 0)
+ a = -a;
+ dist += a;
+ if (dist < bestd) {
+ bestd = dist;
+ best = p[3];
+ }
+ }
+ }
+ }
+ if (j >= 0) {
+ p = network[j];
+ dist = g - p[1]; /* inx key - reverse dif */
+ if (dist >= bestd)
+ j = -1; /* stop iter */
+ else {
+ j--;
+ if (dist < 0)
+ dist = -dist;
+ a = p[0] - b;
+ if (a < 0)
+ a = -a;
+ dist += a;
+ if (dist < bestd) {
+ a = p[2] - r;
+ if (a < 0)
+ a = -a;
+ dist += a;
+ if (dist < bestd) {
+ bestd = dist;
+ best = p[3];
+ }
+ }
+ }
+ }
+ }
+ return (best);
+ }
+
+ public byte[] process() {
+ learn();
+ unbiasnet();
+ inxbuild();
+ return colorMap();
+ }
+
+ /*
+ * Unbias network to give byte values 0..255 and record position i to
+ * prepare for sort
+ * -----------------------------------------------------------------------------------
+ */
+ public void unbiasnet() {
+
+ int i, j;
+
+ for (i = 0; i < netsize; i++) {
+ network[i][0] >>= netbiasshift;
+ network[i][1] >>= netbiasshift;
+ network[i][2] >>= netbiasshift;
+ network[i][3] = i; /* record colour no */
+ }
+ }
+
+ /*
+ * Move adjacent neurons by precomputed alpha*(1-((i-j)^2/[r]^2)) in
+ * radpower[|i-j|]
+ * ---------------------------------------------------------------------------------
+ */
+ protected void alterneigh(int rad, int i, int b, int g, int r) {
+
+ int j, k, lo, hi, a, m;
+ int[] p;
+
+ lo = i - rad;
+ if (lo < -1)
+ lo = -1;
+ hi = i + rad;
+ if (hi > netsize)
+ hi = netsize;
+
+ j = i + 1;
+ k = i - 1;
+ m = 1;
+ while ((j < hi) || (k > lo)) {
+ a = radpower[m++];
+ if (j < hi) {
+ p = network[j++];
+ try {
+ p[0] -= (a * (p[0] - b)) / alpharadbias;
+ p[1] -= (a * (p[1] - g)) / alpharadbias;
+ p[2] -= (a * (p[2] - r)) / alpharadbias;
+ } catch (Exception e) {
+ } // prevents 1.3 miscompilation
+ }
+ if (k > lo) {
+ p = network[k--];
+ try {
+ p[0] -= (a * (p[0] - b)) / alpharadbias;
+ p[1] -= (a * (p[1] - g)) / alpharadbias;
+ p[2] -= (a * (p[2] - r)) / alpharadbias;
+ } catch (Exception e) {
+ }
+ }
+ }
+ }
+
+ /*
+ * Move neuron i towards biased (b,g,r) by factor alpha
+ * ----------------------------------------------------
+ */
+ protected void altersingle(int alpha, int i, int b, int g, int r) {
+
+ /* alter hit neuron */
+ int[] n = network[i];
+ n[0] -= (alpha * (n[0] - b)) / initalpha;
+ n[1] -= (alpha * (n[1] - g)) / initalpha;
+ n[2] -= (alpha * (n[2] - r)) / initalpha;
+ }
+
+ /*
+ * Search for biased BGR values ----------------------------
+ */
+ protected int contest(int b, int g, int r) {
+
+ /* finds closest neuron (min dist) and updates freq */
+ /* finds best neuron (min dist-bias) and returns position */
+ /*
+ * for frequently chosen neurons, freq[i] is high and bias[i] is
+ * negative
+ */
+ /* bias[i] = gamma*((1/netsize)-freq[i]) */
+
+ int i, dist, a, biasdist, betafreq;
+ int bestpos, bestbiaspos, bestd, bestbiasd;
+ int[] n;
+
+ bestd = ~(((int) 1) << 31);
+ bestbiasd = bestd;
+ bestpos = -1;
+ bestbiaspos = bestpos;
+
+ for (i = 0; i < netsize; i++) {
+ n = network[i];
+ dist = n[0] - b;
+ if (dist < 0)
+ dist = -dist;
+ a = n[1] - g;
+ if (a < 0)
+ a = -a;
+ dist += a;
+ a = n[2] - r;
+ if (a < 0)
+ a = -a;
+ dist += a;
+ if (dist < bestd) {
+ bestd = dist;
+ bestpos = i;
+ }
+ biasdist = dist - ((bias[i]) >> (intbiasshift - netbiasshift));
+ if (biasdist < bestbiasd) {
+ bestbiasd = biasdist;
+ bestbiaspos = i;
+ }
+ betafreq = (freq[i] >> betashift);
+ freq[i] -= betafreq;
+ bias[i] += (betafreq << gammashift);
+ }
+ freq[bestpos] += beta;
+ bias[bestpos] -= betagamma;
+ return (bestbiaspos);
+ }
+}
+
+// ==============================================================================
+// Adapted from Jef Poskanzer's Java port by way of J. M. G. Elliott.
+// K Weiner 12/00
+
+class LZWEncoder {
+
+ private static final int EOF = -1;
+
+ private int imgW, imgH;
+
+ private byte[] pixAry;
+
+ private int initCodeSize;
+
+ private int remaining;
+
+ private int curPixel;
+
+ // GIFCOMPR.C - GIF Image compression routines
+ //
+ // Lempel-Ziv compression based on 'compress'. GIF modifications by
+ // David Rowley (mgardi@watdcsu.waterloo.edu)
+
+ // General DEFINEs
+
+ static final int BITS = 12;
+
+ static final int HSIZE = 5003; // 80% occupancy
+
+ // GIF Image compression - modified 'compress'
+ //
+ // Based on: compress.c - File compression ala IEEE Computer, June 1984.
+ //
+ // By Authors: Spencer W. Thomas (decvax!harpo!utah-cs!utah-gr!thomas)
+ // Jim McKie (decvax!mcvax!jim)
+ // Steve Davies (decvax!vax135!petsd!peora!srd)
+ // Ken Turkowski (decvax!decwrl!turtlevax!ken)
+ // James A. Woods (decvax!ihnp4!ames!jaw)
+ // Joe Orost (decvax!vax135!petsd!joe)
+
+ int n_bits; // number of bits/code
+
+ int maxbits = BITS; // user settable max # bits/code
+
+ int maxcode; // maximum code, given n_bits
+
+ int maxmaxcode = 1 << BITS; // should NEVER generate this code
+
+ int[] htab = new int[HSIZE];
+
+ int[] codetab = new int[HSIZE];
+
+ int hsize = HSIZE; // for dynamic table sizing
+
+ int free_ent = 0; // first unused entry
+
+ // block compression parameters -- after all codes are used up,
+ // and compression rate changes, start over.
+ boolean clear_flg = false;
+
+ // Algorithm: use open addressing double hashing (no chaining) on the
+ // prefix code / next character combination. We do a variant of Knuth's
+ // algorithm D (vol. 3, sec. 6.4) along with G. Knott's relatively-prime
+ // secondary probe. Here, the modular division first probe is gives way
+ // to a faster exclusive-or manipulation. Also do block compression with
+ // an adaptive reset, whereby the code table is cleared when the compression
+ // ratio decreases, but after the table fills. The variable-length output
+ // codes are re-sized at this point, and a special CLEAR code is generated
+ // for the decompressor. Late addition: construct the table according to
+ // file size for noticeable speed improvement on small files. Please direct
+ // questions about this implementation to ames!jaw.
+
+ int g_init_bits;
+
+ int ClearCode;
+
+ int EOFCode;
+
+ // output
+ //
+ // Output the given code.
+ // Inputs:
+ // code: A n_bits-bit integer. If == -1, then EOF. This assumes
+ // that n_bits =< wordsize - 1.
+ // Outputs:
+ // Outputs code to the file.
+ // Assumptions:
+ // Chars are 8 bits long.
+ // Algorithm:
+ // Maintain a BITS character long buffer (so that 8 codes will
+ // fit in it exactly). Use the VAX insv instruction to insert each
+ // code in turn. When the buffer fills up empty it and start over.
+
+ int cur_accum = 0;
+
+ int cur_bits = 0;
+
+ int masks[] = { 0x0000, 0x0001, 0x0003, 0x0007, 0x000F, 0x001F, 0x003F, 0x007F, 0x00FF, 0x01FF, 0x03FF, 0x07FF,
+ 0x0FFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF };
+
+ // Number of characters so far in this 'packet'
+ int a_count;
+
+ // Define the storage for the packet accumulator
+ byte[] accum = new byte[256];
+
+ // ----------------------------------------------------------------------------
+ LZWEncoder(int width, int height, byte[] pixels, int color_depth) {
+ imgW = width;
+ imgH = height;
+ pixAry = pixels;
+ initCodeSize = Math.max(2, color_depth);
+ }
+
+ // Add a character to the end of the current packet, and if it is 254
+ // characters, flush the packet to disk.
+ void char_out(byte c, OutputStream outs) throws IOException {
+ accum[a_count++] = c;
+ if (a_count >= 254)
+ flush_char(outs);
+ }
+
+ // Clear out the hash table
+
+ // table clear for block compress
+ void cl_block(OutputStream outs) throws IOException {
+ cl_hash(hsize);
+ free_ent = ClearCode + 2;
+ clear_flg = true;
+
+ output(ClearCode, outs);
+ }
+
+ // reset code table
+ void cl_hash(int hsize) {
+ for (int i = 0; i < hsize; ++i)
+ htab[i] = -1;
+ }
+
+ void compress(int init_bits, OutputStream outs) throws IOException {
+ int fcode;
+ int i /* = 0 */;
+ int c;
+ int ent;
+ int disp;
+ int hsize_reg;
+ int hshift;
+
+ // Set up the globals: g_init_bits - initial number of bits
+ g_init_bits = init_bits;
+
+ // Set up the necessary values
+ clear_flg = false;
+ n_bits = g_init_bits;
+ maxcode = MAXCODE(n_bits);
+
+ ClearCode = 1 << (init_bits - 1);
+ EOFCode = ClearCode + 1;
+ free_ent = ClearCode + 2;
+
+ a_count = 0; // clear packet
+
+ ent = nextPixel();
+
+ hshift = 0;
+ for (fcode = hsize; fcode < 65536; fcode *= 2)
+ ++hshift;
+ hshift = 8 - hshift; // set hash code range bound
+
+ hsize_reg = hsize;
+ cl_hash(hsize_reg); // clear hash table
+
+ output(ClearCode, outs);
+
+ outer_loop: while ((c = nextPixel()) != EOF) {
+ fcode = (c << maxbits) + ent;
+ i = (c << hshift) ^ ent; // xor hashing
+
+ if (htab[i] == fcode) {
+ ent = codetab[i];
+ continue;
+ } else if (htab[i] >= 0) // non-empty slot
+ {
+ disp = hsize_reg - i; // secondary hash (after G. Knott)
+ if (i == 0)
+ disp = 1;
+ do {
+ if ((i -= disp) < 0)
+ i += hsize_reg;
+
+ if (htab[i] == fcode) {
+ ent = codetab[i];
+ continue outer_loop;
+ }
+ } while (htab[i] >= 0);
+ }
+ output(ent, outs);
+ ent = c;
+ if (free_ent < maxmaxcode) {
+ codetab[i] = free_ent++; // code -> hashtable
+ htab[i] = fcode;
+ } else
+ cl_block(outs);
+ }
+ // Put out the final code.
+ output(ent, outs);
+ output(EOFCode, outs);
+ }
+
+ // ----------------------------------------------------------------------------
+ void encode(OutputStream os) throws IOException {
+ os.write(initCodeSize); // write "initial code size" byte
+
+ remaining = imgW * imgH; // reset navigation variables
+ curPixel = 0;
+
+ compress(initCodeSize + 1, os); // compress and write the pixel data
+
+ os.write(0); // write block terminator
+ }
+
+ // Flush the packet to disk, and reset the accumulator
+ void flush_char(OutputStream outs) throws IOException {
+ if (a_count > 0) {
+ outs.write(a_count);
+ outs.write(accum, 0, a_count);
+ a_count = 0;
+ }
+ }
+
+ final int MAXCODE(int n_bits) {
+ return (1 << n_bits) - 1;
+ }
+
+ // ----------------------------------------------------------------------------
+ // Return the next pixel from the image
+ // ----------------------------------------------------------------------------
+ private int nextPixel() {
+ if (remaining == 0)
+ return EOF;
+
+ --remaining;
+
+ byte pix = pixAry[curPixel++];
+
+ return pix & 0xff;
+ }
+
+ void output(int code, OutputStream outs) throws IOException {
+ cur_accum &= masks[cur_bits];
+
+ if (cur_bits > 0)
+ cur_accum |= (code << cur_bits);
+ else
+ cur_accum = code;
+
+ cur_bits += n_bits;
+
+ while (cur_bits >= 8) {
+ char_out((byte) (cur_accum & 0xff), outs);
+ cur_accum >>= 8;
+ cur_bits -= 8;
+ }
+
+ // If the next entry is going to be too big for the code size,
+ // then increase it, if possible.
+ if (free_ent > maxcode || clear_flg) {
+ if (clear_flg) {
+ maxcode = MAXCODE(n_bits = g_init_bits);
+ clear_flg = false;
+ } else {
+ ++n_bits;
+ if (n_bits == maxbits)
+ maxcode = maxmaxcode;
+ else
+ maxcode = MAXCODE(n_bits);
+ }
+ }
+
+ if (code == EOFCode) {
+ // At EOF, write the rest of the buffer.
+ while (cur_bits > 0) {
+ char_out((byte) (cur_accum & 0xff), outs);
+ cur_accum >>= 8;
+ cur_bits -= 8;
+ }
+
+ flush_char(outs);
+ }
+ }
+}
diff --git a/src/net/sourceforge/plantuml/BasicEnsureVisible.java b/src/net/sourceforge/plantuml/BasicEnsureVisible.java
new file mode 100644
index 0000000..b7d7997
--- /dev/null
+++ b/src/net/sourceforge/plantuml/BasicEnsureVisible.java
@@ -0,0 +1,77 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+public class BasicEnsureVisible implements EnsureVisible {
+
+ private double minX = Double.MAX_VALUE;
+ private double maxX = -Double.MAX_VALUE;
+ private double minY = Double.MAX_VALUE;
+ private double maxY = -Double.MAX_VALUE;
+
+ public void ensureVisible(double x, double y) {
+ if (x > maxX) {
+ maxX = x;
+ }
+ if (x < minX) {
+ minX = x;
+ }
+ if (y > maxY) {
+ maxY = y;
+ }
+ if (y < minY) {
+ minY = y;
+ }
+ }
+
+ public String getCoords(double scale) {
+ if (minX == Double.MAX_VALUE) {
+ return "0,0,0,0";
+ }
+ final int x1 = (int) (minX * scale);
+ final int y1 = (int) (minY * scale);
+ final int x2 = (int) (maxX * scale);
+ final int y2 = (int) (maxY * scale);
+ return "" + x1 + "," + y1 + "," + x2 + "," + y2;
+ }
+
+ public double getSurface() {
+ if (minX == Double.MAX_VALUE) {
+ return 0;
+ }
+ return (maxX - minX) * (maxY - minY);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/BlockUml.java b/src/net/sourceforge/plantuml/BlockUml.java
new file mode 100644
index 0000000..067267b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/BlockUml.java
@@ -0,0 +1,101 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.core.Diagram;
+
+public class BlockUml {
+
+ private final List<? extends CharSequence> data;
+ private final int startLine;
+ private Diagram system;
+
+ private static final Pattern patternFilename = MyPattern.cmpile("^@start[^%s{}%g]+[%s{][%s%g]*([^%g]*?)[%s}%g]*$");
+
+ BlockUml(String... strings) {
+ this(Arrays.asList(strings), 0);
+ }
+
+ public BlockUml(List<? extends CharSequence> strings, int startLine) {
+ this.startLine = startLine;
+ final String s0 = strings.get(0).toString().trim();
+ if (s0.startsWith("@start") == false) {
+ throw new IllegalArgumentException();
+ }
+ this.data = new ArrayList<CharSequence>(strings);
+ }
+
+ public String getFilename() {
+ if (OptionFlags.getInstance().isWord()) {
+ return null;
+ }
+ final Matcher m = patternFilename.matcher(data.get(0).toString().trim());
+ final boolean ok = m.find();
+ if (ok == false) {
+ return null;
+ }
+ String result = m.group(1);
+ final int x = result.indexOf(',');
+ if (x != -1) {
+ result = result.substring(0, x);
+ }
+ for (int i = 0; i < result.length(); i++) {
+ final char c = result.charAt(i);
+ if ("<>|".indexOf(c) != -1) {
+ return null;
+ }
+ }
+ return result;
+ }
+
+ public Diagram getDiagram() {
+ if (system == null) {
+ system = new PSystemBuilder().createPSystem(data);
+ }
+ return system;
+ }
+
+ public final int getStartLine() {
+ return startLine;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/BlockUmlBuilder.java b/src/net/sourceforge/plantuml/BlockUmlBuilder.java
new file mode 100644
index 0000000..8b325a1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/BlockUmlBuilder.java
@@ -0,0 +1,123 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import net.sourceforge.plantuml.preproc.Defines;
+import net.sourceforge.plantuml.preproc.Preprocessor;
+import net.sourceforge.plantuml.preproc.ReadLineReader;
+import net.sourceforge.plantuml.preproc.UncommentReadLine;
+import net.sourceforge.plantuml.utils.StartUtils;
+
+final public class BlockUmlBuilder {
+
+ private final List<BlockUml> blocks = new ArrayList<BlockUml>();
+ private final Set<File> usedFiles = new HashSet<File>();
+ private final UncommentReadLine reader2;
+
+ public BlockUmlBuilder(List<String> config, String charset, Defines defines, Reader reader, File newCurrentDir)
+ throws IOException {
+ Preprocessor includer = null;
+ try {
+ reader2 = new UncommentReadLine(new ReadLineReader(reader));
+ includer = new Preprocessor(reader2, charset, defines, usedFiles, newCurrentDir);
+ init(includer, config);
+ } finally {
+ if (includer != null) {
+ includer.close();
+ }
+ }
+ }
+
+ private void init(Preprocessor includer, List<String> config) throws IOException {
+ String s = null;
+ List<String> current = null;
+ boolean paused = false;
+ int startLine = 0;
+ while ((s = includer.readLine()) != null) {
+ if (StartUtils.isArobaseStartDiagram(s)) {
+ current = new ArrayList<String>();
+ paused = false;
+ startLine = includer.getLineNumber();
+ }
+ if (StartUtils.isArobasePauseDiagram(s)) {
+ paused = true;
+ reader2.setPaused(true);
+ }
+ if (current != null && paused == false) {
+ current.add(s);
+ } else if (paused) {
+ final String append = StartUtils.getPossibleAppend(s);
+ if (append != null) {
+ current.add(append);
+ }
+ }
+
+ if (StartUtils.isArobaseUnpauseDiagram(s)) {
+ paused = false;
+ reader2.setPaused(false);
+ }
+ if (StartUtils.isArobaseEndDiagram(s) && current != null) {
+ current.addAll(1, config);
+ blocks.add(new BlockUml(current, startLine));
+ current = null;
+ reader2.setPaused(false);
+ }
+ }
+ }
+
+ public List<BlockUml> getBlockUmls() {
+ return Collections.unmodifiableList(blocks);
+ }
+
+ public final Set<File> getIncludedFiles() {
+ return Collections.unmodifiableSet(usedFiles);
+ }
+
+ /*
+ * private List<String> getStrings(Reader reader) throws IOException { final List<String> result = new
+ * ArrayList<String>(); Preprocessor includer = null; try { includer = new Preprocessor(reader, defines); String s =
+ * null; while ((s = includer.readLine()) != null) { result.add(s); } } finally { if (includer != null) {
+ * includer.close(); } } return Collections.unmodifiableList(result); }
+ */
+}
diff --git a/src/net/sourceforge/plantuml/CMapData.java b/src/net/sourceforge/plantuml/CMapData.java
new file mode 100644
index 0000000..91b8e30
--- /dev/null
+++ b/src/net/sourceforge/plantuml/CMapData.java
@@ -0,0 +1,93 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+public class CMapData {
+
+ private final StringBuilder stringBuilder = new StringBuilder();
+
+ public String asString(String nameId) {
+ return "<map id=\"" + nameId + "_map\" name=\"" + nameId + "_map\">\n" + stringBuilder.toString() + "</map>\n";
+ }
+
+ public boolean containsData() {
+ return stringBuilder.length() > 0;
+ }
+
+ public void appendString(String s) {
+ stringBuilder.append(s);
+ }
+
+ public void appendLong(long s) {
+ stringBuilder.append(s);
+ }
+
+ public void appendUrl(int seq, Url url, double scale) {
+ appendString("<area shape=\"rect\" id=\"id");
+ appendLong(seq);
+ appendString("\" href=\"");
+ appendString(url.getUrl());
+ appendString("\" title=\"");
+ appendString(url.getTooltip());
+ appendString("\" alt=\"\" coords=\"");
+ appendString(url.getCoords(scale));
+ appendString("\"/>");
+
+ appendString("\n");
+ }
+
+ // private CMapData() {
+ // }
+
+ public static CMapData cmapString(Set<Url> allUrlEncountered, double scale) {
+ final CMapData cmapdata = new CMapData();
+
+ final List<Url> all = new ArrayList<Url>(allUrlEncountered);
+ Collections.sort(all, Url.SURFACE_COMPARATOR);
+
+ int seq = 1;
+ for (Url u : all) {
+ cmapdata.appendUrl(seq, u, scale);
+ seq++;
+ }
+ return cmapdata;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ColorParam.java b/src/net/sourceforge/plantuml/ColorParam.java
new file mode 100644
index 0000000..9d04d94
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ColorParam.java
@@ -0,0 +1,173 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+
+
+public enum ColorParam {
+ background(HtmlColorUtils.WHITE),
+ hyperlink(HtmlColorUtils.BLUE),
+
+ activityBackground(HtmlColorUtils.MY_YELLOW),
+ activityBorder(HtmlColorUtils.MY_RED),
+ activityStart(HtmlColorUtils.BLACK),
+ activityEnd(HtmlColorUtils.BLACK),
+ activityBar(HtmlColorUtils.BLACK),
+ activityArrow(HtmlColorUtils.MY_RED),
+
+ usecaseBorder(HtmlColorUtils.MY_RED),
+ usecaseBackground(HtmlColorUtils.MY_YELLOW),
+ usecaseArrow(HtmlColorUtils.MY_RED),
+
+ objectBackground(HtmlColorUtils.MY_YELLOW),
+ objectBorder(HtmlColorUtils.MY_RED),
+ objectArrow(HtmlColorUtils.MY_RED),
+
+ classHeaderBackground(null),
+ classBackground(HtmlColorUtils.MY_YELLOW),
+ classBorder(HtmlColorUtils.MY_RED),
+ stereotypeCBackground(HtmlColorUtils.COL_ADD1B2),
+ stereotypeABackground(HtmlColorUtils.COL_A9DCDF),
+ stereotypeIBackground(HtmlColorUtils.COL_B4A7E5),
+ stereotypeEBackground(HtmlColorUtils.COL_EB937F),
+ classArrow(HtmlColorUtils.MY_RED),
+
+ packageBackground(HtmlColorUtils.MY_YELLOW),
+ packageBorder(HtmlColorUtils.BLACK),
+
+ partitionBackground(HtmlColorUtils.MY_YELLOW),
+ partitionBorder(HtmlColorUtils.BLACK),
+
+ componentBackground(HtmlColorUtils.MY_YELLOW),
+ componentBorder(HtmlColorUtils.MY_RED),
+ interfaceBackground(HtmlColorUtils.MY_YELLOW),
+ interfaceBorder(HtmlColorUtils.MY_RED),
+ // componentArrow,
+
+ stateBackground(HtmlColorUtils.MY_YELLOW),
+ stateBorder(HtmlColorUtils.MY_RED),
+ stateArrow(HtmlColorUtils.MY_RED),
+ stateStart(HtmlColorUtils.BLACK),
+ stateEnd(HtmlColorUtils.BLACK),
+
+ noteBackground(HtmlColorUtils.COL_FBFB77, true),
+ noteBorder(HtmlColorUtils.MY_RED),
+
+ legendBackground(HtmlColorUtils.COL_DDDDDD, true),
+ legendBorder(HtmlColorUtils.BLACK),
+
+ actorBackground(HtmlColorUtils.MY_YELLOW, true),
+ actorBorder(HtmlColorUtils.MY_RED),
+ participantBackground(HtmlColorUtils.MY_YELLOW, true),
+ participantBorder(HtmlColorUtils.MY_RED),
+ sequenceGroupBorder(HtmlColorUtils.BLACK),
+ sequenceGroupBackground(HtmlColorUtils.COL_EEEEEE, true),
+ sequenceReferenceBorder(HtmlColorUtils.BLACK),
+ sequenceReferenceHeaderBackground(HtmlColorUtils.COL_EEEEEE, true),
+ sequenceReferenceBackground(HtmlColorUtils.WHITE, true),
+ sequenceDividerBackground(HtmlColorUtils.COL_EEEEEE, true),
+ sequenceLifeLineBackground(HtmlColorUtils.WHITE, true),
+ sequenceLifeLineBorder(HtmlColorUtils.MY_RED),
+ sequenceArrow(HtmlColorUtils.MY_RED),
+ sequenceBoxBorder(HtmlColorUtils.MY_RED),
+ sequenceBoxBackground(HtmlColorUtils.COL_DDDDDD, true),
+
+ artifactBackground(HtmlColorUtils.MY_YELLOW),
+ artifactBorder(HtmlColorUtils.MY_RED),
+ cloudBackground(HtmlColorUtils.MY_YELLOW),
+ cloudBorder(HtmlColorUtils.MY_RED),
+ queueBackground(HtmlColorUtils.MY_YELLOW),
+ queueBorder(HtmlColorUtils.MY_RED),
+ databaseBackground(HtmlColorUtils.MY_YELLOW),
+ databaseBorder(HtmlColorUtils.MY_RED),
+ folderBackground(HtmlColorUtils.MY_YELLOW),
+ folderBorder(HtmlColorUtils.MY_RED),
+ frameBackground(HtmlColorUtils.MY_YELLOW),
+ frameBorder(HtmlColorUtils.MY_RED),
+ nodeBackground(HtmlColorUtils.MY_YELLOW),
+ nodeBorder(HtmlColorUtils.MY_RED),
+ rectangleBackground(HtmlColorUtils.MY_YELLOW),
+ rectangleBorder(HtmlColorUtils.MY_RED),
+ agentBackground(HtmlColorUtils.MY_YELLOW),
+ agentBorder(HtmlColorUtils.MY_RED),
+ storageBackground(HtmlColorUtils.MY_YELLOW),
+ storageBorder(HtmlColorUtils.MY_RED),
+ boundaryBackground(HtmlColorUtils.MY_YELLOW),
+ boundaryBorder(HtmlColorUtils.MY_RED),
+ controlBackground(HtmlColorUtils.MY_YELLOW),
+ controlBorder(HtmlColorUtils.MY_RED),
+ entityBackground(HtmlColorUtils.MY_YELLOW),
+ entityBorder(HtmlColorUtils.MY_RED),
+
+
+ iconPrivate(HtmlColorUtils.COL_C82930),
+ iconPrivateBackground(HtmlColorUtils.COL_F24D5C),
+ iconPackage(HtmlColorUtils.COL_1963A0),
+ iconPackageBackground(HtmlColorUtils.COL_4177AF),
+ iconProtected(HtmlColorUtils.COL_B38D22),
+ iconProtectedBackground(HtmlColorUtils.COL_FFFF44),
+ iconPublic(HtmlColorUtils.COL_038048),
+ iconPublicBackground(HtmlColorUtils.COL_84BE84);
+
+ private final boolean isBackground;
+ private final HtmlColor defaultValue;
+
+ private ColorParam(HtmlColor defaultValue) {
+ this(defaultValue, false);
+ }
+
+ private ColorParam() {
+ this(null, false);
+ }
+
+ private ColorParam(boolean isBackground) {
+ this(null, isBackground);
+ }
+
+ private ColorParam(HtmlColor defaultValue, boolean isBackground) {
+ this.isBackground = isBackground;
+ this.defaultValue = defaultValue;
+ }
+
+ protected boolean isBackground() {
+ return isBackground;
+ }
+
+ public final HtmlColor getDefaultValue() {
+ return defaultValue;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/CounterOutputStream.java b/src/net/sourceforge/plantuml/CounterOutputStream.java
new file mode 100644
index 0000000..52ebf10
--- /dev/null
+++ b/src/net/sourceforge/plantuml/CounterOutputStream.java
@@ -0,0 +1,91 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+public class CounterOutputStream extends OutputStream {
+
+ private int length;
+ private final OutputStream os;
+
+ public CounterOutputStream(OutputStream os) {
+ this.os = os;
+ }
+
+ /**
+ * Writes to nowhere
+ */
+ @Override
+ public void write(int b) throws IOException {
+ os.write(b);
+ length++;
+ }
+
+ /**
+ * Overridden for performance reason
+ */
+ @Override
+ public void write(byte b[]) throws IOException {
+ os.write(b);
+ length += b.length;
+ }
+
+ /**
+ * Overridden for performance reason
+ */
+ @Override
+ public void write(byte b[], int off, int len) throws IOException {
+ os.write(b, off, len);
+ length += len;
+ }
+
+ public int getLength() {
+ return length;
+ }
+
+ @Override
+ public void flush() throws IOException {
+ os.flush();
+ }
+
+
+ @Override
+ public void close() throws IOException {
+ os.close();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/Dimension2DDouble.java b/src/net/sourceforge/plantuml/Dimension2DDouble.java
new file mode 100644
index 0000000..db30050
--- /dev/null
+++ b/src/net/sourceforge/plantuml/Dimension2DDouble.java
@@ -0,0 +1,125 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.utils.MathUtils;
+
+public class Dimension2DDouble extends Dimension2D {
+
+ final private double width;
+ final private double height;
+
+ public Dimension2DDouble(double width, double height) {
+ this.width = width;
+ this.height = height;
+ }
+
+ @Override
+ public String toString() {
+ return "[" + width + "," + height + "]";
+ }
+
+ @Override
+ public double getHeight() {
+ return height;
+ }
+
+ @Override
+ public double getWidth() {
+ return width;
+ }
+
+ @Override
+ public void setSize(double width, double height) {
+ throw new UnsupportedOperationException();
+ }
+
+ public static Dimension2D delta(Dimension2D dim, double delta) {
+ return delta(dim, delta, delta);
+ }
+
+ public static Dimension2D delta(Dimension2D dim, double deltaWidth, double deltaHeight) {
+ if (deltaHeight == 0 && deltaWidth == 0) {
+ return dim;
+ }
+ return new Dimension2DDouble(dim.getWidth() + deltaWidth, dim.getHeight() + deltaHeight);
+ }
+
+ public static Dimension2D mergeTB(Dimension2D top, Dimension2D bottom) {
+ final double width = Math.max(top.getWidth(), bottom.getWidth());
+ final double height = top.getHeight() + bottom.getHeight();
+ return new Dimension2DDouble(width, height);
+ }
+
+ public static Dimension2D mergeTB(Dimension2D a, Dimension2D b, Dimension2D c) {
+ final double width = MathUtils.max(a.getWidth(), b.getWidth(), c.getWidth());
+ final double height = a.getHeight() + b.getHeight() + c.getHeight();
+ return new Dimension2DDouble(width, height);
+ }
+
+ public static Dimension2D mergeLR(Dimension2D left, Dimension2D right) {
+ final double height = Math.max(left.getHeight(), right.getHeight());
+ final double width = left.getWidth() + right.getWidth();
+ return new Dimension2DDouble(width, height);
+ }
+
+ public static Dimension2D mergeLayoutT12B3(Dimension2D top1, Dimension2D top2, Dimension2D bottom) {
+ final double width = MathUtils.max(top1.getWidth(), top2.getWidth(), bottom.getWidth());
+ final double height = top1.getHeight() + top2.getHeight() + bottom.getHeight();
+ return new Dimension2DDouble(width, height);
+ }
+
+ public static Dimension2D max(Dimension2D dim1, Dimension2D dim2) {
+ return atLeast(dim1, dim2.getWidth(), dim2.getHeight());
+ }
+
+ public static Dimension2D atLeast(Dimension2D dim, double minWidth, double minHeight) {
+ double h = dim.getHeight();
+ double w = dim.getWidth();
+ if (w > minWidth && h > minHeight) {
+ return dim;
+ }
+ if (h < minHeight) {
+ h = minHeight;
+ }
+ if (w < minWidth) {
+ w = minWidth;
+ }
+ return new Dimension2DDouble(w, h);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/DirWatcher.java b/src/net/sourceforge/plantuml/DirWatcher.java
new file mode 100644
index 0000000..8df6f25
--- /dev/null
+++ b/src/net/sourceforge/plantuml/DirWatcher.java
@@ -0,0 +1,129 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import net.sourceforge.plantuml.preproc.Defines;
+
+@Deprecated
+public class DirWatcher {
+
+ final private File dir;
+ final private Option option;
+ final private String pattern;
+
+ final private Map<File, FileWatcher> modifieds = new HashMap<File, FileWatcher>();
+
+ public DirWatcher(File dir, Option option, String pattern) {
+ this.dir = dir;
+ this.option = option;
+ this.pattern = pattern;
+ }
+
+ public List<GeneratedImage> buildCreatedFiles() throws IOException, InterruptedException {
+ boolean error = false;
+ final List<GeneratedImage> result = new ArrayList<GeneratedImage>();
+ for (File f : dir.listFiles()) {
+ if (error) {
+ continue;
+ }
+ if (f.isFile() == false) {
+ continue;
+ }
+ if (fileToProcess(f.getName()) == false) {
+ continue;
+ }
+ final FileWatcher watcher = modifieds.get(f);
+
+ if (watcher == null || watcher.hasChanged()) {
+ final SourceFileReader sourceFileReader = new SourceFileReader(new Defines(), f, option.getOutputDir(),
+ option.getConfig(), option.getCharset(), option.getFileFormatOption());
+ final Set<File> files = new HashSet<File>(sourceFileReader.getIncludedFiles());
+ files.add(f);
+ for (GeneratedImage g : sourceFileReader.getGeneratedImages()) {
+ result.add(g);
+ if (option.isFailfastOrFailfast2() && g.lineErrorRaw() != -1) {
+ error = true;
+ }
+ }
+ modifieds.put(f, new FileWatcher(files));
+ }
+ }
+ Collections.sort(result);
+ return Collections.unmodifiableList(result);
+ }
+
+ public File getErrorFile() throws IOException, InterruptedException {
+ for (File f : dir.listFiles()) {
+ if (f.isFile() == false) {
+ continue;
+ }
+ if (fileToProcess(f.getName()) == false) {
+ continue;
+ }
+ final FileWatcher watcher = modifieds.get(f);
+
+ if (watcher == null || watcher.hasChanged()) {
+ final SourceFileReader sourceFileReader = new SourceFileReader(new Defines(), f, option.getOutputDir(),
+ option.getConfig(), option.getCharset(), option.getFileFormatOption());
+ if (sourceFileReader.hasError()) {
+ return f;
+ }
+ }
+ }
+ return null;
+ }
+
+ private boolean fileToProcess(String name) {
+ return name.matches(pattern);
+ }
+
+ public final File getDir() {
+ return dir;
+ }
+
+ // public void setPattern(String pattern) {
+ // this.pattern = pattern;
+ // }
+}
diff --git a/src/net/sourceforge/plantuml/DirWatcher2.java b/src/net/sourceforge/plantuml/DirWatcher2.java
new file mode 100644
index 0000000..1f2bf39
--- /dev/null
+++ b/src/net/sourceforge/plantuml/DirWatcher2.java
@@ -0,0 +1,128 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+
+import net.sourceforge.plantuml.preproc.Defines;
+
+public class DirWatcher2 {
+
+ final private File dir;
+ final private Option option;
+ final private String pattern;
+
+ final private Map<File, FileWatcher> modifieds = new ConcurrentHashMap<File, FileWatcher>();
+ final private ExecutorService executorService;
+
+ public DirWatcher2(File dir, Option option, String pattern) {
+ this.dir = dir;
+ this.option = option;
+ this.pattern = pattern;
+ final int nb = Option.defaultNbThreads();
+ this.executorService = Executors.newFixedThreadPool(nb);
+ }
+
+ public Map<File, Future<List<GeneratedImage>>> buildCreatedFiles() throws IOException, InterruptedException {
+ final Map<File, Future<List<GeneratedImage>>> result = new TreeMap<File, Future<List<GeneratedImage>>>();
+ if (dir.listFiles() != null) {
+ for (final File f : dir.listFiles()) {
+ if (f.isFile() == false) {
+ continue;
+ }
+ if (fileToProcess(f.getName()) == false) {
+ continue;
+ }
+ final FileWatcher watcher = modifieds.get(f);
+
+ if (watcher == null || watcher.hasChanged()) {
+ final SourceFileReader sourceFileReader = new SourceFileReader(new Defines(), f,
+ option.getOutputDir(), option.getConfig(), option.getCharset(),
+ option.getFileFormatOption());
+ modifieds.put(f, new FileWatcher(Collections.singleton(f)));
+ final Future<List<GeneratedImage>> value = executorService
+ .submit(new Callable<List<GeneratedImage>>() {
+ public List<GeneratedImage> call() throws Exception {
+ try {
+ final List<GeneratedImage> generatedImages = sourceFileReader
+ .getGeneratedImages();
+ final Set<File> files = new HashSet<File>(sourceFileReader.getIncludedFiles());
+ files.add(f);
+ modifieds.put(f, new FileWatcher(files));
+ return Collections.unmodifiableList(generatedImages);
+ } catch (Exception e) {
+ e.printStackTrace();
+ return Collections.emptyList();
+ }
+ }
+ });
+ result.put(f, value);
+ }
+ }
+ }
+ return Collections.unmodifiableMap(result);
+ }
+
+ private boolean fileToProcess(String name) {
+ return name.matches(pattern);
+ }
+
+ public final File getDir() {
+ return dir;
+ }
+
+ public void cancel() {
+ executorService.shutdownNow();
+ }
+
+ public void waitEnd() throws InterruptedException {
+ executorService.shutdown();
+ executorService.awaitTermination(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/Direction.java b/src/net/sourceforge/plantuml/Direction.java
new file mode 100644
index 0000000..9d5b8f5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/Direction.java
@@ -0,0 +1,120 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import java.awt.geom.Point2D;
+
+public enum Direction {
+ RIGHT, LEFT, DOWN, UP;
+
+ public Direction getInv() {
+ if (this == RIGHT) {
+ return LEFT;
+ }
+ if (this == LEFT) {
+ return RIGHT;
+ }
+ if (this == DOWN) {
+ return UP;
+ }
+ if (this == UP) {
+ return DOWN;
+ }
+ throw new IllegalStateException();
+ }
+
+ public static Direction fromChar(char c) {
+ if (c == '<') {
+ return Direction.LEFT;
+ }
+ if (c == '>') {
+ return Direction.RIGHT;
+ }
+ if (c == '^') {
+ return Direction.UP;
+ }
+ return Direction.DOWN;
+ }
+
+ public Direction clockwise() {
+ if (this == RIGHT) {
+ return DOWN;
+ }
+ if (this == LEFT) {
+ return UP;
+ }
+ if (this == DOWN) {
+ return LEFT;
+ }
+ if (this == UP) {
+ return RIGHT;
+ }
+ throw new IllegalStateException();
+ }
+
+ public static Direction leftOrRight(Point2D p1, Point2D p2) {
+ if (p1.getX() < p2.getX()) {
+ return Direction.LEFT;
+ }
+ if (p1.getX() > p2.getX()) {
+ return Direction.RIGHT;
+ }
+ throw new IllegalArgumentException();
+ }
+
+ public static Direction fromVector(Point2D p1, Point2D p2) {
+ final double x1 = p1.getX();
+ final double y1 = p1.getY();
+ final double x2 = p2.getX();
+ final double y2 = p2.getY();
+ if (x1 == x2 && y1 == y2) {
+ return null;
+ }
+ if (x1 == x2) {
+ if (y2 > y1) {
+ return Direction.DOWN;
+ }
+ return Direction.UP;
+ }
+ if (y1 == y2) {
+ if (x2 > x1) {
+ return Direction.RIGHT;
+ }
+ return Direction.LEFT;
+ }
+ throw new IllegalArgumentException("Not a H or V line!");
+
+ }
+}
diff --git a/src/net/sourceforge/plantuml/EmbededDiagram.java b/src/net/sourceforge/plantuml/EmbededDiagram.java
new file mode 100644
index 0000000..1993519
--- /dev/null
+++ b/src/net/sourceforge/plantuml/EmbededDiagram.java
@@ -0,0 +1,62 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import net.sourceforge.plantuml.cucadiagram.Display;
+
+public class EmbededDiagram implements CharSequence {
+
+ private final Display system;
+
+ public EmbededDiagram(Display system) {
+ this.system = system;
+ }
+
+ public int length() {
+ return toString().length();
+ }
+
+ public char charAt(int index) {
+ return toString().charAt(index);
+ }
+
+ public CharSequence subSequence(int start, int end) {
+ return toString().subSequence(start, end);
+ }
+
+ public final Display getLines() {
+ return system;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/EmptyImageBuilder.java b/src/net/sourceforge/plantuml/EmptyImageBuilder.java
new file mode 100644
index 0000000..a363548
--- /dev/null
+++ b/src/net/sourceforge/plantuml/EmptyImageBuilder.java
@@ -0,0 +1,88 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.geom.AffineTransform;
+import java.awt.image.BufferedImage;
+
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+import net.sourceforge.plantuml.ugraphic.UAntiAliasing;
+import net.sourceforge.plantuml.ugraphic.g2d.UGraphicG2d;
+
+public class EmptyImageBuilder {
+
+ private final BufferedImage im;
+ private final Graphics2D g2d;
+
+ public EmptyImageBuilder(double width, double height, Color background) {
+ this((int) width, (int) height, background);
+ }
+
+ public EmptyImageBuilder(int width, int height, Color background) {
+ Log.info("Creating image " + width + "x" + height);
+ im = new BufferedImage(width, height, background == null ? BufferedImage.TYPE_INT_ARGB
+ : BufferedImage.TYPE_INT_RGB);
+ g2d = im.createGraphics();
+ UAntiAliasing.ANTI_ALIASING_ON.apply(g2d);
+ if (background != null) {
+ g2d.setColor(background);
+ g2d.fillRect(0, 0, width, height);
+ }
+ }
+
+ public EmptyImageBuilder(int width, int height, Color background, double dpiFactor) {
+ this(width * dpiFactor, height * dpiFactor, background);
+ if (dpiFactor != 1.0) {
+ g2d.setTransform(AffineTransform.getScaleInstance(dpiFactor, dpiFactor));
+ }
+ }
+
+ public BufferedImage getBufferedImage() {
+ return im;
+ }
+
+ public Graphics2D getGraphics2D() {
+ return g2d;
+ }
+
+ public UGraphicG2d getUGraphicG2d() {
+ final UGraphicG2d result = new UGraphicG2d(new ColorMapperIdentity(), g2d, 1.0);
+ result.setBufferedImage(im);
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/EnsureVisible.java b/src/net/sourceforge/plantuml/EnsureVisible.java
new file mode 100644
index 0000000..8aa0bb5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/EnsureVisible.java
@@ -0,0 +1,41 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+public interface EnsureVisible {
+
+ public void ensureVisible(double x, double y);
+
+}
diff --git a/src/net/sourceforge/plantuml/ErrorUml.java b/src/net/sourceforge/plantuml/ErrorUml.java
new file mode 100644
index 0000000..96dba20
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ErrorUml.java
@@ -0,0 +1,96 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import net.sourceforge.plantuml.suggest.SuggestEngineResult;
+import net.sourceforge.plantuml.suggest.SuggestEngineStatus;
+
+public class ErrorUml {
+
+ private final String error;
+ private final int position;
+ private final ErrorUmlType type;
+ private SuggestEngineResult suggest;
+
+ public ErrorUml(ErrorUmlType type, String error, int position) {
+ if (error == null || type == null || StringUtils.isEmpty(error)) {
+ throw new IllegalArgumentException();
+ }
+ this.error = error;
+ this.type = type;
+ this.position = position;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ final ErrorUml this2 = (ErrorUml) obj;
+ return this.type == this2.type && this.position == this2.position && this.error.equals(this2.error);
+ }
+
+ @Override
+ public int hashCode() {
+ return error.hashCode() + type.hashCode() + position + (suggest == null ? 0 : suggest.hashCode());
+ }
+
+ @Override
+ public String toString() {
+ return type.toString() + " " + position + " " + error + " " + suggest;
+ }
+
+ public final String getError() {
+ return error;
+ }
+
+ public final ErrorUmlType getType() {
+ return type;
+ }
+
+ public int getPosition() {
+ return position;
+ }
+
+ public final SuggestEngineResult getSuggest() {
+ return suggest;
+ }
+
+ public final boolean hasSuggest() {
+ return suggest != null && suggest.getStatus() == SuggestEngineStatus.ONE_SUGGESTION;
+ }
+
+ public void setSuggest(SuggestEngineResult suggest) {
+ this.suggest = suggest;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ErrorUmlType.java b/src/net/sourceforge/plantuml/ErrorUmlType.java
new file mode 100644
index 0000000..ca10a54
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ErrorUmlType.java
@@ -0,0 +1,40 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+public enum ErrorUmlType {
+ SYNTAX_ERROR, EXECUTION_ERROR
+
+}
diff --git a/src/net/sourceforge/plantuml/FileFormat.java b/src/net/sourceforge/plantuml/FileFormat.java
new file mode 100644
index 0000000..60ab6e7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/FileFormat.java
@@ -0,0 +1,118 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import java.io.File;
+
+/**
+ * Format for output files generated by PlantUML.
+ *
+ * @author Arnaud Roques
+ *
+ */
+public enum FileFormat {
+ PNG, SVG, EPS, EPS_TEXT, ATXT, UTXT, XMI_STANDARD, XMI_STAR, XMI_ARGO, PDF, MJPEG, ANIMATED_GIF, HTML, HTML5, VDX, LATEX, BASE64;
+
+ /**
+ * Returns the file format to be used for that format.
+ *
+ * @return a string starting by a point.
+ */
+ public String getFileSuffix() {
+ if (name().startsWith("XMI")) {
+ return ".xmi";
+ }
+ if (this == MJPEG) {
+ return ".avi";
+ }
+ if (this == ANIMATED_GIF) {
+ return ".gif";
+ }
+ if (this == EPS_TEXT) {
+ return EPS.getFileSuffix();
+ }
+ return "." + StringUtils.goLowerCase(name());
+ }
+
+ /**
+ * Check if this file format is Encapsulated PostScript.
+ *
+ * @return <code>true</code> for EPS.
+ */
+ public boolean isEps() {
+ if (this == EPS) {
+ return true;
+ }
+ if (this == EPS_TEXT) {
+ return true;
+ }
+ return false;
+ }
+
+ public String changeName(String fileName, int cpt) {
+ if (cpt == 0) {
+ return changeName(fileName, getFileSuffix());
+ }
+ return changeName(fileName, "_" + String.format("%03d", cpt) + getFileSuffix());
+ }
+
+ private String changeName(String fileName, String replacement) {
+ String result = fileName.replaceAll("\\.\\w+$", replacement);
+ if (result.equals(fileName)) {
+ result = fileName + replacement;
+ }
+ return result;
+ }
+
+ public File computeFilename(File pngFile, int i) {
+ if (i == 0) {
+ return pngFile;
+ }
+ final File dir = pngFile.getParentFile();
+ return new File(dir, computeFilename(pngFile.getName(), i));
+ // String name = pngFile.getName();
+ // name = name.replaceAll("\\" + getFileSuffix() + "$", "_" + String.format("%03d", i) + getFileSuffix());
+ // return new File(dir, name);
+
+ }
+
+ public String computeFilename(String name, int i) {
+ if (i == 0) {
+ return name;
+ }
+ return name.replaceAll("\\" + getFileSuffix() + "$", "_" + String.format("%03d", i) + getFileSuffix());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/FileFormatOption.java b/src/net/sourceforge/plantuml/FileFormatOption.java
new file mode 100644
index 0000000..cc805c5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/FileFormatOption.java
@@ -0,0 +1,203 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Dimension2D;
+import java.awt.image.BufferedImage;
+
+import net.sourceforge.plantuml.eps.EpsStrategy;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorGradient;
+import net.sourceforge.plantuml.graphic.HtmlColorSimple;
+import net.sourceforge.plantuml.graphic.HtmlColorTransparent;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic2;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.eps.UGraphicEps;
+import net.sourceforge.plantuml.ugraphic.g2d.UGraphicG2d;
+import net.sourceforge.plantuml.ugraphic.html5.UGraphicHtml5;
+import net.sourceforge.plantuml.ugraphic.svg.UGraphicSvg;
+import net.sourceforge.plantuml.ugraphic.tikz.UGraphicTikz;
+import net.sourceforge.plantuml.ugraphic.visio.UGraphicVdx;
+import net.sourceforge.plantuml.StringUtils;
+
+/**
+ * A FileFormat with some parameters.
+ *
+ *
+ * @author Arnaud Roques
+ *
+ */
+public class FileFormatOption {
+
+ private final FileFormat fileFormat;
+ private final AffineTransform affineTransform;
+ private final boolean withMetadata;
+ private final boolean useRedForError;
+
+ public FileFormatOption(FileFormat fileFormat) {
+ this(fileFormat, null, true, false);
+ }
+
+ public final boolean isWithMetadata() {
+ return withMetadata;
+ }
+
+ public FileFormatOption(FileFormat fileFormat, boolean withMetadata) {
+ this(fileFormat, null, false, false);
+ }
+
+ private FileFormatOption(FileFormat fileFormat, AffineTransform at, boolean withMetadata, boolean useRedForError) {
+ this.fileFormat = fileFormat;
+ this.affineTransform = at;
+ this.withMetadata = withMetadata;
+ this.useRedForError = useRedForError;
+ }
+
+ public FileFormatOption withUseRedForError() {
+ return new FileFormatOption(fileFormat, affineTransform, withMetadata, true);
+ }
+
+ @Override
+ public String toString() {
+ return fileFormat.toString() + " " + affineTransform;
+ }
+
+ public final FileFormat getFileFormat() {
+ return fileFormat;
+ }
+
+ public AffineTransform getAffineTransform() {
+ return affineTransform;
+ }
+
+ /**
+ * Create a UGraphic corresponding to this FileFormatOption
+ *
+ * @param colorMapper
+ * @param dpiFactor
+ * 1.0 for a standard dot per inch
+ * @param dim
+ * @param mybackcolor
+ * @param rotation
+ * @return
+ */
+ public UGraphic2 createUGraphic(ColorMapper colorMapper, double dpiFactor, final Dimension2D dim,
+ HtmlColor mybackcolor, boolean rotation) {
+ switch (fileFormat) {
+ case PNG:
+ return createUGraphicPNG(colorMapper, dpiFactor, dim, mybackcolor, rotation);
+ case SVG:
+ return createUGraphicSVG(colorMapper, dpiFactor, dim, mybackcolor, rotation);
+ case EPS:
+ return new UGraphicEps(colorMapper, EpsStrategy.getDefault2());
+ case EPS_TEXT:
+ return new UGraphicEps(colorMapper, EpsStrategy.WITH_MACRO_AND_TEXT);
+ case HTML5:
+ return new UGraphicHtml5(colorMapper);
+ case VDX:
+ return new UGraphicVdx(colorMapper);
+ case LATEX:
+ return new UGraphicTikz(colorMapper);
+ default:
+ throw new UnsupportedOperationException(fileFormat.toString());
+ }
+ }
+
+ public UGraphic2 createUGraphic(final Dimension2D dim) {
+ return createUGraphic(new ColorMapperIdentity(), 1.0, dim, null, false);
+ }
+
+ private UGraphic2 createUGraphicSVG(ColorMapper colorMapper, double scale, Dimension2D dim, HtmlColor mybackcolor,
+ boolean rotation) {
+ Color backColor = Color.WHITE;
+ if (mybackcolor instanceof HtmlColorSimple) {
+ backColor = colorMapper.getMappedColor(mybackcolor);
+ }
+ final UGraphicSvg ug;
+ if (mybackcolor instanceof HtmlColorGradient) {
+ ug = new UGraphicSvg(colorMapper, (HtmlColorGradient) mybackcolor, false, scale);
+ } else if (backColor == null || backColor.equals(Color.WHITE)) {
+ ug = new UGraphicSvg(colorMapper, false, scale);
+ } else {
+ ug = new UGraphicSvg(colorMapper, StringUtils.getAsHtml(backColor), false, scale);
+ }
+ return ug;
+
+ }
+
+ private UGraphic2 createUGraphicPNG(ColorMapper colorMapper, double dpiFactor, final Dimension2D dim,
+ HtmlColor mybackcolor, boolean rotation) {
+ Color backColor = Color.WHITE;
+ if (mybackcolor instanceof HtmlColorSimple) {
+ backColor = colorMapper.getMappedColor(mybackcolor);
+ } else if (mybackcolor instanceof HtmlColorTransparent) {
+ backColor = null;
+ }
+
+ final EmptyImageBuilder builder;
+ final Graphics2D graphics2D;
+ 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 {
+ builder = new EmptyImageBuilder((int) (dim.getWidth() * dpiFactor), (int) (dim.getHeight() * dpiFactor),
+ backColor);
+ graphics2D = builder.getGraphics2D();
+
+ }
+ final UGraphicG2d ug = new UGraphicG2d(colorMapper, graphics2D, dpiFactor);
+ ug.setBufferedImage(builder.getBufferedImage());
+ final BufferedImage im = ((UGraphicG2d) ug).getBufferedImage();
+ if (mybackcolor instanceof HtmlColorGradient) {
+ ug.apply(new UChangeBackColor(mybackcolor)).draw(new URectangle(im.getWidth(), im.getHeight()));
+ }
+
+ return ug;
+ }
+
+ public final boolean isUseRedForError() {
+ return useRedForError;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/FileGroup.java b/src/net/sourceforge/plantuml/FileGroup.java
new file mode 100644
index 0000000..bbbaa3c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/FileGroup.java
@@ -0,0 +1,177 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+
+public class FileGroup {
+
+ private final List<File> result = new ArrayList<File>();
+ private final String pattern;
+ private final List<String> excluded;
+ private final Option option;
+
+ private final static Pattern predirPath = MyPattern.cmpile("^([^*?]*[/\\\\])?(.*)$");
+
+ public FileGroup(String pattern, List<String> excluded, Option option) {
+ this.pattern = pattern;
+ this.excluded = excluded;
+ this.option = option;
+ if (pattern.indexOf("*") == -1 && pattern.indexOf("?") == -1) {
+ initNoStar();
+ } else if (pattern.indexOf("**") != -1) {
+ recurse();
+ } else {
+ initWithSimpleStar();
+ }
+ Collections.sort(result);
+
+ }
+
+ private void recurse() {
+ final Matcher m = predirPath.matcher(pattern);
+ final boolean ok = m.find();
+ if (ok == false) {
+ throw new IllegalArgumentException();
+ }
+ final File parent;
+ if (m.group(1) == null) {
+ parent = new File(".");
+ } else {
+ parent = new File(m.group(1));
+ }
+ initWithDoubleStar(parent);
+ }
+
+ private void initNoStar() {
+ final File f = new File(pattern);
+ if (f.isDirectory()) {
+ addSimpleDirectory(f);
+ } else if (f.isFile()) {
+ addResultFile(f);
+ }
+ }
+
+ private void addResultFile(final File f) {
+ final String path = getNormalizedPath(f);
+ for (String x : excluded) {
+ if (path.matches(toRegexp(x))) {
+ return;
+ }
+ }
+ result.add(f);
+ }
+
+ private void addSimpleDirectory(File dir) {
+ if (OptionFlags.getInstance().isWord()) {
+ addSimpleDirectory(dir, "(?i)^.*_extr\\d+\\.txt$");
+ } else {
+ addSimpleDirectory(dir, option.getPattern());
+ }
+ }
+
+ private void addSimpleDirectory(File dir, String pattern) {
+ if (dir.isDirectory() == false) {
+ throw new IllegalArgumentException("dir=" + dir);
+ }
+ for (File f : dir.listFiles()) {
+ if (f.getName().matches(pattern)) {
+ addResultFile(f);
+ }
+ }
+ }
+
+ private static String getNormalizedPath(File f) {
+ return f.getPath().replace('\\', '/');
+ }
+
+ private final static Pattern noStarInDirectory = MyPattern.cmpile("^(?:([^*?]*)[/\\\\])?([^/\\\\]*)$");
+
+ private void initWithSimpleStar() {
+ assert pattern.indexOf("**") == -1;
+ final Matcher m = noStarInDirectory.matcher(pattern);
+ if (m.find()) {
+ File dir = new File(".");
+ if (m.group(1) != null) {
+ final String dirPart = m.group(1);
+ dir = new File(dirPart);
+ }
+
+ final String filesPart = m.group(2);
+ addSimpleDirectory(dir, toRegexp(filesPart));
+ } else {
+ recurse();
+ }
+
+ }
+
+ private void initWithDoubleStar(File currentDir) {
+ for (File f : currentDir.listFiles()) {
+ if (f.isDirectory()) {
+ initWithDoubleStar(f);
+ } else if (f.isFile()) {
+ final String path = getNormalizedPath(f);
+ if (path.matches(toRegexp(pattern))) {
+ addResultFile(f);
+ }
+
+ }
+ }
+
+ }
+
+ public List<File> getFiles() {
+ return Collections.unmodifiableList(result);
+ }
+
+ public static String toRegexp(String pattern) {
+ pattern = pattern.replace("\\", "/");
+ pattern = pattern.replace(".", "\\.");
+ pattern = pattern.replace("?", "[^/]");
+ pattern = pattern.replace("/**/", "(/|/.{0,}/)");
+ pattern = pattern.replace("**", ".{0,}");
+ pattern = pattern.replace("*", "[^/]{0,}");
+ pattern = "(?i)^(\\./)?" + pattern + "$";
+ return pattern;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/FileSystem.java b/src/net/sourceforge/plantuml/FileSystem.java
new file mode 100644
index 0000000..dfaa378
--- /dev/null
+++ b/src/net/sourceforge/plantuml/FileSystem.java
@@ -0,0 +1,119 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+
+public class FileSystem {
+
+ private final static FileSystem singleton = new FileSystem();
+
+ private final ThreadLocal<File> currentDir = new ThreadLocal<File>();
+
+ private FileSystem() {
+ reset();
+ }
+
+ public static FileSystem getInstance() {
+ return singleton;
+ }
+
+ public void setCurrentDir(File dir) {
+ if (dir == null) {
+ throw new IllegalArgumentException();
+ }
+ Log.info("Setting current dir: " + dir);
+ this.currentDir.set(dir);
+ }
+
+ public File getCurrentDir() {
+ return this.currentDir.get();
+ }
+
+ public File getFile(String nameOrPath) throws IOException {
+ final File dir = currentDir.get();
+ if (dir == null || isAbsolute(nameOrPath)) {
+ return new File(nameOrPath).getCanonicalFile();
+ }
+ final File filecurrent = new File(dir.getAbsoluteFile(), nameOrPath);
+ if (filecurrent.exists()) {
+ return filecurrent.getCanonicalFile();
+ }
+ for (File d : getPath("plantuml.include.path")) {
+ final File file = new File(d, nameOrPath);
+ if (file.exists()) {
+ return file.getCanonicalFile();
+ }
+ }
+ for (File d : getPath("java.class.path")) {
+ final File file = new File(d, nameOrPath);
+ if (file.exists()) {
+ return file.getCanonicalFile();
+ }
+ }
+ return filecurrent;
+ }
+
+ private List<File> getPath(String prop) {
+ final List<File> result = new ArrayList<File>();
+ final String paths = System.getProperty(prop);
+ if (paths == null) {
+ return result;
+ }
+ final StringTokenizer st = new StringTokenizer(paths, System.getProperty("path.separator"));
+ while (st.hasMoreTokens()) {
+ final File f = new File(st.nextToken());
+ if (f.exists() && f.isDirectory()) {
+ result.add(f);
+ }
+ }
+ return result;
+ }
+
+ private boolean isAbsolute(String nameOrPath) {
+ final File f = new File(nameOrPath);
+ return f.isAbsolute();
+ }
+
+ public void reset() {
+ setCurrentDir(new File("."));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/FileUtils.java b/src/net/sourceforge/plantuml/FileUtils.java
new file mode 100644
index 0000000..9dae20b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/FileUtils.java
@@ -0,0 +1,114 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.concurrent.atomic.AtomicInteger;
+
+// Used by the Eclipse Plugin, so do not change package location.
+public class FileUtils {
+
+ private static AtomicInteger counter;
+
+ public static void resetCounter() {
+ counter = new AtomicInteger(0);
+ }
+
+ static public File createTempFile(String prefix, String suffix) throws IOException {
+ if (suffix.startsWith(".") == false) {
+ throw new IllegalArgumentException();
+ }
+ if (prefix == null) {
+ throw new IllegalArgumentException();
+ }
+ final File f;
+ if (counter == null) {
+ f = File.createTempFile(prefix, suffix);
+ } else {
+ final String name = prefix + counter.addAndGet(1) + suffix;
+ f = new File(name);
+ }
+ Log.info("Creating temporary file: " + f);
+ if (OptionFlags.getInstance().isKeepTmpFiles() == false) {
+ f.deleteOnExit();
+ }
+ return f;
+ }
+
+ private static void copyInternal(final InputStream fis, final OutputStream fos) throws IOException {
+ final byte[] buf = new byte[10240];
+ int len;
+ while ((len = fis.read(buf)) > 0) {
+ fos.write(buf, 0, len);
+ }
+ fos.close();
+ fis.close();
+ }
+
+ static public void copyToFile(File src, File dest) throws IOException {
+ if (dest.isDirectory()) {
+ dest = new File(dest, src.getName());
+ }
+ final InputStream fis = new BufferedInputStream(new FileInputStream(src));
+ final OutputStream fos = new BufferedOutputStream(new FileOutputStream(dest));
+ copyInternal(fis, fos);
+ }
+
+ static public void copyToStream(File src, OutputStream os) throws IOException {
+ final InputStream fis = new BufferedInputStream(new FileInputStream(src));
+ final OutputStream fos = new BufferedOutputStream(os);
+ copyInternal(fis, fos);
+ }
+
+ static public void copyToStream(InputStream is, OutputStream os) throws IOException {
+ final InputStream fis = new BufferedInputStream(is);
+ final OutputStream fos = new BufferedOutputStream(os);
+ copyInternal(fis, fos);
+ }
+
+ static public void copyToFile(byte[] src, File dest) throws IOException {
+ final OutputStream fos = new BufferedOutputStream(new FileOutputStream(dest));
+ fos.write(src);
+ fos.close();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/FileWatcher.java b/src/net/sourceforge/plantuml/FileWatcher.java
new file mode 100644
index 0000000..df3b30c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/FileWatcher.java
@@ -0,0 +1,70 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+public class FileWatcher {
+
+ private final Map<File, Long> modified2 = new HashMap<File, Long>();
+
+ public FileWatcher(Set<File> files) {
+ if (files.size() == 0) {
+ throw new IllegalArgumentException();
+ }
+ for (File f : files) {
+ modified2.put(f, f.lastModified());
+ }
+ }
+
+ @Override
+ public String toString() {
+ return modified2.toString();
+ }
+
+ public boolean hasChanged() {
+ for (Map.Entry<File, Long> ent : modified2.entrySet()) {
+ final long nowModified = ent.getKey().lastModified();
+ if (ent.getValue().longValue() != nowModified) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/FontParam.java b/src/net/sourceforge/plantuml/FontParam.java
new file mode 100644
index 0000000..22b4fa5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/FontParam.java
@@ -0,0 +1,150 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import java.awt.Font;
+
+interface FontParamConstant {
+ String FAMILY = "SansSerif";
+ String COLOR = "black";
+}
+
+public enum FontParam {
+ ACTIVITY(12, Font.PLAIN), //
+ ACTIVITY_DIAMOND(11, Font.PLAIN), //
+ ACTIVITY_ARROW(11, Font.PLAIN), //
+ GENERIC_ARROW(13, Font.PLAIN), //
+ CIRCLED_CHARACTER(17, Font.BOLD, FontParamConstant.COLOR, "Monospaced"), //
+ OBJECT_ATTRIBUTE(10, Font.PLAIN), //
+ OBJECT(12, Font.PLAIN), //
+ OBJECT_STEREOTYPE(12, Font.ITALIC), //
+ CLASS_ATTRIBUTE(10, Font.PLAIN), //
+ CLASS(12, Font.PLAIN), //
+ CLASS_STEREOTYPE(12, Font.ITALIC), //
+ COMPONENT(14, Font.PLAIN), //
+ INTERFACE(14, Font.PLAIN), //
+ INTERFACE_STEREOTYPE(14, Font.ITALIC), //
+ COMPONENT_STEREOTYPE(14, Font.ITALIC), //
+ NOTE(13, Font.PLAIN), //
+ PACKAGE(14, Font.PLAIN), //
+ ACTOR(14, Font.PLAIN), //
+ ARTIFACT(14, Font.PLAIN), //
+ CLOUD(14, Font.PLAIN), //
+ FOLDER(14, Font.PLAIN), //
+ FRAME(14, Font.PLAIN), //
+ STORAGE(14, Font.PLAIN), //
+ BOUNDARY(14, Font.PLAIN), //
+ CONTROL(14, Font.PLAIN), //
+ ENTITY(14, Font.PLAIN), //
+ AGENT(14, Font.PLAIN), //
+ RECTANGLE(14, Font.PLAIN), //
+ NODE(14, Font.PLAIN), //
+ DATABASE(14, Font.PLAIN), //
+ QUEUE(14, Font.PLAIN), //
+ SEQUENCE_ARROW(13, Font.PLAIN), //
+ SEQUENCE_BOX(13, Font.BOLD), //
+ SEQUENCE_DIVIDER(13, Font.BOLD), //
+ SEQUENCE_REFERENCE(13, Font.PLAIN), //
+ SEQUENCE_DELAY(11, Font.PLAIN), //
+ SEQUENCE_GROUP(11, Font.BOLD), //
+ SEQUENCE_GROUP_HEADER(13, Font.BOLD), //
+ PARTICIPANT(14, Font.PLAIN), //
+ SEQUENCE_TITLE(14, Font.BOLD), //
+ STATE(14, Font.PLAIN), //
+ STATE_ATTRIBUTE(12, Font.PLAIN), //
+ LEGEND(14, Font.PLAIN), //
+ TITLE(18, Font.PLAIN), //
+ FOOTER(10, Font.PLAIN, "#888888", FontParamConstant.FAMILY), //
+ HEADER(10, Font.PLAIN, "#888888", FontParamConstant.FAMILY), //
+ USECASE(14, Font.PLAIN), //
+ USECASE_STEREOTYPE(14, Font.ITALIC), //
+ ARTIFACT_STEREOTYPE(14, Font.ITALIC), //
+ CLOUD_STEREOTYPE(14, Font.ITALIC), //
+ STORAGE_STEREOTYPE(14, Font.ITALIC), //
+ BOUNDARY_STEREOTYPE(14, Font.ITALIC), //
+ CONTROL_STEREOTYPE(14, Font.ITALIC), //
+ ENTITY_STEREOTYPE(14, Font.ITALIC), //
+ AGENT_STEREOTYPE(14, Font.ITALIC), //
+ RECTANGLE_STEREOTYPE(14, Font.ITALIC), //
+ NODE_STEREOTYPE(14, Font.ITALIC), //
+ FOLDER_STEREOTYPE(14, Font.ITALIC), //
+ FRAME_STEREOTYPE(14, Font.ITALIC), //
+ DATABASE_STEREOTYPE(14, Font.ITALIC), //
+ QUEUE_STEREOTYPE(14, Font.ITALIC), //
+ ACTOR_STEREOTYPE(14, Font.ITALIC), //
+ SEQUENCE_STEREOTYPE(14, Font.ITALIC); //
+
+ private final int defaultSize;
+ private final int fontStyle;
+ private final String defaultColor;
+ private final String defaultFamily;
+
+ private FontParam(int defaultSize, int fontStyle, String defaultColor, String defaultFamily) {
+ this.defaultSize = defaultSize;
+ this.fontStyle = fontStyle;
+ this.defaultColor = defaultColor;
+ this.defaultFamily = defaultFamily;
+ }
+
+ private FontParam(int defaultSize, int fontStyle) {
+ this(defaultSize, fontStyle, FontParamConstant.COLOR, FontParamConstant.FAMILY);
+ }
+
+ public final int getDefaultSize(ISkinParam skinParam) {
+ if (this == CLASS_ATTRIBUTE) {
+ return 11;
+ }
+ return defaultSize;
+ }
+
+ public final int getDefaultFontStyle(ISkinParam skinParam, boolean inPackageTitle) {
+ if (this == STATE) {
+ return fontStyle;
+ }
+ if (inPackageTitle || this == PACKAGE) {
+ return Font.BOLD;
+ }
+ return fontStyle;
+ }
+
+ public final String getDefaultColor() {
+ return defaultColor;
+ }
+
+ public String getDefaultFamily() {
+ return defaultFamily;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/GeneratedImage.java b/src/net/sourceforge/plantuml/GeneratedImage.java
new file mode 100644
index 0000000..6753446
--- /dev/null
+++ b/src/net/sourceforge/plantuml/GeneratedImage.java
@@ -0,0 +1,93 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import java.io.File;
+
+import net.sourceforge.plantuml.core.Diagram;
+
+public class GeneratedImage implements Comparable<GeneratedImage> {
+
+ private final File pngFile;
+ private final String description;
+ private final BlockUml blockUml;
+
+ public GeneratedImage(File pngFile, String description, BlockUml blockUml) {
+ this.blockUml = blockUml;
+ this.pngFile = pngFile;
+ this.description = description;
+ }
+
+ public File getPngFile() {
+ return pngFile;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public int lineErrorRaw() {
+ final Diagram system = blockUml.getDiagram();
+ if (system instanceof PSystemError) {
+ return ((PSystemError) system).getHigherErrorPosition() + blockUml.getStartLine();
+ }
+ return -1;
+ }
+
+ @Override
+ public String toString() {
+ return pngFile.getAbsolutePath() + " " + description;
+ }
+
+ public int compareTo(GeneratedImage this2) {
+ final int cmp = this.pngFile.compareTo(this2.pngFile);
+ if (cmp != 0) {
+ return cmp;
+ }
+ return this.description.compareTo(this2.description);
+ }
+
+ @Override
+ public int hashCode() {
+ return pngFile.hashCode() + description.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ final GeneratedImage this2 = (GeneratedImage) obj;
+ return this2.pngFile.equals(this.pngFile) && this2.description.equals(this.description);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/Hideable.java b/src/net/sourceforge/plantuml/Hideable.java
new file mode 100644
index 0000000..0dbc37f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/Hideable.java
@@ -0,0 +1,41 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+public interface Hideable {
+
+ public boolean isHidden();
+
+}
diff --git a/src/net/sourceforge/plantuml/ISkinParam.java b/src/net/sourceforge/plantuml/ISkinParam.java
new file mode 100644
index 0000000..e139548
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ISkinParam.java
@@ -0,0 +1,125 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import net.sourceforge.plantuml.cucadiagram.Rankdir;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.cucadiagram.dot.DotSplines;
+import net.sourceforge.plantuml.cucadiagram.dot.GraphvizLayoutStrategy;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.IHtmlColorSet;
+import net.sourceforge.plantuml.graphic.SkinParameter;
+import net.sourceforge.plantuml.svek.ConditionStyle;
+import net.sourceforge.plantuml.svek.PackageStyle;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+
+public interface ISkinParam extends ISkinSimple {
+
+ public HtmlColor getHyperlinkColor();
+
+ public boolean useUnderlineForHyperlink();
+
+ public HtmlColor getBackgroundColor();
+
+ public HtmlColor getHtmlColor(ColorParam param, Stereotype stereotype, boolean clickable);
+
+ public HtmlColor getFontHtmlColor(FontParam param, Stereotype stereotype);
+
+ public UStroke getThickness(LineParam param, Stereotype stereotype);
+
+ public UFont getFont(FontParam fontParam, Stereotype stereotype, boolean inPackageTitle);
+
+ public HorizontalAlignment getHorizontalAlignment(AlignParam param);
+
+ public HorizontalAlignment getDefaultTextAlignment();
+
+ public int getCircledCharacterRadius();
+
+ public int classAttributeIconSize();
+
+ public ColorMapper getColorMapper();
+
+ public int getDpi();
+
+ public DotSplines getDotSplines();
+
+ public GraphvizLayoutStrategy getStrategy();
+
+ public boolean shadowing();
+
+ public boolean shadowing2(SkinParameter skinParameter);
+
+ public PackageStyle getPackageStyle();
+
+ public boolean useUml2ForComponent();
+
+ public boolean stereotypePositionTop();
+
+ public boolean useSwimlanes(UmlDiagramType type);
+
+ public double getNodesep();
+
+ public double getRanksep();
+
+ public double getRoundCorner();
+
+ public double maxMessageSize();
+
+ public boolean strictUmlStyle();
+
+ public boolean forceSequenceParticipantUnderlined();
+
+ public ConditionStyle getConditionStyle();
+
+ public double minClassWidth();
+
+ public boolean sameClassWidth();
+
+ public Rankdir getRankdir();
+
+ public boolean useOctagonForActivity(Stereotype stereotype);
+
+ public IHtmlColorSet getIHtmlColorSet();
+
+ public int groupInheritance();
+
+ public boolean useGuillemet();
+
+ public boolean handwritten();
+
+}
diff --git a/src/net/sourceforge/plantuml/ISkinSimple.java b/src/net/sourceforge/plantuml/ISkinSimple.java
new file mode 100644
index 0000000..8a8fad4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ISkinSimple.java
@@ -0,0 +1,44 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+public interface ISkinSimple extends SpriteContainer {
+
+ public String getValue(String key);
+
+ public double getPadding();
+
+
+}
diff --git a/src/net/sourceforge/plantuml/ISourceFileReader.java b/src/net/sourceforge/plantuml/ISourceFileReader.java
new file mode 100644
index 0000000..71fa4ce
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ISourceFileReader.java
@@ -0,0 +1,48 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import java.io.IOException;
+import java.util.List;
+
+public interface ISourceFileReader {
+
+ public List<GeneratedImage> getGeneratedImages() throws IOException;
+
+ public List<String> getEncodedUrl() throws IOException;
+
+ public boolean hasError();
+
+}
diff --git a/src/net/sourceforge/plantuml/LineConfigurable.java b/src/net/sourceforge/plantuml/LineConfigurable.java
new file mode 100644
index 0000000..1c8e647
--- /dev/null
+++ b/src/net/sourceforge/plantuml/LineConfigurable.java
@@ -0,0 +1,50 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+
+public interface LineConfigurable {
+
+ public HtmlColor getSpecificLineColor();
+
+ public void setSpecificLineColor(HtmlColor specificLinecolor);
+
+ public UStroke getSpecificLineStroke();
+
+ public void setSpecificLineStroke(UStroke specificLineStoke);
+
+}
diff --git a/src/net/sourceforge/plantuml/LineParam.java b/src/net/sourceforge/plantuml/LineParam.java
new file mode 100644
index 0000000..88c428c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/LineParam.java
@@ -0,0 +1,50 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+
+public enum LineParam {
+// sequenceBoundaryBorder,
+ sequenceActorBorder,
+ sequenceDividerBorder,
+// sequenceGroupBorder(0.1),
+// sequenceReferenceBorder(0.1),
+ sequenceLifeLineBorder,
+ sequenceParticipantBorder, noteBorder, sequenceGroupBorder, sequenceReferenceBorder,
+ classBorder, objectBorder,
+ packageBorder;
+// sequenceBoxBorder(0.1);
+
+}
diff --git a/src/net/sourceforge/plantuml/Log.java b/src/net/sourceforge/plantuml/Log.java
new file mode 100644
index 0000000..30f1fcf
--- /dev/null
+++ b/src/net/sourceforge/plantuml/Log.java
@@ -0,0 +1,110 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+
+public abstract class Log {
+
+ private static final long start = System.currentTimeMillis();
+
+ public synchronized static void debug(String s) {
+ }
+
+ public synchronized static void info(String s) {
+ if (OptionFlags.getInstance().isVerbose()) {
+ System.out.println(format(s));
+ }
+ }
+
+ public synchronized static void error(String s) {
+ System.err.println(s);
+ }
+
+ private static String format(String s) {
+ final long delta = System.currentTimeMillis() - start;
+ // final HealthCheck healthCheck = Performance.getHealthCheck();
+ // final long cpu = healthCheck.jvmCpuTime() / 1000L / 1000L;
+ // final long dot = healthCheck.dotTime().getSum();
+
+ final long freeMemory = Runtime.getRuntime().freeMemory();
+ final long maxMemory = Runtime.getRuntime().maxMemory();
+ final long totalMemory = Runtime.getRuntime().totalMemory();
+ final long usedMemory = totalMemory - freeMemory;
+ final int threadActiveCount = Thread.activeCount();
+
+ final StringBuilder sb = new StringBuilder();
+ sb.append("(");
+ sb.append(delta / 1000L);
+ sb.append(".");
+ sb.append(String.format("%03d", delta % 1000L));
+// if (cpu != -1) {
+// sb.append(" - ");
+// sb.append(cpu / 1000L);
+// sb.append(".");
+// sb.append(String.format("%03d", cpu % 1000L));
+// }
+// sb.append(" - ");
+// sb.append(dot / 1000L);
+// sb.append(".");
+// sb.append(String.format("%03d", dot % 1000L));
+// sb.append("(");
+// sb.append(healthCheck.dotTime().getNb());
+// sb.append(")");
+ sb.append(" - ");
+ final long total = totalMemory / 1024 / 1024;
+ final long free = freeMemory / 1024 / 1024;
+ sb.append(total);
+ sb.append(" Mo) ");
+ sb.append(free);
+ sb.append(" Mo - ");
+ sb.append(s);
+ return sb.toString();
+
+ }
+
+ public static void println(Object s) {
+ if (header2.get() == null) {
+ System.err.println("L = " + s);
+ } else {
+ System.err.println(header2.get() + " " + s);
+ }
+ }
+
+ private static final ThreadLocal<String> header2 = new ThreadLocal<String>();
+
+ public static void header(String s) {
+ header2.set(s);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/NewpagedDiagram.java b/src/net/sourceforge/plantuml/NewpagedDiagram.java
new file mode 100644
index 0000000..8814b8d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/NewpagedDiagram.java
@@ -0,0 +1,135 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.command.Command;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.core.Diagram;
+import net.sourceforge.plantuml.core.DiagramDescription;
+import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
+import net.sourceforge.plantuml.core.ImageData;
+
+public class NewpagedDiagram extends AbstractPSystem {
+
+ private final List<Diagram> diagrams = new ArrayList<Diagram>();
+
+ public NewpagedDiagram(AbstractPSystem diag1, AbstractPSystem diag2) {
+ if (diag1 instanceof NewpagedDiagram) {
+ throw new IllegalArgumentException();
+ }
+ if (diag2 instanceof NewpagedDiagram) {
+ throw new IllegalArgumentException();
+ }
+ this.diagrams.add(diag1);
+ this.diagrams.add(diag2);
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + " SIZE=" + diagrams.size() + " " + diagrams;
+ }
+
+ public CommandExecutionResult executeCommand(Command cmd, List<String> lines) {
+ final int nb = diagrams.size();
+ final CommandExecutionResult tmp = cmd.execute(diagrams.get(nb - 1), lines);
+ if (tmp.getNewDiagram() instanceof NewpagedDiagram) {
+ final NewpagedDiagram new1 = (NewpagedDiagram) tmp.getNewDiagram();
+ // System.err.println("this=" + this);
+ // System.err.println("new1=" + new1);
+ if (new1.size() != 2) {
+ throw new IllegalStateException();
+ }
+ if (new1.diagrams.get(0) != this.diagrams.get(nb - 1)) {
+ throw new IllegalStateException();
+ }
+ this.diagrams.add(new1.diagrams.get(1));
+ return tmp.withDiagram(this);
+
+ }
+ return tmp;
+ }
+
+ private int size() {
+ return diagrams.size();
+ }
+
+ public ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormat) throws IOException {
+ return diagrams.get(num).exportDiagram(os, 0, fileFormat);
+ }
+
+ public int getNbImages() {
+ int nb = 0;
+ for (Diagram d : diagrams) {
+ nb += d.getNbImages();
+ }
+ return nb;
+ }
+
+ public DiagramDescription getDescription() {
+ final StringBuilder sb = new StringBuilder();
+ for (Diagram d : diagrams) {
+ if (sb.length() > 0) {
+ sb.append(" ");
+ }
+ sb.append(d.getDescription());
+ }
+ return new DiagramDescriptionImpl(sb.toString(), getClass());
+ }
+
+ public String getWarningOrError() {
+ final StringBuilder sb = new StringBuilder();
+ for (Diagram d : diagrams) {
+ if (sb.length() > 0) {
+ sb.append(" ");
+ }
+ sb.append(d.getWarningOrError());
+ }
+ return sb.toString();
+ }
+
+ @Override
+ public void makeDiagramReady() {
+ super.makeDiagramReady();
+ for (Diagram diagram : diagrams) {
+ ((AbstractPSystem) diagram).makeDiagramReady();
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/NullOutputStream.java b/src/net/sourceforge/plantuml/NullOutputStream.java
new file mode 100644
index 0000000..837f9c2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/NullOutputStream.java
@@ -0,0 +1,67 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+// Modified by Maxime Sinclair
+public class NullOutputStream extends OutputStream {
+
+ /**
+ * Writes to nowhere
+ */
+ @Override
+ public void write(int b) throws IOException {
+ // Do nothing silently
+ }
+
+ /**
+ * Overridden for performance reason
+ */
+ @Override
+ public void write(byte b[]) throws IOException {
+ // Do nothing silently
+ }
+
+ /**
+ * Overridden for performance reason
+ */
+ @Override
+ public void write(byte b[], int off, int len) throws IOException {
+ // Do nothing silently
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/Option.java b/src/net/sourceforge/plantuml/Option.java
new file mode 100644
index 0000000..8400b7c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/Option.java
@@ -0,0 +1,416 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.preproc.Defines;
+
+public class Option {
+
+ private final List<String> excludes = new ArrayList<String>();
+ private final List<String> config = new ArrayList<String>();
+ private final Map<String, String> defines = new LinkedHashMap<String, String>();
+ private String charset;
+ private boolean computeurl = false;
+ private boolean decodeurl = false;
+ private boolean pipe = false;
+ private boolean syntax = false;
+ private boolean checkOnly = false;
+ private boolean failfast = false;
+ private boolean failfast2 = false;
+ private boolean pattern = false;
+ private boolean duration = false;
+ private int nbThreads = 0;
+ private int ftpPort = -1;
+
+ private File outputDir = null;
+ private File outputFile = null;
+
+ private final List<String> result = new ArrayList<String>();
+
+ public Option() {
+ }
+
+ private FileFormat fileFormat = FileFormat.PNG;
+
+ public FileFormat getFileFormat() {
+ return fileFormat;
+ }
+
+ public void setFileFormat(FileFormat fileFormat) {
+ this.fileFormat = fileFormat;
+ }
+
+ public Option(String... arg) throws InterruptedException, IOException {
+ if (arg.length == 0) {
+ OptionFlags.getInstance().setGui(true);
+ }
+ for (int i = 0; i < arg.length; i++) {
+ String s = arg[i];
+ if (s.equalsIgnoreCase("-tsvg") || s.equalsIgnoreCase("-svg")) {
+ setFileFormat(FileFormat.SVG);
+ } else if (s.equalsIgnoreCase("-thtml") || s.equalsIgnoreCase("-html")) {
+ setFileFormat(FileFormat.HTML);
+ } else if (s.equalsIgnoreCase("-txmi") || s.equalsIgnoreCase("-xmi")) {
+ setFileFormat(FileFormat.XMI_STANDARD);
+ } else if (s.equalsIgnoreCase("-txmi:argo") || s.equalsIgnoreCase("-xmi:argo")) {
+ setFileFormat(FileFormat.XMI_ARGO);
+ } else if (s.equalsIgnoreCase("-txmi:star") || s.equalsIgnoreCase("-xmi:star")) {
+ setFileFormat(FileFormat.XMI_STAR);
+ } else if (s.equalsIgnoreCase("-teps") || s.equalsIgnoreCase("-eps")) {
+ setFileFormat(FileFormat.EPS);
+ } else if (s.equalsIgnoreCase("-teps:text") || s.equalsIgnoreCase("-eps:text")) {
+ setFileFormat(FileFormat.EPS_TEXT);
+ } else if (s.equalsIgnoreCase("-ttxt") || s.equalsIgnoreCase("-txt")) {
+ setFileFormat(FileFormat.ATXT);
+ } else if (s.equalsIgnoreCase("-tutxt") || s.equalsIgnoreCase("-utxt")) {
+ setFileFormat(FileFormat.UTXT);
+ } else if (s.equalsIgnoreCase("-png") || s.equalsIgnoreCase("-tpng")) {
+ setFileFormat(FileFormat.PNG);
+ } else if (s.equalsIgnoreCase("-vdx") || s.equalsIgnoreCase("-tvdx")) {
+ setFileFormat(FileFormat.VDX);
+ } else if (s.equalsIgnoreCase("-latex") || s.equalsIgnoreCase("-tlatex")) {
+ setFileFormat(FileFormat.LATEX);
+ } else if (s.equalsIgnoreCase("-base64") || s.equalsIgnoreCase("-tbase64")) {
+ setFileFormat(FileFormat.BASE64);
+ } else if (s.equalsIgnoreCase("-pdf") || s.equalsIgnoreCase("-tpdf")) {
+ setFileFormat(FileFormat.PDF);
+ } else if (s.equalsIgnoreCase("-overwrite")) {
+ OptionFlags.getInstance().setOverwrite(true);
+ } else if (s.equalsIgnoreCase("-output") || s.equalsIgnoreCase("-o")) {
+ i++;
+ if (i == arg.length) {
+ continue;
+ }
+ outputDir = new File(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i]));
+ } else if (s.equalsIgnoreCase("-ofile")) {
+ i++;
+ if (i == arg.length) {
+ continue;
+ }
+ outputFile = new File(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i]));
+ } else if (s.equalsIgnoreCase("-graphvizdot") || s.equalsIgnoreCase("-graphviz_dot")) {
+ i++;
+ if (i == arg.length) {
+ continue;
+ }
+ OptionFlags.getInstance().setDotExecutable(
+ StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i]));
+ } else if (s.equalsIgnoreCase("-charset")) {
+ i++;
+ if (i == arg.length) {
+ continue;
+ }
+ charset = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i]);
+ } else if (s.startsWith("-o") && s.length() > 3) {
+ s = s.substring(2);
+ outputDir = new File(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(s));
+ } else if (s.equalsIgnoreCase("-recurse") || s.equalsIgnoreCase("-r")) {
+ // recurse = true;
+ } else if (s.equalsIgnoreCase("-exclude") || s.equalsIgnoreCase("-x")) {
+ i++;
+ if (i == arg.length) {
+ continue;
+ }
+ excludes.add(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i]));
+ } else if (s.equalsIgnoreCase("-nbthread") || s.equalsIgnoreCase("-nbthreads")) {
+ i++;
+ if (i == arg.length) {
+ continue;
+ }
+ final String nb = arg[i];
+ if ("auto".equalsIgnoreCase(nb)) {
+ this.nbThreads = defaultNbThreads();
+ } else if (nb.matches("\\d+")) {
+ this.nbThreads = Integer.parseInt(nb);
+ }
+ } else if (s.equalsIgnoreCase("-failfast")) {
+ this.failfast = true;
+ } else if (s.equalsIgnoreCase("-failfast2")) {
+ this.failfast2 = true;
+ } else if (s.equalsIgnoreCase("-checkonly")) {
+ this.checkOnly = true;
+ } else if (s.equalsIgnoreCase("-config")) {
+ i++;
+ if (i == arg.length) {
+ continue;
+ }
+ initConfig(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i]));
+ } else if (s.equalsIgnoreCase("-computeurl") || s.equalsIgnoreCase("-encodeurl")) {
+ this.computeurl = true;
+ } else if (s.startsWith("-x")) {
+ s = s.substring(2);
+ excludes.add(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(s));
+ } else if (s.equalsIgnoreCase("-verbose") || s.equalsIgnoreCase("-v")) {
+ OptionFlags.getInstance().setVerbose(true);
+ } else if (s.equalsIgnoreCase("-pipe") || s.equalsIgnoreCase("-p")) {
+ pipe = true;
+ } else if (s.equalsIgnoreCase("-pattern")) {
+ pattern = true;
+ } else if (s.equalsIgnoreCase("-syntax")) {
+ syntax = true;
+ OptionFlags.getInstance().setQuiet(true);
+ } else if (s.equalsIgnoreCase("-duration")) {
+ duration = true;
+ } else if (s.equalsIgnoreCase("-keepfiles") || s.equalsIgnoreCase("-keepfile")) {
+ OptionFlags.getInstance().setKeepTmpFiles(true);
+ } else if (s.equalsIgnoreCase("-metadata")) {
+ OptionFlags.getInstance().setMetadata(true);
+ } else if (s.equalsIgnoreCase("-logdata")) {
+ i++;
+ if (i == arg.length) {
+ continue;
+ }
+ OptionFlags.getInstance().setLogData(
+ new File(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg[i])));
+ } else if (s.equalsIgnoreCase("-word")) {
+ OptionFlags.getInstance().setWord(true);
+ OptionFlags.getInstance().setQuiet(true);
+ } else if (s.equalsIgnoreCase("-quiet")) {
+ OptionFlags.getInstance().setQuiet(true);
+ } else if (s.equalsIgnoreCase("-decodeurl")) {
+ this.decodeurl = true;
+ } else if (s.equalsIgnoreCase("-version")) {
+ OptionPrint.printVersion();
+ } else if (s.matches("(?i)^-li[sc][ea]n[sc]e\\s*$")) {
+ OptionPrint.printLicense();
+ } else if (s.equalsIgnoreCase("-checkversion")) {
+ OptionPrint.checkVersion();
+ } else if (s.startsWith("-D")) {
+ manageDefine(s.substring(2));
+ } else if (s.startsWith("-S")) {
+ manageSkinParam(s.substring(2));
+ } else if (s.equalsIgnoreCase("-testdot")) {
+ OptionPrint.printTestDot();
+ } else if (s.equalsIgnoreCase("-about") || s.equalsIgnoreCase("-author") || s.equalsIgnoreCase("-authors")) {
+ OptionPrint.printAbout();
+ } else if (s.equalsIgnoreCase("-help") || s.equalsIgnoreCase("-h") || s.equalsIgnoreCase("-?")) {
+ OptionPrint.printHelp();
+ } else if (s.equalsIgnoreCase("-language")) {
+ OptionPrint.printLanguage();
+ } else if (s.equalsIgnoreCase("-gui")) {
+ OptionFlags.getInstance().setGui(true);
+ } else if (s.equalsIgnoreCase("-encodesprite")) {
+ OptionFlags.getInstance().setEncodesprite(true);
+ } else if (s.equalsIgnoreCase("-nosuggestengine")) {
+ OptionFlags.getInstance().setUseSuggestEngine(false);
+ } else if (s.equalsIgnoreCase("-printfonts")) {
+ OptionFlags.getInstance().setPrintFonts(true);
+ } else if (StringUtils.goLowerCase(s).startsWith("-ftp")) {
+ final int x = s.indexOf(':');
+ if (x == -1) {
+ this.ftpPort = 4242;
+ } else {
+ this.ftpPort = Integer.parseInt(s.substring(x + 1));
+ }
+ } else if (s.startsWith("-c")) {
+ s = s.substring(2);
+ config.add(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(s));
+ } else {
+ result.add(s);
+ }
+ }
+ }
+
+ public int getFtpPort() {
+ return ftpPort;
+ }
+
+ public void initConfig(String filename) throws IOException {
+ BufferedReader br = null;
+ try {
+ br = new BufferedReader(new FileReader(filename));
+ String s = null;
+ while ((s = br.readLine()) != null) {
+ config.add(s);
+ }
+ } finally {
+ if (br != null) {
+ br.close();
+ }
+ }
+ }
+
+ private void manageDefine(String s) {
+ final Pattern p = MyPattern.cmpile("^(\\w+)(?:=(.*))?$");
+ final Matcher m = p.matcher(s);
+ if (m.find()) {
+ define(m.group(1), m.group(2));
+ }
+ }
+
+ private void manageSkinParam(String s) {
+ final Pattern p = MyPattern.cmpile("^(\\w+)(?:=(.*))?$");
+ final Matcher m = p.matcher(s);
+ if (m.find()) {
+ skinParam(m.group(1), m.group(2));
+ }
+ }
+
+ private void skinParam(String var, String value) {
+ if (var != null && value != null) {
+ config.add("skinparamlocked " + var + " " + value);
+ }
+
+ }
+
+ public final File getOutputDir() {
+ return outputDir;
+ }
+
+ public final static String getPattern() {
+ return "(?i)^.*\\.(txt|tex|java|htm|html|c|h|cpp|apt|pu)$";
+ }
+
+ public void setOutputDir(File f) {
+ outputDir = f;
+ }
+
+ public final List<String> getExcludes() {
+ return Collections.unmodifiableList(excludes);
+ }
+
+ public Defines getDefaultDefines() {
+ final Defines result = new Defines();
+ for (Map.Entry<String, String> ent : defines.entrySet()) {
+ result.define(ent.getKey(), Arrays.asList(ent.getValue()));
+
+ }
+ return result;
+ }
+
+ public void define(String name, String value) {
+ defines.put(name, value);
+ }
+
+ public List<String> getConfig() {
+ return Collections.unmodifiableList(config);
+ }
+
+ public final List<String> getResult() {
+ return Collections.unmodifiableList(result);
+ }
+
+ public final String getCharset() {
+ return charset;
+ }
+
+ public void setCharset(String s) {
+ this.charset = s;
+
+ }
+
+ public final boolean isComputeurl() {
+ return computeurl;
+ }
+
+ public final boolean isDecodeurl() {
+ return decodeurl;
+ }
+
+ public final boolean isPipe() {
+ return pipe;
+ }
+
+ public final boolean isSyntax() {
+ return syntax;
+ }
+
+ public final boolean isPattern() {
+ return pattern;
+ }
+
+ public FileFormatOption getFileFormatOption() {
+ return new FileFormatOption(getFileFormat());
+ }
+
+ public final boolean isDuration() {
+ return duration;
+ }
+
+ public final int getNbThreads() {
+ return nbThreads;
+ }
+
+ public final void setNbThreads(int nb) {
+ this.nbThreads = nb;
+ }
+
+ public static int defaultNbThreads() {
+ return Runtime.getRuntime().availableProcessors();
+ }
+
+ public final boolean isCheckOnly() {
+ return checkOnly;
+ }
+
+ public final void setCheckOnly(boolean checkOnly) {
+ this.checkOnly = checkOnly;
+ }
+
+ public final boolean isFailfastOrFailfast2() {
+ return failfast || failfast2;
+ }
+
+ public final boolean isFailfast2() {
+ return failfast2;
+ }
+
+ public final void setFailfast(boolean failfast) {
+ this.failfast = failfast;
+ }
+
+ public final void setFailfast2(boolean failfast2) {
+ this.failfast2 = failfast2;
+ }
+
+ public final File getOutputFile() {
+ return outputFile;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/OptionFlags.java b/src/net/sourceforge/plantuml/OptionFlags.java
new file mode 100644
index 0000000..8ccb342
--- /dev/null
+++ b/src/net/sourceforge/plantuml/OptionFlags.java
@@ -0,0 +1,291 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.PrintStream;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import net.sourceforge.plantuml.core.Diagram;
+import net.sourceforge.plantuml.cucadiagram.dot.GraphvizUtils;
+
+public class OptionFlags {
+
+ // static public final boolean PBBACK = false;
+ // static public boolean GRAPHVIZCACHE = false;
+ static public final boolean TRACE_DOT = false;
+
+ static public boolean ALLOW_INCLUDE = true;
+
+ static public final boolean USE_HECTOR = false;
+ static public boolean ADD_NICE_FOR_DOT = false;
+ static public final boolean STRICT_SELFMESSAGE_POSITION = true;
+ static public final boolean FORCE_TEOZ = false;
+ static public final boolean USE_INTERFACE_EYE1 = false;
+ static public final boolean USE_INTERFACE_EYE2 = false;
+ static public final boolean SWI2 = false;
+
+ public void reset() {
+ reset(false);
+ }
+
+ private void reset(boolean exit) {
+ keepTmpFiles = false;
+ verbose = false;
+ metadata = false;
+ word = false;
+ systemExit = exit;
+ dotExecutable = null;
+ gui = false;
+ quiet = false;
+ checkDotError = false;
+ printFonts = false;
+ useSuggestEngine = true;
+ // failOnError = false;
+ encodesprite = false;
+ // PIC_LINE = false;
+ }
+
+ public boolean useJavaInsteadOfDot() {
+ return false;
+ }
+
+ private static final OptionFlags singleton = new OptionFlags();
+
+ private boolean keepTmpFiles;
+ private boolean verbose;
+ private boolean metadata;
+ private boolean word;
+ private boolean systemExit;
+ private String dotExecutable;
+ private boolean gui;
+ private boolean quiet;
+ private boolean checkDotError;
+ private boolean printFonts;
+ private boolean useSuggestEngine;
+ // private boolean failOnError;
+ private boolean encodesprite;
+ private boolean overwrite;
+ private File logData;
+
+ private OptionFlags() {
+ reset(true);
+ }
+
+ public static OptionFlags getInstance() {
+ return singleton;
+ }
+
+ public synchronized final boolean isKeepTmpFiles() {
+ return keepTmpFiles;
+ }
+
+ public synchronized final void setKeepTmpFiles(boolean keepTmpFiles) {
+ this.keepTmpFiles = keepTmpFiles;
+ }
+
+ public final boolean isVerbose() {
+ return verbose;
+ }
+
+ public final void setVerbose(boolean verbose) {
+ this.verbose = verbose;
+ }
+
+ public final boolean isMetadata() {
+ return metadata;
+ }
+
+ public final void setMetadata(boolean metadata) {
+ this.metadata = metadata;
+ }
+
+ public final boolean isWord() {
+ return word;
+ }
+
+ public final void setWord(boolean word) {
+ this.word = word;
+ }
+
+ public final boolean isSystemExit() {
+ return systemExit;
+ }
+
+ public final void setSystemExit(boolean systemExit) {
+ this.systemExit = systemExit;
+ }
+
+ public final String getDotExecutable() {
+ return dotExecutable;
+ }
+
+ public final void setDotExecutable(String dotExecutable) {
+ this.dotExecutable = dotExecutable;
+ }
+
+ public final boolean isGui() {
+ return gui;
+ }
+
+ public final void setGui(boolean gui) {
+ this.gui = gui;
+ }
+
+ public final boolean isQuiet() {
+ return quiet;
+ }
+
+ public final void setQuiet(boolean quiet) {
+ this.quiet = quiet;
+ }
+
+ public final boolean isCheckDotError() {
+ return checkDotError;
+ }
+
+ public final void setCheckDotError(boolean checkDotError) {
+ this.checkDotError = checkDotError;
+ }
+
+ private final AtomicBoolean logDataInitized = new AtomicBoolean(false);
+
+ public void logData(File file, Diagram system) {
+ final String warnOrError = system.getWarningOrError();
+ if (warnOrError == null) {
+ return;
+ }
+ synchronized (logDataInitized) {
+ if (logData == null && logDataInitized.get() == false) {
+ final String s = GraphvizUtils.getenvLogData();
+ if (s != null) {
+ setLogData(new File(s));
+ }
+ logDataInitized.set(true);
+ }
+
+ if (logData == null) {
+ return;
+ }
+ // final PSystemError systemError = (PSystemError) system;
+ PrintStream ps = null;
+ try {
+ ps = new PrintStream(new FileOutputStream(logData, true));
+ ps.println("Start of " + file.getName());
+ ps.println(warnOrError);
+ ps.println("End of " + file.getName());
+ ps.println();
+ } catch (FileNotFoundException e) {
+ Log.error("Cannot open " + logData);
+ e.printStackTrace();
+ } finally {
+ if (ps != null) {
+ ps.close();
+ }
+ }
+ }
+ }
+
+ // public static void logErrorFile(final PSystemError systemError, PrintStream ps) {
+ // ps.println(systemError.getDescription());
+ // for (CharSequence t : systemError.getTitle()) {
+ // ps.println(t);
+ // }
+ // systemError.print(ps);
+ // for (String s : systemError.getSuggest()) {
+ // ps.println(s);
+ // }
+ // }
+
+ public final void setLogData(File logData) {
+ this.logData = logData;
+ logData.delete();
+ PrintStream ps = null;
+ try {
+ ps = new PrintStream(new FileOutputStream(logData));
+ ps.println();
+ } catch (FileNotFoundException e) {
+ Log.error("Cannot open " + logData);
+ e.printStackTrace();
+ } finally {
+ if (ps != null) {
+ ps.close();
+ }
+ }
+ }
+
+ public final boolean isPrintFonts() {
+ return printFonts;
+ }
+
+ public final void setPrintFonts(boolean printFonts) {
+ this.printFonts = printFonts;
+ }
+
+ public final boolean isUseSuggestEngine() {
+ return useSuggestEngine;
+ }
+
+ public final void setUseSuggestEngine(boolean useSuggestEngine) {
+ this.useSuggestEngine = useSuggestEngine;
+ }
+
+ // public final boolean isFailOnError() {
+ // return failOnError;
+ // }
+ //
+ // public final void setFailOnError(boolean failOnError) {
+ // this.failOnError = failOnError;
+ // }
+
+ public final boolean isEncodesprite() {
+ return encodesprite;
+ }
+
+ public final void setEncodesprite(boolean encodesprite) {
+ this.encodesprite = encodesprite;
+ }
+
+ public final boolean isOverwrite() {
+ return overwrite;
+ }
+
+ public final void setOverwrite(boolean overwrite) {
+ this.overwrite = overwrite;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/OptionPrint.java b/src/net/sourceforge/plantuml/OptionPrint.java
new file mode 100644
index 0000000..61b65b2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/OptionPrint.java
@@ -0,0 +1,199 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import java.io.File;
+import java.nio.charset.Charset;
+import java.util.Date;
+import java.util.Properties;
+
+import net.sourceforge.plantuml.cucadiagram.dot.GraphvizUtils;
+import net.sourceforge.plantuml.syntax.LanguageDescriptor;
+import net.sourceforge.plantuml.version.License;
+import net.sourceforge.plantuml.version.PSystemVersion;
+import net.sourceforge.plantuml.version.Version;
+
+public class OptionPrint {
+
+ static public void printTestDot() throws InterruptedException {
+ for (String s : GraphvizUtils.getTestDotStrings(false)) {
+ System.out.println(s);
+ }
+ exit();
+ }
+
+ static public void printHelp() throws InterruptedException {
+
+ final String charset = Charset.defaultCharset().displayName();
+
+ System.out.println("Usage: java -jar plantuml.jar [options] -gui");
+ System.out.println("\t(to execute the GUI)");
+ System.out.println(" or java -jar plantuml.jar [options] [file/dir] [file/dir] [file/dir]");
+ System.out.println("\t(to process files or directories)");
+ System.out.println();
+ System.out.println("You can use the following wildcards in files/dirs:");
+ System.out.println("\t*\tmeans any characters but '" + File.separator + "'");
+ System.out.println("\t?\tone and only one character but '" + File.separator + "'");
+ System.out.println("\t**\tmeans any characters (used to recurse through directories)");
+ System.out.println();
+ System.out.println("where options include:");
+ System.out.println(" -gui\t\tTo run the graphical user interface");
+ System.out.println(" -tpng\t\tTo generate images using PNG format (default)");
+ System.out.println(" -tsvg\t\tTo generate images using SVG format");
+ System.out.println(" -teps\t\tTo generate images using EPS format");
+ System.out.println(" -tpdf\t\tTo generate images using PDF format");
+ System.out.println(" -tvdx\t\tTo generate images using VDX format");
+ System.out.println(" -txmi\t\tTo generate XMI file for class diagram");
+ System.out.println(" -thtml\t\tTo generate HTML files for class diagram");
+ System.out.println(" -ttxt\t\tTo generate images with ASCII art");
+ System.out.println(" -tutxt\t\tTo generate images with ASCII art using Unicode characters");
+ System.out.println(" -o[utput] \"dir\"\tTo generate images in the specified directory");
+ System.out.println(" -DVAR1=value\tTo set a preprocessing variable as if '!define VAR1 value' were used");
+ System.out.println(" -Sparam1=value\tTo set a skin parameter as if 'skinparam param1 value' were used");
+ System.out.println(" -r[ecurse]\t\trecurse through directories");
+ System.out.println(" -config \"file\"\tTo read the provided config file before each diagram");
+ System.out.println(" -charset xxx\tTo use a specific charset (default is " + charset + ")");
+ System.out.println(" -e[x]clude pattern\tTo exclude files that match the provided pattern");
+ System.out.println(" -metadata\t\tTo retrieve PlantUML sources from PNG images");
+ System.out.println(" -version\t\tTo display information about PlantUML and Java versions");
+ System.out.println(" -checkversion\tTo check if a newer version is available for download");
+ System.out.println(" -v[erbose]\t\tTo have log information");
+ System.out.println(" -quiet\t\tTo NOT print error message into the console");
+ // Log.println(" -forcegd\t\tTo force dot to use GD PNG library");
+ // Log.println(" -forcecairo\t\tTo force dot to use Cairo PNG library");
+ System.out.println(" -keepfiles\t\tTo NOT delete temporary files after process");
+ System.out.println(" -h[elp]\t\tTo display this help message");
+ System.out.println(" -testdot\t\tTo test the installation of graphviz");
+ System.out.println(" -graphvizdot \"exe\"\tTo specify dot executable");
+ System.out.println(" -p[ipe]\t\tTo use stdin for PlantUML source and stdout for PNG/SVG/EPS generation");
+ System.out.println(" -encodesprite 4|8|16[z] \"file\"\tTo encode a sprite at gray level (z for compression) from an image");
+ System.out.println(" -computeurl|-encodeurl\tTo compute the encoded URL of a PlantUML source file");
+ System.out.println(" -decodeurl\t\tTo retrieve the PlantUML source from an encoded URL");
+ System.out.println(" -syntax\t\tTo report any syntax error from standard input without generating images");
+ System.out.println(" -language\t\tTo print the list of PlantUML keywords");
+ System.out.println(" -nosuggestengine\tTo disable the suggest engine when errors in diagrams");
+ System.out.println(" -checkonly\t\tTo check the syntax of files without generating images");
+ System.out.println(" -failfast\t\tTo stop processing as soon as a syntax error in diagram occurs");
+ System.out.println(" -failfast2\t\tTo do a first syntax check before processing files, to fail even faster");
+ System.out.println(" -pattern\t\tTo print the list of Regular Expression used by PlantUML");
+ System.out.println(" -duration\t\tTo print the duration of complete diagrams processing");
+ System.out.println(" -nbthread N\t\tTo use (N) threads for processing");
+ System.out.println(" -nbthread auto\tTo use " + Option.defaultNbThreads() + " threads for processing");
+ System.out.println(" -author[s]\t\tTo print information about PlantUML authors");
+ System.out.println(" -overwrite\t\tTo allow to overwrite read only files");
+ System.out.println(" -printfonts\t\tTo print fonts available on your system");
+ System.out.println();
+ System.out.println("If needed, you can setup the environment variable GRAPHVIZ_DOT.");
+ exit();
+ }
+
+ static private void exit() throws InterruptedException {
+ if (OptionFlags.getInstance().isSystemExit()) {
+ System.exit(0);
+ }
+ throw new InterruptedException("exit");
+ }
+
+ public static void printLicense() throws InterruptedException {
+ for (String s : License.getCurrent().getText()) {
+ System.out.println(s);
+ }
+ exit();
+ }
+
+ public static void printVersion() throws InterruptedException {
+ System.out
+ .println("PlantUML version " + Version.versionString() + " (" + Version.compileTimeString() + ")");
+ System.out.println("(" + License.getCurrent() + " source distribution)");
+ final Properties p = System.getProperties();
+ System.out.println(p.getProperty("java.runtime.name"));
+ System.out.println(p.getProperty("java.vm.name"));
+ System.out.println(p.getProperty("java.runtime.version"));
+ System.out.println(p.getProperty("os.name"));
+ System.out.println();
+ for (String s : GraphvizUtils.getTestDotStrings(false)) {
+ System.out.println(s);
+ }
+ exit();
+ }
+
+ public static void checkVersion() throws InterruptedException {
+ System.out
+ .println("PlantUML version " + Version.versionString() + " (" + Version.compileTimeString() + ")");
+ System.out.println();
+ final int lastversion = PSystemVersion.extractDownloadableVersion(null, null);
+ if (lastversion == -1) {
+ System.out.println("Error");
+ System.out.println("Cannot connect to http://plantuml.sourceforge.net/");
+ System.out.println("Maybe you should set your proxy ?");
+ } else if (lastversion == 0) {
+ System.out.println("Error");
+ System.out.println("Cannot retrieve last version from http://plantuml.sourceforge.net/");
+ } else {
+ System.out.println("Last available version for download : " + lastversion);
+ System.out.println();
+ if (Version.version() >= lastversion) {
+ System.out.println("Your version is up to date.");
+ } else {
+ System.out.println("A newer version is available for download.");
+ }
+ }
+
+ exit();
+ }
+
+ public static void printAbout() throws InterruptedException {
+ // Duplicate in PSystemVersion
+ System.out
+ .println("PlantUML version " + Version.versionString() + " (" + Version.compileTimeString() + ")");
+ System.out.println();
+ System.out.println("Original idea: Arnaud Roques");
+ System.out.println("Word Macro: Alain Bertucat & Matthieu Sabatier");
+ System.out.println("Word Add-in: Adriaan van den Brand");
+ System.out.println("Eclipse Plugin: Claude Durif & Anne Pecoil");
+ System.out.println("Servlet & XWiki: Maxime Sinclair");
+ System.out.println("Site design: Raphael Cotisson");
+ System.out.println("Logo: Benjamin Croizet");
+ System.out.println();
+ System.out.println("http://plantuml.sourceforge.net");
+ exit();
+ }
+
+ public static void printLanguage() throws InterruptedException {
+ new LanguageDescriptor().print(System.out);
+ exit();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/PSystemBuilder.java b/src/net/sourceforge/plantuml/PSystemBuilder.java
new file mode 100644
index 0000000..366393d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/PSystemBuilder.java
@@ -0,0 +1,168 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import net.sourceforge.plantuml.activitydiagram.ActivityDiagramFactory;
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagramFactory3;
+import net.sourceforge.plantuml.api.PSystemFactory;
+import net.sourceforge.plantuml.classdiagram.ClassDiagramFactory;
+import net.sourceforge.plantuml.compositediagram.CompositeDiagramFactory;
+import net.sourceforge.plantuml.core.Diagram;
+import net.sourceforge.plantuml.core.DiagramType;
+import net.sourceforge.plantuml.core.UmlSource;
+import net.sourceforge.plantuml.creole.PSystemCreoleFactory;
+import net.sourceforge.plantuml.cute.PSystemCuteFactory;
+import net.sourceforge.plantuml.descdiagram.DescriptionDiagramFactory;
+import net.sourceforge.plantuml.directdot.PSystemDotFactory;
+import net.sourceforge.plantuml.donors.PSystemDonorsFactory;
+import net.sourceforge.plantuml.eggs.PSystemAppleTwoFactory;
+import net.sourceforge.plantuml.eggs.PSystemCharlieFactory;
+import net.sourceforge.plantuml.eggs.PSystemEggFactory;
+import net.sourceforge.plantuml.eggs.PSystemLostFactory;
+import net.sourceforge.plantuml.eggs.PSystemPathFactory;
+import net.sourceforge.plantuml.eggs.PSystemRIPFactory;
+import net.sourceforge.plantuml.flowdiagram.FlowDiagramFactory;
+import net.sourceforge.plantuml.font.PSystemListFontsFactory;
+import net.sourceforge.plantuml.jungle.PSystemTreeFactory;
+import net.sourceforge.plantuml.objectdiagram.ObjectDiagramFactory;
+import net.sourceforge.plantuml.openiconic.PSystemListOpenIconicFactory;
+import net.sourceforge.plantuml.openiconic.PSystemOpenIconicFactory;
+import net.sourceforge.plantuml.oregon.PSystemOregonFactory;
+import net.sourceforge.plantuml.postit.PostIdDiagramFactory;
+import net.sourceforge.plantuml.printskin.PrintSkinFactory;
+import net.sourceforge.plantuml.project2.PSystemProjectFactory2;
+import net.sourceforge.plantuml.salt.PSystemSaltFactory;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagramFactory;
+import net.sourceforge.plantuml.statediagram.StateDiagramFactory;
+import net.sourceforge.plantuml.version.License;
+import net.sourceforge.plantuml.version.PSystemLicenseFactory;
+import net.sourceforge.plantuml.version.PSystemVersionFactory;
+
+public class PSystemBuilder {
+
+ public static final long startTime = System.currentTimeMillis();
+
+ final public Diagram createPSystem(final List<? extends CharSequence> strings) {
+
+ final List<PSystemFactory> factories = getAllFactories();
+
+ final DiagramType type = DiagramType.getTypeFromArobaseStart(strings.get(0).toString());
+
+ final UmlSource umlSource = new UmlSource(strings, type == DiagramType.UML);
+ final DiagramType diagramType = umlSource.getDiagramType();
+ final List<PSystemError> errors = new ArrayList<PSystemError>();
+ for (PSystemFactory systemFactory : factories) {
+ if (diagramType != systemFactory.getDiagramType()) {
+ continue;
+ }
+ final Diagram sys = systemFactory.createSystem(umlSource);
+ if (isOk(sys)) {
+ return sys;
+ }
+ errors.add((PSystemError) sys);
+ }
+
+ final PSystemError err = merge(errors);
+ // if (OptionFlags.getInstance().isQuiet() == false) {
+ // err.print(System.err);
+ // }
+ return err;
+
+ }
+
+ private List<PSystemFactory> getAllFactories() {
+ final List<PSystemFactory> factories = new ArrayList<PSystemFactory>();
+ factories.add(new SequenceDiagramFactory());
+ factories.add(new ClassDiagramFactory());
+ factories.add(new ActivityDiagramFactory());
+ factories.add(new DescriptionDiagramFactory());
+ factories.add(new StateDiagramFactory());
+ factories.add(new ActivityDiagramFactory3());
+ factories.add(new CompositeDiagramFactory());
+ factories.add(new ObjectDiagramFactory());
+ factories.add(new PostIdDiagramFactory());
+ factories.add(new PrintSkinFactory());
+ factories.add(new PSystemLicenseFactory());
+ factories.add(new PSystemVersionFactory());
+ factories.add(new PSystemDonorsFactory());
+ factories.add(new PSystemListFontsFactory());
+ factories.add(new PSystemOpenIconicFactory());
+ factories.add(new PSystemListOpenIconicFactory());
+ factories.add(new PSystemSaltFactory(DiagramType.SALT));
+ factories.add(new PSystemSaltFactory(DiagramType.UML));
+ factories.add(new PSystemDotFactory(DiagramType.DOT));
+ factories.add(new PSystemDotFactory(DiagramType.UML));
+ factories.add(new PSystemCreoleFactory());
+ factories.add(new PSystemEggFactory());
+ factories.add(new PSystemAppleTwoFactory());
+ factories.add(new PSystemRIPFactory());
+ factories.add(new PSystemLostFactory());
+ factories.add(new PSystemPathFactory());
+ factories.add(new PSystemOregonFactory());
+ factories.add(new PSystemCharlieFactory());
+ factories.add(new PSystemProjectFactory2());
+ factories.add(new FlowDiagramFactory());
+ factories.add(new PSystemTreeFactory(DiagramType.JUNGLE));
+ factories.add(new PSystemCuteFactory(DiagramType.CUTE));
+ return factories;
+ }
+
+ private PSystemError merge(Collection<PSystemError> ps) {
+ UmlSource source = null;
+ final List<ErrorUml> errors = new ArrayList<ErrorUml>();
+ for (PSystemError system : ps) {
+ if (system.getSource() != null && source == null) {
+ source = system.getSource();
+ }
+ errors.addAll(system.getErrorsUml());
+ }
+ if (source == null) {
+ throw new IllegalStateException();
+ }
+ return new PSystemError(source, errors);
+ }
+
+ private boolean isOk(Diagram ps) {
+ if (ps == null || ps instanceof PSystemError) {
+ return false;
+ }
+ return true;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/PSystemError.java b/src/net/sourceforge/plantuml/PSystemError.java
new file mode 100644
index 0000000..694ed2e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/PSystemError.java
@@ -0,0 +1,298 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.List;
+
+import net.sourceforge.plantuml.api.ImageDataSimple;
+import net.sourceforge.plantuml.asciiart.UmlCharArea;
+import net.sourceforge.plantuml.core.DiagramDescription;
+import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.core.UmlSource;
+import net.sourceforge.plantuml.graphic.GraphicStrings;
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+import net.sourceforge.plantuml.ugraphic.ImageBuilder;
+import net.sourceforge.plantuml.ugraphic.txt.UGraphicTxt;
+
+public class PSystemError extends AbstractPSystem {
+
+ private String getSuggestColor(boolean useRed) {
+ if (useRed) {
+ return "black";
+ }
+ return "white";
+ }
+
+ private String getRed(boolean useRed) {
+ if (useRed) {
+ return "#CD0A0A";
+ }
+ return "red";
+ }
+
+ private final int higherErrorPosition;
+ private final List<ErrorUml> printedErrors;
+
+ public PSystemError(UmlSource source, List<ErrorUml> all) {
+ this.setSource(source);
+
+ final int higherErrorPositionExecution = getHigherErrorPosition(ErrorUmlType.EXECUTION_ERROR, all);
+ final int higherErrorPositionSyntax = getHigherErrorPosition(ErrorUmlType.SYNTAX_ERROR, all);
+
+ if (higherErrorPositionExecution == Integer.MIN_VALUE && higherErrorPositionSyntax == Integer.MIN_VALUE) {
+ throw new IllegalStateException();
+ }
+
+ if (higherErrorPositionExecution >= higherErrorPositionSyntax) {
+ higherErrorPosition = higherErrorPositionExecution;
+ printedErrors = getErrorsAt(higherErrorPositionExecution, ErrorUmlType.EXECUTION_ERROR, all);
+ } else {
+ assert higherErrorPositionSyntax > higherErrorPositionExecution;
+ higherErrorPosition = higherErrorPositionSyntax;
+ printedErrors = getErrorsAt(higherErrorPositionSyntax, ErrorUmlType.SYNTAX_ERROR, all);
+ }
+
+ }
+
+ public PSystemError(UmlSource source, ErrorUml singleError) {
+ this(source, Collections.singletonList(singleError));
+ }
+
+ public ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormat) throws IOException {
+ if (fileFormat.getFileFormat() == FileFormat.ATXT || fileFormat.getFileFormat() == FileFormat.UTXT) {
+ final UGraphicTxt ugt = new UGraphicTxt();
+ final UmlCharArea area = ugt.getCharArea();
+ area.drawStringsLR(getTextStrings(), 0, 0);
+ area.print(new PrintStream(os));
+ return new ImageDataSimple(1, 1);
+
+ }
+ final boolean useRed = fileFormat.isUseRedForError();
+ final GraphicStrings result = GraphicStrings.createDefault(getHtmlStrings(useRed), useRed);
+ final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(),
+ getMetadata(), null, 0, 0, null, false);
+ imageBuilder.addUDrawable(result);
+ return imageBuilder.writeImageTOBEMOVED(fileFormat.getFileFormat(), os);
+ }
+
+ private List<String> getTextStrings() {
+ final List<String> result = new ArrayList<String>();
+
+ final int limit = 4;
+ int start;
+ final int skip = higherErrorPosition - limit + 1;
+ if (skip <= 0) {
+ start = 0;
+ } else {
+ if (skip == 1) {
+ result.add("... (skipping 1 line) ...");
+ } else {
+ result.add("... (skipping " + skip + " lines) ...");
+ }
+ start = higherErrorPosition - limit + 1;
+ }
+ for (int i = start; i < higherErrorPosition; i++) {
+ result.add(getSource().getLine(i));
+ }
+ final String errorLine = getSource().getLine(higherErrorPosition);
+ final String err = StringUtils.hideComparatorCharacters(errorLine);
+ if (StringUtils.isNotEmpty(err)) {
+ result.add(err);
+ }
+ final StringBuilder underscore = new StringBuilder();
+ for (int i = 0; i < errorLine.length(); i++) {
+ underscore.append("^");
+ }
+ result.add(underscore.toString());
+ final Collection<String> textErrors = new LinkedHashSet<String>();
+ for (ErrorUml er : printedErrors) {
+ textErrors.add(er.getError());
+ }
+ for (String er : textErrors) {
+ result.add(" " + er);
+ }
+ boolean first = true;
+ for (String s : getSuggest()) {
+ if (first) {
+ result.add(" " + s);
+ } else {
+ result.add(s);
+ }
+ first = false;
+ }
+
+ return result;
+ }
+
+ private List<String> getHtmlStrings(boolean useRed) {
+ final List<String> htmlStrings = new ArrayList<String>();
+
+ final int limit = 4;
+ int start;
+ final int skip = higherErrorPosition - limit + 1;
+ if (skip <= 0) {
+ start = 0;
+ } else {
+ if (skip == 1) {
+ htmlStrings.add("... (skipping 1 line) ...");
+ } else {
+ htmlStrings.add("... (skipping " + skip + " lines) ...");
+ }
+ start = higherErrorPosition - limit + 1;
+ }
+ for (int i = start; i < higherErrorPosition; i++) {
+ htmlStrings.add(StringUtils.hideComparatorCharacters(getSource().getLine(i)));
+ }
+ final String errorLine = getSource().getLine(higherErrorPosition);
+ final String err = StringUtils.hideComparatorCharacters(errorLine);
+ if (StringUtils.isNotEmpty(err)) {
+ htmlStrings.add("<w:" + getRed(useRed) + ">" + err + "</w>");
+ }
+// final StringBuilder underscore = new StringBuilder();
+// for (int i = 0; i < errorLine.length(); i++) {
+// underscore.append("^");
+// }
+ final Collection<String> textErrors = new LinkedHashSet<String>();
+ for (ErrorUml er : printedErrors) {
+ textErrors.add(er.getError());
+ }
+ for (String er : textErrors) {
+ htmlStrings.add(" <color:" + getRed(useRed) + ">" + er + "</color>");
+ }
+ boolean first = true;
+ for (String s : getSuggest()) {
+ if (first) {
+ htmlStrings.add(" <color:" + getSuggestColor(useRed) + "><i>" + s + "</i></color>");
+ } else {
+ htmlStrings.add("<color:" + getSuggestColor(useRed) + ">" + StringUtils.hideComparatorCharacters(s)
+ + "</color>");
+ }
+ first = false;
+ }
+
+ return htmlStrings;
+ }
+
+ public List<String> getSuggest() {
+ boolean suggested = false;
+ for (ErrorUml er : printedErrors) {
+ if (er.hasSuggest()) {
+ suggested = true;
+ }
+ }
+ if (suggested == false) {
+ return Collections.emptyList();
+ }
+ final List<String> result = new ArrayList<String>();
+ result.add("Did you mean:");
+ for (ErrorUml er : printedErrors) {
+ if (er.hasSuggest()) {
+ result.add(er.getSuggest().getSuggestedLine());
+ }
+ }
+ return Collections.unmodifiableList(result);
+
+ }
+
+ private Collection<ErrorUml> getErrors(ErrorUmlType type, List<ErrorUml> all) {
+ final Collection<ErrorUml> result = new LinkedHashSet<ErrorUml>();
+ for (ErrorUml error : all) {
+ if (error.getType() == type) {
+ result.add(error);
+ }
+ }
+ return result;
+ }
+
+ private int getHigherErrorPosition(ErrorUmlType type, List<ErrorUml> all) {
+ int max = Integer.MIN_VALUE;
+ for (ErrorUml error : getErrors(type, all)) {
+ if (error.getPosition() > max) {
+ max = error.getPosition();
+ }
+ }
+ // if (max == Integer.MIN_VALUE) {
+ // throw new IllegalStateException();
+ // }
+ return max;
+ }
+
+ private List<ErrorUml> getErrorsAt(int position, ErrorUmlType type, List<ErrorUml> all) {
+ final List<ErrorUml> result = new ArrayList<ErrorUml>();
+ for (ErrorUml error : getErrors(type, all)) {
+ if (error.getPosition() == position && StringUtils.isNotEmpty(error.getError())) {
+ result.add(error);
+ }
+ }
+ return result;
+ }
+
+ public DiagramDescription getDescription() {
+ return new DiagramDescriptionImpl("(Error)", getClass());
+ }
+
+ public final int getHigherErrorPosition() {
+ return higherErrorPosition;
+ }
+
+ public final Collection<ErrorUml> getErrorsUml() {
+ return Collections.unmodifiableCollection(printedErrors);
+ }
+
+ @Override
+ public String getWarningOrError() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append(getDescription());
+ sb.append('\n');
+ for (CharSequence t : getTitle()) {
+ sb.append(t);
+ sb.append('\n');
+ }
+ sb.append('\n');
+ for (String s : getSuggest()) {
+ sb.append(s);
+ sb.append('\n');
+ }
+ return sb.toString();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/PSystemUtils.java b/src/net/sourceforge/plantuml/PSystemUtils.java
new file mode 100644
index 0000000..7d7e0fc
--- /dev/null
+++ b/src/net/sourceforge/plantuml/PSystemUtils.java
@@ -0,0 +1,231 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.core.Diagram;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
+import net.sourceforge.plantuml.html.CucaDiagramHtmlMaker;
+import net.sourceforge.plantuml.png.PngSplitter;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+
+public class PSystemUtils {
+
+ public static List<File> exportDiagrams(Diagram system, File suggestedFile, FileFormatOption fileFormatOption)
+ throws IOException {
+ if (system instanceof NewpagedDiagram) {
+ return exportDiagramsNewpaged((NewpagedDiagram) system, suggestedFile, fileFormatOption);
+ }
+ if (system instanceof SequenceDiagram) {
+ return exportDiagramsSequence((SequenceDiagram) system, suggestedFile, fileFormatOption);
+ }
+ if (system instanceof CucaDiagram) {
+ return exportDiagramsCuca((CucaDiagram) system, suggestedFile, fileFormatOption);
+ }
+ if (system instanceof ActivityDiagram3) {
+ return exportDiagramsActivityDiagram3((ActivityDiagram3) system, suggestedFile, fileFormatOption);
+ }
+ return exportDiagramsDefault(system, suggestedFile, fileFormatOption);
+ }
+
+ private static List<File> exportDiagramsNewpaged(NewpagedDiagram system, File suggestedFile,
+ FileFormatOption fileFormat) throws IOException {
+ final List<File> result = new ArrayList<File>();
+ final int nbImages = system.getNbImages();
+ for (int i = 0; i < nbImages; i++) {
+
+ final File f = fileFormat.getFileFormat().computeFilename(suggestedFile, i);
+ if (canFileBeWritten(f) == false) {
+ return result;
+ }
+ final OutputStream fos = new BufferedOutputStream(new FileOutputStream(f));
+ // ImageData cmap = null;
+ try {
+ /* cmap = */system.exportDiagram(fos, i, fileFormat);
+ } finally {
+ fos.close();
+ }
+ // if (system.hasUrl() && cmap != null && cmap.containsCMapData()) {
+ // system.exportCmap(suggestedFile, cmap);
+ // }
+ Log.info("File size : " + f.length());
+ result.add(f);
+ }
+ return result;
+ }
+
+ public static boolean canFileBeWritten(final File f) {
+ Log.info("Creating file: " + f);
+ if (f.exists() && f.canWrite() == false) {
+ if (OptionFlags.getInstance().isOverwrite()) {
+ Log.info("Overwrite " + f);
+ f.setWritable(true);
+ f.delete();
+ return true;
+ }
+ Log.error("Cannot write to file " + f);
+ return false;
+ }
+ return true;
+ }
+
+ static private List<File> exportDiagramsDefault(Diagram system, File suggestedFile, FileFormatOption fileFormat)
+ throws IOException {
+ if (suggestedFile.exists() && suggestedFile.isDirectory()) {
+ throw new IllegalArgumentException("File is a directory " + suggestedFile);
+ }
+ OutputStream os = null;
+ try {
+ if (canFileBeWritten(suggestedFile) == false) {
+ return Collections.emptyList();
+ }
+ os = new BufferedOutputStream(new FileOutputStream(suggestedFile));
+ // system.exportDiagram(os, null, 0, fileFormat);
+ system.exportDiagram(os, 0, fileFormat);
+ } finally {
+ if (os != null) {
+ os.close();
+ }
+ }
+ return Arrays.asList(suggestedFile);
+ }
+
+ static private List<File> exportDiagramsActivityDiagram3(ActivityDiagram3 system, File suggestedFile,
+ FileFormatOption fileFormat) throws IOException {
+ if (suggestedFile.exists() && suggestedFile.isDirectory()) {
+ throw new IllegalArgumentException("File is a directory " + suggestedFile);
+ }
+ OutputStream os = null;
+ ImageData cmap = null;
+ try {
+ if (canFileBeWritten(suggestedFile) == false) {
+ return Collections.emptyList();
+ }
+ os = new BufferedOutputStream(new FileOutputStream(suggestedFile));
+ cmap = system.exportDiagram(os, 0, fileFormat);
+ } finally {
+ if (os != null) {
+ os.close();
+ }
+ }
+ if (cmap != null && cmap.containsCMapData()) {
+ system.exportCmap(suggestedFile, cmap);
+ }
+ return Arrays.asList(suggestedFile);
+ }
+
+ private static List<File> exportDiagramsSequence(SequenceDiagram system, File suggestedFile,
+ FileFormatOption fileFormat) throws IOException {
+ final List<File> result = new ArrayList<File>();
+ final int nbImages = system.getNbImages();
+ for (int i = 0; i < nbImages; i++) {
+
+ final File f = fileFormat.getFileFormat().computeFilename(suggestedFile, i);
+ if (canFileBeWritten(suggestedFile) == false) {
+ return result;
+ }
+ final OutputStream fos = new BufferedOutputStream(new FileOutputStream(f));
+ ImageData cmap = null;
+ try {
+ cmap = system.exportDiagram(fos, i, fileFormat);
+ } finally {
+ fos.close();
+ }
+ if (cmap != null && cmap.containsCMapData()) {
+ system.exportCmap(suggestedFile, cmap);
+ }
+ Log.info("File size : " + f.length());
+ result.add(f);
+ }
+ return result;
+ }
+
+ static public List<File> exportDiagramsCuca(CucaDiagram system, File suggestedFile, FileFormatOption fileFormat)
+ throws IOException {
+ if (suggestedFile.exists() && suggestedFile.isDirectory()) {
+ throw new IllegalArgumentException("File is a directory " + suggestedFile);
+ }
+
+ if (fileFormat.getFileFormat() == FileFormat.HTML) {
+ return createFilesHtml(system, suggestedFile);
+ }
+
+ ImageData cmap = null;
+ OutputStream os = null;
+ try {
+ if (canFileBeWritten(suggestedFile) == false) {
+ return Collections.emptyList();
+ }
+ os = new BufferedOutputStream(new FileOutputStream(suggestedFile));
+ cmap = system.exportDiagram(os, 0, fileFormat);
+ } finally {
+ if (os != null) {
+ os.close();
+ }
+ }
+ List<File> result = Arrays.asList(suggestedFile);
+
+ if (cmap != null && cmap.containsCMapData()) {
+ system.exportCmap(suggestedFile, cmap);
+ }
+
+ if (fileFormat.getFileFormat() == FileFormat.PNG) {
+ result = new PngSplitter(suggestedFile, system.getHorizontalPages(), system.getVerticalPages(),
+ system.getMetadata(), system.getDpi(fileFormat), fileFormat.isWithMetadata()).getFiles();
+ }
+ return result;
+
+ }
+
+ private static List<File> createFilesHtml(CucaDiagram system, File suggestedFile) throws IOException {
+ final String name = suggestedFile.getName();
+ final int idx = name.lastIndexOf('.');
+ final File dir = new File(suggestedFile.getParentFile(), name.substring(0, idx));
+ final CucaDiagramHtmlMaker maker = new CucaDiagramHtmlMaker(system, dir);
+ return maker.create();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/Pragma.java b/src/net/sourceforge/plantuml/Pragma.java
new file mode 100644
index 0000000..dcd268f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/Pragma.java
@@ -0,0 +1,74 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import net.sourceforge.plantuml.StringUtils;
+
+public class Pragma {
+
+ private final Map<String, String> values = new LinkedHashMap<String, String>();
+
+ public void define(String name, String value) {
+ values.put(name, value);
+ if (name.equalsIgnoreCase("graphviz_dot")) {
+ OptionFlags.getInstance().setDotExecutable(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(value));
+ }
+ }
+
+ public boolean isDefine(String name) {
+ return values.containsKey(name);
+ }
+
+ public void undefine(String name) {
+ values.remove(name);
+ }
+
+ public String getValue(String name) {
+ return values.get(name);
+ }
+
+ public boolean horizontalLineBetweenDifferentPackageAllowed() {
+ return isDefine("horizontallinebetweendifferentpackageallowed");
+ }
+
+ public boolean useTeozLayout() {
+ final String teoz = getValue("teoz");
+ return "true".equalsIgnoreCase(teoz) || "on".equalsIgnoreCase(teoz);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/Removeable.java b/src/net/sourceforge/plantuml/Removeable.java
new file mode 100644
index 0000000..10d5339
--- /dev/null
+++ b/src/net/sourceforge/plantuml/Removeable.java
@@ -0,0 +1,41 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+public interface Removeable {
+
+ public boolean isRemoved();
+
+}
diff --git a/src/net/sourceforge/plantuml/Run.java b/src/net/sourceforge/plantuml/Run.java
new file mode 100644
index 0000000..5536ca1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/Run.java
@@ -0,0 +1,411 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import java.awt.Font;
+import java.awt.GraphicsEnvironment;
+import java.awt.image.BufferedImage;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.PrintStream;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import javax.imageio.ImageIO;
+import javax.swing.UIManager;
+
+import net.sourceforge.plantuml.activitydiagram.ActivityDiagramFactory;
+import net.sourceforge.plantuml.classdiagram.ClassDiagramFactory;
+import net.sourceforge.plantuml.code.Transcoder;
+import net.sourceforge.plantuml.code.TranscoderUtil;
+import net.sourceforge.plantuml.command.UmlDiagramFactory;
+import net.sourceforge.plantuml.core.Diagram;
+import net.sourceforge.plantuml.descdiagram.DescriptionDiagramFactory;
+import net.sourceforge.plantuml.ftp.FtpServer;
+import net.sourceforge.plantuml.objectdiagram.ObjectDiagramFactory;
+import net.sourceforge.plantuml.png.MetadataTag;
+import net.sourceforge.plantuml.preproc.Defines;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagramFactory;
+import net.sourceforge.plantuml.statediagram.StateDiagramFactory;
+import net.sourceforge.plantuml.swing.MainWindow2;
+import net.sourceforge.plantuml.ugraphic.SpriteGrayLevel;
+import net.sourceforge.plantuml.ugraphic.SpriteUtils;
+import net.sourceforge.plantuml.version.Version;
+
+public class Run {
+
+ public static void main(String[] argsArray) throws IOException, InterruptedException {
+ final long start = System.currentTimeMillis();
+ final Option option = new Option(argsArray);
+ if (OptionFlags.getInstance().isEncodesprite()) {
+ encodeSprite(option.getResult());
+ return;
+ }
+ if (OptionFlags.getInstance().isVerbose()) {
+ Log.info("PlantUML Version " + Version.versionString());
+ Log.info("GraphicsEnvironment.isHeadless() " + GraphicsEnvironment.isHeadless());
+ }
+ if (GraphicsEnvironment.isHeadless()) {
+ Log.info("Forcing -Djava.awt.headless=true");
+ System.setProperty("java.awt.headless", "true");
+ Log.info("java.awt.headless set as true");
+
+ }
+ if (OptionFlags.getInstance().isPrintFonts()) {
+ printFonts();
+ return;
+ }
+
+ if (option.getFtpPort() != -1) {
+ goFtp(option);
+ return;
+ }
+
+ boolean error = false;
+ boolean forceQuit = false;
+ if (option.isPattern()) {
+ managePattern();
+ } else if (OptionFlags.getInstance().isGui()) {
+ try {
+ UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
+ } catch (Exception e) {
+ }
+ final List<String> list = option.getResult();
+ File dir = null;
+ if (list.size() == 1) {
+ final File f = new File(list.get(0));
+ if (f.exists() && f.isDirectory()) {
+ dir = f;
+ }
+ }
+ new MainWindow2(option, dir);
+ } else if (option.isPipe() || option.isSyntax()) {
+ managePipe(option);
+ forceQuit = true;
+ } else if (option.isFailfast2()) {
+ final long start2 = System.currentTimeMillis();
+ option.setCheckOnly(true);
+ error = manageAllFiles(option);
+ option.setCheckOnly(false);
+ if (option.isDuration()) {
+ final double duration = (System.currentTimeMillis() - start2) / 1000.0;
+ Log.error("Check Duration = " + duration + " seconds");
+ }
+ if (error == false) {
+ error = manageAllFiles(option);
+ }
+ forceQuit = true;
+ } else {
+ error = manageAllFiles(option);
+ forceQuit = true;
+ }
+
+ if (option.isDuration()) {
+ final double duration = (System.currentTimeMillis() - start) / 1000.0;
+ Log.error("Duration = " + duration + " seconds");
+ }
+
+ if (error) {
+ Log.error("Some diagram description contains errors");
+ System.exit(1);
+ }
+
+ if (forceQuit && OptionFlags.getInstance().isSystemExit()) {
+ System.exit(0);
+ }
+ }
+
+ private static void encodeSprite(List<String> result) throws IOException {
+ SpriteGrayLevel level = SpriteGrayLevel.GRAY_16;
+ boolean compressed = false;
+ final File f;
+ if (result.size() > 1 && result.get(0).matches("(4|8|16)z?")) {
+ if (result.get(0).startsWith("8")) {
+ level = SpriteGrayLevel.GRAY_8;
+ }
+ if (result.get(0).startsWith("4")) {
+ level = SpriteGrayLevel.GRAY_4;
+ }
+ compressed = StringUtils.goLowerCase(result.get(0)).endsWith("z");
+ f = new File(result.get(1));
+ } else {
+ f = new File(result.get(0));
+ }
+ final BufferedImage im = ImageIO.read(f);
+ final String name = getSpriteName(f);
+ final String s = compressed ? SpriteUtils.encodeCompressed(im, name, level) : SpriteUtils.encode(im, name,
+ level);
+ System.out.println(s);
+ }
+
+ private static String getSpriteName(File f) {
+ final String s = getSpriteNameInternal(f);
+ if (s.length() == 0) {
+ return "test";
+ }
+ return s;
+ }
+
+ private static String getSpriteNameInternal(File f) {
+ final StringBuilder sb = new StringBuilder();
+ for (char c : f.getName().toCharArray()) {
+ if (("" + c).matches("[\\p{L}0-9_]")) {
+ sb.append(c);
+ } else {
+ return sb.toString();
+ }
+ }
+ return sb.toString();
+ }
+
+ private static void goFtp(Option option) throws IOException {
+ final int ftpPort = option.getFtpPort();
+ System.err.println("ftpPort=" + ftpPort);
+ final FtpServer ftpServer = new FtpServer(ftpPort, option.getFileFormat());
+ ftpServer.go();
+ }
+
+ public static void printFonts() {
+ final Font fonts[] = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
+ for (Font f : fonts) {
+ System.out.println("f=" + f + "/" + f.getPSName() + "/" + f.getName() + "/" + f.getFontName() + "/"
+ + f.getFamily());
+ }
+ final String name[] = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
+ for (String n : name) {
+ System.out.println("n=" + n);
+ }
+
+ }
+
+ private static void managePattern() {
+ printPattern(new SequenceDiagramFactory());
+ printPattern(new ClassDiagramFactory());
+ printPattern(new ActivityDiagramFactory());
+ printPattern(new DescriptionDiagramFactory());
+ // printPattern(new ComponentDiagramFactory());
+ printPattern(new StateDiagramFactory());
+ printPattern(new ObjectDiagramFactory());
+ }
+
+ private static void printPattern(UmlDiagramFactory factory) {
+ System.out.println();
+ System.out.println(factory.getClass().getSimpleName().replaceAll("Factory", ""));
+ final List<String> descriptions = factory.getDescription();
+ for (String s : descriptions) {
+ System.out.println(s);
+ }
+ }
+
+ private static void managePipe(Option option) throws IOException {
+ final String charset = option.getCharset();
+ final BufferedReader br;
+ if (charset == null) {
+ br = new BufferedReader(new InputStreamReader(System.in));
+ } else {
+ br = new BufferedReader(new InputStreamReader(System.in, charset));
+ }
+ managePipe(option, br, System.out);
+ }
+
+ public static void managePipe(Option option, final BufferedReader br, final PrintStream ps) throws IOException {
+ final StringBuilder sb = new StringBuilder();
+ String s = null;
+ while ((s = br.readLine()) != null) {
+ sb.append(s);
+ sb.append("\n");
+ }
+ String source = sb.toString();
+ if (source.contains("@startuml") == false) {
+ source = "@startuml\n" + source + "\n@enduml";
+ }
+ final SourceStringReader sourceStringReader = new SourceStringReader(new Defines(), source, option.getConfig());
+
+ if (option.isSyntax()) {
+ final Diagram system = sourceStringReader.getBlocks().get(0).getDiagram();
+ if (system instanceof UmlDiagram) {
+ ps.println(((UmlDiagram) system).getUmlDiagramType().name());
+ ps.println(system.getDescription());
+ } else if (system instanceof PSystemError) {
+ ps.println("ERROR");
+ final PSystemError sys = (PSystemError) system;
+ ps.println(sys.getHigherErrorPosition());
+ for (ErrorUml er : sys.getErrorsUml()) {
+ ps.println(er.getError());
+ }
+ } else {
+ ps.println("OTHER");
+ ps.println(system.getDescription());
+ }
+ } else if (option.isPipe()) {
+ sourceStringReader.generateImage(ps, 0, option.getFileFormatOption());
+ }
+ }
+
+ private static boolean manageAllFiles(Option option) throws IOException, InterruptedException {
+
+ File lockFile = null;
+ try {
+ if (OptionFlags.getInstance().isWord()) {
+ final File dir = new File(option.getResult().get(0));
+ final File javaIsRunningFile = new File(dir, "javaisrunning.tmp");
+ javaIsRunningFile.delete();
+ lockFile = new File(dir, "javaumllock.tmp");
+ }
+ return processArgs(option);
+ } finally {
+ if (lockFile != null) {
+ lockFile.delete();
+ }
+ }
+
+ }
+
+ private static boolean processArgs(Option option) throws IOException, InterruptedException {
+ if (option.isDecodeurl() == false && option.getNbThreads() > 0 && option.isCheckOnly() == false
+ && OptionFlags.getInstance().isMetadata() == false) {
+ return multithread(option);
+ }
+ boolean errorGlobal = false;
+ for (String s : option.getResult()) {
+ if (option.isDecodeurl()) {
+ final Transcoder transcoder = TranscoderUtil.getDefaultTranscoder();
+ System.out.println("@startuml");
+ System.out.println(transcoder.decode(s));
+ System.out.println("@enduml");
+ } else {
+ final FileGroup group = new FileGroup(s, option.getExcludes(), option);
+ for (File f : group.getFiles()) {
+ try {
+ final boolean error = manageFileInternal(f, option);
+ if (error) {
+ errorGlobal = true;
+ }
+ if (error && option.isFailfastOrFailfast2()) {
+ return true;
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ return errorGlobal;
+ }
+
+ private static boolean multithread(final Option option) throws InterruptedException {
+ Log.info("Using several threads: " + option.getNbThreads());
+ final ExecutorService executor = Executors.newFixedThreadPool(option.getNbThreads());
+ final AtomicBoolean errors = new AtomicBoolean(false);
+ for (String s : option.getResult()) {
+ final FileGroup group = new FileGroup(s, option.getExcludes(), option);
+ for (final File f : group.getFiles()) {
+ executor.submit(new Runnable() {
+ public void run() {
+ if (errors.get() && option.isFailfastOrFailfast2()) {
+ return;
+ }
+ try {
+ final boolean error = manageFileInternal(f, option);
+ if (error) {
+ errors.set(true);
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ }
+ }
+ executor.shutdown();
+ executor.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS);
+ return errors.get();
+ }
+
+ private static boolean manageFileInternal(File f, Option option) throws IOException, InterruptedException {
+ if (OptionFlags.getInstance().isMetadata()) {
+ System.out.println("------------------------");
+ System.out.println(f);
+ // new Metadata().readAndDisplayMetadata(f);
+ System.out.println();
+ System.out.println(new MetadataTag(f, "plantuml").getData());
+ System.out.println("------------------------");
+ return false;
+ }
+ final ISourceFileReader sourceFileReader;
+ if (option.getOutputFile() == null) {
+ sourceFileReader = new SourceFileReader(option.getDefaultDefines(), f, option.getOutputDir(),
+ option.getConfig(), option.getCharset(), option.getFileFormatOption());
+ } else {
+ sourceFileReader = new SourceFileReader2(option.getDefaultDefines(), f, option.getOutputFile(),
+ option.getConfig(), option.getCharset(), option.getFileFormatOption());
+ }
+ if (option.isComputeurl()) {
+ final List<String> urls = sourceFileReader.getEncodedUrl();
+ for (String s : urls) {
+ System.out.println(s);
+ }
+ return false;
+ }
+ if (option.isCheckOnly()) {
+ final boolean hasError = sourceFileReader.hasError();
+ final List<GeneratedImage> result = sourceFileReader.getGeneratedImages();
+ hasErrors(f, result);
+ return hasError;
+ }
+ final List<GeneratedImage> result = sourceFileReader.getGeneratedImages();
+ return hasErrors(f, result);
+ }
+
+ private static boolean hasErrors(File f, final List<GeneratedImage> list) throws IOException {
+ boolean result = false;
+ for (GeneratedImage i : list) {
+ final int lineError = i.lineErrorRaw();
+ if (lineError != -1) {
+ Log.error("Error line " + lineError + " in file: " + f.getCanonicalPath());
+ result = true;
+ }
+ }
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/Scale.java b/src/net/sourceforge/plantuml/Scale.java
new file mode 100644
index 0000000..9d6a4cd
--- /dev/null
+++ b/src/net/sourceforge/plantuml/Scale.java
@@ -0,0 +1,40 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+public interface Scale {
+
+ public double getScale(double width, double height);
+}
diff --git a/src/net/sourceforge/plantuml/ScaleHeight.java b/src/net/sourceforge/plantuml/ScaleHeight.java
new file mode 100644
index 0000000..7186497
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ScaleHeight.java
@@ -0,0 +1,48 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+public class ScaleHeight implements Scale {
+
+ private final double maxHeight;
+
+ public ScaleHeight(double maxHeight) {
+ this.maxHeight = maxHeight;
+ }
+
+ public double getScale(double width, double height) {
+ return maxHeight / height;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ScaleSimple.java b/src/net/sourceforge/plantuml/ScaleSimple.java
new file mode 100644
index 0000000..5969d1a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ScaleSimple.java
@@ -0,0 +1,48 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+public class ScaleSimple implements Scale {
+
+ private final double scale;
+
+ public ScaleSimple(double scale) {
+ this.scale = scale;
+ }
+
+ public double getScale(double width, double height) {
+ return scale;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ScaleWidth.java b/src/net/sourceforge/plantuml/ScaleWidth.java
new file mode 100644
index 0000000..282aaa9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ScaleWidth.java
@@ -0,0 +1,48 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+public class ScaleWidth implements Scale {
+
+ private final double maxWidth;
+
+ public ScaleWidth(double maxWidth) {
+ this.maxWidth = maxWidth;
+ }
+
+ public double getScale(double width, double height) {
+ return maxWidth / width;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ScaleWidthAndHeight.java b/src/net/sourceforge/plantuml/ScaleWidthAndHeight.java
new file mode 100644
index 0000000..fa03322
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ScaleWidthAndHeight.java
@@ -0,0 +1,55 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+public class ScaleWidthAndHeight implements Scale {
+
+ private final double maxWidth;
+ private final double maxHeight;
+
+ public ScaleWidthAndHeight(double maxWidth, double maxHeight) {
+ this.maxWidth = maxWidth;
+ this.maxHeight = maxHeight;
+ }
+
+ public double getScale(double width, double height) {
+ final double scale1 = maxWidth / width;
+ final double scale2 = maxHeight / height;
+// if (scale1 > 1 && scale2 > 1) {
+// return 1;
+// }
+ return Math.min(scale1, scale2);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/SignatureUtils.java b/src/net/sourceforge/plantuml/SignatureUtils.java
new file mode 100644
index 0000000..5f5cbde
--- /dev/null
+++ b/src/net/sourceforge/plantuml/SignatureUtils.java
@@ -0,0 +1,97 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+import net.sourceforge.plantuml.code.AsciiEncoder;
+
+public class SignatureUtils {
+
+ public static String getSignature(String s) {
+ try {
+ final AsciiEncoder coder = new AsciiEncoder();
+ final MessageDigest msgDigest = MessageDigest.getInstance("MD5");
+ msgDigest.update(s.getBytes("UTF-8"));
+ final byte[] digest = msgDigest.digest();
+ return coder.encode(digest);
+ } catch (NoSuchAlgorithmException e) {
+ e.printStackTrace();
+ throw new UnsupportedOperationException(e);
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ throw new UnsupportedOperationException(e);
+ }
+ }
+
+ public static String getSignatureWithoutImgSrc(String s) {
+ s = getSignature(purge(s));
+ return s;
+ }
+
+ public static String purge(String s) {
+ final String regex = "(?i)\\<img\\s+src=\"(?:[^\"]+[/\\\\])?([^/\\\\\\d.]+)\\d*(\\.\\w+)\"/\\>";
+ s = s.replaceAll(regex, "<img src=\"$1$2\"/>");
+ final String regex2 = "(?i)image=\"(?:[^\"]+[/\\\\])?([^/\\\\\\d.]+)\\d*(\\.\\w+)\"";
+ s = s.replaceAll(regex2, "image=\"$1$2\"");
+ return s;
+ }
+
+ public static String getSignature(File f) throws IOException {
+ try {
+ final AsciiEncoder coder = new AsciiEncoder();
+ final MessageDigest msgDigest = MessageDigest.getInstance("MD5");
+ final FileInputStream is = new FileInputStream(f);
+ int read = -1;
+ while ((read = is.read()) != -1) {
+ msgDigest.update((byte) read);
+ }
+ is.close();
+ final byte[] digest = msgDigest.digest();
+ return coder.encode(digest);
+ } catch (NoSuchAlgorithmException e) {
+ e.printStackTrace();
+ throw new UnsupportedOperationException(e);
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ throw new UnsupportedOperationException(e);
+ }
+ }
+}
diff --git a/src/net/sourceforge/plantuml/SingleLine.java b/src/net/sourceforge/plantuml/SingleLine.java
new file mode 100644
index 0000000..86fa5c5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/SingleLine.java
@@ -0,0 +1,42 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import net.sourceforge.plantuml.core.Diagram;
+
+public interface SingleLine {
+
+ Diagram getSystemFromSingleLine(String singleLine);
+}
diff --git a/src/net/sourceforge/plantuml/SkinParam.java b/src/net/sourceforge/plantuml/SkinParam.java
new file mode 100644
index 0000000..8e0fc6b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/SkinParam.java
@@ -0,0 +1,668 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import java.awt.Font;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.cucadiagram.Rankdir;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.cucadiagram.dot.DotSplines;
+import net.sourceforge.plantuml.cucadiagram.dot.GraphvizLayoutStrategy;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorSetSimple;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.IHtmlColorSet;
+import net.sourceforge.plantuml.graphic.SkinParameter;
+import net.sourceforge.plantuml.svek.ConditionStyle;
+import net.sourceforge.plantuml.svek.PackageStyle;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+import net.sourceforge.plantuml.ugraphic.ColorMapperMonochrome;
+import net.sourceforge.plantuml.ugraphic.Sprite;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+
+public class SkinParam implements ISkinParam {
+
+ private final Map<String, String> params = new HashMap<String, String>();
+ private Rankdir rankdir = Rankdir.TOP_TO_BOTTOM;
+
+ public void setParam(String key, String value) {
+ params.put(cleanForKey(key), value.trim());
+ }
+
+ private static final String stereoPatternString = "\\<\\<(.*?)\\>\\>";
+ private static final Pattern stereoPattern = MyPattern.cmpile(stereoPatternString);
+
+ // public SkinParam() {
+ //
+ // }
+
+ public static SkinParam noShadowing() {
+ final SkinParam result = new SkinParam();
+ result.setParam("shadowing", "false");
+ return result;
+ }
+
+ // public SkinParam(String type) {
+ // if (type == null) {
+ // setParam("shadowing", "false");
+ // }
+ // }
+
+ static String cleanForKey(String key) {
+ key = StringUtils.goLowerCase(key).trim();
+ key = key.replaceAll("_|\\.|\\s", "");
+ key = replaceSmart(key, "partition", "package");
+ key = replaceSmart(key, "sequenceparticipant", "participant");
+ key = replaceSmart(key, "sequenceactor", "actor");
+ if (key.contains("arrow")) {
+ key = key.replaceAll("activityarrow|objectarrow|classarrow|componentarrow|statearrow|usecasearrow",
+ "genericarrow");
+ }
+ // // key = key.replaceAll("activityarrow", "genericarrow");
+ // // key = key.replaceAll("objectarrow", "genericarrow");
+ // // key = key.replaceAll("classarrow", "genericarrow");
+ // // key = key.replaceAll("componentarrow", "genericarrow");
+ // // key = key.replaceAll("statearrow", "genericarrow");
+ // // key = key.replaceAll("usecasearrow", "genericarrow");
+ final Matcher m = stereoPattern.matcher(key);
+ if (m.find()) {
+ final String s = m.group(1);
+ key = key.replaceAll(stereoPatternString, "");
+ key += "<<" + s + ">>";
+ }
+ return key;
+ }
+
+ private static String replaceSmart(String s, String src, String target) {
+ if (s.contains(src) == false) {
+ return s;
+ }
+ return s.replaceAll(src, target);
+ }
+
+ public HtmlColor getHyperlinkColor() {
+ final HtmlColor result = getHtmlColor(ColorParam.hyperlink, null, false);
+ if (result == null) {
+ return HtmlColorUtils.BLUE;
+ }
+ return result;
+ }
+
+ public HtmlColor getBackgroundColor() {
+ final HtmlColor result = getHtmlColor(ColorParam.background, null, false);
+ if (result == null) {
+ return HtmlColorUtils.WHITE;
+ }
+ return result;
+ }
+
+ public String getValue(String key) {
+ return params.get(cleanForKey(key));
+ }
+
+ static String humanName(String key) {
+ final StringBuilder sb = new StringBuilder();
+ boolean upper = true;
+ for (int i = 0; i < key.length(); i++) {
+ final char c = key.charAt(i);
+ if (c == '_') {
+ upper = true;
+ } else {
+ sb.append(upper ? StringUtils.goUpperCase(c) : StringUtils.goLowerCase(c));
+ upper = false;
+ }
+ }
+ return sb.toString();
+ }
+
+ public HtmlColor getHtmlColor(ColorParam param, Stereotype stereotype, boolean clickable) {
+ if (stereotype != null) {
+ checkStereotype(stereotype);
+ final String value2 = getValue(param.name() + "color" + stereotype.getLabel(false));
+ if (value2 != null && getIHtmlColorSet().getColorIfValid(value2) != null) {
+ return getIHtmlColorSet().getColorIfValid(value2);
+ }
+ }
+ final String value = getValue(getParamName(param, clickable));
+ final boolean acceptTransparent = param == ColorParam.background;
+ if (value == null) {
+ return null;
+ }
+ return getIHtmlColorSet().getColorIfValid(value, acceptTransparent);
+ }
+
+ private String getParamName(ColorParam param, boolean clickable) {
+ String n = param.name();
+ if (clickable && n.endsWith("Background")) {
+ n = n.replaceAll("Background", "ClickableBackground");
+ } else if (clickable && n.endsWith("Border")) {
+ n = n.replaceAll("Border", "ClickableBorder");
+ }
+ return n + "color";
+ }
+
+ private void checkStereotype(Stereotype stereotype) {
+ // if (stereotype.startsWith("<<") == false || stereotype.endsWith(">>") == false) {
+ // throw new IllegalArgumentException();
+ // }
+ }
+
+ private int getFontSize(FontParam param, Stereotype stereotype) {
+ if (stereotype != null) {
+ checkStereotype(stereotype);
+ final String value2 = getValue(param.name() + "fontsize" + stereotype.getLabel(false));
+ if (value2 != null && value2.matches("\\d+")) {
+ return Integer.parseInt(value2);
+ }
+ }
+ String value = getValue(param.name() + "fontsize");
+ if (value == null || value.matches("\\d+") == false) {
+ value = getValue("defaultfontsize");
+ }
+ if (value == null || value.matches("\\d+") == false) {
+ return param.getDefaultSize(this);
+ }
+ return Integer.parseInt(value);
+ }
+
+ private String getFontFamily(FontParam param, Stereotype stereotype) {
+ if (stereotype != null) {
+ checkStereotype(stereotype);
+ final String value2 = getValue(param.name() + "fontname" + stereotype.getLabel(false));
+ if (value2 != null) {
+ return StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(value2);
+ }
+ }
+ // Times, Helvetica, Courier or Symbol
+ String value = getValue(param.name() + "fontname");
+ if (value != null) {
+ return StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(value);
+ }
+ if (param != FontParam.CIRCLED_CHARACTER) {
+ value = getValue("defaultfontname");
+ if (value != null) {
+ return StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(value);
+ }
+ }
+ return param.getDefaultFamily();
+ }
+
+ public HtmlColor getFontHtmlColor(FontParam param, Stereotype stereotype) {
+ String value = null;
+ if (stereotype != null) {
+ checkStereotype(stereotype);
+ value = getValue(param.name() + "fontcolor" + stereotype.getLabel(false));
+ }
+ if (value == null || getIHtmlColorSet().getColorIfValid(value) == null) {
+ value = getValue(param.name() + "fontcolor");
+ }
+ if (value == null || getIHtmlColorSet().getColorIfValid(value) == null) {
+ value = getValue("defaultfontcolor");
+ }
+ if (value == null || getIHtmlColorSet().getColorIfValid(value) == null) {
+ value = param.getDefaultColor();
+ }
+ return getIHtmlColorSet().getColorIfValid(value);
+ }
+
+ private int getFontStyle(FontParam param, Stereotype stereotype, boolean inPackageTitle) {
+ String value = null;
+ if (stereotype != null) {
+ checkStereotype(stereotype);
+ value = getValue(param.name() + "fontstyle" + stereotype.getLabel(false));
+ }
+ if (value == null) {
+ value = getValue(param.name() + "fontstyle");
+ }
+ if (value == null) {
+ value = getValue("defaultfontstyle");
+ }
+ if (value == null) {
+ return param.getDefaultFontStyle(this, inPackageTitle);
+ }
+ int result = Font.PLAIN;
+ if (StringUtils.goLowerCase(value).contains("bold")) {
+ result = result | Font.BOLD;
+ }
+ if (StringUtils.goLowerCase(value).contains("italic")) {
+ result = result | Font.ITALIC;
+ }
+ return result;
+ }
+
+ public UFont getFont(FontParam fontParam, Stereotype stereotype, boolean inPackageTitle) {
+ if (stereotype != null) {
+ checkStereotype(stereotype);
+ }
+ final String fontFamily = getFontFamily(fontParam, stereotype);
+ final int fontStyle = getFontStyle(fontParam, stereotype, inPackageTitle);
+ final int fontSize = getFontSize(fontParam, stereotype);
+ return new UFont(fontFamily, fontStyle, fontSize);
+ }
+
+ public int getCircledCharacterRadius() {
+ final String value = getValue("circledcharacterradius");
+ if (value != null && value.matches("\\d+")) {
+ return Integer.parseInt(value);
+ }
+ // return 11;
+ // Log.println("SIZE1="+getFontSize(FontParam.CIRCLED_CHARACTER));
+ // Log.println("SIZE1="+getFontSize(FontParam.CIRCLED_CHARACTER)/3);
+ return getFontSize(FontParam.CIRCLED_CHARACTER, null) / 3 + 6;
+ }
+
+ public int classAttributeIconSize() {
+ final String value = getValue("classAttributeIconSize");
+ if (value != null && value.matches("\\d+")) {
+ return Integer.parseInt(value);
+ }
+ return 10;
+ }
+
+ private boolean isMonochrome() {
+ return "true".equals(getValue("monochrome"));
+ }
+
+ public static Collection<String> getPossibleValues() {
+ final Set<String> result = new TreeSet<String>();
+ result.add("Monochrome");
+ // result.add("BackgroundColor");
+ result.add("CircledCharacterRadius");
+ result.add("ClassAttributeIconSize");
+ result.add("DefaultFontName");
+ result.add("DefaultFontStyle");
+ result.add("DefaultFontSize");
+ result.add("DefaultFontColor");
+ for (FontParam p : EnumSet.allOf(FontParam.class)) {
+ final String h = humanName(p.name());
+ result.add(h + "FontStyle");
+ result.add(h + "FontName");
+ result.add(h + "FontSize");
+ result.add(h + "FontColor");
+ }
+ for (ColorParam p : EnumSet.allOf(ColorParam.class)) {
+ final String h = capitalize(p.name());
+ result.add(h + "Color");
+ }
+ for (LineParam p : EnumSet.allOf(LineParam.class)) {
+ final String h = capitalize(p.name());
+ result.add(h + "Thickness");
+ }
+ return Collections.unmodifiableSet(result);
+ }
+
+ private static String capitalize(String name) {
+ return StringUtils.goUpperCase(name.substring(0, 1)) + name.substring(1);
+ }
+
+ public int getDpi() {
+ final String value = getValue("dpi");
+ if (value != null && value.matches("\\d+")) {
+ return Integer.parseInt(value);
+ }
+ return 96;
+ }
+
+ public DotSplines getDotSplines() {
+ final String value = getValue("linetype");
+ if ("polyline".equalsIgnoreCase(value)) {
+ return DotSplines.POLYLINE;
+ }
+ if ("ortho".equalsIgnoreCase(value)) {
+ return DotSplines.ORTHO;
+ }
+ return DotSplines.SPLINES;
+ }
+
+ public GraphvizLayoutStrategy getStrategy() {
+ final String value = getValue("layout");
+ if ("neato".equalsIgnoreCase(value)) {
+ return GraphvizLayoutStrategy.NEATO;
+ }
+ if ("circo".equalsIgnoreCase(value)) {
+ return GraphvizLayoutStrategy.CIRCO;
+ }
+ if ("fdp".equalsIgnoreCase(value)) {
+ return GraphvizLayoutStrategy.FDP;
+ }
+ if ("twopi".equalsIgnoreCase(value)) {
+ return GraphvizLayoutStrategy.TWOPI;
+ }
+ return GraphvizLayoutStrategy.DOT;
+ }
+
+ public HorizontalAlignment getHorizontalAlignment(AlignParam param) {
+ final String value;
+ switch (param) {
+ case SEQUENCE_MESSAGE_ALIGN:
+ value = getArg(getValue(AlignParam.SEQUENCE_MESSAGE_ALIGN.name()), 0);
+ break;
+ case SEQUENCE_MESSAGETEXT_ALIGN:
+ value = getArg(getValue(AlignParam.SEQUENCE_MESSAGE_ALIGN.name()), 1);
+ break;
+ default:
+ value = getValue(param.name());
+ }
+ final HorizontalAlignment result = HorizontalAlignment.fromString(value);
+ if (result == null) {
+ return param.getDefaultValue();
+ }
+ return result;
+ }
+
+ public HorizontalAlignment getDefaultTextAlignment() {
+ final String value = getValue("defaulttextalignment");
+ final HorizontalAlignment result = HorizontalAlignment.fromString(value);
+ if (result == null) {
+ return HorizontalAlignment.CENTER;
+ }
+ return result;
+ }
+
+ private String getArg(String value, int i) {
+ if (value == null) {
+ return null;
+ }
+ final String[] split = value.split(":");
+ if (i >= split.length) {
+ return split[0];
+ }
+ return split[i];
+ }
+
+ public ColorMapper getColorMapper() {
+ if (isMonochrome()) {
+ return new ColorMapperMonochrome();
+ }
+ return new ColorMapperIdentity();
+ }
+
+ public boolean shadowing() {
+ final String value = getValue("shadowing");
+ if ("false".equalsIgnoreCase(value)) {
+ return false;
+ }
+ if ("true".equalsIgnoreCase(value)) {
+ return true;
+ }
+ if (strictUmlStyle()) {
+ return false;
+ }
+ return true;
+ }
+
+ public boolean shadowing2(SkinParameter skinParameter) {
+ if (skinParameter == null) {
+ throw new IllegalArgumentException();
+ }
+ final String name = skinParameter.getUpperCaseName();
+ final String value = getValue(name + "shadowing");
+ if (value == null) {
+ return shadowing();
+ }
+ if ("false".equalsIgnoreCase(value)) {
+ return false;
+ }
+ if ("true".equalsIgnoreCase(value)) {
+ return true;
+ }
+ if (strictUmlStyle()) {
+ return false;
+ }
+ return true;
+ }
+
+ public PackageStyle getPackageStyle() {
+ final String value = getValue("packageStyle");
+ final PackageStyle p = PackageStyle.fromString(value);
+ if (p == null) {
+ return PackageStyle.FOLDER;
+ }
+ return p;
+ }
+
+ private final Map<String, Sprite> sprites = new HashMap<String, Sprite>();
+
+ public void addSprite(String name, Sprite sprite) {
+ sprites.put(name, sprite);
+ }
+
+ public Sprite getSprite(String name) {
+ return sprites.get(name);
+ }
+
+ public boolean useUml2ForComponent() {
+ if (strictUmlStyle()) {
+ return true;
+ }
+ final String value = getValue("componentstyle");
+ return "uml2".equalsIgnoreCase(value);
+ }
+
+ public boolean stereotypePositionTop() {
+ final String value = getValue("stereotypePosition");
+ if ("bottom".equalsIgnoreCase(value)) {
+ return false;
+ }
+ return true;
+ }
+
+ public boolean useSwimlanes(UmlDiagramType type) {
+ if (type != UmlDiagramType.ACTIVITY) {
+ return false;
+ }
+ if ("true".equalsIgnoreCase(getValue("swimlane"))) {
+ return true;
+ }
+ if ("true".equalsIgnoreCase(getValue("swimlanes"))) {
+ return true;
+ }
+ return false;
+ }
+
+ public double getNodesep() {
+ final String value = getValue("nodesep");
+ if (value != null && value.matches("\\d+")) {
+ return Double.parseDouble(value);
+ }
+ return 0;
+ }
+
+ public double getRanksep() {
+ final String value = getValue("ranksep");
+ if (value != null && value.matches("\\d+")) {
+ return Double.parseDouble(value);
+ }
+ return 0;
+ }
+
+ public double getRoundCorner() {
+ final String value = getValue("roundcorner");
+ if (value != null && value.matches("\\d+")) {
+ return Double.parseDouble(value);
+ }
+ return 0;
+ }
+
+ public UStroke getThickness(LineParam param, Stereotype stereotype) {
+ if (stereotype != null) {
+ checkStereotype(stereotype);
+ final String value2 = getValue(param.name() + "thickness" + stereotype.getLabel(false));
+ if (value2 != null && value2.matches("[\\d.]+")) {
+ return new UStroke(Double.parseDouble(value2));
+ }
+ }
+ final String value = getValue(param.name() + "thickness");
+ if (value != null && value.matches("[\\d.]+")) {
+ return new UStroke(Double.parseDouble(value));
+ }
+ return null;
+ }
+
+ public double maxMessageSize() {
+ final String value = getValue("maxmessagesize");
+ if (value != null && value.matches("-?\\d+")) {
+ return Double.parseDouble(value);
+ }
+ return 0;
+ }
+
+ public boolean strictUmlStyle() {
+ final String value = getValue("style");
+ if ("strictuml".equalsIgnoreCase(value)) {
+ return true;
+ }
+ return false;
+ }
+
+ public boolean forceSequenceParticipantUnderlined() {
+ final String value = getValue("sequenceParticipant");
+ if ("underline".equalsIgnoreCase(value)) {
+ return true;
+ }
+ return false;
+ }
+
+ public ConditionStyle getConditionStyle() {
+ final String value = getValue("conditionStyle");
+ final ConditionStyle p = ConditionStyle.fromString(value);
+ if (p == null) {
+ return ConditionStyle.INSIDE;
+ }
+ return p;
+ }
+
+ public double minClassWidth() {
+ final String value = getValue("minclasswidth");
+ if (value != null && value.matches("\\d+")) {
+ return Integer.parseInt(value);
+ }
+ return 0;
+ }
+
+ public boolean sameClassWidth() {
+ return "true".equals(getValue("sameclasswidth"));
+ }
+
+ public final Rankdir getRankdir() {
+ return rankdir;
+ }
+
+ public final void setRankdir(Rankdir rankdir) {
+ this.rankdir = rankdir;
+ }
+
+ public boolean useOctagonForActivity(Stereotype stereotype) {
+ String value = getValue("activityshape");
+ if (stereotype != null) {
+ checkStereotype(stereotype);
+ final String value2 = getValue("activityshape" + stereotype.getLabel(false));
+ if (value2 != null) {
+ value = value2;
+ }
+ }
+ if ("roundedbox".equalsIgnoreCase(value)) {
+ return false;
+ }
+ if ("octagon".equalsIgnoreCase(value)) {
+ return true;
+ }
+ return false;
+ }
+
+ private final IHtmlColorSet htmlColorSet = new HtmlColorSetSimple();
+
+ public IHtmlColorSet getIHtmlColorSet() {
+ return htmlColorSet;
+ }
+
+ public boolean useUnderlineForHyperlink() {
+ final String value = getValue("hyperlinkunderline");
+ if ("false".equalsIgnoreCase(value)) {
+ return false;
+ }
+ return true;
+ }
+
+ public double getPadding() {
+ final String value = getValue("padding");
+ if (value != null && value.matches("\\d+(\\.\\d+)?")) {
+ return Double.parseDouble(value);
+ }
+ return 0;
+ }
+
+ public int groupInheritance() {
+ final String value = getValue("groupinheritance");
+ int result = Integer.MAX_VALUE;
+ if (value != null && value.matches("\\d+")) {
+ result = Integer.parseInt(value);
+ }
+ if (result <= 1) {
+ result = Integer.MAX_VALUE;
+ }
+ return result;
+ }
+
+ public boolean useGuillemet() {
+ final String value = getValue("guillemet");
+ if ("false".equalsIgnoreCase(value)) {
+ return false;
+ }
+ return true;
+ }
+
+ public boolean handwritten() {
+ final String value = getValue("handwritten");
+ if ("true".equalsIgnoreCase(value)) {
+ return true;
+ }
+ return false;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/SkinParamBackcolored.java b/src/net/sourceforge/plantuml/SkinParamBackcolored.java
new file mode 100644
index 0000000..0b27f44
--- /dev/null
+++ b/src/net/sourceforge/plantuml/SkinParamBackcolored.java
@@ -0,0 +1,87 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+
+public class SkinParamBackcolored extends SkinParamDelegator {
+
+ final private HtmlColor backColorElement;
+ final private HtmlColor backColorGeneral;
+ final private boolean forceClickage;
+
+ public SkinParamBackcolored(ISkinParam skinParam, HtmlColor backColorElement) {
+ this(skinParam, backColorElement, null, false);
+ }
+
+ public SkinParamBackcolored(ISkinParam skinParam, HtmlColor backColorElement, boolean forceClickage) {
+ this(skinParam, backColorElement, null, forceClickage);
+ }
+
+ public SkinParamBackcolored(ISkinParam skinParam, HtmlColor backColorElement, HtmlColor backColorGeneral) {
+ this(skinParam, backColorElement, backColorGeneral, false);
+ }
+
+ public SkinParamBackcolored(ISkinParam skinParam, HtmlColor backColorElement, HtmlColor backColorGeneral,
+ boolean forceClickage) {
+ super(skinParam);
+ this.forceClickage = forceClickage;
+ this.backColorElement = backColorElement;
+ this.backColorGeneral = backColorGeneral;
+ }
+
+ public HtmlColor getBackgroundColor() {
+ if (backColorGeneral != null) {
+ return backColorGeneral;
+ }
+ return super.getBackgroundColor();
+ }
+
+ public HtmlColor getHtmlColor(ColorParam param, Stereotype stereotype, boolean clickable) {
+ if (param.isBackground() && backColorElement != null) {
+ return backColorElement;
+ }
+ if (forceClickage) {
+ final HtmlColor c1 = super.getHtmlColor(param, stereotype, true);
+ if (c1 != null) {
+ return c1;
+ }
+ // clickable = true;
+ }
+ return super.getHtmlColor(param, stereotype, clickable);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/SkinParamBackcoloredReference.java b/src/net/sourceforge/plantuml/SkinParamBackcoloredReference.java
new file mode 100644
index 0000000..0a96ecb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/SkinParamBackcoloredReference.java
@@ -0,0 +1,62 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+
+public class SkinParamBackcoloredReference extends SkinParamDelegator {
+
+ final private HtmlColor sequenceReferenceHeaderBackground;
+ final private HtmlColor sequenceReferenceBackground;
+
+ public SkinParamBackcoloredReference(ISkinParam skinParam, HtmlColor sequenceReferenceHeaderBackground,
+ HtmlColor sequenceReferenceBackground) {
+ super(skinParam);
+ this.sequenceReferenceBackground = sequenceReferenceBackground;
+ this.sequenceReferenceHeaderBackground = sequenceReferenceHeaderBackground;
+ }
+
+ public HtmlColor getHtmlColor(ColorParam param, Stereotype stereotype, boolean clickable) {
+ if (param == ColorParam.sequenceReferenceHeaderBackground && sequenceReferenceHeaderBackground != null) {
+ return sequenceReferenceHeaderBackground;
+ }
+ if (param == ColorParam.sequenceReferenceBackground && sequenceReferenceBackground != null) {
+ return sequenceReferenceBackground;
+ }
+ return super.getHtmlColor(param, stereotype, clickable);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/SkinParamDelegator.java b/src/net/sourceforge/plantuml/SkinParamDelegator.java
new file mode 100644
index 0000000..6264ccc
--- /dev/null
+++ b/src/net/sourceforge/plantuml/SkinParamDelegator.java
@@ -0,0 +1,217 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import net.sourceforge.plantuml.cucadiagram.Rankdir;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.cucadiagram.dot.DotSplines;
+import net.sourceforge.plantuml.cucadiagram.dot.GraphvizLayoutStrategy;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.IHtmlColorSet;
+import net.sourceforge.plantuml.graphic.SkinParameter;
+import net.sourceforge.plantuml.svek.ConditionStyle;
+import net.sourceforge.plantuml.svek.PackageStyle;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.Sprite;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+
+public class SkinParamDelegator implements ISkinParam {
+
+ final private ISkinParam skinParam;
+
+ public SkinParamDelegator(ISkinParam skinParam) {
+ this.skinParam = skinParam;
+ }
+
+ public HtmlColor getHyperlinkColor() {
+ return skinParam.getHyperlinkColor();
+ }
+
+ public HtmlColor getBackgroundColor() {
+ return skinParam.getBackgroundColor();
+ }
+
+ public int getCircledCharacterRadius() {
+ return skinParam.getCircledCharacterRadius();
+ }
+
+ public UFont getFont(FontParam fontParam, Stereotype stereotype, boolean inPackageTitle) {
+ return skinParam.getFont(fontParam, stereotype, false);
+ }
+
+ public HtmlColor getFontHtmlColor(FontParam param, Stereotype stereotype) {
+ return skinParam.getFontHtmlColor(param, stereotype);
+ }
+
+ public HtmlColor getHtmlColor(ColorParam param, Stereotype stereotype, boolean clickable) {
+ return skinParam.getHtmlColor(param, stereotype, clickable);
+ }
+
+ public String getValue(String key) {
+ return skinParam.getValue(key);
+ }
+
+ public int classAttributeIconSize() {
+ return skinParam.classAttributeIconSize();
+ }
+
+ public int getDpi() {
+ return skinParam.getDpi();
+ }
+
+ public DotSplines getDotSplines() {
+ return skinParam.getDotSplines();
+ }
+
+ public GraphvizLayoutStrategy getStrategy() {
+ return skinParam.getStrategy();
+ }
+
+ public HorizontalAlignment getHorizontalAlignment(AlignParam param) {
+ return skinParam.getHorizontalAlignment(param);
+ }
+
+ public ColorMapper getColorMapper() {
+ return skinParam.getColorMapper();
+ }
+
+ public boolean shadowing() {
+ return skinParam.shadowing();
+ }
+
+ public boolean shadowing2(SkinParameter skinParameter) {
+ return skinParam.shadowing2(skinParameter);
+ }
+
+ public PackageStyle getPackageStyle() {
+ return skinParam.getPackageStyle();
+ }
+
+ public Sprite getSprite(String name) {
+ return skinParam.getSprite(name);
+ }
+
+ public boolean useUml2ForComponent() {
+ return skinParam.useUml2ForComponent();
+ }
+
+ public boolean stereotypePositionTop() {
+ return skinParam.stereotypePositionTop();
+ }
+
+ public boolean useSwimlanes(UmlDiagramType type) {
+ return skinParam.useSwimlanes(type);
+ }
+
+ public double getNodesep() {
+ return skinParam.getNodesep();
+ }
+
+ public double getRanksep() {
+ return skinParam.getRanksep();
+ }
+
+ public double getRoundCorner() {
+ return skinParam.getRoundCorner();
+ }
+
+ public UStroke getThickness(LineParam param, Stereotype stereotype) {
+ return skinParam.getThickness(param, stereotype);
+ }
+
+ public double maxMessageSize() {
+ return skinParam.maxMessageSize();
+ }
+
+ public boolean strictUmlStyle() {
+ return skinParam.strictUmlStyle();
+ }
+
+ public boolean forceSequenceParticipantUnderlined() {
+ return skinParam.forceSequenceParticipantUnderlined();
+ }
+
+ public ConditionStyle getConditionStyle() {
+ return skinParam.getConditionStyle();
+ }
+
+ public double minClassWidth() {
+ return skinParam.minClassWidth();
+ }
+
+ public boolean sameClassWidth() {
+ return skinParam.sameClassWidth();
+ }
+
+ public Rankdir getRankdir() {
+ return skinParam.getRankdir();
+ }
+
+ public boolean useOctagonForActivity(Stereotype stereotype) {
+ return skinParam.useOctagonForActivity(stereotype);
+ }
+
+ public IHtmlColorSet getIHtmlColorSet() {
+ return skinParam.getIHtmlColorSet();
+ }
+
+ public boolean useUnderlineForHyperlink() {
+ return skinParam.useUnderlineForHyperlink();
+ }
+
+ public HorizontalAlignment getDefaultTextAlignment() {
+ return skinParam.getDefaultTextAlignment();
+ }
+
+ public double getPadding() {
+ return skinParam.getPadding();
+ }
+
+ public int groupInheritance() {
+ return skinParam.groupInheritance();
+ }
+
+ public boolean useGuillemet() {
+ return skinParam.useGuillemet();
+ }
+
+ public boolean handwritten() {
+ return skinParam.handwritten();
+ }
+
+
+}
diff --git a/src/net/sourceforge/plantuml/SkinParamForecolored.java b/src/net/sourceforge/plantuml/SkinParamForecolored.java
new file mode 100644
index 0000000..b04c027
--- /dev/null
+++ b/src/net/sourceforge/plantuml/SkinParamForecolored.java
@@ -0,0 +1,52 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+
+public class SkinParamForecolored extends SkinParamDelegator {
+
+ final private HtmlColor forecolor;
+
+ public SkinParamForecolored(ISkinParam skinParam, HtmlColor forecolor) {
+ super(skinParam);
+ this.forecolor = forecolor;
+ }
+
+ public HtmlColor getHtmlColor(ColorParam param, String stereotype, boolean clickable) {
+ return forecolor;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/SkinParamSameClassWidth.java b/src/net/sourceforge/plantuml/SkinParamSameClassWidth.java
new file mode 100644
index 0000000..c5b5ff0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/SkinParamSameClassWidth.java
@@ -0,0 +1,50 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+public class SkinParamSameClassWidth extends SkinParamDelegator {
+
+ final private double width;
+
+ public SkinParamSameClassWidth(ISkinParam skinParam, double width) {
+ super(skinParam);
+ this.width = width;
+ }
+
+ public double minClassWidth() {
+ return width;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/SkinParamUtils.java b/src/net/sourceforge/plantuml/SkinParamUtils.java
new file mode 100644
index 0000000..58c8c3a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/SkinParamUtils.java
@@ -0,0 +1,58 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.skin.rose.Rose;
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public class SkinParamUtils {
+
+ private static final Rose rose = new Rose();
+
+ public static UFont getFont(ISkinParam skinParam, FontParam fontParam, Stereotype stereo) {
+ return skinParam.getFont(fontParam, stereo, false);
+ }
+
+ public static HtmlColor getFontColor(ISkinParam skinParam, FontParam fontParam, Stereotype stereo) {
+ return skinParam.getFontHtmlColor(fontParam, stereo);
+ }
+
+ public static HtmlColor getColor(ISkinParam skinParam, ColorParam colorParam, Stereotype stereo) {
+ return rose.getHtmlColor(skinParam, colorParam, stereo);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/SourceFileReader.java b/src/net/sourceforge/plantuml/SourceFileReader.java
new file mode 100644
index 0000000..3a99030
--- /dev/null
+++ b/src/net/sourceforge/plantuml/SourceFileReader.java
@@ -0,0 +1,185 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.PrintStream;
+import java.io.Reader;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+import net.sourceforge.plantuml.code.Transcoder;
+import net.sourceforge.plantuml.code.TranscoderUtil;
+import net.sourceforge.plantuml.core.Diagram;
+import net.sourceforge.plantuml.preproc.Defines;
+
+public class SourceFileReader implements ISourceFileReader {
+
+ private final File file;
+ private final File outputDirectory;
+
+ private final BlockUmlBuilder builder;
+ private FileFormatOption fileFormatOption;
+
+ public SourceFileReader(File file) throws IOException {
+ this(file, file.getAbsoluteFile().getParentFile());
+ }
+
+ public SourceFileReader(File file, File outputDirectory, String charset) throws IOException {
+ this(new Defines(), file, outputDirectory, Collections.<String> emptyList(), charset, new FileFormatOption(
+ FileFormat.PNG));
+ }
+
+ public SourceFileReader(final File file, File outputDirectory) throws IOException {
+ this(new Defines(), file, outputDirectory, Collections.<String> emptyList(), null, new FileFormatOption(
+ FileFormat.PNG));
+ }
+
+ public SourceFileReader(final File file, File outputDirectory, FileFormatOption fileFormatOption)
+ throws IOException {
+ this(new Defines(), file, outputDirectory, Collections.<String> emptyList(), null, fileFormatOption);
+ }
+
+ public SourceFileReader(Defines defines, final File file, File outputDirectory, List<String> config,
+ String charset, FileFormatOption fileFormatOption) throws IOException {
+ this.file = file;
+ this.fileFormatOption = fileFormatOption;
+ if (file.exists() == false) {
+ throw new IllegalArgumentException();
+ }
+ FileSystem.getInstance().setCurrentDir(file.getAbsoluteFile().getParentFile());
+ if (outputDirectory == null) {
+ outputDirectory = file.getAbsoluteFile().getParentFile();
+ } else if (outputDirectory.isAbsolute() == false) {
+ outputDirectory = FileSystem.getInstance().getFile(outputDirectory.getPath());
+ }
+ if (outputDirectory.exists() == false) {
+ outputDirectory.mkdirs();
+ }
+ this.outputDirectory = outputDirectory;
+
+ builder = new BlockUmlBuilder(config, charset, defines, getReader(charset), file.getAbsoluteFile()
+ .getParentFile());
+ }
+
+ public boolean hasError() {
+ for (final BlockUml b : builder.getBlockUmls()) {
+ if (b.getDiagram() instanceof PSystemError) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public List<GeneratedImage> getGeneratedImages() throws IOException {
+ Log.info("Reading file: " + file);
+
+ int cpt = 0;
+ final List<GeneratedImage> result = new ArrayList<GeneratedImage>();
+
+ for (BlockUml blockUml : builder.getBlockUmls()) {
+ String newName = blockUml.getFilename();
+
+ if (newName == null) {
+ newName = fileFormatOption.getFileFormat().changeName(file.getName(), cpt++);
+ }
+
+ final File suggested = new File(outputDirectory, newName);
+ suggested.getParentFile().mkdirs();
+
+ final Diagram system = blockUml.getDiagram();
+ final List<File> exportDiagrams = PSystemUtils.exportDiagrams(system, suggested, fileFormatOption);
+ OptionFlags.getInstance().logData(file, system);
+
+ for (File f : exportDiagrams) {
+ final String desc = "[" + file.getName() + "] " + system.getDescription();
+ if (OptionFlags.getInstance().isWord()) {
+ final String warnOrError = system.getWarningOrError();
+ if (warnOrError != null) {
+ final String name = f.getName().substring(0, f.getName().length() - 4) + ".err";
+ final File errorFile = new File(f.getParentFile(), name);
+ final PrintStream ps = new PrintStream(new FileOutputStream(errorFile));
+ ps.print(warnOrError);
+ ps.close();
+ }
+ }
+ final GeneratedImage generatedImage = new GeneratedImage(f, desc, blockUml);
+ result.add(generatedImage);
+ }
+
+ }
+
+ Log.info("Number of image(s): " + result.size());
+
+ return Collections.unmodifiableList(result);
+ }
+
+ public List<String> getEncodedUrl() throws IOException {
+ final List<String> result = new ArrayList<String>();
+ final Transcoder transcoder = TranscoderUtil.getDefaultTranscoder();
+ for (BlockUml blockUml : builder.getBlockUmls()) {
+ final String source = blockUml.getDiagram().getSource().getPlainString();
+ final String encoded = transcoder.encode(source);
+ result.add(encoded);
+ }
+ return Collections.unmodifiableList(result);
+ }
+
+ private Reader getReader(String charset) throws FileNotFoundException, UnsupportedEncodingException {
+ if (charset == null) {
+ Log.info("Using default charset");
+ return new InputStreamReader(new FileInputStream(file));
+ }
+ Log.info("Using charset " + charset);
+ return new InputStreamReader(new FileInputStream(file), charset);
+ }
+
+ public final void setFileFormatOption(FileFormatOption fileFormatOption) {
+ this.fileFormatOption = fileFormatOption;
+ }
+
+ public final Set<File> getIncludedFiles() {
+ return builder.getIncludedFiles();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/SourceFileReader2.java b/src/net/sourceforge/plantuml/SourceFileReader2.java
new file mode 100644
index 0000000..855e8ba
--- /dev/null
+++ b/src/net/sourceforge/plantuml/SourceFileReader2.java
@@ -0,0 +1,137 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+import net.sourceforge.plantuml.code.Transcoder;
+import net.sourceforge.plantuml.code.TranscoderUtil;
+import net.sourceforge.plantuml.core.Diagram;
+import net.sourceforge.plantuml.preproc.Defines;
+
+public class SourceFileReader2 implements ISourceFileReader {
+
+ private final File file;
+ private final File outputFile;
+
+ private final BlockUmlBuilder builder;
+ private FileFormatOption fileFormatOption;
+
+ public SourceFileReader2(Defines defines, final File file, File outputFile, List<String> config, String charset,
+ FileFormatOption fileFormatOption) throws IOException {
+ this.file = file;
+ this.fileFormatOption = fileFormatOption;
+ this.outputFile = outputFile;
+ if (file.exists() == false) {
+ throw new IllegalArgumentException();
+ }
+ FileSystem.getInstance().setCurrentDir(file.getAbsoluteFile().getParentFile());
+
+ builder = new BlockUmlBuilder(config, charset, defines, getReader(charset), file.getAbsoluteFile()
+ .getParentFile());
+ }
+
+ public boolean hasError() {
+ for (final BlockUml b : builder.getBlockUmls()) {
+ if (b.getDiagram() instanceof PSystemError) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public List<GeneratedImage> getGeneratedImages() throws IOException {
+ Log.info("Reading file: " + file);
+
+ final List<GeneratedImage> result = new ArrayList<GeneratedImage>();
+
+ for (BlockUml blockUml : builder.getBlockUmls()) {
+ final File suggested = outputFile;
+
+ final Diagram system = blockUml.getDiagram();
+ OptionFlags.getInstance().logData(file, system);
+
+ for (File f : PSystemUtils.exportDiagrams(system, suggested, fileFormatOption)) {
+ final String desc = "[" + file.getName() + "] " + system.getDescription();
+ final GeneratedImage generatedImage = new GeneratedImage(f, desc, blockUml);
+ result.add(generatedImage);
+ }
+
+ }
+
+ Log.info("Number of image(s): " + result.size());
+
+ return Collections.unmodifiableList(result);
+ }
+
+ public List<String> getEncodedUrl() throws IOException {
+ final List<String> result = new ArrayList<String>();
+ final Transcoder transcoder = TranscoderUtil.getDefaultTranscoder();
+ for (BlockUml blockUml : builder.getBlockUmls()) {
+ final String source = blockUml.getDiagram().getSource().getPlainString();
+ final String encoded = transcoder.encode(source);
+ result.add(encoded);
+ }
+ return Collections.unmodifiableList(result);
+ }
+
+ private Reader getReader(String charset) throws FileNotFoundException, UnsupportedEncodingException {
+ if (charset == null) {
+ Log.info("Using default charset");
+ return new InputStreamReader(new FileInputStream(file));
+ }
+ Log.info("Using charset " + charset);
+ return new InputStreamReader(new FileInputStream(file), charset);
+ }
+
+ public final void setFileFormatOption(FileFormatOption fileFormatOption) {
+ this.fileFormatOption = fileFormatOption;
+ }
+
+ public final Set<File> getIncludedFiles() {
+ return builder.getIncludedFiles();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/SourceStringReader.java b/src/net/sourceforge/plantuml/SourceStringReader.java
new file mode 100644
index 0000000..a306d44
--- /dev/null
+++ b/src/net/sourceforge/plantuml/SourceStringReader.java
@@ -0,0 +1,186 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.StringReader;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import net.sourceforge.plantuml.core.Diagram;
+import net.sourceforge.plantuml.core.DiagramDescription;
+import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.graphic.GraphicStrings;
+import net.sourceforge.plantuml.preproc.Defines;
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+import net.sourceforge.plantuml.ugraphic.ImageBuilder;
+
+public class SourceStringReader {
+
+ final private List<BlockUml> blocks;
+
+ public SourceStringReader(String source) {
+ this(new Defines(), source, Collections.<String> emptyList());
+ }
+
+ public SourceStringReader(String source, String charset) {
+ this(new Defines(), source, "UTF-8", Collections.<String> emptyList());
+ }
+
+ public SourceStringReader(Defines defines, String source, List<String> config) {
+ this(defines, source, "UTF-8", config);
+ }
+
+ public SourceStringReader(Defines defines, String source, String charset, List<String> config) {
+ // WARNING GLOBAL LOCK HERE
+ synchronized (SourceStringReader.class) {
+ try {
+ final BlockUmlBuilder builder = new BlockUmlBuilder(config, charset, defines, new StringReader(source),
+ null);
+ this.blocks = builder.getBlockUmls();
+ } catch (IOException e) {
+ Log.error("error " + e);
+ throw new IllegalStateException(e);
+ }
+ }
+ }
+
+ public String generateImage(OutputStream os) throws IOException {
+ return generateImage(os, 0);
+ }
+
+ public String generateImage(File f) throws IOException {
+ final OutputStream os = new BufferedOutputStream(new FileOutputStream(f));
+ final String result = generateImage(os, 0);
+ os.close();
+ return result;
+ }
+
+ public String generateImage(OutputStream os, FileFormatOption fileFormatOption) throws IOException {
+ return generateImage(os, 0, fileFormatOption);
+ }
+
+ public String generateImage(OutputStream os, int numImage) throws IOException {
+ return generateImage(os, numImage, new FileFormatOption(FileFormat.PNG));
+ }
+
+ public String generateImage(OutputStream os, int numImage, FileFormatOption fileFormatOption) throws IOException {
+ if (blocks.size() == 0) {
+ noStartumlFound(os, fileFormatOption);
+ return null;
+ }
+ for (BlockUml b : blocks) {
+ final Diagram system = b.getDiagram();
+ final int nbInSystem = system.getNbImages();
+ if (numImage < nbInSystem) {
+ // final CMapData cmap = new CMapData();
+ final ImageData imageData = system.exportDiagram(os, numImage, fileFormatOption);
+ if (imageData.containsCMapData()) {
+ return system.getDescription().getDescription() + "\n" + imageData.getCMapData("plantuml");
+ }
+ return system.getDescription().getDescription();
+ }
+ numImage -= nbInSystem;
+ }
+ Log.error("numImage is too big = " + numImage);
+ return null;
+
+ }
+
+ private void noStartumlFound(OutputStream os, FileFormatOption fileFormatOption) throws IOException {
+ final GraphicStrings error = GraphicStrings.createDefault(Arrays.asList("No @startuml found"),
+ fileFormatOption.isUseRedForError());
+ final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, error.getBackcolor(), null,
+ null, 0, 0, null, false);
+ imageBuilder.addUDrawable(error);
+ imageBuilder.writeImageTOBEMOVED(fileFormatOption.getFileFormat(), os);
+ }
+
+ public DiagramDescription generateDiagramDescription(OutputStream os) throws IOException {
+ return generateDiagramDescription(os, 0);
+ }
+
+ public DiagramDescription generateDiagramDescription(File f) throws IOException {
+ final OutputStream os = new BufferedOutputStream(new FileOutputStream(f));
+ final DiagramDescription result = generateDiagramDescription(os, 0);
+ os.close();
+ return result;
+ }
+
+ public DiagramDescription generateDiagramDescription(OutputStream os, FileFormatOption fileFormatOption)
+ throws IOException {
+ return generateDiagramDescription(os, 0, fileFormatOption);
+ }
+
+ public DiagramDescription generateDiagramDescription(OutputStream os, int numImage) throws IOException {
+ return generateDiagramDescription(os, numImage, new FileFormatOption(FileFormat.PNG));
+ }
+
+ public DiagramDescription generateDiagramDescription(OutputStream os, int numImage,
+ FileFormatOption fileFormatOption) throws IOException {
+ if (blocks.size() == 0) {
+ noStartumlFound(os, fileFormatOption);
+ return null;
+ }
+ for (BlockUml b : blocks) {
+ final Diagram system = b.getDiagram();
+ final int nbInSystem = system.getNbImages();
+ if (numImage < nbInSystem) {
+ // final CMapData cmap = new CMapData();
+ final ImageData imageData = system.exportDiagram(os, numImage, fileFormatOption);
+ if (imageData.containsCMapData()) {
+ return ((DiagramDescriptionImpl) system.getDescription()).withCMapData(imageData
+ .getCMapData("plantuml"));
+ }
+ return system.getDescription();
+ }
+ numImage -= nbInSystem;
+ }
+ Log.error("numImage is too big = " + numImage);
+ return null;
+
+ }
+
+ public final List<BlockUml> getBlocks() {
+ return Collections.unmodifiableList(blocks);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/SpecificBackcolorable.java b/src/net/sourceforge/plantuml/SpecificBackcolorable.java
new file mode 100644
index 0000000..1648fc4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/SpecificBackcolorable.java
@@ -0,0 +1,45 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+
+public interface SpecificBackcolorable {
+
+ public HtmlColor getSpecificBackColor();
+
+ public void setSpecificBackcolor(HtmlColor specificBackcolor);
+
+}
diff --git a/src/net/sourceforge/plantuml/SpriteContainer.java b/src/net/sourceforge/plantuml/SpriteContainer.java
new file mode 100644
index 0000000..e35dd71
--- /dev/null
+++ b/src/net/sourceforge/plantuml/SpriteContainer.java
@@ -0,0 +1,45 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import net.sourceforge.plantuml.ugraphic.Sprite;
+
+public interface SpriteContainer {
+
+ public Sprite getSprite(String name);
+
+ public boolean useGuillemet();
+
+}
diff --git a/src/net/sourceforge/plantuml/SpriteContainerEmpty.java b/src/net/sourceforge/plantuml/SpriteContainerEmpty.java
new file mode 100644
index 0000000..21421ca
--- /dev/null
+++ b/src/net/sourceforge/plantuml/SpriteContainerEmpty.java
@@ -0,0 +1,57 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import net.sourceforge.plantuml.ugraphic.Sprite;
+
+public class SpriteContainerEmpty implements SpriteContainer, ISkinSimple {
+
+ public Sprite getSprite(String name) {
+ return null;
+ }
+
+ public String getValue(String key) {
+ return null;
+ }
+
+ public double getPadding() {
+ return 0;
+ }
+
+ public boolean useGuillemet() {
+ return false;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/StringUtils.java b/src/net/sourceforge/plantuml/StringUtils.java
new file mode 100644
index 0000000..ac14e10
--- /dev/null
+++ b/src/net/sourceforge/plantuml/StringUtils.java
@@ -0,0 +1,499 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import java.awt.Color;
+import java.io.File;
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorTransparent;
+import net.sourceforge.plantuml.preproc.ReadLineReader;
+import net.sourceforge.plantuml.preproc.UncommentReadLine;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+
+// Do not move
+public class StringUtils {
+
+ public static String getPlateformDependentAbsolutePath(File file) {
+ return file.getAbsolutePath();
+ }
+
+ public static List<String> getWithNewlines2(Code s) {
+ return getWithNewlines2(s.getFullName());
+ }
+
+ public static List<String> getWithNewlines2(String s) {
+ if (s == null) {
+ return null;
+ }
+ final List<String> result = new ArrayList<String>();
+ final StringBuilder current = new StringBuilder();
+ for (int i = 0; i < s.length(); i++) {
+ final char c = s.charAt(i);
+ if (c == '\\' && i < s.length() - 1) {
+ final char c2 = s.charAt(i + 1);
+ i++;
+ if (c2 == 'n') {
+ result.add(current.toString());
+ current.setLength(0);
+ } else if (c2 == 't') {
+ current.append('\t');
+ } else if (c2 == '\\') {
+ current.append(c2);
+ }
+ } else {
+ current.append(c);
+ }
+ }
+ result.add(current.toString());
+ return Collections.unmodifiableList(result);
+ }
+
+ public static String getMergedLines(List<? extends CharSequence> strings) {
+ final StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < strings.size(); i++) {
+ sb.append(strings.get(i));
+ if (i < strings.size() - 1) {
+ sb.append("\\n");
+ }
+ }
+ return sb.toString();
+ }
+
+ final static public List<String> getSplit(Pattern pattern, String line) {
+ final Matcher m = pattern.matcher(line);
+ if (m.find() == false) {
+ return null;
+ }
+ final List<String> result = new ArrayList<String>();
+ for (int i = 1; i <= m.groupCount(); i++) {
+ result.add(m.group(i));
+ }
+ return result;
+
+ }
+
+ public static boolean isNotEmpty(String input) {
+ return input != null && input.trim().length() > 0;
+ }
+
+ public static boolean isNotEmpty(List<? extends CharSequence> input) {
+ return input != null && input.size() > 0;
+ }
+
+ public static boolean isEmpty(String input) {
+ return input == null || input.trim().length() == 0;
+ }
+
+ public static String manageHtml(String s) {
+ s = s.replace("<", "&lt;");
+ s = s.replace(">", "&gt;");
+ return s;
+ }
+
+ public static String unicode(String s) {
+ final StringBuilder result = new StringBuilder();
+ for (char c : s.toCharArray()) {
+ if (c > 127 || c == '&' || c == '|') {
+ final int i = c;
+ result.append("&#" + i + ";");
+ } else {
+ result.append(c);
+ }
+ }
+ return result.toString();
+ }
+
+ public static String unicodeForHtml(String s) {
+ final StringBuilder result = new StringBuilder();
+ for (char c : s.toCharArray()) {
+ if (c > 127 || c == '&' || c == '|' || c == '<' || c == '>') {
+ final int i = c;
+ result.append("&#" + i + ";");
+ } else {
+ result.append(c);
+ }
+ }
+ return result.toString();
+ }
+
+ public static String unicodeForHtml(Display display) {
+ final StringBuilder result = new StringBuilder();
+ for (int i = 0; i < display.size(); i++) {
+ result.append(unicodeForHtml(display.get(i).toString()));
+ if (i < display.size() - 1) {
+ result.append("<br>");
+ }
+ }
+ return result.toString();
+ }
+
+ public static String manageArrowForSequence(String s) {
+ s = s.replace('=', '-').toLowerCase();
+ return s;
+ }
+
+ public static String capitalize(String s) {
+ return s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase();
+ }
+
+ public static String goUpperCase(String s) {
+ return s.toUpperCase(Locale.ENGLISH);
+ }
+
+ public static char goUpperCase(char c) {
+ return goUpperCase("" + c).charAt(0);
+ }
+
+ public static String goLowerCase(String s) {
+ return s.toLowerCase(Locale.ENGLISH);
+ }
+
+ public static char goLowerCase(char c) {
+ return goLowerCase("" + c).charAt(0);
+ }
+
+ public static String manageArrowForCuca(String s) {
+ final Direction dir = getArrowDirection(s);
+ s = s.replace('=', '-');
+ s = s.replaceAll("\\w*", "");
+ if (dir == Direction.LEFT || dir == Direction.RIGHT) {
+ s = s.replaceAll("-+", "-");
+ }
+ if (s.length() == 2 && (dir == Direction.UP || dir == Direction.DOWN)) {
+ s = s.replaceFirst("-", "--");
+ }
+ return s;
+ }
+
+ public static String manageQueueForCuca(String s) {
+ final Direction dir = getQueueDirection(s);
+ s = s.replace('=', '-');
+ s = s.replaceAll("\\w*", "");
+ if (dir == Direction.LEFT || dir == Direction.RIGHT) {
+ s = s.replaceAll("-+", "-");
+ }
+ if (s.length() == 1 && (dir == Direction.UP || dir == Direction.DOWN)) {
+ s = s.replaceFirst("-", "--");
+ }
+ return s;
+ }
+
+ public static Direction getArrowDirection(String s) {
+ if (s.endsWith(">")) {
+ return getQueueDirection(s.substring(0, s.length() - 1));
+ }
+ if (s.startsWith("<")) {
+ if (s.length() == 2) {
+ return Direction.LEFT;
+ }
+ return Direction.UP;
+ }
+ throw new IllegalArgumentException(s);
+ }
+
+ public static Direction getQueueDirection(String s) {
+ if (s.indexOf('<') != -1 || s.indexOf('>') != -1) {
+ throw new IllegalArgumentException(s);
+ }
+ s = s.toLowerCase();
+ if (s.contains("left")) {
+ return Direction.LEFT;
+ }
+ if (s.contains("right")) {
+ return Direction.RIGHT;
+ }
+ if (s.contains("up")) {
+ return Direction.UP;
+ }
+ if (s.contains("down")) {
+ return Direction.DOWN;
+ }
+ if (s.contains("l")) {
+ return Direction.LEFT;
+ }
+ if (s.contains("r")) {
+ return Direction.RIGHT;
+ }
+ if (s.contains("u")) {
+ return Direction.UP;
+ }
+ if (s.contains("d")) {
+ return Direction.DOWN;
+ }
+ if (s.length() == 1) {
+ return Direction.RIGHT;
+ }
+ return Direction.DOWN;
+ }
+
+ // public static Code eventuallyRemoveStartingAndEndingDoubleQuote(Code s) {
+ // return Code.of(eventuallyRemoveStartingAndEndingDoubleQuote(s.getCode()));
+ // }
+
+ public static String eventuallyRemoveStartingAndEndingDoubleQuote(String s, String format) {
+ if (format.contains("\"") && s.length() > 1 && isDoubleQuote(s.charAt(0))
+ && isDoubleQuote(s.charAt(s.length() - 1))) {
+ return s.substring(1, s.length() - 1);
+ }
+ if (format.contains("(") && s.startsWith("(") && s.endsWith(")")) {
+ return s.substring(1, s.length() - 1);
+ }
+ if (format.contains("[") && s.startsWith("[") && s.endsWith("]")) {
+ return s.substring(1, s.length() - 1);
+ }
+ if (format.contains(":") && s.startsWith(":") && s.endsWith(":")) {
+ return s.substring(1, s.length() - 1);
+ }
+ return s;
+ }
+
+ public static String eventuallyRemoveStartingAndEndingDoubleQuote(String s) {
+ return eventuallyRemoveStartingAndEndingDoubleQuote(s, "\"([:");
+ }
+
+ private static boolean isDoubleQuote(char c) {
+ return c == '\"' || c == '\u201c' || c == '\u201d' || c == '\u00ab' || c == '\u00bb';
+ }
+
+ public static boolean isCJK(char c) {
+ final Character.UnicodeBlock block = Character.UnicodeBlock.of(c);
+ Log.println("block=" + block);
+ return false;
+ }
+
+ public static char hiddenLesserThan() {
+ return '\u0005';
+ }
+
+ public static char hiddenBiggerThan() {
+ return '\u0006';
+ }
+
+ public static String hideComparatorCharacters(String s) {
+ s = s.replace('<', hiddenLesserThan());
+ s = s.replace('>', hiddenBiggerThan());
+ return s;
+ }
+
+ public static String showComparatorCharacters(String s) {
+ s = s.replace(hiddenLesserThan(), '<');
+ s = s.replace(hiddenBiggerThan(), '>');
+ return s;
+ }
+
+ public static int getWidth(List<? extends CharSequence> stringsToDisplay) {
+ int result = 1;
+ for (CharSequence s : stringsToDisplay) {
+ if (result < s.length()) {
+ result = s.length();
+ }
+ }
+ return result;
+ }
+
+ public static int getWidth(Display stringsToDisplay) {
+ int result = 1;
+ for (CharSequence s : stringsToDisplay) {
+ if (result < s.length()) {
+ result = s.length();
+ }
+ }
+ return result;
+ }
+
+ public static int getHeight(List<? extends CharSequence> stringsToDisplay) {
+ return stringsToDisplay.size();
+ }
+
+ public static int getHeight(Display stringsToDisplay) {
+ return stringsToDisplay.size();
+ }
+
+ private static void removeFirstColumn(List<String> data) {
+ for (int i = 0; i < data.size(); i++) {
+ final String s = data.get(i);
+ if (s.length() > 0) {
+ data.set(i, s.substring(1));
+ }
+ }
+ }
+
+ private static boolean firstColumnRemovable(List<String> data) {
+ boolean allEmpty = true;
+ for (String s : data) {
+ if (s.length() == 0) {
+ continue;
+ }
+ allEmpty = false;
+ final char c = s.charAt(0);
+ if (c != ' ' && c != '\t') {
+ return false;
+ }
+ }
+ return allEmpty == false;
+ }
+
+ public static List<String> removeEmptyColumns(List<String> data) {
+ if (firstColumnRemovable(data) == false) {
+ return data;
+ }
+ final List<String> result = new ArrayList<String>(data);
+ do {
+ removeFirstColumn(result);
+ } while (firstColumnRemovable(result));
+ return result;
+ }
+
+ public static void trim(List<String> data, boolean removeEmptyLines) {
+ for (int i = 0; i < data.size(); i++) {
+ final String s = data.get(i);
+ data.set(i, s.trim());
+ }
+ if (removeEmptyLines) {
+ for (final Iterator<String> it = data.iterator(); it.hasNext();) {
+ if (it.next().length() == 0) {
+ it.remove();
+ }
+ }
+ }
+ }
+
+ public static String uncommentSource(String source) {
+ final StringReader sr = new StringReader(source);
+ final UncommentReadLine un = new UncommentReadLine(new ReadLineReader(sr));
+ final StringBuilder sb = new StringBuilder();
+ String s = null;
+ try {
+ while ((s = un.readLine()) != null) {
+ sb.append(s);
+ sb.append('\n');
+ }
+ } catch (IOException e) {
+ Log.error("Error " + e);
+ throw new IllegalStateException(e.toString());
+ }
+
+ sr.close();
+ return sb.toString();
+ }
+
+ public static boolean isDiagramCacheable(String uml) {
+ uml = uml.toLowerCase();
+ if (uml.startsWith("@startuml\nversion\n")) {
+ return false;
+ }
+ if (uml.startsWith("@startuml\ncheckversion")) {
+ return false;
+ }
+ if (uml.startsWith("@startuml\ntestdot\n")) {
+ return false;
+ }
+ if (uml.startsWith("@startuml\nsudoku\n")) {
+ return false;
+ }
+ return true;
+ }
+
+ public static List<String> splitComma(String s) {
+ s = s.trim();
+ // if (s.matches("([\\p{L}0-9_.]+|[%g][^%g]+[%g])(\\s*,\\s*([\\p{L}0-9_.]+|[%g][^%g]+[%g]))*") == false) {
+ // throw new IllegalArgumentException();
+ // }
+ final List<String> result = new ArrayList<String>();
+ final Pattern p = MyPattern.cmpile("([\\p{L}0-9_.]+|[%g][^%g]+[%g])");
+ final Matcher m = p.matcher(s);
+ while (m.find()) {
+ result.add(eventuallyRemoveStartingAndEndingDoubleQuote(m.group(0)));
+ }
+ return Collections.unmodifiableList(result);
+ }
+
+ public static String getAsHtml(Color color) {
+ if (color == null) {
+ return null;
+ }
+ return getAsHtml(color.getRGB());
+ }
+
+ public static String getAsSvg(ColorMapper mapper, HtmlColor color) {
+ if (color == null) {
+ return "none";
+ }
+ if (color instanceof HtmlColorTransparent) {
+ return "#FFFFFF";
+ }
+ return getAsHtml(mapper.getMappedColor(color));
+ }
+
+ public static String getAsHtml(int color) {
+ final int v = 0xFFFFFF & color;
+ String s = "000000" + Integer.toHexString(v).toUpperCase();
+ s = s.substring(s.length() - 6);
+ return "#" + s;
+ }
+
+ public static String getUid(String uid1, int uid2) {
+ return uid1 + String.format("%04d", uid2);
+ }
+
+ public static boolean isMethod(String s) {
+ return s.contains("(") || s.contains(")");
+ }
+
+ public static <O> List<O> merge(List<O> l1, List<O> l2) {
+ final List<O> result = new ArrayList<O>(l1);
+ result.addAll(l2);
+ return Collections.unmodifiableList(result);
+ }
+
+ public static boolean endsWithBackslash(final String s) {
+ return s.endsWith("\\") && s.endsWith("\\\\") == false;
+ }
+
+ // http://docs.oracle.com/javase/tutorial/i18n/format/dateFormat.html
+}
diff --git a/src/net/sourceforge/plantuml/UmlDiagram.java b/src/net/sourceforge/plantuml/UmlDiagram.java
new file mode 100644
index 0000000..02b9a0f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/UmlDiagram.java
@@ -0,0 +1,430 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import java.awt.Font;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Dimension2D;
+import java.awt.image.BufferedImage;
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.imageio.ImageIO;
+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.core.Diagram;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.core.UmlSource;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.UnparsableGraphvizException;
+import net.sourceforge.plantuml.flashcode.FlashCodeFactory;
+import net.sourceforge.plantuml.flashcode.FlashCodeUtils;
+import net.sourceforge.plantuml.fun.IconLoader;
+import net.sourceforge.plantuml.graphic.GraphicPosition;
+import net.sourceforge.plantuml.graphic.GraphicStrings;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.QuoteUtils;
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.graphic.VerticalAlignment;
+import net.sourceforge.plantuml.mjpeg.MJPEGGenerator;
+import net.sourceforge.plantuml.pdf.PdfConverter;
+import net.sourceforge.plantuml.svek.EmptySvgException;
+import net.sourceforge.plantuml.svek.GraphvizCrash;
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+import net.sourceforge.plantuml.ugraphic.ImageBuilder;
+import net.sourceforge.plantuml.ugraphic.Sprite;
+import net.sourceforge.plantuml.ugraphic.UAntiAliasing;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UImage;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+import net.sourceforge.plantuml.version.Version;
+
+public abstract class UmlDiagram extends AbstractPSystem implements Diagram {
+
+ private boolean rotation;
+ private boolean hideUnlinkedData;
+
+ private int minwidth = Integer.MAX_VALUE;
+
+ private Display title;
+ private Display header;
+ private Display footer;
+ private Display legend = null;
+ private HorizontalAlignment legendAlignment = HorizontalAlignment.CENTER;
+ private VerticalAlignment legendVerticalAlignment = VerticalAlignment.BOTTOM;
+
+ private HorizontalAlignment headerAlignment = HorizontalAlignment.RIGHT;
+ private HorizontalAlignment footerAlignment = HorizontalAlignment.CENTER;
+ private final Pragma pragma = new Pragma();
+ private Scale scale;
+ private Animation animation;
+
+ private final SkinParam skinParam = new SkinParam();
+
+ final public void setTitle(Display strings) {
+ this.title = strings;
+ }
+
+ final public Display getTitle() {
+ return title;
+ }
+
+ final public int getMinwidth() {
+ return minwidth;
+ }
+
+ final public void setMinwidth(int minwidth) {
+ this.minwidth = minwidth;
+ }
+
+ final public boolean isRotation() {
+ return rotation;
+ }
+
+ final public void setRotation(boolean rotation) {
+ this.rotation = rotation;
+ }
+
+ public final ISkinParam getSkinParam() {
+ return skinParam;
+ }
+
+ public void setParam(String key, String value) {
+ skinParam.setParam(StringUtils.goLowerCase(key), value);
+ }
+
+ public final Display getHeader() {
+ return header;
+ }
+
+ public final void setHeader(Display header) {
+ this.header = header;
+ }
+
+ public final Display getFooter() {
+ return footer;
+ }
+
+ public final void setFooter(Display footer) {
+ this.footer = footer;
+ }
+
+ public final HorizontalAlignment getHeaderAlignment() {
+ return headerAlignment;
+ }
+
+ public final void setHeaderAlignment(HorizontalAlignment headerAlignment) {
+ this.headerAlignment = headerAlignment;
+ }
+
+ public final HorizontalAlignment getFooterAlignment() {
+ return footerAlignment;
+ }
+
+ public final void setFooterAlignment(HorizontalAlignment footerAlignment) {
+ this.footerAlignment = footerAlignment;
+ }
+
+ abstract public UmlDiagramType getUmlDiagramType();
+
+ public Pragma getPragma() {
+ return pragma;
+ }
+
+ final public void setScale(Scale scale) {
+ this.scale = scale;
+ }
+
+ final public Scale getScale() {
+ return scale;
+ }
+
+ final public void setAnimation(List<String> animationData) {
+ try {
+ final AnimationDecoder animationDecoder = new AnimationDecoder(animationData);
+ this.animation = Animation.create(animationDecoder.decode());
+ } catch (ScriptException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ final public Animation getAnimation() {
+ return animation;
+ }
+
+ public final double getDpiFactor(FileFormatOption fileFormatOption) {
+ if (getSkinParam().getDpi() == 96) {
+ return 1.0;
+ }
+ return getSkinParam().getDpi() / 96.0;
+ }
+
+ public final int getDpi(FileFormatOption fileFormatOption) {
+ return getSkinParam().getDpi();
+ }
+
+ public final boolean isHideUnlinkedData() {
+ return hideUnlinkedData;
+ }
+
+ public final void setHideUnlinkedData(boolean hideUnlinkedData) {
+ this.hideUnlinkedData = hideUnlinkedData;
+ }
+
+ final public ImageData exportDiagram(OutputStream os, int index, FileFormatOption fileFormatOption)
+ throws IOException {
+
+ if (fileFormatOption.getFileFormat() == FileFormat.PDF) {
+ return exportDiagramInternalPdf(os, index);
+ }
+
+ try {
+ final ImageData imageData = exportDiagramInternal(os, index, fileFormatOption);
+ this.lastInfo = new Dimension2DDouble(imageData.getWidth(), imageData.getHeight());
+ return imageData;
+ } catch (UnparsableGraphvizException e) {
+ e.printStackTrace();
+ exportDiagramError(os, e.getCause(), fileFormatOption, e.getGraphvizVersion(), e.getDebugData());
+ } catch (Exception e) {
+ e.printStackTrace();
+ exportDiagramError(os, e, fileFormatOption, null, null);
+ }
+ return new ImageDataSimple();
+
+ }
+
+ private void exportDiagramError(OutputStream os, Throwable exception, FileFormatOption fileFormat,
+ String graphvizVersion, String svg) throws IOException {
+ final UFont font = new UFont("SansSerif", Font.PLAIN, 12);
+ final List<String> strings = getFailureText(exception, graphvizVersion);
+
+ final String flash = getFlashData();
+ for (StackTraceElement ste : exception.getStackTrace()) {
+ strings.add(" " + ste.toString());
+ }
+ if (exception.getCause() != null) {
+ final Throwable cause = exception.getCause();
+ strings.add(" ");
+ strings.add("Caused by " + cause.toString());
+ for (StackTraceElement ste : cause.getStackTrace()) {
+ strings.add(" " + ste.toString());
+ }
+
+ }
+
+ final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, HtmlColorUtils.WHITE,
+ getMetadata(), null, 0, 0, null, getSkinParam().handwritten());
+
+ final FlashCodeUtils utils = FlashCodeFactory.getFlashCodeUtils();
+ final BufferedImage im = utils.exportFlashcode(flash);
+ if (im != null) {
+ GraphvizCrash.addDecodeHint(strings);
+ }
+
+ final GraphicStrings graphicStrings = new GraphicStrings(strings, font, HtmlColorUtils.BLACK,
+ HtmlColorUtils.WHITE, UAntiAliasing.ANTI_ALIASING_ON, IconLoader.getRandom(),
+ GraphicPosition.BACKGROUND_CORNER_TOP_RIGHT);
+
+ if (im == null) {
+ imageBuilder.addUDrawable(graphicStrings);
+ } else {
+ imageBuilder.addUDrawable(new UDrawable() {
+ public void drawU(UGraphic ug) {
+ graphicStrings.drawU(ug);
+ final double height = graphicStrings.calculateDimension(ug.getStringBounder()).getHeight();
+ ug = ug.apply(new UTranslate(0, height));
+ ug.draw(new UImage(im));
+ }
+ });
+ }
+ imageBuilder.writeImageTOBEMOVED(fileFormat.getFileFormat(), os);
+ }
+
+ private String getFlashData() {
+ // for (Map.Entry<Object, Object> ent : System.getProperties().entrySet()) {
+ // System.err.println("p1=" + ent.getKey() + " " + ent.getValue());
+ // }
+ final StringBuilder result = new StringBuilder();
+ final UmlSource source = getSource();
+ result.append(source.getPlainString());
+ return result.toString();
+ }
+
+ private List<String> getFailureText(Throwable exception, String graphvizVersion) {
+ final List<String> strings = new ArrayList<String>();
+ strings.add("An error has occured : " + exception);
+ final String quote = QuoteUtils.getSomeQuote();
+ strings.add("<i>" + quote);
+ strings.add(" ");
+ strings.add("PlantUML (" + Version.versionString() + ") cannot parse result from dot/GraphViz.");
+ if (exception instanceof EmptySvgException) {
+ strings.add("Because dot/GraphViz returns an empty string.");
+ }
+ if (graphvizVersion != null) {
+ strings.add(" ");
+ strings.add("GraphViz version used : " + graphvizVersion);
+ }
+ strings.add(" ");
+ GraphvizCrash.addProperties(strings);
+ strings.add(" ");
+ strings.add("This may be caused by :");
+ strings.add(" - a bug in PlantUML");
+ strings.add(" - a problem in GraphViz");
+ strings.add(" ");
+ strings.add("You should send this diagram and this image to <b>plantuml@gmail.com</b> to solve this issue.");
+ strings.add("You can try to turn arround this issue by simplifing your diagram.");
+ strings.add(" ");
+ strings.add(exception.toString());
+ return strings;
+ }
+
+ private void exportDiagramInternalMjpeg(OutputStream os) throws IOException {
+ final File f = new File("c:/test.avi");
+ final int nb = 150;
+ final double framerate = 30;
+ final MJPEGGenerator m = new MJPEGGenerator(f, 640, 480, framerate, nb);
+
+ for (int i = 0; i < nb; i++) {
+ final AffineTransform at = new AffineTransform();
+ final double coef = (nb - 1 - i) * 1.0 / nb;
+ at.setToShear(coef, coef);
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ // exportDiagramTOxxBEREMOVED(baos, null, 0, new FileFormatOption(FileFormat.PNG, at));
+ baos.close();
+ final BufferedImage im = ImageIO.read(new ByteArrayInputStream(baos.toByteArray()));
+ m.addImage(im);
+ }
+ m.finishAVI();
+
+ }
+
+ private Dimension2D lastInfo;
+
+ private ImageData exportDiagramInternalPdf(OutputStream os, int index) throws IOException {
+ final File svg = FileUtils.createTempFile("pdf", ".svf");
+ final File pdfFile = FileUtils.createTempFile("pdf", ".pdf");
+ final OutputStream fos = new BufferedOutputStream(new FileOutputStream(svg));
+ final ImageData result = exportDiagram(fos, index, new FileFormatOption(FileFormat.SVG));
+ fos.close();
+ PdfConverter.convert(svg, pdfFile);
+ FileUtils.copyToStream(pdfFile, os);
+ return result;
+ }
+
+ protected abstract ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
+ throws IOException;
+
+ final protected void exportCmap(File suggestedFile, final ImageData cmapdata) throws FileNotFoundException {
+ final String name = changeName(suggestedFile.getAbsolutePath());
+ final File cmapFile = new File(name);
+ PrintWriter pw = null;
+ try {
+ if (PSystemUtils.canFileBeWritten(cmapFile) == false) {
+ return;
+ }
+ pw = new PrintWriter(cmapFile);
+ pw.print(cmapdata.getCMapData(cmapFile.getName().substring(0, cmapFile.getName().length() - 6)));
+ pw.close();
+ } finally {
+ if (pw != null) {
+ pw.close();
+ }
+ }
+ }
+
+ static String changeName(String name) {
+ return name.replaceAll("(?i)\\.\\w{3}$", ".cmapx");
+ }
+
+ @Override
+ public String getWarningOrError() {
+ if (lastInfo == null) {
+ return null;
+ }
+ final double actualWidth = lastInfo.getWidth();
+ if (actualWidth == 0) {
+ return null;
+ }
+ final String value = getSkinParam().getValue("widthwarning");
+ if (value == null) {
+ return null;
+ }
+ if (value.matches("\\d+") == false) {
+ return null;
+ }
+ final int widthwarning = Integer.parseInt(value);
+ if (actualWidth > widthwarning) {
+ return "The image is " + ((int) actualWidth) + " pixel width. (Warning limit is " + widthwarning + ")";
+ }
+ return null;
+ }
+
+ public void addSprite(String name, Sprite sprite) {
+ skinParam.addSprite(name, sprite);
+ }
+
+ public final Display getLegend() {
+ return legend;
+ }
+
+ public final HorizontalAlignment getLegendAlignment() {
+ return legendAlignment;
+ }
+
+ public final VerticalAlignment getLegendVerticalAlignment() {
+ return legendVerticalAlignment;
+ }
+
+ public final void setLegend(Display legend, HorizontalAlignment horizontalAlignment, VerticalAlignment valignment) {
+ this.legend = legend;
+ this.legendAlignment = horizontalAlignment;
+ this.legendVerticalAlignment = valignment;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/UmlDiagramType.java b/src/net/sourceforge/plantuml/UmlDiagramType.java
new file mode 100644
index 0000000..301ee57
--- /dev/null
+++ b/src/net/sourceforge/plantuml/UmlDiagramType.java
@@ -0,0 +1,39 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+public enum UmlDiagramType {
+ SEQUENCE, STATE, CLASS, OBJECT, ACTIVITY, DESCRIPTION, COMPOSITE, FLOW
+}
diff --git a/src/net/sourceforge/plantuml/Url.java b/src/net/sourceforge/plantuml/Url.java
new file mode 100644
index 0000000..f181637
--- /dev/null
+++ b/src/net/sourceforge/plantuml/Url.java
@@ -0,0 +1,120 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import java.util.Comparator;
+
+import net.sourceforge.plantuml.cucadiagram.dot.DotMaker2;
+
+public class Url implements EnsureVisible {
+
+ private final String url;
+ private final String tooltip;
+ private final String label;
+ private boolean member;
+
+ public Url(String url, String tooltip) {
+ this(url, tooltip, null);
+ }
+
+ public Url(String url, String tooltip, String label) {
+ if (url.contains("{")) {
+ throw new IllegalArgumentException(url);
+ }
+ this.url = url;
+ if (tooltip == null) {
+ this.tooltip = url;
+ } else {
+ this.tooltip = tooltip;
+ }
+ if (label == null) {
+ this.label = url;
+ } else {
+ this.label = label;
+ }
+ }
+
+ public final String getUrl() {
+ return url;
+ }
+
+ public final String getTooltip() {
+ return tooltip;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + " " + url + " " + visible.getCoords(1.0);
+ }
+
+ public String getCoords(double scale) {
+ if (DotMaker2.isJunit() && visible.getCoords(1.0).contains("0,0,0,0")) {
+ throw new IllegalStateException();
+ }
+ return visible.getCoords(scale);
+ }
+
+ public void setMember(boolean member) {
+ this.member = member;
+ }
+
+ public final boolean isMember() {
+ return member;
+ }
+
+ private final BasicEnsureVisible visible = new BasicEnsureVisible();
+
+ public void ensureVisible(double x, double y) {
+ visible.ensureVisible(x, y);
+ }
+
+ public static final Comparator<Url> SURFACE_COMPARATOR = new Comparator<Url>() {
+ public int compare(Url url1, Url url2) {
+ final double surface1 = url1.visible.getSurface();
+ final double surface2 = url2.visible.getSurface();
+ if (surface1 > surface2) {
+ return 1;
+ } else if (surface1 < surface2) {
+ return -1;
+ }
+ return 0;
+ }
+ };
+
+}
diff --git a/src/net/sourceforge/plantuml/UrlBuilder.java b/src/net/sourceforge/plantuml/UrlBuilder.java
new file mode 100644
index 0000000..2ab4865
--- /dev/null
+++ b/src/net/sourceforge/plantuml/UrlBuilder.java
@@ -0,0 +1,100 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+
+public class UrlBuilder {
+
+ public static enum ModeUrl {
+ STRICT, AT_START, ANYWHERE, AT_END
+ }
+
+ private static final String URL_PATTERN = "\\[\\[([%g][^%g]+[%g]|[^{}%s\\]\\[]*)(?:[%s]*\\{([^{}]+)\\})?(?:[%s]*([^\\]\\[]+))?\\]\\]";
+
+ private final String topurl;
+ private ModeUrl mode;
+
+ public UrlBuilder(String topurl, ModeUrl mode) {
+ this.topurl = topurl;
+ this.mode = mode;
+ }
+
+ public Url getUrl(String s) {
+ final Pattern p;
+ if (mode == ModeUrl.STRICT) {
+ p = MyPattern.cmpile("(?i)^" + URL_PATTERN + "$");
+ } else if (mode == ModeUrl.AT_START) {
+ p = MyPattern.cmpile("(?i)^" + URL_PATTERN + ".*");
+ } else if (mode == ModeUrl.AT_END) {
+ p = MyPattern.cmpile("(?i).*" + URL_PATTERN + "$");
+ } else if (mode == ModeUrl.ANYWHERE) {
+ p = MyPattern.cmpile("(?i).*" + URL_PATTERN + ".*");
+ } else {
+ throw new IllegalStateException();
+ }
+ final Matcher m = p.matcher(s.trim());
+ if (m.matches() == false) {
+ return null;
+ }
+ String url = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(m.group(1));
+ if (url.startsWith("http:") == false && url.startsWith("https:") == false) {
+ // final String top = getSystem().getSkinParam().getValue("topurl");
+ if (topurl != null) {
+ url = topurl + url;
+ }
+ }
+ return new Url(url, m.group(2), m.group(3));
+ }
+
+ public static String getRegexp() {
+ return URL_PATTERN;
+ }
+
+ public static String purgeUrl(final String label) {
+ final Pattern p = MyPattern.cmpile("[%s]*" + URL_PATTERN + "[%s]*");
+ final Matcher m = p.matcher(label);
+ if (m.find() == false) {
+ throw new IllegalStateException();
+ }
+ final String url = m.group(0);
+ final int x = label.indexOf(url);
+ return label.substring(0, x) + label.substring(x + url.length());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram/ActivityDiagram.java b/src/net/sourceforge/plantuml/activitydiagram/ActivityDiagram.java
new file mode 100644
index 0000000..f124580
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram/ActivityDiagram.java
@@ -0,0 +1,183 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram;
+
+import java.util.Arrays;
+import java.util.List;
+
+import net.sourceforge.plantuml.Direction;
+import net.sourceforge.plantuml.UmlDiagramType;
+import net.sourceforge.plantuml.core.DiagramDescription;
+import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.GroupType;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+import net.sourceforge.plantuml.graphic.USymbol;
+import net.sourceforge.plantuml.utils.UniqueSequence;
+
+public class ActivityDiagram extends CucaDiagram {
+
+ private IEntity lastEntityConsulted;
+ private IEntity lastEntityBrancheConsulted;
+ private ConditionalContext currentContext;
+
+ public ILeaf getOrCreateLeaf(Code code, LeafType type, USymbol symbol) {
+ return getOrCreateLeafDefault(code, type, symbol);
+ }
+
+ private String getAutoBranch() {
+ return "#" + UniqueSequence.getValue();
+ }
+
+ public IEntity getOrCreate(Code code, Display display, LeafType type) {
+ final IEntity result;
+ if (leafExist(code)) {
+ result = getOrCreateLeafDefault(code, type, null);
+ if (result.getEntityType() != type) {
+ // throw new IllegalArgumentException("Already known: " + code + " " + result.getType() + " " + type);
+ return null;
+ }
+ } else {
+ result = createLeaf(code, display, type, null);
+ }
+ updateLasts(result);
+ return result;
+ }
+
+ public void startIf(Code optionalCode) {
+ final IEntity br = createLeaf(optionalCode == null ? Code.of(getAutoBranch()) : optionalCode,
+ Display.create(""), LeafType.BRANCH, null);
+ currentContext = new ConditionalContext(currentContext, br, Direction.DOWN);
+ }
+
+ public void endif() {
+ currentContext = currentContext.getParent();
+ }
+
+ public ILeaf getStart() {
+ return (ILeaf) getOrCreate(Code.of("start"), Display.getWithNewlines("start"), LeafType.CIRCLE_START);
+ }
+
+ public ILeaf getEnd(String suppId) {
+ final Code code = suppId == null ? Code.of("end") : Code.of("end$" + suppId);
+ return (ILeaf) getOrCreate(code, Display.getWithNewlines("end"), LeafType.CIRCLE_END);
+ }
+
+ private void updateLasts(final IEntity result) {
+ if (result.getEntityType() == LeafType.NOTE) {
+ return;
+ }
+ this.lastEntityConsulted = result;
+ if (result.getEntityType() == LeafType.BRANCH) {
+ lastEntityBrancheConsulted = result;
+ }
+ }
+
+ @Override
+ public ILeaf createLeaf(Code code, Display display, LeafType type, USymbol symbol) {
+ final ILeaf result = super.createLeaf(code, display, type, symbol);
+ updateLasts(result);
+ return result;
+ }
+
+ public IEntity createNote(Code code, Display display) {
+ return super.createLeaf(code, display, LeafType.NOTE, null);
+ }
+
+ final protected List<String> getDotStrings() {
+ return Arrays.asList("nodesep=.20;", "ranksep=0.4;", "edge [fontsize=11,labelfontsize=11];",
+ "node [fontsize=11];");
+ }
+
+ public DiagramDescription getDescription() {
+ return new DiagramDescriptionImpl("(" + getLeafssize() + " activities)", getClass());
+ }
+
+ public IEntity getLastEntityConsulted() {
+ return lastEntityConsulted;
+ }
+
+ @Deprecated
+ public IEntity getLastEntityBrancheConsulted() {
+ return lastEntityBrancheConsulted;
+ }
+
+ @Override
+ public UmlDiagramType getUmlDiagramType() {
+ return UmlDiagramType.ACTIVITY;
+ }
+
+ public final ConditionalContext getCurrentContext() {
+ return currentContext;
+ }
+
+ public final void setLastEntityConsulted(IEntity lastEntityConsulted) {
+ this.lastEntityConsulted = lastEntityConsulted;
+ }
+
+ public IEntity createInnerActivity() {
+ // Log.println("createInnerActivity A");
+ final Code code = Code.of("##" + UniqueSequence.getValue());
+ final IEntity g = getOrCreateGroup(code, Display.getWithNewlines(code), GroupType.INNER_ACTIVITY,
+ getCurrentGroup());
+ // g.setRankdir(Rankdir.LEFT_TO_RIGHT);
+ lastEntityConsulted = null;
+ lastEntityBrancheConsulted = null;
+ // Log.println("createInnerActivity B "+getCurrentGroup());
+ return g;
+ }
+
+ public void concurrentActivity(String name) {
+ // Log.println("concurrentActivity A name=" + name+" "+getCurrentGroup());
+ if (getCurrentGroup().getGroupType() == GroupType.CONCURRENT_ACTIVITY) {
+ // getCurrentGroup().setRankdir(Rankdir.LEFT_TO_RIGHT);
+ endGroup();
+ // Log.println("endgroup");
+ }
+ // Log.println("concurrentActivity A name=" + name+" "+getCurrentGroup());
+ final Code code = Code.of("##" + UniqueSequence.getValue());
+ if (getCurrentGroup().getGroupType() != GroupType.INNER_ACTIVITY) {
+ throw new IllegalStateException("type=" + getCurrentGroup().getGroupType());
+ }
+ getOrCreateGroup(code, Display.getWithNewlines("code"), GroupType.CONCURRENT_ACTIVITY, getCurrentGroup());
+ lastEntityConsulted = null;
+ lastEntityBrancheConsulted = null;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram/ActivityDiagramFactory.java b/src/net/sourceforge/plantuml/activitydiagram/ActivityDiagramFactory.java
new file mode 100644
index 0000000..3a7dba8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram/ActivityDiagramFactory.java
@@ -0,0 +1,91 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.activitydiagram.command.CommandElse;
+import net.sourceforge.plantuml.activitydiagram.command.CommandEndPartition;
+import net.sourceforge.plantuml.activitydiagram.command.CommandEndif;
+import net.sourceforge.plantuml.activitydiagram.command.CommandIf;
+import net.sourceforge.plantuml.activitydiagram.command.CommandLinkActivity;
+import net.sourceforge.plantuml.activitydiagram.command.CommandLinkLongActivity2;
+import net.sourceforge.plantuml.activitydiagram.command.CommandPartition;
+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.note.FactoryNoteActivityCommand;
+import net.sourceforge.plantuml.command.note.FactoryNoteOnLinkCommand;
+
+public class ActivityDiagramFactory extends UmlDiagramFactory {
+
+ @Override
+ public ActivityDiagram createEmptyDiagram() {
+ return new ActivityDiagram();
+ }
+
+ @Override
+ protected List<Command> createCommands() {
+ final List<Command> cmds = new ArrayList<Command>();
+ cmds.add(new CommandFootboxIgnored());
+ addCommonCommands(cmds);
+ cmds.add(new CommandRankDir());
+
+ cmds.add(new CommandPartition());
+ cmds.add(new CommandEndPartition());
+ cmds.add(new CommandLinkLongActivity2());
+
+ final FactoryNoteActivityCommand factoryNoteActivityCommand = new FactoryNoteActivityCommand();
+ cmds.add(factoryNoteActivityCommand.createSingleLine());
+ cmds.add(factoryNoteActivityCommand.createMultiLine());
+
+ final FactoryNoteOnLinkCommand factoryNoteOnLinkCommand = new FactoryNoteOnLinkCommand();
+ cmds.add(factoryNoteOnLinkCommand.createSingleLine());
+ cmds.add(factoryNoteOnLinkCommand.createMultiLine());
+
+ cmds.add(new CommandIf());
+ cmds.add(new CommandElse());
+ cmds.add(new CommandEndif());
+
+ cmds.add(new CommandLinkActivity());
+ // addCommand(new CommandInnerConcurrent(system));
+
+ return cmds;
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram/ConditionalContext.java b/src/net/sourceforge/plantuml/activitydiagram/ConditionalContext.java
new file mode 100644
index 0000000..20cba23
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram/ConditionalContext.java
@@ -0,0 +1,68 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram;
+
+import net.sourceforge.plantuml.Direction;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+
+public class ConditionalContext {
+
+ private final IEntity branch;
+ private final Direction direction;
+ private final ConditionalContext parent;
+
+ public ConditionalContext(ConditionalContext parent, IEntity branch, Direction direction) {
+ if (branch.getEntityType() != LeafType.BRANCH) {
+ throw new IllegalArgumentException();
+ }
+ this.branch = branch;
+ this.direction = direction;
+ this.parent = parent;
+ }
+
+ public Direction getDirection() {
+ return direction;
+ }
+
+ public final ConditionalContext getParent() {
+ return parent;
+ }
+
+ public final IEntity getBranch() {
+ return branch;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandElse.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandElse.java
new file mode 100644
index 0000000..031a2a1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandElse.java
@@ -0,0 +1,65 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.activitydiagram.ActivityDiagram;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+
+public class CommandElse extends SingleLineCommand<ActivityDiagram> {
+
+ public CommandElse() {
+ super("(?i)^else$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram system, List<String> arg) {
+ if (system.getLastEntityConsulted() == null) {
+ return CommandExecutionResult.error("No if for this else");
+ }
+ if (system.getCurrentContext() == null) {
+ return CommandExecutionResult.error("No if for this else");
+ }
+ final IEntity branch = system.getCurrentContext().getBranch();
+
+ system.setLastEntityConsulted(branch);
+
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandEndPartition.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandEndPartition.java
new file mode 100644
index 0000000..a9ce25c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandEndPartition.java
@@ -0,0 +1,60 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.activitydiagram.ActivityDiagram;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+
+public class CommandEndPartition extends SingleLineCommand<ActivityDiagram> {
+
+ public CommandEndPartition() {
+ super("(?i)^(end[%s]?partition|\\})$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram diagram, List<String> arg) {
+ final IEntity currentPackage = diagram.getCurrentGroup();
+ if (currentPackage == null) {
+ return CommandExecutionResult.error("No partition defined");
+ }
+ diagram.endGroup();
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandEndif.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandEndif.java
new file mode 100644
index 0000000..ed0ca2c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandEndif.java
@@ -0,0 +1,62 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.activitydiagram.ActivityDiagram;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+
+public class CommandEndif extends SingleLineCommand<ActivityDiagram> {
+
+ public CommandEndif() {
+ super("(?i)^end[%s]?if$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram diagram, List<String> arg) {
+ if (diagram.getLastEntityConsulted() == null) {
+ return CommandExecutionResult.error("No if for this endif");
+ }
+ if (diagram.getCurrentContext() == null) {
+ return CommandExecutionResult.error("No if for this endif");
+ }
+ diagram.endif();
+
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandIf.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandIf.java
new file mode 100644
index 0000000..8fd2456
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandIf.java
@@ -0,0 +1,121 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram.command;
+
+import net.sourceforge.plantuml.Direction;
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.activitydiagram.ActivityDiagram;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexOptional;
+import net.sourceforge.plantuml.command.regex.RegexOr;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.cucadiagram.LinkDecor;
+import net.sourceforge.plantuml.cucadiagram.LinkType;
+
+public class CommandIf extends SingleLineCommand2<ActivityDiagram> {
+
+ public CommandIf() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexOptional(//
+ new RegexOr("FIRST", //
+ new RegexLeaf("STAR", "(\\(\\*(top)?\\))"), //
+ new RegexLeaf("CODE", "([\\p{L}0-9_.]+)"), //
+ new RegexLeaf("BAR", "(?:==+)[%s]*([\\p{L}0-9_.]+)[%s]*(?:==+)"), //
+ new RegexLeaf("QUOTED", "[%g]([^%g]+)[%g](?:[%s]+as[%s]+([\\p{L}0-9_.]+))?"))), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("ARROW", "([=-]+(?:(left|right|up|down|le?|ri?|up?|do?)(?=[-=.]))?[=-]*\\>)?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("BRACKET", "(?:\\[([^\\]*]+[^\\]]*)\\])?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexOr(//
+ new RegexLeaf("IF1", "if[%s]*[%g]([^%g]*)[%g][%s]*(?:as[%s]+([\\p{L}0-9_.]+)[%s]+)?"), //
+ new RegexLeaf("IF2", "if[%s]+(.+?)[%s]*")), //
+ new RegexLeaf("(?:then)?$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram system, RegexResult arg) {
+ final IEntity entity1 = CommandLinkActivity.getEntity(system, arg, true);
+ if (entity1 == null) {
+ return CommandExecutionResult.error("No if possible at this point");
+ }
+
+ final String ifCode;
+ final String ifLabel;
+ if (arg.get("IF2", 0) == null) {
+ ifCode = arg.get("IF1", 1);
+ ifLabel = arg.get("IF1", 0);
+ } else {
+ ifCode = null;
+ ifLabel = arg.get("IF2", 0);
+ }
+ system.startIf(Code.of(ifCode));
+
+ int lenght = 2;
+
+ if (arg.get("ARROW", 0) != null) {
+ final String arrow = StringUtils.manageArrowForCuca(arg.get("ARROW", 0));
+ lenght = arrow.length() - 1;
+ }
+
+ final IEntity branch = system.getCurrentContext().getBranch();
+
+ Link link = new Link(entity1, branch, new LinkType(LinkDecor.ARROW, LinkDecor.NONE),
+ Display.getWithNewlines(arg.get("BRACKET", 0)), lenght, null, ifLabel, system.getLabeldistance(),
+ system.getLabelangle());
+ if (arg.get("ARROW", 0) != null) {
+ final Direction direction = StringUtils.getArrowDirection(arg.get("ARROW", 0));
+ if (direction == Direction.LEFT || direction == Direction.UP) {
+ link = link.getInv();
+ }
+ }
+
+ system.addLink(link);
+
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandInnerConcurrent.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandInnerConcurrent.java
new file mode 100644
index 0000000..517e94b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandInnerConcurrent.java
@@ -0,0 +1,60 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.activitydiagram.ActivityDiagram;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.cucadiagram.EntityUtils;
+
+public class CommandInnerConcurrent extends SingleLineCommand<ActivityDiagram> {
+
+ public CommandInnerConcurrent() {
+ super("(?i)^--\\s*(.*)$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram diagram, List<String> arg) {
+ if (EntityUtils.groupRoot(diagram.getCurrentGroup())) {
+ return CommandExecutionResult.error("No inner activity");
+ }
+ diagram.concurrentActivity(arg.get(0));
+
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkActivity.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkActivity.java
new file mode 100644
index 0000000..c76aa00
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkActivity.java
@@ -0,0 +1,258 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram.command;
+
+import net.sourceforge.plantuml.Direction;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
+import net.sourceforge.plantuml.activitydiagram.ActivityDiagram;
+import net.sourceforge.plantuml.classdiagram.command.CommandLinkClass;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexOptional;
+import net.sourceforge.plantuml.command.regex.RegexOr;
+import net.sourceforge.plantuml.command.regex.RegexPartialMatch;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.GroupType;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.cucadiagram.LinkDecor;
+import net.sourceforge.plantuml.cucadiagram.LinkType;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.StringUtils;
+
+public class CommandLinkActivity extends SingleLineCommand2<ActivityDiagram> {
+
+ public CommandLinkActivity() {
+ super(getRegexConcat());
+ }
+
+ private static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexOptional(//
+ new RegexOr("FIRST", //
+ new RegexLeaf("STAR", "(\\(\\*(top)?\\))"), //
+ new RegexLeaf("CODE", "([\\p{L}0-9][\\p{L}0-9_.]*)"), //
+ new RegexLeaf("BAR", "(?:==+)[%s]*([\\p{L}0-9_.]+)[%s]*(?:==+)"), //
+ new RegexLeaf("QUOTED", "[%g]([^%g]+)[%g](?:[%s]+as[%s]+([\\p{L}0-9_.]+))?"))), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("BACKCOLOR", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
+
+ new RegexLeaf("ARROW_BODY1", "([-.]+)"), //
+ new RegexLeaf("ARROW_STYLE1",
+ "(?:\\[((?:#\\w+|dotted|dashed|bold|hidden)(?:,#\\w+|,dotted|,dashed|,bold|,hidden)*)\\])?"), //
+ new RegexLeaf("ARROW_DIRECTION", "(\\*|left|right|up|down|le?|ri?|up?|do?)?"), //
+ new RegexLeaf("ARROW_STYLE2",
+ "(?:\\[((?:#\\w+|dotted|dashed|bold|hidden)(?:,#\\w+|,dotted|,dashed|,bold|,hidden)*)\\])?"), //
+ new RegexLeaf("ARROW_BODY2", "([-.]*)\\>"), //
+
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("BRACKET", "(?:\\[([^\\]*]+[^\\]]*)\\])?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexOr("FIRST2", //
+ new RegexLeaf("STAR2", "(\\(\\*(top|\\d+)?\\))"), //
+ new RegexLeaf("OPENBRACKET2", "(\\{)"), //
+ new RegexLeaf("CODE2", "([\\p{L}0-9][\\p{L}0-9_.]*)"), //
+ new RegexLeaf("BAR2", "(?:==+)[%s]*([\\p{L}0-9_.]+)[%s]*(?:==+)"), //
+ new RegexLeaf("QUOTED2", "[%g]([^%g]+)[%g](?:[%s]+as[%s]+([\\p{L}0-9][\\p{L}0-9_.]*))?"), //
+ new RegexLeaf("QUOTED_INVISIBLE2", "(\\w.*?)")), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("STEREOTYPE2", "(\\<\\<.*\\>\\>)?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("PARTITION2", "(?:in[%s]+([%g][^%g]+[%g]|\\S+))?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("BACKCOLOR2", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram diagram, RegexResult arg) {
+ final IEntity entity1 = getEntity(diagram, arg, true);
+ if (entity1 == null) {
+ return CommandExecutionResult.error("No such activity");
+ }
+ if (arg.get("STEREOTYPE", 0) != null) {
+ entity1.setStereotype(new Stereotype(arg.get("STEREOTYPE", 0)));
+ }
+ if (arg.get("BACKCOLOR", 0) != null) {
+ entity1.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet()
+ .getColorIfValid(arg.get("BACKCOLOR", 0)));
+ }
+
+ final IEntity entity2 = getEntity(diagram, arg, false);
+ if (entity2 == null) {
+ return CommandExecutionResult.error("No such activity");
+ }
+ if (arg.get("BACKCOLOR2", 0) != null) {
+ entity2.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet()
+ .getColorIfValid(arg.get("BACKCOLOR2", 0)));
+ }
+ if (arg.get("STEREOTYPE2", 0) != null) {
+ entity2.setStereotype(new Stereotype(arg.get("STEREOTYPE2", 0)));
+ }
+
+ final Display linkLabel = Display.getWithNewlines(arg.get("BRACKET", 0));
+
+ final String arrowBody1 = CommandLinkClass.notNull(arg.get("ARROW_BODY1", 0));
+ final String arrowBody2 = CommandLinkClass.notNull(arg.get("ARROW_BODY2", 0));
+ final String arrowDirection = CommandLinkClass.notNull(arg.get("ARROW_DIRECTION", 0));
+
+ final String arrow = StringUtils.manageArrowForCuca(arrowBody1 + arrowDirection + arrowBody2 + ">");
+ int lenght = arrow.length() - 1;
+ if (arrowDirection.contains("*")) {
+ lenght = 2;
+ }
+
+ LinkType type = new LinkType(LinkDecor.ARROW, LinkDecor.NONE);
+ if ((arrowBody1 + arrowBody2).contains(".")) {
+ type = type.getDotted();
+ }
+
+ Link link = new Link(entity1, entity2, type, linkLabel, lenght);
+ if (arrowDirection.contains("*")) {
+ link.setConstraint(false);
+ }
+ final Direction direction = StringUtils.getArrowDirection(arrowBody1 + arrowDirection + arrowBody2 + ">");
+ if (direction == Direction.LEFT || direction == Direction.UP) {
+ link = link.getInv();
+ }
+ if (arg.get("URL", 0) != null) {
+ final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
+ final Url urlLink = urlBuilder.getUrl(arg.get("URL", 0));
+ link.setUrl(urlLink);
+ }
+
+ CommandLinkClass.applyStyle(arg.getLazzy("ARROW_STYLE", 0), link);
+ diagram.addLink(link);
+
+ return CommandExecutionResult.ok();
+
+ }
+
+ static IEntity getEntity(ActivityDiagram system, RegexResult arg, final boolean start) {
+ final String suf = start ? "" : "2";
+
+ final String openBracket2 = arg.get("OPENBRACKET" + suf, 0);
+ if (openBracket2 != null) {
+ return system.createInnerActivity();
+ }
+ if (arg.get("STAR" + suf, 0) != null) {
+ final String suppId = arg.get("STAR" + suf, 1);
+ if (start) {
+ if (suppId != null) {
+ system.getStart().setTop(true);
+ }
+ return system.getStart();
+ }
+ return system.getEnd(suppId);
+ }
+ String partition = arg.get("PARTITION" + suf, 0);
+ if (partition != null) {
+ partition = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(partition);
+ }
+ final Code code = Code.of(arg.get("CODE" + suf, 0));
+ if (code != null) {
+ if (partition != null) {
+ system.getOrCreateGroup(Code.of(partition), Display.getWithNewlines(partition), GroupType.PACKAGE,
+ system.getRootGroup());
+ }
+ final IEntity result = system.getOrCreate(code, Display.getWithNewlines(code),
+ CommandLinkActivity.getTypeIfExisting(system, code));
+ if (partition != null) {
+ system.endGroup();
+ }
+ return result;
+ }
+ final String bar = arg.get("BAR" + suf, 0);
+ if (bar != null) {
+ return system.getOrCreate(Code.of(bar), Display.getWithNewlines(bar), LeafType.SYNCHRO_BAR);
+ }
+ final RegexPartialMatch quoted = arg.get("QUOTED" + suf);
+ if (quoted.get(0) != null) {
+ final Code quotedCode = Code.of(quoted.get(1) == null ? quoted.get(0) : quoted.get(1));
+ if (partition != null) {
+ system.getOrCreateGroup(Code.of(partition), Display.getWithNewlines(partition), GroupType.PACKAGE,
+ system.getRootGroup());
+ }
+ final IEntity result = system.getOrCreate(quotedCode, Display.getWithNewlines(quoted.get(0)),
+ CommandLinkActivity.getTypeIfExisting(system, quotedCode));
+ if (partition != null) {
+ system.endGroup();
+ }
+ return result;
+ }
+ final Code quotedInvisible = Code.of(arg.get("QUOTED_INVISIBLE" + suf, 0));
+ if (quotedInvisible != null) {
+ if (partition != null) {
+ system.getOrCreateGroup(Code.of(partition), Display.getWithNewlines(partition), GroupType.PACKAGE,
+ system.getRootGroup());
+ }
+ final IEntity result = system.getOrCreate(quotedInvisible, Display.getWithNewlines(quotedInvisible),
+ LeafType.ACTIVITY);
+ if (partition != null) {
+ system.endGroup();
+ }
+ return result;
+ }
+ final String first = arg.get("FIRST" + suf, 0);
+ if (first == null) {
+ return system.getLastEntityConsulted();
+ }
+
+ return null;
+ }
+
+ static LeafType getTypeIfExisting(ActivityDiagram system, Code code) {
+ if (system.leafExist(code)) {
+ final IEntity ent = system.getLeafsget(code);
+ if (ent.getEntityType() == LeafType.BRANCH) {
+ return LeafType.BRANCH;
+ }
+ }
+ return LeafType.ACTIVITY;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity.java
new file mode 100644
index 0000000..7e2c6a1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity.java
@@ -0,0 +1,203 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.Direction;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
+import net.sourceforge.plantuml.activitydiagram.ActivityDiagram;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.CommandMultilines2;
+import net.sourceforge.plantuml.command.MultilinesStrategy;
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexOptional;
+import net.sourceforge.plantuml.command.regex.RegexOr;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.GroupType;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.cucadiagram.LinkDecor;
+import net.sourceforge.plantuml.cucadiagram.LinkType;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.StringUtils;
+
+public class CommandLinkLongActivity extends CommandMultilines2<ActivityDiagram> {
+
+ public CommandLinkLongActivity() {
+ super(getRegexConcat(), MultilinesStrategy.REMOVE_STARTING_QUOTE);
+ }
+
+ @Override
+ public String getPatternEnd() {
+ return "(?i)^[%s]*([^%g]*)[%g](?:[%s]+as[%s]+([\\p{L}0-9][\\p{L}0-9_.]*))?[%s]*(\\<\\<.*\\>\\>)?[%s]*(?:in[%s]+([%g][^%g]+[%g]|\\S+))?[%s]*(#\\w+)?$";
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexOptional(//
+ new RegexOr("FIRST", //
+ new RegexLeaf("STAR", "(\\(\\*(top)?\\))"), //
+ new RegexLeaf("CODE", "([\\p{L}0-9][\\p{L}0-9_.]*)"), //
+ new RegexLeaf("BAR", "(?:==+)[%s]*([\\p{L}0-9_.]+)[%s]*(?:==+)"), //
+ new RegexLeaf("QUOTED", "[%g]([^%g]+)[%g](?:[%s]+as[%s]+([\\p{L}0-9_.]+))?"))), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("BACKCOLOR", "(#\\w+)?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
+ new RegexLeaf("ARROW", "([-=.]+(?:(left|right|up|down|le?|ri?|up?|do?)(?=[-=.]))?[-=.]*\\>)"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("BRACKET", "(?:\\[([^\\]*]+[^\\]]*)\\])?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("DESC", "[%g]([^%g]*?)"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("$"));
+ }
+
+ public CommandExecutionResult executeNow(final ActivityDiagram diagram, List<String> lines) {
+ StringUtils.trim(lines, false);
+ final RegexResult line0 = getStartingPattern().matcher(lines.get(0).trim());
+
+ final IEntity entity1 = CommandLinkActivity.getEntity(diagram, line0, true);
+
+ if (line0.get("STEREOTYPE", 0) != null) {
+ entity1.setStereotype(new Stereotype(line0.get("STEREOTYPE", 0)));
+ }
+ if (line0.get("BACKCOLOR", 0) != null) {
+ entity1.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet()
+ .getColorIfValid(line0.get("BACKCOLOR", 0)));
+ }
+ final StringBuilder sb = new StringBuilder();
+
+ final String desc0 = line0.get("DESC", 0);
+ Url urlActivity = null;
+ if (StringUtils.isNotEmpty(desc0)) {
+ final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
+ urlActivity = urlBuilder.getUrl(desc0);
+ if (urlActivity == null) {
+ sb.append(desc0);
+ sb.append("\\n");
+ }
+ }
+ for (int i = 1; i < lines.size() - 1; i++) {
+ if (i == 1 && urlActivity == null) {
+ final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
+ urlActivity = urlBuilder.getUrl(lines.get(i));
+ if (urlActivity != null) {
+ continue;
+ }
+ }
+ sb.append(lines.get(i));
+ if (i < lines.size() - 2) {
+ sb.append("\\n");
+ }
+ }
+
+ final List<String> lineLast = StringUtils.getSplit(MyPattern.cmpile(getPatternEnd()),
+ lines.get(lines.size() - 1));
+ if (StringUtils.isNotEmpty(lineLast.get(0))) {
+ if (sb.length() > 0 && sb.toString().endsWith("\\n") == false) {
+ sb.append("\\n");
+ }
+ sb.append(lineLast.get(0));
+ }
+
+ final String display = sb.toString();
+ final Code code = Code.of(lineLast.get(1) == null ? display : lineLast.get(1));
+
+ String partition = null;
+ if (lineLast.get(3) != null) {
+ partition = lineLast.get(3);
+ partition = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(partition);
+ }
+ if (partition != null) {
+ diagram.getOrCreateGroup(Code.of(partition), Display.getWithNewlines(partition), GroupType.PACKAGE,
+ null);
+ }
+ final IEntity entity2 = diagram.createLeaf(code, Display.getWithNewlines(display), LeafType.ACTIVITY, null);
+ if (partition != null) {
+ diagram.endGroup();
+ }
+ if (urlActivity != null) {
+ entity2.addUrl(urlActivity);
+ }
+
+ if (lineLast.get(2) != null) {
+ entity2.setStereotype(new Stereotype(lineLast.get(2)));
+ }
+ if (lineLast.get(4) != null) {
+ entity2.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(lineLast.get(4)));
+ }
+
+ if (entity1 == null || entity2 == null) {
+ return CommandExecutionResult.error("No such entity");
+ }
+
+ final String arrow = StringUtils.manageArrowForCuca(line0.get("ARROW", 0));
+ final int lenght = arrow.length() - 1;
+
+ final Display linkLabel = Display.getWithNewlines(line0.get("BRACKET", 0));
+
+ LinkType type = new LinkType(LinkDecor.ARROW, LinkDecor.NONE);
+ if (line0.get("ARROW", 0).contains(".")) {
+ type = type.getDotted();
+ }
+ Link link = new Link(entity1, entity2, type, linkLabel, lenght);
+ final Direction direction = StringUtils.getArrowDirection(line0.get("ARROW", 0));
+ if (direction == Direction.LEFT || direction == Direction.UP) {
+ link = link.getInv();
+ }
+
+ if (line0.get("URL", 0) != null) {
+ final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
+ final Url urlLink = urlBuilder.getUrl(line0.get("URL", 0));
+ link.setUrl(urlLink);
+ }
+
+ diagram.addLink(link);
+
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity2.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity2.java
new file mode 100644
index 0000000..7c57629
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandLinkLongActivity2.java
@@ -0,0 +1,220 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.Direction;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
+import net.sourceforge.plantuml.activitydiagram.ActivityDiagram;
+import net.sourceforge.plantuml.classdiagram.command.CommandLinkClass;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.CommandMultilines2;
+import net.sourceforge.plantuml.command.MultilinesStrategy;
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexOptional;
+import net.sourceforge.plantuml.command.regex.RegexOr;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.GroupType;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.cucadiagram.LinkDecor;
+import net.sourceforge.plantuml.cucadiagram.LinkType;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.graphic.HtmlColorSet;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.StringUtils;
+
+public class CommandLinkLongActivity2 extends CommandMultilines2<ActivityDiagram> {
+
+ public CommandLinkLongActivity2() {
+ super(getRegexConcat(), MultilinesStrategy.REMOVE_STARTING_QUOTE);
+ }
+
+ @Override
+ public String getPatternEnd() {
+ return "(?i)^[%s]*([^%g]*)[%g](?:[%s]+as[%s]+([\\p{L}0-9][\\p{L}0-9_.]*))?[%s]*(\\<\\<.*\\>\\>)?[%s]*(?:in[%s]+([%g][^%g]+[%g]|\\S+))?[%s]*(#\\w+)?$";
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexOptional(//
+ new RegexOr("FIRST", //
+ new RegexLeaf("STAR", "(\\(\\*(top)?\\))"), //
+ new RegexLeaf("CODE", "([\\p{L}0-9][\\p{L}0-9_.]*)"), //
+ new RegexLeaf("BAR", "(?:==+)[%s]*([\\p{L}0-9_.]+)[%s]*(?:==+)"), //
+ new RegexLeaf("QUOTED", "[%g]([^%g]+)[%g](?:[%s]+as[%s]+([\\p{L}0-9_.]+))?"))), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("BACKCOLOR", "(#\\w+)?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
+
+ new RegexLeaf("ARROW_BODY1", "([-.]+)"), //
+ new RegexLeaf("ARROW_STYLE1",
+ "(?:\\[((?:#\\w+|dotted|dashed|bold|hidden)(?:,#\\w+|,dotted|,dashed|,bold|,hidden)*)\\])?"), //
+ new RegexLeaf("ARROW_DIRECTION", "(\\*|left|right|up|down|le?|ri?|up?|do?)?"), //
+ new RegexLeaf("ARROW_STYLE2",
+ "(?:\\[((?:#\\w+|dotted|dashed|bold|hidden)(?:,#\\w+|,dotted|,dashed|,bold|,hidden)*)\\])?"), //
+ new RegexLeaf("ARROW_BODY2", "([-.]*)\\>"), //
+
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("BRACKET", "(?:\\[([^\\]*]+[^\\]]*)\\])?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("DESC", "[%g]([^%g]*?)"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("$"));
+ }
+
+ public CommandExecutionResult executeNow(final ActivityDiagram diagram, List<String> lines) {
+ StringUtils.trim(lines, false);
+ final RegexResult line0 = getStartingPattern().matcher(lines.get(0).trim());
+
+ final IEntity entity1 = CommandLinkActivity.getEntity(diagram, line0, true);
+
+ if (line0.get("STEREOTYPE", 0) != null) {
+ entity1.setStereotype(new Stereotype(line0.get("STEREOTYPE", 0)));
+ }
+ if (line0.get("BACKCOLOR", 0) != null) {
+ entity1.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet()
+ .getColorIfValid(line0.get("BACKCOLOR", 0)));
+ }
+ final StringBuilder sb = new StringBuilder();
+
+ final String desc0 = line0.get("DESC", 0);
+ Url urlActivity = null;
+ if (StringUtils.isNotEmpty(desc0)) {
+ final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
+ urlActivity = urlBuilder.getUrl(desc0);
+ if (urlActivity == null) {
+ sb.append(desc0);
+ sb.append("\\n");
+ }
+ }
+ for (int i = 1; i < lines.size() - 1; i++) {
+ if (i == 1 && urlActivity == null) {
+ final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
+ urlActivity = urlBuilder.getUrl(lines.get(i));
+ if (urlActivity != null) {
+ continue;
+ }
+ }
+ sb.append(lines.get(i));
+ if (i < lines.size() - 2) {
+ sb.append("\\n");
+ }
+ }
+
+ final List<String> lineLast = StringUtils.getSplit(MyPattern.cmpile(getPatternEnd()),
+ lines.get(lines.size() - 1));
+ if (StringUtils.isNotEmpty(lineLast.get(0))) {
+ if (sb.length() > 0 && sb.toString().endsWith("\\n") == false) {
+ sb.append("\\n");
+ }
+ sb.append(lineLast.get(0));
+ }
+
+ final String display = sb.toString();
+ final Code code = Code.of(lineLast.get(1) == null ? display : lineLast.get(1));
+
+ String partition = null;
+ if (lineLast.get(3) != null) {
+ partition = lineLast.get(3);
+ partition = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(partition);
+ }
+ if (partition != null) {
+ diagram.getOrCreateGroup(Code.of(partition), Display.getWithNewlines(partition), GroupType.PACKAGE,
+ null);
+ }
+ final IEntity entity2 = diagram.createLeaf(code, Display.getWithNewlines(display), LeafType.ACTIVITY, null);
+ if (partition != null) {
+ diagram.endGroup();
+ }
+ if (urlActivity != null) {
+ entity2.addUrl(urlActivity);
+ }
+
+ if (lineLast.get(2) != null) {
+ entity2.setStereotype(new Stereotype(lineLast.get(2)));
+ }
+ if (lineLast.get(4) != null) {
+ entity2.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(lineLast.get(4)));
+ }
+
+ if (entity1 == null || entity2 == null) {
+ return CommandExecutionResult.error("No such entity");
+ }
+
+ final String arrowBody1 = CommandLinkClass.notNull(line0.get("ARROW_BODY1", 0));
+ final String arrowBody2 = CommandLinkClass.notNull(line0.get("ARROW_BODY2", 0));
+ final String arrowDirection = CommandLinkClass.notNull(line0.get("ARROW_DIRECTION", 0));
+
+ final String arrow = StringUtils.manageArrowForCuca(arrowBody1 + arrowDirection + arrowBody2 + ">");
+
+ final int lenght = arrow.length() - 1;
+
+ final Display linkLabel = Display.getWithNewlines(line0.get("BRACKET", 0));
+
+ LinkType type = new LinkType(LinkDecor.ARROW, LinkDecor.NONE);
+ if (arrow.contains(".")) {
+ type = type.getDotted();
+ }
+ Link link = new Link(entity1, entity2, type, linkLabel, lenght);
+ final Direction direction = StringUtils.getArrowDirection(arrowBody1 + arrowDirection + arrowBody2 + ">");
+ if (direction == Direction.LEFT || direction == Direction.UP) {
+ link = link.getInv();
+ }
+
+ if (line0.get("URL", 0) != null) {
+ final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
+ final Url urlLink = urlBuilder.getUrl(line0.get("URL", 0));
+ link.setUrl(urlLink);
+ }
+
+ CommandLinkClass.applyStyle(line0.getLazzy("ARROW_STYLE", 0), link);
+ diagram.addLink(link);
+
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandPartition.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandPartition.java
new file mode 100644
index 0000000..c4e3cee
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandPartition.java
@@ -0,0 +1,69 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.activitydiagram.ActivityDiagram;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.GroupType;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.IGroup;
+import net.sourceforge.plantuml.graphic.HtmlColorSet;
+import net.sourceforge.plantuml.StringUtils;
+
+public class CommandPartition extends SingleLineCommand<ActivityDiagram> {
+
+ public CommandPartition() {
+ super("(?i)^partition[%s]+([%g][^%g]+[%g]|\\S+)[%s]*(#[0-9a-fA-F]{6}|#?\\w+)?[%s]*\\{?$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram diagram, List<String> arg) {
+ final Code code = Code.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get(0)));
+ final IGroup currentPackage = diagram.getCurrentGroup();
+ final IEntity p = diagram.getOrCreateGroup(code, Display.getWithNewlines(code), GroupType.PACKAGE,
+ currentPackage);
+ final String color = arg.get(1);
+ if (color != null) {
+ p.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(color));
+ }
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java b/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java
new file mode 100644
index 0000000..cbcd1ec
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java
@@ -0,0 +1,450 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3;
+
+import java.awt.geom.Dimension2D;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.List;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.Scale;
+import net.sourceforge.plantuml.UmlDiagram;
+import net.sourceforge.plantuml.UmlDiagramType;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.activitydiagram3.ftile.BoxStyle;
+import net.sourceforge.plantuml.activitydiagram3.ftile.EntityImageLegend;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlanes;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.core.DiagramDescription;
+import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockCompressed;
+import net.sourceforge.plantuml.graphic.TextBlockRecentred;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+import net.sourceforge.plantuml.skin.rose.Rose;
+import net.sourceforge.plantuml.svek.DecorateEntityImage;
+import net.sourceforge.plantuml.svek.DecorateTextBlock;
+import net.sourceforge.plantuml.ugraphic.ImageBuilder;
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public class ActivityDiagram3 extends UmlDiagram {
+
+ enum SwimlaneStrategy {
+ SWIMLANE_FORBIDDEN, SWIMLANE_ALLOWED;
+ }
+
+ private SwimlaneStrategy swimlaneStrategy;
+
+ private final Swimlanes swinlanes = new Swimlanes(getSkinParam());
+
+ private void manageSwimlaneStrategy() {
+ if (swimlaneStrategy == null) {
+ swimlaneStrategy = SwimlaneStrategy.SWIMLANE_FORBIDDEN;
+ }
+ }
+
+ public CommandExecutionResult swimlane(String name, HtmlColor color, Display label) {
+ if (swimlaneStrategy == null) {
+ swimlaneStrategy = SwimlaneStrategy.SWIMLANE_ALLOWED;
+ }
+ if (swimlaneStrategy == SwimlaneStrategy.SWIMLANE_FORBIDDEN) {
+ return CommandExecutionResult.error("This swimlane must be defined at the start of the diagram.");
+ }
+
+ swinlanes.swimlane(name, color, label);
+ return CommandExecutionResult.ok();
+ }
+
+ private void setCurrent(Instruction ins) {
+ swinlanes.setCurrent(ins);
+ }
+
+ private Instruction current() {
+ return swinlanes.getCurrent();
+ }
+
+ private LinkRendering nextLinkRenderer() {
+ return swinlanes.nextLinkRenderer();
+ }
+
+ public void addActivity(Display activity, HtmlColor color, BoxStyle style, Url url) {
+ manageSwimlaneStrategy();
+ final InstructionSimple ins = new InstructionSimple(activity, color, nextLinkRenderer(),
+ swinlanes.getCurrentSwimlane(), style, url);
+ current().add(ins);
+ setNextLinkRendererInternal(null);
+ manageHasUrl(activity);
+ if (url != null) {
+ hasUrl = true;
+ }
+ }
+
+ public CommandExecutionResult addGoto(String name) {
+ final InstructionGoto ins = new InstructionGoto(swinlanes.getCurrentSwimlane(), name);
+ current().add(ins);
+ setNextLinkRendererInternal(null);
+ return CommandExecutionResult.ok();
+ }
+
+ public CommandExecutionResult addLabel(String name) {
+ final InstructionLabel ins = new InstructionLabel(swinlanes.getCurrentSwimlane(), name);
+ current().add(ins);
+ setNextLinkRendererInternal(null);
+ return CommandExecutionResult.ok();
+ }
+
+ public void start() {
+ manageSwimlaneStrategy();
+ current().add(new InstructionStart(swinlanes.getCurrentSwimlane()));
+ }
+
+ public void stop() {
+ manageSwimlaneStrategy();
+ current().add(new InstructionStop(swinlanes.getCurrentSwimlane(), nextLinkRenderer()));
+ }
+
+ public DiagramDescription getDescription() {
+ return new DiagramDescriptionImpl("activity3", getClass());
+ }
+
+ @Override
+ public UmlDiagramType getUmlDiagramType() {
+ return UmlDiagramType.ACTIVITY;
+ }
+
+ private TextBlock addLegend(TextBlock original) {
+ final Display legend = getLegend();
+ if (legend == null) {
+ return original;
+ }
+ final TextBlock text = EntityImageLegend.create(legend, getSkinParam());
+
+ return DecorateEntityImage.add(original, text, getLegendAlignment(), getLegendVerticalAlignment());
+ }
+
+ @Override
+ protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
+ throws IOException {
+ // BUG42
+ // COMPRESSION
+ // TextBlock result = swinlanes;
+ TextBlock result = new TextBlockCompressed(swinlanes);
+ result = new TextBlockRecentred(result);
+ result = addLegend(result);
+ result = addTitle(result);
+ result = addHeaderAndFooter(result);
+ final ISkinParam skinParam = getSkinParam();
+ final Dimension2D dim = TextBlockUtils.getMinMax(result).getDimension();
+ final double margin = 10;
+ final double dpiFactor = getDpiFactor(fileFormatOption, Dimension2DDouble.delta(dim, 2 * margin, 0));
+
+ final ImageBuilder imageBuilder = new ImageBuilder(skinParam.getColorMapper(), dpiFactor, getSkinParam()
+ .getBackgroundColor(), fileFormatOption.isWithMetadata() ? getMetadata() : null, getWarningOrError(),
+ margin, margin, getAnimation(), getSkinParam().handwritten());
+ imageBuilder.addUDrawable(result);
+
+ return imageBuilder.writeImageTOBEMOVED(fileFormatOption.getFileFormat(), os);
+
+ }
+
+ private final double getDpiFactor(FileFormatOption fileFormatOption, final Dimension2D dim) {
+ final double dpiFactor;
+ final Scale scale = getScale();
+ if (scale == null) {
+ dpiFactor = getDpiFactor(fileFormatOption);
+ } else {
+ dpiFactor = scale.getScale(dim.getWidth(), dim.getHeight());
+ }
+ return dpiFactor;
+ }
+
+ private TextBlock addTitle(TextBlock original) {
+ final Display title = getTitle();
+ if (title == null) {
+ return original;
+ }
+ final TextBlock text = TextBlockUtils.create(title, new FontConfiguration(getFont(FontParam.TITLE),
+ getFontColor(FontParam.TITLE, null), getSkinParam().getHyperlinkColor(), getSkinParam()
+ .useUnderlineForHyperlink()), HorizontalAlignment.CENTER, getSkinParam());
+
+ return new DecorateTextBlock(original, text, HorizontalAlignment.CENTER);
+ }
+
+ private TextBlock addHeaderAndFooter(TextBlock original) {
+ final Display footer = getFooter();
+ final Display header = getHeader();
+ if (footer == null && header == null) {
+ return original;
+ }
+ final TextBlock textFooter = footer == null ? null : TextBlockUtils.create(footer, new FontConfiguration(
+ getFont(FontParam.FOOTER), getFontColor(FontParam.FOOTER, null), getSkinParam().getHyperlinkColor(),
+ getSkinParam().useUnderlineForHyperlink()), getFooterAlignment(), getSkinParam());
+ final TextBlock textHeader = header == null ? null : TextBlockUtils.create(header, new FontConfiguration(
+ getFont(FontParam.HEADER), getFontColor(FontParam.HEADER, null), getSkinParam().getHyperlinkColor(),
+ getSkinParam().useUnderlineForHyperlink()), getHeaderAlignment(), getSkinParam());
+
+ return new DecorateTextBlock(original, textHeader, getHeaderAlignment(), textFooter, getFooterAlignment());
+ }
+
+ private final UFont getFont(FontParam fontParam) {
+ final ISkinParam skinParam = getSkinParam();
+ return skinParam.getFont(fontParam, null, false);
+ }
+
+ private final HtmlColor getFontColor(FontParam fontParam, Stereotype stereotype2) {
+ final ISkinParam skinParam = getSkinParam();
+ return skinParam.getFontHtmlColor(fontParam, stereotype2);
+ }
+
+ public void fork() {
+ final InstructionFork instructionFork = new InstructionFork(current(), nextLinkRenderer());
+ current().add(instructionFork);
+ setNextLinkRendererInternal(null);
+ setCurrent(instructionFork);
+ }
+
+ public CommandExecutionResult forkAgain() {
+ if (current() instanceof InstructionFork) {
+ ((InstructionFork) current()).forkAgain();
+ return CommandExecutionResult.ok();
+ }
+ return CommandExecutionResult.error("Cannot find fork");
+ }
+
+ public CommandExecutionResult endFork() {
+ if (current() instanceof InstructionFork) {
+ setCurrent(((InstructionFork) current()).getParent());
+ return CommandExecutionResult.ok();
+ }
+ return CommandExecutionResult.error("Cannot find fork");
+ }
+
+ public void split() {
+ final InstructionSplit instructionSplit = new InstructionSplit(current(), nextLinkRenderer());
+ setNextLinkRendererInternal(null);
+ current().add(instructionSplit);
+ setCurrent(instructionSplit);
+ }
+
+ public CommandExecutionResult splitAgain() {
+ if (current() instanceof InstructionSplit) {
+ ((InstructionSplit) current()).splitAgain(nextLinkRenderer());
+ setNextLinkRendererInternal(null);
+ return CommandExecutionResult.ok();
+ }
+ return CommandExecutionResult.error("Cannot find split");
+ }
+
+ public CommandExecutionResult endSplit() {
+ if (current() instanceof InstructionSplit) {
+ ((InstructionSplit) current()).endSplit(nextLinkRenderer());
+ setNextLinkRendererInternal(null);
+ setCurrent(((InstructionSplit) current()).getParent());
+ return CommandExecutionResult.ok();
+ }
+ return CommandExecutionResult.error("Cannot find split");
+ }
+
+ public void startIf(Display test, Display whenThen, HtmlColor color) {
+ manageSwimlaneStrategy();
+ final InstructionIf instructionIf = new InstructionIf(swinlanes.getCurrentSwimlane(), current(), test,
+ whenThen, nextLinkRenderer(), color, getSkinParam());
+ current().add(instructionIf);
+ setNextLinkRendererInternal(null);
+ setCurrent(instructionIf);
+ }
+
+ public CommandExecutionResult elseIf(Display test, Display whenThen, HtmlColor color) {
+ if (current() instanceof InstructionIf) {
+ ((InstructionIf) current()).elseIf(test, whenThen, nextLinkRenderer(), color);
+ setNextLinkRendererInternal(null);
+ return CommandExecutionResult.ok();
+ }
+ return CommandExecutionResult.error("Cannot find if");
+ }
+
+ public CommandExecutionResult else2(Display whenElse) {
+ if (current() instanceof InstructionIf) {
+ final boolean result = ((InstructionIf) current()).swithToElse2(whenElse, nextLinkRenderer());
+ if (result == false) {
+ return CommandExecutionResult.error("Cannot find if");
+ }
+ setNextLinkRendererInternal(null);
+ return CommandExecutionResult.ok();
+ }
+ return CommandExecutionResult.error("Cannot find if");
+ }
+
+ public CommandExecutionResult endif() {
+ if (current() instanceof InstructionIf) {
+ ((InstructionIf) current()).endif(nextLinkRenderer());
+ setNextLinkRendererInternal(null);
+ setCurrent(((InstructionIf) current()).getParent());
+ return CommandExecutionResult.ok();
+ }
+ return CommandExecutionResult.error("Cannot find if");
+ }
+
+ public void startRepeat(HtmlColor color) {
+ manageSwimlaneStrategy();
+ final InstructionRepeat instructionRepeat = new InstructionRepeat(swinlanes.getCurrentSwimlane(), current(),
+ nextLinkRenderer(), color);
+ current().add(instructionRepeat);
+ setCurrent(instructionRepeat);
+ setNextLinkRendererInternal(null);
+
+ }
+
+ public CommandExecutionResult repeatWhile(Display label, Display yes, Display out, Display linkLabel,
+ HtmlColor linkColor) {
+ manageSwimlaneStrategy();
+ if (current() instanceof InstructionRepeat) {
+ final InstructionRepeat instructionRepeat = (InstructionRepeat) current();
+ final LinkRendering back = new LinkRendering(linkColor);
+ back.setDisplay(linkLabel);
+ instructionRepeat.setTest(label, yes, out, nextLinkRenderer(), back);
+ setCurrent(instructionRepeat.getParent());
+ this.setNextLinkRendererInternal(null);
+ return CommandExecutionResult.ok();
+ }
+ return CommandExecutionResult.error("Cannot find repeat");
+
+ }
+
+ public void doWhile(Display test, Display yes, HtmlColor color) {
+ manageSwimlaneStrategy();
+ final InstructionWhile instructionWhile = new InstructionWhile(swinlanes.getCurrentSwimlane(), current(), test,
+ nextLinkRenderer(), yes, color, getSkinParam());
+ current().add(instructionWhile);
+ setCurrent(instructionWhile);
+ }
+
+ public CommandExecutionResult endwhile(Display out) {
+ if (current() instanceof InstructionWhile) {
+ ((InstructionWhile) current()).endwhile(nextLinkRenderer(), out);
+ setNextLinkRendererInternal(null);
+ setCurrent(((InstructionWhile) current()).getParent());
+ return CommandExecutionResult.ok();
+ }
+ return CommandExecutionResult.error("Cannot find while");
+ }
+
+ final public CommandExecutionResult kill() {
+ if (current().kill() == false) {
+ return CommandExecutionResult.error("kill cannot be used here");
+ }
+ return CommandExecutionResult.ok();
+ }
+
+ public void startGroup(Display name, HtmlColor backColor, HtmlColor titleColor) {
+ manageSwimlaneStrategy();
+ final InstructionGroup instructionGroup = new InstructionGroup(current(), name, backColor, titleColor);
+ current().add(instructionGroup);
+ setCurrent(instructionGroup);
+ }
+
+ public CommandExecutionResult endGroup() {
+ if (current() instanceof InstructionGroup) {
+ setCurrent(((InstructionGroup) current()).getParent());
+ return CommandExecutionResult.ok();
+ }
+ return CommandExecutionResult.error("Cannot find group");
+ }
+
+ private void setNextLinkRendererInternal(LinkRendering link) {
+ swinlanes.setNextLinkRenderer(link);
+ }
+
+ private void setNextLink(LinkRendering linkRenderer) {
+ if (current() instanceof InstructionList) {
+ final Instruction last = ((InstructionList) current()).getLast();
+ if (last instanceof InstructionWhile) {
+ ((InstructionWhile) last).afterEndwhile(linkRenderer);
+ }
+ }
+ this.setNextLinkRendererInternal(linkRenderer);
+ }
+
+ private final Rose rose = new Rose();
+
+ public void setLabelNextArrow(Display label) {
+ if (nextLinkRenderer() == null) {
+ final HtmlColor arrowColor = rose.getHtmlColor(getSkinParam(), ColorParam.activityArrow);
+ this.setNextLink(new LinkRendering(arrowColor));
+ }
+ nextLinkRenderer().setDisplay(label);
+ }
+
+ public void setColorNextArrow(HtmlColor color) {
+ if (color == null) {
+ return;
+ }
+ final LinkRendering link = new LinkRendering(color);
+ setNextLink(link);
+ }
+
+ public CommandExecutionResult addNote(Display note, NotePosition position) {
+ current().addNote(note, position);
+ manageHasUrl(note);
+ return CommandExecutionResult.ok();
+ }
+
+ private boolean hasUrl = false;
+
+ private void manageHasUrl(Display display) {
+ if (display.hasUrl()) {
+ hasUrl = true;
+ }
+ }
+
+ @Override
+ public boolean hasUrl() {
+ return hasUrl;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagramFactory3.java b/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagramFactory3.java
new file mode 100644
index 0000000..38c57b0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagramFactory3.java
@@ -0,0 +1,143 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.activitydiagram3.command.CommandActivity3;
+import net.sourceforge.plantuml.activitydiagram3.command.CommandActivityLegacy1;
+import net.sourceforge.plantuml.activitydiagram3.command.CommandActivityLong3;
+import net.sourceforge.plantuml.activitydiagram3.command.CommandArrow3;
+import net.sourceforge.plantuml.activitydiagram3.command.CommandArrowLong3;
+import net.sourceforge.plantuml.activitydiagram3.command.CommandElse3;
+import net.sourceforge.plantuml.activitydiagram3.command.CommandElseIf2;
+import net.sourceforge.plantuml.activitydiagram3.command.CommandElseLegacy1;
+import net.sourceforge.plantuml.activitydiagram3.command.CommandEndPartition3;
+import net.sourceforge.plantuml.activitydiagram3.command.CommandEndif3;
+import net.sourceforge.plantuml.activitydiagram3.command.CommandFork3;
+import net.sourceforge.plantuml.activitydiagram3.command.CommandForkAgain3;
+import net.sourceforge.plantuml.activitydiagram3.command.CommandForkEnd3;
+import net.sourceforge.plantuml.activitydiagram3.command.CommandGoto;
+import net.sourceforge.plantuml.activitydiagram3.command.CommandGroup3;
+import net.sourceforge.plantuml.activitydiagram3.command.CommandGroupEnd3;
+import net.sourceforge.plantuml.activitydiagram3.command.CommandIf2;
+import net.sourceforge.plantuml.activitydiagram3.command.CommandIf2Multilines;
+import net.sourceforge.plantuml.activitydiagram3.command.CommandIf4;
+import net.sourceforge.plantuml.activitydiagram3.command.CommandIfLegacy1;
+import net.sourceforge.plantuml.activitydiagram3.command.CommandKill3;
+import net.sourceforge.plantuml.activitydiagram3.command.CommandLabel;
+import net.sourceforge.plantuml.activitydiagram3.command.CommandLink3;
+import net.sourceforge.plantuml.activitydiagram3.command.CommandNote3;
+import net.sourceforge.plantuml.activitydiagram3.command.CommandNoteLong3;
+import net.sourceforge.plantuml.activitydiagram3.command.CommandPartition3;
+import net.sourceforge.plantuml.activitydiagram3.command.CommandRepeat3;
+import net.sourceforge.plantuml.activitydiagram3.command.CommandRepeatWhile3;
+import net.sourceforge.plantuml.activitydiagram3.command.CommandSplit3;
+import net.sourceforge.plantuml.activitydiagram3.command.CommandSplitAgain3;
+import net.sourceforge.plantuml.activitydiagram3.command.CommandSplitEnd3;
+import net.sourceforge.plantuml.activitydiagram3.command.CommandStart3;
+import net.sourceforge.plantuml.activitydiagram3.command.CommandStop3;
+import net.sourceforge.plantuml.activitydiagram3.command.CommandStopLegacy1;
+import net.sourceforge.plantuml.activitydiagram3.command.CommandSwimlane;
+import net.sourceforge.plantuml.activitydiagram3.command.CommandSwimlane2;
+import net.sourceforge.plantuml.activitydiagram3.command.CommandWhile3;
+import net.sourceforge.plantuml.activitydiagram3.command.CommandWhileEnd3;
+import net.sourceforge.plantuml.command.Command;
+import net.sourceforge.plantuml.command.CommandFootboxIgnored;
+import net.sourceforge.plantuml.command.UmlDiagramFactory;
+
+public class ActivityDiagramFactory3 extends UmlDiagramFactory {
+
+ @Override
+ protected List<Command> createCommands() {
+
+ final List<Command> cmds = new ArrayList<Command>();
+ cmds.add(new CommandFootboxIgnored());
+
+ addCommonCommands(cmds);
+ cmds.add(new CommandSwimlane());
+ cmds.add(new CommandSwimlane2());
+ cmds.add(new CommandPartition3());
+ cmds.add(new CommandEndPartition3());
+ cmds.add(new CommandGroup3());
+ cmds.add(new CommandGroupEnd3());
+ cmds.add(new CommandArrow3());
+ cmds.add(new CommandArrowLong3());
+ cmds.add(new CommandActivity3());
+ cmds.add(new CommandIf4());
+ cmds.add(new CommandIf2());
+ cmds.add(new CommandIf2Multilines());
+ cmds.add(new CommandIfLegacy1());
+ cmds.add(new CommandElseIf2());
+ cmds.add(new CommandElse3());
+ cmds.add(new CommandElseLegacy1());
+ cmds.add(new CommandEndif3());
+ cmds.add(new CommandRepeat3());
+ cmds.add(new CommandRepeatWhile3());
+ cmds.add(new CommandWhile3());
+ cmds.add(new CommandWhileEnd3());
+ cmds.add(new CommandFork3());
+ cmds.add(new CommandForkAgain3());
+ cmds.add(new CommandForkEnd3());
+ cmds.add(new CommandSplit3());
+ cmds.add(new CommandSplitAgain3());
+ cmds.add(new CommandSplitEnd3());
+// cmds.add(new CommandGroup3());
+// cmds.add(new CommandGroupEnd3());
+ cmds.add(new CommandStart3());
+ cmds.add(new CommandStop3());
+ cmds.add(new CommandStopLegacy1());
+ cmds.add(new CommandKill3());
+ cmds.add(new CommandLink3());
+ cmds.add(new CommandNote3());
+ cmds.add(new CommandNoteLong3());
+
+ cmds.add(new CommandActivityLong3());
+ cmds.add(new CommandActivityLegacy1());
+
+ cmds.add(new CommandLabel());
+ cmds.add(new CommandGoto());
+
+
+ return cmds;
+ }
+
+ @Override
+ public ActivityDiagram3 createEmptyDiagram() {
+ return new ActivityDiagram3();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/Branch.java b/src/net/sourceforge/plantuml/activitydiagram3/Branch.java
new file mode 100644
index 0000000..ebf5cc4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/Branch.java
@@ -0,0 +1,124 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3;
+
+import java.util.Collection;
+
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+
+public class Branch {
+
+ private final InstructionList list;
+ private final Display labelTest;
+ private final Display labelPositive;
+ private final HtmlColor color;
+
+ private LinkRendering inlinkRendering;
+
+ private Ftile ftile;
+
+ public boolean isOnlySingleStop() {
+ return list.isOnlySingleStop();
+ }
+
+ public Branch(Swimlane swimlane, Display labelPositive, Display labelTest, HtmlColor color) {
+ this.list = new InstructionList(swimlane);
+ this.labelTest = labelTest;
+ this.labelPositive = labelPositive;
+ this.color = color;
+ }
+
+ public void add(Instruction ins) {
+ list.add(ins);
+ }
+
+ public boolean kill() {
+ return list.kill();
+ }
+
+ public void addNote(Display note, NotePosition position) {
+ list.addNote(note, position);
+ }
+
+ public final void setInlinkRendering(LinkRendering inlinkRendering) {
+ this.inlinkRendering = inlinkRendering;
+ }
+
+ public void updateFtile(FtileFactory factory) {
+ this.ftile = factory.decorateOut(list.createFtile(factory), inlinkRendering);
+ }
+
+ public Collection<? extends Swimlane> getSwimlanes() {
+ return list.getSwimlanes();
+ }
+
+ public final Display getLabelPositive() {
+ final LinkRendering in = ftile.getInLinkRendering();
+ if (in != null && in.getDisplay() != null) {
+ return in.getDisplay();
+ }
+ return labelPositive;
+ }
+
+ public final Display getLabelTest() {
+ return labelTest;
+ }
+
+ public final HtmlColor getInlinkRenderingColor() {
+ return inlinkRendering == null ? null : inlinkRendering.getColor();
+ }
+
+ public final Ftile getFtile() {
+ return ftile;
+ }
+
+ public boolean shadowing() {
+ return ftile.shadowing();
+ }
+
+ public final HtmlColor getColor() {
+ return color;
+ }
+
+ public boolean isEmpty() {
+ return list.isEmpty();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/Instruction.java b/src/net/sourceforge/plantuml/activitydiagram3/Instruction.java
new file mode 100644
index 0000000..3b71f5c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/Instruction.java
@@ -0,0 +1,55 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3;
+
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimable;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+
+public interface Instruction extends Swimable {
+
+ public Ftile createFtile(FtileFactory factory);
+
+ public void add(Instruction other);
+
+ public boolean kill();
+
+ public LinkRendering getInLinkRendering();
+
+ public void addNote(Display note, NotePosition position);
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionFork.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionFork.java
new file mode 100644
index 0000000..6c44474
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionFork.java
@@ -0,0 +1,110 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+
+public class InstructionFork implements Instruction {
+
+ private final List<InstructionList> forks = new ArrayList<InstructionList>();
+ private final Instruction parent;
+ private final LinkRendering inlinkRendering;
+
+ public InstructionFork(Instruction parent, LinkRendering inlinkRendering) {
+ this.parent = parent;
+ this.inlinkRendering = inlinkRendering;
+ this.forks.add(new InstructionList());
+ }
+
+ private InstructionList getLast() {
+ return forks.get(forks.size() - 1);
+ }
+
+
+ public void add(Instruction ins) {
+ getLast().add(ins);
+ }
+
+ public Ftile createFtile(FtileFactory factory) {
+ final List<Ftile> all = new ArrayList<Ftile>();
+ for (InstructionList list : forks) {
+ all.add(list.createFtile(factory));
+ }
+ return factory.createFork(getSwimlaneIn(), all);
+ }
+
+ public Instruction getParent() {
+ return parent;
+ }
+
+ public void forkAgain() {
+ this.forks.add(new InstructionList());
+ }
+
+ final public boolean kill() {
+ return getLast().kill();
+ }
+
+ public LinkRendering getInLinkRendering() {
+ return inlinkRendering;
+ }
+
+ public void addNote(Display note, NotePosition position) {
+ getLast().addNote(note, position);
+ }
+
+ public Set<Swimlane> getSwimlanes() {
+ return InstructionList.getSwimlanes2(forks);
+ }
+
+ public Swimlane getSwimlaneIn() {
+ // return parent.getSwimlaneOut();
+ return forks.get(0).getSwimlaneIn();
+ }
+
+ public Swimlane getSwimlaneOut() {
+ return getLast().getSwimlaneOut();
+ }
+
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionGoto.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionGoto.java
new file mode 100644
index 0000000..5858a99
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionGoto.java
@@ -0,0 +1,73 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3;
+
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGoto;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+
+public class InstructionGoto extends MonoSwimable implements Instruction {
+
+ private final String name;
+
+ public InstructionGoto(Swimlane swimlane, String name) {
+ super(swimlane);
+ this.name = name;
+ }
+
+ public Ftile createFtile(FtileFactory factory) {
+ return new FtileGoto(factory.shadowing(), getSwimlaneIn(), name);
+ }
+
+ public void add(Instruction other) {
+ throw new UnsupportedOperationException();
+ }
+
+ final public boolean kill() {
+ return false;
+ }
+
+ public LinkRendering getInLinkRendering() {
+ return null;
+ }
+
+ public void addNote(Display note, NotePosition position) {
+ throw new UnsupportedOperationException();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionGroup.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionGroup.java
new file mode 100644
index 0000000..844b2c1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionGroup.java
@@ -0,0 +1,103 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3;
+
+import java.util.Set;
+
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+
+public class InstructionGroup implements Instruction {
+
+ private final InstructionList list = new InstructionList();
+ private final Instruction parent;
+ private final HtmlColor backColor;
+ private final HtmlColor titleColor;
+
+ private final Display test;
+ private Display headerNote;
+
+ public InstructionGroup(Instruction parent, Display test, HtmlColor backColor, HtmlColor titleColor) {
+ this.parent = parent;
+ this.test = test;
+ this.backColor = backColor;
+ this.titleColor = titleColor;
+ }
+
+ public void add(Instruction ins) {
+ list.add(ins);
+ }
+
+ public Ftile createFtile(FtileFactory factory) {
+ return factory.createGroup(list.createFtile(factory), test, backColor, titleColor, headerNote);
+ }
+
+ public Instruction getParent() {
+ return parent;
+ }
+
+ final public boolean kill() {
+ return list.kill();
+ }
+
+ public LinkRendering getInLinkRendering() {
+ return null;
+ }
+
+ public void addNote(Display note, NotePosition position) {
+ if (list.isEmpty()) {
+ this.headerNote = note;
+ return;
+ }
+ list.addNote(note, position);
+ }
+
+ public Set<Swimlane> getSwimlanes() {
+ return list.getSwimlanes();
+ }
+
+ public Swimlane getSwimlaneIn() {
+ return list.getSwimlaneIn();
+ }
+
+ public Swimlane getSwimlaneOut() {
+ return list.getSwimlaneOut();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java
new file mode 100644
index 0000000..d2fb46a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java
@@ -0,0 +1,166 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileWithNoteOpale;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+
+public class InstructionIf implements Instruction {
+
+ private final List<Branch> thens = new ArrayList<Branch>();
+ private Branch elseBranch;
+ private final ISkinParam skinParam;
+
+ private final Instruction parent;
+
+ private Branch current;
+ private final LinkRendering inlinkRendering;
+
+ private final Swimlane swimlane;
+
+ public InstructionIf(Swimlane swimlane, Instruction parent, Display labelTest, Display whenThen,
+ LinkRendering inlinkRendering, HtmlColor color, ISkinParam skinParam) {
+ this.parent = parent;
+ this.skinParam = skinParam;
+
+ this.inlinkRendering = inlinkRendering;
+ this.swimlane = swimlane;
+ this.thens.add(new Branch(swimlane, whenThen, labelTest, color));
+ this.current = this.thens.get(0);
+ }
+
+ public void add(Instruction ins) {
+ current.add(ins);
+ }
+
+ private Display note;
+ private NotePosition position;
+
+ public Ftile createFtile(FtileFactory factory) {
+ for (Branch branch : thens) {
+ branch.updateFtile(factory);
+ }
+ if (elseBranch == null) {
+ this.elseBranch = new Branch(swimlane, null, null, null);
+ }
+ elseBranch.updateFtile(factory);
+ Ftile result = factory.createIf(swimlane, thens, elseBranch);
+ if (note != null) {
+ result = new FtileWithNoteOpale(result, note, position, skinParam, false);
+ }
+ return result;
+ }
+
+ public Instruction getParent() {
+ return parent;
+ }
+
+ public boolean swithToElse2(Display whenElse, LinkRendering nextLinkRenderer) {
+ if (elseBranch != null) {
+ return false;
+ }
+ this.current.setInlinkRendering(nextLinkRenderer);
+ this.elseBranch = new Branch(swimlane, whenElse, null, null);
+ this.current = elseBranch;
+ return true;
+ }
+
+ public void elseIf(Display test, Display whenThen, LinkRendering nextLinkRenderer, HtmlColor color) {
+ if (elseBranch != null) {
+ throw new IllegalStateException();
+ }
+ this.current.setInlinkRendering(nextLinkRenderer);
+ this.current = new Branch(swimlane, whenThen, test, color);
+ this.thens.add(current);
+
+ }
+
+ public void endif(LinkRendering nextLinkRenderer) {
+ if (elseBranch == null) {
+ this.elseBranch = new Branch(swimlane, null, null, null);
+ }
+ this.current.setInlinkRendering(nextLinkRenderer);
+ }
+
+ final public boolean kill() {
+ return current.kill();
+ }
+
+ public LinkRendering getInLinkRendering() {
+ return inlinkRendering;
+ }
+
+ public void addNote(Display note, NotePosition position) {
+ if (current.isEmpty()) {
+ this.note = note;
+ this.position = position;
+ } else {
+ current.addNote(note, position);
+ }
+ }
+
+ public Set<Swimlane> getSwimlanes() {
+ final Set<Swimlane> result = new HashSet<Swimlane>();
+ if (swimlane != null) {
+ result.add(swimlane);
+ }
+ for (Branch branch : thens) {
+ result.addAll(branch.getSwimlanes());
+ }
+ result.addAll(elseBranch.getSwimlanes());
+ return Collections.unmodifiableSet(result);
+ }
+
+ public Swimlane getSwimlaneIn() {
+ return swimlane;
+ }
+
+ public Swimlane getSwimlaneOut() {
+ return swimlane;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionLabel.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionLabel.java
new file mode 100644
index 0000000..4c9e3e5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionLabel.java
@@ -0,0 +1,73 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3;
+
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileLabel;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+
+public class InstructionLabel extends MonoSwimable implements Instruction {
+
+ private final String name;
+
+ public InstructionLabel(Swimlane swimlane, String name) {
+ super(swimlane);
+ this.name = name;
+ }
+
+ public Ftile createFtile(FtileFactory factory) {
+ return new FtileLabel(factory.shadowing(), getSwimlaneIn(), name);
+ }
+
+ public void add(Instruction other) {
+ throw new UnsupportedOperationException();
+ }
+
+ final public boolean kill() {
+ return false;
+ }
+
+ public LinkRendering getInLinkRendering() {
+ return null;
+ }
+
+ public void addNote(Display note, NotePosition position) {
+ throw new UnsupportedOperationException();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionList.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionList.java
new file mode 100644
index 0000000..ef77acf
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionList.java
@@ -0,0 +1,158 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileEmpty;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+
+public class InstructionList implements Instruction {
+
+ private final List<Instruction> all = new ArrayList<Instruction>();
+ private final Swimlane defaultSwimlane;
+
+ public boolean isOnlySingleStop() {
+ if (all.size() == 1) {
+ final Instruction last = getLast();
+ return last instanceof InstructionStop;
+ }
+ return false;
+ }
+
+ public InstructionList() {
+ this(null);
+ }
+
+ public boolean isEmpty() {
+ return all.isEmpty();
+ }
+
+ public InstructionList(Swimlane defaultSwimlane) {
+ this.defaultSwimlane = defaultSwimlane;
+ }
+
+ public void add(Instruction ins) {
+ all.add(ins);
+ }
+
+ public Ftile createFtile(FtileFactory factory) {
+ if (all.size() == 0) {
+ return new FtileEmpty(factory.shadowing(), defaultSwimlane);
+ }
+ Ftile result = null;
+ for (Instruction ins : all) {
+ Ftile cur = ins.createFtile(factory);
+ if (ins.getInLinkRendering() != null) {
+ cur = factory.decorateIn(cur, ins.getInLinkRendering());
+ }
+ if (result == null) {
+ result = cur;
+ } else {
+ result = factory.assembly(result, cur);
+ }
+ }
+ if (outlinkRendering != null) {
+ result = factory.decorateOut(result, outlinkRendering);
+ }
+ // if (killed) {
+ // result = new FtileKilled(result);
+ // }
+ return result;
+ }
+
+ final public boolean kill() {
+ if (all.size() == 0) {
+ return false;
+ }
+ return getLast().kill();
+ }
+
+ public LinkRendering getInLinkRendering() {
+ return all.iterator().next().getInLinkRendering();
+ }
+
+ public Instruction getLast() {
+ if (all.size() == 0) {
+ return null;
+ }
+ return all.get(all.size() - 1);
+ }
+
+ public void addNote(Display note, NotePosition position) {
+ getLast().addNote(note, position);
+ }
+
+ public Set<Swimlane> getSwimlanes() {
+ return getSwimlanes2(all);
+ }
+
+ public Swimlane getSwimlaneIn() {
+ if (getSwimlanes().size() == 0) {
+ return null;
+ }
+ return all.get(0).getSwimlaneIn();
+ }
+
+ public Swimlane getSwimlaneOut() {
+ if (getSwimlanes().size() == 0) {
+ return null;
+ }
+ return getLast().getSwimlaneOut();
+ }
+
+ public static Set<Swimlane> getSwimlanes2(List<? extends Instruction> list) {
+ final Set<Swimlane> result = new HashSet<Swimlane>();
+ for (Instruction ins : list) {
+ result.addAll(ins.getSwimlanes());
+ }
+ return Collections.unmodifiableSet(result);
+ }
+
+ private LinkRendering outlinkRendering;
+
+ public void setOutRendering(LinkRendering outlinkRendering) {
+ this.outlinkRendering = outlinkRendering;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionPartition.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionPartition.java
new file mode 100644
index 0000000..8a35bd4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionPartition.java
@@ -0,0 +1,90 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3;
+
+import java.util.Set;
+
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+
+public class InstructionPartition implements Instruction {
+
+ private final InstructionList list = new InstructionList();
+ private final Instruction parent;
+
+ public InstructionPartition(Instruction parent, String partitionTitle) {
+ this.parent = parent;
+ }
+
+ public Instruction getParent() {
+ return parent;
+ }
+
+ public Set<Swimlane> getSwimlanes() {
+ return list.getSwimlanes();
+ }
+
+ public Swimlane getSwimlaneIn() {
+ return list.getSwimlaneIn();
+ }
+
+ public Swimlane getSwimlaneOut() {
+ return list.getSwimlaneOut();
+ }
+
+ public Ftile createFtile(FtileFactory factory) {
+ return list.createFtile(factory);
+ }
+
+ public void add(Instruction other) {
+ list.add(other);
+ }
+
+ public boolean kill() {
+ return list.kill();
+ }
+
+ public LinkRendering getInLinkRendering() {
+ return list.getInLinkRendering();
+ }
+
+ public void addNote(Display note, NotePosition position) {
+ throw new UnsupportedOperationException();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionRepeat.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionRepeat.java
new file mode 100644
index 0000000..97ee9f4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionRepeat.java
@@ -0,0 +1,112 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3;
+
+import java.util.Set;
+
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+
+public class InstructionRepeat implements Instruction {
+
+ private final InstructionList repeatList = new InstructionList();
+ private final Instruction parent;
+ private final LinkRendering nextLinkRenderer;
+ private final Swimlane swimlane;
+ private final HtmlColor color;
+
+ private Display test;
+ private Display yes;
+ private Display out;
+ private LinkRendering endRepeatLinkRendering;
+ private LinkRendering backRepeatLinkRendering;
+
+ public InstructionRepeat(Swimlane swimlane, Instruction parent, LinkRendering nextLinkRenderer, HtmlColor color) {
+ this.parent = parent;
+ this.swimlane = swimlane;
+ this.nextLinkRenderer = nextLinkRenderer;
+ this.color = color;
+ }
+
+ public void add(Instruction ins) {
+ repeatList.add(ins);
+ }
+
+ public Ftile createFtile(FtileFactory factory) {
+ return factory.repeat(swimlane, factory.decorateOut(repeatList.createFtile(factory), endRepeatLinkRendering),
+ test, yes, out, color, backRepeatLinkRendering);
+ }
+
+ public Instruction getParent() {
+ return parent;
+ }
+
+ public void setTest(Display test, Display yes, Display out, LinkRendering endRepeatLinkRendering, LinkRendering backRepeatLinkRendering) {
+ this.test = test;
+ this.yes = yes;
+ this.out = out;
+ this.endRepeatLinkRendering = endRepeatLinkRendering;
+ this.backRepeatLinkRendering = backRepeatLinkRendering;
+ }
+
+ final public boolean kill() {
+ return repeatList.kill();
+ }
+
+ public LinkRendering getInLinkRendering() {
+ return nextLinkRenderer;
+ }
+
+ public void addNote(Display note, NotePosition position) {
+ repeatList.addNote(note, position);
+ }
+
+ public Set<Swimlane> getSwimlanes() {
+ return repeatList.getSwimlanes();
+ }
+
+ public Swimlane getSwimlaneIn() {
+ return parent.getSwimlaneOut();
+ }
+
+ public Swimlane getSwimlaneOut() {
+ return repeatList.getSwimlaneOut();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionSimple.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionSimple.java
new file mode 100644
index 0000000..d08e2df
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionSimple.java
@@ -0,0 +1,100 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.activitydiagram3.ftile.BoxStyle;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileKilled;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+
+public class InstructionSimple extends MonoSwimable implements Instruction {
+
+ private boolean killed = false;
+ private final Display label;
+ private final HtmlColor color;
+ private final LinkRendering inlinkRendering;
+ private Display note;
+ private NotePosition notePosition;
+ private final BoxStyle style;
+ private final Url url;
+
+ public InstructionSimple(Display label, HtmlColor color, LinkRendering inlinkRendering, Swimlane swimlane,
+ BoxStyle style, Url url) {
+ super(swimlane);
+ this.url = url;
+ this.style = style;
+ this.label = label;
+ this.color = color;
+ this.inlinkRendering = inlinkRendering;
+ }
+
+ public Ftile createFtile(FtileFactory factory) {
+ Ftile result = factory.activity(label, color, getSwimlaneIn(), style);
+ if (url != null) {
+ result = factory.addUrl(result, url);
+ }
+ if (note != null) {
+ result = factory.addNote(result, note, notePosition);
+ }
+ if (killed) {
+ return new FtileKilled(result);
+ }
+ return result;
+ }
+
+ public void add(Instruction other) {
+ throw new UnsupportedOperationException();
+ }
+
+ final public boolean kill() {
+ this.killed = true;
+ return true;
+ }
+
+ public LinkRendering getInLinkRendering() {
+ return inlinkRendering;
+ }
+
+ public void addNote(Display note, NotePosition position) {
+ this.note = note;
+ this.notePosition = position;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionSplit.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionSplit.java
new file mode 100644
index 0000000..f2c0eb2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionSplit.java
@@ -0,0 +1,118 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+
+public class InstructionSplit implements Instruction {
+
+ private final List<InstructionList> splits = new ArrayList<InstructionList>();
+ private final Instruction parent;
+ private final LinkRendering inlinkRendering;
+
+ public InstructionSplit(Instruction parent, LinkRendering inlinkRendering) {
+ this.parent = parent;
+ this.splits.add(new InstructionList());
+ this.inlinkRendering = inlinkRendering;
+ }
+
+ private InstructionList getLast() {
+ return splits.get(splits.size() - 1);
+ }
+
+ public void add(Instruction ins) {
+ getLast().add(ins);
+ }
+
+ public Ftile createFtile(FtileFactory factory) {
+ final List<Ftile> all = new ArrayList<Ftile>();
+ for (InstructionList list : splits) {
+ all.add(list.createFtile(factory));
+ }
+ return factory.createSplit(all);
+ }
+
+ public Instruction getParent() {
+ return parent;
+ }
+
+ public void splitAgain(LinkRendering inlinkRendering) {
+ if (inlinkRendering != null) {
+ getLast().setOutRendering(inlinkRendering);
+ }
+ final InstructionList list = new InstructionList();
+ this.splits.add(list);
+ }
+
+ public void endSplit(LinkRendering inlinkRendering) {
+ if (inlinkRendering != null) {
+ getLast().setOutRendering(inlinkRendering);
+ }
+
+ }
+
+ final public boolean kill() {
+ return getLast().kill();
+ }
+
+ public LinkRendering getInLinkRendering() {
+ return inlinkRendering;
+ }
+
+ public void addNote(Display note, NotePosition position) {
+ getLast().addNote(note, position);
+ }
+
+ public Set<Swimlane> getSwimlanes() {
+ return InstructionList.getSwimlanes2(splits);
+ }
+
+ public Swimlane getSwimlaneIn() {
+ return parent.getSwimlaneOut();
+ }
+
+ public Swimlane getSwimlaneOut() {
+ return getLast().getSwimlaneOut();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionStart.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionStart.java
new file mode 100644
index 0000000..b75e654
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionStart.java
@@ -0,0 +1,69 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3;
+
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+
+public class InstructionStart extends MonoSwimable implements Instruction {
+
+ public InstructionStart(Swimlane swimlane) {
+ super(swimlane);
+ }
+
+ public Ftile createFtile(FtileFactory factory) {
+ return factory.start(getSwimlaneIn());
+ }
+
+ public void add(Instruction other) {
+ throw new UnsupportedOperationException();
+ }
+
+ final public boolean kill() {
+ return false;
+ }
+
+ public LinkRendering getInLinkRendering() {
+ return null;
+ }
+
+ public void addNote(Display note, NotePosition position) {
+ throw new UnsupportedOperationException();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionStop.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionStop.java
new file mode 100644
index 0000000..7f4eb3e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionStop.java
@@ -0,0 +1,72 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3;
+
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+
+public class InstructionStop extends MonoSwimable implements Instruction {
+
+ private final LinkRendering inlinkRendering;
+
+ public InstructionStop(Swimlane swimlane, LinkRendering inlinkRendering) {
+ super(swimlane);
+ this.inlinkRendering = inlinkRendering;
+ }
+
+ public Ftile createFtile(FtileFactory factory) {
+ return factory.stop(getSwimlaneIn());
+ }
+
+ public void add(Instruction other) {
+ throw new UnsupportedOperationException();
+ }
+
+ final public boolean kill() {
+ return false;
+ }
+
+ public LinkRendering getInLinkRendering() {
+ return inlinkRendering;
+ }
+
+ public void addNote(Display note, NotePosition position) {
+ throw new UnsupportedOperationException();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionWhile.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionWhile.java
new file mode 100644
index 0000000..28554eb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionWhile.java
@@ -0,0 +1,133 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3;
+
+import java.util.Set;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileWithNoteOpale;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+
+public class InstructionWhile implements Instruction {
+
+ private final InstructionList repeatList = new InstructionList();
+ private final Instruction parent;
+ private final LinkRendering nextLinkRenderer;
+ private final HtmlColor color;
+
+ private final Display test;
+ private final Display yes;
+ private Display out;
+ private LinkRendering endInlinkRendering;
+ private LinkRendering afterEndwhile;
+ private final Swimlane swimlane;
+ private final ISkinParam skinParam;
+
+ public InstructionWhile(Swimlane swimlane, Instruction parent, Display test, LinkRendering nextLinkRenderer,
+ Display yes, HtmlColor color, ISkinParam skinParam) {
+ this.parent = parent;
+ this.test = test;
+ this.nextLinkRenderer = nextLinkRenderer;
+ this.yes = yes;
+ this.swimlane = swimlane;
+ this.color = color;
+ this.skinParam = skinParam;
+ }
+
+ public void add(Instruction ins) {
+ repeatList.add(ins);
+ }
+
+ private Display note;
+ private NotePosition position;
+
+ public Ftile createFtile(FtileFactory factory) {
+ Ftile tmp = factory.decorateOut(repeatList.createFtile(factory), endInlinkRendering);
+ tmp = factory.createWhile(swimlane, tmp, test, yes, out, afterEndwhile, color);
+ if (note != null) {
+ tmp = new FtileWithNoteOpale(tmp, note, position, skinParam, false);
+ }
+ // tmp = factory.decorateOut(tmp, afterEndwhile);
+ return tmp;
+ }
+
+ public Instruction getParent() {
+ return parent;
+ }
+
+ final public boolean kill() {
+ return repeatList.kill();
+ }
+
+ public LinkRendering getInLinkRendering() {
+ return nextLinkRenderer;
+ }
+
+ public void endwhile(LinkRendering nextLinkRenderer, Display out) {
+ this.endInlinkRendering = nextLinkRenderer;
+ this.out = out;
+ }
+
+ public void afterEndwhile(LinkRendering linkRenderer) {
+ this.afterEndwhile = linkRenderer;
+ }
+
+ public void addNote(Display note, NotePosition position) {
+ if (repeatList.isEmpty()) {
+ this.note = note;
+ this.position = position;
+ } else {
+ repeatList.addNote(note, position);
+ }
+ }
+
+ public Set<Swimlane> getSwimlanes() {
+ return repeatList.getSwimlanes();
+ }
+
+ public Swimlane getSwimlaneIn() {
+ return parent.getSwimlaneOut();
+ }
+
+ public Swimlane getSwimlaneOut() {
+ return getSwimlaneIn();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/LinkRendering.java b/src/net/sourceforge/plantuml/activitydiagram3/LinkRendering.java
new file mode 100644
index 0000000..8883338
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/LinkRendering.java
@@ -0,0 +1,87 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3;
+
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+
+public class LinkRendering {
+
+ private final HtmlColor color;
+ private Display display;
+
+ public LinkRendering(HtmlColor color) {
+ this.color = color;
+ }
+
+ public void setDisplay(Display display) {
+ this.display = display;
+ }
+
+ public Display getDisplay() {
+ return display;
+ }
+
+ public HtmlColor getColor() {
+ return color;
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + " " + display + " " + color;
+ }
+
+ public static HtmlColor getColor(LinkRendering inLinkRendering, HtmlColor defaultColor) {
+ if (inLinkRendering == null || inLinkRendering.getColor() == null) {
+ return defaultColor;
+ }
+ return inLinkRendering.getColor();
+ }
+
+ public static HtmlColor getColor(HtmlColor col, HtmlColor defaultColor) {
+ if (col == null) {
+ return defaultColor;
+ }
+ return col;
+ }
+
+ public static Display getDisplay(LinkRendering linkRendering) {
+ if (linkRendering == null) {
+ return null;
+ }
+ return linkRendering.getDisplay();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/MonoSwimable.java b/src/net/sourceforge/plantuml/activitydiagram3/MonoSwimable.java
new file mode 100644
index 0000000..c6f49a3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/MonoSwimable.java
@@ -0,0 +1,63 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3;
+
+import java.util.Collections;
+import java.util.Set;
+
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimable;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+
+public class MonoSwimable implements Swimable {
+
+ private final Swimlane swimlane;
+
+ public MonoSwimable(Swimlane swimlane) {
+ this.swimlane = swimlane;
+ }
+
+ final public Set<Swimlane> getSwimlanes() {
+ return swimlane == null ? Collections.<Swimlane> emptySet() : Collections.<Swimlane> singleton(swimlane);
+ }
+
+ final public Swimlane getSwimlaneIn() {
+ return swimlane;
+ }
+
+ final public Swimlane getSwimlaneOut() {
+ return swimlane;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivity3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivity3.java
new file mode 100644
index 0000000..16d7b1f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivity3.java
@@ -0,0 +1,86 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.command;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.activitydiagram3.ftile.BoxStyle;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+
+public class CommandActivity3 extends SingleLineCommand2<ActivityDiagram3> {
+
+ public static final String ENDING_GROUP = "(;|(?<![/|<>}\\]])(?:[/<}\\]])|(?<!\\</?\\w{1,5})(?<!\\<img[^>]{1,999})(?<!\\<\\$\\w{1,999})(?<!\\>)(?:\\>)|(?<!\\|.{1,999})(?:\\|))";
+
+ public CommandActivity3() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
+ new RegexLeaf("COLOR", "(?::?(" + HtmlColorUtils.COLOR_REGEXP + "))?"), //
+ new RegexLeaf(":"), //
+ new RegexLeaf("LABEL", "(.*)"), //
+ new RegexLeaf("STYLE", ENDING_GROUP), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
+
+ final Url url;
+ if (arg.get("URL", 0) == null) {
+ url = null;
+ } else {
+ final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
+ url = urlBuilder.getUrl(arg.get("URL", 0));
+ }
+
+ final HtmlColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0));
+ final BoxStyle style = BoxStyle.fromChar(arg.get("STYLE", 0).charAt(0));
+ diagram.addActivity(Display.getWithNewlines(arg.get("LABEL", 0)), color, style, url);
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivityLegacy1.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivityLegacy1.java
new file mode 100644
index 0000000..1b3ea3f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivityLegacy1.java
@@ -0,0 +1,65 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.command;
+
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.activitydiagram3.ftile.BoxStyle;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Display;
+
+public class CommandActivityLegacy1 extends SingleLineCommand2<ActivityDiagram3> {
+
+ public CommandActivityLegacy1() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("-"), //
+ new RegexLeaf("LABEL", "(.*)"), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
+ diagram.addActivity(Display.getWithNewlines(arg.get("LABEL", 0)), null, BoxStyle.PLAIN, null);
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivityLong3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivityLong3.java
new file mode 100644
index 0000000..4f70a4b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandActivityLong3.java
@@ -0,0 +1,103 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.activitydiagram3.ftile.BoxStyle;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.CommandMultilines2;
+import net.sourceforge.plantuml.command.MultilinesStrategy;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.StringUtils;
+
+public class CommandActivityLong3 extends CommandMultilines2<ActivityDiagram3> {
+
+ public CommandActivityLong3() {
+ super(getRegexConcat(), MultilinesStrategy.REMOVE_STARTING_QUOTE);
+ }
+
+ @Override
+ public String getPatternEnd() {
+ return "^(.*)" + CommandActivity3.ENDING_GROUP + "$";
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("COLOR", "(?::?(" + HtmlColorUtils.COLOR_REGEXP + "))?"), //
+ new RegexLeaf(":"), //
+ new RegexLeaf("DATA", "(.*)"), //
+ new RegexLeaf("$"));
+ }
+
+ public CommandExecutionResult executeNow(ActivityDiagram3 diagram, List<String> lines) {
+ lines = StringUtils.removeEmptyColumns(lines);
+ final RegexResult line0 = getStartingPattern().matcher(lines.get(0).trim());
+ final HtmlColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(line0.get("COLOR", 0));
+ final BoxStyle style = BoxStyle.fromChar(getLastChar(lines));
+ removeStarting(lines, line0.get("DATA", 0));
+ removeEnding(lines);
+ diagram.addActivity(Display.create(lines), color, style, null);
+ return CommandExecutionResult.ok();
+ }
+
+ private char getLastChar(List<String> lines) {
+ final String s = lines.get(lines.size() - 1);
+ return s.charAt(s.length() - 1);
+ }
+
+ private void removeStarting(List<String> lines, String data) {
+ if (lines.size() == 0) {
+ return;
+ }
+ lines.set(0, data);
+ }
+
+ private void removeEnding(List<String> lines) {
+ if (lines.size() == 0) {
+ return;
+ }
+ final int n = lines.size() - 1;
+ final String s = lines.get(n);
+ lines.set(n, s.substring(0, s.length() - 1));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandArrow3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandArrow3.java
new file mode 100644
index 0000000..5b9469e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandArrow3.java
@@ -0,0 +1,78 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.command;
+
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexOr;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+
+public class CommandArrow3 extends SingleLineCommand2<ActivityDiagram3> {
+
+ public CommandArrow3() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexOr(//
+ new RegexLeaf("->"), //
+ new RegexLeaf("COLOR", "-\\[(#\\w+)\\]->")), //
+ new RegexLeaf("[%s]*"), //
+ new RegexOr(//
+ new RegexLeaf("LABEL", "(.*);"), //
+ new RegexLeaf("")), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
+
+ final HtmlColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0));
+ diagram.setColorNextArrow(color);
+ final String label = arg.get("LABEL", 0);
+ if (label != null && label.length() > 0) {
+ diagram.setLabelNextArrow(Display.getWithNewlines(label));
+ }
+
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandArrowLong3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandArrowLong3.java
new file mode 100644
index 0000000..a7b0789
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandArrowLong3.java
@@ -0,0 +1,99 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.CommandMultilines2;
+import net.sourceforge.plantuml.command.MultilinesStrategy;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexOr;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.StringUtils;
+
+public class CommandArrowLong3 extends CommandMultilines2<ActivityDiagram3> {
+
+ public CommandArrowLong3() {
+ super(getRegexConcat(), MultilinesStrategy.REMOVE_STARTING_QUOTE);
+ }
+
+ @Override
+ public String getPatternEnd() {
+ return "^(.*);$";
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexOr(//
+ new RegexLeaf("->"), //
+ new RegexLeaf("COLOR", "-\\[(#\\w+)\\]->")), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("LABEL", "(.*)"), //
+ new RegexLeaf("$"));
+ }
+
+ public CommandExecutionResult executeNow(ActivityDiagram3 diagram, List<String> lines) {
+ lines = StringUtils.removeEmptyColumns(lines);
+ final RegexResult line0 = getStartingPattern().matcher(lines.get(0).trim());
+ final HtmlColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(line0.get("COLOR", 0));
+ diagram.setColorNextArrow(color);
+ removeStarting(lines, line0.get("LABEL", 0));
+ removeEnding(lines);
+ diagram.setLabelNextArrow(Display.create(lines));
+ return CommandExecutionResult.ok();
+ }
+
+ private void removeStarting(List<String> lines, String data) {
+ if (lines.size() == 0) {
+ return;
+ }
+ lines.set(0, data);
+ }
+
+ private void removeEnding(List<String> lines) {
+ if (lines.size() == 0) {
+ return;
+ }
+ final int n = lines.size() - 1;
+ final String s = lines.get(n);
+ lines.set(n, s.substring(0, s.length() - 1));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandElse3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandElse3.java
new file mode 100644
index 0000000..2c2b9d3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandElse3.java
@@ -0,0 +1,67 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.command;
+
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Display;
+
+public class CommandElse3 extends SingleLineCommand2<ActivityDiagram3> {
+
+ public CommandElse3() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(//
+ new RegexLeaf("^"), //
+ new RegexLeaf("else"), //
+ new RegexLeaf("WHEN", "(?:[%s]*(?:\\(([^()]*)\\))?)?"), //
+ new RegexLeaf(";?$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
+ // if (getSystem().getLastEntityConsulted() == null) {
+ // return CommandExecutionResult.error("No if for this endif");
+ // }
+ return diagram.else2(Display.getWithNewlines(arg.get("WHEN", 0)));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandElseIf2.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandElseIf2.java
new file mode 100644
index 0000000..0bc837e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandElseIf2.java
@@ -0,0 +1,77 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.command;
+
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorSet;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+
+public class CommandElseIf2 extends SingleLineCommand2<ActivityDiagram3> {
+
+ public CommandElseIf2() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("COLOR", "(?:(" + HtmlColorUtils.COLOR_REGEXP + "):)?"), //
+ new RegexLeaf("else[%s]*if"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("TEST", "\\((.*?)\\)"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("WHEN", "(?:then[%s]*(?:\\((.+?)\\))?)?"), //
+ new RegexLeaf(";?$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
+ final HtmlColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0));
+
+ String test = arg.get("TEST", 0);
+ if (test.length() == 0) {
+ test = null;
+ }
+
+ return diagram.elseIf(Display.getWithNewlines(test), Display.getWithNewlines(arg.get("WHEN", 0)), color);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandElseLegacy1.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandElseLegacy1.java
new file mode 100644
index 0000000..97f036e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandElseLegacy1.java
@@ -0,0 +1,67 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.command;
+
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Display;
+
+public class CommandElseLegacy1 extends SingleLineCommand2<ActivityDiagram3> {
+
+ public CommandElseLegacy1() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(//
+ new RegexLeaf("^"), //
+ new RegexLeaf("else[%s]when"), //
+ new RegexLeaf("WHEN", "[%s]+(.*)"), //
+ new RegexLeaf(";?$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
+ // if (getSystem().getLastEntityConsulted() == null) {
+ // return CommandExecutionResult.error("No if for this endif");
+ // }
+ return diagram.else2(Display.getWithNewlines(arg.get("WHEN", 0)));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandEndPartition3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandEndPartition3.java
new file mode 100644
index 0000000..26f2798
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandEndPartition3.java
@@ -0,0 +1,58 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+
+public class CommandEndPartition3 extends SingleLineCommand<ActivityDiagram3> {
+
+ public CommandEndPartition3() {
+ super("(?i)^(\\})$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, List<String> arg) {
+// final IEntity currentPackage = diagram.getCurrentGroup();
+// if (currentPackage == null) {
+// return CommandExecutionResult.error("No partition defined");
+// }
+ return diagram.endGroup();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandEndif3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandEndif3.java
new file mode 100644
index 0000000..b6cac84
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandEndif3.java
@@ -0,0 +1,65 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.command;
+
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+
+public class CommandEndif3 extends SingleLineCommand2<ActivityDiagram3> {
+
+ public CommandEndif3() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(//
+ new RegexLeaf("^"), //
+ new RegexLeaf("endif"), //
+ new RegexLeaf(";?$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
+ // if (getSystem().getLastEntityConsulted() == null) {
+ // return CommandExecutionResult.error("No if for this endif");
+ // }
+ return diagram.endif();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandFork3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandFork3.java
new file mode 100644
index 0000000..1cdca1e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandFork3.java
@@ -0,0 +1,64 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.command;
+
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+
+public class CommandFork3 extends SingleLineCommand2<ActivityDiagram3> {
+
+ public CommandFork3() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(//
+ new RegexLeaf("^"), //
+ new RegexLeaf("fork"), //
+ new RegexLeaf(";?$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
+ diagram.fork();
+
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandForkAgain3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandForkAgain3.java
new file mode 100644
index 0000000..8026bec
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandForkAgain3.java
@@ -0,0 +1,63 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.command;
+
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+
+public class CommandForkAgain3 extends SingleLineCommand2<ActivityDiagram3> {
+
+ public CommandForkAgain3() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(//
+ new RegexLeaf("^"), //
+ new RegexLeaf("fork[%s]?again"), //
+ new RegexLeaf(";?$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
+ return diagram.forkAgain();
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandForkEnd3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandForkEnd3.java
new file mode 100644
index 0000000..a25d215
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandForkEnd3.java
@@ -0,0 +1,62 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.command;
+
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+
+public class CommandForkEnd3 extends SingleLineCommand2<ActivityDiagram3> {
+
+ public CommandForkEnd3() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(//
+ new RegexLeaf("^"), //
+ new RegexLeaf("(end[%s]?fork|fork[%s]?end)"), //
+ new RegexLeaf(";?$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
+ return diagram.endFork();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandGoto.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandGoto.java
new file mode 100644
index 0000000..2a9658a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandGoto.java
@@ -0,0 +1,65 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.command;
+
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+
+public class CommandGoto extends SingleLineCommand2<ActivityDiagram3> {
+
+ public CommandGoto() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("goto"), //
+ new RegexLeaf("[%s]+"), //
+ new RegexLeaf("NAME", "([\\p{L}0-9_.]+)"), //
+ new RegexLeaf(";?"), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
+ final String name = arg.get("NAME", 0);
+ return diagram.addGoto(name);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandGroup3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandGroup3.java
new file mode 100644
index 0000000..0384587
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandGroup3.java
@@ -0,0 +1,65 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.command;
+
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Display;
+
+public class CommandGroup3 extends SingleLineCommand2<ActivityDiagram3> {
+
+ public CommandGroup3() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("group"), //
+ new RegexLeaf("\\s*"), //
+ new RegexLeaf("NAME", "(.*)"), //
+ new RegexLeaf(";?$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
+ diagram.startGroup(Display.getWithNewlines(arg.get("NAME", 0)), null, null);
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandGroupEnd3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandGroupEnd3.java
new file mode 100644
index 0000000..60947ff
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandGroupEnd3.java
@@ -0,0 +1,61 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.command;
+
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+
+public class CommandGroupEnd3 extends SingleLineCommand2<ActivityDiagram3> {
+
+ public CommandGroupEnd3() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("(end ?group|group ?end)"), //
+ new RegexLeaf(";?$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
+ return diagram.endGroup();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf2.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf2.java
new file mode 100644
index 0000000..37e6ca7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf2.java
@@ -0,0 +1,78 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.command;
+
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+
+public class CommandIf2 extends SingleLineCommand2<ActivityDiagram3> {
+
+ public CommandIf2() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("COLOR", "(?:(" + HtmlColorUtils.COLOR_REGEXP + "):)?"), //
+ new RegexLeaf("if"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("TEST", "\\((.*?)\\)"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("WHEN", "(?:then[%s]*(?:\\((.+?)\\))?)?"), //
+ new RegexLeaf(";?$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
+ final HtmlColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0));
+
+ String test = arg.get("TEST", 0);
+ if (test.length() == 0) {
+ test = null;
+ }
+
+ diagram.startIf(Display.getWithNewlines(test), Display.getWithNewlines(arg.get("WHEN", 0)), color);
+
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf2Multilines.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf2Multilines.java
new file mode 100644
index 0000000..cf0c812
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf2Multilines.java
@@ -0,0 +1,95 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.CommandMultilines2;
+import net.sourceforge.plantuml.command.MultilinesStrategy;
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.StringUtils;
+
+public class CommandIf2Multilines extends CommandMultilines2<ActivityDiagram3> {
+
+ public CommandIf2Multilines() {
+ super(getRegexConcat(), MultilinesStrategy.REMOVE_STARTING_QUOTE);
+ }
+
+ @Override
+ public String getPatternEnd() {
+ return "(?i)^(.*?)\\)[%s]*(?:then[%s]*(?:\\((.+?)\\))?)?;?$";
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("COLOR", "(?:(" + HtmlColorUtils.COLOR_REGEXP + "):)?"), //
+ new RegexLeaf("if"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("\\("), //
+ new RegexLeaf("TEST", "([^)]*)$"));
+ }
+
+ @Override
+ public CommandExecutionResult executeNow(ActivityDiagram3 diagram, List<String> lines) {
+ StringUtils.trim(lines, false);
+ final RegexResult line0 = getStartingPattern().matcher(lines.get(0).trim());
+ final List<String> lineLast = StringUtils.getSplit(MyPattern.cmpile(getPatternEnd()),
+ lines.get(lines.size() - 1));
+
+ final HtmlColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(line0.get("COLOR", 0));
+
+ final String test = line0.get("TEST", 0);
+ Display testDisplay = Display.getWithNewlines(test);
+ for (int i = 1; i < lines.size() - 1; i++) {
+ testDisplay = testDisplay.add(lines.get(i));
+ }
+ final String trailTest = lineLast.get(0);
+ if (StringUtils.isEmpty(trailTest) == false) {
+ testDisplay = testDisplay.add(trailTest);
+ }
+
+ diagram.startIf(testDisplay, Display.getWithNewlines(lineLast.get(1)), color);
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf4.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf4.java
new file mode 100644
index 0000000..a0d0d11
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIf4.java
@@ -0,0 +1,77 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.command;
+
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+
+public class CommandIf4 extends SingleLineCommand2<ActivityDiagram3> {
+
+ public CommandIf4() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("COLOR", "(?:(" + HtmlColorUtils.COLOR_REGEXP + "):)?"), //
+ new RegexLeaf("if"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("TEST", "\\((.*?)\\)"), //
+ new RegexLeaf("[%s]*(is|equals?)[%s]*"), //
+ new RegexLeaf("WHEN", "\\((.+?)\\)"), //
+ new RegexLeaf("[%s]*then[%s]*"), //
+ new RegexLeaf(";?$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
+ final HtmlColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0));
+
+ String test = arg.get("TEST", 0);
+ if (test.length() == 0) {
+ test = null;
+ }
+ diagram.startIf(Display.getWithNewlines(test), Display.getWithNewlines(arg.get("WHEN", 0)), color);
+
+ return CommandExecutionResult.ok();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIfLegacy1.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIfLegacy1.java
new file mode 100644
index 0000000..e14386e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandIfLegacy1.java
@@ -0,0 +1,69 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.command;
+
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Display;
+
+public class CommandIfLegacy1 extends SingleLineCommand2<ActivityDiagram3> {
+
+ public CommandIfLegacy1() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("if"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("TEST", "\\((.+?)\\)"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("WHEN", "then[%s]when[%s]+(.*)"), //
+ new RegexLeaf(";?$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
+
+ diagram.startIf(Display.getWithNewlines(arg.get("TEST", 0)), Display.getWithNewlines(arg.get("WHEN", 0)), null);
+
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandKill3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandKill3.java
new file mode 100644
index 0000000..45432bf
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandKill3.java
@@ -0,0 +1,62 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.command;
+
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+
+public class CommandKill3 extends SingleLineCommand2<ActivityDiagram3> {
+
+ public CommandKill3() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(//
+ new RegexLeaf("^"), //
+ new RegexLeaf("kill|detach"), //
+ new RegexLeaf(";?$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
+ return diagram.kill();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandLabel.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandLabel.java
new file mode 100644
index 0000000..62171b6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandLabel.java
@@ -0,0 +1,66 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.command;
+
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+
+public class CommandLabel extends SingleLineCommand2<ActivityDiagram3> {
+
+ public CommandLabel() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("label"), //
+ new RegexLeaf("[%s]+"), //
+ new RegexLeaf("NAME", "([\\p{L}0-9_.]+)"), //
+ new RegexLeaf(";?"), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
+
+ final String name = arg.get("NAME", 0);
+ return diagram.addLabel(name);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandLink3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandLink3.java
new file mode 100644
index 0000000..15fc795
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandLink3.java
@@ -0,0 +1,68 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.command;
+
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+
+public class CommandLink3 extends SingleLineCommand2<ActivityDiagram3> {
+
+ public CommandLink3() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("link[%s]+"), //
+ new RegexLeaf("COLOR", "(#\\w+)"), //
+ new RegexLeaf(";?"), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
+ final HtmlColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0));
+ if (color != null) {
+ diagram.setColorNextArrow(color);
+ }
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandNolink.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandNolink.java
new file mode 100644
index 0000000..a2f4e27
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandNolink.java
@@ -0,0 +1,65 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.command;
+
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Display;
+
+public class CommandNolink extends SingleLineCommand2<ActivityDiagram3> {
+
+ public CommandNolink() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("nolink"), //
+ new RegexLeaf(";?"), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
+ // diagram.setColorNextArrow(color);
+ diagram.setLabelNextArrow(Display.getWithNewlines("NOLINK"));
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandNote3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandNote3.java
new file mode 100644
index 0000000..9bb2691
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandNote3.java
@@ -0,0 +1,76 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.command;
+
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+
+public class CommandNote3 extends SingleLineCommand2<ActivityDiagram3> {
+
+ public CommandNote3() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("note"), //
+ new RegexLeaf("POSITION", "[%s]*(left|right)?"), //
+ new RegexLeaf("[%s]*:[%s]*"), //
+ new RegexLeaf("NOTE", "(.*)"), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
+ final Display note = Display.getWithNewlines(arg.get("NOTE", 0));
+ final NotePosition position = getPosition(arg.get("POSITION", 0));
+ return diagram.addNote(note, position);
+ }
+
+ private NotePosition getPosition(String s) {
+ if (s == null) {
+ return NotePosition.LEFT;
+ }
+ return NotePosition.valueOf(StringUtils.goUpperCase(s));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandNoteLong3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandNoteLong3.java
new file mode 100644
index 0000000..34ee7bd
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandNoteLong3.java
@@ -0,0 +1,83 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.CommandMultilines2;
+import net.sourceforge.plantuml.command.MultilinesStrategy;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+import net.sourceforge.plantuml.StringUtils;
+
+public class CommandNoteLong3 extends CommandMultilines2<ActivityDiagram3> {
+
+ public CommandNoteLong3() {
+ super(getRegexConcat(), MultilinesStrategy.REMOVE_STARTING_QUOTE);
+ }
+
+ public String getPatternEnd() {
+ return "(?i)^end[%s]?note$";
+ }
+
+ public CommandExecutionResult executeNow(final ActivityDiagram3 diagram, List<String> lines) {
+ // final RegexResult line0 = getStartingPattern().matcher(lines.get(0).trim());
+ final List<String> in = StringUtils.removeEmptyColumns(lines.subList(1, lines.size() - 1));
+ final RegexResult line0 = getStartingPattern().matcher(lines.get(0).trim());
+ final NotePosition position = getPosition(line0.get("POSITION", 0));
+ final Display note = Display.create(in);
+ return diagram.addNote(note, position);
+ }
+
+ private NotePosition getPosition(String s) {
+ if (s == null) {
+ return NotePosition.LEFT;
+ }
+ return NotePosition.valueOf(StringUtils.goUpperCase(s));
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("note"), //
+ new RegexLeaf("POSITION", "[%s]*(left|right)?"), //
+ new RegexLeaf("$"));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandPartition3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandPartition3.java
new file mode 100644
index 0000000..c86053e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandPartition3.java
@@ -0,0 +1,74 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.command;
+
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.StringUtils;
+
+public class CommandPartition3 extends SingleLineCommand2<ActivityDiagram3> {
+
+ public CommandPartition3() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("partition"), //
+ new RegexLeaf("[%s]+"), //
+ new RegexLeaf("BACKCOLOR", "(?:(#\\w+)[%s]+)?"), //
+ new RegexLeaf("TITLECOLOR", "(?:(#\\w+)[%s]+)?"), //
+ new RegexLeaf("NAME", "([%g][^%g]+[%g]|\\S+)"), //
+ new RegexLeaf("[%s]*\\{?$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
+ final String partitionTitle = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("NAME", 0));
+ final HtmlColor backColor = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("BACKCOLOR", 0));
+ final HtmlColor titleColor = diagram.getSkinParam().getIHtmlColorSet()
+ .getColorIfValid(arg.get("TITLECOLOR", 0));
+ diagram.startGroup(Display.getWithNewlines(partitionTitle), backColor, titleColor);
+
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeat3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeat3.java
new file mode 100644
index 0000000..c8c4c29
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeat3.java
@@ -0,0 +1,68 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.command;
+
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+
+public class CommandRepeat3 extends SingleLineCommand2<ActivityDiagram3> {
+
+ public CommandRepeat3() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("COLOR", "(?:(" + HtmlColorUtils.COLOR_REGEXP + "):)?"), //
+ new RegexLeaf("repeat"), //
+ new RegexLeaf(";?$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
+ final HtmlColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0));
+
+ diagram.startRepeat(color);
+
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeatWhile3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeatWhile3.java
new file mode 100644
index 0000000..916f41e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandRepeatWhile3.java
@@ -0,0 +1,97 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.command;
+
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexOptional;
+import net.sourceforge.plantuml.command.regex.RegexOr;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+
+public class CommandRepeatWhile3 extends SingleLineCommand2<ActivityDiagram3> {
+
+ public CommandRepeatWhile3() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(//
+ new RegexLeaf("^"), //
+ new RegexLeaf("repeat[%s]?while"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexOr(//
+ new RegexConcat(new RegexLeaf("TEST3", "\\((.*?)\\)"), //
+ new RegexLeaf("[%s]*(is|equals?)[%s]*"), //
+ new RegexLeaf("WHEN3", "\\((.+?)\\)"), //
+ new RegexLeaf("[%s]*(not)[%s]*"), //
+ new RegexLeaf("OUT3", "\\((.+?)\\)")), //
+ new RegexConcat(new RegexLeaf("TEST4", "\\((.*?)\\)"), //
+ new RegexLeaf("[%s]*(not)[%s]*"), //
+ new RegexLeaf("OUT4", "\\((.+?)\\)")), //
+ new RegexConcat(new RegexLeaf("TEST2", "\\((.*?)\\)"), //
+ new RegexLeaf("[%s]*(is|equals?)[%s]*"), //
+ new RegexLeaf("WHEN2", "\\((.+?)\\)") //
+ ), //
+ new RegexLeaf("TEST1", "(?:\\((.*)\\))?") //
+ ), //
+ new RegexLeaf("[%s]*"), //
+ new RegexOptional(new RegexConcat( //
+ new RegexOr(//
+ new RegexLeaf("->"), //
+ new RegexLeaf("COLOR", "-\\[(#\\w+)\\]->")), //
+ new RegexLeaf("[%s]*"), //
+ new RegexOr(//
+ new RegexLeaf("LABEL", "(.*)"), //
+ new RegexLeaf("")) //
+ )), //
+ new RegexLeaf(";?$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
+ final Display test = Display.getWithNewlines(arg.getLazzy("TEST", 0));
+ final Display yes = Display.getWithNewlines(arg.getLazzy("WHEN", 0));
+ final Display out = Display.getWithNewlines(arg.getLazzy("OUT", 0));
+ final HtmlColor linkColor = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0));
+ final Display linkLabel = Display.getWithNewlines(arg.get("LABEL", 0));
+ return diagram.repeatWhile(test, yes, out, linkLabel, linkColor);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSplit3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSplit3.java
new file mode 100644
index 0000000..7d95a9a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSplit3.java
@@ -0,0 +1,64 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.command;
+
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+
+public class CommandSplit3 extends SingleLineCommand2<ActivityDiagram3> {
+
+ public CommandSplit3() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(//
+ new RegexLeaf("^"), //
+ new RegexLeaf("split"), //
+ new RegexLeaf(";?$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
+ diagram.split();
+
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSplitAgain3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSplitAgain3.java
new file mode 100644
index 0000000..ea73e9f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSplitAgain3.java
@@ -0,0 +1,63 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.command;
+
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+
+public class CommandSplitAgain3 extends SingleLineCommand2<ActivityDiagram3> {
+
+ public CommandSplitAgain3() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(//
+ new RegexLeaf("^"), //
+ new RegexLeaf("split[%s]?again"), //
+ new RegexLeaf(";?$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
+ return diagram.splitAgain();
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSplitEnd3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSplitEnd3.java
new file mode 100644
index 0000000..68b76e4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSplitEnd3.java
@@ -0,0 +1,62 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.command;
+
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+
+public class CommandSplitEnd3 extends SingleLineCommand2<ActivityDiagram3> {
+
+ public CommandSplitEnd3() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(//
+ new RegexLeaf("^"), //
+ new RegexLeaf("(end[%s]?split|split[%s]?end)"), //
+ new RegexLeaf(";?$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
+ return diagram.endSplit();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandStart3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandStart3.java
new file mode 100644
index 0000000..cb81024
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandStart3.java
@@ -0,0 +1,67 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.command;
+
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+
+public class CommandStart3 extends SingleLineCommand2<ActivityDiagram3> {
+
+ public CommandStart3() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(//
+ new RegexLeaf("^"), //
+ new RegexLeaf("start"), //
+ new RegexLeaf(";?$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
+ // if (getSystem().getLastEntityConsulted() == null) {
+ // return CommandExecutionResult.error("No if for this endif");
+ // }
+ diagram.start();
+
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandStop3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandStop3.java
new file mode 100644
index 0000000..ae7c128
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandStop3.java
@@ -0,0 +1,67 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.command;
+
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+
+public class CommandStop3 extends SingleLineCommand2<ActivityDiagram3> {
+
+ public CommandStop3() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(//
+ new RegexLeaf("^"), //
+ new RegexLeaf("stop"), //
+ new RegexLeaf(";?$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
+ // if (getSystem().getLastEntityConsulted() == null) {
+ // return CommandExecutionResult.error("No if for this endif");
+ // }
+ diagram.stop();
+
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandStopLegacy1.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandStopLegacy1.java
new file mode 100644
index 0000000..afc103e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandStopLegacy1.java
@@ -0,0 +1,67 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.command;
+
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+
+public class CommandStopLegacy1 extends SingleLineCommand2<ActivityDiagram3> {
+
+ public CommandStopLegacy1() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(//
+ new RegexLeaf("^"), //
+ new RegexLeaf("end"), //
+ new RegexLeaf(";?$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
+ // if (getSystem().getLastEntityConsulted() == null) {
+ // return CommandExecutionResult.error("No if for this endif");
+ // }
+ diagram.stop();
+
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSwimlane.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSwimlane.java
new file mode 100644
index 0000000..0024161
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSwimlane.java
@@ -0,0 +1,71 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.command;
+
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+
+public class CommandSwimlane extends SingleLineCommand2<ActivityDiagram3> {
+
+ public CommandSwimlane() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("\\|"), //
+ new RegexLeaf("COLOR", "(?:(" + HtmlColorUtils.COLOR_REGEXP + ")\\|)?"), //
+ new RegexLeaf("SWIMLANE", "([^|]+)"), //
+ new RegexLeaf("\\|"), //
+ new RegexLeaf("LABEL", "([^|]+)?"), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
+ final HtmlColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0));
+ final String name = arg.get("SWIMLANE", 0);
+ final Display label = Display.getWithNewlines(arg.get("LABEL", 0));
+ return diagram.swimlane(name, color, label);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSwimlane2.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSwimlane2.java
new file mode 100644
index 0000000..428b0eb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandSwimlane2.java
@@ -0,0 +1,71 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.command;
+
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+
+public class CommandSwimlane2 extends SingleLineCommand2<ActivityDiagram3> {
+
+ public CommandSwimlane2() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("swimlane[%s]+"), //
+ new RegexLeaf("COLOR", "(?:(" + HtmlColorUtils.COLOR_REGEXP + "))?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("SWIMLANE", "([^|]+)"), //
+ new RegexLeaf("LABEL", "(?:[%s]+as[%s]+([^|]+))?"), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
+ final HtmlColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0));
+ final String name = arg.get("SWIMLANE", 0);
+ final Display label = Display.getWithNewlines(arg.get("LABEL", 0));
+ return diagram.swimlane(name, color, label);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandWhile3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandWhile3.java
new file mode 100644
index 0000000..55c6395
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandWhile3.java
@@ -0,0 +1,75 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.command;
+
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexOptional;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorSet;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+
+public class CommandWhile3 extends SingleLineCommand2<ActivityDiagram3> {
+
+ public CommandWhile3() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(//
+ new RegexLeaf("^"), //
+ new RegexLeaf("COLOR", "(?:(" + HtmlColorUtils.COLOR_REGEXP + "):)?"), //
+ new RegexLeaf("while"), //
+ new RegexLeaf("TEST", "[%s]*\\((.+?)\\)"), //
+ new RegexOptional(new RegexConcat(//
+ new RegexLeaf("[%s]*(is|equals?)[%s]*"), //
+ new RegexLeaf("YES", "\\((.+?)\\)"))), //
+ new RegexLeaf(";?$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
+ final HtmlColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0));
+ diagram.doWhile(Display.getWithNewlines(arg.get("TEST", 0)), Display.getWithNewlines(arg.get("YES", 0)), color);
+
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/command/CommandWhileEnd3.java b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandWhileEnd3.java
new file mode 100644
index 0000000..a406e13
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/command/CommandWhileEnd3.java
@@ -0,0 +1,63 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.command;
+
+import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Display;
+
+public class CommandWhileEnd3 extends SingleLineCommand2<ActivityDiagram3> {
+
+ public CommandWhileEnd3() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("(end[%s]?while|while[%s]?end)"), //
+ new RegexLeaf("OUT", "[%s]*(?:\\((.+?)\\))?"), //
+ new RegexLeaf(";?$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
+ return diagram.endwhile(Display.getWithNewlines(arg.get("OUT", 0)));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/AbstractConnection.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/AbstractConnection.java
new file mode 100644
index 0000000..61b64cb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/AbstractConnection.java
@@ -0,0 +1,60 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+public abstract class AbstractConnection implements Connection {
+
+ private final Ftile ftile1;
+ private final Ftile ftile2;
+
+ public AbstractConnection(Ftile ftile1, Ftile ftile2) {
+ this.ftile1 = ftile1;
+ this.ftile2 = ftile2;
+ }
+
+ @Override
+ public String toString() {
+ return "[" + ftile1 + "]->[" + ftile2 + "]";
+ }
+
+ final public Ftile getFtile1() {
+ return ftile1;
+ }
+
+ final public Ftile getFtile2() {
+ return ftile2;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/AbstractFtile.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/AbstractFtile.java
new file mode 100644
index 0000000..14fcb23
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/AbstractFtile.java
@@ -0,0 +1,72 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+import java.util.Collection;
+import java.util.Collections;
+
+import net.sourceforge.plantuml.activitydiagram3.LinkRendering;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public abstract class AbstractFtile implements Ftile {
+
+ private final boolean shadowing;
+
+ public AbstractFtile(boolean shadowing) {
+ this.shadowing = shadowing;
+ }
+
+ final public boolean shadowing() {
+ return shadowing;
+ }
+
+ public LinkRendering getInLinkRendering() {
+ return null;
+ }
+
+ public LinkRendering getOutLinkRendering() {
+ return null;
+ }
+
+ public Collection<Connection> getInnerConnections() {
+ return Collections.emptyList();
+ }
+
+ public UTranslate getTranslateFor(Ftile child, StringBounder stringBounder) {
+ throw new UnsupportedOperationException();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/Arrows.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Arrows.java
new file mode 100644
index 0000000..3876ce0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Arrows.java
@@ -0,0 +1,91 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+import net.sourceforge.plantuml.Direction;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+
+public class Arrows {
+
+ final static private double delta1 = 10;
+ final static private double delta2 = 4;
+
+ public static UPolygon asToUp() {
+ final UPolygon polygon = new UPolygon();
+ polygon.addPoint(-delta2, delta1);
+ polygon.addPoint(0, 0);
+ polygon.addPoint(delta2, delta1);
+ polygon.addPoint(0, delta1 - 4);
+ return polygon;
+ }
+
+ public static UPolygon asToDown() {
+ final UPolygon polygon = new UPolygon();
+ polygon.addPoint(-delta2, -delta1);
+ polygon.addPoint(0, 0);
+ polygon.addPoint(delta2, -delta1);
+ polygon.addPoint(0, -delta1 + 4);
+ return polygon;
+ }
+
+ public static UPolygon asToRight() {
+ final UPolygon polygon = new UPolygon();
+ polygon.addPoint(-delta1, -delta2);
+ polygon.addPoint(0, 0);
+ polygon.addPoint(-delta1, delta2);
+ polygon.addPoint(-delta1 + 4, 0);
+ return polygon;
+ }
+
+ public static UPolygon asToLeft() {
+ final UPolygon polygon = new UPolygon();
+ polygon.addPoint(delta1, -delta2);
+ polygon.addPoint(0, 0);
+ polygon.addPoint(delta1, delta2);
+ polygon.addPoint(delta1 - 4, 0);
+ return polygon;
+ }
+
+ public static UPolygon asTo(Direction direction) {
+ if (direction == Direction.UP) {
+ return asToUp();
+ }
+ if (direction == Direction.DOWN) {
+ return asToDown();
+ }
+ throw new IllegalArgumentException();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/BoxStyle.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/BoxStyle.java
new file mode 100644
index 0000000..81c552a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/BoxStyle.java
@@ -0,0 +1,176 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.ugraphic.Shadowable;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.USegmentType;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+// Created from Luc Trudeau original work
+public enum BoxStyle {
+ PLAIN {
+ @Override
+ protected Shadowable getShape(double width, double height) {
+ return new URectangle(width, height, CORNER, CORNER);
+ }
+ },
+ SDL_INPUT('<') {
+ @Override
+ protected Shadowable getShape(double width, double height) {
+ final UPolygon result = new UPolygon();
+ result.addPoint(0, 0);
+ result.addPoint(width + DELTA_INPUT_OUTPUT, 0);
+ result.addPoint(width, height / 2);
+ result.addPoint(width + DELTA_INPUT_OUTPUT, height);
+ result.addPoint(0, height);
+ return result;
+ }
+ },
+ SDL_OUTPUT('>') {
+ @Override
+ protected Shadowable getShape(double width, double height) {
+ final UPolygon result = new UPolygon();
+ result.addPoint(0.0, 0.0);
+ result.addPoint(width, 0.0);
+ result.addPoint(width + DELTA_INPUT_OUTPUT, height / 2);
+ result.addPoint(width, height);
+ result.addPoint(0.0, height);
+ return result;
+ }
+ },
+ SDL_PROCEDURE('|') {
+ @Override
+ protected void drawInternal(UGraphic ug, double width, double height, boolean shadowing) {
+ final URectangle rect = new URectangle(width, height);
+ if (shadowing) {
+ rect.setDeltaShadow(3);
+ }
+ ug.draw(rect);
+ final ULine vline = new ULine(0, height);
+ ug.apply(new UTranslate(PADDING, 0)).draw(vline);
+ ug.apply(new UTranslate(width - PADDING, 0)).draw(vline);
+ }
+ },
+ SDL_SAVE('/') {
+ @Override
+ protected Shadowable getShape(double width, double height) {
+ final UPolygon result = new UPolygon();
+ result.addPoint(0.0, 0.0);
+ result.addPoint(width - DELTA_INPUT_OUTPUT, 0.0);
+ result.addPoint(width, height);
+ result.addPoint(DELTA_INPUT_OUTPUT, height);
+ return result;
+ }
+ },
+ SDL_CONTINUOUS('}') {
+ @Override
+ protected Shadowable getShape(double width, double height) {
+ final UPath result = new UPath();
+ final double c1[] = { DELTA_CONTINUOUS, 0 };
+ final double c2[] = { 0, height / 2 };
+ final double c3[] = { DELTA_CONTINUOUS, height };
+
+ result.add(c1, USegmentType.SEG_MOVETO);
+ result.add(c2, USegmentType.SEG_LINETO);
+ result.add(c3, USegmentType.SEG_LINETO);
+
+ final double c4[] = { width - DELTA_CONTINUOUS, 0 };
+ final double c5[] = { width, height / 2 };
+ final double c6[] = { width - DELTA_CONTINUOUS, height };
+
+ result.add(c4, USegmentType.SEG_MOVETO);
+ result.add(c5, USegmentType.SEG_LINETO);
+ result.add(c6, USegmentType.SEG_LINETO);
+ return result;
+ }
+ },
+ SDL_TASK(']') {
+ @Override
+ protected Shadowable getShape(double width, double height) {
+ return new URectangle(width, height);
+ }
+ };
+
+ private static final int CORNER = 25;
+ private final char style;
+ private static int DELTA_INPUT_OUTPUT = 10;
+ private static double DELTA_CONTINUOUS = 5.0;
+ private static int PADDING = 5;
+
+ private BoxStyle() {
+ this('\0');
+ }
+
+ private BoxStyle(char style) {
+ this.style = style;
+ }
+
+ public static BoxStyle fromChar(char style) {
+ for (BoxStyle bs : BoxStyle.values()) {
+ if (bs.style == style) {
+ return bs;
+ }
+ }
+ return PLAIN;
+ }
+
+ public final UDrawable getUDrawable(final double width, final double height, final boolean shadowing) {
+ return new UDrawable() {
+ public void drawU(UGraphic ug) {
+ drawInternal(ug, width, height, shadowing);
+ }
+ };
+ }
+
+ protected Shadowable getShape(double width, double height) {
+ return null;
+ }
+
+ protected void drawInternal(UGraphic ug, double width, double height, boolean shadowing) {
+ final Shadowable s = getShape(width, height);
+ if (shadowing) {
+ s.setDeltaShadow(3);
+ }
+ ug.draw(s);
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/CollisionDetector.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/CollisionDetector.java
new file mode 100644
index 0000000..46fb126
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/CollisionDetector.java
@@ -0,0 +1,225 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+import java.awt.geom.Line2D;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.MinMax;
+import net.sourceforge.plantuml.ugraphic.UChange;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UParamNull;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class CollisionDetector implements UGraphic {
+
+ public UGraphic apply(UChange change) {
+ if (change instanceof UTranslate) {
+ return new CollisionDetector(stringBounder, translate.compose((UTranslate) change), this.context);
+ } else if (change instanceof UStroke) {
+ return new CollisionDetector(this);
+ } else if (change instanceof UChangeBackColor) {
+ return new CollisionDetector(this);
+ } else if (change instanceof UChangeColor) {
+ return new CollisionDetector(this);
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ private final StringBounder stringBounder;
+ private final UTranslate translate;
+ private final Context context;
+
+ static class Context {
+ private final List<MinMax> rectangles = new ArrayList<MinMax>();
+ private final List<Snake> snakes = new ArrayList<Snake>();
+ private boolean manageSnakes;
+
+ public void drawDebug(UGraphic ug) {
+ for (MinMax minmax : rectangles) {
+ if (collision(minmax)) {
+ minmax.drawGrey(ug);
+ }
+ }
+ final HtmlColor color = HtmlColorUtils.BLACK;
+ ug = ug.apply(new UChangeColor(color)).apply(new UStroke(5));
+ for (Snake snake : snakes) {
+ for (Line2D line : snake.getHorizontalLines()) {
+ if (collision(line)) {
+ drawLine(ug, line);
+ }
+ }
+ }
+ }
+
+ private void drawLine(UGraphic ug, Line2D line) {
+ ug = ug.apply(new UTranslate(line.getX1(), line.getY1()));
+ ug.draw(new ULine(line.getX2() - line.getX1(), line.getY2() - line.getY1()));
+ }
+
+ private boolean collision(Line2D hline) {
+ for (MinMax r : rectangles) {
+ if (collisionCheck(r, hline)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean collision(MinMax r) {
+ for (Snake snake : snakes) {
+ for (Line2D hline : snake.getHorizontalLines()) {
+ if (collisionCheck(r, hline)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ }
+
+ private static boolean collisionCheck(MinMax rect, Line2D hline) {
+ if (hline.getY1() != hline.getY2()) {
+ throw new IllegalArgumentException();
+ }
+ if (hline.getY1() < rect.getMinY()) {
+ return false;
+ }
+ if (hline.getY1() > rect.getMaxY()) {
+ return false;
+ }
+ final double x1 = Math.min(hline.getX1(), hline.getX2());
+ final double x2 = Math.max(hline.getX1(), hline.getX2());
+ if (x2 < rect.getMinX()) {
+ return false;
+ }
+ if (x1 > rect.getMaxX()) {
+ return false;
+ }
+ return true;
+ }
+
+ public CollisionDetector(StringBounder stringBounder) {
+ this(stringBounder, new UTranslate(), new Context());
+ }
+
+ private CollisionDetector(StringBounder stringBounder, UTranslate translate, Context context) {
+ this.stringBounder = stringBounder;
+ this.translate = translate;
+ this.context = context;
+ }
+
+ private CollisionDetector(CollisionDetector other) {
+ this(other.stringBounder, other.translate, other.context);
+ }
+
+ public StringBounder getStringBounder() {
+ return stringBounder;
+ }
+
+ public UParam getParam() {
+ return new UParamNull();
+ }
+
+ public void draw(UShape shape) {
+ if (shape instanceof UPolygon) {
+ drawPolygone((UPolygon) shape);
+ } else if (shape instanceof URectangle) {
+ drawRectangle((URectangle) shape);
+ } else if (shape instanceof Snake) {
+ drawSnake((Snake) shape);
+ } /*
+ * else { System.err.println("shape=" + shape.getClass() + " " + shape); }
+ */
+ }
+
+ private void drawSnake(Snake shape) {
+ if (context.manageSnakes) {
+ context.snakes.add(shape.translate(translate));
+ }
+
+ }
+
+ private void drawRectangle(URectangle shape) {
+ context.rectangles.add(shape.getMinMax().translate(translate));
+ }
+
+ private void drawPolygone(UPolygon shape) {
+ context.rectangles.add(shape.getMinMax().translate(translate));
+ }
+
+ public ColorMapper getColorMapper() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void startUrl(Url url) {
+ }
+
+ public void closeAction() {
+ }
+
+ public void flushUg() {
+ }
+
+ public void drawDebug(UGraphic ug) {
+ context.drawDebug(ug);
+ }
+
+ public final void setManageSnakes(boolean manageSnakes) {
+ this.context.manageSnakes = manageSnakes;
+ }
+
+ public boolean isSpecialTxt() {
+ return false;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/Connection.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Connection.java
new file mode 100644
index 0000000..a2b3417
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Connection.java
@@ -0,0 +1,48 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+
+public interface Connection extends UDrawable, UShape {
+
+ public Ftile getFtile1();
+
+ public Ftile getFtile2();
+
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/ConnectionCross.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/ConnectionCross.java
new file mode 100644
index 0000000..2ee0557
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/ConnectionCross.java
@@ -0,0 +1,63 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class ConnectionCross extends AbstractConnection {
+
+ private final Connection connection;
+
+ public ConnectionCross(Connection connection) {
+ super(connection.getFtile1(), connection.getFtile2());
+ this.connection = connection;
+ }
+
+ public void drawU(UGraphic ug) {
+ if (connection instanceof ConnectionTranslatable) {
+ final ConnectionTranslatable conn = (ConnectionTranslatable) connection;
+
+ final Swimlane swimlane1 = getFtile1().getSwimlaneOut();
+ final Swimlane swimlane2 = getFtile2().getSwimlaneIn();
+ if (swimlane1 == null) {
+ throw new IllegalStateException("" + getFtile1().getClass());
+ }
+ if (swimlane2 == null) {
+ throw new IllegalStateException("" + getFtile2().getClass());
+ }
+ conn.drawTranslate(ug, swimlane1.getTranslate(), swimlane2.getTranslate());
+ }
+ }
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/ConnectionTranslatable.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/ConnectionTranslatable.java
new file mode 100644
index 0000000..12e1153
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/ConnectionTranslatable.java
@@ -0,0 +1,44 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public interface ConnectionTranslatable extends Connection {
+
+ public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2);
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/Diamond.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Diamond.java
new file mode 100644
index 0000000..965fe0b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Diamond.java
@@ -0,0 +1,120 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.creole.Stencil;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+
+public class Diamond {
+
+ final static public double diamondHalfSize = 12;
+
+ public static UPolygon asPolygon(boolean shadowing) {
+ final UPolygon diams = new UPolygon();
+
+ diams.addPoint(diamondHalfSize, 0);
+ diams.addPoint(diamondHalfSize * 2, diamondHalfSize);
+ diams.addPoint(diamondHalfSize, diamondHalfSize * 2);
+ diams.addPoint(0, diamondHalfSize);
+ diams.addPoint(diamondHalfSize, 0);
+
+ if (shadowing) {
+ diams.setDeltaShadow(3);
+ }
+
+ return diams;
+ }
+
+ public static UPolygon asPolygon(boolean shadowing, double width, double height) {
+ final UPolygon diams = new UPolygon();
+
+ diams.addPoint(diamondHalfSize, 0);
+ diams.addPoint(width - diamondHalfSize, 0);
+ diams.addPoint(width, height / 2);
+ diams.addPoint(width - diamondHalfSize, height);
+ diams.addPoint(diamondHalfSize, height);
+ diams.addPoint(0, height / 2);
+ diams.addPoint(diamondHalfSize, 0);
+
+ if (shadowing) {
+ diams.setDeltaShadow(3);
+ }
+
+ return diams;
+ }
+
+ public static Stencil asStencil(final TextBlock tb) {
+ return new Stencil() {
+
+ private final double getDeltaX(double height, double y) {
+ final double p = y / height * 2;
+ if (p <= 1) {
+ return diamondHalfSize * p;
+ }
+ return diamondHalfSize * (2 - p);
+ }
+
+ public double getStartingX(StringBounder stringBounder, double y) {
+ final Dimension2D dim = tb.calculateDimension(stringBounder);
+ return -getDeltaX(dim.getHeight(), y);
+ }
+
+ public double getEndingX(StringBounder stringBounder, double y) {
+ final Dimension2D dim = tb.calculateDimension(stringBounder);
+ return dim.getWidth() + getDeltaX(dim.getHeight(), y);
+ }
+ };
+ }
+
+ public static UPolygon asPolygonFoo1(boolean shadowing, double width, double height) {
+ final UPolygon diams = new UPolygon();
+
+ diams.addPoint(width / 2, 0);
+ diams.addPoint(width, height / 2);
+ diams.addPoint(width / 2, height);
+ diams.addPoint(0, height / 2);
+
+ if (shadowing) {
+ diams.setDeltaShadow(3);
+ }
+
+ return diams;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/EntityImageLegend.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/EntityImageLegend.java
new file mode 100644
index 0000000..9b78750
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/EntityImageLegend.java
@@ -0,0 +1,129 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.skin.rose.Rose;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class EntityImageLegend implements TextBlock {
+
+ private final int cornersize = 10;
+ private final HtmlColor noteBackgroundColor;
+ private final HtmlColor borderColor;
+ private final int marginX = 6;
+ private final int marginY = 5;
+ private final boolean withShadow;
+
+ private final TextBlock textBlock;
+
+ private EntityImageLegend(Display note, ISkinParam skinParam) {
+ this.withShadow = false;
+ final Rose rose = new Rose();
+
+ noteBackgroundColor = rose.getHtmlColor(skinParam, ColorParam.legendBackground);
+
+ borderColor = rose.getHtmlColor(skinParam, ColorParam.legendBorder);
+ final HtmlColor fontColor = rose.getFontColor(skinParam, FontParam.LEGEND);
+ final UFont fontNote = skinParam.getFont(FontParam.LEGEND, null, false);
+
+ this.textBlock = TextBlockUtils.create(note, new FontConfiguration(fontNote, fontColor,
+ skinParam.getHyperlinkColor(), skinParam.useUnderlineForHyperlink()), HorizontalAlignment.LEFT, skinParam);
+ }
+
+ public static TextBlock create(Display legend, ISkinParam skinParam) {
+ return TextBlockUtils.withMargin(new EntityImageLegend(legend, skinParam), 8, 8);
+ }
+
+ private double getTextHeight(StringBounder stringBounder) {
+ final Dimension2D size = textBlock.calculateDimension(stringBounder);
+ return size.getHeight() + 2 * marginY;
+ }
+
+ private double getPureTextWidth(StringBounder stringBounder) {
+ final Dimension2D size = textBlock.calculateDimension(stringBounder);
+ return size.getWidth();
+ }
+
+ private double getTextWidth(StringBounder stringBounder) {
+ return getPureTextWidth(stringBounder) + 2 * marginX;
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final double height = getTextHeight(stringBounder);
+ final double width = getTextWidth(stringBounder);
+ return new Dimension2DDouble(width + 1, height + 1);
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final UPolygon polygon = getPolygonNormal(stringBounder);
+ if (withShadow) {
+ polygon.setDeltaShadow(4);
+ }
+ ug = ug.apply(new UChangeBackColor(noteBackgroundColor)).apply(new UChangeColor(borderColor));
+ ug.draw(polygon);
+ textBlock.drawU(ug.apply(new UTranslate(marginX, marginY)));
+ }
+
+ private UPolygon getPolygonNormal(final StringBounder stringBounder) {
+ final UPolygon polygon = new UPolygon();
+ polygon.addPoint(0, 0);
+ polygon.addPoint(0, getTextHeight(stringBounder));
+ final double width = getTextWidth(stringBounder);
+ polygon.addPoint(width, getTextHeight(stringBounder));
+ polygon.addPoint(width, 0);
+ polygon.addPoint(0, 0);
+ return polygon;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/Ftile.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Ftile.java
new file mode 100644
index 0000000..c58eebe
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Ftile.java
@@ -0,0 +1,58 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+import java.util.Collection;
+
+import net.sourceforge.plantuml.activitydiagram3.LinkRendering;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public interface Ftile extends Swimable, TextBlock {
+
+ public boolean shadowing();
+
+ public LinkRendering getInLinkRendering();
+
+ public LinkRendering getOutLinkRendering();
+
+ public FtileGeometry calculateDimension(StringBounder stringBounder);
+
+ public UTranslate getTranslateFor(Ftile child, StringBounder stringBounder);
+
+ public Collection<Connection> getInnerConnections();
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileAssemblySimple.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileAssemblySimple.java
new file mode 100644
index 0000000..c9be210
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileAssemblySimple.java
@@ -0,0 +1,139 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+import java.awt.geom.Dimension2D;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import net.sourceforge.plantuml.activitydiagram3.LinkRendering;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class FtileAssemblySimple implements Ftile {
+
+ private final Ftile tile1;
+ private final Ftile tile2;
+
+ @Override
+ public String toString() {
+ return "FtileAssemblySimple " + tile1 + " && " + tile2;
+ }
+
+ public FtileAssemblySimple(Ftile tile1, Ftile tile2) {
+ this.tile1 = tile1;
+ this.tile2 = tile2;
+ }
+
+ public Swimlane getSwimlaneIn() {
+ return tile1.getSwimlaneIn();
+ }
+
+ public Swimlane getSwimlaneOut() {
+ return tile2.getSwimlaneOut();
+ }
+
+ public UTranslate getTranslateFor(Ftile child, StringBounder stringBounder) {
+ if (child == tile1) {
+ return getTranslated1(stringBounder);
+ }
+ if (child == tile2) {
+ return getTranslated2(stringBounder);
+ }
+ UTranslate tmp = tile1.getTranslateFor(child, stringBounder);
+ if (tmp != null) {
+ return tmp.compose(getTranslated1(stringBounder));
+ }
+ tmp = tile2.getTranslateFor(child, stringBounder);
+ if (tmp != null) {
+ return tmp.compose(getTranslated2(stringBounder));
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ ug.apply(getTranslated1(stringBounder)).draw(tile1);
+ ug.apply(getTranslated2(stringBounder)).draw(tile2);
+ }
+
+ public LinkRendering getInLinkRendering() {
+ return tile1.getInLinkRendering();
+ }
+
+ public LinkRendering getOutLinkRendering() {
+ return null;
+ }
+
+ private FtileGeometry calculateDimension;
+
+ public FtileGeometry calculateDimension(StringBounder stringBounder) {
+ if (calculateDimension == null) {
+ calculateDimension = tile1.calculateDimension(stringBounder).appendBottom(
+ tile2.calculateDimension(stringBounder));
+ }
+ return calculateDimension;
+ }
+
+ private UTranslate getTranslated1(StringBounder stringBounder) {
+ final double left = calculateDimension(stringBounder).getLeft();
+ return new UTranslate(left - tile1.calculateDimension(stringBounder).getLeft(), 0);
+ }
+
+ private UTranslate getTranslated2(StringBounder stringBounder) {
+ final Dimension2D dim1 = tile1.calculateDimension(stringBounder);
+ final double left = calculateDimension(stringBounder).getLeft();
+ return new UTranslate(left - tile2.calculateDimension(stringBounder).getLeft(), dim1.getHeight());
+ }
+
+ public Collection<Connection> getInnerConnections() {
+ return Collections.emptyList();
+ }
+
+ public Set<Swimlane> getSwimlanes() {
+ final Set<Swimlane> result = new HashSet<Swimlane>();
+ result.addAll(tile1.getSwimlanes());
+ result.addAll(tile2.getSwimlanes());
+ return Collections.unmodifiableSet(result);
+ }
+
+ public boolean shadowing() {
+ return tile1.shadowing() || tile2.shadowing();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileEmpty.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileEmpty.java
new file mode 100644
index 0000000..fe9b71d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileEmpty.java
@@ -0,0 +1,95 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+import java.util.Collections;
+import java.util.Set;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class FtileEmpty extends AbstractFtile {
+
+ private final double width;
+ private final double height;
+ private final Swimlane swimlaneIn;
+ private final Swimlane swimlaneOut;
+
+ public FtileEmpty(boolean shadowing, double width, double height) {
+ this(shadowing, width, height, null, null);
+ }
+
+ public FtileEmpty(boolean shadowing, double width, double height, Swimlane swimlaneIn, Swimlane swimlaneOut) {
+ super(shadowing);
+ this.width = width;
+ this.height = height;
+ this.swimlaneIn = swimlaneIn;
+ this.swimlaneOut = swimlaneOut;
+
+ }
+
+ public FtileEmpty(boolean shadowing) {
+ this(shadowing, 0, 0, null, null);
+ }
+
+ public FtileEmpty(boolean shadowing, Swimlane swimlane) {
+ this(shadowing, 0, 0, swimlane, swimlane);
+ }
+
+ @Override
+ public String toString() {
+ return "FtileEmpty";
+ }
+
+ public void drawU(UGraphic ug) {
+ }
+
+ public FtileGeometry calculateDimension(StringBounder stringBounder) {
+ return new FtileGeometry(width, height, width / 2, 0, height);
+ }
+
+ public Swimlane getSwimlaneIn() {
+ return swimlaneIn;
+ }
+
+ public Swimlane getSwimlaneOut() {
+ return swimlaneOut;
+ }
+
+ public Set<Swimlane> getSwimlanes() {
+ return Collections.emptySet();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactory.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactory.java
new file mode 100644
index 0000000..0be313e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactory.java
@@ -0,0 +1,83 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.activitydiagram3.Branch;
+import net.sourceforge.plantuml.activitydiagram3.LinkRendering;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+
+public interface FtileFactory extends ISkinSimple {
+
+ public StringBounder getStringBounder();
+
+ public boolean shadowing();
+
+ public Ftile start(Swimlane swimlane);
+
+ public Ftile stop(Swimlane swimlane);
+
+ public Ftile activity(Display label, HtmlColor color, Swimlane swimlane, BoxStyle style);
+
+ public Ftile addNote(Ftile ftile, Display note, NotePosition notePosition);
+
+ public Ftile addUrl(Ftile ftile, Url url);
+
+ public Ftile decorateIn(Ftile ftile, LinkRendering linkRendering);
+
+ public Ftile decorateOut(Ftile ftile, LinkRendering linkRendering);
+
+ public Ftile assembly(Ftile tile1, Ftile tile2);
+
+ public Ftile repeat(Swimlane swimlane, Ftile repeat, Display test, Display yes, Display out, HtmlColor color, LinkRendering backRepeatLinkRendering);
+
+ public Ftile createWhile(Swimlane swimlane, Ftile whileBlock, Display test, Display yes, Display out,
+ LinkRendering afterEndwhile, HtmlColor color);
+
+ public Ftile createIf(Swimlane swimlane, List<Branch> thens, Branch elseBranch);
+
+ public Ftile createFork(Swimlane swimlane, List<Ftile> all);
+
+ public Ftile createSplit(List<Ftile> all);
+
+ public Ftile createGroup(Ftile list, Display name, HtmlColor backColor, HtmlColor titleColor, Display headerNote);
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactoryDelegator.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactoryDelegator.java
new file mode 100644
index 0000000..cd0de1f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactoryDelegator.java
@@ -0,0 +1,174 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.activitydiagram3.Branch;
+import net.sourceforge.plantuml.activitydiagram3.LinkRendering;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+import net.sourceforge.plantuml.skin.rose.Rose;
+import net.sourceforge.plantuml.ugraphic.Sprite;
+
+public class FtileFactoryDelegator implements FtileFactory {
+
+ private final FtileFactory factory;
+ private final ISkinParam skinParam;
+ private final Rose rose = new Rose();
+
+ protected HtmlColor getInLinkRenderingColor(Ftile tile) {
+ final HtmlColor color;
+ final LinkRendering linkRendering = tile.getInLinkRendering();
+ if (linkRendering == null || linkRendering.getColor() == null) {
+ color = rose.getHtmlColor(getSkinParam(), ColorParam.activityArrow);
+ } else {
+ color = linkRendering.getColor();
+ }
+ return color;
+ }
+
+ protected Display getInLinkRenderingDisplay(Ftile tile) {
+ final LinkRendering linkRendering = tile.getInLinkRendering();
+ if (linkRendering == null) {
+ return null;
+ }
+ return linkRendering.getDisplay();
+ }
+
+ public FtileFactoryDelegator(FtileFactory factory, ISkinParam skinParam) {
+ this.factory = factory;
+ this.skinParam = skinParam;
+ }
+
+ public Ftile start(Swimlane swimlane) {
+ return factory.start(swimlane);
+ }
+
+ public Ftile stop(Swimlane swimlane) {
+ return factory.stop(swimlane);
+ }
+
+ public Ftile activity(Display label, HtmlColor color, Swimlane swimlane, BoxStyle style) {
+ return factory.activity(label, color, swimlane, style);
+ }
+
+ public Ftile addNote(Ftile ftile, Display note, NotePosition notePosition) {
+ return factory.addNote(ftile, note, notePosition);
+ }
+
+ public Ftile addUrl(Ftile ftile, Url url) {
+ return factory.addUrl(ftile, url);
+ }
+
+ public Ftile decorateIn(Ftile ftile, LinkRendering linkRendering) {
+ return factory.decorateIn(ftile, linkRendering);
+ }
+
+ public Ftile decorateOut(Ftile ftile, LinkRendering linkRendering) {
+ return factory.decorateOut(ftile, linkRendering);
+ }
+
+ public Ftile assembly(Ftile tile1, Ftile tile2) {
+ return factory.assembly(tile1, tile2);
+ }
+
+ public Ftile repeat(Swimlane swimlane, Ftile repeat, Display test, Display yes, Display out, HtmlColor color, LinkRendering backRepeatLinkRendering) {
+ return factory.repeat(swimlane, repeat, test, yes, out, color, backRepeatLinkRendering);
+ }
+
+ public Ftile createWhile(Swimlane swimlane, Ftile whileBlock, Display test, Display yes, Display out,
+ LinkRendering afterEndwhile, HtmlColor color) {
+ return factory.createWhile(swimlane, whileBlock, test, yes, out, afterEndwhile, color);
+ }
+
+ public Ftile createIf(Swimlane swimlane, List<Branch> thens, Branch elseBranch) {
+ return factory.createIf(swimlane, thens, elseBranch);
+ }
+
+ public Ftile createFork(Swimlane swimlane, List<Ftile> all) {
+ return factory.createFork(swimlane, all);
+ }
+
+ public Ftile createSplit(List<Ftile> all) {
+ return factory.createSplit(all);
+ }
+
+ public Ftile createGroup(Ftile list, Display name, HtmlColor backColor, HtmlColor titleColor, Display headerNote) {
+ return factory.createGroup(list, name, backColor, titleColor, headerNote);
+ }
+
+ public StringBounder getStringBounder() {
+ return factory.getStringBounder();
+ }
+
+ protected final ISkinParam getSkinParam() {
+ return skinParam;
+ }
+
+ protected final Rose getRose() {
+ return rose;
+ }
+
+ public boolean shadowing() {
+ return skinParam.shadowing();
+ }
+
+ protected FtileFactory getFactory() {
+ return factory;
+ }
+
+ public Sprite getSprite(String name) {
+ return skinParam.getSprite(name);
+ }
+
+ public String getValue(String key) {
+ return skinParam.getValue(key);
+ }
+
+ public double getPadding() {
+ return skinParam.getPadding();
+ }
+
+ public boolean useGuillemet() {
+ return skinParam.useGuillemet();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileGeometry.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileGeometry.java
new file mode 100644
index 0000000..62c74da
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileGeometry.java
@@ -0,0 +1,144 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class FtileGeometry extends Dimension2D {
+
+ private final double width;
+ private final double height;
+ private final double left;
+ private final double inY;
+ private final double outY;
+
+ public FtileGeometry(Dimension2D dim, double left, double inY) {
+ this(dim.getWidth(), dim.getHeight(), left, inY);
+ }
+
+ public FtileGeometry(double width, double height, double left, double inY) {
+ this(width, height, left, inY, Double.MIN_NORMAL);
+ }
+
+ @Override
+ public String toString() {
+ return "[" + width + "x" + height + " left=" + left + "]";
+ }
+
+ @Override
+ public void setSize(double width, double height) {
+ throw new UnsupportedOperationException();
+ }
+
+ public FtileGeometry(double width, double height, double left, double inY, double outY) {
+ this.left = left;
+ this.inY = inY;
+ this.outY = outY;
+ this.width = width;
+ this.height = height;
+ }
+
+ public FtileGeometry(Dimension2D dim, double left, double inY, double outY) {
+ this(dim.getWidth(), dim.getHeight(), left, inY, outY);
+ }
+
+ public boolean hasPointOut() {
+ return outY != Double.MIN_NORMAL;
+ }
+
+ public Point2D getPointIn() {
+ return new Point2D.Double(left, inY);
+ }
+
+ public Point2D getPointOut() {
+ if (outY == Double.MIN_NORMAL) {
+ throw new UnsupportedOperationException();
+ }
+ return new Point2D.Double(left, outY);
+ }
+
+ public FtileGeometry withoutPointOut() {
+ return new FtileGeometry(width, height, left, inY);
+ }
+
+ public FtileGeometry translate(UTranslate translate) {
+ final double dx = translate.getDx();
+ final double dy = translate.getDy();
+ if (this.outY == Double.MIN_NORMAL) {
+ return new FtileGeometry(width, height, left + dx, inY + dy);
+ }
+ return new FtileGeometry(width, height, left + dx, inY + dy, outY + dy);
+ }
+
+ public final double getInY() {
+ return inY;
+ }
+
+ public final double getLeft() {
+ return left;
+ }
+
+ public double getOutY() {
+ return outY;
+ }
+
+ public final double getWidth() {
+ return width;
+ }
+
+ public final double getHeight() {
+ return height;
+ }
+
+ public FtileGeometry addDim(double deltaWidth, double deltaHeight) {
+ return new FtileGeometry(width + deltaWidth, height + deltaHeight, left, inY, outY + deltaHeight);
+ }
+
+ public FtileGeometry addMarginX(double marginx) {
+ return new FtileGeometry(width + 2 * marginx, height, left + marginx, inY, outY);
+ }
+
+ public FtileGeometry fixedHeight(double fixedHeight) {
+ return new FtileGeometry(width, fixedHeight, left, inY, outY);
+ }
+
+ public FtileGeometry appendBottom(FtileGeometry other) {
+ return new FtileGeometryMerger(this, other).getResult();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileGeometryMerger.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileGeometryMerger.java
new file mode 100644
index 0000000..7acab23
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileGeometryMerger.java
@@ -0,0 +1,58 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+public class FtileGeometryMerger {
+
+ private final FtileGeometry result;
+
+ public FtileGeometryMerger(FtileGeometry geo1, FtileGeometry geo2) {
+ final double left = Math.max(geo1.getLeft(), geo2.getLeft());
+ final double dx1 = left - geo1.getLeft();
+ final double dx2 = left - geo2.getLeft();
+ final double width = Math.max(geo1.getWidth() + dx1, geo2.getWidth() + dx2);
+ final double height = geo1.getHeight() + geo2.getHeight();
+
+ if (geo2.hasPointOut()) {
+ result = new FtileGeometry(width, height, left, geo1.getInY(), geo2.getOutY() + geo1.getHeight());
+ } else {
+ result = new FtileGeometry(width, height, left, geo1.getInY());
+ }
+ }
+
+ public final FtileGeometry getResult() {
+ return result;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileGoto.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileGoto.java
new file mode 100644
index 0000000..8f1125f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileGoto.java
@@ -0,0 +1,56 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+
+public class FtileGoto extends FtileEmpty {
+
+ private final String name;
+
+ public FtileGoto(boolean shadowing, Swimlane swimlane, String name) {
+ super(shadowing, swimlane);
+ this.name = name;
+ }
+
+ public FtileGeometry calculateDimension(StringBounder stringBounder) {
+ return super.calculateDimension(stringBounder).withoutPointOut();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileHeightFixed.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileHeightFixed.java
new file mode 100644
index 0000000..636b066
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileHeightFixed.java
@@ -0,0 +1,94 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+import java.awt.geom.Dimension2D;
+import java.util.Set;
+
+import net.sourceforge.plantuml.activitydiagram3.LinkRendering;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class FtileHeightFixed extends AbstractFtile {
+
+ private final Ftile tile;
+ private final double fixedHeight;
+
+ public FtileHeightFixed(Ftile tile, double fixedHeight) {
+ super(tile.shadowing());
+ this.tile = tile;
+ this.fixedHeight = fixedHeight;
+ }
+
+ @Override
+ public LinkRendering getInLinkRendering() {
+ return tile.getInLinkRendering();
+ }
+
+ @Override
+ public LinkRendering getOutLinkRendering() {
+ return tile.getOutLinkRendering();
+ }
+
+ public Set<Swimlane> getSwimlanes() {
+ return tile.getSwimlanes();
+ }
+
+ public Swimlane getSwimlaneIn() {
+ return tile.getSwimlaneIn();
+ }
+
+ public Swimlane getSwimlaneOut() {
+ return tile.getSwimlaneOut();
+ }
+
+ public FtileGeometry calculateDimension(StringBounder stringBounder) {
+ return tile.calculateDimension(stringBounder).translate(getTranslate(stringBounder)).fixedHeight(fixedHeight);
+ }
+
+ private UTranslate getTranslate(StringBounder stringBounder) {
+ final Dimension2D dim = tile.calculateDimension(stringBounder);
+ if (dim.getHeight() > fixedHeight) {
+ throw new IllegalStateException();
+ }
+ return new UTranslate(0, (fixedHeight - dim.getHeight()) / 2);
+ }
+
+ public void drawU(UGraphic ug) {
+ ug.apply(getTranslate(ug.getStringBounder())).draw(tile);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileKilled.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileKilled.java
new file mode 100644
index 0000000..65529ac
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileKilled.java
@@ -0,0 +1,72 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+import java.util.Set;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class FtileKilled extends AbstractFtile {
+
+ private final Ftile tile;
+
+ public FtileKilled(Ftile tileToKill) {
+ super(tileToKill.shadowing());
+ this.tile = tileToKill;
+ }
+
+ public Set<Swimlane> getSwimlanes() {
+ return tile.getSwimlanes();
+ }
+
+ public Swimlane getSwimlaneIn() {
+ return tile.getSwimlaneIn();
+ }
+
+ public Swimlane getSwimlaneOut() {
+ return tile.getSwimlaneOut();
+ }
+
+ public FtileGeometry calculateDimension(StringBounder stringBounder) {
+ final FtileGeometry geo = tile.calculateDimension(stringBounder);
+ return new FtileGeometry(tile.calculateDimension(stringBounder), geo.getLeft(), geo.getInY());
+ }
+
+ public void drawU(UGraphic ug) {
+ ug.draw(tile);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileLabel.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileLabel.java
new file mode 100644
index 0000000..c9d4110
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileLabel.java
@@ -0,0 +1,50 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+public class FtileLabel extends FtileEmpty {
+
+ private final String name;
+
+ public FtileLabel(boolean shadowing, Swimlane swimlane, String name) {
+ super(shadowing, swimlane);
+ this.name = name;
+ }
+
+ public final String getName() {
+ return name;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileMarged.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileMarged.java
new file mode 100644
index 0000000..aaa874c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileMarged.java
@@ -0,0 +1,87 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+import java.util.Set;
+
+import net.sourceforge.plantuml.activitydiagram3.LinkRendering;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class FtileMarged extends AbstractFtile {
+
+ private final Ftile tile;
+ private final double margin;
+
+ public FtileMarged(Ftile tile, double margin) {
+ super(tile.shadowing());
+ this.tile = tile;
+ this.margin = margin;
+ }
+
+ @Override
+ public LinkRendering getInLinkRendering() {
+ return tile.getInLinkRendering();
+ }
+
+ @Override
+ public LinkRendering getOutLinkRendering() {
+ return tile.getOutLinkRendering();
+ }
+
+ public Set<Swimlane> getSwimlanes() {
+ return tile.getSwimlanes();
+ }
+
+ public Swimlane getSwimlaneIn() {
+ return tile.getSwimlaneIn();
+ }
+
+ public Swimlane getSwimlaneOut() {
+ return tile.getSwimlaneOut();
+ }
+
+ public FtileGeometry calculateDimension(StringBounder stringBounder) {
+ final FtileGeometry orig = tile.calculateDimension(stringBounder);
+ return new FtileGeometry(orig.getWidth() + 2 * margin, orig.getHeight(), orig.getLeft() + margin,
+ orig.getInY(), orig.getOutY());
+ }
+
+ public void drawU(UGraphic ug) {
+ ug.apply(new UTranslate(margin, 0)).draw(tile);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileMargedVertically.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileMargedVertically.java
new file mode 100644
index 0000000..9b7fc54
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileMargedVertically.java
@@ -0,0 +1,66 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDecorate;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class FtileMargedVertically extends FtileDecorate {
+
+ private final double margin1;
+ private final double margin2;
+
+ public FtileMargedVertically(Ftile tile, double margin1, double margin2) {
+ super(tile);
+ this.margin1 = margin1;
+ this.margin2 = margin2;
+ }
+
+ public void drawU(UGraphic ug) {
+ if (margin1 > 0) {
+ ug = ug.apply(new UTranslate(0, margin1));
+ }
+ ug.draw(getFtileDelegated());
+ }
+
+ public FtileGeometry calculateDimension(StringBounder stringBounder) {
+ final FtileGeometry orig = getFtileDelegated().calculateDimension(stringBounder);
+ return new FtileGeometry(orig.getWidth(), orig.getHeight() + margin1 + margin2, orig.getLeft(), orig.getInY()
+ + margin1, orig.getOutY() + margin1);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileMinWidth.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileMinWidth.java
new file mode 100644
index 0000000..97a3569
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileMinWidth.java
@@ -0,0 +1,101 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDecorate;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class FtileMinWidth extends FtileDecorate {
+
+ private final double minWidth;
+
+ public FtileMinWidth(Ftile tile, double minWidth) {
+ super(tile);
+ this.minWidth = minWidth;
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final UTranslate change = getUTranslateInternal(stringBounder);
+ super.drawU(ug.apply(change));
+ }
+
+ @Override
+ public FtileGeometry calculateDimension(StringBounder stringBounder) {
+ final FtileGeometry geo = super.calculateDimension(stringBounder);
+ final double left = getPoint2(geo.getLeft(), stringBounder);
+ if (geo.hasPointOut() == false) {
+ return new FtileGeometry(getDimensionInternal(stringBounder), left, geo.getInY());
+ }
+ return new FtileGeometry(getDimensionInternal(stringBounder), left, geo.getInY(), geo.getOutY());
+ }
+
+ private Dimension2D getDimensionInternal(StringBounder stringBounder) {
+ final Dimension2D dim = getFtileDelegated().calculateDimension(stringBounder);
+ if (dim.getWidth() < minWidth) {
+ return new Dimension2DDouble(minWidth, dim.getHeight());
+ }
+ return dim;
+ }
+
+ private UTranslate getUTranslateInternal(final StringBounder stringBounder) {
+ final Dimension2D dimTile = getFtileDelegated().calculateDimension(stringBounder);
+ final Dimension2D dimTotal = getDimensionInternal(stringBounder);
+ final UTranslate change = new UTranslate((dimTotal.getWidth() - dimTile.getWidth()) / 2, 0);
+ return change;
+ }
+
+ public UTranslate getTranslateFor(Ftile child, StringBounder stringBounder) {
+ if (child == getFtileDelegated()) {
+ return getUTranslateInternal(stringBounder);
+ }
+ return null;
+ }
+
+ private double getPoint2(double x, StringBounder stringBounder) {
+ final Dimension2D dim = getFtileDelegated().calculateDimension(stringBounder);
+ if (dim.getWidth() < minWidth) {
+ final double diff = minWidth - dim.getWidth();
+ return x + diff / 2;
+ }
+ return x;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileUtils.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileUtils.java
new file mode 100644
index 0000000..8ef5fb4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileUtils.java
@@ -0,0 +1,71 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+import java.util.Collection;
+
+public class FtileUtils {
+
+ public static Ftile addConnection(Ftile ftile, Connection connection) {
+ return new FtileWithConnection(ftile, connection);
+ }
+
+ public static Ftile addConnection(Ftile ftile, Collection<Connection> connections) {
+ return new FtileWithConnection(ftile, connections);
+ }
+
+ public static Ftile withSwimlaneOut(Ftile ftile, Swimlane out) {
+ return new FtileWithSwimlanes(ftile, ftile.getSwimlaneIn(), out);
+ }
+
+ public static Ftile addBottom(Ftile ftile, double marginBottom) {
+ return new FtileMargedVertically(ftile, 0, marginBottom);
+ }
+
+ public static Ftile addVerticalMargin(Ftile ftile, double marginTop, double marginBottom) {
+ if (marginTop == 0 && marginBottom == 0) {
+ return ftile;
+ }
+ return new FtileMargedVertically(ftile, marginTop, marginBottom);
+ }
+
+ private static Ftile neverNull(Ftile ftile) {
+ if (ftile == null) {
+ return new FtileEmpty(false);
+ }
+ return ftile;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileWithConnection.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileWithConnection.java
new file mode 100644
index 0000000..a1b47cc
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileWithConnection.java
@@ -0,0 +1,83 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDecorate;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+class FtileWithConnection extends FtileDecorate {
+
+ private final List<Connection> connections = new ArrayList<Connection>();
+
+ FtileWithConnection(Ftile ftile, Collection<Connection> connections) {
+ super(ftile);
+ if (connections == null || connections.size() == 0) {
+ throw new IllegalArgumentException();
+ }
+ this.connections.addAll(connections);
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + " " + connections;
+ }
+
+ public FtileWithConnection(Ftile ftile, Connection connection) {
+ this(ftile, Arrays.asList(connection));
+ if (connection == null) {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ public void drawU(UGraphic ug) {
+ getFtileDelegated().drawU(ug);
+ for (Connection c : connections) {
+ ug.draw(c);
+ }
+ }
+
+ public Collection<Connection> getInnerConnections() {
+ final List<Connection> result = new ArrayList<Connection>(super.getInnerConnections());
+ result.addAll(connections);
+ return Collections.unmodifiableList(connections);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileWithSwimlanes.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileWithSwimlanes.java
new file mode 100644
index 0000000..12e346d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileWithSwimlanes.java
@@ -0,0 +1,60 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDecorate;
+
+class FtileWithSwimlanes extends FtileDecorate {
+
+ private final Swimlane in;
+ private final Swimlane out;
+
+ FtileWithSwimlanes(Ftile ftile, Swimlane in, Swimlane out) {
+ super(ftile);
+ this.in = in;
+ this.out = out;
+ }
+
+ @Override
+ public Swimlane getSwimlaneIn() {
+ return in;
+ }
+
+ @Override
+ public Swimlane getSwimlaneOut() {
+ return out;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileWithUrl.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileWithUrl.java
new file mode 100644
index 0000000..87926d6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileWithUrl.java
@@ -0,0 +1,59 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDecorate;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class FtileWithUrl extends FtileDecorate {
+
+ private final Url url;
+
+ public FtileWithUrl(Ftile ftile, Url url) {
+ super(ftile);
+ if (url == null) {
+ throw new IllegalArgumentException();
+ }
+ this.url = url;
+ }
+
+ public void drawU(UGraphic ug) {
+ ug.startUrl(url);
+ getFtileDelegated().drawU(ug);
+ ug.closeAction();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/GotoInterceptor.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/GotoInterceptor.java
new file mode 100644
index 0000000..2b48832
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/GotoInterceptor.java
@@ -0,0 +1,61 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.UGraphicInterceptorGoto;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class GotoInterceptor implements TextBlock {
+
+ private final TextBlock swinlanes;
+
+ public GotoInterceptor(TextBlock swinlanes) {
+ this.swinlanes = swinlanes;
+ }
+
+ public void drawU(UGraphic ug) {
+ new UGraphicInterceptorGoto(ug).draw(swinlanes);
+
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return swinlanes.calculateDimension(stringBounder);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/Snake.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Snake.java
new file mode 100644
index 0000000..12cb49f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Snake.java
@@ -0,0 +1,415 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Line2D;
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import net.sourceforge.plantuml.Direction;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.ugraphic.CompressionTransform;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class Snake implements UShape {
+
+ private final List<Point2D.Double> points = new ArrayList<Point2D.Double>();
+ private final UPolygon endDecoration;
+ private final HtmlColor color;
+ private TextBlock textBlock;
+ private boolean mergeable = true;
+ private Direction emphasizeDirection;
+
+ public Snake transformX(CompressionTransform compressionTransform) {
+ final Snake result = new Snake(color, endDecoration);
+ result.textBlock = this.textBlock;
+ result.mergeable = this.mergeable;
+ result.emphasizeDirection = this.emphasizeDirection;
+ for (Point2D.Double pt : points) {
+ final double x = compressionTransform.transform(pt.x);
+ final double y = pt.y;
+ result.addPoint(x, y);
+ }
+ return result;
+ }
+
+ public Snake(HtmlColor color, UPolygon endDecoration) {
+ this.endDecoration = endDecoration;
+ this.color = color;
+ }
+
+ public Snake(HtmlColor color) {
+ this(color, null);
+ }
+
+ public void setLabel(TextBlock label) {
+ this.textBlock = label;
+ }
+
+ public Snake move(double dx, double dy) {
+ final Snake result = new Snake(color, endDecoration);
+ for (Point2D pt : points) {
+ result.addPoint(pt.getX() + dx, pt.getY() + dy);
+ }
+ result.textBlock = this.textBlock;
+ result.mergeable = this.mergeable;
+ result.emphasizeDirection = this.emphasizeDirection;
+ return result;
+ }
+
+ public Snake translate(UTranslate translate) {
+ return move(translate.getDx(), translate.getDy());
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder result = new StringBuilder();
+ for (int i = 0; i < points.size() - 1; i++) {
+ result.append(getDirectionAtPoint(i) + " ");
+ }
+ return result + points.toString();
+ }
+
+ SnakeDirection getDirection() {
+ if (points.size() < 2) {
+ throw new IllegalStateException();
+ }
+ return SnakeDirection.getDirection(points.get(0), points.get(1));
+ }
+
+ public void addPoint(double x, double y) {
+ this.points.add(new Point2D.Double(x, y));
+ }
+
+ public void addPoint(Point2D p) {
+ addPoint(p.getX(), p.getY());
+ }
+
+ public void drawInternal(UGraphic ug) {
+ ug = ug.apply(new UChangeColor(color));
+ ug = ug.apply(new UChangeBackColor(color));
+ ug = ug.apply(new UStroke(1.5));
+ boolean drawn = false;
+ for (int i = 0; i < points.size() - 1; i++) {
+ final java.awt.geom.Point2D.Double p1 = points.get(i);
+ final java.awt.geom.Point2D.Double p2 = points.get(i + 1);
+ final Line2D line = new Line2D.Double(p1, p2);
+ if (drawn == false && emphasizeDirection != null && Direction.fromVector(p1, p2) == emphasizeDirection) {
+ drawLine(ug, line, emphasizeDirection);
+ drawn = true;
+ } else {
+ drawLine(ug, line, null);
+ }
+ }
+ if (endDecoration != null) {
+ final Point2D end = points.get(points.size() - 1);
+ ug.apply(new UTranslate(end)).apply(new UStroke()).draw(endDecoration);
+ }
+ if (textBlock != null) {
+ final Point2D position = getTextBlockPosition(ug.getStringBounder());
+ // double max = getMaxX(ug.getStringBounder());
+ // ug.apply(new UChangeBackColor(HtmlColorUtils.LIGHT_GRAY)).apply(new UTranslate(0,
+ // position.getY())).draw(new URectangle(max, 10));
+ textBlock.drawU(ug.apply(new UTranslate(position)));
+ }
+ }
+
+ public double getMaxX(StringBounder stringBounder) {
+ double result = -Double.MAX_VALUE;
+ for (Point2D pt : points) {
+ result = Math.max(result, pt.getX());
+ }
+ if (textBlock != null) {
+ final Point2D position = getTextBlockPosition(stringBounder);
+ final Dimension2D dim = textBlock.calculateDimension(stringBounder);
+ result = Math.max(result, position.getX() + dim.getWidth());
+ }
+ return result;
+ }
+
+ private Point2D getTextBlockPosition(StringBounder stringBounder) {
+ final Point2D pt1 = points.get(0);
+ final Point2D pt2 = points.get(1);
+ final Dimension2D dim = textBlock.calculateDimension(stringBounder);
+ final double y = (pt1.getY() + pt2.getY()) / 2 - dim.getHeight() / 2;
+ return new Point2D.Double(Math.max(pt1.getX(), pt2.getX()) + 4, y);
+ }
+
+ public List<Line2D> getHorizontalLines() {
+ final List<Line2D> result = new ArrayList<Line2D>();
+ for (int i = 0; i < points.size() - 1; i++) {
+ final Point2D pt1 = points.get(i);
+ final Point2D pt2 = points.get(i + 1);
+ if (pt1.getY() == pt2.getY()) {
+ final Line2D line = new Line2D.Double(pt1, pt2);
+ result.add(line);
+ }
+ }
+ return result;
+
+ }
+
+ private Point2D getFirst() {
+ return points.get(0);
+ }
+
+ public Point2D getLast() {
+ return points.get(points.size() - 1);
+ }
+
+ private boolean same(Point2D pt1, Point2D pt2) {
+ return pt1.distance(pt2) < 0.001;
+ // return pt1.getX() == pt2.getX() && pt1.getY() == pt2.getY();
+ }
+
+ public Snake merge(Snake other) {
+ if (mergeable == false || other.mergeable == false) {
+ return null;
+ }
+ if (same(this.getLast(), other.getFirst())) {
+ final UPolygon oneOf = endDecoration == null ? other.endDecoration : endDecoration;
+ final Snake result = new Snake(color, oneOf);
+ result.textBlock = textBlock == null ? other.textBlock : textBlock;
+ result.emphasizeDirection = emphasizeDirection == null ? other.emphasizeDirection : emphasizeDirection;
+ result.points.addAll(this.points);
+ result.points.addAll(other.points);
+ result.mergeMe();
+ return result;
+ }
+ if (same(this.getFirst(), other.getLast())) {
+ return other.merge(this);
+ }
+ return null;
+ }
+
+ private void mergeMe() {
+ boolean change = false;
+ do {
+ change = false;
+ change = change || removeNullVector();
+ change = change || removeRedondantDirection();
+ change = change || removePattern1();
+ change = change || removePattern2();
+ change = change || removePattern3();
+ change = change || removePattern4();
+ change = change || removePattern5();
+ change = change || removePattern6();
+ change = change || removePattern7();
+ } while (change);
+ }
+
+ private boolean removeNullVector() {
+ for (int i = 0; i < points.size() - 1; i++) {
+ final Direction dir = getDirectionAtPoint(i);
+ if (dir == null) {
+ points.remove(i);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean removeRedondantDirection() {
+ for (int i = 0; i < points.size() - 2; i++) {
+ final Direction dir1 = getDirectionAtPoint(i);
+ final Direction dir2 = getDirectionAtPoint(i + 1);
+ if (dir1 == dir2) {
+ points.remove(i + 1);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean removePattern1() {
+ for (int i = 0; i < points.size() - 5; i++) {
+ final List<Direction> patternAt = getPatternAt(i);
+ if (Arrays.asList(Direction.DOWN, Direction.LEFT, Direction.DOWN, Direction.RIGHT).equals(patternAt)
+ || Arrays.asList(Direction.DOWN, Direction.RIGHT, Direction.DOWN, Direction.LEFT).equals(patternAt)) {
+ final Point2D.Double newPoint = new Point2D.Double(points.get(i + 1).x, points.get(i + 3).y);
+ points.remove(i + 3);
+ points.remove(i + 2);
+ points.remove(i + 1);
+ points.add(i + 1, newPoint);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean removePattern7() {
+ if (points.size() > 4) {
+ final int i = 0;
+ final List<Direction> patternAt = getPatternAt(i);
+ if (Arrays.asList(Direction.RIGHT, Direction.DOWN, Direction.LEFT, Direction.DOWN).equals(patternAt)
+ && points.get(i + 3).x > points.get(i).x) {
+ final Point2D.Double newPoint = new Point2D.Double(points.get(i + 3).x, points.get(i).y);
+ points.remove(i + 2);
+ points.remove(i + 1);
+ points.add(i + 1, newPoint);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean removePattern2() {
+ for (int i = 0; i < points.size() - 5; i++) {
+ final List<Direction> patternAt = getPatternAt(i);
+ if (Arrays.asList(Direction.RIGHT, Direction.DOWN, Direction.RIGHT, Direction.UP).equals(patternAt)
+ || Arrays.asList(Direction.LEFT, Direction.DOWN, Direction.LEFT, Direction.UP).equals(patternAt)) {
+ final Point2D.Double newPoint = new Point2D.Double(points.get(i + 3).x, points.get(i + 1).y);
+ points.remove(i + 3);
+ points.remove(i + 2);
+ points.remove(i + 1);
+ points.add(i + 1, newPoint);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean removePattern3() {
+ for (int i = 0; i < points.size() - 4; i++) {
+ final List<Direction> patternAt = getPatternAt(i);
+ if (Arrays.asList(Direction.DOWN, Direction.RIGHT, Direction.DOWN, Direction.RIGHT).equals(patternAt)
+ || Arrays.asList(Direction.DOWN, Direction.LEFT, Direction.DOWN, Direction.LEFT).equals(patternAt)) {
+ final Point2D.Double newPoint = new Point2D.Double(points.get(i + 1).x, points.get(i + 3).y);
+ points.remove(i + 3);
+ points.remove(i + 2);
+ points.remove(i + 1);
+ points.add(i + 1, newPoint);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean removePattern4() {
+ final int i = points.size() - 5;
+ if (i >= 0) {
+ final List<Direction> patternAt = getPatternAt(i);
+ if (Arrays.asList(Direction.DOWN, Direction.LEFT, Direction.DOWN, Direction.RIGHT).equals(patternAt)) {
+ final Point2D.Double p1 = points.get(i + 1);
+ final Point2D.Double p4 = points.get(i + 4);
+ if (p4.x > p1.x) {
+ final Point2D.Double newPoint = new Point2D.Double(points.get(i + 1).x, points.get(i + 3).y);
+ points.remove(i + 3);
+ points.remove(i + 2);
+ points.remove(i + 1);
+ points.add(i + 1, newPoint);
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private boolean removePattern5() {
+ final int i = points.size() - 5;
+ if (i >= 0) {
+ final List<Direction> patternAt = getPatternAt(i);
+ if (Arrays.asList(Direction.DOWN, Direction.RIGHT, Direction.DOWN, Direction.LEFT).equals(patternAt)) {
+ final Point2D.Double p1 = points.get(i + 1);
+ final Point2D.Double p4 = points.get(i + 4);
+ if (p4.x < p1.x) {
+ final Point2D.Double newPoint = new Point2D.Double(points.get(i + 1).x, points.get(i + 3).y);
+ points.remove(i + 3);
+ points.remove(i + 2);
+ points.remove(i + 1);
+ points.add(i + 1, newPoint);
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private boolean removePattern6() {
+ for (int i = 0; i < points.size() - 2; i++) {
+ if (isForwardAndBackwardAt(i)) {
+ points.remove(i + 1);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private List<Direction> getPatternAt(int i) {
+ return Arrays.asList(getDirectionAtPoint(i), getDirectionAtPoint(i + 1), getDirectionAtPoint(i + 2),
+ getDirectionAtPoint(i + 3));
+ }
+
+ private boolean isForwardAndBackwardAt(int i) {
+ return getDirectionAtPoint(i) == getDirectionAtPoint(i + 1).getInv();
+ }
+
+ private Direction getDirectionAtPoint(int i) {
+ return Direction.fromVector(points.get(i), points.get(i + 1));
+ }
+
+ private void drawLine(UGraphic ug, Line2D line, Direction direction) {
+ drawLine(ug, line.getX1(), line.getY1(), line.getX2(), line.getY2(), direction);
+ }
+
+ private void drawLine(UGraphic ug, double x1, double y1, double x2, double y2, Direction direction) {
+ ug = ug.apply(new UTranslate(x1, y1));
+ if (direction != null) {
+ ug.apply(new UTranslate((x2 - x1) / 2, (y2 - y1) / 2)).draw(Arrows.asTo(direction));
+ }
+ ug.draw(new ULine(x2 - x1, y2 - y1));
+ }
+
+ public void goUnmergeable() {
+ this.mergeable = false;
+ }
+
+ public void emphasizeDirection(Direction direction) {
+ this.emphasizeDirection = direction;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/SnakeDirection.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/SnakeDirection.java
new file mode 100644
index 0000000..78ca620
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/SnakeDirection.java
@@ -0,0 +1,52 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+import java.awt.geom.Point2D;
+
+public enum SnakeDirection {
+ VERTICAL_THEN_HORIZONTAL, HORIZONTAL_THEN_VERTICAL;
+
+ public static SnakeDirection getDirection(Point2D pt1, Point2D pt2) {
+ if (pt1.getX() == pt2.getX()) {
+ return VERTICAL_THEN_HORIZONTAL;
+ }
+ if (pt1.getY() == pt2.getY()) {
+ return HORIZONTAL_THEN_VERTICAL;
+ }
+ throw new IllegalArgumentException();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/Swimable.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Swimable.java
new file mode 100644
index 0000000..fc45588
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Swimable.java
@@ -0,0 +1,47 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+import java.util.Set;
+
+public interface Swimable {
+
+ public Set<Swimlane> getSwimlanes();
+
+ public Swimlane getSwimlaneIn();
+
+ public Swimlane getSwimlaneOut();
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/Swimlane.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Swimlane.java
new file mode 100644
index 0000000..4c472a0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Swimlane.java
@@ -0,0 +1,95 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+import net.sourceforge.plantuml.SpecificBackcolorable;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class Swimlane implements SpecificBackcolorable {
+
+ private final String name;
+ private HtmlColor color;
+ private Display display;
+
+ private UTranslate translate = new UTranslate();
+ private double totalWidth;
+
+ public Swimlane(String name) {
+ this.name = name;
+ this.display = Display.getWithNewlines(name);
+
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Display getDisplay() {
+ return display;
+ }
+
+ public void setDisplay(Display label) {
+ this.display = label;
+ }
+
+ public final UTranslate getTranslate() {
+ return translate;
+ }
+
+ public final void setTranslateAndWidth(UTranslate translate, double totalWidth) {
+ this.translate = translate;
+ this.totalWidth = totalWidth;
+ }
+
+ public HtmlColor getSpecificBackColor() {
+ return color;
+ }
+
+ public void setSpecificBackcolor(HtmlColor specificBackcolor) {
+ this.color = specificBackcolor;
+ }
+
+ public final double getTotalWidth() {
+ return totalWidth;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/Swimlanes.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Swimlanes.java
new file mode 100644
index 0000000..0ec582a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Swimlanes.java
@@ -0,0 +1,358 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+import java.awt.geom.Dimension2D;
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.OptionFlags;
+import net.sourceforge.plantuml.activitydiagram3.Instruction;
+import net.sourceforge.plantuml.activitydiagram3.InstructionList;
+import net.sourceforge.plantuml.activitydiagram3.LinkRendering;
+import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileFactoryDelegatorAddNote;
+import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileFactoryDelegatorAddUrl;
+import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileFactoryDelegatorAssembly;
+import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileFactoryDelegatorCreateFork;
+import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileFactoryDelegatorCreateGroup;
+import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileFactoryDelegatorCreateSplit;
+import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileFactoryDelegatorIf;
+import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileFactoryDelegatorRepeat;
+import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileFactoryDelegatorWhile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.UGraphicInterceptorOneSwimlane;
+import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.VCompactFactory;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.graphic.UGraphicDelegator;
+import net.sourceforge.plantuml.svek.UGraphicForSnake;
+import net.sourceforge.plantuml.ugraphic.CompressionTransform;
+import net.sourceforge.plantuml.ugraphic.LimitFinder;
+import net.sourceforge.plantuml.ugraphic.MinMax;
+import net.sourceforge.plantuml.ugraphic.SlotFinderX;
+import net.sourceforge.plantuml.ugraphic.SlotSet;
+import net.sourceforge.plantuml.ugraphic.UChange;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class Swimlanes implements TextBlock {
+
+ private final ISkinParam skinParam;;
+
+ private final List<Swimlane> swimlanes = new ArrayList<Swimlane>();
+ private final FontConfiguration fontConfiguration;
+ private Swimlane currentSwimlane = null;
+
+ private final Instruction root = new InstructionList();
+ private Instruction currentInstruction = root;
+
+ private LinkRendering nextLinkRenderer;
+
+ public Swimlanes(ISkinParam skinParam) {
+ this.skinParam = skinParam;
+ final UFont font = skinParam.getFont(FontParam.TITLE, null, false);
+ this.fontConfiguration = new FontConfiguration(font, HtmlColorUtils.BLACK, skinParam.getHyperlinkColor(),
+ skinParam.useUnderlineForHyperlink());
+
+ }
+
+ private FtileFactory getFtileFactory() {
+ FtileFactory factory = new VCompactFactory(skinParam, TextBlockUtils.getDummyStringBounder());
+ factory = new FtileFactoryDelegatorAddUrl(factory, skinParam);
+ factory = new FtileFactoryDelegatorAssembly(factory, skinParam);
+ factory = new FtileFactoryDelegatorIf(factory, skinParam);
+ factory = new FtileFactoryDelegatorWhile(factory, skinParam);
+ factory = new FtileFactoryDelegatorRepeat(factory, skinParam);
+ factory = new FtileFactoryDelegatorCreateFork(factory, skinParam);
+ factory = new FtileFactoryDelegatorCreateSplit(factory, skinParam);
+ factory = new FtileFactoryDelegatorAddNote(factory, skinParam);
+ factory = new FtileFactoryDelegatorCreateGroup(factory, skinParam);
+ return factory;
+ }
+
+ public void swimlane(String name, HtmlColor color, Display label) {
+ currentSwimlane = getOrCreate(name);
+ if (color != null) {
+ currentSwimlane.setSpecificBackcolor(color);
+ }
+ if (label != null) {
+ currentSwimlane.setDisplay(label);
+ }
+ }
+
+ private Swimlane getOrCreate(String name) {
+ for (Swimlane s : swimlanes) {
+ if (s.getName().equals(name)) {
+ return s;
+ }
+ }
+ final Swimlane result = new Swimlane(name);
+ swimlanes.add(result);
+ return result;
+ }
+
+ class Cross extends UGraphicDelegator {
+
+ private Cross(UGraphic ug) {
+ super(ug);
+ }
+
+ @Override
+ public void draw(UShape shape) {
+ if (shape instanceof Ftile) {
+ final Ftile tile = (Ftile) shape;
+ tile.drawU(this);
+ } else if (shape instanceof Connection) {
+ final Connection connection = (Connection) shape;
+ final Ftile tile1 = connection.getFtile1();
+ final Ftile tile2 = connection.getFtile2();
+
+ if (tile1 == null || tile2 == null) {
+ return;
+ }
+ if (tile1.getSwimlaneOut() != tile2.getSwimlaneIn()) {
+ final ConnectionCross connectionCross = new ConnectionCross(connection);
+ connectionCross.drawU(getUg());
+ }
+ }
+ }
+
+ public UGraphic apply(UChange change) {
+ return new Cross(getUg().apply(change));
+ }
+
+ }
+
+ static final double separationMargin = 10;
+
+ public void drawU(UGraphic ug) {
+ final FtileFactory factory = getFtileFactory();
+ TextBlock full = root.createFtile(factory);
+
+ ug = new UGraphicForSnake(ug);
+ if (swimlanes.size() <= 1) {
+ full = new TextBlockInterceptorUDrawable(full);
+ // BUG42
+ // full.drawU(ug);
+ full.drawU(ug);
+ ug.flushUg();
+ return;
+ }
+
+ if (OptionFlags.SWI2) {
+
+ final SlotFinderX slotFinder = new SlotFinderX(ug.getStringBounder());
+ drawWhenSwimlanes(slotFinder, full);
+ final SlotSet slotX = slotFinder.getXSlotSet().reverse();
+ //
+ // // final SlotSet ysSlotSet = slotFinder.getYSlotSet().reverse().smaller(5.0);
+ //
+ System.err.println("slotX=" + slotX);
+
+ printDebug(ug, slotX, HtmlColorUtils.GRAY, full);
+
+ double x2 = 0;
+ double y2 = 0;
+ final double stepy = 40;
+ int i = 0;
+ final SlotSet deconnectedSwimlanes = new SlotSet();
+ for (Swimlane swimlane : swimlanes) {
+ final UGraphic ug2 = ug.apply(new UChangeColor(HtmlColorUtils.GREEN)).apply(
+ new UChangeBackColor(HtmlColorUtils.GREEN));
+ final double totalWidth = swimlane.getTotalWidth();
+ final SlotSet slot2 = slotX.filter(x2 + separationMargin, x2 + totalWidth - separationMargin);
+ deconnectedSwimlanes.addAll(slot2);
+ // ug2.apply(new UTranslate(x2, y2)).draw(new URectangle(totalWidth, stepy));
+ x2 += totalWidth;
+ y2 += stepy;
+ i++;
+ }
+ // printDebug(ug, deconnectedSwimlanes, HtmlColorUtils.GRAY, full);
+
+ //
+ final CompressionTransform compressionTransform = new CompressionTransform(deconnectedSwimlanes);
+ // ug = new UGraphicCompress2(ug, compressionTransform);
+ drawWhenSwimlanes(ug, full);
+ } else {
+ drawWhenSwimlanes(ug, full);
+ }
+ // getCollisionDetector(ug, titleHeightTranslate).drawDebug(ug);
+ }
+
+ static private void printDebug(UGraphic ug, SlotSet slot, HtmlColor col, TextBlock full) {
+ slot.drawDebugX(ug.apply(new UChangeColor(col)).apply(new UChangeBackColor(col)),
+ full.calculateDimension(ug.getStringBounder()).getHeight());
+
+ }
+
+ private void drawWhenSwimlanes(UGraphic ug, TextBlock full) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D dimensionFull = full.calculateDimension(stringBounder);
+
+ final UTranslate titleHeightTranslate = getTitleHeightTranslate(stringBounder);
+
+ computeSize(ug, full);
+
+ double x2 = 0;
+ for (Swimlane swimlane : swimlanes) {
+ if (swimlane.getSpecificBackColor() != null) {
+ final UGraphic background = ug.apply(new UChangeBackColor(swimlane.getSpecificBackColor()))
+ .apply(new UChangeColor(swimlane.getSpecificBackColor())).apply(new UTranslate(x2, 0));
+ background.draw(new URectangle(swimlane.getTotalWidth(), dimensionFull.getHeight()
+ + titleHeightTranslate.getDy()));
+ }
+
+ if (OptionFlags.SWI2 == false) {
+ final TextBlock swTitle = TextBlockUtils.create(swimlane.getDisplay(), fontConfiguration,
+ HorizontalAlignment.LEFT, skinParam);
+ final double titleWidth = swTitle.calculateDimension(stringBounder).getWidth();
+ final double posTitle = x2 + (swimlane.getTotalWidth() - titleWidth) / 2;
+ swTitle.drawU(ug.apply(new UTranslate(posTitle, 0)));
+ }
+
+ drawSeparation(ug.apply(new UTranslate(x2, 0)), dimensionFull.getHeight() + titleHeightTranslate.getDy());
+
+ full.drawU(new UGraphicInterceptorOneSwimlane(ug, swimlane).apply(swimlane.getTranslate()).apply(
+ titleHeightTranslate));
+ x2 += swimlane.getTotalWidth();
+
+ }
+ drawSeparation(ug.apply(new UTranslate(x2, 0)), dimensionFull.getHeight() + titleHeightTranslate.getDy());
+ final Cross cross = new Cross(ug.apply(titleHeightTranslate));
+ full.drawU(cross);
+ cross.flushUg();
+ }
+
+ private void computeSize(UGraphic ug, TextBlock full) {
+ double x1 = 0;
+ final StringBounder stringBounder = ug.getStringBounder();
+ for (Swimlane swimlane : swimlanes) {
+
+ final LimitFinder limitFinder = new LimitFinder(stringBounder, false);
+ final UGraphicInterceptorOneSwimlane interceptor = new UGraphicInterceptorOneSwimlane(new UGraphicForSnake(
+ limitFinder), swimlane);
+ full.drawU(interceptor);
+ interceptor.flushUg();
+ final MinMax minMax = limitFinder.getMinMax();
+
+ final double drawingWidth = minMax.getWidth() + 2 * separationMargin;
+ final TextBlock swTitle = TextBlockUtils.create(swimlane.getDisplay(), fontConfiguration,
+ HorizontalAlignment.LEFT, skinParam);
+ final double titleWidth = swTitle.calculateDimension(stringBounder).getWidth();
+ final double totalWidth = Math.max(drawingWidth, titleWidth + 2 * separationMargin);
+
+ final UTranslate translate = new UTranslate(x1 - minMax.getMinX() + separationMargin
+ + (totalWidth - drawingWidth) / 2.0, 0);
+ swimlane.setTranslateAndWidth(translate, totalWidth);
+
+ x1 += totalWidth;
+ }
+ }
+
+ private UTranslate getTitleHeightTranslate(final StringBounder stringBounder) {
+ double titlesHeight = 0;
+ for (Swimlane swimlane : swimlanes) {
+ final TextBlock swTitle = TextBlockUtils.create(swimlane.getDisplay(), fontConfiguration,
+ HorizontalAlignment.LEFT, skinParam);
+
+ titlesHeight = Math.max(titlesHeight, swTitle.calculateDimension(stringBounder).getHeight());
+ }
+ final UTranslate titleHeightTranslate = new UTranslate(0, titlesHeight);
+ return titleHeightTranslate;
+ }
+
+ private CollisionDetector getCollisionDetector(UGraphic ug, final UTranslate titleHeightTranslate) {
+ final FtileFactory factory = getFtileFactory();
+ final TextBlock full = root.createFtile(factory);
+ ug = new UGraphicForSnake(ug);
+
+ final CollisionDetector collisionDetector = new CollisionDetector(ug.getStringBounder());
+
+ for (Swimlane swimlane : swimlanes) {
+ full.drawU(new UGraphicInterceptorOneSwimlane(collisionDetector, swimlane).apply(swimlane.getTranslate())
+ .apply(titleHeightTranslate));
+ }
+
+ collisionDetector.setManageSnakes(true);
+ final Cross cross = new Cross(collisionDetector.apply(titleHeightTranslate));
+ full.drawU(cross);
+ cross.flushUg();
+
+ return collisionDetector;
+ }
+
+ private void drawSeparation(UGraphic ug, double height) {
+ ug.apply(new UStroke(2)).apply(new UChangeColor(HtmlColorUtils.BLACK)).draw(new ULine(0, height));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return TextBlockUtils.getMinMax(this, stringBounder).getDimension();
+ }
+
+ public Instruction getCurrent() {
+ return currentInstruction;
+ }
+
+ public void setCurrent(Instruction current) {
+ this.currentInstruction = current;
+ }
+
+ public LinkRendering nextLinkRenderer() {
+ return nextLinkRenderer;
+ }
+
+ public void setNextLinkRenderer(LinkRendering link) {
+ this.nextLinkRenderer = link;
+ }
+
+ public Swimlane getCurrentSwimlane() {
+ return currentSwimlane;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/TextBlockInterceptorUDrawable.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/TextBlockInterceptorUDrawable.java
new file mode 100644
index 0000000..a4d24cb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/TextBlockInterceptorUDrawable.java
@@ -0,0 +1,63 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+import java.awt.geom.Dimension2D;
+import java.util.HashMap;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class TextBlockInterceptorUDrawable implements TextBlock {
+
+ private final TextBlock textBlock;
+
+ public TextBlockInterceptorUDrawable(TextBlock textBlock) {
+ this.textBlock = textBlock;
+ }
+
+ public void drawU(UGraphic ug) {
+ textBlock.drawU(new UGraphicInterceptorUDrawable2(ug, new HashMap<String, UTranslate>()));
+ ug.flushUg();
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return TextBlockUtils.getMinMax(this, stringBounder).getDimension();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/UGraphicInterceptorUDrawable2.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/UGraphicInterceptorUDrawable2.java
new file mode 100644
index 0000000..fe284fe
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/UGraphicInterceptorUDrawable2.java
@@ -0,0 +1,109 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile;
+
+import java.awt.geom.Point2D;
+import java.util.Map;
+
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.graphic.UGraphicDelegator;
+import net.sourceforge.plantuml.svek.UGraphicForSnake;
+import net.sourceforge.plantuml.ugraphic.UChange;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class UGraphicInterceptorUDrawable2 extends UGraphicDelegator {
+
+ private final Map<String, UTranslate> positions;
+
+ public UGraphicInterceptorUDrawable2(UGraphic ug, Map<String, UTranslate> positions) {
+ super(ug);
+ this.positions = positions;
+ }
+
+ public void draw(UShape shape) {
+ if (shape instanceof Ftile) {
+ final Ftile ftile = (Ftile) shape;
+ // System.err.println("ftile=" + ftile);
+ ftile.drawU(this);
+ if (ftile instanceof FtileLabel) {
+ positions.put(((FtileLabel) ftile).getName(), getPosition());
+ // System.err.println("ug=" + getUg().getClass());
+ }
+ if (ftile instanceof FtileGoto) {
+ // System.err.println("positions=" + positions);
+ drawGoto((FtileGoto) ftile);
+ }
+ } else if (shape instanceof UDrawable) {
+ final UDrawable drawable = (UDrawable) shape;
+ drawable.drawU(this);
+ } else {
+ getUg().draw(shape);
+ }
+
+ }
+
+ private UTranslate getPosition() {
+ return ((UGraphicForSnake) getUg()).getTranslation();
+ }
+
+ private void drawGoto(FtileGoto ftile) {
+ final FtileGeometry geom = ftile.calculateDimension(getStringBounder());
+ final Point2D pt = geom.getPointIn();
+ UGraphic ugGoto = getUg().apply(new UChangeColor(HtmlColorUtils.GREEN)).apply(
+ new UChangeBackColor(HtmlColorUtils.GREEN));
+ ugGoto = ugGoto.apply(new UTranslate(pt));
+ final UTranslate posNow = getPosition();
+ final UTranslate dest = positions.get(ftile.getName());
+ final double dx = dest.getDx() - posNow.getDx();
+ final double dy = dest.getDy() - posNow.getDy();
+ ugGoto.draw(new UEllipse(3, 3));
+ ugGoto.apply(new UTranslate(dx, dy)).draw(new UEllipse(3, 3));
+ ugGoto.draw(new ULine(dx, 0));
+ ugGoto.apply(new UTranslate(dx, 0)).draw(new ULine(0, dy));
+ // ugGoto.draw(new ULine(dx, dy));
+ }
+
+ public UGraphic apply(UChange change) {
+ return new UGraphicInterceptorUDrawable2(getUg().apply(change), positions);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ConnectionVerticalDown.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ConnectionVerticalDown.java
new file mode 100644
index 0000000..1690fee
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/ConnectionVerticalDown.java
@@ -0,0 +1,103 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractConnection;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Connection;
+import net.sourceforge.plantuml.activitydiagram3.ftile.ConnectionTranslatable;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Snake;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ConnectionVerticalDown extends AbstractConnection implements ConnectionTranslatable {
+
+ private final Point2D p1;
+ private final Point2D p2;
+ private final HtmlColor color;
+ private final TextBlock textBlock;
+
+ public ConnectionVerticalDown(Ftile ftile1, Ftile ftile2, Point2D p1, Point2D p2, HtmlColor color,
+ TextBlock textBlock) {
+ super(ftile1, ftile2);
+ this.p1 = p1;
+ this.p2 = p2;
+ this.color = color;
+ this.textBlock = textBlock;
+ }
+
+ public void drawU(UGraphic ug) {
+ ug.draw(getSimpleSnake());
+ }
+
+ public double getMaxX(StringBounder stringBounder) {
+ return getSimpleSnake().getMaxX(stringBounder);
+ }
+
+ private Snake getSimpleSnake() {
+ final Snake snake = new Snake(color, Arrows.asToDown());
+ snake.setLabel(textBlock);
+ snake.addPoint(p1);
+ snake.addPoint(p2);
+ return snake;
+ }
+
+ public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) {
+ final Snake snake = new Snake(color, Arrows.asToDown());
+ snake.setLabel(textBlock);
+ final Point2D mp1a = translate1.getTranslated(p1);
+ final Point2D mp2b = translate2.getTranslated(p2);
+ final double middle = (mp1a.getY() + mp2b.getY()) / 2.0;
+ snake.addPoint(mp1a);
+ snake.addPoint(mp1a.getX(), middle);
+ snake.addPoint(mp2b.getX(), middle);
+ snake.addPoint(mp2b);
+ ug.draw(snake);
+
+ // final Snake small = new Snake(color, Arrows.asToDown());
+ // small.addPoint(mp2b.getX(), middle);
+ // small.addPoint(mp2b);
+ // ug.draw(small);
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FloatingNote.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FloatingNote.java
new file mode 100644
index 0000000..afaf69b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FloatingNote.java
@@ -0,0 +1,98 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.creole.CreoleParser;
+import net.sourceforge.plantuml.creole.Sheet;
+import net.sourceforge.plantuml.creole.SheetBlock1;
+import net.sourceforge.plantuml.creole.SheetBlock2;
+import net.sourceforge.plantuml.creole.Stencil;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.skin.rose.Rose;
+import net.sourceforge.plantuml.svek.image.Opale;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+
+public class FloatingNote implements Stencil, TextBlock {
+
+ private final Opale opale;
+
+ public FloatingNote(Display note, ISkinParam skinParam) {
+
+ final Rose rose = new Rose();
+ final HtmlColor fontColor = rose.getFontColor(skinParam, FontParam.NOTE);
+ final UFont fontNote = skinParam.getFont(FontParam.NOTE, null, false);
+
+ final HtmlColor noteBackgroundColor = rose.getHtmlColor(skinParam, ColorParam.noteBackground);
+ final HtmlColor borderColor = rose.getHtmlColor(skinParam, ColorParam.noteBorder);
+
+ final FontConfiguration fc = new FontConfiguration(fontNote, fontColor, skinParam.getHyperlinkColor(), skinParam.useUnderlineForHyperlink());
+
+ final Sheet sheet = new CreoleParser(fc, HorizontalAlignment.LEFT, skinParam, false).createSheet(note);
+ final SheetBlock2 sheetBlock2 = new SheetBlock2(new SheetBlock1(sheet, 0, skinParam.getPadding()), this, new UStroke(1));
+ this.opale = new Opale(borderColor, noteBackgroundColor, sheetBlock2, skinParam.shadowing(), false);
+
+ // this.text = sheetBlock2;
+
+ }
+
+ public void drawU(UGraphic ug) {
+ opale.drawU(ug);
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return opale.calculateDimension(stringBounder);
+ }
+
+ public double getStartingX(StringBounder stringBounder, double y) {
+ return -opale.getMarginX1();
+ }
+
+ public double getEndingX(StringBounder stringBounder, double y) {
+ return opale.calculateDimension(stringBounder).getWidth() - opale.getMarginX1();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorAddNote.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorAddNote.java
new file mode 100644
index 0000000..5cdbd52
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorAddNote.java
@@ -0,0 +1,66 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactoryDelegator;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+
+public class FtileFactoryDelegatorAddNote extends FtileFactoryDelegator {
+
+ // private final Rose rose = new Rose();
+
+ public FtileFactoryDelegatorAddNote(FtileFactory factory, ISkinParam skinParam) {
+ super(factory, skinParam);
+ }
+
+ @Override
+ public Ftile addNote(Ftile ftile, Display note, NotePosition notePosition) {
+ if (note == null) {
+ throw new IllegalArgumentException();
+ }
+ // final HtmlColor colorlink;
+ // final LinkRendering inlinkRendering = ftile.getInLinkRendering();
+ // if (inlinkRendering == null || inlinkRendering.getColor() == null) {
+ // colorlink = rose.getHtmlColor(getSkinParam(), ColorParam.activityArrow);
+ // } else {
+ // colorlink = inlinkRendering.getColor();
+ // }
+ return new FtileWithNoteOpale(ftile, note, notePosition, getSkinParam(), true);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorAddUrl.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorAddUrl.java
new file mode 100644
index 0000000..8dcdb8f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorAddUrl.java
@@ -0,0 +1,58 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactoryDelegator;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileWithUrl;
+import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileBox;
+
+public class FtileFactoryDelegatorAddUrl extends FtileFactoryDelegator {
+
+ public FtileFactoryDelegatorAddUrl(FtileFactory factory, ISkinParam skinParam) {
+ super(factory, skinParam);
+ }
+
+ @Override
+ public Ftile addUrl(Ftile ftile, Url url) {
+ if (ftile instanceof FtileBox) {
+ return new FtileWithUrl(ftile, url);
+ }
+ return ftile;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorAssembly.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorAssembly.java
new file mode 100644
index 0000000..29bf617
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorAssembly.java
@@ -0,0 +1,116 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactoryDelegator;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileMargedVertically;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileMinWidth;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.skin.rose.Rose;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class FtileFactoryDelegatorAssembly extends FtileFactoryDelegator {
+
+ public FtileFactoryDelegatorAssembly(FtileFactory factory, ISkinParam skinParam) {
+ super(factory, skinParam);
+ }
+
+ @Override
+ public Ftile assembly(final Ftile tile1, final Ftile tile2) {
+ double height = 35;
+ final TextBlock textBlock = getTextBlock(getInLinkRenderingDisplay(tile2));
+ final StringBounder stringBounder = getStringBounder();
+ if (textBlock != null) {
+ height += textBlock.calculateDimension(stringBounder).getHeight();
+ }
+ // final Ftile space = new FtileEmpty(getFactory().shadowing(), 1, height);
+ final Ftile tile1andSpace = FtileUtils.addBottom(tile1, height);
+ Ftile result = super.assembly(tile1andSpace, tile2);
+ final FtileGeometry geo = tile1.calculateDimension(stringBounder);
+ if (geo.hasPointOut() == false) {
+ return result;
+ }
+ final UTranslate translate1 = result.getTranslateFor(tile1andSpace, stringBounder);
+ final Point2D p1 = geo.translate(translate1).getPointOut();
+ final UTranslate translate2 = result.getTranslateFor(tile2, stringBounder);
+ final Point2D p2 = tile2.calculateDimension(stringBounder).translate(translate2).getPointIn();
+
+ final HtmlColor color = getInLinkRenderingColor(tile2);
+
+ final ConnectionVerticalDown connection = new ConnectionVerticalDown(tile1, tile2, p1, p2, color, textBlock);
+ result = FtileUtils.addConnection(result, connection);
+ if (textBlock != null) {
+ final double width = result.calculateDimension(stringBounder).getWidth();
+ // System.err.println("width=" + width);
+ // System.err.println("p1=" + p1);
+ // System.err.println("p2=" + p2);
+ final double maxX = connection.getMaxX(stringBounder);
+ // System.err.println("maxX=" + maxX);
+ final double needed = (maxX - width) * 2;
+ result = new FtileMinWidth(result, needed);
+ }
+ return result;
+ }
+
+ private final Rose rose = new Rose();
+
+ private TextBlock getTextBlock(Display display) {
+ // DUP1433
+ if (display == null) {
+ return null;
+ }
+ final ISkinParam skinParam = getSkinParam();
+ final UFont font = skinParam.getFont(FontParam.ACTIVITY_ARROW, null, false);
+ final HtmlColor color = rose.getFontColor(skinParam, FontParam.ACTIVITY_ARROW);
+ final FontConfiguration fontConfiguration = new FontConfiguration(font, color, skinParam.getHyperlinkColor(),
+ skinParam.useUnderlineForHyperlink());
+ return TextBlockUtils.create(display, fontConfiguration, HorizontalAlignment.LEFT, null, true);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateFork.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateFork.java
new file mode 100644
index 0000000..1686e73
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateFork.java
@@ -0,0 +1,193 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractConnection;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Connection;
+import net.sourceforge.plantuml.activitydiagram3.ftile.ConnectionTranslatable;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileAssemblySimple;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactoryDelegator;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileHeightFixed;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileMarged;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Snake;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileBlackBlock;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.skin.rose.Rose;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class FtileFactoryDelegatorCreateFork extends FtileFactoryDelegator {
+
+ private final double spaceArroundBlackBar = 20;
+ private final double barHeight = 6;
+ private final double xMargin = 14;
+
+ private final Rose rose = new Rose();
+
+ public FtileFactoryDelegatorCreateFork(FtileFactory factory, ISkinParam skinParam) {
+ super(factory, skinParam);
+ }
+
+ @Override
+ public Ftile createFork(Swimlane swimlane, List<Ftile> all) {
+ final HtmlColor colorBar = rose.getHtmlColor(getSkinParam(), ColorParam.activityBar);
+ final HtmlColor arrowColor = rose.getHtmlColor(getSkinParam(), ColorParam.activityArrow);
+
+ final Dimension2D dimSuper = super.createFork(swimlane, all).calculateDimension(getStringBounder());
+ final double height1 = dimSuper.getHeight() + 2 * spaceArroundBlackBar;
+
+ final List<Ftile> list = new ArrayList<Ftile>();
+ for (Ftile tmp : all) {
+ list.add(new FtileHeightFixed(new FtileMarged(tmp, xMargin), height1));
+ }
+
+ Ftile inner = super.createFork(swimlane, list);
+
+ final List<Connection> conns = new ArrayList<Connection>();
+
+ final Ftile black = new FtileBlackBlock(shadowing(), colorBar, list.get(0).getSwimlaneIn());
+ double x = 0;
+ for (Ftile tmp : list) {
+ final Dimension2D dim = tmp.calculateDimension(getStringBounder());
+ conns.add(new ConnectionIn(black, tmp, x, arrowColor));
+ conns.add(new ConnectionOut(tmp, black, x, arrowColor, height1));
+ x += dim.getWidth();
+ }
+
+ inner = FtileUtils.addConnection(inner, conns);
+ ((FtileBlackBlock) black).setDimenstion(inner.calculateDimension(getStringBounder()).getWidth(), barHeight);
+ final Ftile tmp1 = new FtileAssemblySimple(black, inner);
+ return new FtileAssemblySimple(tmp1, black);
+ }
+
+ class ConnectionIn extends AbstractConnection implements ConnectionTranslatable {
+
+ private final double x;
+ private final HtmlColor arrowColor;
+
+ public ConnectionIn(Ftile ftile1, Ftile ftile2, double x, HtmlColor arrowColor) {
+ super(ftile1, ftile2);
+ this.x = x;
+ this.arrowColor = arrowColor;
+ }
+
+ public void drawU(UGraphic ug) {
+ ug = ug.apply(new UTranslate(x, 0));
+ final FtileGeometry geo = getFtile2().calculateDimension(getStringBounder());
+ final Snake s = new Snake(arrowColor, Arrows.asToDown());
+ s.addPoint(geo.getLeft(), 0);
+ s.addPoint(geo.getLeft(), geo.getInY());
+ ug.draw(s);
+ }
+
+ public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) {
+ ug = ug.apply(new UTranslate(x, 0));
+ final FtileGeometry geo = getFtile2().calculateDimension(getStringBounder());
+ final Point2D p1 = new Point2D.Double(geo.getLeft(), 0);
+ final Point2D p2 = new Point2D.Double(geo.getLeft(), geo.getInY());
+
+ final Snake snake = new Snake(arrowColor, Arrows.asToDown());
+ final Point2D mp1a = translate1.getTranslated(p1);
+ final Point2D mp2b = translate2.getTranslated(p2);
+ final double middle = mp1a.getY() + 4;
+ snake.addPoint(mp1a);
+ snake.addPoint(mp1a.getX(), middle);
+ snake.addPoint(mp2b.getX(), middle);
+ snake.addPoint(mp2b);
+ ug.draw(snake);
+ }
+ }
+
+ class ConnectionOut extends AbstractConnection implements ConnectionTranslatable {
+
+ private final double x;
+ private final HtmlColor arrowColor;
+ private final double height;
+
+ public ConnectionOut(Ftile ftile1, Ftile ftile2, double x, HtmlColor arrowColor, double height) {
+ super(ftile1, ftile2);
+ this.x = x;
+ this.arrowColor = arrowColor;
+ this.height = height;
+ }
+
+ public void drawU(UGraphic ug) {
+ ug = ug.apply(new UTranslate(x, 0));
+ final FtileGeometry geo = getFtile1().calculateDimension(getStringBounder());
+ if (geo.hasPointOut() == false) {
+ return;
+ }
+ final Snake s = new Snake(arrowColor, Arrows.asToDown());
+ s.addPoint(geo.getLeft(), geo.getOutY());
+ s.addPoint(geo.getLeft(), height);
+ ug.draw(s);
+ }
+
+ public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) {
+ ug = ug.apply(new UTranslate(x, 0));
+ final FtileGeometry geo = getFtile1().calculateDimension(getStringBounder());
+ if (geo.hasPointOut() == false) {
+ return;
+ }
+ final Point2D p1 = new Point2D.Double(geo.getLeft(), geo.getOutY());
+ final Point2D p2 = new Point2D.Double(geo.getLeft(), height);
+
+ final Snake snake = new Snake(arrowColor, Arrows.asToDown());
+ final Point2D mp1a = translate1.getTranslated(p1);
+ final Point2D mp2b = translate2.getTranslated(p2);
+ final double middle = mp2b.getY() - 14;
+ snake.addPoint(mp1a);
+ snake.addPoint(mp1a.getX(), middle);
+ snake.addPoint(mp2b.getX(), middle);
+ snake.addPoint(mp2b);
+ ug.draw(snake);
+ }
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateGroup.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateGroup.java
new file mode 100644
index 0000000..65f9132
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateGroup.java
@@ -0,0 +1,60 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactoryDelegator;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.skin.rose.Rose;
+
+public class FtileFactoryDelegatorCreateGroup extends FtileFactoryDelegator {
+
+ private final Rose rose = new Rose();
+
+ public FtileFactoryDelegatorCreateGroup(FtileFactory factory, ISkinParam skinParam) {
+ super(factory, skinParam);
+ }
+
+ @Override
+ public Ftile createGroup(Ftile list, Display name, HtmlColor backColor, HtmlColor titleColor, Display headerNote) {
+ final HtmlColor arrowColor = rose.getHtmlColor(getSkinParam(), ColorParam.activityArrow);
+ return new FtileGroup(list, name, headerNote, arrowColor, backColor, titleColor, getSkinParam());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateSplit.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateSplit.java
new file mode 100644
index 0000000..4d55d09
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorCreateSplit.java
@@ -0,0 +1,416 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
+
+import java.awt.geom.Dimension2D;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.OptionFlags;
+import net.sourceforge.plantuml.activitydiagram3.LinkRendering;
+import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractConnection;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Connection;
+import net.sourceforge.plantuml.activitydiagram3.ftile.ConnectionTranslatable;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactoryDelegator;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileHeightFixed;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileKilled;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileMarged;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Snake;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.skin.rose.Rose;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class FtileFactoryDelegatorCreateSplit extends FtileFactoryDelegator {
+
+ private final double spaceArroundBlackBar = 20;
+ private final double barHeight = 6;
+ private final double xMargin = 14;
+
+ private final Rose rose = new Rose();
+
+ public FtileFactoryDelegatorCreateSplit(FtileFactory factory, ISkinParam skinParam) {
+ super(factory, skinParam);
+ }
+
+ static private boolean isSimpleSwimlanes(List<Ftile> all) {
+ final Set<Swimlane> already = new HashSet<Swimlane>();
+ for (Ftile ftile : all) {
+ final Set<Swimlane> currents = ftile.getSwimlanes();
+ if (currents.size() != 1) {
+ return false;
+ }
+ assert currents.size() == 1;
+ final Swimlane current = currents.iterator().next();
+ if (already.contains(current)) {
+ return false;
+ }
+ already.add(current);
+ }
+ return already.size() > 1;
+ }
+
+ static private boolean isSeveralSwimlanes(List<Ftile> all) {
+ final Set<Swimlane> already = new HashSet<Swimlane>();
+ for (Ftile ftile : all) {
+ final Set<Swimlane> currents = ftile.getSwimlanes();
+ if (currents.size() > 1) {
+ return true;
+ }
+ assert currents.size() == 0 || currents.size() == 1;
+ if (currents.size() == 1) {
+ final Swimlane current = currents.iterator().next();
+ already.add(current);
+ }
+ }
+ return already.size() > 1;
+ }
+
+ @Override
+ public Ftile createSplit(List<Ftile> all) {
+ // OptionFlags.SWI2
+ // if (all != null)
+ // return severalSwimlanes(all);
+ // // if (isSimpleSwimlanes(all)) {
+ // return simpleSwimlanes(all);
+ // // return severalSwimlanes(all);
+ // // } else if (isSeveralSwimlanes(all)) {
+ // // return severalSwimlanes(all);
+ // }
+ final HtmlColor arrowColor = rose.getHtmlColor(getSkinParam(), ColorParam.activityArrow);
+
+ final Dimension2D dimSuper = super.createSplit(all).calculateDimension(getStringBounder());
+ final double height1 = dimSuper.getHeight() + 2 * spaceArroundBlackBar;
+
+ final List<Ftile> list = new ArrayList<Ftile>();
+ for (Ftile tmp : all) {
+ list.add(new FtileHeightFixed(new FtileMarged(tmp, xMargin), height1));
+ }
+
+ Ftile inner = super.createSplit(list);
+
+ final List<Connection> conns = new ArrayList<Connection>();
+
+ double x = 0;
+ boolean hasOut = false;
+ for (Ftile tmp : list) {
+ final Dimension2D dim = tmp.calculateDimension(getStringBounder());
+ conns.add(new ConnectionIn(tmp, x, arrowColor, getTextBlock(tmp.getInLinkRendering())));
+ final boolean hasOutTmp = tmp.calculateDimension(getStringBounder()).hasPointOut();
+ if (hasOutTmp) {
+ conns.add(new ConnectionOut(tmp, x, arrowColor, height1, getTextBlock(tmp.getOutLinkRendering())));
+ hasOut = true;
+ }
+ x += dim.getWidth();
+ }
+ final double totalWidth = inner.calculateDimension(getStringBounder()).getWidth();
+ conns.add(new ConnectionHline2(inner, OptionFlags.SWI2 ? HtmlColorUtils.BLUE : arrowColor, 0, list, totalWidth));
+ if (hasOut) {
+ conns.add(new ConnectionHline2(inner, OptionFlags.SWI2 ? HtmlColorUtils.GREEN : arrowColor, height1, list,
+ totalWidth));
+ }
+
+ inner = FtileUtils.addConnection(inner, conns);
+ if (hasOut == false) {
+ inner = new FtileKilled(inner);
+ }
+ return inner;
+ }
+
+ // private Ftile severalSwimlanes(List<Ftile> all) {
+ // final HtmlColor arrowColor = rose.getHtmlColor(getSkinParam(), ColorParam.activityArrow);
+ // final Dimension2D dimSuper = new FtileForkInner1(all).calculateDimension(getStringBounder());
+ // final double height1 = dimSuper.getHeight() + 2 * spaceArroundBlackBar;
+ // final List<Ftile> list = new ArrayList<Ftile>();
+ // for (Ftile tmp : all) {
+ // list.add(new FtileHeightFixed(new FtileMarged(tmp, xMargin), height1));
+ // // list.add(new FtileMarged(tmp, xMargin));
+ // // list.add(tmp);
+ // }
+ //
+ // Ftile inner = new FtileForkInner1(list);
+ // final List<Connection> conns = new ArrayList<Connection>();
+ // boolean hasOut = false;
+ // for (Ftile tmp : list) {
+ // // final Dimension2D dim = tmp.calculateDimension(getStringBounder());
+ // final UTranslate translateFor = inner.getTranslateFor(tmp, getStringBounder());
+ // if (translateFor == null) {
+ // continue;
+ // }
+ // final double x = translateFor.getDx();
+ // conns.add(new ConnectionIn(tmp, x, arrowColor));
+ // final boolean hasOutTmp = tmp.calculateDimension(getStringBounder()).hasPointOut();
+ // if (hasOutTmp) {
+ // conns.add(new ConnectionOut(tmp, x, arrowColor, height1));
+ // hasOut = true;
+ // }
+ // // x += dim.getWidth();
+ // }
+ // final double totalWidth = inner.calculateDimension(getStringBounder()).getWidth();
+ // conns.add(new ConnectionHline2(inner, arrowColor, 0, list, totalWidth));
+ // if (hasOut) {
+ // conns.add(new ConnectionHline2(inner, arrowColor, height1, list, totalWidth));
+ // }
+ // inner = FtileUtils.addConnection(inner, conns);
+ //
+ // return inner;
+ // }
+
+ private TextBlock getTextBlock(LinkRendering linkRendering) {
+ // DUP1433
+ final Display display = LinkRendering.getDisplay(linkRendering);
+ if (display == null) {
+ return null;
+ }
+ final ISkinParam skinParam = getSkinParam();
+ final UFont font = skinParam.getFont(FontParam.ACTIVITY_ARROW, null, false);
+ final HtmlColor color = rose.getFontColor(skinParam, FontParam.ACTIVITY_ARROW);
+ final FontConfiguration fontConfiguration = new FontConfiguration(font, color, skinParam.getHyperlinkColor(),
+ skinParam.useUnderlineForHyperlink());
+ return TextBlockUtils.create(display, fontConfiguration, HorizontalAlignment.LEFT, null, true);
+ }
+
+ private Ftile simpleSwimlanes(List<Ftile> all) {
+ final HtmlColor arrowColor = rose.getHtmlColor(getSkinParam(), ColorParam.activityArrow);
+
+ final Dimension2D dimSuper = new FtileSplit1(all).calculateDimension(getStringBounder());
+ final double height1 = dimSuper.getHeight() + 2 * spaceArroundBlackBar;
+
+ final List<Ftile> list = new ArrayList<Ftile>();
+ for (Ftile tmp : all) {
+ list.add(new FtileHeightFixed(new FtileMarged(tmp, xMargin), height1));
+ }
+
+ Ftile inner = new FtileSplit1(list);
+
+ final List<Connection> conns = new ArrayList<Connection>();
+
+ boolean hasOut = false;
+ for (Ftile tmp : list) {
+ // final Dimension2D dim = tmp.calculateDimension(getStringBounder());
+ final double x = inner.getTranslateFor(tmp, getStringBounder()).getDx();
+ conns.add(new ConnectionIn(tmp, x, arrowColor, null));
+ final boolean hasOutTmp = tmp.calculateDimension(getStringBounder()).hasPointOut();
+ if (hasOutTmp) {
+ conns.add(new ConnectionOut(tmp, x, arrowColor, height1, null));
+ hasOut = true;
+ }
+ // x += dim.getWidth();
+ }
+ final double totalWidth = inner.calculateDimension(getStringBounder()).getWidth();
+ conns.add(new ConnectionHline3(inner, arrowColor, 0, list, totalWidth));
+ if (hasOut) {
+ conns.add(new ConnectionHline3(inner, arrowColor, height1, list, totalWidth));
+ }
+ //
+ inner = FtileUtils.addConnection(inner, conns);
+ if (hasOut == false) {
+ inner = new FtileKilled(inner);
+ }
+ return inner;
+
+ }
+
+ static class ConnectionHline2 extends AbstractConnection {
+
+ private final Ftile inner;
+ private final double y;
+ private final HtmlColor arrowColor;
+ private final List<Ftile> list;
+ private final double totalWidth;
+
+ public ConnectionHline2(Ftile inner, HtmlColor arrowColor, double y, List<Ftile> list, double totalWidth) {
+ super(null, null);
+ this.inner = inner;
+ this.y = y;
+ this.arrowColor = arrowColor;
+ this.list = list;
+ this.totalWidth = totalWidth;
+ }
+
+ public void drawU(UGraphic ug) {
+ double minX = Double.MAX_VALUE;
+ double maxX = 0;
+ final StringBounder stringBounder = ug.getStringBounder();
+ for (Ftile tmp : list) {
+ if (y > 0 && tmp.calculateDimension(stringBounder).hasPointOut() == false) {
+ continue;
+ }
+ final UTranslate ut = inner.getTranslateFor(tmp, stringBounder);
+ if (ut == null) {
+ continue;
+ }
+ final double middle = tmp.calculateDimension(stringBounder).translate(ut).getLeft();
+ minX = Math.min(minX, middle);
+ maxX = Math.max(maxX, middle);
+ }
+ if (minX > totalWidth / 2) {
+ minX = totalWidth / 2;
+ }
+ if (maxX < totalWidth / 2) {
+ maxX = totalWidth / 2;
+ }
+
+ final Snake s = new Snake(arrowColor);
+ s.goUnmergeable();
+ s.addPoint(minX, y);
+ s.addPoint(maxX, y);
+ ug.draw(s);
+ }
+ }
+
+ static class ConnectionHline3 extends AbstractConnection implements ConnectionTranslatable {
+
+ private final Ftile inner;
+ private final double y;
+ private final HtmlColor arrowColor;
+ private final List<Ftile> list;
+ private final double totalWidth;
+
+ public ConnectionHline3(Ftile inner, HtmlColor arrowColor, double y, List<Ftile> list, double totalWidth) {
+ super(null, null);
+ this.inner = inner;
+ this.y = y;
+ this.arrowColor = arrowColor;
+ this.list = list;
+ this.totalWidth = totalWidth;
+ }
+
+ public void drawU(UGraphic ug) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final UTranslate left = inner.getSwimlaneIn().getTranslate();
+ double minX = inner.calculateDimension(stringBounder).getLeft() + left.getDx();
+ double maxX = minX;
+
+ for (Ftile tmp : list) {
+ final FtileGeometry tmpGeom = tmp.calculateDimension(stringBounder);
+ final UTranslate tpos = inner.getTranslateFor(tmp, stringBounder);
+ for (Swimlane sw : tmp.getSwimlanes()) {
+ final double x = tmpGeom.translate(sw.getTranslate().compose(tpos)).getLeft();
+ minX = Math.min(minX, x);
+ maxX = Math.max(maxX, x);
+ }
+ }
+ final Dimension2D dimInner = inner.calculateDimension(stringBounder);
+
+ final Snake s = new Snake(arrowColor);
+ // final Snake s = new Snake(HtmlColorUtils.GREEN);
+ s.goUnmergeable();
+ s.addPoint(minX, y);
+ s.addPoint(maxX, y);
+ ug.draw(s);
+ }
+ }
+
+ static class ConnectionIn extends AbstractConnection {
+
+ private final double x;
+ private final HtmlColor arrowColor;
+ private final TextBlock text;
+
+ public ConnectionIn(Ftile tmp, double x, HtmlColor arrowColor, TextBlock text) {
+ super(null, tmp);
+ this.x = x;
+ this.arrowColor = arrowColor;
+ this.text = text;
+ }
+
+ public void drawU(UGraphic ug) {
+ ug = ug.apply(new UTranslate(x, 0));
+ final FtileGeometry geo = getFtile2().calculateDimension(ug.getStringBounder());
+ final double left = geo.getLeft();
+ final Snake s = new Snake(arrowColor, Arrows.asToDown());
+ s.setLabel(text);
+ s.addPoint(left, 0);
+ s.addPoint(left, geo.getInY());
+ ug.draw(s);
+ }
+ }
+
+ static class ConnectionOut extends AbstractConnection {
+
+ private final double x;
+ private final HtmlColor arrowColor;
+ private final double height;
+ private final TextBlock text;
+
+ public ConnectionOut(Ftile tmp, double x, HtmlColor arrowColor, double height, TextBlock text) {
+ super(tmp, null);
+ this.x = x;
+ this.arrowColor = arrowColor;
+ this.height = height;
+ this.text = text;
+ }
+
+ public void drawU(UGraphic ug) {
+ ug = ug.apply(new UTranslate(x, 0));
+ final FtileGeometry geo = getFtile1().calculateDimension(ug.getStringBounder());
+ if (geo.hasPointOut() == false) {
+ assert false;
+ return;
+ }
+ final Snake s = new Snake(arrowColor, Arrows.asToDown());
+ s.setLabel(text);
+ s.goUnmergeable();
+ s.addPoint(geo.getLeft(), geo.getOutY());
+ s.addPoint(geo.getLeft(), height);
+ ug.draw(s);
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorIf.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorIf.java
new file mode 100644
index 0000000..9de99a1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorIf.java
@@ -0,0 +1,79 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.activitydiagram3.Branch;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactoryDelegator;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.svek.ConditionStyle;
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public class FtileFactoryDelegatorIf extends FtileFactoryDelegator {
+
+ public FtileFactoryDelegatorIf(FtileFactory factory, ISkinParam skinParam) {
+ super(factory, skinParam);
+ }
+
+ @Override
+ public Ftile createIf(Swimlane swimlane, List<Branch> thens, Branch elseBranch) {
+
+ final ConditionStyle conditionStyle = getSkinParam().getConditionStyle();
+ final UFont fontArrow = getSkinParam().getFont(FontParam.ACTIVITY_ARROW, null, false);
+ final UFont fontTest = getSkinParam().getFont(
+ conditionStyle == ConditionStyle.INSIDE ? FontParam.ACTIVITY_DIAMOND : FontParam.ACTIVITY_ARROW, null, false);
+ final Branch branch0 = thens.get(0);
+
+ final HtmlColor borderColor = getRose().getHtmlColor(getSkinParam(), ColorParam.activityBorder);
+ final HtmlColor backColor = branch0.getColor() == null ? getRose().getHtmlColor(getSkinParam(),
+ ColorParam.activityBackground) : branch0.getColor();
+ final HtmlColor arrowColor = getRose().getHtmlColor(getSkinParam(), ColorParam.activityArrow);
+
+ if (thens.size() > 1) {
+ return FtileIfLong2.create(swimlane, borderColor, backColor, fontArrow, arrowColor, getFactory(),
+ conditionStyle, thens, elseBranch, getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink());
+ }
+ return FtileIf.create(swimlane, borderColor, backColor, fontArrow, fontTest, arrowColor, getFactory(),
+ conditionStyle, thens.get(0), elseBranch, getSkinParam(), getStringBounder());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorRepeat.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorRepeat.java
new file mode 100644
index 0000000..f0467cb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorRepeat.java
@@ -0,0 +1,77 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.activitydiagram3.LinkRendering;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactoryDelegator;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.svek.ConditionStyle;
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public class FtileFactoryDelegatorRepeat extends FtileFactoryDelegator {
+
+ public FtileFactoryDelegatorRepeat(FtileFactory factory, ISkinParam skinParam) {
+ super(factory, skinParam);
+ }
+
+ @Override
+ public Ftile repeat(Swimlane swimlane, Ftile repeat, Display test, Display yes, Display out, HtmlColor color,
+ LinkRendering backRepeatLinkRendering) {
+ final ConditionStyle conditionStyle = getSkinParam().getConditionStyle();
+ final UFont font = getSkinParam().getFont(
+ conditionStyle == ConditionStyle.INSIDE ? FontParam.ACTIVITY_DIAMOND : FontParam.ACTIVITY_ARROW, null,
+ false);
+
+ final HtmlColor borderColor = getRose().getHtmlColor(getSkinParam(), ColorParam.activityBorder);
+ final HtmlColor backColor = color == null ? getRose().getHtmlColor(getSkinParam(),
+ ColorParam.activityBackground) : color;
+ final HtmlColor arrowColor = getRose().getHtmlColor(getSkinParam(), ColorParam.activityArrow);
+
+ final LinkRendering endRepeatLinkRendering = repeat.getOutLinkRendering();
+ final HtmlColor endRepeatLinkColor = endRepeatLinkRendering == null ? null : endRepeatLinkRendering.getColor();
+
+ return FtileRepeat.create(backRepeatLinkRendering, swimlane, repeat, test, yes, out, borderColor, backColor, font, arrowColor,
+ endRepeatLinkColor, conditionStyle, this, getSkinParam().getHyperlinkColor(), getSkinParam()
+ .useUnderlineForHyperlink());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorWhile.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorWhile.java
new file mode 100644
index 0000000..a1bd72c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileFactoryDelegatorWhile.java
@@ -0,0 +1,75 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.activitydiagram3.LinkRendering;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactoryDelegator;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.svek.ConditionStyle;
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public class FtileFactoryDelegatorWhile extends FtileFactoryDelegator {
+
+ public FtileFactoryDelegatorWhile(FtileFactory factory, ISkinParam skinParam) {
+ super(factory, skinParam);
+ }
+
+ @Override
+ public Ftile createWhile(Swimlane swimlane, Ftile whileBlock, Display test, Display yes, Display out,
+ LinkRendering afterEndwhile, HtmlColor color) {
+ final HtmlColor borderColor = getRose().getHtmlColor(getSkinParam(), ColorParam.activityBorder);
+ final HtmlColor backColor = color == null ? getRose().getHtmlColor(getSkinParam(),
+ ColorParam.activityBackground) : color;
+ final HtmlColor arrowColor = getRose().getHtmlColor(getSkinParam(), ColorParam.activityArrow);
+
+ final ConditionStyle conditionStyle = getSkinParam().getConditionStyle();
+ final UFont fontArrow = getSkinParam().getFont(FontParam.ACTIVITY_ARROW, null, false);
+ final UFont fontTest = getSkinParam().getFont(
+ conditionStyle == ConditionStyle.INSIDE ? FontParam.ACTIVITY_DIAMOND : FontParam.ACTIVITY_ARROW, null, false);
+
+ final LinkRendering endInlinkRendering = whileBlock.getOutLinkRendering();
+ final HtmlColor endInlinkColor = endInlinkRendering == null ? arrowColor : endInlinkRendering.getColor();
+ return FtileWhile.create(swimlane, whileBlock, test, borderColor, backColor, arrowColor, yes, out,
+ fontArrow, endInlinkColor, afterEndwhile, getFactory(), conditionStyle, fontTest, getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileForkInner.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileForkInner.java
new file mode 100644
index 0000000..0a37e68
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileForkInner.java
@@ -0,0 +1,121 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
+
+import java.awt.geom.Dimension2D;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class FtileForkInner extends AbstractFtile {
+
+ private final List<Ftile> forks = new ArrayList<Ftile>();
+
+ public FtileForkInner(List<Ftile> forks) {
+ super(forks.get(0).shadowing());
+ for (Ftile ftile : forks) {
+ this.forks.add(ftile);
+ }
+ }
+
+ public Swimlane getSwimlaneIn() {
+ return forks.get(0).getSwimlaneIn();
+ }
+
+ public Swimlane getSwimlaneOut() {
+ return getSwimlaneIn();
+ }
+
+ public Set<Swimlane> getSwimlanes() {
+ return mergeSwimlanes(forks);
+ }
+
+ public static Set<Swimlane> mergeSwimlanes(List<Ftile> tiles) {
+ final Set<Swimlane> result = new HashSet<Swimlane>();
+ for (Ftile tile : tiles) {
+ result.addAll(tile.getSwimlanes());
+ }
+ return Collections.unmodifiableSet(result);
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+
+ double xpos = 0;
+ for (Ftile ftile : forks) {
+ ug.apply(new UTranslate(xpos, 0)).draw(ftile);
+ final Dimension2D dim = ftile.calculateDimension(stringBounder);
+ xpos += dim.getWidth();
+ }
+ }
+
+ public FtileGeometry calculateDimension(StringBounder stringBounder) {
+ double height = 0;
+ double width = 0;
+ for (Ftile ftile : forks) {
+ final Dimension2D dim = ftile.calculateDimension(stringBounder);
+ width += dim.getWidth();
+ if (dim.getHeight() > height) {
+ height = dim.getHeight();
+ }
+ }
+ final Dimension2D dimTotal = new Dimension2DDouble(width, height);
+ return new FtileGeometry(dimTotal, dimTotal.getWidth() / 2, 0, dimTotal.getHeight());
+ }
+
+ public UTranslate getTranslateFor(Ftile searched, StringBounder stringBounder) {
+ double xpos = 0;
+ for (Ftile ftile : forks) {
+ if (ftile == searched) {
+ return new UTranslate(xpos, 0);
+ }
+ final Dimension2D dim = ftile.calculateDimension(stringBounder);
+ xpos += dim.getWidth();
+ }
+ throw new IllegalArgumentException();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileGroup.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileGroup.java
new file mode 100644
index 0000000..c46dbcc
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileGroup.java
@@ -0,0 +1,168 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
+
+import java.awt.Font;
+import java.awt.geom.Dimension2D;
+import java.util.Set;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.activitydiagram3.LinkRendering;
+import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileMarged;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.SymbolContext;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.graphic.USymbol;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+import net.sourceforge.plantuml.utils.MathUtils;
+
+public class FtileGroup extends AbstractFtile {
+
+ private final double diffYY2 = 20;
+ private final Ftile inner;
+ private final TextBlock name;
+ private final TextBlock headerNote;
+ private final HtmlColor color;
+ private final HtmlColor backColor;
+ private final HtmlColor titleColor;
+
+ public FtileGroup(Ftile inner, Display title, Display displayNote, HtmlColor color, HtmlColor backColor,
+ HtmlColor titleColor, ISkinParam skinParam) {
+ super(inner.shadowing());
+ this.backColor = backColor == null ? HtmlColorUtils.WHITE : backColor;
+ this.inner = new FtileMarged(inner, 10);
+ this.color = color;
+ this.titleColor = titleColor;
+ final UFont font = new UFont("Serif", Font.PLAIN, 14);
+ final FontConfiguration fc = new FontConfiguration(font, HtmlColorUtils.BLACK, skinParam.getHyperlinkColor(),
+ skinParam.useUnderlineForHyperlink());
+ if (title == null) {
+ this.name = TextBlockUtils.empty(0, 0);
+ } else {
+ this.name = TextBlockUtils.create(title, fc, HorizontalAlignment.LEFT, skinParam);
+ }
+ if (displayNote == null) {
+ this.headerNote = TextBlockUtils.empty(0, 0);
+ } else {
+ this.headerNote = new FloatingNote(displayNote, skinParam);
+ }
+ }
+
+ @Override
+ public LinkRendering getInLinkRendering() {
+ return inner.getInLinkRendering();
+ }
+
+ public Set<Swimlane> getSwimlanes() {
+ return inner.getSwimlanes();
+ }
+
+ public Swimlane getSwimlaneIn() {
+ return inner.getSwimlaneIn();
+ }
+
+ public Swimlane getSwimlaneOut() {
+ return inner.getSwimlaneOut();
+ }
+
+ private double diffHeightTitle(StringBounder stringBounder) {
+ final Dimension2D dimTitle = name.calculateDimension(stringBounder);
+ return Math.max(25, dimTitle.getHeight() + 20);
+ }
+
+ private UTranslate getTranslate(StringBounder stringBounder) {
+ final double suppWidth = suppWidth(stringBounder);
+ return new UTranslate(suppWidth / 2, diffHeightTitle(stringBounder) + headerNoteHeight(stringBounder));
+ }
+
+ public double suppWidth(StringBounder stringBounder) {
+ final FtileGeometry orig = inner.calculateDimension(stringBounder);
+ final Dimension2D dimTitle = name.calculateDimension(stringBounder);
+ final Dimension2D dimHeaderNote = headerNote.calculateDimension(stringBounder);
+ final double suppWidth = MathUtils
+ .max(orig.getWidth(), dimTitle.getWidth() + 20, dimHeaderNote.getWidth() + 20) - orig.getWidth();
+ return suppWidth;
+ }
+
+ public FtileGeometry calculateDimension(StringBounder stringBounder) {
+ final FtileGeometry orig = inner.calculateDimension(stringBounder);
+ final double suppWidth = suppWidth(stringBounder);
+ final double width = orig.getWidth() + suppWidth;
+ final double height = orig.getHeight() + diffHeightTitle(stringBounder) + diffYY2
+ + headerNoteHeight(stringBounder);
+ final double titleAndHeaderNoteHeight = diffHeightTitle(stringBounder) + headerNoteHeight(stringBounder);
+ if (orig.hasPointOut()) {
+ return new FtileGeometry(width, height, orig.getLeft() + suppWidth / 2, orig.getInY()
+ + titleAndHeaderNoteHeight, orig.getOutY() + titleAndHeaderNoteHeight);
+ }
+ return new FtileGeometry(width, height, orig.getLeft() + suppWidth / 2, orig.getInY()
+ + titleAndHeaderNoteHeight);
+ }
+
+ private double headerNoteHeight(StringBounder stringBounder) {
+ return headerNote.calculateDimension(stringBounder).getHeight();
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D dimTotal = calculateDimension(stringBounder);
+
+ final SymbolContext symbolContext = new SymbolContext(backColor, HtmlColorUtils.BLACK).withShadow(shadowing())
+ .withStroke(new UStroke(2));
+ USymbol.FRAME.asBig(name, TextBlockUtils.empty(0, 0), dimTotal.getWidth(), dimTotal.getHeight(), symbolContext)
+ .drawU(ug);
+
+ final Dimension2D dimHeaderNote = headerNote.calculateDimension(stringBounder);
+ headerNote.drawU(ug.apply(new UTranslate(dimTotal.getWidth() - dimHeaderNote.getWidth() - 10,
+ diffHeightTitle(ug.getStringBounder()) - 10)));
+
+ ug.apply(getTranslate(stringBounder)).draw(inner);
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIf.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIf.java
new file mode 100644
index 0000000..58fee9a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIf.java
@@ -0,0 +1,595 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.Direction;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.activitydiagram3.Branch;
+import net.sourceforge.plantuml.activitydiagram3.LinkRendering;
+import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractConnection;
+import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Connection;
+import net.sourceforge.plantuml.activitydiagram3.ftile.ConnectionTranslatable;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Diamond;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileEmpty;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileMinWidth;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Snake;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamond;
+import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamondInside;
+import net.sourceforge.plantuml.creole.CreoleParser;
+import net.sourceforge.plantuml.creole.Sheet;
+import net.sourceforge.plantuml.creole.SheetBlock1;
+import net.sourceforge.plantuml.creole.SheetBlock2;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.svek.ConditionStyle;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class FtileIf extends AbstractFtile {
+
+ private final Ftile tile1;
+ private final Ftile tile2;
+ private final Ftile diamond1;
+ private final Ftile diamond2;
+
+ private final HtmlColor arrowColor;
+
+ private FtileIf(Ftile diamond1, Ftile tile1, Ftile tile2, Ftile diamond2, HtmlColor arrowColor) {
+ super(tile1.shadowing() || tile2.shadowing());
+ this.diamond1 = diamond1;
+ this.diamond2 = diamond2;
+ this.tile1 = tile1;
+ this.tile2 = tile2;
+
+ this.arrowColor = arrowColor;
+
+ }
+
+ public Set<Swimlane> getSwimlanes() {
+ final Set<Swimlane> result = new HashSet<Swimlane>();
+ if (getSwimlaneIn() != null) {
+ result.add(getSwimlaneIn());
+ }
+ result.addAll(tile1.getSwimlanes());
+ result.addAll(tile2.getSwimlanes());
+ return Collections.unmodifiableSet(result);
+ }
+
+ public Swimlane getSwimlaneIn() {
+ return diamond1.getSwimlaneIn();
+ }
+
+ public Swimlane getSwimlaneOut() {
+ return getSwimlaneIn();
+ }
+
+ static Ftile create(Swimlane swimlane, HtmlColor borderColor, HtmlColor backColor, UFont fontArrow, UFont fontTest,
+ HtmlColor arrowColor, FtileFactory ftileFactory, ConditionStyle conditionStyle, Branch branch1,
+ Branch branch2, ISkinParam skinParam, StringBounder stringBounder) {
+
+ final Display labelTest = branch1.getLabelTest();
+ // if (branch1.isOnlySingleStop() || branch2.isOnlySingleStop()) {
+ // final Branch nonStop = branch1.isOnlySingleStop() ? branch2 : branch1;
+ // return FtileIfAndStop.create(swimlane, borderColor, backColor, fontArrow, fontTest, arrowColor,
+ // ftileFactory, conditionStyle, nonStop, skinParam, stringBounder, labelTest);
+ // }
+
+ final Ftile tile1 = new FtileMinWidth(branch1.getFtile(), 30);
+ final Ftile tile2 = new FtileMinWidth(branch2.getFtile(), 30);
+
+ final HtmlColor fontColor = skinParam.getFontHtmlColor(FontParam.ACTIVITY_DIAMOND, null);
+
+ final FontConfiguration fcArrow = new FontConfiguration(fontArrow, fontColor, skinParam.getHyperlinkColor(),
+ skinParam.useUnderlineForHyperlink());
+ final FontConfiguration fcTest = new FontConfiguration(fontTest, fontColor, skinParam.getHyperlinkColor(),
+ skinParam.useUnderlineForHyperlink());
+
+ final TextBlock tb1 = TextBlockUtils.create(branch1.getLabelPositive(), fcArrow, HorizontalAlignment.LEFT,
+ ftileFactory, true);
+ final TextBlock tb2 = TextBlockUtils.create(branch2.getLabelPositive(), fcArrow, HorizontalAlignment.LEFT,
+ ftileFactory, true);
+
+ final Sheet sheet = new CreoleParser(fcTest, HorizontalAlignment.LEFT, skinParam, false).createSheet(labelTest);
+ final SheetBlock1 sheetBlock1 = new SheetBlock1(sheet, 0, skinParam.getPadding());
+ final TextBlock tbTest = new SheetBlock2(sheetBlock1, Diamond.asStencil(sheetBlock1), new UStroke(1.5));
+
+ final Ftile diamond1;
+ if (conditionStyle == ConditionStyle.INSIDE) {
+ diamond1 = new FtileDiamondInside(tile1.shadowing(), backColor, borderColor, swimlane, tbTest)
+ .withWest(tb1).withEast(tb2);
+ } else if (conditionStyle == ConditionStyle.DIAMOND) {
+ diamond1 = new FtileDiamond(tile1.shadowing(), backColor, borderColor, swimlane).withWest(tb1)
+ .withEast(tb2).withNorth(tbTest);
+ } else {
+ throw new IllegalStateException();
+ }
+
+ final Ftile diamond2;
+ if (tile1.calculateDimension(stringBounder).hasPointOut()
+ && tile2.calculateDimension(stringBounder).hasPointOut()) {
+ final Display out1 = LinkRendering.getDisplay(branch1.getFtile().getOutLinkRendering());
+ final TextBlock tbout1 = out1 == null ? null : TextBlockUtils.create(out1, fcArrow,
+ HorizontalAlignment.LEFT, ftileFactory, true);
+ final Display out2 = LinkRendering.getDisplay(branch2.getFtile().getOutLinkRendering());
+ final TextBlock tbout2 = out2 == null ? null : TextBlockUtils.create(out2, fcArrow,
+ HorizontalAlignment.LEFT, ftileFactory, true);
+ diamond2 = new FtileDiamond(tile1.shadowing(), backColor, borderColor, swimlane).withWest(tbout1).withEast(
+ tbout2);
+ } else {
+ diamond2 = new FtileEmpty(tile1.shadowing(), Diamond.diamondHalfSize * 2, Diamond.diamondHalfSize * 2,
+ swimlane, swimlane);
+ }
+ final FtileIf result = new FtileIf(diamond1, tile1, tile2, diamond2, arrowColor);
+
+ final List<Connection> conns = new ArrayList<Connection>();
+ conns.add(result.new ConnectionHorizontalThenVertical(tile1, branch1));
+ conns.add(result.new ConnectionHorizontalThenVertical(tile2, branch2));
+ if (tile1.calculateDimension(stringBounder).hasPointOut()
+ && tile2.calculateDimension(stringBounder).hasPointOut()) {
+ conns.add(result.new ConnectionVerticalThenHorizontal(tile1, branch1.getInlinkRenderingColor(), branch1
+ .isEmpty()));
+ conns.add(result.new ConnectionVerticalThenHorizontal(tile2, branch2.getInlinkRenderingColor(), branch2
+ .isEmpty()));
+ } else if (tile1.calculateDimension(stringBounder).hasPointOut()
+ && tile2.calculateDimension(stringBounder).hasPointOut() == false) {
+ conns.add(result.new ConnectionVerticalThenHorizontalDirect(tile1, branch1.getInlinkRenderingColor(),
+ branch1.isEmpty()));
+ } else if (tile1.calculateDimension(stringBounder).hasPointOut() == false
+ && tile2.calculateDimension(stringBounder).hasPointOut()) {
+ conns.add(result.new ConnectionVerticalThenHorizontalDirect(tile2, branch2.getInlinkRenderingColor(),
+ branch2.isEmpty()));
+ }
+ // return result;
+ return FtileUtils.addConnection(result, conns);
+ }
+
+ private HtmlColor getInColor(Branch branch) {
+ if (branch.isEmpty()) {
+ return LinkRendering.getColor(branch.getFtile().getOutLinkRendering(), arrowColor);
+ }
+ final LinkRendering linkIn = branch.getFtile().getInLinkRendering();
+ final HtmlColor color = linkIn == null ? arrowColor : linkIn.getColor();
+ return color;
+
+ }
+
+ class ConnectionHorizontalThenVertical extends AbstractConnection implements ConnectionTranslatable {
+
+ private final HtmlColor color;
+ private final UPolygon usingArrow;
+
+ public ConnectionHorizontalThenVertical(Ftile tile, Branch branch) {
+ super(diamond1, tile);
+ color = getInColor(branch);
+ usingArrow = branch.isEmpty() ? null : Arrows.asToDown();
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Point2D p1 = getP1(stringBounder);
+ final Point2D p2 = getP2(stringBounder);
+ final double x1 = p1.getX();
+ final double y1 = p1.getY();
+ final double x2 = p2.getX();
+ final double y2 = p2.getY();
+
+ final Snake snake = new Snake(color, usingArrow);
+ snake.addPoint(x1, y1);
+ snake.addPoint(x2, y1);
+ snake.addPoint(x2, y2);
+
+ ug.draw(snake);
+ }
+
+ public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ Point2D p1 = getP1(stringBounder);
+ Point2D p2 = getP2(stringBounder);
+ final Direction originalDirection = Direction.leftOrRight(p1, p2);
+ p1 = translate1.getTranslated(p1);
+ p2 = translate2.getTranslated(p2);
+ final Direction newDirection = Direction.leftOrRight(p1, p2);
+ if (originalDirection != newDirection) {
+ final double delta = (originalDirection == Direction.RIGHT ? -1 : 1) * Diamond.diamondHalfSize;
+ final Dimension2D dimDiamond1 = diamond1.calculateDimension(stringBounder);
+ final Snake small = new Snake(color);
+ small.addPoint(p1);
+ small.addPoint(p1.getX() + delta, p1.getY());
+ small.addPoint(p1.getX() + delta, p1.getY() + dimDiamond1.getHeight() * .75);
+ ug.draw(small);
+ p1 = small.getLast();
+ }
+ final Snake snake = new Snake(color, usingArrow);
+ snake.addPoint(p1);
+ snake.addPoint(p2.getX(), p1.getY());
+ snake.addPoint(p2);
+ ug.draw(snake);
+
+ }
+
+ private Point2D getP1(StringBounder stringBounder) {
+ final Dimension2D dimDiamond1 = diamond1.calculateDimension(stringBounder);
+ final double diamondWidth = dimDiamond1.getWidth();
+ final double x;
+ if (getFtile2() == tile1) {
+ x = 0;
+ } else if (getFtile2() == tile2) {
+ x = diamondWidth;
+ } else {
+ throw new IllegalStateException();
+ }
+ return getTranslateDiamond1(stringBounder)
+ .getTranslated(new Point2D.Double(x, dimDiamond1.getHeight() / 2));
+ }
+
+ private Point2D getP2(final StringBounder stringBounder) {
+ return translate(stringBounder).getTranslated(getFtile2().calculateDimension(stringBounder).getPointIn());
+ }
+
+ private UTranslate translate(StringBounder stringBounder) {
+ if (getFtile2() == tile1) {
+ return getTranslate1(stringBounder);
+ }
+ if (getFtile2() == tile2) {
+ return getTranslate2(stringBounder);
+ }
+ throw new IllegalStateException();
+ }
+ }
+
+ class ConnectionVerticalThenHorizontal extends AbstractConnection implements ConnectionTranslatable {
+ private final HtmlColor myArrowColor;
+ private final boolean branchEmpty;
+
+ public ConnectionVerticalThenHorizontal(Ftile tile, HtmlColor myArrowColor, boolean branchEmpty) {
+ super(tile, diamond2);
+ this.myArrowColor = myArrowColor == null ? arrowColor : myArrowColor;
+ this.branchEmpty = branchEmpty;
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+
+ final FtileGeometry geo = getFtile1().calculateDimension(stringBounder);
+ if (geo.hasPointOut() == false) {
+ return;
+ }
+ final Point2D p1 = geo.translate(translate(stringBounder)).getPointOut();
+ final Point2D p2 = getP2(stringBounder);
+
+ final double x1 = p1.getX();
+ final double y1 = p1.getY();
+ final double x2 = p2.getX();
+ final double y2 = p2.getY();
+
+ final UPolygon arrow = x2 > x1 ? Arrows.asToRight() : Arrows.asToLeft();
+ final Snake snake = new Snake(myArrowColor, arrow);
+ if (branchEmpty) {
+ snake.emphasizeDirection(Direction.DOWN);
+ }
+ snake.addPoint(x1, y1);
+ snake.addPoint(x1, y2);
+ snake.addPoint(x2, y2);
+
+ ug.draw(snake);
+ }
+
+ public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final FtileGeometry geo = getFtile1().calculateDimension(stringBounder);
+ if (geo.hasPointOut() == false) {
+ return;
+ }
+ final Point2D p2 = getP2(stringBounder);
+ final Point2D p1 = geo.translate(translate(stringBounder)).getPointOut();
+ final Direction originalDirection = Direction.leftOrRight(p1, p2);
+
+ final double x1 = p1.getX();
+ final double x2 = p2.getX();
+ final Point2D mp1a = translate1.getTranslated(p1);
+ final Point2D mp2b = translate2.getTranslated(p2);
+ final Direction newDirection = Direction.leftOrRight(mp1a, mp2b);
+ final UPolygon arrow = x2 > x1 ? Arrows.asToRight() : Arrows.asToLeft();
+ if (originalDirection == newDirection) {
+ final double delta = (x2 > x1 ? -1 : 1) * 1.5 * Diamond.diamondHalfSize;
+ final Point2D mp2bc = new Point2D.Double(mp2b.getX() + delta, mp2b.getY());
+ final Snake snake = new Snake(myArrowColor);
+ final double middle = (mp1a.getY() + mp2b.getY()) / 2.0;
+ snake.addPoint(mp1a);
+ snake.addPoint(mp1a.getX(), middle);
+ snake.addPoint(mp2bc.getX(), middle);
+ snake.addPoint(mp2bc);
+ ug.draw(snake);
+ final Snake small = new Snake(myArrowColor, arrow);
+ small.addPoint(mp2bc);
+ small.addPoint(mp2bc.getX(), mp2b.getY());
+ small.addPoint(mp2b);
+ ug.draw(small);
+ } else {
+ final double delta = (x2 > x1 ? -1 : 1) * 1.5 * Diamond.diamondHalfSize;
+ final Point2D mp2bb = new Point2D.Double(mp2b.getX() + delta, mp2b.getY() - 3 * Diamond.diamondHalfSize);
+ final Snake snake = new Snake(myArrowColor);
+ snake.addPoint(mp1a);
+ snake.addPoint(mp1a.getX(), mp2bb.getY());
+ snake.addPoint(mp2bb);
+ ug.draw(snake);
+ final Snake small = new Snake(myArrowColor, arrow);
+ small.addPoint(mp2bb);
+ small.addPoint(mp2bb.getX(), mp2b.getY());
+ small.addPoint(mp2b);
+ ug.draw(small);
+
+ }
+
+ }
+
+ private Point2D getP2(StringBounder stringBounder) {
+ final Dimension2D dimDiamond2 = diamond2.calculateDimension(stringBounder);
+ final double diamondWidth = dimDiamond2.getWidth();
+ final double x;
+ if (getFtile1() == tile1) {
+ x = 0;
+ } else if (getFtile1() == tile2) {
+ x = diamondWidth;
+ } else {
+ throw new IllegalStateException();
+ }
+ return getTranslateDiamond2(stringBounder)
+ .getTranslated(new Point2D.Double(x, dimDiamond2.getHeight() / 2));
+ }
+
+ private UTranslate translate(StringBounder stringBounder) {
+ if (getFtile1() == tile1) {
+ return getTranslate1(stringBounder);
+ }
+ if (getFtile1() == tile2) {
+ return getTranslate2(stringBounder);
+ }
+ throw new IllegalStateException();
+ }
+ }
+
+ class ConnectionVerticalThenHorizontalDirect extends AbstractConnection implements ConnectionTranslatable {
+ private final HtmlColor myArrowColor;
+ private final boolean branchEmpty;
+
+ public ConnectionVerticalThenHorizontalDirect(Ftile tile, HtmlColor myArrowColor, boolean branchEmpty) {
+ super(tile, diamond2);
+ this.myArrowColor = myArrowColor == null ? arrowColor : myArrowColor;
+ this.branchEmpty = branchEmpty;
+ }
+
+ public void drawU(UGraphic ug) {
+
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
+
+ final FtileGeometry geo = getFtile1().calculateDimension(stringBounder);
+ if (geo.hasPointOut() == false) {
+ return;
+ }
+ final Point2D p1 = geo.translate(translate(stringBounder)).getPointOut();
+ final Point2D p2 = new Point2D.Double(getLeft(stringBounder), dimTotal.getHeight()
+ - Diamond.diamondHalfSize);
+
+ final double x1 = p1.getX();
+ final double y1 = p1.getY();
+ final double x2 = p2.getX();
+ final double y2 = p2.getY();
+
+ final Snake snake = new Snake(myArrowColor);
+ if (branchEmpty) {
+ snake.emphasizeDirection(Direction.DOWN);
+ }
+ snake.addPoint(x1, y1);
+ snake.addPoint(x1, y2);
+ snake.addPoint(x2, y2);
+ snake.addPoint(x2, dimTotal.getHeight());
+
+ ug.draw(snake);
+ }
+
+ private UTranslate translate(StringBounder stringBounder) {
+ if (getFtile1() == tile1) {
+ return getTranslate1(stringBounder);
+ }
+ if (getFtile1() == tile2) {
+ return getTranslate2(stringBounder);
+ }
+ throw new IllegalStateException();
+ }
+
+ public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
+
+ final FtileGeometry geo = getFtile1().calculateDimension(stringBounder);
+ if (geo.hasPointOut() == false) {
+ return;
+ }
+ final Point2D p1 = geo.translate(translate(stringBounder)).getPointOut();
+ final Point2D p2 = new Point2D.Double(getLeft(stringBounder), dimTotal.getHeight()
+ - Diamond.diamondHalfSize);
+
+ final Point2D mp1a = translate1.getTranslated(p1);
+ final Point2D mp2b = translate2.getTranslated(p2);
+
+ final Snake snake = new Snake(myArrowColor);
+ // snake.emphasizeDirection(Direction.DOWN);
+
+ final double x1 = mp1a.getX();
+ final double x2 = mp2b.getX();
+ final double y2 = mp2b.getY();
+
+ snake.addPoint(mp1a);
+ snake.addPoint(x1, y2);
+ snake.addPoint(mp2b);
+ snake.addPoint(x2, dimTotal.getHeight());
+
+ ug.draw(snake);
+ }
+ }
+
+ private UTranslate getTranslate1(StringBounder stringBounder) {
+ final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
+ final Dimension2D dimDiamond1 = diamond1.calculateDimension(stringBounder);
+ final Dimension2D dim1 = tile1.calculateDimension(stringBounder);
+
+ final double x1 = 0;
+ final double h = dimDiamond1.getHeight();
+ // final double y1 = (dimTotal.getHeight() - 2 * h - dim1.getHeight()) / 2 + h;
+ final double y1 = h * 1.9;
+ return new UTranslate(x1, y1);
+ }
+
+ private UTranslate getTranslate2(StringBounder stringBounder) {
+ final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
+ final Dimension2D dimDiamond1 = diamond1.calculateDimension(stringBounder);
+ final Dimension2D dim2 = tile2.calculateDimension(stringBounder);
+
+ final double x2 = dimTotal.getWidth() - dim2.getWidth();
+ final double h = dimDiamond1.getHeight();
+ // final double y2 = (dimTotal.getHeight() - 2 * h - dim2.getHeight()) / 2 + h;
+ final double y2 = h * 1.9;
+ return new UTranslate(x2, y2);
+
+ }
+
+ private UTranslate getTranslateDiamond1(StringBounder stringBounder) {
+ final double y1 = 0;
+ final Dimension2D dimDiamond1 = diamond1.calculateDimension(stringBounder);
+ final double x1 = getLeft(stringBounder) - dimDiamond1.getWidth() / 2;
+ return new UTranslate(x1, y1);
+ }
+
+ private UTranslate getTranslateDiamond2(StringBounder stringBounder) {
+ final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
+ final Dimension2D dimDiamond2 = diamond2.calculateDimension(stringBounder);
+ final double y2 = dimTotal.getHeight() - dimDiamond2.getHeight();
+ final double x2 = getLeft(stringBounder) - dimDiamond2.getWidth() / 2;
+ return new UTranslate(x2, y2);
+ }
+
+ @Override
+ public UTranslate getTranslateFor(Ftile child, StringBounder stringBounder) {
+ if (child == diamond1) {
+ return getTranslateDiamond1(stringBounder);
+ }
+ if (child == tile1) {
+ return getTranslate1(stringBounder);
+ }
+ if (child == tile2) {
+ return getTranslate2(stringBounder);
+ }
+ if (child == diamond2) {
+ return getTranslateDiamond2(stringBounder);
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+
+ ug.apply(getTranslateDiamond1(stringBounder)).draw(diamond1);
+ ug.apply(getTranslate1(stringBounder)).draw(tile1);
+ ug.apply(getTranslate2(stringBounder)).draw(tile2);
+ ug.apply(getTranslateDiamond2(stringBounder)).draw(diamond2);
+ }
+
+ public FtileGeometry calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
+ if (tile1.calculateDimension(stringBounder).hasPointOut()
+ || tile2.calculateDimension(stringBounder).hasPointOut()) {
+ return new FtileGeometry(dimTotal, getLeft(stringBounder), 0, dimTotal.getHeight());
+ }
+ return new FtileGeometry(dimTotal, getLeft(stringBounder), 0);
+ }
+
+ private Dimension2D calculateDimensionInternal;
+
+ private Dimension2D calculateDimensionInternal(StringBounder stringBounder) {
+ if (calculateDimensionInternal == null) {
+ calculateDimensionInternal = calculateDimensionInternalSlow(stringBounder);
+ }
+ return calculateDimensionInternal;
+ }
+
+ private Dimension2D calculateDimensionInternalSlow(StringBounder stringBounder) {
+ final FtileGeometry dim1 = tile1.calculateDimension(stringBounder);
+ final FtileGeometry dim2 = tile2.calculateDimension(stringBounder);
+
+ final Dimension2D dimDiamond1 = diamond1.calculateDimension(stringBounder);
+
+ final double withInner = Math.max(dimDiamond1.getWidth(), (dim1.getWidth() - dim1.getLeft()) + dim2.getLeft()
+ + 10);
+ final double width = dim1.getLeft() + withInner + (dim2.getWidth() - dim2.getLeft());
+
+ final Dimension2D dim12 = Dimension2DDouble.mergeLR(dim1, dim2);
+
+ return new Dimension2DDouble(width + 30, dim12.getHeight() + dimDiamond1.getHeight() * 3 + 30);
+ }
+
+ private double getLeft(StringBounder stringBounder) {
+ final double left1 = tile1.calculateDimension(stringBounder).translate(getTranslate1(stringBounder)).getLeft();
+ final double left2 = tile2.calculateDimension(stringBounder).translate(getTranslate2(stringBounder)).getLeft();
+ return (left1 + left2) / 2;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfAndStop.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfAndStop.java
new file mode 100644
index 0000000..9579bdd
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfAndStop.java
@@ -0,0 +1,319 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.activitydiagram3.Branch;
+import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractConnection;
+import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Connection;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Diamond;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Snake;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamond;
+import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamondInside;
+import net.sourceforge.plantuml.creole.CreoleParser;
+import net.sourceforge.plantuml.creole.Sheet;
+import net.sourceforge.plantuml.creole.SheetBlock1;
+import net.sourceforge.plantuml.creole.SheetBlock2;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.svek.ConditionStyle;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class FtileIfAndStop extends AbstractFtile {
+
+ private final Ftile tile1;
+ private final Ftile diamond1;
+ private final Ftile stop2;
+
+ private final HtmlColor arrowColor;
+
+ private FtileIfAndStop(Ftile diamond1, Ftile tile1, HtmlColor arrowColor, Ftile stopFtile) {
+ super(tile1.shadowing());
+ this.diamond1 = diamond1;
+ this.tile1 = tile1;
+ this.stop2 = stopFtile;
+
+ this.arrowColor = arrowColor;
+
+ }
+
+ public Set<Swimlane> getSwimlanes() {
+ final Set<Swimlane> result = new HashSet<Swimlane>();
+ if (getSwimlaneIn() != null) {
+ result.add(getSwimlaneIn());
+ }
+ result.addAll(tile1.getSwimlanes());
+ return Collections.unmodifiableSet(result);
+ }
+
+ public Swimlane getSwimlaneIn() {
+ return diamond1.getSwimlaneIn();
+ }
+
+ public Swimlane getSwimlaneOut() {
+ return getSwimlaneIn();
+ }
+
+ static Ftile create(Swimlane swimlane, HtmlColor borderColor, HtmlColor backColor, UFont fontArrow, UFont fontTest,
+ HtmlColor arrowColor, FtileFactory ftileFactory, ConditionStyle conditionStyle, Branch nonStop,
+ ISkinParam skinParam, StringBounder stringBounder, Display labelTest) {
+
+ backColor = HtmlColorUtils.BLUE;
+
+ // final Ftile tileNonStop = new FtileMinWidth(nonStop.getFtile(), 30);
+ final Ftile tileNonStop = nonStop.getFtile();
+
+ final HtmlColor fontColor = skinParam.getFontHtmlColor(FontParam.ACTIVITY_DIAMOND, null);
+
+ final FontConfiguration fcArrow = new FontConfiguration(fontArrow, fontColor, skinParam.getHyperlinkColor(),
+ skinParam.useUnderlineForHyperlink());
+ final FontConfiguration fcTest = new FontConfiguration(fontTest, fontColor, skinParam.getHyperlinkColor(),
+ skinParam.useUnderlineForHyperlink());
+
+ final Ftile stopFtile = ftileFactory.stop(swimlane);
+
+ // final TextBlock tb1 = TextBlockUtils.create(branch1.getLabelPositive(), fcArrow, HorizontalAlignment.LEFT,
+ // ftileFactory);
+ // final TextBlock tb2 = TextBlockUtils.create(branch2.getLabelPositive(), fcArrow, HorizontalAlignment.LEFT,
+ // ftileFactory);
+
+ final Sheet sheet = new CreoleParser(fcTest, HorizontalAlignment.LEFT, skinParam, false).createSheet(labelTest);
+ final SheetBlock1 sheetBlock1 = new SheetBlock1(sheet, 0, skinParam.getPadding());
+ final TextBlock tbTest = new SheetBlock2(sheetBlock1, Diamond.asStencil(sheetBlock1), new UStroke(1.5));
+
+ final Ftile diamond1;
+ if (conditionStyle == ConditionStyle.INSIDE) {
+ diamond1 = new FtileDiamondInside(tileNonStop.shadowing(), backColor, borderColor, swimlane, tbTest);
+ // .withWest(tb1).withEast(tb2);
+ } else if (conditionStyle == ConditionStyle.DIAMOND) {
+ diamond1 = new FtileDiamond(tileNonStop.shadowing(), backColor, borderColor, swimlane).withNorth(tbTest);
+ // .withWest(tb1).withEast(tb2).withNorth(tbTest);
+ } else {
+ throw new IllegalStateException();
+ }
+
+ // final Ftile diamond2;
+ // if (tile1.calculateDimension(stringBounder).hasPointOut()
+ // && tile2.calculateDimension(stringBounder).hasPointOut()) {
+ // diamond2 = new FtileDiamond(tile1.shadowing(), backColor, borderColor, swimlane);
+ // } else {
+ // diamond2 = new FtileEmpty(tile1.shadowing(), Diamond.diamondHalfSize * 2, Diamond.diamondHalfSize * 2,
+ // swimlane, swimlane);
+ // }
+ final FtileIfAndStop result = new FtileIfAndStop(diamond1, tileNonStop, arrowColor, stopFtile);
+
+ final List<Connection> conns = new ArrayList<Connection>();
+ conns.add(result.new ConnectionHorizontal(arrowColor));
+ // conns.add(result.new ConnectionHorizontalThenVertical(tile2));
+ // if (tile1.calculateDimension(stringBounder).hasPointOut()
+ // && tile2.calculateDimension(stringBounder).hasPointOut()) {
+ // conns.add(result.new ConnectionVerticalThenHorizontal(tile1, branch1.getInlinkRenderingColor()));
+ // conns.add(result.new ConnectionVerticalThenHorizontal(tile2, branch2.getInlinkRenderingColor()));
+ // } else if (tile1.calculateDimension(stringBounder).hasPointOut()
+ // && tile2.calculateDimension(stringBounder).hasPointOut() == false) {
+ // conns.add(result.new ConnectionVerticalThenHorizontalDirect(tile1, branch1.getInlinkRenderingColor()));
+ // } else if (tile1.calculateDimension(stringBounder).hasPointOut() == false
+ // && tile2.calculateDimension(stringBounder).hasPointOut()) {
+ // conns.add(result.new ConnectionVerticalThenHorizontalDirect(tile2, branch2.getInlinkRenderingColor()));
+ // }
+ return FtileUtils.addConnection(result, conns);
+ // return result;
+ }
+
+ private UTranslate getTranslate1(StringBounder stringBounder) {
+ // final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
+ final FtileGeometry dimTotal = calculateDimension(stringBounder);
+ final FtileGeometry dimDiamond1 = diamond1.calculateDimension(stringBounder);
+ final FtileGeometry dim1 = tile1.calculateDimension(stringBounder);
+
+ final double x1 = calculateDimension(stringBounder).getLeft() - dim1.getLeft();
+ // final double y1 = (dimTotal.getHeight() - 2 * h - dim1.getHeight()) / 2 + h;
+ final double y1 = dimDiamond1.getHeight() + getSuppHeight();
+ return new UTranslate(x1, y1);
+ }
+
+ private int getSuppHeight() {
+ return 30;
+ }
+
+ private UTranslate getTranslateDiamond1(StringBounder stringBounder) {
+ final double y1 = 0;
+ final Dimension2D dimDiamond1 = diamond1.calculateDimension(stringBounder);
+ // final double x1 = getLeft(stringBounder) - dimDiamond1.getWidth() / 2;
+ final double x1 = calculateDimension(stringBounder).getLeft() - dimDiamond1.getWidth() / 2;
+ return new UTranslate(x1, y1);
+ }
+
+ private UTranslate getTranslateStop(StringBounder stringBounder) {
+ final Dimension2D dimDiamond1 = diamond1.calculateDimension(stringBounder);
+ final Dimension2D dimStop = stop2.calculateDimension(stringBounder);
+ final double y1 = (dimDiamond1.getHeight() - dimStop.getHeight()) / 2;
+ final double x1 = calculateDimension(stringBounder).getLeft() + dimDiamond1.getWidth() / 2
+ + getDiamondStopDistance();
+ return new UTranslate(x1, y1);
+ }
+
+ private double getDiamondStopDistance() {
+ return 40;
+ }
+
+ class ConnectionHorizontal extends AbstractConnection {
+
+ private final HtmlColor color;
+
+ public ConnectionHorizontal(HtmlColor color) {
+ super(diamond1, stop2);
+ this.color = color;
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Point2D p1 = getP1(stringBounder);
+ final Point2D p2 = getP2(stringBounder);
+
+ final Snake snake = new Snake(color, Arrows.asToRight());
+ snake.addPoint(p1);
+ snake.addPoint(p2);
+ ug.draw(snake);
+ }
+
+ private Point2D getP1(StringBounder stringBounder) {
+ final Dimension2D dimDiamond1 = getFtile1().calculateDimension(stringBounder);
+ final Point2D p = new Point2D.Double(dimDiamond1.getWidth(), dimDiamond1.getHeight() / 2);
+
+ return getTranslateDiamond1(stringBounder).getTranslated(p);
+ }
+
+ private Point2D getP2(StringBounder stringBounder) {
+ final Dimension2D dimStop = getFtile2().calculateDimension(stringBounder);
+ final Point2D p = new Point2D.Double(0, dimStop.getHeight() / 2);
+ return getTranslateStop(stringBounder).getTranslated(p);
+ }
+
+ }
+
+ @Override
+ public UTranslate getTranslateFor(Ftile child, StringBounder stringBounder) {
+ if (child == diamond1) {
+ return getTranslateDiamond1(stringBounder);
+ }
+ if (child == tile1) {
+ return getTranslate1(stringBounder);
+ }
+ // if (child == tile2) {
+ // return getTranslate2(stringBounder);
+ // }
+ // if (child == diamond2) {
+ // return getTranslateDiamond2(stringBounder);
+ // }
+ throw new UnsupportedOperationException();
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+
+ ug.apply(getTranslateDiamond1(stringBounder)).draw(diamond1);
+ ug.apply(getTranslate1(stringBounder)).draw(tile1);
+ ug.apply(getTranslateStop(stringBounder)).draw(stop2);
+ }
+
+ public FtileGeometry calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dimStop2 = stop2.calculateDimension(stringBounder);
+ final FtileGeometry dim1 = tile1.calculateDimension(stringBounder).addDim(0,
+ getDiamondStopDistance() + dimStop2.getWidth());
+ final FtileGeometry dimDiamond1 = diamond1.calculateDimension(stringBounder);
+ return dimDiamond1.appendBottom(dim1).addDim(0, getSuppHeight());
+
+ // final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
+ // if (tile1.calculateDimension(stringBounder).hasPointOut()) {
+ // return new FtileGeometry(dimTotal, getLeft(stringBounder), 0, dimTotal.getHeight());
+ // }
+ // return new FtileGeometry(dimTotal, getLeft(stringBounder), 0);
+ }
+
+ // private Dimension2D calculateDimensionInternal;
+ //
+ // private Dimension2D calculateDimensionInternal(StringBounder stringBounder) {
+ // if (calculateDimensionInternal == null) {
+ // calculateDimensionInternal = calculateDimensionInternalSlow(stringBounder);
+ // }
+ // return calculateDimensionInternal;
+ // }
+ //
+ // private Dimension2D calculateDimensionInternalSlow(StringBounder stringBounder) {
+ // final Dimension2D dim1 = tile1.calculateDimension(stringBounder);
+ // final Dimension2D dimDiamond1 = diamond1.calculateDimension(stringBounder);
+ // final Dimension2D dimStop2 = stop2.calculateDimension(stringBounder);
+ // final double width = Math.max(dim1.getWidth(),
+ // dimDiamond1.getWidth() + getDiamondStopDistance() + dimStop2.getWidth());
+ // return new Dimension2DDouble(width + 30, dim1.getHeight() + dimDiamond1.getHeight() + 40);
+ // }
+ //
+ // private double getLeft(StringBounder stringBounder) {
+ // // return calculateDimension(stringBounder).getLeft();
+ // return tile1.calculateDimension(stringBounder).translate(getTranslate1(stringBounder)).getLeft();
+ // // final double left1 =
+ // tile1.calculateDimension(stringBounder).translate(getTranslate1(stringBounder)).getLeft();
+ // // // final double left2 =
+ // // // tile2.calculateDimension(stringBounder).translate(getTranslate2(stringBounder)).getLeft();
+ // // // return (left1 + left2) / 2;
+ // // return left1;
+ // }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLong.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLong.java
new file mode 100644
index 0000000..26b0ead
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLong.java
@@ -0,0 +1,516 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.activitydiagram3.Branch;
+import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractConnection;
+import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Connection;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileMinWidth;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Snake;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamondInside;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.svek.ConditionStyle;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class FtileIfLong extends AbstractFtile {
+
+ private final double xSeparation = 20;
+
+ private final List<Ftile> tiles;
+ private final Ftile tile2;
+ private final List<Ftile> diamonds;
+
+ private final HtmlColor arrowColor;
+
+ private FtileIfLong(List<Ftile> diamonds, List<Ftile> tiles, Ftile tile2, HtmlColor arrowColor) {
+ super(tiles.get(0).shadowing() || tile2.shadowing());
+ this.diamonds = diamonds;
+ this.tiles = tiles;
+ this.tile2 = tile2;
+
+ this.arrowColor = arrowColor;
+
+ }
+
+ public Set<Swimlane> getSwimlanes() {
+ final Set<Swimlane> result = new HashSet<Swimlane>();
+ if (getSwimlaneIn() != null) {
+ result.add(getSwimlaneIn());
+ }
+ for (Ftile tile : tiles) {
+ result.addAll(tile.getSwimlanes());
+ }
+ result.addAll(tile2.getSwimlanes());
+ return Collections.unmodifiableSet(result);
+ }
+
+ public Swimlane getSwimlaneIn() {
+ return diamonds.get(0).getSwimlaneIn();
+ }
+
+ public Swimlane getSwimlaneOut() {
+ return getSwimlaneIn();
+ }
+
+ static Ftile create(Swimlane swimlane, HtmlColor borderColor, HtmlColor backColor, UFont font,
+ HtmlColor arrowColor, FtileFactory ftileFactory, ConditionStyle conditionStyle, List<Branch> thens,
+ Branch branch2, HtmlColor hyperlinkColor, boolean useUnderlineForHyperlink) {
+
+ final List<Ftile> tiles = new ArrayList<Ftile>();
+
+ for (Branch branch : thens) {
+ tiles.add(new FtileMinWidth(branch.getFtile(), 30));
+ }
+
+ final Ftile tile2 = new FtileMinWidth(branch2.getFtile(), 30);
+
+ final FontConfiguration fc = new FontConfiguration(font, HtmlColorUtils.BLACK, hyperlinkColor,
+ useUnderlineForHyperlink);
+
+ final List<Ftile> diamonds = new ArrayList<Ftile>();
+ final List<Connection> conns = new ArrayList<Connection>();
+ for (Branch branch : thens) {
+ final TextBlock tb1 = TextBlockUtils.create(branch.getLabelPositive(), fc, HorizontalAlignment.LEFT,
+ ftileFactory);
+ final TextBlock tbTest = TextBlockUtils.create(branch.getLabelTest(), fc, HorizontalAlignment.LEFT,
+ ftileFactory);
+ FtileDiamondInside diamond = new FtileDiamondInside(branch.shadowing(), backColor, borderColor, swimlane,
+ tbTest);
+ diamond = diamond.withNorth(tb1);
+ diamonds.add(diamond);
+ }
+
+ final TextBlock tb2 = TextBlockUtils.create(branch2.getLabelPositive(), fc, HorizontalAlignment.LEFT,
+ ftileFactory);
+ final int last = diamonds.size() - 1;
+ diamonds.set(last, ((FtileDiamondInside) diamonds.get(last)).withEast(tb2));
+
+ final FtileIfLong result = new FtileIfLong(diamonds, tiles, tile2, arrowColor);
+
+ for (int i = 0; i < thens.size(); i++) {
+ final Ftile ftile = tiles.get(i);
+ final Ftile diam = diamonds.get(i);
+
+ final HtmlColor color = thens.get(i).getInlinkRenderingColor();
+ conns.add(result.new ConnectionVerticalIn(diam, ftile, color == null ? arrowColor : color));
+ conns.add(result.new ConnectionVerticalOut(ftile, arrowColor));
+ }
+
+ for (int i = 0; i < diamonds.size() - 1; i++) {
+ final Ftile diam1 = diamonds.get(i);
+ final Ftile diam2 = diamonds.get(i + 1);
+ conns.add(result.new ConnectionHorizontal(diam1, diam2, arrowColor));
+ }
+ conns.add(result.new ConnectionIn(arrowColor));
+ conns.add(result.new ConnectionLastElseIn(arrowColor));
+ conns.add(result.new ConnectionLastElseOut(arrowColor));
+ conns.add(result.new ConnectionHline(arrowColor));
+
+ return FtileUtils.addConnection(result, conns);
+ }
+
+ class ConnectionHorizontal extends AbstractConnection {
+
+ private final HtmlColor color;
+
+ public ConnectionHorizontal(Ftile diam1, Ftile diam2, HtmlColor color) {
+ super(diam1, diam2);
+ this.color = color;
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Point2D p1 = getP1(stringBounder);
+ final Point2D p2 = getP2(stringBounder);
+
+ final Snake snake = new Snake(color, Arrows.asToRight());
+ snake.addPoint(p1);
+ snake.addPoint(p2);
+ ug.draw(snake);
+ }
+
+ private Point2D getP1(StringBounder stringBounder) {
+ final FtileGeometry dimDiamond1 = getFtile1().calculateDimension(stringBounder);
+ final Point2D p = new Point2D.Double(dimDiamond1.getWidth(), dimDiamond1.getOutY() / 2);
+
+ return getTranslateDiamond1(getFtile1(), stringBounder).getTranslated(p);
+ }
+
+ private Point2D getP2(StringBounder stringBounder) {
+ final FtileGeometry dimDiamond1 = getFtile2().calculateDimension(stringBounder);
+ final Point2D p = new Point2D.Double(0, dimDiamond1.getOutY() / 2);
+ return getTranslateDiamond1(getFtile2(), stringBounder).getTranslated(p);
+ }
+
+ }
+
+ class ConnectionIn extends AbstractConnection {
+
+ private final HtmlColor arrowColor;
+
+ public ConnectionIn(HtmlColor arrowColor) {
+ super(null, diamonds.get(0));
+ this.arrowColor = arrowColor;
+ }
+
+ public void drawU(UGraphic ug) {
+ final UTranslate tr = getTranslateDiamond1(getFtile2(), ug.getStringBounder());
+ final Point2D p2 = tr.getTranslated(getFtile2().calculateDimension(ug.getStringBounder()).getPointIn());
+ final Snake snake = new Snake(arrowColor, Arrows.asToDown());
+ final Point2D p1 = calculateDimension(ug.getStringBounder()).getPointIn();
+
+ snake.addPoint(p1);
+ snake.addPoint(p2.getX(), p1.getY());
+ snake.addPoint(p2);
+ ug.draw(snake);
+ }
+
+ }
+
+ class ConnectionLastElseIn extends AbstractConnection {
+
+ private final HtmlColor arrowColor;
+
+ public ConnectionLastElseIn(HtmlColor arrowColor) {
+ super(diamonds.get(diamonds.size() - 1), tile2);
+ this.arrowColor = arrowColor;
+ }
+
+ public void drawU(UGraphic ug) {
+ final Point2D p1 = getP1(ug.getStringBounder());
+ final UTranslate tr2 = getTranslate2(ug.getStringBounder());
+ final Point2D p2 = tr2.getTranslated(getFtile2().calculateDimension(ug.getStringBounder()).getPointIn());
+ final Snake snake = new Snake(arrowColor, Arrows.asToDown());
+ snake.addPoint(p1);
+ snake.addPoint(p2.getX(), p1.getY());
+ snake.addPoint(p2);
+ ug.draw(snake);
+ }
+
+ private Point2D getP1(StringBounder stringBounder) {
+ final FtileGeometry dimDiamond1 = getFtile1().calculateDimension(stringBounder);
+ final Point2D p = new Point2D.Double(dimDiamond1.getWidth(), dimDiamond1.getOutY() / 2);
+ return getTranslateDiamond1(getFtile1(), stringBounder).getTranslated(p);
+ }
+
+ }
+
+ class ConnectionLastElseOut extends AbstractConnection {
+
+ private final HtmlColor arrowColor;
+
+ public ConnectionLastElseOut(HtmlColor arrowColor) {
+ super(tile2, null);
+ this.arrowColor = arrowColor;
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final UTranslate tr1 = getTranslate2(stringBounder);
+ final FtileGeometry dim = getFtile1().calculateDimension(stringBounder);
+ if (dim.hasPointOut() == false) {
+ return;
+ }
+ final Point2D p1 = tr1.getTranslated(dim.getPointOut());
+ final double totalHeight = calculateDimensionInternal(stringBounder).getHeight();
+ final Point2D p2 = new Point2D.Double(p1.getX(), totalHeight);
+
+ final Snake snake = new Snake(arrowColor, Arrows.asToDown());
+ snake.addPoint(p1);
+ snake.addPoint(p2);
+ ug.draw(snake);
+ }
+
+ }
+
+ class ConnectionVerticalIn extends AbstractConnection {
+
+ private final HtmlColor color;
+
+ public ConnectionVerticalIn(Ftile diamond, Ftile tile, HtmlColor color) {
+ super(diamond, tile);
+ this.color = color;
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Point2D p1 = getP1(stringBounder);
+ final Point2D p2 = getP2(stringBounder);
+
+ final Snake snake = new Snake(color, Arrows.asToDown());
+ snake.addPoint(p1);
+ snake.addPoint(p2);
+ ug.draw(snake);
+ }
+
+ private Point2D getP1(StringBounder stringBounder) {
+ final Point2D p = getFtile1().calculateDimension(stringBounder).getPointOut();
+ return getTranslateDiamond1(getFtile1(), stringBounder).getTranslated(p);
+ }
+
+ private Point2D getP2(StringBounder stringBounder) {
+ final Point2D p = getFtile2().calculateDimension(stringBounder).getPointIn();
+ return getTranslate1(getFtile2(), stringBounder).getTranslated(p);
+ }
+
+ }
+
+ class ConnectionVerticalOut extends AbstractConnection {
+
+ private final HtmlColor color;
+
+ public ConnectionVerticalOut(Ftile tile, HtmlColor color) {
+ super(tile, null);
+ this.color = color;
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final double totalHeight = calculateDimensionInternal(stringBounder).getHeight();
+ final Point2D p1 = getP1(stringBounder);
+ if (p1 == null) {
+ return;
+ }
+ final Point2D p2 = new Point2D.Double(p1.getX(), totalHeight);
+
+ final Snake snake = new Snake(color, Arrows.asToDown());
+ snake.addPoint(p1);
+ snake.addPoint(p2);
+ ug.draw(snake);
+ }
+
+ private Point2D getP1(StringBounder stringBounder) {
+ final FtileGeometry geo = getFtile1().calculateDimension(stringBounder);
+ if (geo.hasPointOut() == false) {
+ return null;
+ }
+ final Point2D p = geo.getPointOut();
+ return getTranslate1(getFtile1(), stringBounder).getTranslated(p);
+ }
+
+ }
+
+ class ConnectionHline extends AbstractConnection {
+
+ private final HtmlColor arrowColor;
+
+ public ConnectionHline(HtmlColor arrowColor) {
+ super(null, null);
+ this.arrowColor = arrowColor;
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D totalDim = calculateDimensionInternal(stringBounder);
+
+ final List<Ftile> all = new ArrayList<Ftile>(tiles);
+ all.add(tile2);
+ double minX = totalDim.getWidth() / 2;
+ double maxX = totalDim.getWidth() / 2;
+ for (Ftile tmp : all) {
+ if (tmp.calculateDimension(stringBounder).hasPointOut() == false) {
+ continue;
+ }
+ final UTranslate ut = getTranslateFor(tmp, stringBounder);
+ final double out = tmp.calculateDimension(stringBounder).translate(ut).getLeft();
+ minX = Math.min(minX, out);
+ maxX = Math.max(maxX, out);
+ }
+
+ final Snake s = new Snake(arrowColor);
+ s.goUnmergeable();
+ final double height = totalDim.getHeight();
+ s.addPoint(minX, height);
+ s.addPoint(maxX, height);
+ ug.draw(s);
+ }
+ }
+
+ @Override
+ public UTranslate getTranslateFor(Ftile child, StringBounder stringBounder) {
+ if (child == tile2) {
+ return getTranslate2(stringBounder);
+ }
+ if (tiles.contains(child)) {
+ return getTranslate1(child, stringBounder);
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ private UTranslate getTranslate2(StringBounder stringBounder) {
+ final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
+ final Dimension2D dim2 = tile2.calculateDimension(stringBounder);
+
+ final double x2 = dimTotal.getWidth() - dim2.getWidth();
+
+ final double h = getAllDiamondsHeight(stringBounder);
+ final double y2 = (dimTotal.getHeight() - h * 2 - dim2.getHeight()) / 2 + h;
+
+ return new UTranslate(x2, y2);
+
+ }
+
+ private UTranslate getTranslateDiamond1(Ftile diamond1, StringBounder stringBounder) {
+ double x1 = 0;
+
+ for (Ftile diamond : diamonds) {
+ final FtileGeometry dim1 = dimDiamondAndTile(stringBounder, diamond);
+ if (diamond == diamond1) {
+ final FtileGeometry dimDiamond = diamond.calculateDimension(stringBounder);
+ double xresult = x1 + dim1.getLeft() - dimDiamond.getLeft();
+ return new UTranslate(xresult, 25);
+ }
+ x1 += dim1.getWidth() + xSeparation;
+ }
+ throw new IllegalArgumentException();
+
+ }
+
+ private UTranslate getTranslate1(Ftile tile1, StringBounder stringBounder) {
+ final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
+ double x1 = 0;
+
+ for (Ftile tile : tiles) {
+ final Dimension2D dim1 = dimDiamondAndTile(stringBounder, tile);
+ if (tile == tile1) {
+ final Dimension2D dimTile = tile.calculateDimension(stringBounder);
+ final double h = getAllDiamondsHeight(stringBounder);
+ final double y1 = (dimTotal.getHeight() - 2 * h - dimTile.getHeight()) / 2 + h;
+ return new UTranslate(x1 + (dim1.getWidth() - dimTile.getWidth()) / 2, y1);
+ }
+ x1 += dim1.getWidth() + xSeparation;
+ }
+ throw new IllegalArgumentException();
+
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ for (Ftile tile : tiles) {
+ ug.apply(getTranslate1(tile, stringBounder)).draw(tile);
+ }
+ for (Ftile diamond : diamonds) {
+ ug.apply(getTranslateDiamond1(diamond, stringBounder)).draw(diamond);
+ }
+
+ ug.apply(getTranslate2(stringBounder)).draw(tile2);
+ }
+
+ public FtileGeometry calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
+
+ final List<Ftile> all = new ArrayList<Ftile>(tiles);
+ all.add(tile2);
+ for (Ftile tmp : all) {
+ if (tmp.calculateDimension(stringBounder).hasPointOut()) {
+ return new FtileGeometry(dimTotal, dimTotal.getWidth() / 2, 0, dimTotal.getHeight());
+ }
+ }
+ return new FtileGeometry(dimTotal, dimTotal.getWidth() / 2, 0);
+
+ }
+
+ private FtileGeometry dimDiamondAndTile(StringBounder stringBounder, Ftile tileOrDiamond) {
+ for (int i = 0; i < tiles.size(); i++) {
+ final Ftile tile = tiles.get(i);
+ final Ftile diamond = diamonds.get(i);
+ if (tile != tileOrDiamond && diamond != tileOrDiamond) {
+ continue;
+ }
+ final FtileGeometry dimTile = tile.calculateDimension(stringBounder);
+ final FtileGeometry dimDiamond = diamond.calculateDimension(stringBounder);
+ return dimDiamond.appendBottom(dimTile);
+ }
+ throw new UnsupportedOperationException();
+
+ }
+
+ private Dimension2D calculateDimensionInternal(StringBounder stringBounder) {
+ Dimension2D dimOnlyTiles = new Dimension2DDouble(0, 0);
+ Dimension2D dimOnlyDiamond = new Dimension2DDouble(0, 0);
+ Dimension2D dimBoth = new Dimension2DDouble(0, 0);
+ for (int i = 0; i < tiles.size(); i++) {
+ final Ftile tile = tiles.get(i);
+ final Ftile diamond = diamonds.get(i);
+ final FtileGeometry dimTile = tile.calculateDimension(stringBounder);
+ final FtileGeometry dimDiamond = diamond.calculateDimension(stringBounder);
+ final FtileGeometry both = dimDiamond.appendBottom(dimTile);
+ dimOnlyTiles = Dimension2DDouble.mergeLR(dimOnlyTiles, dimTile);
+ dimOnlyDiamond = Dimension2DDouble.mergeLR(dimOnlyDiamond, dimDiamond);
+ dimBoth = Dimension2DDouble.mergeLR(dimBoth, both);
+ }
+ final FtileGeometry dimTile2 = tile2.calculateDimension(stringBounder);
+ dimOnlyTiles = Dimension2DDouble.mergeLR(dimOnlyTiles, dimTile2);
+ dimBoth = Dimension2DDouble.mergeLR(dimBoth, dimTile2);
+
+ final Dimension2D result = new Dimension2DDouble(dimBoth.getWidth(), dimOnlyDiamond.getHeight() * 4
+ + dimOnlyTiles.getHeight());
+ return Dimension2DDouble.delta(result, xSeparation * tiles.size(), 40);
+ }
+
+ private double getAllDiamondsHeight(StringBounder stringBounder) {
+ Dimension2D dimOnlyDiamond = new Dimension2DDouble(0, 0);
+ for (Ftile diamond : diamonds) {
+ final Dimension2D dimDiamond = diamond.calculateDimension(stringBounder);
+ dimOnlyDiamond = Dimension2DDouble.mergeLR(dimOnlyDiamond, dimDiamond);
+ }
+ return dimOnlyDiamond.getHeight();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLong2.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLong2.java
new file mode 100644
index 0000000..1aaecbc
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileIfLong2.java
@@ -0,0 +1,511 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.activitydiagram3.Branch;
+import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractConnection;
+import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Connection;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileAssemblySimple;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileMinWidth;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Snake;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamondInside2;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.svek.ConditionStyle;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class FtileIfLong2 extends AbstractFtile {
+
+ private final double xSeparation = 20;
+
+ private final List<Ftile> tiles;
+ private final Ftile tile2;
+ private final List<Ftile> diamonds;
+ private final List<Ftile> couples = new ArrayList<Ftile>();
+
+ private final HtmlColor arrowColor;
+
+ private FtileIfLong2(List<Ftile> diamonds, List<Ftile> tiles, Ftile tile2, HtmlColor arrowColor) {
+ super(tiles.get(0).shadowing() || tile2.shadowing());
+ if (diamonds.size() != tiles.size()) {
+ throw new IllegalArgumentException();
+ }
+ for (int i = 0; i < diamonds.size(); i++) {
+ couples.add(new FtileAssemblySimple(diamonds.get(i), tiles.get(i)));
+ }
+ this.tile2 = tile2;
+ this.diamonds = new ArrayList<Ftile>(diamonds);
+ this.tiles = new ArrayList<Ftile>(tiles);
+
+ this.arrowColor = arrowColor;
+
+ }
+
+ private static List<Ftile> alignDiamonds(List<Ftile> diamonds, StringBounder stringBounder) {
+ double maxOutY = 0;
+ for (Ftile diamond : diamonds) {
+ maxOutY = Math.max(maxOutY, diamond.calculateDimension(stringBounder).getOutY());
+ }
+ final List<Ftile> result = new ArrayList<Ftile>();
+ for (int i = 0; i < diamonds.size(); i++) {
+ Ftile diamond = diamonds.get(i);
+ final double missing = maxOutY - diamond.calculateDimension(stringBounder).getOutY();
+ assert missing >= 0;
+ diamond = FtileUtils.addVerticalMargin(diamond, missing / 2, 20);
+ result.add(diamond);
+ }
+ return result;
+ }
+
+ public Set<Swimlane> getSwimlanes() {
+ final Set<Swimlane> result = new HashSet<Swimlane>();
+ if (getSwimlaneIn() != null) {
+ result.add(getSwimlaneIn());
+ }
+ for (Ftile tile : couples) {
+ result.addAll(tile.getSwimlanes());
+ }
+ result.addAll(tile2.getSwimlanes());
+ return Collections.unmodifiableSet(result);
+ }
+
+ public Swimlane getSwimlaneIn() {
+ return couples.get(0).getSwimlaneIn();
+ }
+
+ public Swimlane getSwimlaneOut() {
+ return getSwimlaneIn();
+ }
+
+ static Ftile create(Swimlane swimlane, HtmlColor borderColor, HtmlColor backColor, UFont font,
+ HtmlColor arrowColor, FtileFactory ftileFactory, ConditionStyle conditionStyle, List<Branch> thens,
+ Branch branch2, HtmlColor hyperlinkColor, boolean useUnderlineForHyperlink) {
+
+ final List<Ftile> tiles = new ArrayList<Ftile>();
+
+ for (Branch branch : thens) {
+ tiles.add(new FtileMinWidth(branch.getFtile(), 30));
+ }
+
+ final Ftile tile2 = new FtileMinWidth(branch2.getFtile(), 30);
+
+ final FontConfiguration fc = new FontConfiguration(font, HtmlColorUtils.BLACK, hyperlinkColor,
+ useUnderlineForHyperlink);
+
+ List<Ftile> diamonds = new ArrayList<Ftile>();
+ final List<Connection> conns = new ArrayList<Connection>();
+ for (Branch branch : thens) {
+ final TextBlock tb1 = TextBlockUtils.create(branch.getLabelPositive(), fc, HorizontalAlignment.LEFT,
+ ftileFactory);
+ final TextBlock tbTest = TextBlockUtils.create(branch.getLabelTest(), fc, HorizontalAlignment.LEFT,
+ ftileFactory);
+ FtileDiamondInside2 diamond = new FtileDiamondInside2(branch.shadowing(), backColor, borderColor, swimlane,
+ tbTest);
+ diamond = diamond.withNorth(tb1);
+ diamonds.add(diamond);
+ }
+
+ final TextBlock tb2 = TextBlockUtils.create(branch2.getLabelPositive(), fc, HorizontalAlignment.LEFT,
+ ftileFactory);
+ final int last = diamonds.size() - 1;
+ diamonds.set(last, ((FtileDiamondInside2) diamonds.get(last)).withEast(tb2));
+
+ diamonds = alignDiamonds(diamonds, ftileFactory.getStringBounder());
+
+ final FtileIfLong2 result = new FtileIfLong2(diamonds, tiles, tile2, arrowColor);
+
+ for (int i = 0; i < thens.size(); i++) {
+ final Ftile ftile = tiles.get(i);
+ final Ftile diam = diamonds.get(i);
+
+ final HtmlColor color = thens.get(i).getInlinkRenderingColor();
+ conns.add(result.new ConnectionVerticalIn(diam, ftile, color == null ? arrowColor : color));
+ conns.add(result.new ConnectionVerticalOut(ftile, arrowColor));
+ }
+
+ for (int i = 0; i < diamonds.size() - 1; i++) {
+ final Ftile diam1 = diamonds.get(i);
+ final Ftile diam2 = diamonds.get(i + 1);
+ conns.add(result.new ConnectionHorizontal(diam1, diam2, arrowColor));
+ }
+ conns.add(result.new ConnectionIn(arrowColor));
+ conns.add(result.new ConnectionLastElseIn(arrowColor));
+ conns.add(result.new ConnectionLastElseOut(arrowColor));
+ conns.add(result.new ConnectionHline(arrowColor));
+
+ return FtileUtils.addConnection(result, conns);
+ }
+
+ class ConnectionHorizontal extends AbstractConnection {
+
+ private final HtmlColor color;
+
+ public ConnectionHorizontal(Ftile diam1, Ftile diam2, HtmlColor color) {
+ super(diam1, diam2);
+ this.color = color;
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Point2D p1 = getP1(stringBounder);
+ final Point2D p2 = getP2(stringBounder);
+
+ final Snake snake = new Snake(color, Arrows.asToRight());
+ snake.addPoint(p1);
+ snake.addPoint(p2);
+ ug.draw(snake);
+ }
+
+ private Point2D getP1(StringBounder stringBounder) {
+ final FtileGeometry dimDiamond1 = getFtile1().calculateDimension(stringBounder);
+ final Point2D p = new Point2D.Double(dimDiamond1.getLeft() * 2, getYdiamontOutToLeft(dimDiamond1,
+ stringBounder));
+
+ return getTranslateDiamond1(getFtile1(), stringBounder).getTranslated(p);
+ }
+
+ private Point2D getP2(StringBounder stringBounder) {
+ final FtileGeometry dimDiamond1 = getFtile2().calculateDimension(stringBounder);
+ final Point2D p = new Point2D.Double(0, getYdiamontOutToLeft(dimDiamond1, stringBounder));
+ return getTranslateDiamond1(getFtile2(), stringBounder).getTranslated(p);
+ }
+
+ }
+
+ static private double getYdiamontOutToLeft(FtileGeometry dimDiamond1, StringBounder stringBounder) {
+ return (dimDiamond1.getInY() + dimDiamond1.getOutY()) / 2;
+ }
+
+ class ConnectionIn extends AbstractConnection {
+
+ private final HtmlColor arrowColor;
+
+ public ConnectionIn(HtmlColor arrowColor) {
+ super(null, diamonds.get(0));
+ this.arrowColor = arrowColor;
+ }
+
+ public void drawU(UGraphic ug) {
+ final UTranslate tr = getTranslateDiamond1(getFtile2(), ug.getStringBounder());
+ final Point2D p2 = tr.getTranslated(getFtile2().calculateDimension(ug.getStringBounder()).getPointIn());
+ final Snake snake = new Snake(arrowColor, Arrows.asToDown());
+ final Point2D p1 = calculateDimensionInternal(ug.getStringBounder()).getPointIn();
+
+ snake.addPoint(p1);
+ snake.addPoint(p2.getX(), p1.getY());
+ snake.addPoint(p2);
+ ug.draw(snake);
+ }
+
+ }
+
+ class ConnectionLastElseIn extends AbstractConnection {
+
+ private final HtmlColor arrowColor;
+
+ public ConnectionLastElseIn(HtmlColor arrowColor) {
+ super(diamonds.get(diamonds.size() - 1), tile2);
+ this.arrowColor = arrowColor;
+ }
+
+ public void drawU(UGraphic ug) {
+ final Point2D p1 = getP1(ug.getStringBounder());
+ final UTranslate tr2 = getTranslate2(ug.getStringBounder());
+ final Point2D p2 = tr2.getTranslated(getFtile2().calculateDimension(ug.getStringBounder()).getPointIn());
+ final Snake snake = new Snake(arrowColor, Arrows.asToDown());
+ snake.addPoint(p1);
+ snake.addPoint(p2.getX(), p1.getY());
+ snake.addPoint(p2);
+ ug.draw(snake);
+ }
+
+ private Point2D getP1(StringBounder stringBounder) {
+ final FtileGeometry dimDiamond1 = getFtile1().calculateDimension(stringBounder);
+ final Point2D p = new Point2D.Double(dimDiamond1.getLeft() * 2, getYdiamontOutToLeft(dimDiamond1,
+ stringBounder));
+ return getTranslateDiamond1(getFtile1(), stringBounder).getTranslated(p);
+ }
+
+ }
+
+ class ConnectionLastElseOut extends AbstractConnection {
+
+ private final HtmlColor arrowColor;
+
+ public ConnectionLastElseOut(HtmlColor arrowColor) {
+ super(tile2, null);
+ this.arrowColor = arrowColor;
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final UTranslate tr1 = getTranslate2(stringBounder);
+ final FtileGeometry dim = getFtile1().calculateDimension(stringBounder);
+ if (dim.hasPointOut() == false) {
+ return;
+ }
+ final Point2D p1 = tr1.getTranslated(dim.getPointOut());
+ final double totalHeight = calculateDimensionInternal(stringBounder).getHeight();
+ final Point2D p2 = new Point2D.Double(p1.getX(), totalHeight);
+
+ final Snake snake = new Snake(arrowColor, Arrows.asToDown());
+ snake.addPoint(p1);
+ snake.addPoint(p2);
+ ug.draw(snake);
+ }
+
+ }
+
+ class ConnectionVerticalIn extends AbstractConnection {
+
+ private final HtmlColor color;
+
+ public ConnectionVerticalIn(Ftile diamond, Ftile tile, HtmlColor color) {
+ super(diamond, tile);
+ this.color = color;
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Point2D p1 = getP1(stringBounder);
+ final Point2D p2 = getP2(stringBounder);
+
+ final Snake snake = new Snake(color, Arrows.asToDown());
+ snake.addPoint(p1);
+ snake.addPoint(p2);
+ ug.draw(snake);
+ }
+
+ private Point2D getP1(StringBounder stringBounder) {
+ final Point2D p = getFtile1().calculateDimension(stringBounder).getPointOut();
+ return getTranslateDiamond1(getFtile1(), stringBounder).getTranslated(p);
+ }
+
+ private Point2D getP2(StringBounder stringBounder) {
+ final Point2D p = getFtile2().calculateDimension(stringBounder).getPointIn();
+ return getTranslate1(getFtile2(), stringBounder).getTranslated(p);
+ }
+
+ }
+
+ class ConnectionVerticalOut extends AbstractConnection {
+
+ private final HtmlColor color;
+
+ public ConnectionVerticalOut(Ftile tile, HtmlColor color) {
+ super(tile, null);
+ this.color = color;
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final double totalHeight = calculateDimensionInternal(stringBounder).getHeight();
+ final Point2D p1 = getP1(stringBounder);
+ if (p1 == null) {
+ return;
+ }
+ final Point2D p2 = new Point2D.Double(p1.getX(), totalHeight);
+
+ final Snake snake = new Snake(color, Arrows.asToDown());
+ snake.addPoint(p1);
+ snake.addPoint(p2);
+ ug.draw(snake);
+ }
+
+ private Point2D getP1(StringBounder stringBounder) {
+ final FtileGeometry geo = getFtile1().calculateDimension(stringBounder);
+ if (geo.hasPointOut() == false) {
+ return null;
+ }
+ final Point2D p = geo.getPointOut();
+ return getTranslate1(getFtile1(), stringBounder).getTranslated(p);
+ }
+
+ }
+
+ class ConnectionHline extends AbstractConnection {
+
+ private final HtmlColor arrowColor;
+
+ public ConnectionHline(HtmlColor arrowColor) {
+ super(null, null);
+ this.arrowColor = arrowColor;
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D totalDim = calculateDimensionInternal(stringBounder);
+
+ final List<Ftile> all = new ArrayList<Ftile>(couples);
+ all.add(tile2);
+ double minX = totalDim.getWidth() / 2;
+ double maxX = totalDim.getWidth() / 2;
+ for (Ftile tmp : all) {
+ if (tmp.calculateDimension(stringBounder).hasPointOut() == false) {
+ continue;
+ }
+ final UTranslate ut = getTranslateFor(tmp, stringBounder);
+ final double out = tmp.calculateDimension(stringBounder).translate(ut).getLeft();
+ minX = Math.min(minX, out);
+ maxX = Math.max(maxX, out);
+ }
+
+ final Snake s = new Snake(arrowColor);
+ s.goUnmergeable();
+ final double height = totalDim.getHeight();
+ s.addPoint(minX, height);
+ s.addPoint(maxX, height);
+ ug.draw(s);
+ }
+ }
+
+ @Override
+ public UTranslate getTranslateFor(Ftile child, StringBounder stringBounder) {
+ if (child == tile2) {
+ return getTranslate2(stringBounder);
+ }
+ if (couples.contains(child)) {
+ return getTranslateCouple1(child, stringBounder);
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ private UTranslate getTranslate2(StringBounder stringBounder) {
+ final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
+ final Dimension2D dim2 = tile2.calculateDimension(stringBounder);
+
+ final double x2 = dimTotal.getWidth() - dim2.getWidth();
+
+ final double h = 0; // getAllDiamondsHeight(stringBounder);
+ final double y2 = (dimTotal.getHeight() - h * 2 - dim2.getHeight()) / 2 + h;
+
+ return new UTranslate(x2, y2);
+
+ }
+
+ private UTranslate getTranslateDiamond1(Ftile diamond, StringBounder stringBounder) {
+ final int idx = diamonds.indexOf(diamond);
+ if (idx == -1) {
+ throw new IllegalArgumentException();
+ }
+ final UTranslate trCouple = getTranslateCouple1(couples.get(idx), stringBounder);
+ final UTranslate in = couples.get(idx).getTranslateFor(diamond, stringBounder);
+ return trCouple.compose(in);
+ }
+
+ public UTranslate getTranslate1(Ftile tile, StringBounder stringBounder) {
+ final int idx = tiles.indexOf(tile);
+ if (idx == -1) {
+ throw new IllegalArgumentException();
+ }
+ final UTranslate trCouple = getTranslateCouple1(couples.get(idx), stringBounder);
+ final UTranslate in = couples.get(idx).getTranslateFor(tile, stringBounder);
+ return trCouple.compose(in);
+ }
+
+ private UTranslate getTranslateCouple1(Ftile candidat, StringBounder stringBounder) {
+ double x1 = 0;
+
+ for (Ftile couple : couples) {
+ final FtileGeometry dim1 = couple.calculateDimension(stringBounder);
+ if (couple == candidat) {
+ return new UTranslate(x1, 25);
+ }
+ x1 += dim1.getWidth() + xSeparation;
+ }
+ throw new IllegalArgumentException();
+
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ for (Ftile couple : couples) {
+ ug.apply(getTranslateCouple1(couple, stringBounder)).draw(couple);
+ }
+
+ ug.apply(getTranslate2(stringBounder)).draw(tile2);
+ }
+
+ private FtileGeometry calculateDimensionInternal(StringBounder stringBounder) {
+ Dimension2D result = new Dimension2DDouble(0, 0);
+ for (Ftile couple : couples) {
+ result = Dimension2DDouble.mergeLR(result, couple.calculateDimension(stringBounder));
+ }
+ final FtileGeometry dimTile2 = tile2.calculateDimension(stringBounder);
+ result = Dimension2DDouble.mergeLR(result, dimTile2);
+ result = Dimension2DDouble.delta(result, xSeparation * couples.size(), 100);
+
+ return new FtileGeometry(result, result.getWidth() / 2, 0);
+ }
+
+ public FtileGeometry calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
+
+ final List<Ftile> all = new ArrayList<Ftile>(tiles);
+ all.add(tile2);
+ for (Ftile tmp : all) {
+ if (tmp.calculateDimension(stringBounder).hasPointOut()) {
+ return new FtileGeometry(dimTotal, dimTotal.getWidth() / 2, 0, dimTotal.getHeight());
+ }
+ }
+ return new FtileGeometry(dimTotal, dimTotal.getWidth() / 2, 0);
+
+ }
+
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileRepeat.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileRepeat.java
new file mode 100644
index 0000000..c98280f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileRepeat.java
@@ -0,0 +1,369 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.Direction;
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.activitydiagram3.LinkRendering;
+import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractConnection;
+import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Connection;
+import net.sourceforge.plantuml.activitydiagram3.ftile.ConnectionTranslatable;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Diamond;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Snake;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamond;
+import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamondFoo1;
+import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamondInside;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.svek.ConditionStyle;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class FtileRepeat extends AbstractFtile {
+
+ private final Ftile repeat;
+ private final Ftile diamond1;
+ private final Ftile diamond2;
+ private final TextBlock tbTest;
+
+ private FtileRepeat(Ftile repeat, Ftile diamond1, Ftile diamond2, TextBlock tbTest) {
+ super(repeat.shadowing());
+ this.repeat = repeat;
+ this.diamond1 = diamond1;
+ this.diamond2 = diamond2;
+ this.tbTest = tbTest;
+ }
+
+ public Swimlane getSwimlaneIn() {
+ return repeat.getSwimlaneIn();
+ }
+
+ public Swimlane getSwimlaneOut() {
+ return getSwimlaneIn();
+ }
+
+ public Set<Swimlane> getSwimlanes() {
+ return repeat.getSwimlanes();
+ }
+
+ public static Ftile create(LinkRendering backRepeatLinkRendering, Swimlane swimlane, Ftile repeat, Display test,
+ Display yes, Display out, HtmlColor borderColor, HtmlColor backColor, UFont fontTest, HtmlColor arrowColor,
+ HtmlColor endRepeatLinkColor, ConditionStyle conditionStyle, ISkinSimple spriteContainer,
+ HtmlColor hyperlinkColor, boolean useUnderlineForHyperlink) {
+
+ final FontConfiguration fc = new FontConfiguration(fontTest, HtmlColorUtils.BLACK, hyperlinkColor,
+ useUnderlineForHyperlink);
+ final TextBlock tbTest = TextBlockUtils.create(test, fc, HorizontalAlignment.LEFT, spriteContainer);
+ final TextBlock yesTb = TextBlockUtils.create(yes, fc, HorizontalAlignment.LEFT, spriteContainer);
+ final TextBlock outTb = TextBlockUtils.create(out, fc, HorizontalAlignment.LEFT, spriteContainer);
+
+ final Ftile diamond1 = new FtileDiamond(repeat.shadowing(), backColor, borderColor, swimlane);
+ final FtileRepeat result;
+ if (conditionStyle == ConditionStyle.INSIDE) {
+ final Ftile diamond2 = new FtileDiamondInside(repeat.shadowing(), backColor, borderColor, swimlane, tbTest)
+ .withEast(yesTb).withSouth(outTb);
+ result = new FtileRepeat(repeat, diamond1, diamond2, TextBlockUtils.empty(0, 0));
+ } else if (conditionStyle == ConditionStyle.DIAMOND) {
+ final Ftile diamond2 = new FtileDiamond(repeat.shadowing(), backColor, borderColor, swimlane)
+ .withEast(tbTest);
+ result = new FtileRepeat(repeat, diamond1, diamond2, tbTest);
+ } else if (conditionStyle == ConditionStyle.FOO1) {
+ final Ftile diamond2 = new FtileDiamondFoo1(repeat.shadowing(), backColor, borderColor, swimlane, tbTest);
+ result = new FtileRepeat(repeat, diamond1, diamond2, TextBlockUtils.empty(0, 0));
+ } else {
+ throw new IllegalStateException();
+ }
+
+ final List<Connection> conns = new ArrayList<Connection>();
+ final Display in1 = LinkRendering.getDisplay(repeat.getInLinkRendering());
+ final TextBlock tbin1 = in1 == null ? null : TextBlockUtils.create(in1, fc, HorizontalAlignment.LEFT,
+ spriteContainer, true);
+ conns.add(result.new ConnectionIn(LinkRendering.getColor(repeat.getInLinkRendering(), arrowColor), tbin1));
+
+ final Display backLink1 = LinkRendering.getDisplay(backRepeatLinkRendering);
+ final TextBlock tbbackLink1 = backLink1 == null ? null : TextBlockUtils.create(backLink1, fc,
+ HorizontalAlignment.LEFT, spriteContainer, true);
+ conns.add(result.new ConnectionBack(LinkRendering.getColor(backRepeatLinkRendering, arrowColor), tbbackLink1));
+
+ final Display out1 = LinkRendering.getDisplay(repeat.getOutLinkRendering());
+ final TextBlock tbout1 = out1 == null ? null : TextBlockUtils.create(out1, fc, HorizontalAlignment.LEFT,
+ spriteContainer, true);
+ conns.add(result.new ConnectionOut(LinkRendering.getColor(endRepeatLinkColor, arrowColor), tbout1));
+ return FtileUtils.addConnection(result, conns);
+ }
+
+ class ConnectionIn extends AbstractConnection {
+ private final HtmlColor arrowColor;
+ private final TextBlock tbin;
+
+ public ConnectionIn(HtmlColor arrowColor, TextBlock tbin) {
+ super(diamond1, repeat);
+ this.arrowColor = arrowColor;
+ this.tbin = tbin;
+ }
+
+ private Point2D getP1(final StringBounder stringBounder) {
+ return getFtile1().calculateDimension(stringBounder).translate(getTranslateDiamond1(stringBounder))
+ .getPointOut();
+ }
+
+ private Point2D getP2(final StringBounder stringBounder) {
+ return getFtile2().calculateDimension(stringBounder).translate(getTranslateForRepeat(stringBounder))
+ .getPointIn();
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+
+ final Snake snake = new Snake(arrowColor, Arrows.asToDown());
+ snake.setLabel(tbin);
+ snake.addPoint(getP1(stringBounder));
+ snake.addPoint(getP2(stringBounder));
+
+ ug.draw(snake);
+ }
+ }
+
+ class ConnectionOut extends AbstractConnection implements ConnectionTranslatable {
+ private final HtmlColor arrowColor;
+ private final TextBlock tbout;
+
+ public ConnectionOut(HtmlColor arrowColor, TextBlock tbout) {
+ super(repeat, diamond2);
+ this.arrowColor = arrowColor;
+ this.tbout = tbout;
+ }
+
+ private Point2D getP1(final StringBounder stringBounder) {
+ return getTranslateForRepeat(stringBounder).getTranslated(
+ getFtile1().calculateDimension(stringBounder).getPointOut());
+ }
+
+ private Point2D getP2(final StringBounder stringBounder) {
+ return getTranslateDiamond2(stringBounder).getTranslated(
+ getFtile2().calculateDimension(stringBounder).getPointIn());
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+
+ final Snake snake = new Snake(arrowColor, Arrows.asToDown());
+ snake.setLabel(tbout);
+ snake.addPoint(getP1(stringBounder));
+ snake.addPoint(getP2(stringBounder));
+
+ ug.draw(snake);
+ }
+
+ public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Snake snake = new Snake(arrowColor);
+ snake.setLabel(tbout);
+ final Point2D mp1a = translate1.getTranslated(getP1(stringBounder));
+ final Point2D mp2b = translate2.getTranslated(getP2(stringBounder));
+ final double middle = (mp1a.getY() + mp2b.getY()) / 2.0;
+ snake.addPoint(mp1a);
+ snake.addPoint(mp1a.getX(), middle);
+ snake.addPoint(mp2b.getX(), middle);
+ // snake.addPoint(mp2b);
+ ug.draw(snake);
+
+ final Snake small = new Snake(arrowColor, Arrows.asToDown());
+ small.addPoint(mp2b.getX(), middle);
+ small.addPoint(mp2b);
+ ug.draw(small);
+
+ }
+
+ }
+
+ class ConnectionBack extends AbstractConnection {
+ private final HtmlColor arrowColor;
+ private final TextBlock tbback;
+
+ public ConnectionBack(HtmlColor arrowColor, TextBlock tbback) {
+ super(diamond2, repeat);
+ this.arrowColor = arrowColor;
+ this.tbback = tbback;
+ }
+
+ private Point2D getP1(final StringBounder stringBounder) {
+ return getTranslateDiamond2(stringBounder).getTranslated(new Point2D.Double(0, 0));
+ }
+
+ private Point2D getP2(final StringBounder stringBounder) {
+ return getTranslateDiamond1(stringBounder).getTranslated(new Point2D.Double(0, 0));
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+
+ final Snake snake = new Snake(arrowColor, Arrows.asToLeft());
+ snake.setLabel(tbback);
+ snake.emphasizeDirection(Direction.UP);
+ final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
+ final Point2D p1 = getP1(stringBounder);
+ final Point2D p2 = getP2(stringBounder);
+ final Dimension2D dimDiamond1 = diamond1.calculateDimension(stringBounder);
+ final Dimension2D dimDiamond2 = diamond2.calculateDimension(stringBounder);
+ final double x1 = p1.getX() + dimDiamond2.getWidth();
+ final double y1 = p1.getY() + dimDiamond2.getHeight() / 2;
+ final double x2 = p2.getX() + dimDiamond1.getWidth();
+ final double y2 = p2.getY() + dimDiamond1.getHeight() / 2;
+
+ snake.addPoint(x1, y1);
+ final double yy = dimTotal.getWidth() - Diamond.diamondHalfSize;
+ snake.addPoint(yy, y1);
+ snake.addPoint(yy, y2);
+ snake.addPoint(x2, y2);
+
+ ug.draw(snake);
+ // ug = ug.apply(new UChangeColor(arrowColor)).apply(new UChangeBackColor(arrowColor));
+ // ug.apply(new UTranslate(yy, dimTotal.getHeight() / 2)).draw(Arrows.asToUp());
+ }
+
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ ug.apply(getTranslateForRepeat(stringBounder)).draw(repeat);
+ ug.apply(getTranslateDiamond1(stringBounder)).draw(diamond1);
+ ug.apply(getTranslateDiamond2(stringBounder)).draw(diamond2);
+
+ }
+
+ public FtileGeometry calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
+ return new FtileGeometry(dimTotal, getLeft(stringBounder), 0, dimTotal.getHeight());
+ }
+
+ private Dimension2D calculateDimensionInternal(StringBounder stringBounder) {
+ final Dimension2D dimDiamond1 = diamond1.calculateDimension(stringBounder);
+ final Dimension2D dimDiamond2 = diamond2.calculateDimension(stringBounder);
+ final Dimension2D dimRepeat = repeat.calculateDimension(stringBounder);
+
+ final double w = tbTest.calculateDimension(stringBounder).getWidth();
+
+ double width = getLeft(stringBounder) + getRight(stringBounder);
+ width = Math.max(width, w + 2 * Diamond.diamondHalfSize);
+ final double height = dimDiamond1.getHeight() + dimRepeat.getHeight() + dimDiamond2.getHeight() + 8
+ * Diamond.diamondHalfSize;
+ return new Dimension2DDouble(width + 2 * Diamond.diamondHalfSize, height);
+
+ }
+
+ @Override
+ public UTranslate getTranslateFor(Ftile child, StringBounder stringBounder) {
+ if (child == repeat) {
+ return getTranslateForRepeat(stringBounder);
+ }
+ if (child == diamond1) {
+ return getTranslateDiamond1(stringBounder);
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ private UTranslate getTranslateForRepeat(StringBounder stringBounder) {
+
+ final Dimension2D dimDiamond1 = diamond1.calculateDimension(stringBounder);
+ final Dimension2D dimDiamond2 = diamond2.calculateDimension(stringBounder);
+ final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
+ final Dimension2D dimRepeat = repeat.calculateDimension(stringBounder);
+ final double y = (dimTotal.getHeight() - dimDiamond1.getHeight() - dimDiamond2.getHeight() - dimRepeat
+ .getHeight()) / 2;
+
+ final double left = getLeft(stringBounder);
+ return new UTranslate(left - repeat.calculateDimension(stringBounder).getLeft(), y);
+
+ }
+
+ private UTranslate getTranslateDiamond1(StringBounder stringBounder) {
+ final Dimension2D dimDiamond1 = diamond1.calculateDimension(stringBounder);
+ final double left = getLeft(stringBounder);
+ return new UTranslate(left - dimDiamond1.getWidth() / 2, 0);
+ }
+
+ private UTranslate getTranslateDiamond2(StringBounder stringBounder) {
+ final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
+ final Dimension2D dimDiamond2 = diamond2.calculateDimension(stringBounder);
+ final double y2 = dimTotal.getHeight() - dimDiamond2.getHeight();
+ final double left = getLeft(stringBounder);
+ return new UTranslate(left - dimDiamond2.getWidth() / 2, y2);
+ }
+
+ private double getLeft(StringBounder stringBounder) {
+ final Dimension2D dimDiamond1 = diamond1.calculateDimension(stringBounder);
+ final Dimension2D dimDiamond2 = diamond2.calculateDimension(stringBounder);
+ double left1 = repeat.calculateDimension(stringBounder).getLeft();
+ left1 = Math.max(left1, dimDiamond1.getWidth() / 2);
+ double left2 = repeat.calculateDimension(stringBounder).getLeft();
+ left2 = Math.max(left2, dimDiamond2.getWidth() / 2);
+ return Math.max(left1, left2);
+ }
+
+ private double getRight(StringBounder stringBounder) {
+ final Dimension2D dimDiamond1 = diamond1.calculateDimension(stringBounder);
+ final Dimension2D dimDiamond2 = diamond2.calculateDimension(stringBounder);
+ final Dimension2D dimRepeat = repeat.calculateDimension(stringBounder);
+ double right1 = dimRepeat.getWidth() - repeat.calculateDimension(stringBounder).getLeft();
+ right1 = Math.max(right1, dimDiamond1.getWidth() / 2);
+ double right2 = dimRepeat.getWidth() - repeat.calculateDimension(stringBounder).getLeft();
+ right2 = Math.max(right2, dimDiamond2.getWidth() / 2);
+ return Math.max(right1, right2);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileSplit1.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileSplit1.java
new file mode 100644
index 0000000..84c81c5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileSplit1.java
@@ -0,0 +1,115 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
+
+import java.awt.geom.Dimension2D;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class FtileSplit1 extends AbstractFtile {
+
+ private final List<Ftile> forks = new ArrayList<Ftile>();
+
+ public FtileSplit1(List<Ftile> forks) {
+ super(forks.get(0).shadowing());
+ for (Ftile ftile : forks) {
+ this.forks.add(ftile);
+ }
+ }
+
+ public Swimlane getSwimlaneIn() {
+ return forks.get(0).getSwimlaneIn();
+ }
+
+ public Swimlane getSwimlaneOut() {
+ return null;
+ // return getSwimlaneIn();
+ }
+
+ public Set<Swimlane> getSwimlanes() {
+ return mergeSwimlanes(forks);
+ }
+
+ public static Set<Swimlane> mergeSwimlanes(List<Ftile> tiles) {
+ final Set<Swimlane> result = new HashSet<Swimlane>();
+ for (Ftile tile : tiles) {
+ result.addAll(tile.getSwimlanes());
+ }
+ return Collections.unmodifiableSet(result);
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+
+ for (Ftile ftile : forks) {
+ ug.apply(getTranslateFor(ftile, stringBounder)).draw(ftile);
+ }
+ }
+
+ public FtileGeometry calculateDimension(StringBounder stringBounder) {
+ double height = 0;
+ double width = 0;
+ for (Ftile ftile : forks) {
+ final Dimension2D dim = ftile.calculateDimension(stringBounder);
+ if (dim.getWidth() > width) {
+ width = dim.getWidth();
+ }
+ if (dim.getHeight() > height) {
+ height = dim.getHeight();
+ }
+ }
+ final Dimension2D dimTotal = new Dimension2DDouble(width, height);
+ return new FtileGeometry(dimTotal, dimTotal.getWidth() / 2, 0, dimTotal.getHeight());
+ }
+
+ public UTranslate getTranslateFor(Ftile searched, StringBounder stringBounder) {
+ final Dimension2D dim = searched.calculateDimension(stringBounder);
+ final double xpos = calculateDimension(stringBounder).getWidth() - dim.getWidth();
+ return new UTranslate(xpos / 2, 0);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWhile.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWhile.java
new file mode 100644
index 0000000..1ccc403
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWhile.java
@@ -0,0 +1,397 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import net.sourceforge.plantuml.Direction;
+import net.sourceforge.plantuml.FileGroup;
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.activitydiagram3.LinkRendering;
+import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractConnection;
+import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Connection;
+import net.sourceforge.plantuml.activitydiagram3.ftile.ConnectionTranslatable;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Diamond;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Snake;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamond;
+import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamondFoo1;
+import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamondInside;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.svek.ConditionStyle;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UEmpty;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class FtileWhile extends AbstractFtile {
+
+ private final Ftile whileBlock;
+ private final Ftile diamond1;
+ private final TextBlock supplementarySouthText;
+
+ public Set<Swimlane> getSwimlanes() {
+ final Set<Swimlane> result = new HashSet<Swimlane>(whileBlock.getSwimlanes());
+ result.add(getSwimlaneIn());
+ return result;
+ }
+
+ public Swimlane getSwimlaneIn() {
+ return diamond1.getSwimlaneIn();
+ }
+
+ public Swimlane getSwimlaneOut() {
+ return getSwimlaneIn();
+ }
+
+ private FtileWhile(Ftile whileBlock, Ftile diamond1, TextBlock supplementarySouthText) {
+ super(whileBlock.shadowing());
+ this.whileBlock = whileBlock;
+ this.diamond1 = diamond1;
+ this.supplementarySouthText = supplementarySouthText;
+ }
+
+ private static TextBlock createLabel1(Display test, Display yes, UFont font, ISkinSimple spriteContainer,
+ HtmlColor hyperlinkColor, boolean useUnderlineForHyperlink) {
+ final FontConfiguration fc = new FontConfiguration(font, HtmlColorUtils.BLACK, hyperlinkColor,
+ useUnderlineForHyperlink);
+ final TextBlock tmpb = TextBlockUtils.create(yes, fc, HorizontalAlignment.LEFT, spriteContainer);
+ if (test == null) {
+ return tmpb;
+ }
+ return TextBlockUtils.mergeTB(TextBlockUtils.create(test, fc, HorizontalAlignment.LEFT, spriteContainer), tmpb,
+ HorizontalAlignment.CENTER);
+ }
+
+ public static Ftile create(Swimlane swimlane, Ftile whileBlock, Display test, HtmlColor borderColor,
+ HtmlColor backColor, HtmlColor arrowColor, Display yes, Display out2, UFont fontArrow,
+ HtmlColor endInlinkColor, LinkRendering afterEndwhile, FtileFactory ftileFactory,
+ ConditionStyle conditionStyle, UFont fontTest, HtmlColor hyperlinkColor, boolean useUnderlineForHyperlink) {
+
+ final FontConfiguration fcArrow = new FontConfiguration(fontArrow, HtmlColorUtils.BLACK, hyperlinkColor,
+ useUnderlineForHyperlink);
+ final FontConfiguration fcTest = new FontConfiguration(fontTest, HtmlColorUtils.BLACK, hyperlinkColor,
+ useUnderlineForHyperlink);
+ final TextBlock yesTb = TextBlockUtils.create(yes, fcArrow, HorizontalAlignment.LEFT, ftileFactory);
+ final TextBlock testTb = TextBlockUtils.create(test, fcTest, HorizontalAlignment.LEFT, ftileFactory);
+ final TextBlock out = TextBlockUtils.create(out2, fcArrow, HorizontalAlignment.LEFT, ftileFactory);
+
+ final Ftile diamond1;
+ final TextBlock supplementarySouthText;
+ if (conditionStyle == ConditionStyle.INSIDE) {
+ supplementarySouthText = TextBlockUtils.empty(0, 0);
+ diamond1 = new FtileDiamondInside(whileBlock.shadowing(), backColor, borderColor, swimlane, testTb)
+ .withNorth(yesTb).withWest(out);
+ } else if (conditionStyle == ConditionStyle.FOO1) {
+ supplementarySouthText = TextBlockUtils.empty(0, 0);
+ diamond1 = new FtileDiamondFoo1(whileBlock.shadowing(), backColor, borderColor, swimlane, testTb)
+ .withNorth(yesTb).withWest(out);
+ } else if (conditionStyle == ConditionStyle.DIAMOND) {
+ supplementarySouthText = createLabel1(test, yes, fontArrow, ftileFactory, hyperlinkColor,
+ useUnderlineForHyperlink);
+ diamond1 = new FtileDiamond(whileBlock.shadowing(), backColor, borderColor, swimlane).withWest(out)
+ .withSouth(supplementarySouthText);
+ } else {
+ throw new IllegalStateException();
+ }
+
+ final FtileWhile result = new FtileWhile(whileBlock, diamond1, supplementarySouthText);
+ HtmlColor afterEndwhileColor = arrowColor;
+ if (afterEndwhile != null && afterEndwhile.getColor() != null) {
+ afterEndwhileColor = afterEndwhile.getColor();
+ }
+
+ final List<Connection> conns = new ArrayList<Connection>();
+ conns.add(result.new ConnectionIn(LinkRendering.getColor(whileBlock.getInLinkRendering(), arrowColor)));
+ conns.add(result.new ConnectionBack(endInlinkColor));
+ conns.add(result.new ConnectionOut(afterEndwhileColor));
+ return FtileUtils.addConnection(result, conns);
+ }
+
+ class ConnectionIn extends AbstractConnection implements ConnectionTranslatable {
+ private final HtmlColor arrowColor;
+
+ public ConnectionIn(HtmlColor arrowColor) {
+ super(diamond1, whileBlock);
+ this.arrowColor = arrowColor;
+ }
+
+ private Point2D getP1(final StringBounder stringBounder) {
+ return getTranslateDiamond1(stringBounder).getTranslated(
+ getFtile1().calculateDimension(stringBounder).getPointOut());
+ }
+
+ private Point2D getP2(final StringBounder stringBounder) {
+ return getTranslateForWhile(stringBounder).getTranslated(
+ getFtile2().calculateDimension(stringBounder).getPointIn());
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+
+ final Snake snake = new Snake(arrowColor, Arrows.asToDown());
+ snake.addPoint(getP1(stringBounder));
+ snake.addPoint(getP2(stringBounder));
+
+ ug.draw(snake);
+ }
+
+ public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Point2D p1 = getP1(stringBounder);
+ final Point2D p2 = getP2(stringBounder);
+ final Snake snake = new Snake(arrowColor, Arrows.asToDown());
+ final Point2D mp1a = translate1.getTranslated(p1);
+ final Point2D mp2b = translate2.getTranslated(p2);
+ final double middle = (mp1a.getY() + mp2b.getY()) / 2.0;
+ snake.addPoint(mp1a);
+ snake.addPoint(mp1a.getX(), middle);
+ snake.addPoint(mp2b.getX(), middle);
+ snake.addPoint(mp2b);
+ ug.draw(snake);
+ }
+ }
+
+ class ConnectionBack extends AbstractConnection implements ConnectionTranslatable {
+ private final HtmlColor endInlinkColor;
+
+ public ConnectionBack(HtmlColor endInlinkColor) {
+ super(whileBlock, diamond1);
+ this.endInlinkColor = endInlinkColor;
+ }
+
+ private Point2D getP1(final StringBounder stringBounder) {
+ final FtileGeometry geo = whileBlock.calculateDimension(stringBounder);
+ if (geo.hasPointOut() == false) {
+ return null;
+ }
+ return getTranslateForWhile(stringBounder).getTranslated(geo.getPointOut());
+ }
+
+ private Point2D getP2(final StringBounder stringBounder) {
+ return getTranslateDiamond1(stringBounder).getTranslated(new Point2D.Double(0, 0));
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+
+ final Snake snake = new Snake(endInlinkColor, Arrows.asToLeft());
+ final Dimension2D dimTotal = calculateDimension(stringBounder);
+ final Point2D p1 = getP1(stringBounder);
+ if (p1 == null) {
+ return;
+ }
+ final Point2D p2 = getP2(stringBounder);
+ final FtileGeometry dimDiamond1 = diamond1.calculateDimension(stringBounder);
+
+ final double x1 = p1.getX();
+ final double y1 = p1.getY();
+ final double x2 = p2.getX() + dimDiamond1.getWidth();
+ final double y2 = p2.getY() + dimDiamond1.getOutY() / 2;
+
+ snake.addPoint(x1, y1);
+ snake.addPoint(x1, y1 + Diamond.diamondHalfSize);
+ final double xx = dimTotal.getWidth();
+ snake.addPoint(xx, y1 + Diamond.diamondHalfSize);
+ snake.addPoint(xx, y2);
+ snake.addPoint(x2, y2);
+ snake.emphasizeDirection(Direction.UP);
+
+ ug.draw(snake);
+
+ ug.apply(new UTranslate(x1, y1 + Diamond.diamondHalfSize)).draw(new UEmpty(5, Diamond.diamondHalfSize));
+
+ // ug = ug.apply(new UChangeColor(endInlinkColor)).apply(new UChangeBackColor(endInlinkColor));
+ // ug.apply(new UTranslate(xx, (y1 + y2) / 2)).draw(Arrows.asToUp());
+ }
+
+ public void drawTranslate(UGraphic ug, UTranslate translate1, UTranslate translate2) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Snake snake = new Snake(endInlinkColor, Arrows.asToLeft());
+ final Dimension2D dimTotal = calculateDimension(stringBounder);
+ final Point2D ap1 = getP1(stringBounder);
+ final Point2D ap2 = getP2(stringBounder);
+ final Point2D p1 = translate1.getTranslated(ap1);
+ final Point2D p2 = translate2.getTranslated(ap2);
+
+ final Dimension2D dimDiamond1 = diamond1.calculateDimension(stringBounder);
+
+ final double x1 = p1.getX();
+ final double y1 = p1.getY();
+ final double x2 = p2.getX() + dimDiamond1.getWidth();
+ final double y2 = p2.getY() + dimDiamond1.getHeight() / 2;
+
+ snake.addPoint(x1, y1);
+ snake.addPoint(x1, y1 + Diamond.diamondHalfSize);
+ final double xx = Math.max(translate1.getDx(), translate2.getDx()) + dimTotal.getWidth();
+ snake.addPoint(xx, y1 + Diamond.diamondHalfSize);
+ snake.addPoint(xx, y2);
+ snake.addPoint(x2, y2);
+
+ ug.draw(snake);
+
+ ug.apply(new UTranslate(x1, y1 + Diamond.diamondHalfSize)).draw(new UEmpty(5, Diamond.diamondHalfSize));
+
+ ug = ug.apply(new UChangeColor(endInlinkColor)).apply(new UChangeBackColor(endInlinkColor));
+ ug.apply(new UTranslate(xx, (y1 + y2) / 2)).draw(Arrows.asToUp());
+
+ }
+
+ }
+
+ class ConnectionOut extends AbstractConnection {
+ private final HtmlColor afterEndwhileColor;
+
+ public ConnectionOut(HtmlColor afterEndwhileColor) {
+ super(diamond1, null);
+ this.afterEndwhileColor = afterEndwhileColor;
+ }
+
+ private Point2D getP1(final StringBounder stringBounder) {
+ return getTranslateDiamond1(stringBounder).getTranslated(new Point2D.Double(0, 0));
+ }
+
+ private Point2D getP2(final StringBounder stringBounder) {
+ final FtileGeometry dimTotal = calculateDimension(stringBounder);
+ return new Point2D.Double(dimTotal.getLeft(), dimTotal.getHeight());
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+
+ final Snake snake = new Snake(afterEndwhileColor);
+
+ final FtileGeometry dimDiamond1 = diamond1.calculateDimension(stringBounder);
+ final Point2D p1 = getP1(stringBounder);
+ final Point2D p2 = getP2(stringBounder);
+
+ final double x1 = p1.getX();
+ final double y1 = p1.getY() + dimDiamond1.getOutY() / 2;
+ final double x2 = p2.getX();
+ final double y2 = p2.getY();
+
+ snake.addPoint(x1, y1);
+ snake.addPoint(Diamond.diamondHalfSize, y1);
+ snake.addPoint(Diamond.diamondHalfSize, y2);
+ snake.emphasizeDirection(Direction.DOWN);
+
+ ug.draw(snake);
+ // ug = ug.apply(new UChangeColor(afterEndwhileColor)).apply(new UChangeBackColor(afterEndwhileColor));
+ // ug.apply(new UTranslate(Diamond.diamondHalfSize, (y1 + y2) / 2)).draw(Arrows.asToDown());
+
+ final Snake snake2 = new Snake(afterEndwhileColor);
+ snake2.addPoint(Diamond.diamondHalfSize, y2);
+ snake2.addPoint(x2, y2);
+ ug.draw(snake2);
+
+ }
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ ug.apply(getTranslateForWhile(stringBounder)).draw(whileBlock);
+ ug.apply(getTranslateDiamond1(stringBounder)).draw(diamond1);
+ }
+
+ public FtileGeometry calculateDimension(StringBounder stringBounder) {
+ final FtileGeometry geoDiamond1 = diamond1.calculateDimension(stringBounder);
+ final Dimension2D dimSupplementarySouth = supplementarySouthText.calculateDimension(stringBounder);
+ FtileGeometry geoWhile = whileBlock.calculateDimension(stringBounder);
+ final double diff = dimSupplementarySouth.getWidth() - geoWhile.getWidth();
+ if (diff > 0) {
+ geoWhile = geoWhile.addMarginX(diff / 2);
+ }
+ final FtileGeometry geo = geoDiamond1.appendBottom(geoWhile);
+ final double height = geo.getHeight() + 4 * Diamond.diamondHalfSize + dimSupplementarySouth.getHeight();
+ final double dx = 2 * Diamond.diamondHalfSize;
+ return new FtileGeometry(geo.getWidth() + dx + Diamond.diamondHalfSize, height, geo.getLeft() + dx, 0, height);
+
+ }
+
+ @Override
+ public UTranslate getTranslateFor(Ftile child, StringBounder stringBounder) {
+ if (child == whileBlock) {
+ return getTranslateForWhile(stringBounder);
+ }
+ if (child == diamond1) {
+ return getTranslateDiamond1(stringBounder);
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ private UTranslate getTranslateForWhile(StringBounder stringBounder) {
+ final FtileGeometry dimDiamond1 = diamond1.calculateDimension(stringBounder);
+
+ final FtileGeometry dimTotal = calculateDimension(stringBounder);
+ final FtileGeometry dimWhile = whileBlock.calculateDimension(stringBounder);
+
+ final double y = dimDiamond1.getHeight()
+ + (dimTotal.getHeight() - dimDiamond1.getHeight() - dimWhile.getHeight()) / 2;
+
+ final double x = dimTotal.getLeft() - dimWhile.getLeft();
+ return new UTranslate(x, y);
+
+ }
+
+ private UTranslate getTranslateDiamond1(StringBounder stringBounder) {
+ final FtileGeometry dimTotal = calculateDimension(stringBounder);
+ final FtileGeometry dimDiamond1 = diamond1.calculateDimension(stringBounder);
+
+ final double y1 = 0;
+ final double x1 = dimTotal.getLeft() - dimDiamond1.getLeft();
+ return new UTranslate(x1, y1);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNoteOpale.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNoteOpale.java
new file mode 100644
index 0000000..1b3eceb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileWithNoteOpale.java
@@ -0,0 +1,187 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.util.Set;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.Direction;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.creole.CreoleParser;
+import net.sourceforge.plantuml.creole.Sheet;
+import net.sourceforge.plantuml.creole.SheetBlock1;
+import net.sourceforge.plantuml.creole.SheetBlock2;
+import net.sourceforge.plantuml.creole.Stencil;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+import net.sourceforge.plantuml.skin.rose.Rose;
+import net.sourceforge.plantuml.svek.image.Opale;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class FtileWithNoteOpale extends AbstractFtile implements Stencil {
+
+ private final Ftile tile;
+ private final Opale opale;
+
+ // private final HtmlColor arrowColor;
+ private final NotePosition notePosition;
+ private final double suppSpace = 20;
+
+ public Set<Swimlane> getSwimlanes() {
+ return tile.getSwimlanes();
+ }
+
+ public Swimlane getSwimlaneIn() {
+ return tile.getSwimlaneIn();
+ }
+
+ public Swimlane getSwimlaneOut() {
+ return tile.getSwimlaneOut();
+ }
+
+ public FtileWithNoteOpale(Ftile tile, Display note, NotePosition notePosition, ISkinParam skinParam,
+ boolean withLink) {
+ super(tile.shadowing());
+ this.tile = tile;
+ this.notePosition = notePosition;
+ // this.arrowColor = arrowColor;
+
+ final Rose rose = new Rose();
+ final HtmlColor fontColor = rose.getFontColor(skinParam, FontParam.NOTE);
+ final UFont fontNote = skinParam.getFont(FontParam.NOTE, null, false);
+
+ final HtmlColor noteBackgroundColor = rose.getHtmlColor(skinParam, ColorParam.noteBackground);
+ final HtmlColor borderColor = rose.getHtmlColor(skinParam, ColorParam.noteBorder);
+
+ final FontConfiguration fc = new FontConfiguration(fontNote, fontColor, skinParam.getHyperlinkColor(), skinParam.useUnderlineForHyperlink());
+
+ final Sheet sheet = new CreoleParser(fc, HorizontalAlignment.LEFT, skinParam, false).createSheet(note);
+ final TextBlock text = new SheetBlock2(new SheetBlock1(sheet, 0, skinParam.getPadding()), this, new UStroke(1));
+ opale = new Opale(borderColor, noteBackgroundColor, text, skinParam.shadowing(), withLink);
+
+ }
+
+ private UTranslate getTranslate(StringBounder stringBounder) {
+ final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
+ final Dimension2D dimNote = opale.calculateDimension(stringBounder);
+ final Dimension2D dimTile = tile.calculateDimension(stringBounder);
+ final double yForFtile = (dimTotal.getHeight() - dimTile.getHeight()) / 2;
+ final double marge;
+ if (notePosition == NotePosition.LEFT) {
+ marge = dimNote.getWidth() + suppSpace;
+ } else {
+ marge = 0;
+ }
+
+ return new UTranslate(marge, yForFtile);
+
+ }
+
+ private UTranslate getTranslateForOpale(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D dimTotal = calculateDimension(stringBounder);
+ final Dimension2D dimNote = opale.calculateDimension(stringBounder);
+
+ final double yForNote = (dimTotal.getHeight() - dimNote.getHeight()) / 2;
+
+ if (notePosition == NotePosition.LEFT) {
+ return new UTranslate(0, yForNote);
+ }
+ final double dx = dimTotal.getWidth() - dimNote.getWidth();
+ return new UTranslate(dx, yForNote);
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D dimNote = opale.calculateDimension(stringBounder);
+
+ if (notePosition == NotePosition.LEFT) {
+ final Direction strategy = Direction.RIGHT;
+ final Point2D pp1 = new Point2D.Double(dimNote.getWidth(), dimNote.getHeight() / 2);
+ final Point2D pp2 = new Point2D.Double(dimNote.getWidth() + suppSpace, dimNote.getHeight() / 2);
+ opale.setOpale(strategy, pp1, pp2);
+ } else {
+ final Direction strategy = Direction.LEFT;
+ final Point2D pp1 = new Point2D.Double(0, dimNote.getHeight() / 2);
+ final Point2D pp2 = new Point2D.Double(-suppSpace, dimNote.getHeight() / 2);
+ opale.setOpale(strategy, pp1, pp2);
+ }
+ opale.drawU(ug.apply(getTranslateForOpale(ug)));
+ ug.apply(getTranslate(stringBounder)).draw(tile);
+ }
+
+ public FtileGeometry calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
+ final FtileGeometry orig = tile.calculateDimension(stringBounder);
+ final UTranslate translate = getTranslate(stringBounder);
+ if (orig.hasPointOut()) {
+ return new FtileGeometry(dimTotal, orig.getLeft() + translate.getDx(), orig.getInY() + translate.getDy(),
+ orig.getOutY() + translate.getDy());
+ }
+ return new FtileGeometry(dimTotal, orig.getLeft() + translate.getDx(), orig.getInY() + translate.getDy());
+ }
+
+ private Dimension2D calculateDimensionInternal(StringBounder stringBounder) {
+ final Dimension2D dimNote = opale.calculateDimension(stringBounder);
+ final Dimension2D dimTile = tile.calculateDimension(stringBounder);
+ final double height = Math.max(dimNote.getHeight(), dimTile.getHeight());
+ return new Dimension2DDouble(dimTile.getWidth() + 1 * dimNote.getWidth() + suppSpace, height);
+ }
+
+ public double getStartingX(StringBounder stringBounder, double y) {
+ return -opale.getMarginX1();
+ }
+
+ public double getEndingX(StringBounder stringBounder, double y) {
+ return opale.calculateDimension(stringBounder).getWidth() - opale.getMarginX1();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/UGraphicInterceptorGoto.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/UGraphicInterceptorGoto.java
new file mode 100644
index 0000000..4f7f853
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/UGraphicInterceptorGoto.java
@@ -0,0 +1,66 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
+
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.graphic.UGraphicDelegator;
+import net.sourceforge.plantuml.ugraphic.UChange;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class UGraphicInterceptorGoto extends UGraphicDelegator {
+
+ public UGraphicInterceptorGoto(UGraphic ug) {
+ super(ug);
+ }
+
+ public void draw(UShape shape) {
+ System.err.println("inter=" + shape.getClass());
+
+ if (shape instanceof Ftile) {
+ final Ftile foo = (Ftile) shape;
+ foo.drawU(this);
+ } else {
+ getUg().draw(shape);
+ System.err.println("Drawing " + shape);
+ }
+
+ }
+
+ public UGraphic apply(UChange change) {
+ return new UGraphicInterceptorGoto(getUg().apply(change));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/UGraphicInterceptorOneSwimlane.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/UGraphicInterceptorOneSwimlane.java
new file mode 100644
index 0000000..26d213f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/UGraphicInterceptorOneSwimlane.java
@@ -0,0 +1,99 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
+
+import java.util.Set;
+
+import net.sourceforge.plantuml.activitydiagram3.ftile.Connection;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.UGraphicDelegator;
+import net.sourceforge.plantuml.ugraphic.UChange;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class UGraphicInterceptorOneSwimlane extends UGraphicDelegator {
+
+ private final Swimlane swimlane;
+
+ public UGraphicInterceptorOneSwimlane(UGraphic ug, Swimlane swimlane) {
+ super(ug);
+ this.swimlane = swimlane;
+ }
+
+ public void draw(UShape shape) {
+ // System.err.println("inter=" + shape.getClass());
+ if (shape instanceof Ftile) {
+ final Ftile tile = (Ftile) shape;
+ final Set<Swimlane> swinlanes = tile.getSwimlanes();
+ final boolean contained = swinlanes.contains(swimlane);
+ if (contained) {
+ tile.drawU(this);
+ // drawGoto();
+ }
+ } else if (shape instanceof Connection) {
+ final Connection connection = (Connection) shape;
+ final Ftile tile1 = connection.getFtile1();
+ final Ftile tile2 = connection.getFtile2();
+ final boolean contained1 = tile1 == null || tile1.getSwimlaneOut() == null
+ || tile1.getSwimlaneOut() == swimlane;
+ final boolean contained2 = tile2 == null || tile2.getSwimlaneIn() == null
+ || tile2.getSwimlaneIn() == swimlane;
+
+ if (contained1 && contained2) {
+ connection.drawU(this);
+ }
+ } else {
+ getUg().draw(shape);
+ // System.err.println("Drawing " + shape);
+ }
+
+ }
+
+ private void drawGoto() {
+ final UGraphic ugGoto = getUg().apply(new UChangeColor(HtmlColorUtils.GREEN)).apply(
+ new UChangeBackColor(HtmlColorUtils.GREEN));
+ ugGoto.draw(new ULine(100, 100));
+ }
+
+ public UGraphic apply(UChange change) {
+ return new UGraphicInterceptorOneSwimlane(getUg().apply(change), swimlane);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/VCompactFactory.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/VCompactFactory.java
new file mode 100644
index 0000000..bbbeecc
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/VCompactFactory.java
@@ -0,0 +1,174 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.activitydiagram3.Branch;
+import net.sourceforge.plantuml.activitydiagram3.LinkRendering;
+import net.sourceforge.plantuml.activitydiagram3.ftile.BoxStyle;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileAssemblySimple;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileBox;
+import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileCircleStart;
+import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileCircleStop;
+import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDecorateIn;
+import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDecorateOut;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+import net.sourceforge.plantuml.skin.rose.Rose;
+import net.sourceforge.plantuml.ugraphic.Sprite;
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public class VCompactFactory implements FtileFactory {
+
+ private final ISkinParam skinParam;
+ private final Rose rose = new Rose();
+ private final StringBounder stringBounder;
+
+ public StringBounder getStringBounder() {
+ return stringBounder;
+ }
+
+ public VCompactFactory(ISkinParam skinParam, StringBounder stringBounder) {
+ this.skinParam = skinParam;
+ this.stringBounder = stringBounder;
+ }
+
+ public Ftile start(Swimlane swimlane) {
+ final HtmlColor color = rose.getHtmlColor(skinParam, ColorParam.activityStart);
+ return new FtileCircleStart(shadowing(), color, swimlane);
+ }
+
+ public Ftile stop(Swimlane swimlane) {
+ final HtmlColor color = rose.getHtmlColor(skinParam, ColorParam.activityEnd);
+ return new FtileCircleStop(shadowing(), color, swimlane);
+ }
+
+ public Ftile activity(Display label, final HtmlColor color, Swimlane swimlane, BoxStyle style) {
+ final HtmlColor borderColor = rose.getHtmlColor(skinParam, ColorParam.activityBorder);
+ final HtmlColor backColor = color == null ? rose.getHtmlColor(skinParam, ColorParam.activityBackground) : color;
+ final UFont font = skinParam.getFont(FontParam.ACTIVITY, null, false);
+ final HtmlColor arrowColor = rose.getHtmlColor(skinParam, ColorParam.activityArrow);
+ return new FtileBox(shadowing(), label, borderColor, backColor, font, arrowColor, swimlane, style, skinParam);
+ }
+
+ public Ftile addNote(Ftile ftile, Display note, NotePosition notePosition) {
+ return ftile;
+ }
+
+ public Ftile addUrl(Ftile ftile, Url url) {
+ return ftile;
+ }
+
+ public Ftile assembly(Ftile tile1, Ftile tile2) {
+ return new FtileAssemblySimple(tile1, tile2);
+ }
+
+ public Ftile repeat(Swimlane swimlane, Ftile repeat, Display test, Display yes, Display out, HtmlColor color,
+ LinkRendering backRepeatLinkRendering) {
+ return repeat;
+ }
+
+ public Ftile createWhile(Swimlane swimlane, Ftile whileBlock, Display test, Display yes, Display out,
+ LinkRendering afterEndwhile, HtmlColor color) {
+ return whileBlock;
+ }
+
+ public Ftile createIf(Swimlane swimlane, List<Branch> thens, Branch elseBranch) {
+ final List<Ftile> ftiles = new ArrayList<Ftile>();
+ for (Branch branch : thens) {
+ ftiles.add(branch.getFtile());
+ }
+ ftiles.add(elseBranch.getFtile());
+ return new FtileForkInner(ftiles);
+ }
+
+ public Ftile createFork(Swimlane swimlane, List<Ftile> all) {
+ return new FtileForkInner(all);
+ }
+
+ public Ftile createSplit(List<Ftile> all) {
+ return new FtileForkInner(all);
+ }
+
+ public Ftile createGroup(Ftile list, Display name, HtmlColor backColor, HtmlColor titleColor, Display headerNote) {
+ return list;
+ }
+
+ public Ftile decorateIn(final Ftile ftile, final LinkRendering linkRendering) {
+ return new FtileDecorateIn(ftile, linkRendering);
+ }
+
+ public Ftile decorateOut(final Ftile ftile, final LinkRendering linkRendering) {
+ // if (ftile instanceof FtileWhile) {
+ // if (linkRendering != null) {
+ // ((FtileWhile) ftile).changeAfterEndwhileColor(linkRendering.getColor());
+ // }
+ // return ftile;
+ // }
+ return new FtileDecorateOut(ftile, linkRendering);
+ }
+
+ public boolean shadowing() {
+ return skinParam.shadowing();
+ }
+
+ public Sprite getSprite(String name) {
+ return skinParam.getSprite(name);
+ }
+
+ public String getValue(String key) {
+ return skinParam.getValue(key);
+ }
+
+ public double getPadding() {
+ return skinParam.getPadding();
+ }
+
+ public boolean useGuillemet() {
+ return skinParam.useGuillemet();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBlackBlock.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBlackBlock.java
new file mode 100644
index 0000000..65cd93e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBlackBlock.java
@@ -0,0 +1,92 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile.vertical;
+
+import java.util.Collections;
+import java.util.Set;
+
+import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+
+public class FtileBlackBlock extends AbstractFtile {
+
+ private double width;
+ private double height;
+ private final HtmlColor colorBar;
+ private final Swimlane swimlane;
+
+ public FtileBlackBlock(boolean shadowing, HtmlColor colorBar, Swimlane swimlane) {
+ super(shadowing);
+ this.colorBar = colorBar;
+ this.swimlane = swimlane;
+ }
+
+ public void setDimenstion(double width, double height) {
+ this.height = height;
+ this.width = width;
+ }
+
+ public FtileGeometry calculateDimension(StringBounder stringBounder) {
+ return new FtileGeometry(width, height, width / 2, 0, height);
+ }
+
+ public void drawU(UGraphic ug) {
+ final URectangle rect = new URectangle(width, height, 5, 5);
+ if (shadowing()) {
+ rect.setDeltaShadow(3);
+ }
+ ug.apply(new UChangeColor(colorBar)).apply(new UChangeBackColor(colorBar)).draw(rect);
+ }
+
+ public Set<Swimlane> getSwimlanes() {
+ return Collections.singleton(swimlane);
+ }
+
+ public Swimlane getSwimlaneIn() {
+ return swimlane;
+ }
+
+ public Swimlane getSwimlaneOut() {
+ return swimlane;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBox.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBox.java
new file mode 100644
index 0000000..ebae0c7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileBox.java
@@ -0,0 +1,156 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile.vertical;
+
+import java.awt.geom.Dimension2D;
+import java.util.Collections;
+import java.util.Set;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.activitydiagram3.LinkRendering;
+import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.BoxStyle;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileEmpty;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.creole.CreoleParser;
+import net.sourceforge.plantuml.creole.Sheet;
+import net.sourceforge.plantuml.creole.SheetBlock1;
+import net.sourceforge.plantuml.creole.SheetBlock2;
+import net.sourceforge.plantuml.creole.Stencil;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class FtileBox extends AbstractFtile {
+
+ private static final int MARGIN = 10;
+
+ private final TextBlock tb;
+
+ private final HtmlColor borderColor;
+ private final HtmlColor backColor;
+ private final LinkRendering inRenreding;
+ private final Swimlane swimlane;
+ private final BoxStyle style;
+
+ final public LinkRendering getInLinkRendering() {
+ return inRenreding;
+ }
+
+ public Set<Swimlane> getSwimlanes() {
+ if (swimlane == null) {
+ return Collections.emptySet();
+ }
+ return Collections.singleton(swimlane);
+ }
+
+ public Swimlane getSwimlaneIn() {
+ return swimlane;
+ }
+
+ public Swimlane getSwimlaneOut() {
+ return swimlane;
+ }
+
+ class MyStencil implements Stencil {
+
+ public double getStartingX(StringBounder stringBounder, double y) {
+ return -MARGIN;
+ }
+
+ public double getEndingX(StringBounder stringBounder, double y) {
+ final Dimension2D dim = calculateDimension(stringBounder);
+ return dim.getWidth() - MARGIN;
+ }
+
+ }
+
+ public FtileBox(boolean shadowing, Display label, HtmlColor color, HtmlColor backColor, UFont font,
+ HtmlColor arrowColor, Swimlane swimlane, BoxStyle style, ISkinParam skinParam) {
+ super(shadowing);
+ this.style = style;
+ this.borderColor = color;
+ this.swimlane = swimlane;
+ this.backColor = backColor;
+ this.inRenreding = new LinkRendering(arrowColor);
+ final HtmlColor fontColor = skinParam.getFontHtmlColor(FontParam.ACTIVITY, null);
+ final FontConfiguration fc = new FontConfiguration(font, fontColor, skinParam.getHyperlinkColor(),
+ skinParam.useUnderlineForHyperlink());
+
+ final Sheet sheet = new CreoleParser(fc, HorizontalAlignment.LEFT, skinParam, false).createSheet(label);
+ this.tb = new SheetBlock2(new SheetBlock1(sheet, 0, skinParam.getPadding()), new MyStencil(), new UStroke(1));
+ this.print = label.toString();
+ }
+
+ final private String print;
+
+ @Override
+ public String toString() {
+ return print;
+ }
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dimTotal = calculateDimension(ug.getStringBounder());
+ final double widthTotal = dimTotal.getWidth();
+ final double heightTotal = dimTotal.getHeight();
+ final UDrawable rect = style.getUDrawable(widthTotal, heightTotal, shadowing());
+
+ ug = ug.apply(new UChangeColor(borderColor)).apply(new UChangeBackColor(backColor)).apply(new UStroke(1.5));
+ rect.drawU(ug);
+
+ tb.drawU(ug.apply(new UTranslate(MARGIN, MARGIN)));
+ }
+
+ public FtileGeometry calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dim = tb.calculateDimension(stringBounder);
+ return new FtileGeometry(Dimension2DDouble.delta(dim, 2 * MARGIN, 2 * MARGIN), dim.getWidth() / 2 + MARGIN, 0,
+ dim.getHeight() + 2 * MARGIN);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileCircleStart.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileCircleStart.java
new file mode 100644
index 0000000..9da8a6b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileCircleStart.java
@@ -0,0 +1,90 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile.vertical;
+
+import java.util.Collections;
+import java.util.Set;
+
+import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class FtileCircleStart extends AbstractFtile {
+
+ private static final int SIZE = 20;
+
+ private final HtmlColor backColor;
+ private final Swimlane swimlane;
+
+ public FtileCircleStart(boolean shadowing, HtmlColor backColor, Swimlane swimlane) {
+ super(shadowing);
+ this.backColor = backColor;
+ this.swimlane = swimlane;
+ }
+
+ public Set<Swimlane> getSwimlanes() {
+ if (swimlane == null) {
+ return Collections.emptySet();
+ }
+ return Collections.singleton(swimlane);
+ }
+
+ public Swimlane getSwimlaneIn() {
+ return swimlane;
+ }
+
+ public Swimlane getSwimlaneOut() {
+ return swimlane;
+ }
+
+ public void drawU(UGraphic ug) {
+ final UEllipse circle = new UEllipse(SIZE, SIZE);
+ if (shadowing()) {
+ circle.setDeltaShadow(3);
+ }
+ ug.apply(new UChangeColor(null)).apply(new UChangeBackColor(backColor)).draw(circle);
+ }
+
+ public FtileGeometry calculateDimension(StringBounder stringBounder) {
+ return new FtileGeometry(SIZE, SIZE, SIZE / 2, 0, SIZE);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileCircleStop.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileCircleStop.java
new file mode 100644
index 0000000..abf58f3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileCircleStop.java
@@ -0,0 +1,106 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile.vertical;
+
+import java.util.Collections;
+import java.util.Set;
+
+import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class FtileCircleStop extends AbstractFtile {
+
+ private static final int SIZE = 20;
+
+ private final HtmlColor backColor;
+ private final Swimlane swimlane;
+
+ public FtileCircleStop(boolean shadowing, HtmlColor backColor, Swimlane swimlane) {
+ super(shadowing);
+ this.backColor = backColor;
+ this.swimlane = swimlane;
+ }
+
+ public Set<Swimlane> getSwimlanes() {
+ if (swimlane == null) {
+ return Collections.emptySet();
+ }
+ return Collections.singleton(swimlane);
+ }
+
+ public Swimlane getSwimlaneIn() {
+ return swimlane;
+ }
+
+ public Swimlane getSwimlaneOut() {
+ return swimlane;
+ }
+
+ public void drawU(UGraphic ug) {
+ double xTheoricalPosition = 0;
+ double yTheoricalPosition = 0;
+ xTheoricalPosition = Math.round(xTheoricalPosition);
+ yTheoricalPosition = Math.round(yTheoricalPosition);
+
+ final UEllipse circle = new UEllipse(SIZE, SIZE);
+ if (shadowing()) {
+ circle.setDeltaShadow(3);
+ }
+ ug.apply(new UChangeColor(backColor)).apply(new UChangeBackColor(null))
+ .apply(new UTranslate(xTheoricalPosition, yTheoricalPosition)).draw(circle);
+
+ final double delta = 4;
+ final UEllipse circleSmall = new UEllipse(SIZE - delta * 2, SIZE - delta * 2);
+ if (shadowing()) {
+ circleSmall.setDeltaShadow(3);
+ }
+ ug.apply(new UChangeColor(null)).apply(new UChangeBackColor(backColor))
+ .apply(new UTranslate(xTheoricalPosition + delta + .5, yTheoricalPosition + delta + .5))
+ .draw(circleSmall);
+ }
+
+ public FtileGeometry calculateDimension(StringBounder stringBounder) {
+ return new FtileGeometry(SIZE, SIZE, SIZE / 2, 0);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDecorate.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDecorate.java
new file mode 100644
index 0000000..4b6e3ca
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDecorate.java
@@ -0,0 +1,106 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile.vertical;
+
+import java.util.Collection;
+import java.util.Set;
+
+import net.sourceforge.plantuml.activitydiagram3.LinkRendering;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Connection;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public abstract class FtileDecorate implements Ftile {
+
+ final private Ftile ftile;
+
+ public FtileDecorate(final Ftile ftile) {
+ this.ftile = ftile;
+ }
+
+ @Override
+ public String toString() {
+ return "" + getClass() + " " + ftile;
+ }
+
+ public LinkRendering getOutLinkRendering() {
+ return ftile.getOutLinkRendering();
+ }
+
+ public LinkRendering getInLinkRendering() {
+ return ftile.getInLinkRendering();
+ }
+
+ public void drawU(UGraphic ug) {
+ ftile.drawU(ug);
+ }
+
+ public FtileGeometry calculateDimension(StringBounder stringBounder) {
+ return ftile.calculateDimension(stringBounder);
+ }
+
+ public Collection<Connection> getInnerConnections() {
+ return ftile.getInnerConnections();
+ }
+
+ public UTranslate getTranslateFor(Ftile child, StringBounder stringBounder) {
+ return ftile.getTranslateFor(child, stringBounder);
+ }
+
+ public Set<Swimlane> getSwimlanes() {
+ return ftile.getSwimlanes();
+ }
+
+ public Swimlane getSwimlaneIn() {
+ return ftile.getSwimlaneIn();
+ }
+
+ public Swimlane getSwimlaneOut() {
+ return ftile.getSwimlaneOut();
+ }
+
+ public boolean shadowing() {
+ return ftile.shadowing();
+ }
+
+ protected final Ftile getFtileDelegated() {
+ return ftile;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDecorateIn.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDecorateIn.java
new file mode 100644
index 0000000..9448ad8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDecorateIn.java
@@ -0,0 +1,53 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile.vertical;
+
+import net.sourceforge.plantuml.activitydiagram3.LinkRendering;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+
+public class FtileDecorateIn extends FtileDecorate {
+
+ final private LinkRendering linkRendering;
+
+ public FtileDecorateIn(final Ftile ftile, final LinkRendering linkRendering) {
+ super(ftile);
+ this.linkRendering = linkRendering;
+ }
+
+ public LinkRendering getInLinkRendering() {
+ return linkRendering;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDecorateOut.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDecorateOut.java
new file mode 100644
index 0000000..64593dd
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDecorateOut.java
@@ -0,0 +1,53 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile.vertical;
+
+import net.sourceforge.plantuml.activitydiagram3.LinkRendering;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+
+public class FtileDecorateOut extends FtileDecorate {
+
+ final private LinkRendering linkRendering;
+
+ public FtileDecorateOut(final Ftile ftile, final LinkRendering linkRendering) {
+ super(ftile);
+ this.linkRendering = linkRendering;
+ }
+
+ public LinkRendering getOutLinkRendering() {
+ return linkRendering;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDecoratePointOut.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDecoratePointOut.java
new file mode 100644
index 0000000..7bda33d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDecoratePointOut.java
@@ -0,0 +1,61 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile.vertical;
+
+import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
+import net.sourceforge.plantuml.graphic.StringBounder;
+
+public class FtileDecoratePointOut extends FtileDecorate {
+
+ final private double dx;
+ final private double dy;
+
+ public FtileDecoratePointOut(final Ftile ftile, final double dx, double dy) {
+ super(ftile);
+ this.dx = dx;
+ if (dx != 0) {
+ throw new IllegalArgumentException();
+ }
+ this.dy = dy;
+ }
+
+ @Override
+ public FtileGeometry calculateDimension(StringBounder stringBounder) {
+ final FtileGeometry geo = super.calculateDimension(stringBounder);
+ return new FtileGeometry(geo.getWidth(), geo.getHeight(), geo.getLeft(), geo.getInY(), geo.getOutY() + dy);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamond.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamond.java
new file mode 100644
index 0000000..eb3a91b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamond.java
@@ -0,0 +1,145 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile.vertical;
+
+import java.awt.geom.Dimension2D;
+import java.util.Collections;
+import java.util.Set;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Diamond;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class FtileDiamond extends AbstractFtile {
+
+ private final HtmlColor backColor;
+ private final HtmlColor borderColor;
+ private final Swimlane swimlane;
+ private final TextBlock north;
+ private final TextBlock south;
+ private final TextBlock west1;
+ private final TextBlock east1;
+
+ public FtileDiamond(boolean shadowing, HtmlColor backColor, HtmlColor borderColor, Swimlane swimlane) {
+ this(shadowing, backColor, borderColor, swimlane, TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0),
+ TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0));
+ }
+
+ public FtileDiamond withNorth(TextBlock north) {
+ return new FtileDiamond(shadowing(), backColor, borderColor, swimlane, north, south, east1, west1);
+ }
+
+ public FtileDiamond withWest(TextBlock west1) {
+ if (west1 == null) {
+ return this;
+ }
+ return new FtileDiamond(shadowing(), backColor, borderColor, swimlane, north, south, east1, west1);
+ }
+
+ public FtileDiamond withEast(TextBlock east1) {
+ if (east1 == null) {
+ return this;
+ }
+ return new FtileDiamond(shadowing(), backColor, borderColor, swimlane, north, south, east1, west1);
+ }
+
+ public FtileDiamond withSouth(TextBlock south) {
+ return new FtileDiamond(shadowing(), backColor, borderColor, swimlane, north, south, east1, west1);
+ }
+
+ private FtileDiamond(boolean shadowing, HtmlColor backColor, HtmlColor borderColor, Swimlane swimlane,
+ TextBlock north, TextBlock south, TextBlock east1, TextBlock west1) {
+ super(shadowing);
+ this.backColor = backColor;
+ this.swimlane = swimlane;
+ this.borderColor = borderColor;
+ this.north = north;
+ this.west1 = west1;
+ this.east1 = east1;
+ this.south = south;
+ }
+
+ public Set<Swimlane> getSwimlanes() {
+ if (swimlane == null) {
+ return Collections.emptySet();
+ }
+ return Collections.singleton(swimlane);
+ }
+
+ public Swimlane getSwimlaneIn() {
+ return swimlane;
+ }
+
+ public Swimlane getSwimlaneOut() {
+ return swimlane;
+ }
+
+ public void drawU(UGraphic ug) {
+
+ ug.apply(new UChangeColor(borderColor)).apply(new UStroke(1.5)).apply(new UChangeBackColor(backColor))
+ .draw(Diamond.asPolygon(shadowing()));
+ final Dimension2D dimNorth = north.calculateDimension(ug.getStringBounder());
+ north.drawU(ug.apply(new UTranslate(Diamond.diamondHalfSize * 1.5, -dimNorth.getHeight()
+ - Diamond.diamondHalfSize)));
+
+ final Dimension2D dimSouth = south.calculateDimension(ug.getStringBounder());
+ south.drawU(ug.apply(new UTranslate(-(dimSouth.getWidth() - 2 * Diamond.diamondHalfSize) / 2,
+ 2 * Diamond.diamondHalfSize)));
+
+ final Dimension2D dimWeat1 = west1.calculateDimension(ug.getStringBounder());
+ west1.drawU(ug.apply(new UTranslate(-dimWeat1.getWidth(), -dimWeat1.getHeight() + Diamond.diamondHalfSize)));
+
+ final Dimension2D dimEast1 = east1.calculateDimension(ug.getStringBounder());
+ east1.drawU(ug.apply(new UTranslate(Diamond.diamondHalfSize * 2, -dimEast1.getHeight()
+ + Diamond.diamondHalfSize)));
+ }
+
+ public FtileGeometry calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dim = new Dimension2DDouble(Diamond.diamondHalfSize * 2, Diamond.diamondHalfSize * 2);
+ return new FtileGeometry(dim, dim.getWidth() / 2, 0, dim.getHeight());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondFoo1.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondFoo1.java
new file mode 100644
index 0000000..6e9ad81
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondFoo1.java
@@ -0,0 +1,147 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile.vertical;
+
+import java.awt.geom.Dimension2D;
+import java.util.Collections;
+import java.util.Set;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Diamond;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class FtileDiamondFoo1 extends AbstractFtile {
+
+ private final HtmlColor backColor;
+ private final HtmlColor borderColor;
+ private final Swimlane swimlane;
+ private final TextBlock label;
+ private final TextBlock west;
+ private final TextBlock east;
+ private final TextBlock north;
+
+ public FtileDiamondFoo1(boolean shadowing, HtmlColor backColor, HtmlColor borderColor, Swimlane swimlane,
+ TextBlock label) {
+ this(shadowing, backColor, borderColor, swimlane, label, TextBlockUtils.empty(0, 0),
+ TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0));
+ }
+
+ public FtileDiamondFoo1 withNorth(TextBlock north) {
+ return new FtileDiamondFoo1(shadowing(), backColor, borderColor, swimlane, label, north, west, east);
+ }
+
+ public FtileDiamondFoo1 withWest(TextBlock west) {
+ return new FtileDiamondFoo1(shadowing(), backColor, borderColor, swimlane, label, north, west, east);
+ }
+
+ public FtileDiamondFoo1 withEast(TextBlock east) {
+ return new FtileDiamondFoo1(shadowing(), backColor, borderColor, swimlane, label, north, west, east);
+ }
+
+ private FtileDiamondFoo1(boolean shadowing, HtmlColor backColor, HtmlColor borderColor, Swimlane swimlane,
+ TextBlock label, TextBlock north, TextBlock west, TextBlock east) {
+ super(shadowing);
+ this.backColor = backColor;
+ this.swimlane = swimlane;
+ this.borderColor = borderColor;
+ this.label = label;
+ this.west = west;
+ this.east = east;
+ this.north = north;
+ }
+
+ public Set<Swimlane> getSwimlanes() {
+ if (swimlane == null) {
+ return Collections.emptySet();
+ }
+ return Collections.singleton(swimlane);
+ }
+
+ public Swimlane getSwimlaneIn() {
+ return swimlane;
+ }
+
+ public Swimlane getSwimlaneOut() {
+ return swimlane;
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D dimLabel = label.calculateDimension(stringBounder);
+ final Dimension2D dimTotal = calculateDimensionInternal(stringBounder);
+ ug = ug.apply(new UChangeColor(borderColor)).apply(new UStroke(1.5)).apply(new UChangeBackColor(backColor));
+ ug.draw(Diamond.asPolygonFoo1(shadowing(), dimTotal.getWidth(), dimTotal.getHeight()));
+
+ north.drawU(ug.apply(new UTranslate(4 + dimTotal.getWidth() / 2, dimTotal.getHeight())));
+
+ final double lx = (dimTotal.getWidth() - dimLabel.getWidth()) / 2;
+ final double ly = (dimTotal.getHeight() - dimLabel.getHeight()) / 2;
+ label.drawU(ug.apply(new UTranslate(lx, ly)));
+
+ final Dimension2D dimWeat = west.calculateDimension(stringBounder);
+ west.drawU(ug.apply(new UTranslate(-dimWeat.getWidth(), -dimWeat.getHeight() + Diamond.diamondHalfSize)));
+
+ final Dimension2D dimEast = east.calculateDimension(stringBounder);
+ east.drawU(ug.apply(new UTranslate(dimTotal.getWidth(), -dimEast.getHeight() + Diamond.diamondHalfSize)));
+
+ }
+
+ public FtileGeometry calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dim = calculateDimensionInternal(stringBounder);
+ return new FtileGeometry(dim, dim.getWidth() / 2, 0, dim.getHeight());
+ }
+
+ private Dimension2D calculateDimensionInternal(StringBounder stringBounder) {
+ final Dimension2D dimLabel = label.calculateDimension(stringBounder);
+ if (dimLabel.getWidth() == 0 || dimLabel.getHeight() == 0) {
+ return new Dimension2DDouble(Diamond.diamondHalfSize * 2, Diamond.diamondHalfSize * 2);
+ }
+ Dimension2D result = dimLabel;
+ result = Dimension2DDouble.delta(result, Diamond.diamondHalfSize * 2, Diamond.diamondHalfSize * 2);
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondInside.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondInside.java
new file mode 100644
index 0000000..7374653
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondInside.java
@@ -0,0 +1,161 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile.vertical;
+
+import java.awt.geom.Dimension2D;
+import java.util.Collections;
+import java.util.Set;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Diamond;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class FtileDiamondInside extends AbstractFtile {
+
+ private final HtmlColor backColor;
+ private final HtmlColor borderColor;
+ private final Swimlane swimlane;
+ private final TextBlock label;
+ private final TextBlock west;
+ private final TextBlock east;
+ private final TextBlock north;
+ private final TextBlock south;
+
+ public FtileDiamondInside(boolean shadowing, HtmlColor backColor, HtmlColor borderColor, Swimlane swimlane,
+ TextBlock label) {
+ this(shadowing, backColor, borderColor, swimlane, label, TextBlockUtils.empty(0, 0),
+ TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0));
+ }
+
+ public FtileDiamondInside withNorth(TextBlock north) {
+ return new FtileDiamondInside(shadowing(), backColor, borderColor, swimlane, label, north, south, west, east);
+ }
+
+ public FtileDiamondInside withWest(TextBlock west) {
+ return new FtileDiamondInside(shadowing(), backColor, borderColor, swimlane, label, north, south, west, east);
+ }
+
+ public FtileDiamondInside withEast(TextBlock east) {
+ return new FtileDiamondInside(shadowing(), backColor, borderColor, swimlane, label, north, south, west, east);
+ }
+
+ public FtileDiamondInside withSouth(TextBlock south) {
+ return new FtileDiamondInside(shadowing(), backColor, borderColor, swimlane, label, north, south, west, east);
+ }
+
+ private FtileDiamondInside(boolean shadowing, HtmlColor backColor, HtmlColor borderColor, Swimlane swimlane,
+ TextBlock label, TextBlock north, TextBlock south, TextBlock west, TextBlock east) {
+ super(shadowing);
+ this.backColor = backColor;
+ this.swimlane = swimlane;
+ this.borderColor = borderColor;
+ this.label = label;
+ this.west = west;
+ this.east = east;
+ this.north = north;
+ this.south = south;
+ }
+
+ public Set<Swimlane> getSwimlanes() {
+ if (swimlane == null) {
+ return Collections.emptySet();
+ }
+ return Collections.singleton(swimlane);
+ }
+
+ public Swimlane getSwimlaneIn() {
+ return swimlane;
+ }
+
+ public Swimlane getSwimlaneOut() {
+ return swimlane;
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D dimLabel = label.calculateDimension(stringBounder);
+ final Dimension2D dimTotal = calculateDimensionAlone(stringBounder);
+ ug = ug.apply(new UChangeColor(borderColor)).apply(new UStroke(1.5)).apply(new UChangeBackColor(backColor));
+ ug.draw(Diamond.asPolygon(shadowing(), dimTotal.getWidth(), dimTotal.getHeight()));
+
+ north.drawU(ug.apply(new UTranslate(4 + dimTotal.getWidth() / 2, dimTotal.getHeight())));
+ south.drawU(ug.apply(new UTranslate(4 + dimTotal.getWidth() / 2, dimTotal.getHeight())));
+
+ final double lx = (dimTotal.getWidth() - dimLabel.getWidth()) / 2;
+ final double ly = (dimTotal.getHeight() - dimLabel.getHeight()) / 2;
+ label.drawU(ug.apply(new UTranslate(lx, ly)));
+
+ final Dimension2D dimWeat = west.calculateDimension(stringBounder);
+ west.drawU(ug.apply(new UTranslate(-dimWeat.getWidth(), -dimWeat.getHeight() + dimTotal.getHeight() / 2)));
+
+ final Dimension2D dimEast = east.calculateDimension(stringBounder);
+ east.drawU(ug.apply(new UTranslate(dimTotal.getWidth(), -dimEast.getHeight() + dimTotal.getHeight() / 2)));
+
+ }
+
+ public FtileGeometry calculateDimension(StringBounder stringBounder) {
+ Dimension2D dim = calculateDimensionAlone(stringBounder);
+ final Dimension2D dimNorth = north.calculateDimension(stringBounder);
+ final double northHeight = dimNorth.getHeight();
+ final double northWidth = dimNorth.getWidth();
+ dim = Dimension2DDouble.delta(dim, 0, northHeight);
+ return new FtileGeometry(dim, dim.getWidth() / 2, 0, dim.getHeight() - northHeight);
+ }
+
+ private FtileGeometry calculateDimensionAlone(StringBounder stringBounder) {
+ final Dimension2D dimLabel = label.calculateDimension(stringBounder);
+ final Dimension2D dim;
+ if (dimLabel.getWidth() == 0 || dimLabel.getHeight() == 0) {
+ dim = new Dimension2DDouble(Diamond.diamondHalfSize * 2, Diamond.diamondHalfSize * 2);
+ } else {
+ dim = Dimension2DDouble.delta(
+ Dimension2DDouble.atLeast(dimLabel, Diamond.diamondHalfSize * 2, Diamond.diamondHalfSize * 2),
+ Diamond.diamondHalfSize * 2, 0);
+ }
+ return new FtileGeometry(dim, dim.getWidth() / 2, 0, dim.getHeight());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondInside2.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondInside2.java
new file mode 100644
index 0000000..4affeed
--- /dev/null
+++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vertical/FtileDiamondInside2.java
@@ -0,0 +1,161 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.activitydiagram3.ftile.vertical;
+
+import java.awt.geom.Dimension2D;
+import java.util.Collections;
+import java.util.Set;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Diamond;
+import net.sourceforge.plantuml.activitydiagram3.ftile.FtileGeometry;
+import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class FtileDiamondInside2 extends AbstractFtile {
+
+ private final HtmlColor backColor;
+ private final HtmlColor borderColor;
+ private final Swimlane swimlane;
+ private final TextBlock label;
+ private final TextBlock west;
+ private final TextBlock east;
+ private final TextBlock north;
+ private final TextBlock south;
+
+ public FtileDiamondInside2(boolean shadowing, HtmlColor backColor, HtmlColor borderColor, Swimlane swimlane,
+ TextBlock label) {
+ this(shadowing, backColor, borderColor, swimlane, label, TextBlockUtils.empty(0, 0),
+ TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0));
+ }
+
+ public FtileDiamondInside2 withNorth(TextBlock north) {
+ return new FtileDiamondInside2(shadowing(), backColor, borderColor, swimlane, label, north, south, west, east);
+ }
+
+ public FtileDiamondInside2 withWest(TextBlock west) {
+ return new FtileDiamondInside2(shadowing(), backColor, borderColor, swimlane, label, north, south, west, east);
+ }
+
+ public FtileDiamondInside2 withEast(TextBlock east) {
+ return new FtileDiamondInside2(shadowing(), backColor, borderColor, swimlane, label, north, south, west, east);
+ }
+
+ public FtileDiamondInside2 withSouth(TextBlock south) {
+ return new FtileDiamondInside2(shadowing(), backColor, borderColor, swimlane, label, north, south, west, east);
+ }
+
+ private FtileDiamondInside2(boolean shadowing, HtmlColor backColor, HtmlColor borderColor, Swimlane swimlane,
+ TextBlock label, TextBlock north, TextBlock south, TextBlock west, TextBlock east) {
+ super(shadowing);
+ this.backColor = backColor;
+ this.swimlane = swimlane;
+ this.borderColor = borderColor;
+ this.label = label;
+ this.west = west;
+ this.east = east;
+ this.north = north;
+ this.south = south;
+ }
+
+ public Set<Swimlane> getSwimlanes() {
+ if (swimlane == null) {
+ return Collections.emptySet();
+ }
+ return Collections.singleton(swimlane);
+ }
+
+ public Swimlane getSwimlaneIn() {
+ return swimlane;
+ }
+
+ public Swimlane getSwimlaneOut() {
+ return swimlane;
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D dimLabel = label.calculateDimension(stringBounder);
+ final Dimension2D dimTotal = calculateDimensionAlone(stringBounder);
+ ug = ug.apply(new UChangeColor(borderColor)).apply(new UStroke(1.5)).apply(new UChangeBackColor(backColor));
+ ug.draw(Diamond.asPolygon(shadowing(), dimTotal.getWidth(), dimTotal.getHeight()));
+
+ north.drawU(ug.apply(new UTranslate(4 + dimTotal.getWidth() / 2, dimTotal.getHeight())));
+ south.drawU(ug.apply(new UTranslate(4 + dimTotal.getWidth() / 2, dimTotal.getHeight())));
+
+ final double lx = (dimTotal.getWidth() - dimLabel.getWidth()) / 2;
+ final double ly = (dimTotal.getHeight() - dimLabel.getHeight()) / 2;
+ label.drawU(ug.apply(new UTranslate(lx, ly)));
+
+ final Dimension2D dimWeat = west.calculateDimension(stringBounder);
+ west.drawU(ug.apply(new UTranslate(-dimWeat.getWidth(), -dimWeat.getHeight() + dimTotal.getHeight() / 2)));
+
+ final Dimension2D dimEast = east.calculateDimension(stringBounder);
+ east.drawU(ug.apply(new UTranslate(dimTotal.getWidth(), -dimEast.getHeight() + dimTotal.getHeight() / 2)));
+
+ }
+
+ public FtileGeometry calculateDimension(StringBounder stringBounder) {
+ final Dimension2D diamond = calculateDimensionAlone(stringBounder);
+ final Dimension2D north = this.north.calculateDimension(stringBounder);
+ final double height = diamond.getHeight() + north.getHeight();
+ final double left = diamond.getWidth() / 2;
+ final double width = north.getWidth() > left ? left + north.getWidth() : diamond.getWidth();
+ return new FtileGeometry(width, height, left, 0, diamond.getHeight());
+ }
+
+ private FtileGeometry calculateDimensionAlone(StringBounder stringBounder) {
+ final Dimension2D dimLabel = label.calculateDimension(stringBounder);
+ final Dimension2D dim;
+ if (dimLabel.getWidth() == 0 || dimLabel.getHeight() == 0) {
+ dim = new Dimension2DDouble(Diamond.diamondHalfSize * 2, Diamond.diamondHalfSize * 2);
+ } else {
+ dim = Dimension2DDouble.delta(
+ Dimension2DDouble.atLeast(dimLabel, Diamond.diamondHalfSize * 2, Diamond.diamondHalfSize * 2),
+ Diamond.diamondHalfSize * 2, 0);
+ }
+ return new FtileGeometry(dim, dim.getWidth() / 2, 0, dim.getHeight());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/anim/AffineTransformation.java b/src/net/sourceforge/plantuml/anim/AffineTransformation.java
new file mode 100644
index 0000000..3a8cdfb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/anim/AffineTransformation.java
@@ -0,0 +1,153 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.anim;
+
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.util.StringTokenizer;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.ugraphic.MinMax;
+
+public class AffineTransformation {
+
+ static private final Pattern rotate = Pattern.compile("rotate\\s+(-?\\d+\\.?\\d*)");
+ static private final Pattern shear = Pattern.compile("shear\\s+(-?\\d+\\.?\\d*)\\s+(-?\\d+\\.?\\d*)");
+ static private final Pattern translate = Pattern.compile("translate\\s+(-?\\d+\\.?\\d*)\\s+(-?\\d+\\.?\\d*)");
+ static private final Pattern scale = Pattern.compile("scale\\s+(-?\\d+\\.?\\d*)\\s+(-?\\d+\\.?\\d*)");
+ static private final Pattern color = Pattern.compile("color\\s+.*");
+
+ private final AffineTransform affineTransform;
+ private Dimension2D dimension;
+
+ private AffineTransformation(AffineTransform affineTransform) {
+ this.affineTransform = affineTransform;
+ if (affineTransform == null) {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ private AffineTransformation compose(AffineTransformation other) {
+ final AffineTransform tmp = new AffineTransform(this.affineTransform);
+ tmp.concatenate(other.affineTransform);
+ return new AffineTransformation(tmp);
+ }
+
+ public static AffineTransformation from(AffineTransform affineTransform) {
+ return new AffineTransformation(affineTransform);
+ }
+
+ static AffineTransformation create(String value) {
+ final StringTokenizer st = new StringTokenizer(value, "|");
+ AffineTransformation result = null;
+ while (st.hasMoreTokens()) {
+ final String s = st.nextToken();
+ final AffineTransformation tmp = createSimple(s);
+ if (tmp != null) {
+ if (result == null) {
+ result = tmp;
+ } else {
+ result = result.compose(tmp);
+ }
+ }
+ }
+ return result;
+ }
+
+ private static AffineTransformation createSimple(String value) {
+ Matcher m = rotate.matcher(value.trim());
+ if (m.find()) {
+ final double angle = Double.parseDouble(m.group(1));
+ return new AffineTransformation(AffineTransform.getRotateInstance(angle * Math.PI / 180.0));
+ }
+ m = shear.matcher(value);
+ if (m.find()) {
+ final double shx = Double.parseDouble(m.group(1));
+ final double shy = Double.parseDouble(m.group(2));
+ return new AffineTransformation(AffineTransform.getShearInstance(shx, shy));
+ }
+ m = translate.matcher(value);
+ if (m.find()) {
+ final double tx = Double.parseDouble(m.group(1));
+ final double ty = Double.parseDouble(m.group(2));
+ return new AffineTransformation(AffineTransform.getTranslateInstance(tx, ty));
+ }
+ m = scale.matcher(value);
+ if (m.find()) {
+ final double scalex = Double.parseDouble(m.group(1));
+ final double scaley = Double.parseDouble(m.group(2));
+ return new AffineTransformation(AffineTransform.getScaleInstance(scalex, scaley));
+ }
+ m = color.matcher(value);
+ if (m.find()) {
+ return new AffineTransformation(new AffineTransform());
+ }
+ return null;
+ }
+
+ public final AffineTransform getAffineTransform() {
+ return getAffineTransform(dimension);
+ }
+
+ private AffineTransform getAffineTransform(Dimension2D dimension) {
+ if (dimension == null) {
+ throw new IllegalStateException();
+ }
+ final AffineTransform at = AffineTransform.getTranslateInstance(dimension.getWidth() / 2,
+ dimension.getHeight() / 2);
+ at.concatenate(affineTransform);
+ at.translate(-dimension.getWidth() / 2, -dimension.getHeight() / 2);
+
+ return at;
+ }
+
+ public void setDimension(Dimension2D dim) {
+ this.dimension = dim;
+
+ }
+
+ public MinMax getMinMax(Dimension2D rect) {
+ MinMax result = MinMax.getEmpty(false);
+ final AffineTransform tmp = getAffineTransform(rect);
+ result = result.addPoint(tmp.transform(new Point2D.Double(0, 0), null));
+ result = result.addPoint(tmp.transform(new Point2D.Double(0, rect.getHeight()), null));
+ result = result.addPoint(tmp.transform(new Point2D.Double(rect.getWidth(), 0), null));
+ result = result.addPoint(tmp.transform(new Point2D.Double(rect.getWidth(), rect.getHeight()), null));
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/anim/Animation.java b/src/net/sourceforge/plantuml/anim/Animation.java
new file mode 100644
index 0000000..bbefe32
--- /dev/null
+++ b/src/net/sourceforge/plantuml/anim/Animation.java
@@ -0,0 +1,98 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.anim;
+
+import java.awt.geom.Dimension2D;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import net.sourceforge.plantuml.ugraphic.MinMax;
+
+public class Animation {
+
+ private final List<AffineTransformation> all;
+
+ private Animation(List<AffineTransformation> all) {
+ if (all.size() == 0) {
+ throw new IllegalArgumentException();
+ }
+ this.all = all;
+ }
+
+ public static Animation singleton(AffineTransformation affineTransformation) {
+ if (affineTransformation == null) {
+ return null;
+ }
+ return new Animation(Collections.singletonList(affineTransformation));
+ }
+
+ public static Animation create(List<String> descriptions) {
+ final List<AffineTransformation> all = new ArrayList<AffineTransformation>();
+ for (String s : descriptions) {
+ final AffineTransformation tmp = AffineTransformation.create(s);
+ if (tmp != null) {
+ all.add(tmp);
+ }
+ }
+ return new Animation(all);
+ }
+
+ public Collection<AffineTransformation> getAll() {
+ return Collections.unmodifiableCollection(all);
+ }
+
+ public void setDimension(Dimension2D dim) {
+ for (AffineTransformation affineTransform : all) {
+ affineTransform.setDimension(dim);
+ }
+
+ }
+
+ public AffineTransformation getFirst() {
+ return all.get(0);
+ }
+
+ public MinMax getMinMax(Dimension2D dim) {
+ MinMax result = MinMax.getEmpty(false);
+ for (AffineTransformation affineTransform : all) {
+ final MinMax m = affineTransform.getMinMax(dim);
+ result = result.addMinMax(m);
+ }
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/anim/AnimationDecoder.java b/src/net/sourceforge/plantuml/anim/AnimationDecoder.java
new file mode 100644
index 0000000..61273cc
--- /dev/null
+++ b/src/net/sourceforge/plantuml/anim/AnimationDecoder.java
@@ -0,0 +1,78 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.anim;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import javax.script.ScriptException;
+
+public class AnimationDecoder {
+
+ private final List<String> result = new ArrayList<String>();
+
+ public AnimationDecoder(List<String> data) throws ScriptException {
+ for (int i = 0; i < data.size(); i++) {
+ String line = data.get(i);
+ if (line.matches("^\\s*\\[script\\]\\s*$")) {
+ final StringBuilder scriptText = new StringBuilder();
+ while (true) {
+ i++;
+ line = data.get(i);
+ if (line.matches("^\\s*\\[/script\\]\\s*$")) {
+ final AnimationScript script = new AnimationScript();
+ final String out = script.eval(scriptText.toString());
+ for (final StringTokenizer st = new StringTokenizer(out, "\n"); st.hasMoreTokens();) {
+ result.add(st.nextToken());
+ }
+ break;
+ } else {
+ scriptText.append(line);
+ scriptText.append("\n");
+ }
+ }
+ } else {
+ result.add(line);
+ }
+ }
+ }
+
+ public List<String> decode() {
+ return Collections.unmodifiableList(result);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/anim/AnimationScript.java b/src/net/sourceforge/plantuml/anim/AnimationScript.java
new file mode 100644
index 0000000..04e712c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/anim/AnimationScript.java
@@ -0,0 +1,77 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.anim;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+import javax.script.ScriptContext;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+
+public class AnimationScript {
+
+ private final ScriptEngine engine;
+
+ public AnimationScript() {
+
+ final ScriptEngineManager manager = new ScriptEngineManager();
+ engine = manager.getEngineByName("js");
+
+ // ScriptEngineManager manager = new ScriptEngineManager();
+ // List<ScriptEngineFactory> factories = manager.getEngineFactories();
+ // for (ScriptEngineFactory factory : factories) {
+ // System.out.println("Name : " + factory.getEngineName());
+ // System.out.println("Version : " + factory.getEngineVersion());
+ // System.out.println("Language name : " + factory.getLanguageName());
+ // System.out.println("Language version : " + factory.getLanguageVersion());
+ // System.out.println("Extensions : " + factory.getExtensions());
+ // System.out.println("Mime types : " + factory.getMimeTypes());
+ // System.out.println("Names : " + factory.getNames());
+ //
+ // }
+
+ }
+
+ public String eval(String line) throws ScriptException {
+ final ScriptContext context = engine.getContext();
+ final StringWriter sw = new StringWriter();
+ context.setWriter(new PrintWriter(sw));
+ engine.eval(line, context);
+ final String result = sw.toString();
+ return result;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ant/PlantUmlTask.java b/src/net/sourceforge/plantuml/ant/PlantUmlTask.java
new file mode 100644
index 0000000..a68cfbd
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ant/PlantUmlTask.java
@@ -0,0 +1,363 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ant;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import net.sourceforge.plantuml.FileFormat;
+import net.sourceforge.plantuml.GeneratedImage;
+import net.sourceforge.plantuml.Option;
+import net.sourceforge.plantuml.OptionFlags;
+import net.sourceforge.plantuml.SourceFileReader;
+import net.sourceforge.plantuml.preproc.Defines;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.DirectoryScanner;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.types.FileList;
+import org.apache.tools.ant.types.FileSet;
+
+// <?xml version="1.0"?>
+//
+// <project name="OwnTaskExample" default="main" basedir=".">
+// <taskdef name="plot" classname="plot.PlotTask" classpath="build"/>
+//
+// <target name="main">
+// <mytask message="Hello World! MyVeryOwnTask works!"/>
+// </target>
+// </project>
+
+// Carriage Return in UTF-8 XML: &#13;
+// Line Feed in UTF-8 XML: &#10;
+public class PlantUmlTask extends Task {
+
+ private String dir = null;
+ private final Option option = new Option();
+ private List<FileSet> filesets = new ArrayList<FileSet>();
+ private List<FileList> filelists = new ArrayList<FileList>();
+ private AtomicInteger nbFiles = new AtomicInteger(0);
+ private ExecutorService executorService;
+
+ /**
+ * Add a set of files to touch
+ */
+ public void addFileset(FileSet set) {
+ filesets.add(set);
+ }
+
+ /**
+ * Add a filelist to touch
+ */
+ public void addFilelist(FileList list) {
+ filelists.add(list);
+ }
+
+ // The method executing the task
+ @Override
+ public void execute() throws BuildException {
+
+ this.log("Starting PlantUML");
+
+ try {
+ if (dir != null) {
+ final File error = processingSingleDirectory(new File(dir));
+ eventuallyFailfast(error);
+ }
+ for (FileSet fileSet : filesets) {
+ final File error = manageFileSet(fileSet);
+ eventuallyFailfast(error);
+ }
+ for (FileList fileList : filelists) {
+ final File error = manageFileList(fileList);
+ eventuallyFailfast(error);
+ }
+ if (executorService != null) {
+ executorService.shutdown();
+ executorService.awaitTermination(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
+ }
+ this.log("Nb images generated: " + nbFiles.get());
+ } catch (IOException e) {
+ e.printStackTrace();
+ throw new BuildException(e.toString());
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ throw new BuildException(e.toString());
+ }
+
+ }
+
+ private void eventuallyFailfast(final File error) throws IOException {
+ if (error != null && option.isFailfastOrFailfast2()) {
+ this.log("Error in file " + error.getCanonicalPath());
+ throw new BuildException("Error in file " + error.getCanonicalPath());
+ }
+ }
+
+ private File manageFileList(FileList fl) throws IOException, InterruptedException {
+ final File fromDir = fl.getDir(getProject());
+
+ final String[] srcFiles = fl.getFiles(getProject());
+
+ for (String src : srcFiles) {
+ final File f = new File(fromDir, src);
+ final boolean error = processingSingleFile(f);
+ if (error) {
+ return f;
+ }
+ }
+ return null;
+ }
+
+ private File manageFileSet(FileSet fs) throws IOException, InterruptedException {
+ final DirectoryScanner ds = fs.getDirectoryScanner(getProject());
+ final File fromDir = fs.getDir(getProject());
+
+ final String[] srcFiles = ds.getIncludedFiles();
+ final String[] srcDirs = ds.getIncludedDirectories();
+
+ for (String src : srcFiles) {
+ final File f = new File(fromDir, src);
+ final boolean error = processingSingleFile(f);
+ if (error) {
+ return f;
+ }
+ }
+
+ for (String src : srcDirs) {
+ final File dir = new File(fromDir, src);
+ final File errorFile = processingSingleDirectory(dir);
+ if (errorFile != null) {
+ return errorFile;
+ }
+ }
+ return null;
+
+ }
+
+ private boolean processingSingleFile(final File f) throws IOException, InterruptedException {
+ if (OptionFlags.getInstance().isVerbose()) {
+ this.log("Processing " + f.getAbsolutePath());
+ }
+ final SourceFileReader sourceFileReader = new SourceFileReader(new Defines(), f, option.getOutputDir(),
+ option.getConfig(), option.getCharset(), option.getFileFormatOption());
+
+ if (option.isCheckOnly()) {
+ return sourceFileReader.hasError();
+ }
+ if (executorService == null) {
+ return doFile(f, sourceFileReader);
+ }
+
+ executorService.submit(new Callable<Boolean>() {
+ public Boolean call() throws Exception {
+ return doFile(f, sourceFileReader);
+ }
+ });
+
+ return false;
+ }
+
+ private boolean doFile(final File f, final SourceFileReader sourceFileReader) throws IOException,
+ InterruptedException {
+ final Collection<GeneratedImage> result = sourceFileReader.getGeneratedImages();
+ boolean error = false;
+ for (GeneratedImage g : result) {
+ if (OptionFlags.getInstance().isVerbose()) {
+ myLog(g + " " + g.getDescription());
+ }
+ nbFiles.addAndGet(1);
+ if (g.lineErrorRaw() != -1) {
+ error = true;
+ }
+ }
+ if (error) {
+ myLog("Error: " + f.getCanonicalPath());
+ }
+ if (error && option.isFailfastOrFailfast2()) {
+ return true;
+ }
+ return false;
+ }
+
+ private synchronized void myLog(String s) {
+ this.log(s);
+ }
+
+ private File processingSingleDirectory(File dir) throws IOException, InterruptedException {
+ if (dir.exists() == false) {
+ final String s = "The file " + dir.getAbsolutePath() + " does not exists.";
+ this.log(s);
+ throw new BuildException(s);
+ }
+ for (File f : dir.listFiles()) {
+ if (f.isFile() == false) {
+ continue;
+ }
+ if (fileToProcess(f.getName()) == false) {
+ continue;
+ }
+ final boolean error = processingSingleFile(f);
+ if (error) {
+ return f;
+ }
+ }
+ return null;
+ }
+
+ private boolean fileToProcess(String name) {
+ return name.matches(Option.getPattern());
+ }
+
+ public void setDir(String s) {
+ this.dir = s;
+ }
+
+ public void setOutput(String s) {
+ option.setOutputDir(new File(s));
+ }
+
+ public void setCharset(String s) {
+ option.setCharset(s);
+ }
+
+ public void setConfig(String s) {
+ try {
+ option.initConfig(s);
+ } catch (IOException e) {
+ log("Error reading " + s);
+ }
+ }
+
+ public void setKeepTmpFiles(String s) {
+ if ("true".equalsIgnoreCase(s)) {
+ OptionFlags.getInstance().setKeepTmpFiles(true);
+ }
+ }
+
+ public void setVerbose(String s) {
+ if ("true".equalsIgnoreCase(s)) {
+ OptionFlags.getInstance().setVerbose(true);
+ }
+ }
+
+ public void setFormat(String s) {
+ if ("xmi".equalsIgnoreCase(s)) {
+ option.setFileFormat(FileFormat.XMI_STANDARD);
+ }
+ if ("xmi:argo".equalsIgnoreCase(s)) {
+ option.setFileFormat(FileFormat.XMI_ARGO);
+ }
+ if ("xmi:start".equalsIgnoreCase(s)) {
+ option.setFileFormat(FileFormat.XMI_STAR);
+ }
+ if ("eps".equalsIgnoreCase(s)) {
+ option.setFileFormat(FileFormat.EPS);
+ }
+ if ("pdf".equalsIgnoreCase(s)) {
+ option.setFileFormat(FileFormat.PDF);
+ }
+ if ("latex".equalsIgnoreCase(s)) {
+ option.setFileFormat(FileFormat.LATEX);
+ }
+ if ("eps:text".equalsIgnoreCase(s)) {
+ option.setFileFormat(FileFormat.EPS_TEXT);
+ }
+ if ("svg".equalsIgnoreCase(s)) {
+ option.setFileFormat(FileFormat.SVG);
+ }
+ if ("txt".equalsIgnoreCase(s)) {
+ option.setFileFormat(FileFormat.ATXT);
+ }
+ if ("utxt".equalsIgnoreCase(s)) {
+ option.setFileFormat(FileFormat.UTXT);
+ }
+ }
+
+ public void setGraphvizDot(String s) {
+ OptionFlags.getInstance().setDotExecutable(s);
+ }
+
+ public void setNbThread(String s) {
+ if (s != null && s.matches("\\d+")) {
+ option.setNbThreads(Integer.parseInt(s));
+ final int nbThreads = option.getNbThreads();
+ this.executorService = Executors.newFixedThreadPool(nbThreads);
+ }
+ if ("auto".equalsIgnoreCase(s)) {
+ option.setNbThreads(Option.defaultNbThreads());
+ final int nbThreads = option.getNbThreads();
+ this.executorService = Executors.newFixedThreadPool(nbThreads);
+ }
+ }
+
+ public void setNbThreads(String s) {
+ setNbThread(s);
+ }
+
+ public void setSuggestEngine(String s) {
+ OptionFlags.getInstance().setUseSuggestEngine(
+ "true".equalsIgnoreCase(s) || "yes".equalsIgnoreCase(s) || "on".equalsIgnoreCase(s));
+ }
+
+ public void setFailFast(String s) {
+ final boolean flag = "true".equalsIgnoreCase(s) || "yes".equalsIgnoreCase(s) || "on".equalsIgnoreCase(s);
+ option.setFailfast(flag);
+ }
+
+ public void setFailFast2(String s) {
+ final boolean flag = "true".equalsIgnoreCase(s) || "yes".equalsIgnoreCase(s) || "on".equalsIgnoreCase(s);
+ option.setFailfast2(flag);
+ }
+
+ public void setCheckOnly(String s) {
+ final boolean flag = "true".equalsIgnoreCase(s) || "yes".equalsIgnoreCase(s) || "on".equalsIgnoreCase(s);
+ option.setCheckOnly(flag);
+ }
+
+ public void setOverwrite(String s) {
+ final boolean flag = "true".equalsIgnoreCase(s) || "yes".equalsIgnoreCase(s) || "on".equalsIgnoreCase(s);
+ OptionFlags.getInstance().setOverwrite(flag);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/api/CountRate.java b/src/net/sourceforge/plantuml/api/CountRate.java
new file mode 100644
index 0000000..cc2ac43
--- /dev/null
+++ b/src/net/sourceforge/plantuml/api/CountRate.java
@@ -0,0 +1,81 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.api;
+
+public final class CountRate {
+
+ private final MagicArray lastMinute = new MagicArray(60);
+ private final MagicArray lastHour = new MagicArray(60);
+ private final MagicArray lastDay = new MagicArray(140);
+
+ public void increment() {
+ final long now = System.currentTimeMillis();
+ lastMinute.incKey(now / 1000L);
+ lastHour.incKey(now / (60 * 1000L));
+ lastDay.incKey(now / (10 * 60 * 1000L));
+ }
+
+ public void increment(int value) {
+ final long now = System.currentTimeMillis();
+ lastMinute.incKey(now / 1000L, value);
+ lastHour.incKey(now / (60 * 1000L), value);
+ lastDay.incKey(now / (10 * 60 * 1000L), value);
+ }
+
+ public long perMinute() {
+ return lastMinute.getSum();
+ }
+
+ public long perHour() {
+ return lastHour.getSum();
+ }
+
+ public long perDay() {
+ return lastDay.getSum();
+ }
+
+ public long perMinuteMax() {
+ return lastMinute.getMaxSum();
+ }
+
+ public long perHourMax() {
+ return lastHour.getMaxSum();
+ }
+
+ public long perDayMax() {
+ return lastDay.getMaxSum();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/api/INumberAnalyzed.java b/src/net/sourceforge/plantuml/api/INumberAnalyzed.java
new file mode 100644
index 0000000..93370be
--- /dev/null
+++ b/src/net/sourceforge/plantuml/api/INumberAnalyzed.java
@@ -0,0 +1,49 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.api;
+
+public interface INumberAnalyzed {
+
+ public int getNb();
+
+ public int getSum();
+
+ public int getMin();
+
+ public int getMax();
+
+ public int getMean();
+
+}
diff --git a/src/net/sourceforge/plantuml/api/ImageDataComplex.java b/src/net/sourceforge/plantuml/api/ImageDataComplex.java
new file mode 100644
index 0000000..612ce03
--- /dev/null
+++ b/src/net/sourceforge/plantuml/api/ImageDataComplex.java
@@ -0,0 +1,81 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.api;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.CMapData;
+import net.sourceforge.plantuml.core.ImageData;
+
+public class ImageDataComplex implements ImageData {
+
+ private final Dimension2D info;
+ private final CMapData cmap;
+ private final String warningOrError;
+
+// public ImageDataComplex(Dimension2D info, CMapData cmap) {
+// this(info, cmap, null);
+// }
+
+ public ImageDataComplex(Dimension2D info, CMapData cmap, String warningOrError) {
+ if (info==null) {
+ throw new IllegalArgumentException();
+ }
+ this.info = info;
+ this.cmap = cmap;
+ this.warningOrError = warningOrError;
+ }
+
+ public int getWidth() {
+ return (int) info.getWidth();
+ }
+
+ public int getHeight() {
+ return (int) info.getHeight();
+ }
+
+ public boolean containsCMapData() {
+ return cmap != null && cmap.containsData();
+ }
+
+ public String getCMapData(String nameId) {
+ return cmap.asString(nameId);
+ }
+
+ public String getWarningOrError() {
+ return warningOrError;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/api/ImageDataSimple.java b/src/net/sourceforge/plantuml/api/ImageDataSimple.java
new file mode 100644
index 0000000..6c556ce
--- /dev/null
+++ b/src/net/sourceforge/plantuml/api/ImageDataSimple.java
@@ -0,0 +1,79 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.api;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.core.ImageData;
+
+public class ImageDataSimple implements ImageData {
+
+ private final int width;
+ private final int height;
+
+ public ImageDataSimple(int width, int height) {
+ this.width = width;
+ this.height = height;
+ }
+
+ public ImageDataSimple() {
+ this(0, 0);
+ }
+
+ public ImageDataSimple(Dimension2D dim) {
+ this((int) dim.getWidth(), (int) dim.getHeight());
+ }
+
+ public int getWidth() {
+ return width;
+ }
+
+ public int getHeight() {
+ return height;
+ }
+
+ public boolean containsCMapData() {
+ return false;
+ }
+
+ public String getCMapData(String nameId) {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getWarningOrError() {
+ return null;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/api/MagicArray.java b/src/net/sourceforge/plantuml/api/MagicArray.java
new file mode 100644
index 0000000..d2f4437
--- /dev/null
+++ b/src/net/sourceforge/plantuml/api/MagicArray.java
@@ -0,0 +1,97 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.api;
+
+public final class MagicArray {
+
+ private final int data[];
+ private final int size;
+ private long lastUpdatedKey = -1;
+ private int lastUpdatedValue;
+ private long sum;
+ private long maxSum;
+
+ public MagicArray(int size) {
+ this.data = new int[size];
+ this.size = size;
+ }
+
+ synchronized public void incKey(long key) {
+ incKey(key, 1);
+ }
+
+ synchronized public void incKey(long key, int delta) {
+ if (key < lastUpdatedKey) {
+ return;
+ }
+ if (key != lastUpdatedKey) {
+ if (lastUpdatedKey != -1) {
+ setValue(lastUpdatedKey, lastUpdatedValue);
+ for (long i = lastUpdatedKey + 1; i < key; i++) {
+ setValue(i, 0);
+ }
+ }
+ lastUpdatedValue = 0;
+ lastUpdatedKey = key;
+ }
+ lastUpdatedValue += delta;
+ }
+
+ private void setValue(long key, int value) {
+ final int i = (int) (key % size);
+ sum += value - data[i];
+ if (sum > maxSum) {
+ maxSum = sum;
+ }
+ data[i] = value;
+ }
+
+ synchronized public long getSum() {
+ return sum;
+ }
+
+ synchronized public long getMaxSum() {
+ return maxSum;
+ }
+
+ private long getSumSlow() {
+ long tmp = 0;
+ for (int d : data) {
+ tmp += d;
+ }
+ return tmp;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/api/MyRunnable.java b/src/net/sourceforge/plantuml/api/MyRunnable.java
new file mode 100644
index 0000000..a8d3111
--- /dev/null
+++ b/src/net/sourceforge/plantuml/api/MyRunnable.java
@@ -0,0 +1,42 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.api;
+
+public interface MyRunnable {
+
+ public void runJob() throws InterruptedException;
+
+ public void cancelJob();
+}
diff --git a/src/net/sourceforge/plantuml/api/NiceNumber.java b/src/net/sourceforge/plantuml/api/NiceNumber.java
new file mode 100644
index 0000000..5b0a23a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/api/NiceNumber.java
@@ -0,0 +1,70 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.api;
+
+import java.text.DecimalFormat;
+import java.text.DecimalFormatSymbols;
+import java.util.Locale;
+
+public class NiceNumber {
+
+ public static int getNicer(final int value) {
+ if (value <= 18) {
+ return value;
+ }
+ if (value < 93) {
+ return ((value + 2) / 5) * 5;
+ }
+ if (value < 100) {
+ return ((value + 5) / 10) * 10;
+ }
+ int m = 1;
+ double head = value;
+ while (head >= 100) {
+ head = head / 10.0;
+ m *= 10;
+ }
+ return getNicer((int) Math.round(head)) * m;
+ }
+
+ public static String format(final long v) {
+ final DecimalFormat df = new DecimalFormat();
+ df.setDecimalFormatSymbols(new DecimalFormatSymbols(Locale.US));
+ df.setGroupingSize(3);
+ df.setMaximumFractionDigits(0);
+ final String t = df.format(v).replace(',', ' ');
+ return t;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/api/NumberAnalyzed.java b/src/net/sourceforge/plantuml/api/NumberAnalyzed.java
new file mode 100644
index 0000000..9ad2692
--- /dev/null
+++ b/src/net/sourceforge/plantuml/api/NumberAnalyzed.java
@@ -0,0 +1,100 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.api;
+
+public class NumberAnalyzed implements INumberAnalyzed {
+
+ private int nb;
+ private int sum;
+ private int min;
+ private int max;
+
+ public NumberAnalyzed() {
+
+ }
+
+ private NumberAnalyzed(int nb, int sum, int min, int max) {
+ this.nb = nb;
+ this.sum = sum;
+ this.min = min;
+ this.max = max;
+ }
+
+ public synchronized INumberAnalyzed getCopyImmutable() {
+ final NumberAnalyzed copy = new NumberAnalyzed(nb, sum, min, max);
+ return copy;
+ }
+
+ public synchronized void addValue(int v) {
+ nb++;
+ if (nb == 1) {
+ sum = v;
+ min = v;
+ max = v;
+ return;
+ }
+ sum += v;
+ if (v > max) {
+ max = v;
+ }
+ if (v < min) {
+ min = v;
+ }
+ }
+
+ synchronized public final int getNb() {
+ return nb;
+ }
+
+ synchronized public final int getSum() {
+ return sum;
+ }
+
+ synchronized public final int getMin() {
+ return min;
+ }
+
+ synchronized public final int getMax() {
+ return max;
+ }
+
+ synchronized public final int getMean() {
+ if (nb == 0) {
+ return 0;
+ }
+ return sum / nb;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/api/PSystemFactory.java b/src/net/sourceforge/plantuml/api/PSystemFactory.java
new file mode 100644
index 0000000..9b919e9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/api/PSystemFactory.java
@@ -0,0 +1,47 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.api;
+
+import net.sourceforge.plantuml.core.Diagram;
+import net.sourceforge.plantuml.core.DiagramType;
+import net.sourceforge.plantuml.core.UmlSource;
+
+public interface PSystemFactory {
+
+ Diagram createSystem(UmlSource source);
+
+ DiagramType getDiagramType();
+
+}
diff --git a/src/net/sourceforge/plantuml/api/PlantumlUtils.java b/src/net/sourceforge/plantuml/api/PlantumlUtils.java
new file mode 100644
index 0000000..832cced
--- /dev/null
+++ b/src/net/sourceforge/plantuml/api/PlantumlUtils.java
@@ -0,0 +1,59 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.api;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.BlockUml;
+import net.sourceforge.plantuml.SourceStringReader;
+import net.sourceforge.plantuml.core.Diagram;
+
+public class PlantumlUtils {
+
+ public static boolean hasCMapData(String uml) {
+ List<BlockUml> blocks = new SourceStringReader(uml).getBlocks();
+ if (blocks.size() == 0) {
+ uml = "@startuml\n" + uml + "\n@enduml";
+ blocks = new SourceStringReader(uml).getBlocks();
+ if (blocks.size() == 0) {
+ return false;
+ }
+ }
+ final BlockUml block = blocks.get(0);
+ final Diagram diagram = block.getDiagram();
+ return diagram.hasUrl();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/api/TimeoutExecutor.java b/src/net/sourceforge/plantuml/api/TimeoutExecutor.java
new file mode 100644
index 0000000..69393eb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/api/TimeoutExecutor.java
@@ -0,0 +1,87 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.api;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+
+public final class TimeoutExecutor {
+
+ private final long ms;
+
+ public TimeoutExecutor(long ms) {
+ this.ms = ms;
+ }
+
+ public boolean executeNow(MyRunnable task) {
+ final MyThread mainThread = new MyThread(task);
+ boolean done = false;
+ try {
+ mainThread.start();
+ mainThread.join(ms);
+ } catch (InterruptedException e) {
+ System.err.println("TimeoutExecutorA " + e);
+ e.printStackTrace();
+ return false;
+ } finally {
+ done = mainThread.done.get();
+ if (done == false) {
+ task.cancelJob();
+ mainThread.interrupt();
+ }
+ }
+ return done;
+ }
+
+ class MyThread extends Thread {
+ private final MyRunnable task;
+ private final AtomicBoolean done = new AtomicBoolean(false);
+
+ private MyThread(MyRunnable task) {
+ this.task = task;
+ }
+
+ @Override
+ public void run() {
+ try {
+ task.runJob();
+ done.set(true);
+ } catch (InterruptedException e) {
+ System.err.println("TimeoutExecutorB " + e);
+ e.printStackTrace();
+ }
+ }
+
+ }
+}
diff --git a/src/net/sourceforge/plantuml/api/mda/option2/MDADiagram.java b/src/net/sourceforge/plantuml/api/mda/option2/MDADiagram.java
new file mode 100644
index 0000000..733a2b6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/api/mda/option2/MDADiagram.java
@@ -0,0 +1,41 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.api.mda.option2;
+
+import java.util.Collection;
+
+public interface MDADiagram {
+ public Collection<MDAPackage> getPackages();
+}
diff --git a/src/net/sourceforge/plantuml/api/mda/option2/MDAEntity.java b/src/net/sourceforge/plantuml/api/mda/option2/MDAEntity.java
new file mode 100644
index 0000000..c1a7bce
--- /dev/null
+++ b/src/net/sourceforge/plantuml/api/mda/option2/MDAEntity.java
@@ -0,0 +1,40 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.api.mda.option2;
+
+public interface MDAEntity {
+ public String getName();
+
+}
diff --git a/src/net/sourceforge/plantuml/api/mda/option2/MDAPackage.java b/src/net/sourceforge/plantuml/api/mda/option2/MDAPackage.java
new file mode 100644
index 0000000..6c83901
--- /dev/null
+++ b/src/net/sourceforge/plantuml/api/mda/option2/MDAPackage.java
@@ -0,0 +1,45 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.api.mda.option2;
+
+import java.util.Collection;
+
+public interface MDAPackage {
+
+ public String getName();
+
+ public Collection<MDAEntity> getEntities();
+
+}
diff --git a/src/net/sourceforge/plantuml/api/mda/option2/MDAUtils.java b/src/net/sourceforge/plantuml/api/mda/option2/MDAUtils.java
new file mode 100644
index 0000000..e3b5bcc
--- /dev/null
+++ b/src/net/sourceforge/plantuml/api/mda/option2/MDAUtils.java
@@ -0,0 +1,44 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.api.mda.option2;
+
+import net.sourceforge.plantuml.mda.MDADiagramImpl;
+
+public class MDAUtils {
+
+ public static MDADiagram getMDADiagram(String plantumlDiagramSource) {
+ return MDADiagramImpl.create(plantumlDiagramSource);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/api/mda/option3/MDAVisitor.java b/src/net/sourceforge/plantuml/api/mda/option3/MDAVisitor.java
new file mode 100644
index 0000000..aa85dd3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/api/mda/option3/MDAVisitor.java
@@ -0,0 +1,38 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.api.mda.option3;
+
+public interface MDAVisitor {
+}
diff --git a/src/net/sourceforge/plantuml/applet/VersionApplet.java b/src/net/sourceforge/plantuml/applet/VersionApplet.java
new file mode 100644
index 0000000..69be09d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/applet/VersionApplet.java
@@ -0,0 +1,58 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.applet;
+
+import java.applet.Applet;
+import java.awt.Graphics;
+
+import net.sourceforge.plantuml.version.Version;
+
+public class VersionApplet extends Applet {
+
+ @Override
+ public void init() {
+ super.init();
+ }
+
+ @Override
+ public void start() {
+ super.start();
+ }
+
+ @Override
+ public void paint(Graphics g) {
+ g.drawString(Version.versionString(), 0, 10);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/asciiart/AbstractComponentText.java b/src/net/sourceforge/plantuml/asciiart/AbstractComponentText.java
new file mode 100644
index 0000000..2c8dd4a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/asciiart/AbstractComponentText.java
@@ -0,0 +1,51 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.asciiart;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.Component;
+
+public abstract class AbstractComponentText implements Component {
+
+ public final Dimension2D getPreferredDimension(StringBounder stringBounder) {
+ final double w = getPreferredWidth(stringBounder);
+ final double h = getPreferredHeight(stringBounder);
+ return new Dimension2DDouble(w, h);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/asciiart/BasicCharArea.java b/src/net/sourceforge/plantuml/asciiart/BasicCharArea.java
new file mode 100644
index 0000000..d6b4649
--- /dev/null
+++ b/src/net/sourceforge/plantuml/asciiart/BasicCharArea.java
@@ -0,0 +1,65 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.asciiart;
+
+import java.io.PrintStream;
+import java.util.List;
+
+public interface BasicCharArea {
+
+ int getWidth();
+
+ int getHeight();
+
+ void drawChar(char c, int x, int y);
+
+ void fillRect(char c, int x, int y, int width, int height);
+
+ void drawStringLR(String string, int x, int y);
+
+ void drawStringTB(String string, int x, int y);
+
+ String getLine(int line);
+
+ void print(PrintStream ps);
+
+ List<String> getLines();
+
+ void drawHLine(char c, int line, int col1, int col2);
+ void drawHLine(char c, int line, int col1, int col2, char ifFound, char thenUse);
+
+ void drawVLine(char c, int col, int line1, int line2);
+
+}
diff --git a/src/net/sourceforge/plantuml/asciiart/BasicCharAreaImpl.java b/src/net/sourceforge/plantuml/asciiart/BasicCharAreaImpl.java
new file mode 100644
index 0000000..1970aa4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/asciiart/BasicCharAreaImpl.java
@@ -0,0 +1,177 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.asciiart;
+
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public class BasicCharAreaImpl implements BasicCharArea {
+
+ private int charSize1 = 160;
+ private int charSize2 = 160;
+
+ private int width;
+ private int height;
+
+ private char chars[][];
+
+ public BasicCharAreaImpl() {
+ this.chars = new char[charSize1][charSize2];
+ for (int i = 0; i < charSize1; i++) {
+ for (int j = 0; j < charSize2; j++) {
+ chars[i][j] = ' ';
+ }
+ }
+ }
+
+ public final int getWidth() {
+ return width;
+ }
+
+ public final int getHeight() {
+ return height;
+ }
+
+ public void drawChar(char c, int x, int y) {
+ ensurePossible(x, y);
+ chars[x][y] = c;
+ if (x >= width) {
+ width = x + 1;
+ }
+ if (y >= height) {
+ height = y + 1;
+ }
+ }
+
+ private void ensurePossible(int x, int y) {
+ int newCharSize1 = charSize1;
+ int newCharSize2 = charSize2;
+ while (x >= newCharSize1) {
+ newCharSize1 *= 2;
+ }
+ while (y >= newCharSize2) {
+ newCharSize2 *= 2;
+ }
+ if (newCharSize1 != charSize1 || newCharSize2 != charSize2) {
+ final char newChars[][] = new char[newCharSize1][newCharSize2];
+ for (int i = 0; i < newCharSize1; i++) {
+ for (int j = 0; j < newCharSize2; j++) {
+ char c = ' ';
+ if (i < charSize1 && j < charSize2) {
+ c = chars[i][j];
+ }
+ newChars[i][j] = c;
+ }
+ }
+ this.chars = newChars;
+ this.charSize1 = newCharSize1;
+ this.charSize2 = newCharSize2;
+ }
+
+ }
+
+ public void drawStringLR(String string, int x, int y) {
+ for (int i = 0; i < string.length(); i++) {
+ drawChar(string.charAt(i), x + i, y);
+ }
+ }
+
+ public void drawStringTB(String string, int x, int y) {
+ for (int i = 0; i < string.length(); i++) {
+ drawChar(string.charAt(i), x, y + i);
+ }
+ }
+
+ public String getLine(int line) {
+ final StringBuilder sb = new StringBuilder(charSize1);
+ for (int x = 0; x < width; x++) {
+ sb.append(chars[x][line]);
+ }
+ return sb.toString();
+ }
+
+ public void print(PrintStream ps) {
+ for (String s : getLines()) {
+ ps.println(s);
+ }
+ }
+
+ public List<String> getLines() {
+ final List<String> result = new ArrayList<String>(height);
+ for (int y = 0; y < height; y++) {
+ result.add(getLine(y));
+ }
+ return Collections.unmodifiableList(result);
+ }
+
+ public void drawHLine(char c, int line, int col1, int col2) {
+ for (int x = col1; x < col2; x++) {
+ this.drawChar(c, x, line);
+ }
+ }
+
+ public void drawHLine(char c, int line, int col1, int col2, char ifFound, char thenUse) {
+ for (int x = col1; x < col2; x++) {
+ ensurePossible(x, line);
+ if (this.chars[x][line] == ifFound) {
+ this.drawChar(thenUse, x, line);
+ } else {
+ this.drawChar(c, x, line);
+ }
+ }
+ }
+
+ public void drawVLine(char c, int col, int line1, int line2) {
+ for (int y = line1; y < line2; y++) {
+ this.drawChar(c, col, y);
+ }
+ }
+
+ @Override
+ public String toString() {
+ return getLines().toString();
+ }
+
+ public void fillRect(char c, int x, int y, int width, int height) {
+ for (int i = 0; i < width; i++) {
+ for (int j = 0; j < height; j++) {
+ drawChar(c, x + i, y + j);
+ }
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/asciiart/ComponentTextActiveLine.java b/src/net/sourceforge/plantuml/asciiart/ComponentTextActiveLine.java
new file mode 100644
index 0000000..7ecd0ab
--- /dev/null
+++ b/src/net/sourceforge/plantuml/asciiart/ComponentTextActiveLine.java
@@ -0,0 +1,79 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.asciiart;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.FileFormat;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.txt.UGraphicTxt;
+
+public class ComponentTextActiveLine extends AbstractComponentText {
+
+ private final FileFormat fileFormat;
+
+ public ComponentTextActiveLine(FileFormat fileFormat) {
+ this.fileFormat = fileFormat;
+ }
+
+ public void drawU(UGraphic ug, Area area, Context2D context) {
+ final Dimension2D dimensionToUse = area.getDimensionToUse();
+ final UmlCharArea charArea = ((UGraphicTxt) ug).getCharArea();
+ final int width = (int) dimensionToUse.getWidth();
+ final int height = (int) dimensionToUse.getHeight();
+ if (fileFormat == FileFormat.UTXT) {
+ charArea.fillRect(' ', 0, 0, width, height);
+ charArea.drawBoxSimpleUnicode(0, 0, width, height);
+ charArea.drawChar('\u2534', width/2, 0);
+ charArea.drawChar('\u252c', width/2, height-1);
+ } else {
+ charArea.fillRect('X', 0, 0, width, height);
+ charArea.drawBoxSimple(0, 0, width, height);
+ }
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return 0;
+ }
+
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return 3;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/asciiart/ComponentTextActor.java b/src/net/sourceforge/plantuml/asciiart/ComponentTextActor.java
new file mode 100644
index 0000000..188fa0d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/asciiart/ComponentTextActor.java
@@ -0,0 +1,105 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.asciiart;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.FileFormat;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.txt.UGraphicTxt;
+import net.sourceforge.plantuml.StringUtils;
+
+public class ComponentTextActor extends AbstractComponentText {
+
+ private final ComponentType type;
+ private final Display stringsToDisplay;
+ private final FileFormat fileFormat;
+
+ public ComponentTextActor(ComponentType type, Display stringsToDisplay, FileFormat fileFormat) {
+ this.type = type;
+ this.stringsToDisplay = stringsToDisplay;
+ this.fileFormat = fileFormat;
+ }
+
+ public void drawU(UGraphic ug, Area area, Context2D context) {
+ final Dimension2D dimensionToUse = area.getDimensionToUse();
+ final UmlCharArea charArea = ((UGraphicTxt) ug).getCharArea();
+ final int width = (int) dimensionToUse.getWidth();
+ // final int textWidth = StringUtils.getWidth(stringsToDisplay);
+ final int height = (int) dimensionToUse.getHeight();
+ charArea.fillRect(' ', 0, 0, width, height);
+
+ final int xman = width / 2 - 1;
+ if (type == ComponentType.ACTOR_HEAD) {
+ charArea.drawStringsLR(stringsToDisplay.as(), 1, getStickManHeight());
+ if (fileFormat == FileFormat.UTXT) {
+ charArea.drawStickManUnicode(xman, 0);
+ } else {
+ charArea.drawStickMan(xman, 0);
+ }
+ } else if (type == ComponentType.ACTOR_TAIL) {
+ charArea.drawStringsLR(stringsToDisplay.as(), 1, 0);
+ if (fileFormat == FileFormat.UTXT) {
+ charArea.drawStickManUnicode(xman, 1);
+ } else {
+ charArea.drawStickMan(xman, 1);
+ }
+ } else {
+ assert false;
+ }
+ }
+
+ private int getStickManHeight() {
+ if (fileFormat == FileFormat.UTXT) {
+ return UmlCharArea.STICKMAN_UNICODE_HEIGHT;
+ }
+ return UmlCharArea.STICKMAN_HEIGHT;
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return StringUtils.getHeight(stringsToDisplay) + getStickManHeight();
+ }
+
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return StringUtils.getWidth(stringsToDisplay) + 2;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/asciiart/ComponentTextArrow.java b/src/net/sourceforge/plantuml/asciiart/ComponentTextArrow.java
new file mode 100644
index 0000000..2eb5403
--- /dev/null
+++ b/src/net/sourceforge/plantuml/asciiart/ComponentTextArrow.java
@@ -0,0 +1,122 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.asciiart;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.FileFormat;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.sequencediagram.MessageNumber;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.ArrowConfiguration;
+import net.sourceforge.plantuml.skin.ArrowDirection;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.txt.UGraphicTxt;
+import net.sourceforge.plantuml.StringUtils;
+
+public class ComponentTextArrow extends AbstractComponentText {
+
+ private final ComponentType type;
+ private final Display stringsToDisplay;
+ private final FileFormat fileFormat;
+ private final ArrowConfiguration config;
+
+ public ComponentTextArrow(ComponentType type, ArrowConfiguration config, Display stringsToDisplay,
+ FileFormat fileFormat) {
+ this.type = type;
+ this.config = config;
+ this.stringsToDisplay = clean(stringsToDisplay);
+ this.fileFormat = fileFormat;
+ }
+
+ private static Display clean(Display orig) {
+ if (orig.size() == 0 || orig.get(0) instanceof MessageNumber == false) {
+ return orig;
+ }
+ Display result = Display.empty();
+ for (int i = 0; i < orig.size(); i++) {
+ CharSequence element = orig.get(i);
+ if (i == 1) {
+ element = removeTag(orig.get(0).toString()) + " " + element;
+ }
+ if (i != 0) {
+ result = result.add(element);
+ }
+ }
+ return result;
+ }
+
+ private static String removeTag(String s) {
+ return s.replaceAll("\\<[^<>]+\\>", "");
+ }
+
+ public void drawU(UGraphic ug, Area area, Context2D context) {
+ final Dimension2D dimensionToUse = area.getDimensionToUse();
+ final UmlCharArea charArea = ((UGraphicTxt) ug).getCharArea();
+ final int width = (int) dimensionToUse.getWidth();
+ final int height = (int) dimensionToUse.getHeight();
+ final int textWidth = StringUtils.getWidth(stringsToDisplay);
+
+ final int yarrow = height - 2;
+ charArea.drawHLine(fileFormat == FileFormat.UTXT ? '\u2500' : '-', yarrow, 1, width);
+ if (config.isDotted()) {
+ for (int i = 1; i < width; i += 2) {
+ charArea.drawChar(' ', i, yarrow);
+ }
+ }
+
+ if (config.getArrowDirection() == ArrowDirection.LEFT_TO_RIGHT_NORMAL) {
+ charArea.drawChar('>', width - 1, yarrow);
+ } else if (config.getArrowDirection() == ArrowDirection.RIGHT_TO_LEFT_REVERSE) {
+ charArea.drawChar('<', 1, yarrow);
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ charArea.drawStringsLR(stringsToDisplay.as(), (width - textWidth) / 2, 0);
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return StringUtils.getHeight(stringsToDisplay) + 2;
+ }
+
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return StringUtils.getWidth(stringsToDisplay) + 2;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/asciiart/ComponentTextDivider.java b/src/net/sourceforge/plantuml/asciiart/ComponentTextDivider.java
new file mode 100644
index 0000000..575f04e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/asciiart/ComponentTextDivider.java
@@ -0,0 +1,97 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.asciiart;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.FileFormat;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.txt.UGraphicTxt;
+import net.sourceforge.plantuml.StringUtils;
+
+public class ComponentTextDivider extends AbstractComponentText {
+
+ private final ComponentType type;
+ private final Display stringsToDisplay;
+ private final FileFormat fileFormat;
+
+ public ComponentTextDivider(ComponentType type, Display stringsToDisplay, FileFormat fileFormat) {
+ this.type = type;
+ this.stringsToDisplay = stringsToDisplay;
+ this.fileFormat = fileFormat;
+ }
+
+ public void drawU(UGraphic ug, Area area, Context2D context) {
+ final Dimension2D dimensionToUse = area.getDimensionToUse();
+ final UmlCharArea charArea = ((UGraphicTxt) ug).getCharArea();
+ final int width = (int) dimensionToUse.getWidth();
+ final int textWidth = StringUtils.getWidth(stringsToDisplay);
+ // final int height = (int) dimensionToUse.getHeight();
+
+ final int textPos = (width - textWidth - 1) / 2;
+ final String desc = " " + stringsToDisplay.get(0).toString();
+
+ if (fileFormat == FileFormat.UTXT) {
+ charArea.drawHLine('\u2550', 2, 0, width, '\u2502', '\u256a');
+ charArea.drawStringLR(desc, textPos, 2);
+
+ charArea.drawHLine('\u2550', 1, textPos - 1, textPos + desc.length() + 1, '\u2502', '\u2567');
+ charArea.drawHLine('\u2550', 3, textPos - 1, textPos + desc.length() + 1, '\u2502', '\u2564');
+
+ charArea.drawStringTB("\u2554\u2563\u255a", textPos - 1, 1);
+ charArea.drawStringTB("\u2557\u2560\u255d", textPos + desc.length(), 1);
+ } else {
+ charArea.drawHLine('=', 2, 0, width);
+ charArea.drawStringLR(desc, textPos, 2);
+ charArea.drawHLine('=', 1, textPos - 1, textPos + desc.length() + 1);
+ charArea.drawHLine('=', 3, textPos - 1, textPos + desc.length() + 1);
+ }
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return StringUtils.getHeight(stringsToDisplay) + 4;
+ }
+
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return StringUtils.getWidth(stringsToDisplay) + 2;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/asciiart/ComponentTextGroupingBody.java b/src/net/sourceforge/plantuml/asciiart/ComponentTextGroupingBody.java
new file mode 100644
index 0000000..49acc30
--- /dev/null
+++ b/src/net/sourceforge/plantuml/asciiart/ComponentTextGroupingBody.java
@@ -0,0 +1,88 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.asciiart;
+
+import java.awt.geom.Dimension2D;
+import java.util.List;
+
+import net.sourceforge.plantuml.FileFormat;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.txt.UGraphicTxt;
+
+public class ComponentTextGroupingBody extends AbstractComponentText {
+
+ private final ComponentType type;
+ private final List<? extends CharSequence> stringsToDisplay;
+ private final FileFormat fileFormat;
+
+ public ComponentTextGroupingBody(ComponentType type, List<? extends CharSequence> stringsToDisplay,
+ FileFormat fileFormat) {
+ this.type = type;
+ this.stringsToDisplay = stringsToDisplay;
+ this.fileFormat = fileFormat;
+ }
+
+ public void drawU(UGraphic ug, Area area, Context2D context) {
+ final Dimension2D dimensionToUse = area.getDimensionToUse();
+ final UmlCharArea charArea = ((UGraphicTxt) ug).getCharArea();
+ final int width = (int) dimensionToUse.getWidth();
+ final int height = (int) dimensionToUse.getHeight();
+
+ if (fileFormat == FileFormat.UTXT) {
+ charArea.drawVLine('\u2551', 0, 0, height);
+ charArea.drawVLine('\u2551', width - 1, 0, height);
+ charArea.drawHLine('\u2550', height - 1, 1, width - 1, '\u2502', '\u256a');
+ charArea.drawChar('\u2560', 0, height - 1);
+ charArea.drawChar('\u2563', width - 1, height - 1);
+ } else {
+ charArea.drawVLine('!', 0, 0, height);
+ charArea.drawVLine('!', width - 1, 0, height);
+ charArea.drawHLine('~', height - 1, 1, width - 1);
+ }
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return 1;
+ }
+
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return 1;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/asciiart/ComponentTextGroupingElse.java b/src/net/sourceforge/plantuml/asciiart/ComponentTextGroupingElse.java
new file mode 100644
index 0000000..16a0419
--- /dev/null
+++ b/src/net/sourceforge/plantuml/asciiart/ComponentTextGroupingElse.java
@@ -0,0 +1,89 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.asciiart;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.FileFormat;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.txt.UGraphicTxt;
+
+public class ComponentTextGroupingElse extends AbstractComponentText {
+
+ private final ComponentType type;
+ private final Display stringsToDisplay;
+ private final FileFormat fileFormat;
+
+ public ComponentTextGroupingElse(ComponentType type, Display stringsToDisplay,
+ FileFormat fileFormat) {
+ this.type = type;
+ this.stringsToDisplay = stringsToDisplay;
+ this.fileFormat = fileFormat;
+ }
+
+ public void drawU(UGraphic ug, Area area, Context2D context) {
+ final Dimension2D dimensionToUse = area.getDimensionToUse();
+ final UmlCharArea charArea = ((UGraphicTxt) ug).getCharArea();
+ final int width = (int) dimensionToUse.getWidth();
+
+ if (stringsToDisplay.get(0) != null) {
+ charArea.drawStringLR("[" + stringsToDisplay.get(0) + "]", 2, 0);
+ }
+ if (fileFormat == FileFormat.UTXT) {
+ charArea.drawChar('\u2560', 0, -1);
+ charArea.drawChar('\u2563', width - 1, -1);
+ charArea.drawHLine('\u2550', -1, 1, width - 1, '\u2502', '\u256a');
+ } else {
+ charArea.drawHLine('~', -1, 1, width - 1);
+ }
+
+ // charArea.fillRect('E', 0, 0, width, height);
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return 1;
+ }
+
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return 1;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/asciiart/ComponentTextGroupingHeader.java b/src/net/sourceforge/plantuml/asciiart/ComponentTextGroupingHeader.java
new file mode 100644
index 0000000..66fe9c6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/asciiart/ComponentTextGroupingHeader.java
@@ -0,0 +1,110 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.asciiart;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.FileFormat;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.txt.UGraphicTxt;
+import net.sourceforge.plantuml.StringUtils;
+
+public class ComponentTextGroupingHeader extends AbstractComponentText {
+
+ private final ComponentType type;
+ private final Display stringsToDisplay;
+ private final FileFormat fileFormat;
+
+ public ComponentTextGroupingHeader(ComponentType type, Display stringsToDisplay,
+ FileFormat fileFormat) {
+ this.type = type;
+ this.stringsToDisplay = stringsToDisplay;
+ this.fileFormat = fileFormat;
+ }
+
+ public void drawU(UGraphic ug, Area area, Context2D context) {
+ final Dimension2D dimensionToUse = area.getDimensionToUse();
+ final UmlCharArea charArea = ((UGraphicTxt) ug).getCharArea();
+ final int width = (int) dimensionToUse.getWidth();
+ final int height = (int) dimensionToUse.getHeight();
+
+ // charArea.fillRect('G', 0, 0, width, height);
+ final String text = stringsToDisplay.get(0).toString();
+
+ if (fileFormat == FileFormat.UTXT) {
+ charArea.drawHLine('\u2550', 0, 1, width - 1, '\u2502', '\u256a');
+ charArea.drawStringLR(StringUtils.goUpperCase(text) + " /", 2, 1);
+ charArea.drawHLine('\u2500', 2, 1, text.length() + 4);
+ charArea.drawVLine('\u2551', 0, 1, height - 1);
+ charArea.drawVLine('\u2551', width - 1, 1, height - 1);
+ charArea.drawChar('\u255f', 0, 2);
+ charArea.drawStringTB("\u2564\u2502\u2518", text.length() + 4, 0);
+ charArea.drawChar('\u2554', 0, 0);
+ charArea.drawChar('\u2557', width - 1, 0);
+ charArea.drawHLine('\u2550', height - 1, 1, width - 1, '\u2502', '\u256a');
+ charArea.drawChar('\u255a', 0, height - 1);
+ charArea.drawChar('\u255d', width - 1, height - 1);
+ } else {
+ charArea.drawHLine('_', 0, 0, width - 1);
+ charArea.drawStringLR(StringUtils.goUpperCase(text) + " /", 2, 1);
+ charArea.drawHLine('_', 2, 1, text.length() + 3);
+ charArea.drawChar('/', text.length() + 3, 2);
+ charArea.drawVLine('!', 0, 1, height);
+ charArea.drawVLine('!', width - 1, 1, height);
+ charArea.drawHLine('~', height - 1, 1, width - 1);
+ }
+
+ if (stringsToDisplay.size() > 1) {
+ final String comment = stringsToDisplay.get(1).toString();
+ charArea.drawStringLR(comment, text.length() + 7, 1);
+
+ }
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return StringUtils.getHeight(stringsToDisplay) + 1;
+ }
+
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return StringUtils.getWidth(stringsToDisplay) + 2;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/asciiart/ComponentTextGroupingTail.java b/src/net/sourceforge/plantuml/asciiart/ComponentTextGroupingTail.java
new file mode 100644
index 0000000..072705e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/asciiart/ComponentTextGroupingTail.java
@@ -0,0 +1,83 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.asciiart;
+
+import java.awt.geom.Dimension2D;
+import java.util.List;
+
+import net.sourceforge.plantuml.FileFormat;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.txt.UGraphicTxt;
+
+public class ComponentTextGroupingTail extends AbstractComponentText {
+
+ private final ComponentType type;
+ private final List<? extends CharSequence> stringsToDisplay;
+ private final FileFormat fileFormat;
+
+ public ComponentTextGroupingTail(ComponentType type, List<? extends CharSequence> stringsToDisplay,
+ FileFormat fileFormat) {
+ this.type = type;
+ this.stringsToDisplay = stringsToDisplay;
+ this.fileFormat = fileFormat;
+ }
+
+ public void drawU(UGraphic ug, Area area, Context2D context) {
+ final Dimension2D dimensionToUse = area.getDimensionToUse();
+ final UmlCharArea charArea = ((UGraphicTxt) ug).getCharArea();
+ final int width = (int) dimensionToUse.getWidth();
+ final int height = (int) dimensionToUse.getHeight();
+
+ // charArea.fillRect('T', 0, 0, width, height);
+ if (fileFormat == FileFormat.UTXT) {
+ charArea.drawChar('\u255a', 0, height - 1);
+ charArea.drawChar('\u255d', width - 1, height - 1);
+ }
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return 1;
+ }
+
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return 1;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/asciiart/ComponentTextLine.java b/src/net/sourceforge/plantuml/asciiart/ComponentTextLine.java
new file mode 100644
index 0000000..e710473
--- /dev/null
+++ b/src/net/sourceforge/plantuml/asciiart/ComponentTextLine.java
@@ -0,0 +1,75 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.asciiart;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.FileFormat;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.txt.UGraphicTxt;
+
+public class ComponentTextLine extends AbstractComponentText {
+
+ private final FileFormat fileFormat;
+
+ public ComponentTextLine(FileFormat fileFormat) {
+ this.fileFormat = fileFormat;
+ }
+
+ public void drawU(UGraphic ug, Area area, Context2D context) {
+ final Dimension2D dimensionToUse = area.getDimensionToUse();
+ final UmlCharArea charArea = ((UGraphicTxt) ug).getCharArea();
+ final int width = (int) dimensionToUse.getWidth();
+ final int height = (int) dimensionToUse.getHeight();
+ if (fileFormat == FileFormat.UTXT) {
+ charArea.drawVLine('\u2502', (width - 1) / 2, 0, height - 1);
+ } else {
+ charArea.drawVLine('|', (width - 1) / 2, 0, height - 1);
+ }
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return 0;
+ }
+
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return 3;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/asciiart/ComponentTextNewpage.java b/src/net/sourceforge/plantuml/asciiart/ComponentTextNewpage.java
new file mode 100644
index 0000000..5859b51
--- /dev/null
+++ b/src/net/sourceforge/plantuml/asciiart/ComponentTextNewpage.java
@@ -0,0 +1,75 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.asciiart;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.FileFormat;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.txt.UGraphicTxt;
+
+public class ComponentTextNewpage extends AbstractComponentText {
+
+ private final FileFormat fileFormat;
+
+ public ComponentTextNewpage(FileFormat fileFormat) {
+ this.fileFormat = fileFormat;
+ }
+
+ public void drawU(UGraphic ug, Area area, Context2D context) {
+ final Dimension2D dimensionToUse = area.getDimensionToUse();
+ final UmlCharArea charArea = ((UGraphicTxt) ug).getCharArea();
+ final int width = (int) dimensionToUse.getWidth();
+
+ if (fileFormat == FileFormat.UTXT) {
+ charArea.drawHLine('\u2550', 0, 0, width, '\u2502', '\u256a');
+ } else {
+ charArea.drawHLine('=', 0, 0, width);
+ }
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return 2;
+ }
+
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return 2;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/asciiart/ComponentTextNote.java b/src/net/sourceforge/plantuml/asciiart/ComponentTextNote.java
new file mode 100644
index 0000000..2c9efe7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/asciiart/ComponentTextNote.java
@@ -0,0 +1,84 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.asciiart;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.FileFormat;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.txt.UGraphicTxt;
+import net.sourceforge.plantuml.StringUtils;
+
+public class ComponentTextNote extends AbstractComponentText {
+
+ private final ComponentType type;
+ private final Display stringsToDisplay;
+ private final FileFormat fileFormat;
+
+ public ComponentTextNote(ComponentType type, Display stringsToDisplay, FileFormat fileFormat) {
+ this.type = type;
+ this.stringsToDisplay = stringsToDisplay;
+ this.fileFormat = fileFormat;
+ }
+
+ public void drawU(UGraphic ug, Area area, Context2D context) {
+ final Dimension2D dimensionToUse = area.getDimensionToUse();
+ final UmlCharArea charArea = ((UGraphicTxt) ug).getCharArea();
+ final int width = (int) dimensionToUse.getWidth() - 1;
+ final int height = (int) dimensionToUse.getHeight();
+ charArea.fillRect(' ', 2, 1, width - 3, height - 2);
+ if (fileFormat == FileFormat.UTXT) {
+ charArea.drawNoteSimpleUnicode(2, 0, width - 2, height);
+ } else {
+ charArea.drawNoteSimple(2, 0, width - 2, height);
+ }
+ charArea.drawStringsLR(stringsToDisplay.as(), 3, 1);
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return StringUtils.getHeight(stringsToDisplay) + 2;
+ }
+
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return StringUtils.getWidth(stringsToDisplay) + 7;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/asciiart/ComponentTextParticipant.java b/src/net/sourceforge/plantuml/asciiart/ComponentTextParticipant.java
new file mode 100644
index 0000000..7ade477
--- /dev/null
+++ b/src/net/sourceforge/plantuml/asciiart/ComponentTextParticipant.java
@@ -0,0 +1,97 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.asciiart;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.FileFormat;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.txt.UGraphicTxt;
+import net.sourceforge.plantuml.StringUtils;
+
+public class ComponentTextParticipant extends AbstractComponentText {
+
+ private final ComponentType type;
+ private final Display stringsToDisplay;
+ private final FileFormat fileFormat;
+
+ public ComponentTextParticipant(ComponentType type, Display stringsToDisplay,
+ FileFormat fileFormat) {
+ this.type = type;
+ this.stringsToDisplay = stringsToDisplay;
+ this.fileFormat = fileFormat;
+ }
+
+ public void drawU(UGraphic ug, Area area, Context2D context) {
+ final Dimension2D dimensionToUse = area.getDimensionToUse();
+ final UmlCharArea charArea = ((UGraphicTxt) ug).getCharArea();
+ final int width = (int) dimensionToUse.getWidth();
+ final int height = (int) dimensionToUse.getHeight();
+ charArea.fillRect(' ', 0, 0, width, height);
+ if (fileFormat == FileFormat.UTXT) {
+ charArea.drawBoxSimpleUnicode(0, 0, width, height);
+ if (type == ComponentType.PARTICIPANT_TAIL) {
+ charArea.drawChar('\u2534', (width - 1) / 2, 0);
+ }
+ if (type == ComponentType.PARTICIPANT_HEAD) {
+ charArea.drawChar('\u252c', (width - 1) / 2, height - 1);
+ }
+ } else {
+ charArea.drawBoxSimple(0, 0, width, height);
+ if (type == ComponentType.PARTICIPANT_TAIL) {
+ charArea.drawChar('+', (width - 1) / 2, 0);
+ }
+ if (type == ComponentType.PARTICIPANT_HEAD) {
+ charArea.drawChar('+', (width - 1) / 2, height - 1);
+ }
+ }
+ charArea.drawStringsLR(stringsToDisplay.as(), 1, 1);
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return StringUtils.getHeight(stringsToDisplay) + 2;
+ }
+
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return StringUtils.getWidth(stringsToDisplay) + 2;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/asciiart/ComponentTextSelfArrow.java b/src/net/sourceforge/plantuml/asciiart/ComponentTextSelfArrow.java
new file mode 100644
index 0000000..71634d0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/asciiart/ComponentTextSelfArrow.java
@@ -0,0 +1,105 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.asciiart;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.FileFormat;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.ArrowConfiguration;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.txt.UGraphicTxt;
+import net.sourceforge.plantuml.StringUtils;
+
+public class ComponentTextSelfArrow extends AbstractComponentText {
+
+ private final ComponentType type;
+ private final Display stringsToDisplay;
+ private final FileFormat fileFormat;
+ private final ArrowConfiguration config;
+
+ public ComponentTextSelfArrow(ComponentType type, ArrowConfiguration config,
+ Display stringsToDisplay, FileFormat fileFormat) {
+ this.type = type;
+ this.stringsToDisplay = stringsToDisplay;
+ this.fileFormat = fileFormat;
+ this.config = config;
+ }
+
+ public void drawU(UGraphic ug, Area area, Context2D context) {
+ final Dimension2D dimensionToUse = area.getDimensionToUse();
+ final UmlCharArea charArea = ((UGraphicTxt) ug).getCharArea();
+ final int width = (int) dimensionToUse.getWidth();
+ final int height = (int) dimensionToUse.getHeight() - 1;
+
+ charArea.fillRect(' ', 0, 0, width, height);
+
+ if (fileFormat == FileFormat.UTXT) {
+ if (config.isDotted()) {
+ charArea.drawStringLR("\u2500 \u2500 \u2510", 0, 0);
+ charArea.drawStringLR("|", 4, 1);
+ charArea.drawStringLR("< \u2500 \u2518", 0, 2);
+ } else {
+ charArea.drawStringLR("\u2500\u2500\u2500\u2500\u2510", 0, 0);
+ charArea.drawStringLR("\u2502", 4, 1);
+ charArea.drawStringLR("<\u2500\u2500\u2500\u2518", 0, 2);
+ }
+ } else if (config.isDotted()) {
+ charArea.drawStringLR("- - .", 0, 0);
+ charArea.drawStringLR("|", 4, 1);
+ charArea.drawStringLR("< - '", 0, 2);
+ } else {
+ charArea.drawStringLR("----.", 0, 0);
+ charArea.drawStringLR("|", 4, 1);
+ charArea.drawStringLR("<---'", 0, 2);
+ }
+
+ charArea.drawStringsLR(stringsToDisplay.as(), 6, 1);
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return StringUtils.getHeight(stringsToDisplay) + 3;
+ }
+
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return StringUtils.getWidth(stringsToDisplay) + 6;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/asciiart/TextSkin.java b/src/net/sourceforge/plantuml/asciiart/TextSkin.java
new file mode 100644
index 0000000..72e3e7b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/asciiart/TextSkin.java
@@ -0,0 +1,116 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.asciiart;
+
+import net.sourceforge.plantuml.FileFormat;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.skin.ArrowConfiguration;
+import net.sourceforge.plantuml.skin.ArrowDirection;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.skin.rose.ComponentRoseGroupingSpace;
+
+public class TextSkin implements Skin {
+
+ private final FileFormat fileFormat;
+
+ public TextSkin(FileFormat fileFormat) {
+ this.fileFormat = fileFormat;
+ }
+
+ public Component createComponent(ComponentType type, ArrowConfiguration config, ISkinParam param,
+ Display stringsToDisplay) {
+ if (type == ComponentType.PARTICIPANT_HEAD || type == ComponentType.PARTICIPANT_TAIL) {
+ return new ComponentTextParticipant(type, stringsToDisplay, fileFormat);
+ }
+ if (type == ComponentType.ACTOR_HEAD || type == ComponentType.ACTOR_TAIL) {
+ return new ComponentTextActor(type, stringsToDisplay, fileFormat);
+ }
+ if (type.isArrow()
+ && ((config.getArrowDirection() == ArrowDirection.LEFT_TO_RIGHT_NORMAL) || (config.getArrowDirection() == ArrowDirection.RIGHT_TO_LEFT_REVERSE))) {
+ return new ComponentTextArrow(type, config, stringsToDisplay, fileFormat);
+ }
+ if (type.isArrow() && config.isSelfArrow()) {
+ return new ComponentTextSelfArrow(type, config, stringsToDisplay, fileFormat);
+ }
+ if (type == ComponentType.PARTICIPANT_LINE) {
+ return new ComponentTextLine(fileFormat);
+ }
+ if (type == ComponentType.CONTINUE_LINE) {
+ return new ComponentTextLine(fileFormat);
+ }
+ if (type == ComponentType.DELAY_LINE) {
+ return new ComponentTextLine(fileFormat);
+ }
+ if (type == ComponentType.ALIVE_BOX_CLOSE_CLOSE) {
+ return new ComponentTextActiveLine(fileFormat);
+ }
+ if (type == ComponentType.ALIVE_BOX_CLOSE_OPEN) {
+ return new ComponentTextActiveLine(fileFormat);
+ }
+ if (type == ComponentType.ALIVE_BOX_OPEN_CLOSE) {
+ return new ComponentTextActiveLine(fileFormat);
+ }
+ if (type == ComponentType.ALIVE_BOX_OPEN_OPEN) {
+ return new ComponentTextActiveLine(fileFormat);
+ }
+ if (type == ComponentType.NOTE) {
+ return new ComponentTextNote(type, stringsToDisplay, fileFormat);
+ }
+ if (type == ComponentType.DIVIDER) {
+ return new ComponentTextDivider(type, stringsToDisplay, fileFormat);
+ }
+ if (type == ComponentType.GROUPING_HEADER) {
+ return new ComponentTextGroupingHeader(type, stringsToDisplay, fileFormat);
+ }
+ if (type == ComponentType.GROUPING_SPACE) {
+ return new ComponentRoseGroupingSpace(1);
+ }
+ if (type == ComponentType.GROUPING_ELSE) {
+ return new ComponentTextGroupingElse(type, stringsToDisplay, fileFormat);
+ }
+ if (type == ComponentType.NEWPAGE) {
+ return new ComponentTextNewpage(fileFormat);
+ }
+ throw new UnsupportedOperationException(type.toString());
+ }
+
+ public Object getProtocolVersion() {
+ return 1;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/asciiart/TextStringBounder.java b/src/net/sourceforge/plantuml/asciiart/TextStringBounder.java
new file mode 100644
index 0000000..6cb22d7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/asciiart/TextStringBounder.java
@@ -0,0 +1,49 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.asciiart;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public class TextStringBounder implements StringBounder {
+
+ public Dimension2D calculateDimension(UFont font, String text) {
+ return new Dimension2DDouble(text.length(), 1);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/asciiart/TranslatedCharArea.java b/src/net/sourceforge/plantuml/asciiart/TranslatedCharArea.java
new file mode 100644
index 0000000..4a4ae7f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/asciiart/TranslatedCharArea.java
@@ -0,0 +1,134 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.asciiart;
+
+import java.io.PrintStream;
+import java.util.Collection;
+import java.util.List;
+
+public class TranslatedCharArea implements UmlCharArea {
+
+ private final int dx;
+ private final int dy;
+ private final UmlCharArea charArea;
+
+ public TranslatedCharArea(UmlCharArea charArea, int dx, int dy) {
+ this.charArea = charArea;
+ this.dx = dx;
+ this.dy = dy;
+ }
+
+ public void drawBoxSimple(int x, int y, int width, int height) {
+ charArea.drawBoxSimple(x + dx, y + dy, width, height);
+
+ }
+
+ public void drawBoxSimpleUnicode(int x, int y, int width, int height) {
+ charArea.drawBoxSimpleUnicode(x + dx, y + dy, width, height);
+ }
+
+ public void drawNoteSimple(int x, int y, int width, int height) {
+ charArea.drawNoteSimple(x + dx, y + dy, width, height);
+ }
+
+ public void drawNoteSimpleUnicode(int x, int y, int width, int height) {
+ charArea.drawNoteSimpleUnicode(x + dx, y + dy, width, height);
+ }
+
+
+
+ public void drawStickMan(int x, int y) {
+ charArea.drawStickMan(x + dx, y + dy);
+ }
+
+ public void drawStickManUnicode(int x, int y) {
+ charArea.drawStickManUnicode(x + dx, y + dy);
+ }
+
+
+ public void drawChar(char c, int x, int y) {
+ charArea.drawChar(c, x + dx, y + dy);
+ }
+
+ public void drawHLine(char c, int line, int col1, int col2) {
+ charArea.drawHLine(c, line + dy, col1 + dx, col2 + dx);
+ }
+ public void drawHLine(char c, int line, int col1, int col2, char ifFound, char thenUse) {
+ charArea.drawHLine(c, line + dy, col1 + dx, col2 + dx, ifFound, thenUse);
+ }
+
+ public void drawStringLR(String string, int x, int y) {
+ charArea.drawStringLR(string, x + dx, y + dy);
+ }
+
+ public void drawStringTB(String string, int x, int y) {
+ charArea.drawStringTB(string, x + dx, y + dy);
+ }
+
+ public void drawVLine(char c, int col, int line1, int line2) {
+ charArea.drawVLine(c, col + dx, line1 + dy, line2 + dy);
+ }
+
+ public int getHeight() {
+ return charArea.getHeight();
+ }
+
+ public int getWidth() {
+ return charArea.getWidth();
+ }
+
+ public String getLine(int line) {
+ return charArea.getLine(line);
+ }
+
+ public List<String> getLines() {
+ return charArea.getLines();
+ }
+
+ public void print(PrintStream ps) {
+ charArea.print(ps);
+ }
+
+ public void drawStringsLR(Collection<? extends CharSequence> strings, int x, int y) {
+ charArea.drawStringsLR(strings, x + dx, y + dy);
+ }
+
+ public void fillRect(char c, int x, int y, int width, int height) {
+ charArea.fillRect(c, x + dx, y + dy, width, height);
+ }
+
+
+
+}
diff --git a/src/net/sourceforge/plantuml/asciiart/UmlCharArea.java b/src/net/sourceforge/plantuml/asciiart/UmlCharArea.java
new file mode 100644
index 0000000..afe52e2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/asciiart/UmlCharArea.java
@@ -0,0 +1,58 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.asciiart;
+
+import java.util.Collection;
+
+public interface UmlCharArea extends BasicCharArea {
+
+ int STICKMAN_HEIGHT = 5;
+ int STICKMAN_UNICODE_HEIGHT = 6;
+
+ void drawBoxSimple(int x, int y, int width, int height);
+
+ void drawBoxSimpleUnicode(int x, int y, int width, int height);
+
+ void drawNoteSimple(int x, int y, int width, int height);
+
+ void drawNoteSimpleUnicode(int x, int y, int width, int height);
+
+ void drawStickMan(int x, int y);
+
+ void drawStickManUnicode(int x, int y);
+
+ void drawStringsLR(Collection<? extends CharSequence> strings, int x, int y);
+
+}
diff --git a/src/net/sourceforge/plantuml/asciiart/UmlCharAreaImpl.java b/src/net/sourceforge/plantuml/asciiart/UmlCharAreaImpl.java
new file mode 100644
index 0000000..ef519dd
--- /dev/null
+++ b/src/net/sourceforge/plantuml/asciiart/UmlCharAreaImpl.java
@@ -0,0 +1,125 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.asciiart;
+
+import java.util.Collection;
+
+import net.sourceforge.plantuml.ugraphic.ClipContainer;
+
+public class UmlCharAreaImpl extends BasicCharAreaImpl implements UmlCharArea {
+
+ public void drawBoxSimple(int x, int y, int width, int height) {
+ this.drawHLine('-', y, x + 1, x + width - 1);
+ this.drawHLine('-', y + height - 1, x + 1, x + width - 1);
+
+ this.drawVLine('|', x, y + 1, y + height - 1);
+ this.drawVLine('|', x + width - 1, y + 1, y + height - 1);
+
+ this.drawChar(',', x, y);
+ this.drawChar('.', x + width - 1, y);
+ this.drawChar('`', x, y + height - 1);
+ this.drawChar('\'', x + width - 1, y + height - 1);
+ }
+
+ public void drawBoxSimpleUnicode(int x, int y, int width, int height) {
+ this.drawHLine('\u2500', y, x + 1, x + width - 1);
+ this.drawHLine('\u2500', y + height - 1, x + 1, x + width - 1);
+
+ this.drawVLine('\u2502', x, y + 1, y + height - 1);
+ this.drawVLine('\u2502', x + width - 1, y + 1, y + height - 1);
+
+ this.drawChar('\u250c', x, y);
+ this.drawChar('\u2510', x + width - 1, y);
+ this.drawChar('\u2514', x, y + height - 1);
+ this.drawChar('\u2518', x + width - 1, y + height - 1);
+ }
+
+ public void drawStickMan(int x, int y) {
+ this.drawStringLR(",-.", x, y++);
+ this.drawStringLR("`-'", x, y++);
+ this.drawStringLR("/|\\", x, y++);
+ this.drawStringLR(" | ", x, y++);
+ this.drawStringLR("/ \\", x, y++);
+ }
+
+ public void drawStickManUnicode(int x, int y) {
+ this.drawStringLR("\u250c\u2500\u2510", x, y++);
+ this.drawStringLR("\u2551\"\u2502", x, y++);
+ this.drawStringLR("\u2514\u252c\u2518", x, y++);
+ this.drawStringLR("\u250c\u253c\u2510", x, y++);
+ this.drawStringLR(" \u2502 ", x, y++);
+ this.drawStringLR("\u250c\u2534\u2510", x, y++);
+ }
+
+ public void drawStringsLR(Collection<? extends CharSequence> strings, int x, int y) {
+ int i = 0;
+ for (CharSequence s : strings) {
+ this.drawStringLR(s.toString(), x, y + i);
+ i++;
+ }
+
+ }
+
+ public void drawNoteSimple(int x, int y, int width, int height) {
+ this.drawHLine('-', y, x + 1, x + width - 1);
+ this.drawHLine('-', y + height - 1, x + 1, x + width - 1);
+
+ this.drawVLine('|', x, y + 1, y + height - 1);
+ this.drawVLine('|', x + width - 1, y + 1, y + height - 1);
+
+ this.drawChar(',', x, y);
+
+ this.drawStringLR("!. ", x + width - 3, y);
+ this.drawStringLR("|_\\", x + width - 3, y + 1);
+
+ this.drawChar('`', x, y + height - 1);
+ this.drawChar('\'', x + width - 1, y + height - 1);
+ }
+
+ public void drawNoteSimpleUnicode(int x, int y, int width, int height) {
+ this.drawChar('\u2591', x + width - 2, y + 1);
+
+ this.drawHLine('\u2550', y, x + 1, x + width - 1, '\u2502', '\u2567');
+ this.drawHLine('\u2550', y + height - 1, x + 1, x + width - 1, '\u2502', '\u2564');
+
+ this.drawVLine('\u2551', x, y + 1, y + height - 1);
+ this.drawVLine('\u2551', x + width - 1, y + 1, y + height - 1);
+
+ this.drawChar('\u2554', x, y);
+ this.drawChar('\u2557', x + width - 1, y);
+ this.drawChar('\u255a', x, y + height - 1);
+ this.drawChar('\u255d', x + width - 1, y + height - 1);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/braille/BrailleUtils.java b/src/net/sourceforge/plantuml/braille/BrailleUtils.java
new file mode 100644
index 0000000..fb2422a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/braille/BrailleUtils.java
@@ -0,0 +1,43 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.braille;
+
+public class BrailleUtils {
+
+ public static boolean isBraille(char c) {
+ return Character.UnicodeBlock.of(c) == Character.UnicodeBlock.BRAILLE_PATTERNS;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/AbstractEntityDiagram.java b/src/net/sourceforge/plantuml/classdiagram/AbstractEntityDiagram.java
new file mode 100644
index 0000000..c1cb367
--- /dev/null
+++ b/src/net/sourceforge/plantuml/classdiagram/AbstractEntityDiagram.java
@@ -0,0 +1,64 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.classdiagram;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import net.sourceforge.plantuml.core.DiagramDescription;
+import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
+import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
+
+public abstract class AbstractEntityDiagram extends CucaDiagram {
+
+ final protected List<String> getDotStrings() {
+ final List<String> def = Arrays.asList("nodesep=.35;", "ranksep=0.8;", "edge [fontsize=11,labelfontsize=11];",
+ "node [fontsize=11,height=.35,width=.55];");
+ if (getPragma().isDefine("graphattributes") == false) {
+ return def;
+ }
+ final String attribute = getPragma().getValue("graphattributes");
+ final List<String> result = new ArrayList<String>(def);
+ result.add(attribute);
+ return Collections.unmodifiableList(result);
+ }
+
+ final public DiagramDescription getDescription() {
+ return new DiagramDescriptionImpl("(" + getLeafssize() + " entities)", getClass());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/ClassDiagram.java b/src/net/sourceforge/plantuml/classdiagram/ClassDiagram.java
new file mode 100644
index 0000000..4dfc7e4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/classdiagram/ClassDiagram.java
@@ -0,0 +1,234 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.classdiagram;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.UmlDiagramType;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.EntityUtils;
+import net.sourceforge.plantuml.cucadiagram.GroupType;
+import net.sourceforge.plantuml.cucadiagram.IGroup;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.USymbol;
+import net.sourceforge.plantuml.objectdiagram.AbstractClassOrObjectDiagram;
+import net.sourceforge.plantuml.svek.image.EntityImageClass;
+import net.sourceforge.plantuml.ugraphic.ImageBuilder;
+
+public class ClassDiagram extends AbstractClassOrObjectDiagram {
+
+ private String namespaceSeparator = ".";
+
+ @Override
+ public ILeaf getOrCreateLeaf(Code code, LeafType type, USymbol symbol) {
+ if (namespaceSeparator != null) {
+ code = code.withSeparator(namespaceSeparator);
+ }
+ if (type == null) {
+ code = code.eventuallyRemoveStartingAndEndingDoubleQuote("\"([:");
+ if (namespaceSeparator == null) {
+ return getOrCreateLeafDefault(code, LeafType.CLASS, symbol);
+ }
+ code = code.getFullyQualifiedCode(getCurrentGroup());
+ if (super.leafExist(code)) {
+ return getOrCreateLeafDefault(code, LeafType.CLASS, symbol);
+ }
+ return createEntityWithNamespace(code, Display.getWithNewlines(code.getShortName(getLeafs())),
+ LeafType.CLASS, symbol);
+ }
+ if (namespaceSeparator == null) {
+ return getOrCreateLeafDefault(code, LeafType.CLASS, symbol);
+ }
+ code = code.getFullyQualifiedCode(getCurrentGroup());
+ if (super.leafExist(code)) {
+ return getOrCreateLeafDefault(code, type, symbol);
+ }
+ return createEntityWithNamespace(code, Display.getWithNewlines(code.getShortName(getLeafs())), type, symbol);
+ }
+
+ public IGroup getOrCreateNamespace(Code namespace, Display display, GroupType type, IGroup parent) {
+ if (namespaceSeparator != null) {
+ namespace = namespace.withSeparator(namespaceSeparator).getFullyQualifiedCode(getCurrentGroup());
+ }
+ final IGroup g = getOrCreateNamespaceInternal(namespace, display, type, parent);
+ currentGroup = g;
+ return g;
+ }
+
+ private IGroup getOrCreateNamespaceInternal(Code namespace, Display display, GroupType type, IGroup parent) {
+ IGroup result = entityFactory.getGroups().get(namespace);
+ if (result != null) {
+ return result;
+ }
+ if (entityFactory.getLeafs().containsKey(namespace)) {
+ result = entityFactory.muteToGroup(namespace, namespace, type, parent);
+ result.setDisplay(display);
+ } else {
+ result = entityFactory.createGroup(namespace, display, namespace, type, parent, getHides(),
+ getNamespaceSeparator());
+ }
+ entityFactory.addGroup(result);
+ return result;
+ }
+
+ @Override
+ public ILeaf createLeaf(Code code, Display display, LeafType type, USymbol symbol) {
+ if (namespaceSeparator != null) {
+ code = code.withSeparator(namespaceSeparator);
+ }
+ if (type != LeafType.ABSTRACT_CLASS && type != LeafType.ANNOTATION && type != LeafType.CLASS
+ && type != LeafType.INTERFACE && type != LeafType.ENUM && type != LeafType.LOLLIPOP
+ && type != LeafType.NOTE) {
+ return super.createLeaf(code, display, type, symbol);
+ }
+ if (namespaceSeparator == null) {
+ return super.createLeaf(code, display, type, symbol);
+ }
+ code = code.getFullyQualifiedCode(getCurrentGroup());
+ if (super.leafExist(code)) {
+ throw new IllegalArgumentException("Already known: " + code);
+ }
+ return createEntityWithNamespace(code, display, type, symbol);
+ }
+
+ private ILeaf createEntityWithNamespace(Code fullyCode, Display display, LeafType type, USymbol symbol) {
+ IGroup group = getCurrentGroup();
+ final String namespace = getNamespace(fullyCode);
+ if (namespace != null
+ && (EntityUtils.groupRoot(group) || group.getCode().getFullName().equals(namespace) == false)) {
+ final Code namespace2 = Code.of(namespace);
+ group = getOrCreateNamespaceInternal(namespace2, Display.getWithNewlines(namespace), GroupType.PACKAGE,
+ getRootGroup());
+ }
+ return createLeafInternal(fullyCode,
+ display == null ? Display.getWithNewlines(fullyCode.getShortName(getLeafs())) : display, type, group,
+ symbol);
+ }
+
+ private final String getNamespace(Code fullyCode) {
+ String name = fullyCode.getFullName();
+ do {
+ final int x = name.lastIndexOf(namespaceSeparator);
+ if (x == -1) {
+ return null;
+ }
+ name = name.substring(0, x);
+ } while (getLeafs().containsKey(Code.of(name, namespaceSeparator)));
+ return name;
+ }
+
+ @Override
+ public final boolean leafExist(Code code) {
+ if (namespaceSeparator == null) {
+ return super.leafExist(code);
+ }
+ code = code.withSeparator(namespaceSeparator);
+ return super.leafExist(code.getFullyQualifiedCode(getCurrentGroup()));
+ }
+
+ @Override
+ public UmlDiagramType getUmlDiagramType() {
+ return UmlDiagramType.CLASS;
+ }
+
+ public void setNamespaceSeparator(String namespaceSeparator) {
+ this.namespaceSeparator = namespaceSeparator;
+ }
+
+ public String getNamespaceSeparator() {
+ return namespaceSeparator;
+ }
+
+ private boolean allowMixing;
+
+ public void setAllowMixing(boolean allowMixing) {
+ this.allowMixing = allowMixing;
+ }
+
+ public boolean isAllowMixing() {
+ return allowMixing;
+ }
+
+ private int useLayoutExplicit = 0;
+
+ public void layoutNewLine() {
+ useLayoutExplicit++;
+ incRawLayout();
+ }
+
+ @Override
+ final protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
+ throws IOException {
+ if (useLayoutExplicit != 0) {
+ return exportLayoutExplicit(os, index, fileFormatOption);
+ }
+ return super.exportDiagramInternal(os, index, fileFormatOption);
+ }
+
+ final protected ImageData exportLayoutExplicit(OutputStream os, int index, FileFormatOption fileFormatOption)
+ throws IOException {
+ final FullLayout fullLayout = new FullLayout();
+ for (int i = 0; i <= useLayoutExplicit; i++) {
+ final RowLayout rawLayout = getRawLayout(i);
+ fullLayout.addRowLayout(rawLayout);
+ }
+ final ImageBuilder imageBuilder = new ImageBuilder(getSkinParam().getColorMapper(), 1, HtmlColorUtils.WHITE,
+ null, null, 0, 10, null, getSkinParam().handwritten());
+ imageBuilder.addUDrawable(fullLayout);
+ return imageBuilder.writeImageTOBEMOVED(fileFormatOption.getFileFormat(), os);
+ }
+
+ private RowLayout getRawLayout(int raw) {
+ final RowLayout rawLayout = new RowLayout();
+ for (ILeaf leaf : getLeafs().values()) {
+ if (leaf.getRawLayout() == raw) {
+ rawLayout.addLeaf(getEntityImageClass(leaf));
+ }
+ }
+ return rawLayout;
+ }
+
+ private TextBlock getEntityImageClass(ILeaf entity) {
+ return new EntityImageClass(null, entity, getSkinParam(), this);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/ClassDiagramFactory.java b/src/net/sourceforge/plantuml/classdiagram/ClassDiagramFactory.java
new file mode 100644
index 0000000..fc9ba75
--- /dev/null
+++ b/src/net/sourceforge/plantuml/classdiagram/ClassDiagramFactory.java
@@ -0,0 +1,167 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.classdiagram;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.UmlDiagramType;
+import net.sourceforge.plantuml.classdiagram.command.CommandAddMethod;
+import net.sourceforge.plantuml.classdiagram.command.CommandAllowMixing;
+import net.sourceforge.plantuml.classdiagram.command.CommandCreateClass;
+import net.sourceforge.plantuml.classdiagram.command.CommandCreateClassMultilines;
+import net.sourceforge.plantuml.classdiagram.command.CommandCreateElementFull2;
+import net.sourceforge.plantuml.classdiagram.command.CommandCreateElementFull2.Mode;
+import net.sourceforge.plantuml.classdiagram.command.CommandDiamondAssociation;
+import net.sourceforge.plantuml.classdiagram.command.CommandHideShowSpecificClass;
+import net.sourceforge.plantuml.classdiagram.command.CommandImport;
+import net.sourceforge.plantuml.classdiagram.command.CommandLayoutNewLine;
+import net.sourceforge.plantuml.classdiagram.command.CommandLinkClass;
+import net.sourceforge.plantuml.classdiagram.command.CommandLinkLollipop;
+import net.sourceforge.plantuml.classdiagram.command.CommandMouseOver;
+import net.sourceforge.plantuml.classdiagram.command.CommandNamespaceSeparator;
+import net.sourceforge.plantuml.classdiagram.command.CommandStereotype;
+import net.sourceforge.plantuml.classdiagram.command.CommandUrl;
+import net.sourceforge.plantuml.command.Command;
+import net.sourceforge.plantuml.command.CommandEndPackage;
+import net.sourceforge.plantuml.command.CommandFootboxIgnored;
+import net.sourceforge.plantuml.command.CommandNamespace;
+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.note.FactoryNoteCommand;
+import net.sourceforge.plantuml.command.note.FactoryNoteOnEntityCommand;
+import net.sourceforge.plantuml.command.note.FactoryNoteOnLinkCommand;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.cucadiagram.Link;
+
+public class ClassDiagramFactory extends UmlDiagramFactory {
+
+ @Override
+ public ClassDiagram createEmptyDiagram() {
+ return new ClassDiagram();
+
+ }
+
+ @Override
+ protected List<Command> createCommands() {
+ final List<Command> cmds = new ArrayList<Command>();
+ cmds.add(new CommandFootboxIgnored());
+ addCommonCommands(cmds);
+
+ cmds.add(new CommandRankDir());
+ cmds.add(new CommandPage());
+ cmds.add(new CommandAddMethod());
+
+ cmds.add(new CommandCreateClass());
+ cmds.add(new CommandAllowMixing());
+ cmds.add(new CommandLayoutNewLine());
+
+ cmds.add(new CommandCreateElementFull2(Mode.NORMAL_KEYWORD));
+ cmds.add(new CommandCreateElementFull2(Mode.WITH_MIX_PREFIX));
+ final FactoryNoteCommand factoryNoteCommand = new FactoryNoteCommand();
+ cmds.add(factoryNoteCommand.createSingleLine());
+
+ cmds.add(new CommandPackage());
+ cmds.add(new CommandEndPackage());
+ cmds.add(new CommandPackageEmpty());
+
+ cmds.add(new CommandNamespace());
+ cmds.add(new CommandStereotype());
+
+ cmds.add(new CommandLinkClass(UmlDiagramType.CLASS));
+ cmds.add(new CommandLinkLollipop(UmlDiagramType.CLASS));
+
+ cmds.add(new CommandImport());
+ final FactoryNoteOnEntityCommand factoryNoteOnEntityCommand = new FactoryNoteOnEntityCommand(new RegexLeaf(
+ "ENTITY", "(" + CommandCreateClass.CODE + "|[%g][^%g]+[%g])"));
+ cmds.add(factoryNoteOnEntityCommand.createSingleLine());
+ cmds.add(new CommandUrl());
+
+ cmds.add(factoryNoteOnEntityCommand.createMultiLine());
+ cmds.add(factoryNoteCommand.createMultiLine());
+ cmds.add(new CommandCreateClassMultilines());
+
+ final FactoryNoteOnLinkCommand factoryNoteOnLinkCommand = new FactoryNoteOnLinkCommand();
+ cmds.add(factoryNoteOnLinkCommand.createSingleLine());
+ cmds.add(factoryNoteOnLinkCommand.createMultiLine());
+
+ cmds.add(new CommandDiamondAssociation());
+ cmds.add(new CommandMouseOver());
+
+ cmds.add(new CommandHideShowSpecificClass());
+
+ cmds.add(new CommandNamespaceSeparator());
+
+ return cmds;
+ }
+
+ @Override
+ public String checkFinalError(AbstractPSystem sys) {
+ final ClassDiagram system = (ClassDiagram) sys;
+
+ for (Link link : system.getLinks()) {
+ final int len = link.getLength();
+ if (len == 1) {
+ for (Link link2 : system.getLinks()) {
+ if (link2.sameConnections(link) && link2.getLength() != 1) {
+ link2.setLength(1);
+ }
+ }
+ }
+ }
+
+ system.applySingleStrategy();
+
+ // for (IGroup g : system.getGroups(true)) {
+ // final List<ILeaf> standalones = new ArrayList<ILeaf>();
+ // for (ILeaf ent : g.getLeafsDirect()) {
+ // if (system.isStandalone(ent)) {
+ // standalones.add(ent);
+ // }
+ // }
+ // if (standalones.size() < 3) {
+ // continue;
+ // }
+ // final Magma magma = new Magma(system, standalones);
+ // magma.putInSquare();
+ // }
+ return super.checkFinalError(system);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/FullLayout.java b/src/net/sourceforge/plantuml/classdiagram/FullLayout.java
new file mode 100644
index 0000000..470c350
--- /dev/null
+++ b/src/net/sourceforge/plantuml/classdiagram/FullLayout.java
@@ -0,0 +1,61 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.classdiagram;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class FullLayout implements UDrawable {
+
+ private final List<RowLayout> all = new ArrayList<RowLayout>();
+
+ public void addRowLayout(RowLayout rawLayout) {
+ this.all.add(rawLayout);
+ }
+
+ public void drawU(UGraphic ug) {
+ double y = 0;
+ for (RowLayout rawLayout : all) {
+ rawLayout.drawU(ug.apply(new UTranslate(0, y)));
+ y += rawLayout.getHeight(ug.getStringBounder()) + 20;
+ }
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/RowLayout.java b/src/net/sourceforge/plantuml/classdiagram/RowLayout.java
new file mode 100644
index 0000000..b8038d0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/classdiagram/RowLayout.java
@@ -0,0 +1,71 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.classdiagram;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class RowLayout implements UDrawable {
+
+ private final List<TextBlock> all = new ArrayList<TextBlock>();
+
+ public void addLeaf(TextBlock entityImageClass) {
+ this.all.add(entityImageClass);
+ }
+
+ public double getHeight(StringBounder stringBounder) {
+ double y = 0;
+ for (TextBlock leaf : all) {
+ y = Math.max(y, leaf.calculateDimension(stringBounder).getHeight());
+ }
+ return y;
+ }
+
+ public void drawU(UGraphic ug) {
+ double x = 0;
+ for (TextBlock leaf : all) {
+ leaf.drawU(ug.apply(new UTranslate(x, 0)));
+ x += leaf.calculateDimension(ug.getStringBounder()).getWidth() + 20;
+ }
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandAddMethod.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandAddMethod.java
new file mode 100644
index 0000000..09adfb7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandAddMethod.java
@@ -0,0 +1,63 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.classdiagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.classdiagram.ClassDiagram;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.skin.VisibilityModifier;
+
+public class CommandAddMethod extends SingleLineCommand<ClassDiagram> {
+
+ public CommandAddMethod() {
+ super("(?i)^([\\p{L}0-9_.]+|[%g][^%g]+[%g])[%s]+:[%s]+(.*)$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ClassDiagram system, List<String> arg) {
+ final IEntity entity = system.getOrCreateLeaf(Code.of(arg.get(0)), null, null);
+
+ final String field = arg.get(1);
+ if (field.length() > 0 && VisibilityModifier.isVisibilityCharacter(field.charAt(0))) {
+ system.setVisibilityModifierPresent(true);
+ }
+ entity.addFieldOrMethod(field);
+ return CommandExecutionResult.ok();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandAllowMixing.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandAllowMixing.java
new file mode 100644
index 0000000..7f635dc
--- /dev/null
+++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandAllowMixing.java
@@ -0,0 +1,62 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.classdiagram.command;
+
+import net.sourceforge.plantuml.classdiagram.ClassDiagram;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+
+public class CommandAllowMixing extends SingleLineCommand2<ClassDiagram> {
+
+ public CommandAllowMixing() {
+ super(getRegexConcat());
+ }
+
+ private static RegexConcat getRegexConcat() {
+
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("allow_mixing"), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ClassDiagram diagram, RegexResult arg) {
+ diagram.setAllowMixing(true);
+ return CommandExecutionResult.ok();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java
new file mode 100644
index 0000000..84eed42
--- /dev/null
+++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClass.java
@@ -0,0 +1,163 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.classdiagram.command;
+
+import java.util.Locale;
+
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
+import net.sourceforge.plantuml.classdiagram.ClassDiagram;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexOr;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+
+public class CommandCreateClass extends SingleLineCommand2<ClassDiagram> {
+
+ public static final String CODE = "[^%s{}%g<>]+";
+
+ enum Mode {
+ EXTENDS, IMPLEMENTS
+ };
+
+ public CommandCreateClass() {
+ super(getRegexConcat());
+ }
+
+ private static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("TYPE", //
+ "(interface|enum|annotation|abstract[%s]+class|abstract|class)[%s]+"), //
+ new RegexOr(//
+ new RegexConcat(//
+ new RegexLeaf("DISPLAY1", "[%g]([^%g]+)[%g]"), //
+ new RegexLeaf("[%s]+as[%s]+"), //
+ new RegexLeaf("CODE1", "(" + CODE + ")")), //
+ new RegexConcat(//
+ new RegexLeaf("CODE2", "(" + CODE + ")"), //
+ new RegexLeaf("[%s]+as[%s]+"), // //
+ new RegexLeaf("DISPLAY2", "[%g]([^%g]+)[%g]")), //
+ new RegexLeaf("CODE3", "(" + CODE + ")"), //
+ new RegexLeaf("CODE4", "[%g]([^%g]+)[%g]")), //
+ new RegexLeaf("GENERIC", "(?:[%s]*\\<(" + GenericRegexProducer.PATTERN + ")\\>)?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("STEREO", "(\\<{2}.*\\>{2})?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("COLOR", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("LINECOLOR", "(?:##(?:\\[(dotted|dashed|bold)\\])?(\\w+)?)?"), //
+ new RegexLeaf("EXTENDS", "([%s]+(extends)[%s]+(" + CommandCreateClassMultilines.CODES + "))?"), //
+ new RegexLeaf("IMPLEMENTS", "([%s]+(implements)[%s]+(" + CommandCreateClassMultilines.CODES + "))?"), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ClassDiagram diagram, RegexResult arg) {
+ final LeafType type = LeafType.getLeafType(StringUtils.goUpperCase(arg.get("TYPE", 0)));
+ final Code code = Code.of(arg.getLazzy("CODE", 0)).eventuallyRemoveStartingAndEndingDoubleQuote("\"([:");
+ final String display = arg.getLazzy("DISPLAY", 0);
+
+ final String stereotype = arg.get("STEREO", 0);
+ final String generic = arg.get("GENERIC", 0);
+ final ILeaf entity;
+ if (diagram.leafExist(code)) {
+ entity = diagram.getOrCreateLeaf(code, type, null);
+ entity.muteToType(type, null);
+ } else {
+ entity = diagram.createLeaf(code, Display.getWithNewlines(display), type, null);
+ }
+ if (stereotype != null) {
+ entity.setStereotype(new Stereotype(stereotype, diagram.getSkinParam().getCircledCharacterRadius(), diagram
+ .getSkinParam().getFont(FontParam.CIRCLED_CHARACTER, null, false), diagram.getSkinParam()
+ .getIHtmlColorSet()));
+ }
+ if (generic != null) {
+ entity.setGeneric(generic);
+ }
+
+ final String urlString = arg.get("URL", 0);
+ if (urlString != null) {
+ final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
+ final Url url = urlBuilder.getUrl(urlString);
+ entity.addUrl(url);
+ }
+
+ entity.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0)));
+ entity.setSpecificLineColor(diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("LINECOLOR", 1)));
+ CommandCreateClassMultilines.applyStroke(entity, arg.get("LINECOLOR", 0));
+
+ // manageExtends(diagram, arg, entity);
+ CommandCreateClassMultilines.manageExtends("EXTENDS", diagram, arg, entity);
+ CommandCreateClassMultilines.manageExtends("IMPLEMENTS", diagram, arg, entity);
+
+ return CommandExecutionResult.ok();
+ }
+
+ // public static void manageExtends(ClassDiagram system, RegexResult arg, final IEntity entity) {
+ // if (arg.get("EXTENDS", 1) != null) {
+ // final Mode mode = arg.get("EXTENDS", 1).equalsIgnoreCase("extends") ? Mode.EXTENDS : Mode.IMPLEMENTS;
+ // final Code other = Code.of(arg.get("EXTENDS", 2));
+ // LeafType type2 = LeafType.CLASS;
+ // if (mode == Mode.IMPLEMENTS) {
+ // type2 = LeafType.INTERFACE;
+ // }
+ // if (mode == Mode.EXTENDS && entity.getEntityType() == LeafType.INTERFACE) {
+ // type2 = LeafType.INTERFACE;
+ // }
+ // final IEntity cl2 = system.getOrCreateLeaf(other, type2, null);
+ // LinkType typeLink = new LinkType(LinkDecor.NONE, LinkDecor.EXTENDS);
+ // if (type2 == LeafType.INTERFACE && entity.getEntityType() != LeafType.INTERFACE) {
+ // typeLink = typeLink.getDashed();
+ // }
+ // final Link link = new Link(cl2, entity, typeLink, null, 2, null, null, system.getLabeldistance(),
+ // system.getLabelangle());
+ // system.addLink(link);
+ // }
+ // }
+
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java
new file mode 100644
index 0000000..9dd87cf
--- /dev/null
+++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateClassMultilines.java
@@ -0,0 +1,234 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.classdiagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
+import net.sourceforge.plantuml.classdiagram.ClassDiagram;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.CommandMultilines2;
+import net.sourceforge.plantuml.command.MultilinesStrategy;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexOr;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.cucadiagram.LinkDecor;
+import net.sourceforge.plantuml.cucadiagram.LinkStyle;
+import net.sourceforge.plantuml.cucadiagram.LinkType;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.graphic.HtmlColorSet;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.skin.VisibilityModifier;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.StringUtils;
+
+public class CommandCreateClassMultilines extends CommandMultilines2<ClassDiagram> {
+
+ private static final String CODE = "(?:\\.|::)?[\\p{L}0-9_]+(?:(?:\\.|::)[\\p{L}0-9_]+)*";
+ public static final String CODES = CODE + "(?:\\s*,\\s*" + CODE + ")*";
+
+ enum Mode {
+ EXTENDS, IMPLEMENTS
+ };
+
+ public CommandCreateClassMultilines() {
+ super(getRegexConcat(), MultilinesStrategy.REMOVE_STARTING_QUOTE);
+ }
+
+ @Override
+ public String getPatternEnd() {
+ return "(?i)^[%s]*\\}[%s]*$";
+ }
+
+ private static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("TYPE", "(interface|enum|abstract[%s]+class|abstract|class)[%s]+"), //
+ new RegexOr(//
+ new RegexConcat(//
+ new RegexLeaf("DISPLAY1", "[%g]([^%g]+)[%g]"), //
+ new RegexLeaf("[%s]+as[%s]+"), //
+ new RegexLeaf("CODE1", "(" + CommandCreateClass.CODE + ")")), //
+ new RegexConcat(//
+ new RegexLeaf("CODE2", "(" + CommandCreateClass.CODE + ")"), //
+ new RegexLeaf("[%s]+as[%s]+"), // //
+ new RegexLeaf("DISPLAY2", "[%g]([^%g]+)[%g]")), //
+ new RegexLeaf("CODE3", "(" + CommandCreateClass.CODE + ")"), //
+ new RegexLeaf("CODE4", "[%g]([^%g]+)[%g]")), //
+ new RegexLeaf("GENERIC", "(?:[%s]*\\<(" + GenericRegexProducer.PATTERN + ")\\>)?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("STEREO", "(\\<\\<.+\\>\\>)?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("COLOR", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("LINECOLOR", "(?:##(?:\\[(dotted|dashed|bold)\\])?(\\w+)?)?"), //
+ new RegexLeaf("EXTENDS", "([%s]+(extends)[%s]+(" + CODES + "))?"), //
+ new RegexLeaf("IMPLEMENTS", "([%s]+(implements)[%s]+(" + CODES + "))?"), //
+ new RegexLeaf("[%s]*\\{[%s]*$"));
+ }
+
+ public CommandExecutionResult executeNow(ClassDiagram diagram, List<String> lines) {
+ StringUtils.trim(lines, false);
+ final RegexResult line0 = getStartingPattern().matcher(lines.get(0).trim());
+ final IEntity entity = executeArg0(diagram, line0);
+ if (entity == null) {
+ return CommandExecutionResult.error("No such entity");
+ }
+ lines = lines.subList(1, lines.size() - 1);
+ final Url url;
+ if (lines.size() > 0) {
+ final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
+ url = urlBuilder.getUrl(lines.get(0).toString());
+ } else {
+ url = null;
+ }
+ if (url != null) {
+ lines = lines.subList(1, lines.size());
+ }
+ for (String s : lines) {
+ if (s.length() > 0 && VisibilityModifier.isVisibilityCharacter(s.charAt(0))) {
+ diagram.setVisibilityModifierPresent(true);
+ }
+ entity.addFieldOrMethod(s);
+ }
+ if (url != null) {
+ entity.addUrl(url);
+ }
+
+ manageExtends("EXTENDS", diagram, line0, entity);
+ manageExtends("IMPLEMENTS", diagram, line0, entity);
+
+ return CommandExecutionResult.ok();
+ }
+
+ public static void manageExtends(String keyword, ClassDiagram system, RegexResult arg, final IEntity entity) {
+ if (arg.get(keyword, 1) != null) {
+ final Mode mode = arg.get(keyword, 1).equalsIgnoreCase("extends") ? Mode.EXTENDS : Mode.IMPLEMENTS;
+ LeafType type2 = LeafType.CLASS;
+ if (mode == Mode.IMPLEMENTS) {
+ type2 = LeafType.INTERFACE;
+ }
+ if (mode == Mode.EXTENDS && entity.getEntityType() == LeafType.INTERFACE) {
+ type2 = LeafType.INTERFACE;
+ }
+ final String codes = arg.get(keyword, 2);
+ for (String s : codes.split(",")) {
+ final Code other = Code.of(s.trim());
+ final IEntity cl2 = system.getOrCreateLeaf(other, type2, null);
+ LinkType typeLink = new LinkType(LinkDecor.NONE, LinkDecor.EXTENDS);
+ if (type2 == LeafType.INTERFACE && entity.getEntityType() != LeafType.INTERFACE) {
+ typeLink = typeLink.getDashed();
+ }
+ final Link link = new Link(cl2, entity, typeLink, null, 2, null, null, system.getLabeldistance(),
+ system.getLabelangle());
+ system.addLink(link);
+ }
+ }
+ }
+
+ private IEntity executeArg0(ClassDiagram diagram, RegexResult arg) {
+
+ final LeafType type = LeafType.getLeafType(StringUtils.goUpperCase(arg.get("TYPE", 0)));
+
+ final Code code = Code.of(arg.getLazzy("CODE", 0)).eventuallyRemoveStartingAndEndingDoubleQuote("\"([:");
+ final String display = arg.getLazzy("DISPLAY", 0);
+
+ final String stereotype = arg.get("STEREO", 0);
+ final String generic = arg.get("GENERIC", 0);
+
+ final ILeaf result;
+ if (diagram.leafExist(code)) {
+ result = diagram.getOrCreateLeaf(code, null, null);
+ result.muteToType(type, null);
+ } else {
+ result = diagram.createLeaf(code, Display.getWithNewlines(display), type, null);
+ }
+ if (stereotype != null) {
+ result.setStereotype(new Stereotype(stereotype, diagram.getSkinParam().getCircledCharacterRadius(), diagram
+ .getSkinParam().getFont(FontParam.CIRCLED_CHARACTER, null, false), diagram.getSkinParam()
+ .getIHtmlColorSet()));
+ }
+
+ final String urlString = arg.get("URL", 0);
+ if (urlString != null) {
+ final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
+ final Url url = urlBuilder.getUrl(urlString);
+ result.addUrl(url);
+ }
+
+ result.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0)));
+ result.setSpecificLineColor(diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("LINECOLOR", 1)));
+ applyStroke(result, arg.get("LINECOLOR", 0));
+
+ if (generic != null) {
+ result.setGeneric(generic);
+ }
+ return result;
+ }
+
+ public static UStroke getStroke(LinkStyle style) {
+ if (style == LinkStyle.DASHED) {
+ return new UStroke(6, 6, 1);
+ }
+ if (style == LinkStyle.DOTTED) {
+ return new UStroke(1, 3, 1);
+ }
+ if (style == LinkStyle.BOLD) {
+ return new UStroke(2.5);
+ }
+ return new UStroke();
+ }
+
+ public static void applyStroke(IEntity entity, String s) {
+ if (s == null) {
+ return;
+ }
+ final LinkStyle style = LinkStyle.valueOf(StringUtils.goUpperCase(s));
+ entity.setSpecificLineStroke(getStroke(style));
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateElementFull2.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateElementFull2.java
new file mode 100644
index 0000000..62e7782
--- /dev/null
+++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandCreateElementFull2.java
@@ -0,0 +1,224 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.classdiagram.command;
+
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
+import net.sourceforge.plantuml.classdiagram.ClassDiagram;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexOr;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.USymbol;
+import net.sourceforge.plantuml.StringUtils;
+
+public class CommandCreateElementFull2 extends SingleLineCommand2<ClassDiagram> {
+
+ private final Mode mode;
+
+ public static enum Mode {
+ NORMAL_KEYWORD, WITH_MIX_PREFIX
+ }
+
+ public CommandCreateElementFull2(Mode mode) {
+ super(getRegexConcat(mode));
+ this.mode = mode;
+ }
+
+ private static RegexConcat getRegexConcat(Mode mode) {
+
+ String regex = "(?:(actor|usecase|component)[%s]+)";
+ if (mode == Mode.WITH_MIX_PREFIX) {
+ regex = "mix_" + regex;
+ }
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("SYMBOL", regex), //
+ new RegexLeaf("[%s]*"), //
+ new RegexOr(//
+ new RegexLeaf("CODE1", CODE_WITH_QUOTE) //
+ ), //
+ new RegexLeaf("STEREOTYPE", "(?:[%s]*(\\<\\<.+\\>\\>))?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("COLOR", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), //
+ new RegexLeaf("$"));
+ }
+
+ private static final String CODE_CORE = "[\\p{L}0-9_.]+|\\(\\)[%s]*[\\p{L}0-9_.]+|\\(\\)[%s]*[%g][^%g]+[%g]|:[^:]+:|\\([^()]+\\)|\\[[^\\[\\]]+\\]";
+ private static final String CODE = "(" + CODE_CORE + ")";
+ private static final String CODE_WITH_QUOTE = "(" + CODE_CORE + "|[%g][^%g]+[%g])";
+
+ private static final String DISPLAY_CORE = "[%g][^%g]+[%g]|:[^:]+:|\\([^()]+\\)|\\[[^\\[\\]]+\\]";
+ private static final String DISPLAY = "(" + DISPLAY_CORE + ")";
+ private static final String DISPLAY_WITHOUT_QUOTE = "(" + DISPLAY_CORE + "|[\\p{L}0-9_.]+)";
+
+ @Override
+ final protected boolean isForbidden(String line) {
+ if (line.matches("^[\\p{L}0-9_.]+$")) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ClassDiagram diagram, RegexResult arg) {
+ if (mode == Mode.NORMAL_KEYWORD && diagram.isAllowMixing() == false) {
+ return CommandExecutionResult
+ .error("Use 'allow_mixing' if you want to mix classes and other UML elements.");
+ }
+ String codeRaw = arg.getLazzy("CODE", 0);
+ final String displayRaw = arg.getLazzy("DISPLAY", 0);
+ final char codeChar = getCharEncoding(codeRaw);
+ final char codeDisplay = getCharEncoding(displayRaw);
+ final String symbol;
+ if (codeRaw.startsWith("()")) {
+ symbol = "interface";
+ codeRaw = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(codeRaw.substring(2).trim());
+ } else if (codeChar == '(' || codeDisplay == '(') {
+ symbol = "usecase";
+ } else if (codeChar == ':' || codeDisplay == ':') {
+ symbol = "actor";
+ } else if (codeChar == '[' || codeDisplay == '[') {
+ symbol = "component";
+ } else {
+ symbol = arg.get("SYMBOL", 0);
+ }
+
+ final LeafType type;
+ final USymbol usymbol;
+
+ if (symbol == null) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.ACTOR;
+ } else if (symbol.equalsIgnoreCase("artifact")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.ARTIFACT;
+ } else if (symbol.equalsIgnoreCase("folder")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.FOLDER;
+ } else if (symbol.equalsIgnoreCase("package")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.PACKAGE;
+ } else if (symbol.equalsIgnoreCase("rectangle")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.RECTANGLE;
+ } else if (symbol.equalsIgnoreCase("node")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.NODE;
+ } else if (symbol.equalsIgnoreCase("frame")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.FRAME;
+ } else if (symbol.equalsIgnoreCase("cloud")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.CLOUD;
+ } else if (symbol.equalsIgnoreCase("database")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.DATABASE;
+ } else if (symbol.equalsIgnoreCase("storage")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.STORAGE;
+ } else if (symbol.equalsIgnoreCase("agent")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.AGENT;
+ } else if (symbol.equalsIgnoreCase("actor")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.ACTOR;
+ } else if (symbol.equalsIgnoreCase("component")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = diagram.getSkinParam().useUml2ForComponent() ? USymbol.COMPONENT2 : USymbol.COMPONENT1;
+ } else if (symbol.equalsIgnoreCase("boundary")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.BOUNDARY;
+ } else if (symbol.equalsIgnoreCase("control")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.CONTROL;
+ } else if (symbol.equalsIgnoreCase("entity")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.ENTITY_DOMAIN;
+ } else if (symbol.equalsIgnoreCase("interface")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.INTERFACE;
+ } else if (symbol.equalsIgnoreCase("()")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.INTERFACE;
+ } else if (symbol.equalsIgnoreCase("usecase")) {
+ type = LeafType.USECASE;
+ usymbol = null;
+ } else {
+ throw new IllegalStateException();
+ }
+
+ final Code code = Code.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(codeRaw));
+ String display = displayRaw;
+ if (display == null) {
+ display = code.getFullName();
+ }
+ display = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(display);
+ final String stereotype = arg.getLazzy("STEREOTYPE", 0);
+ final IEntity entity = diagram.getOrCreateLeaf(code, type, usymbol);
+ entity.setDisplay(Display.getWithNewlines(display));
+ entity.setUSymbol(usymbol);
+ if (stereotype != null) {
+ entity.setStereotype(new Stereotype(stereotype, diagram.getSkinParam().getCircledCharacterRadius(), diagram
+ .getSkinParam().getFont(FontParam.CIRCLED_CHARACTER, null, false), diagram.getSkinParam()
+ .getIHtmlColorSet()));
+ }
+
+ final String urlString = arg.get("URL", 0);
+ if (urlString != null) {
+ final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
+ final Url url = urlBuilder.getUrl(urlString);
+ entity.addUrl(url);
+ }
+
+ entity.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0)));
+ return CommandExecutionResult.ok();
+ }
+
+ private char getCharEncoding(final String codeRaw) {
+ return codeRaw != null && codeRaw.length() > 2 ? codeRaw.charAt(0) : 0;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandDiamondAssociation.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandDiamondAssociation.java
new file mode 100644
index 0000000..7ceaca7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandDiamondAssociation.java
@@ -0,0 +1,61 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.classdiagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.classdiagram.ClassDiagram;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+
+public class CommandDiamondAssociation extends SingleLineCommand<ClassDiagram> {
+
+ public CommandDiamondAssociation() {
+ super("(?i)^\\<\\>[%s]*([\\p{L}0-9_.]+)$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ClassDiagram diagram, List<String> arg) {
+ final Code code = Code.of(arg.get(0));
+ if (diagram.leafExist(code)) {
+ return CommandExecutionResult.error("Already existing : "+code.getFullName());
+ }
+ diagram.createLeaf(code, null, LeafType.ASSOCIATION, null);
+
+ return CommandExecutionResult.ok();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShow.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShow.java
new file mode 100644
index 0000000..921ec32
--- /dev/null
+++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShow.java
@@ -0,0 +1,188 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.classdiagram.command;
+
+import java.util.EnumSet;
+import java.util.Set;
+
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.UmlDiagram;
+import net.sourceforge.plantuml.classdiagram.ClassDiagram;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.EntityGender;
+import net.sourceforge.plantuml.cucadiagram.EntityGenderUtils;
+import net.sourceforge.plantuml.cucadiagram.EntityPortion;
+import net.sourceforge.plantuml.cucadiagram.EntityUtils;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+import net.sourceforge.plantuml.descdiagram.DescriptionDiagram;
+
+public class CommandHideShow extends SingleLineCommand2<UmlDiagram> {
+
+ private static final EnumSet<EntityPortion> PORTION_METHOD = EnumSet.<EntityPortion> of(EntityPortion.METHOD);
+ private static final EnumSet<EntityPortion> PORTION_MEMBER = EnumSet.<EntityPortion> of(EntityPortion.FIELD,
+ EntityPortion.METHOD);
+ private static final EnumSet<EntityPortion> PORTION_FIELD = EnumSet.<EntityPortion> of(EntityPortion.FIELD);
+
+ public CommandHideShow() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("COMMAND", "(hide|show)"), //
+ new RegexLeaf("[%s]+"), //
+ new RegexLeaf("GENDER",
+ "(?:(class|interface|enum|annotation|abstract|[\\p{L}0-9_.]+|[%g][^%g]+[%g]|\\<\\<.*\\>\\>)[%s]+)*?"), //
+ new RegexLeaf("EMPTY", "(?:(empty)[%s]+)?"), //
+ new RegexLeaf("PORTION", "(members?|attributes?|fields?|methods?|circle\\w*|stereotypes?)"), //
+ new RegexLeaf("$"));
+ }
+
+ private final EntityGender emptyByGender(Set<EntityPortion> portion) {
+ if (portion == PORTION_METHOD) {
+ return EntityGenderUtils.emptyMethods();
+ }
+ if (portion == PORTION_FIELD) {
+ return EntityGenderUtils.emptyFields();
+ }
+ if (portion == PORTION_MEMBER) {
+ return EntityGenderUtils.emptyMembers();
+ }
+ return EntityGenderUtils.all();
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(UmlDiagram classDiagram, RegexResult arg) {
+ if (classDiagram instanceof ClassDiagram) {
+ return executeClassDiagram((ClassDiagram) classDiagram, arg);
+ }
+ if (classDiagram instanceof DescriptionDiagram) {
+ return executeDescriptionDiagram((DescriptionDiagram) classDiagram, arg);
+ }
+ // Just ignored
+ return CommandExecutionResult.ok();
+ }
+
+ private CommandExecutionResult executeDescriptionDiagram(DescriptionDiagram diagram, RegexResult arg) {
+ final Set<EntityPortion> portion = getEntityPortion(arg.get("PORTION", 0));
+ final EntityGender gender;
+ final String arg1 = arg.get("GENDER", 0);
+ if (arg1 == null) {
+ gender = EntityGenderUtils.all();
+ } else if (arg1.equalsIgnoreCase("class")) {
+ gender = EntityGenderUtils.byEntityType(LeafType.CLASS);
+ } else if (arg1.equalsIgnoreCase("interface")) {
+ gender = EntityGenderUtils.byEntityType(LeafType.INTERFACE);
+ } else if (arg1.equalsIgnoreCase("enum")) {
+ gender = EntityGenderUtils.byEntityType(LeafType.ENUM);
+ } else if (arg1.equalsIgnoreCase("abstract")) {
+ gender = EntityGenderUtils.byEntityType(LeafType.ABSTRACT_CLASS);
+ } else if (arg1.equalsIgnoreCase("annotation")) {
+ gender = EntityGenderUtils.byEntityType(LeafType.ANNOTATION);
+ } else if (arg1.startsWith("<<")) {
+ gender = EntityGenderUtils.byStereotype(arg1);
+ } else {
+ final IEntity entity = diagram.getOrCreateLeaf(Code.of(arg1), null, null);
+ gender = EntityGenderUtils.byEntityAlone(entity);
+ }
+
+ diagram.hideOrShow(gender, portion, arg.get("COMMAND", 0).equalsIgnoreCase("show"));
+ return CommandExecutionResult.ok();
+ }
+
+ private CommandExecutionResult executeClassDiagram(ClassDiagram classDiagram, RegexResult arg) {
+
+ final Set<EntityPortion> portion = getEntityPortion(arg.get("PORTION", 0));
+
+ EntityGender gender = null;
+ final String arg1 = arg.get("GENDER", 0);
+ if (arg1 == null) {
+ gender = EntityGenderUtils.all();
+ } else if (arg1.equalsIgnoreCase("class")) {
+ gender = EntityGenderUtils.byEntityType(LeafType.CLASS);
+ } else if (arg1.equalsIgnoreCase("interface")) {
+ gender = EntityGenderUtils.byEntityType(LeafType.INTERFACE);
+ } else if (arg1.equalsIgnoreCase("enum")) {
+ gender = EntityGenderUtils.byEntityType(LeafType.ENUM);
+ } else if (arg1.equalsIgnoreCase("abstract")) {
+ gender = EntityGenderUtils.byEntityType(LeafType.ABSTRACT_CLASS);
+ } else if (arg1.equalsIgnoreCase("annotation")) {
+ gender = EntityGenderUtils.byEntityType(LeafType.ANNOTATION);
+ } else if (arg1.startsWith("<<")) {
+ gender = EntityGenderUtils.byStereotype(arg1);
+ } else {
+ final IEntity entity = classDiagram.getOrCreateLeaf(Code.of(arg1), null, null);
+ gender = EntityGenderUtils.byEntityAlone(entity);
+ }
+ if (gender != null) {
+ final boolean empty = arg.get("EMPTY", 0) != null;
+ if (empty == true) {
+ gender = EntityGenderUtils.and(gender, emptyByGender(portion));
+ }
+ if (EntityUtils.groupRoot(classDiagram.getCurrentGroup()) == false) {
+ gender = EntityGenderUtils.and(gender, EntityGenderUtils.byPackage(classDiagram.getCurrentGroup()));
+ }
+ classDiagram.hideOrShow(gender, portion, arg.get("COMMAND", 0).equalsIgnoreCase("show"));
+ }
+ return CommandExecutionResult.ok();
+ }
+
+ private Set<EntityPortion> getEntityPortion(String s) {
+ final String sub = StringUtils.goLowerCase(s.substring(0, 3));
+ if (sub.equals("met")) {
+ return PORTION_METHOD;
+ }
+ if (sub.equals("mem")) {
+ return PORTION_MEMBER;
+ }
+ if (sub.equals("att") || sub.equals("fie")) {
+ return PORTION_FIELD;
+ }
+ if (sub.equals("cir")) {
+ return EnumSet.<EntityPortion> of(EntityPortion.CIRCLED_CHARACTER);
+ }
+ if (sub.equals("ste")) {
+ return EnumSet.<EntityPortion> of(EntityPortion.STEREOTYPE);
+ }
+ throw new IllegalArgumentException();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShow3.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShow3.java
new file mode 100644
index 0000000..c3f4685
--- /dev/null
+++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShow3.java
@@ -0,0 +1,140 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.classdiagram.command;
+
+import java.util.EnumSet;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.UmlDiagram;
+import net.sourceforge.plantuml.classdiagram.ClassDiagram;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.EntityPortion;
+import net.sourceforge.plantuml.skin.VisibilityModifier;
+
+public class CommandHideShow3 extends SingleLineCommand2<UmlDiagram> {
+
+ private static final EnumSet<EntityPortion> PORTION_METHOD = EnumSet.<EntityPortion> of(EntityPortion.METHOD);
+ private static final EnumSet<EntityPortion> PORTION_MEMBER = EnumSet.<EntityPortion> of(EntityPortion.FIELD,
+ EntityPortion.METHOD);
+ private static final EnumSet<EntityPortion> PORTION_FIELD = EnumSet.<EntityPortion> of(EntityPortion.FIELD);
+
+ public CommandHideShow3() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("COMMAND", "(hide|show)"), //
+ new RegexLeaf("[%s]+"), //
+ new RegexLeaf("VISIBILITY",
+ "((?:public|private|protected|package)?(?:[,%s]+(?:public|private|protected|package))*)"), //
+ new RegexLeaf("[%s]+"), //
+ new RegexLeaf("PORTION", "(members?|attributes?|fields?|methods?)"), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(UmlDiagram classDiagram, RegexResult arg) {
+ if (classDiagram instanceof ClassDiagram) {
+ return executeArgClass((ClassDiagram) classDiagram, arg);
+ }
+ // Just ignored
+ return CommandExecutionResult.ok();
+ }
+
+
+ private CommandExecutionResult executeArgClass(ClassDiagram classDiagram, RegexResult arg) {
+
+ final Set<EntityPortion> portion = getEntityPortion(arg.get("PORTION", 0));
+
+ final Set<VisibilityModifier> visibilities = EnumSet.<VisibilityModifier> noneOf(VisibilityModifier.class);
+ final StringTokenizer st = new StringTokenizer(StringUtils.goLowerCase(arg.get("VISIBILITY", 0)), " ,");
+ while (st.hasMoreTokens()) {
+ addVisibilities(st.nextToken(), portion, visibilities);
+ }
+
+ classDiagram.hideOrShow(visibilities, arg.get("COMMAND", 0).equalsIgnoreCase("show"));
+
+ return CommandExecutionResult.ok();
+ }
+
+ private void addVisibilities(String token, Set<EntityPortion> portion, Set<VisibilityModifier> result) {
+ if (token.equals("public") && portion.contains(EntityPortion.FIELD)) {
+ result.add(VisibilityModifier.PUBLIC_FIELD);
+ }
+ if (token.equals("public") && portion.contains(EntityPortion.METHOD)) {
+ result.add(VisibilityModifier.PUBLIC_METHOD);
+ }
+ if (token.equals("private") && portion.contains(EntityPortion.FIELD)) {
+ result.add(VisibilityModifier.PRIVATE_FIELD);
+ }
+ if (token.equals("private") && portion.contains(EntityPortion.METHOD)) {
+ result.add(VisibilityModifier.PRIVATE_METHOD);
+ }
+ if (token.equals("protected") && portion.contains(EntityPortion.FIELD)) {
+ result.add(VisibilityModifier.PROTECTED_FIELD);
+ }
+ if (token.equals("protected") && portion.contains(EntityPortion.METHOD)) {
+ result.add(VisibilityModifier.PROTECTED_METHOD);
+ }
+ if (token.equals("package") && portion.contains(EntityPortion.FIELD)) {
+ result.add(VisibilityModifier.PACKAGE_PRIVATE_FIELD);
+ }
+ if (token.equals("package") && portion.contains(EntityPortion.METHOD)) {
+ result.add(VisibilityModifier.PACKAGE_PRIVATE_METHOD);
+ }
+ }
+
+ private Set<EntityPortion> getEntityPortion(String s) {
+ final String sub = StringUtils.goLowerCase(s.substring(0, 3));
+ if (sub.equals("met")) {
+ return PORTION_METHOD;
+ }
+ if (sub.equals("mem")) {
+ return PORTION_MEMBER;
+ }
+ if (sub.equals("att") || sub.equals("fie")) {
+ return PORTION_FIELD;
+ }
+ throw new IllegalArgumentException();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowSpecificClass.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowSpecificClass.java
new file mode 100644
index 0000000..48cb52a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandHideShowSpecificClass.java
@@ -0,0 +1,79 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.classdiagram.command;
+
+import net.sourceforge.plantuml.classdiagram.ClassDiagram;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+
+public class CommandHideShowSpecificClass extends SingleLineCommand2<ClassDiagram> {
+
+ public CommandHideShowSpecificClass() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("COMMAND", "(hide|show)"), //
+ new RegexLeaf("[%s]+"), //
+ new RegexLeaf("CODE", "(" + CommandCreateClass.CODE + ")"), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ClassDiagram classDiagram, RegexResult arg) {
+
+ final String codeString = arg.get("CODE", 0);
+ if (codeString.equals("class")) {
+ classDiagram.hideOrShow(LeafType.CLASS, arg.get("COMMAND", 0).equalsIgnoreCase("show"));
+ } else if (codeString.equals("interface")) {
+ classDiagram.hideOrShow(LeafType.INTERFACE, arg.get("COMMAND", 0).equalsIgnoreCase("show"));
+ } else {
+ final Code code = Code.of(codeString);
+ final ILeaf leaf = classDiagram.getEntityFactory().getLeafs().get(code);
+ if (leaf == null) {
+ return CommandExecutionResult.error("Class does not exist : " + code.getFullName());
+ }
+ classDiagram.hideOrShow(leaf, arg.get("COMMAND", 0).equalsIgnoreCase("show"));
+ }
+ return CommandExecutionResult.ok();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandImport.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandImport.java
new file mode 100644
index 0000000..34e8993
--- /dev/null
+++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandImport.java
@@ -0,0 +1,110 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.classdiagram.command;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+
+import net.sourceforge.plantuml.FileSystem;
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.classdiagram.ClassDiagram;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.cucadiagram.LinkDecor;
+import net.sourceforge.plantuml.cucadiagram.LinkType;
+
+public class CommandImport extends SingleLineCommand<ClassDiagram> {
+
+ public CommandImport() {
+ super("(?i)^import[%s]+[%g]?([^%g]+)[%g]?$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ClassDiagram classDiagram, List<String> arg) {
+ final String arg0 = arg.get(0);
+ try {
+ final File f = FileSystem.getInstance().getFile(arg0);
+
+ if (f.isFile()) {
+ includeSimpleFile(classDiagram, f);
+ } else if (f.isDirectory()) {
+ includeDirectory(classDiagram, f);
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ return CommandExecutionResult.error("IO error " + e);
+ }
+ return CommandExecutionResult.ok();
+ }
+
+ private void includeDirectory(ClassDiagram classDiagram, File dir) throws IOException {
+ for (File f : dir.listFiles()) {
+ includeSimpleFile(classDiagram, f);
+ }
+
+ }
+
+ private void includeSimpleFile(ClassDiagram classDiagram, File f) throws IOException {
+ if (StringUtils.goLowerCase(f.getName()).endsWith(".java")) {
+ includeFileJava(classDiagram, f);
+ }
+ // if (f.getName().goLowerCase().endsWith(".sql")) {
+ // includeFileSql(f);
+ // }
+ }
+
+ private void includeFileJava(ClassDiagram classDiagram, final File f) throws IOException {
+ final JavaFile javaFile = new JavaFile(f);
+ for (JavaClass cl : javaFile.getJavaClasses()) {
+ final Code name = Code.of(cl.getName());
+ final IEntity ent1 = classDiagram.getOrCreateLeaf(name, cl.getType(), null);
+
+ for (String p : cl.getParents()) {
+ final IEntity ent2 = classDiagram.getOrCreateLeaf(Code.of(p), cl.getParentType(), null);
+ final Link link = new Link(ent2, ent1, new LinkType(LinkDecor.NONE, LinkDecor.EXTENDS), null, 2);
+ classDiagram.addLink(link);
+ }
+ }
+ }
+
+ // private void includeFileSql(final File f) throws IOException {
+ // new SqlImporter(getSystem(), f).process();
+ // }
+
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandLayoutNewLine.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandLayoutNewLine.java
new file mode 100644
index 0000000..fc5db07
--- /dev/null
+++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandLayoutNewLine.java
@@ -0,0 +1,62 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.classdiagram.command;
+
+import net.sourceforge.plantuml.classdiagram.ClassDiagram;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+
+public class CommandLayoutNewLine extends SingleLineCommand2<ClassDiagram> {
+
+ public CommandLayoutNewLine() {
+ super(getRegexConcat());
+ }
+
+ private static RegexConcat getRegexConcat() {
+
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("layout_new_line"), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ClassDiagram diagram, RegexResult arg) {
+ diagram.layoutNewLine();
+ return CommandExecutionResult.ok();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass.java
new file mode 100644
index 0000000..f475f44
--- /dev/null
+++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass.java
@@ -0,0 +1,516 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.classdiagram.command;
+
+import java.util.StringTokenizer;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.Direction;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.UmlDiagramType;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexOr;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.cucadiagram.LinkArrow;
+import net.sourceforge.plantuml.cucadiagram.LinkDecor;
+import net.sourceforge.plantuml.cucadiagram.LinkType;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.objectdiagram.AbstractClassOrObjectDiagram;
+import net.sourceforge.plantuml.StringUtils;
+
+final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrObjectDiagram> {
+
+ public CommandLinkClass(UmlDiagramType umlDiagramType) {
+ super(getRegexConcat(umlDiagramType));
+ }
+
+ static private RegexConcat getRegexConcat(UmlDiagramType umlDiagramType) {
+ return new RegexConcat(
+ new RegexLeaf("HEADER", "^(?:@([\\d.]+)[%s]+)?"), //
+ new RegexOr(//
+ new RegexLeaf("ENT1", "(?:" + optionalKeywords(umlDiagramType) + "[%s]+)?"
+ + getClassIdentifier()),
+ new RegexLeaf("COUPLE1",
+ "\\([%s]*(\\.?[\\p{L}0-9_]+(?:\\.[\\p{L}0-9_]+)*)[%s]*,[%s]*(\\.?[\\p{L}0-9_]+(?:\\.[\\p{L}0-9_]+)*)[%s]*\\)")),
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("FIRST_LABEL", "(?:[%g]([^%g]+)[%g])?"), //
+ new RegexLeaf("[%s]*"), //
+
+ new RegexConcat(
+ //
+ new RegexLeaf("ARROW_HEAD1", "([%s]+o|[#\\[<*+^]|[<\\[]\\|)?"), //
+ new RegexLeaf("ARROW_BODY1", "([-=.]+)"), //
+ new RegexLeaf("ARROW_STYLE1",
+ "(?:\\[((?:#\\w+|dotted|dashed|bold|hidden|norank)(?:,#\\w+|,dotted|,dashed|,bold|,hidden|,norank)*)\\])?"),
+ new RegexLeaf("ARROW_DIRECTION", "(left|right|up|down|le?|ri?|up?|do?)?"), //
+ new RegexLeaf("INSIDE", "(?:(0|\\(0\\)|\\(0|0\\))(?=[-=.~]))?"), //
+ new RegexLeaf("ARROW_STYLE2",
+ "(?:\\[((?:#\\w+|dotted|dashed|bold|hidden|norank)(?:,#\\w+|,dotted|,dashed|,bold|,hidden|,norank)*)\\])?"),
+ new RegexLeaf("ARROW_BODY2", "([-=.]*)"), //
+ new RegexLeaf("ARROW_HEAD2", "(o[%s]+|[#\\]>*+^]|\\|[>\\]])?")), //
+
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("SECOND_LABEL", "(?:[%g]([^%g]+)[%g])?"),
+ new RegexLeaf("[%s]*"), //
+ new RegexOr(
+ new RegexLeaf("ENT2", "(?:" + optionalKeywords(umlDiagramType) + "[%s]+)?"
+ + getClassIdentifier()),
+ new RegexLeaf("COUPLE2",
+ "\\([%s]*(\\.?[\\p{L}0-9_]+(?:\\.[\\p{L}0-9_]+)*)[%s]*,[%s]*(\\.?[\\p{L}0-9_]+(?:\\.[\\p{L}0-9_]+)*)[%s]*\\)")),
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("LABEL_LINK", "(?::[%s]*(.+))?"), //
+ new RegexLeaf("$"));
+ }
+
+ private static String getClassIdentifier() {
+ return "(" + getSeparator() + "?[\\p{L}0-9_]+(?:" + getSeparator()
+ + "[\\p{L}0-9_]+)*|[%g][^%g]+[%g])[%s]*(\\<\\<.*\\>\\>)?";
+ }
+
+ private static String getSeparator() {
+ return "(?:\\.|::)";
+ }
+
+ private static String optionalKeywords(UmlDiagramType type) {
+ if (type == UmlDiagramType.CLASS) {
+ return "(interface|enum|annotation|abstract[%s]+class|abstract|class)";
+ }
+ if (type == UmlDiagramType.OBJECT) {
+ return "(object)";
+ }
+ throw new IllegalArgumentException();
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(AbstractClassOrObjectDiagram diagram, RegexResult arg) {
+ Code ent1 = Code.of(arg.get("ENT1", 1));
+ Code ent2 = Code.of(arg.get("ENT2", 1));
+ if (ent1 == null) {
+ return executeArgSpecial1(diagram, arg);
+ }
+ if (ent2 == null) {
+ return executeArgSpecial2(diagram, arg);
+ }
+ ent1 = ent1.eventuallyRemoveStartingAndEndingDoubleQuote("\"");
+ ent2 = ent2.eventuallyRemoveStartingAndEndingDoubleQuote("\"");
+ if (diagram.isGroup(ent1) && diagram.isGroup(ent2)) {
+ return executePackageLink(diagram, arg);
+ }
+
+ final IEntity cl1 = diagram.isGroup(ent1) ? diagram.getGroup(Code.of(StringUtils
+ .eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT1", 1), "\""))) : diagram.getOrCreateLeaf(
+ ent1, null, null);
+ final IEntity cl2 = diagram.isGroup(ent2) ? diagram.getGroup(Code.of(StringUtils
+ .eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT2", 1), "\""))) : diagram.getOrCreateLeaf(
+ ent2, null, null);
+
+ if (arg.get("ENT1", 0) != null) {
+ final LeafType type = LeafType.getLeafType(arg.get("ENT1", 0));
+ if (type != LeafType.OBJECT) {
+ ((ILeaf) cl1).muteToType(type, null);
+ }
+ }
+ if (arg.get("ENT2", 0) != null) {
+ final LeafType type = LeafType.getLeafType(arg.get("ENT2", 0));
+ if (type != LeafType.OBJECT) {
+ ((ILeaf) cl2).muteToType(type, null);
+ }
+ }
+ if (arg.get("ENT1", 2) != null) {
+ cl1.setStereotype(new Stereotype(arg.get("ENT1", 2), diagram.getSkinParam().getCircledCharacterRadius(),
+ diagram.getSkinParam().getFont(FontParam.CIRCLED_CHARACTER, null, false), diagram.getSkinParam()
+ .getIHtmlColorSet()));
+ }
+ if (arg.get("ENT2", 2) != null) {
+ cl2.setStereotype(new Stereotype(arg.get("ENT2", 2), diagram.getSkinParam().getCircledCharacterRadius(),
+ diagram.getSkinParam().getFont(FontParam.CIRCLED_CHARACTER, null, false), diagram.getSkinParam()
+ .getIHtmlColorSet()));
+ }
+
+ final LinkType linkType = getLinkType(arg);
+ final Direction dir = getDirection(arg);
+ final int queue;
+ if (dir == Direction.LEFT || dir == Direction.RIGHT) {
+ queue = 1;
+ } else {
+ queue = getQueueLength(arg);
+ }
+
+ String firstLabel = arg.get("FIRST_LABEL", 0);
+ String secondLabel = arg.get("SECOND_LABEL", 0);
+
+ String labelLink = null;
+
+ if (arg.get("LABEL_LINK", 0) != null) {
+ labelLink = arg.get("LABEL_LINK", 0);
+ if (firstLabel == null && secondLabel == null) {
+ final Pattern p1 = MyPattern.cmpile("^[%g]([^%g]+)[%g]([^%g]+)[%g]([^%g]+)[%g]$");
+ final Matcher m1 = p1.matcher(labelLink);
+ if (m1.matches()) {
+ firstLabel = m1.group(1);
+ labelLink = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(m1.group(2).trim(), "\"")
+ .trim();
+ secondLabel = m1.group(3);
+ } else {
+ final Pattern p2 = MyPattern.cmpile("^[%g]([^%g]+)[%g]([^%g]+)$");
+ final Matcher m2 = p2.matcher(labelLink);
+ if (m2.matches()) {
+ firstLabel = m2.group(1);
+ labelLink = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(m2.group(2).trim(), "\"")
+ .trim();
+ secondLabel = null;
+ } else {
+ final Pattern p3 = MyPattern.cmpile("^([^%g]+)[%g]([^%g]+)[%g]$");
+ final Matcher m3 = p3.matcher(labelLink);
+ if (m3.matches()) {
+ firstLabel = null;
+ labelLink = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(m3.group(1).trim(),
+ "\"").trim();
+ secondLabel = m3.group(2);
+ }
+ }
+ }
+ }
+ labelLink = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(labelLink, "\"");
+ }
+
+ LinkArrow linkArrow = LinkArrow.NONE;
+ if ("<".equals(labelLink)) {
+ linkArrow = LinkArrow.BACKWARD;
+ labelLink = null;
+ } else if (">".equals(labelLink)) {
+ linkArrow = LinkArrow.DIRECT_NORMAL;
+ labelLink = null;
+ } else if (labelLink != null && labelLink.startsWith("< ")) {
+ linkArrow = LinkArrow.BACKWARD;
+ labelLink = labelLink.substring(2).trim();
+ } else if (labelLink != null && labelLink.startsWith("> ")) {
+ linkArrow = LinkArrow.DIRECT_NORMAL;
+ labelLink = labelLink.substring(2).trim();
+ } else if (labelLink != null && labelLink.endsWith(" >")) {
+ linkArrow = LinkArrow.DIRECT_NORMAL;
+ labelLink = labelLink.substring(0, labelLink.length() - 2).trim();
+ } else if (labelLink != null && labelLink.endsWith(" <")) {
+ linkArrow = LinkArrow.BACKWARD;
+ labelLink = labelLink.substring(0, labelLink.length() - 2).trim();
+ }
+
+ Link link = new Link(cl1, cl2, linkType, Display.getWithNewlines(labelLink), queue, firstLabel, secondLabel,
+ diagram.getLabeldistance(), diagram.getLabelangle());
+
+ if (dir == Direction.LEFT || dir == Direction.UP) {
+ link = link.getInv();
+ }
+ link.setLinkArrow(linkArrow);
+ applyStyle(arg.getLazzy("ARROW_STYLE", 0), link);
+
+ addLink(diagram, link, arg.get("HEADER", 0));
+
+ return CommandExecutionResult.ok();
+ }
+
+ private void addLink(AbstractClassOrObjectDiagram diagram, Link link, String weight) {
+ diagram.addLink(link);
+ if (weight == null) {
+ // final LinkType type = link.getType();
+ // --|> highest
+ // --*, -->, --o normal
+ // ..*, ..>, ..o lowest
+ // if (type.isDashed() == false) {
+ // if (type.contains(LinkDecor.EXTENDS)) {
+ // link.setWeight(3);
+ // }
+ // if (type.contains(LinkDecor.ARROW) ||
+ // type.contains(LinkDecor.COMPOSITION)
+ // || type.contains(LinkDecor.AGREGATION)) {
+ // link.setWeight(2);
+ // }
+ // }
+ } else {
+ link.setWeight(Double.parseDouble(weight));
+ }
+ }
+
+ private CommandExecutionResult executePackageLink(AbstractClassOrObjectDiagram diagram, RegexResult arg) {
+ final IEntity cl1 = diagram.getGroup(Code.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(
+ arg.get("ENT1", 1), "\"")));
+ final IEntity cl2 = diagram.getGroup(Code.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(
+ arg.get("ENT2", 1), "\"")));
+
+ final LinkType linkType = getLinkType(arg);
+ final Direction dir = getDirection(arg);
+ final int queue;
+ if (dir == Direction.LEFT || dir == Direction.RIGHT) {
+ queue = 1;
+ } else {
+ queue = getQueueLength(arg);
+ }
+
+ final Display labelLink = Display.getWithNewlines(arg.get("LABEL_LINK", 0));
+ final String firstLabel = arg.get("FIRST_LABEL", 0);
+ final String secondLabel = arg.get("SECOND_LABEL", 0);
+ final Link link = new Link(cl1, cl2, linkType, labelLink, queue, firstLabel, secondLabel,
+ diagram.getLabeldistance(), diagram.getLabelangle());
+
+ diagram.resetPragmaLabel();
+ addLink(diagram, link, arg.get("HEADER", 0));
+ return CommandExecutionResult.ok();
+ }
+
+ private CommandExecutionResult executeArgSpecial1(AbstractClassOrObjectDiagram diagram, RegexResult arg) {
+ final Code clName1 = Code.of(arg.get("COUPLE1", 0));
+ final Code clName2 = Code.of(arg.get("COUPLE1", 1));
+ if (diagram.leafExist(clName1) == false) {
+ return CommandExecutionResult.error("No class " + clName1);
+ }
+ if (diagram.leafExist(clName2) == false) {
+ return CommandExecutionResult.error("No class " + clName2);
+ }
+
+ final Code ent2 = Code.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT2", 1), "\""));
+ final IEntity cl2 = diagram.getOrCreateLeaf(ent2, null, null);
+
+ final LinkType linkType = getLinkType(arg);
+ final Display label = Display.getWithNewlines(arg.get("LABEL_LINK", 0));
+ // final int length = getQueueLength(arg);
+ // final String weight = arg.get("HEADER").get(0);
+
+ final boolean result = diagram.associationClass(1, clName1, clName2, cl2, linkType, label);
+ if (result == false) {
+ return CommandExecutionResult.error("Cannot have more than 2 assocications");
+ }
+
+ return CommandExecutionResult.ok();
+ }
+
+ private CommandExecutionResult executeArgSpecial2(AbstractClassOrObjectDiagram diagram, RegexResult arg) {
+ final Code clName1 = Code.of(arg.get("COUPLE2", 0));
+ final Code clName2 = Code.of(arg.get("COUPLE2", 1));
+ if (diagram.leafExist(clName1) == false) {
+ return CommandExecutionResult.error("No class " + clName1);
+ }
+ if (diagram.leafExist(clName2) == false) {
+ return CommandExecutionResult.error("No class " + clName2);
+ }
+
+ final Code ent1 = Code.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT1", 1), "\""));
+ final IEntity cl1 = diagram.getOrCreateLeaf(ent1, null, null);
+
+ final LinkType linkType = getLinkType(arg);
+ final Display label = Display.getWithNewlines(arg.get("LABEL_LINK", 0));
+ // final int length = getQueueLength(arg);
+ // final String weight = arg.get("HEADER").get(0);
+
+ final boolean result = diagram.associationClass(2, clName1, clName2, cl1, linkType, label);
+ if (result == false) {
+ return CommandExecutionResult.error("Cannot have more than 2 assocications");
+ }
+
+ return CommandExecutionResult.ok();
+ }
+
+ private LinkDecor getDecors1(String s) {
+ if (s == null) {
+ return LinkDecor.NONE;
+ }
+ s = s.trim();
+ if ("<|".equals(s)) {
+ return LinkDecor.EXTENDS;
+ }
+ if ("<".equals(s)) {
+ return LinkDecor.ARROW;
+ }
+ if ("^".equals(s)) {
+ return LinkDecor.EXTENDS;
+ }
+ if ("+".equals(s)) {
+ return LinkDecor.PLUS;
+ }
+ if ("o".equals(s)) {
+ return LinkDecor.AGREGATION;
+ }
+ if ("*".equals(s)) {
+ return LinkDecor.COMPOSITION;
+ }
+ if ("#".equals(s)) {
+ return LinkDecor.SQUARRE;
+ }
+ return LinkDecor.NONE;
+ }
+
+ private LinkDecor getDecors2(String s) {
+ if (s == null) {
+ return LinkDecor.NONE;
+ }
+ s = s.trim();
+ if ("|>".equals(s)) {
+ return LinkDecor.EXTENDS;
+ }
+ if (">".equals(s)) {
+ return LinkDecor.ARROW;
+ }
+ if ("^".equals(s)) {
+ return LinkDecor.EXTENDS;
+ }
+ if ("+".equals(s)) {
+ return LinkDecor.PLUS;
+ }
+ if ("o".equals(s)) {
+ return LinkDecor.AGREGATION;
+ }
+ if ("*".equals(s)) {
+ return LinkDecor.COMPOSITION;
+ }
+ if ("#".equals(s)) {
+ return LinkDecor.SQUARRE;
+ }
+ return LinkDecor.NONE;
+ }
+
+ private LinkType getLinkType(RegexResult arg) {
+ final LinkDecor decors1 = getDecors1(arg.get("ARROW_HEAD1", 0));
+ final LinkDecor decors2 = getDecors2(arg.get("ARROW_HEAD2", 0));
+
+ LinkType result = new LinkType(decors2, decors1);
+ if (arg.get("ARROW_BODY1", 0).contains(".") || arg.get("ARROW_BODY2", 0).contains(".")) {
+ result = result.getDashed();
+ }
+ final String middle = arg.get("INSIDE", 0);
+ if ("0".equals(middle)) {
+ result = result.withMiddleCircle();
+ } else if ("0)".equals(middle)) {
+ result = result.withMiddleCircleCircled1();
+ } else if ("(0".equals(middle)) {
+ result = result.withMiddleCircleCircled2();
+ } else if ("(0)".equals(middle)) {
+ result = result.withMiddleCircleCircled();
+ }
+ return result;
+ }
+
+ private int getQueueLength(RegexResult arg) {
+ String s = getFullArrow(arg);
+ s = s.replaceAll("[^-.=]", "");
+ return s.length();
+ }
+
+ private Direction getDirection(RegexResult arg) {
+ final LinkDecor decors1 = getDecors1(arg.get("ARROW_HEAD1", 0));
+ final LinkDecor decors2 = getDecors2(arg.get("ARROW_HEAD2", 0));
+
+ String s = getFullArrow(arg);
+ s = s.replaceAll("[^-.=\\w]", "");
+ if (s.startsWith("o")) {
+ s = s.substring(1);
+ }
+ if (s.endsWith("o")) {
+ s = s.substring(0, s.length() - 1);
+ }
+
+ Direction result = StringUtils.getQueueDirection(s);
+ if (isInversed(decors1, decors2) && s.matches(".*\\w.*")) {
+ result = result.getInv();
+ }
+
+ return result;
+ }
+
+ private String getFullArrow(RegexResult arg) {
+ return notNull(arg.get("ARROW_HEAD1", 0)) + notNull(arg.get("ARROW_BODY1", 0))
+ + notNull(arg.get("ARROW_DIRECTION", 0)) + notNull(arg.get("ARROW_BODY2", 0))
+ + notNull(arg.get("ARROW_HEAD2", 0));
+ }
+
+ public static String notNull(String s) {
+ if (s == null) {
+ return "";
+ }
+ return s;
+ }
+
+ public static void applyStyle(String arrowStyle, Link link) {
+ if (arrowStyle == null) {
+ return;
+ }
+ final StringTokenizer st = new StringTokenizer(arrowStyle, ",");
+ while (st.hasMoreTokens()) {
+ final String s = st.nextToken();
+ if (s.equalsIgnoreCase("dashed")) {
+ link.goDashed();
+ } else if (s.equalsIgnoreCase("bold")) {
+ link.goBold();
+ } else if (s.equalsIgnoreCase("dotted")) {
+ link.goDotted();
+ } else if (s.equalsIgnoreCase("hidden")) {
+ link.goHidden();
+ } else if (s.equalsIgnoreCase("norank")) {
+ link.goNorank();
+ } else {
+ link.setSpecificColor(s);
+ }
+ }
+ }
+
+ private boolean isInversed(LinkDecor decors1, LinkDecor decors2) {
+ if (decors1 == LinkDecor.ARROW && decors2 != LinkDecor.ARROW) {
+ return true;
+ }
+ if (decors2 == LinkDecor.AGREGATION) {
+ return true;
+ }
+ if (decors2 == LinkDecor.COMPOSITION) {
+ return true;
+ }
+ if (decors2 == LinkDecor.PLUS) {
+ return true;
+ }
+ // if (decors2 == LinkDecor.EXTENDS) {
+ // return true;
+ // }
+ return false;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkLollipop.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkLollipop.java
new file mode 100644
index 0000000..ee926e3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkLollipop.java
@@ -0,0 +1,224 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.classdiagram.command;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.UmlDiagramType;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexOr;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.cucadiagram.LinkDecor;
+import net.sourceforge.plantuml.cucadiagram.LinkType;
+import net.sourceforge.plantuml.objectdiagram.AbstractClassOrObjectDiagram;
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.utils.UniqueSequence;
+
+final public class CommandLinkLollipop extends SingleLineCommand2<AbstractClassOrObjectDiagram> {
+
+ public CommandLinkLollipop(UmlDiagramType umlDiagramType) {
+ super(getRegexConcat(umlDiagramType));
+ }
+
+ static RegexConcat getRegexConcat(UmlDiagramType umlDiagramType) {
+ return new RegexConcat(new RegexLeaf("HEADER", "^(?:@([\\d.]+)[%s]+)?"), //
+ new RegexLeaf("ENT1", "(?:" + optionalKeywords(umlDiagramType) + "[%s]+)?"
+ + "(\\.?[\\p{L}0-9_]+(?:\\.[\\p{L}0-9_]+)*|[%g][^%g]+[%g])[%s]*(\\<\\<.*\\>\\>)?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("FIRST_LABEL", "(?:[%g]([^%g]+)[%g])?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexOr(new RegexLeaf("LOL_THEN_ENT", "\\(\\)([-=.]+)"), //
+ new RegexLeaf("ENT_THEN_LOL", "([-=.]+)\\(\\)")), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("SECOND_LABEL", "(?:[%g]([^%g]+)[%g])?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("ENT2", "(?:" + optionalKeywords(umlDiagramType) + "[%s]+)?"
+ + "(\\.?[\\p{L}0-9_]+(?:\\.[\\p{L}0-9_]+)*|[%g][^%g]+[%g])[%s]*(\\<\\<.*\\>\\>)?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("LABEL_LINK", "(?::[%s]*(.+))?"), //
+ new RegexLeaf("$"));
+ }
+
+ private static String optionalKeywords(UmlDiagramType type) {
+ if (type == UmlDiagramType.CLASS) {
+ return "(interface|enum|annotation|abstract[%s]+class|abstract|class)";
+ }
+ if (type == UmlDiagramType.OBJECT) {
+ return "(object)";
+ }
+ throw new IllegalArgumentException();
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(AbstractClassOrObjectDiagram diagram, RegexResult arg) {
+
+ final Code ent1 = Code.of(arg.get("ENT1", 1));
+ final Code ent2 = Code.of(arg.get("ENT2", 1));
+
+ final IEntity cl1;
+ final IEntity cl2;
+ final IEntity normalEntity;
+
+ final String suffix = "lol" + UniqueSequence.getValue();
+ if (arg.get("LOL_THEN_ENT", 0) == null) {
+ assert arg.get("ENT_THEN_LOL", 0) != null;
+ cl1 = diagram.getOrCreateLeaf(ent1, null, null);
+ cl2 = diagram.createLeaf(cl1.getCode().addSuffix(suffix), Display.getWithNewlines(ent2), LeafType.LOLLIPOP, null);
+ normalEntity = cl1;
+ } else {
+ cl2 = diagram.getOrCreateLeaf(ent2, null, null);
+ cl1 = diagram.createLeaf(cl2.getCode().addSuffix(suffix), Display.getWithNewlines(ent1), LeafType.LOLLIPOP, null);
+ normalEntity = cl2;
+ }
+
+ final LinkType linkType = getLinkType(arg);
+ final String queue = getQueue(arg);
+
+ int length = queue.length();
+ if (length == 1 && diagram.getNbOfHozizontalLollipop(normalEntity) > 1) {
+ length++;
+ }
+
+ String firstLabel = arg.get("FIRST_LABEL", 0);
+ String secondLabel = arg.get("SECOND_LABEL", 0);
+
+ String labelLink = null;
+
+ if (arg.get("LABEL_LINK", 0) != null) {
+ labelLink = arg.get("LABEL_LINK", 0);
+ if (firstLabel == null && secondLabel == null) {
+ final Pattern p1 = MyPattern.cmpile("^\"([^\"]+)\"([^\"]+)\"([^\"]+)\"$");
+ final Matcher m1 = p1.matcher(labelLink);
+ if (m1.matches()) {
+ firstLabel = m1.group(1);
+ labelLink = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(m1.group(2).trim()).trim();
+ secondLabel = m1.group(3);
+ } else {
+ final Pattern p2 = MyPattern.cmpile("^\"([^\"]+)\"([^\"]+)$");
+ final Matcher m2 = p2.matcher(labelLink);
+ if (m2.matches()) {
+ firstLabel = m2.group(1);
+ labelLink = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(m2.group(2).trim()).trim();
+ secondLabel = null;
+ } else {
+ final Pattern p3 = MyPattern.cmpile("^([^\"]+)\"([^\"]+)\"$");
+ final Matcher m3 = p3.matcher(labelLink);
+ if (m3.matches()) {
+ firstLabel = null;
+ labelLink = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(m3.group(1).trim())
+ .trim();
+ secondLabel = m3.group(2);
+ }
+ }
+ }
+ }
+ labelLink = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(labelLink);
+ } /*
+ * else if (arg.get("LABEL_LINK_XT").get(0) != null || arg.get("LABEL_LINK_XT").get(1) != null ||
+ * arg.get("LABEL_LINK_XT").get(2) != null) { labelLink = arg.get("LABEL_LINK_XT").get(1); firstLabel =
+ * merge(firstLabel, arg.get("LABEL_LINK_XT").get(0)); secondLabel = merge(arg.get("LABEL_LINK_XT").get(2),
+ * secondLabel); }
+ */
+
+ final Link link = new Link(cl1, cl2, linkType, Display.getWithNewlines(labelLink), length, firstLabel,
+ secondLabel, diagram.getLabeldistance(), diagram.getLabelangle());
+ diagram.resetPragmaLabel();
+ addLink(diagram, link, arg.get("HEADER", 0));
+
+ return CommandExecutionResult.ok();
+ }
+
+ // private String merge(String a, String b) {
+ // if (a == null && b == null) {
+ // return null;
+ // }
+ // if (a == null && b != null) {
+ // return StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(b);
+ // }
+ // if (b == null && a != null) {
+ // return StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(a);
+ // }
+ // return StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(a) +
+ // "\\n"
+ // + StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(b);
+ // }
+
+ private void addLink(AbstractClassOrObjectDiagram diagram, Link link, String weight) {
+ diagram.addLink(link);
+ if (weight == null) {
+ // final LinkType type = link.getType();
+ // --|> highest
+ // --*, -->, --o normal
+ // ..*, ..>, ..o lowest
+ // if (type.isDashed() == false) {
+ // if (type.contains(LinkDecor.EXTENDS)) {
+ // link.setWeight(3);
+ // }
+ // if (type.contains(LinkDecor.ARROW) ||
+ // type.contains(LinkDecor.COMPOSITION)
+ // || type.contains(LinkDecor.AGREGATION)) {
+ // link.setWeight(2);
+ // }
+ // }
+ } else {
+ link.setWeight(Double.parseDouble(weight));
+ }
+ }
+
+ private LinkType getLinkType(RegexResult arg) {
+ return new LinkType(LinkDecor.NONE, LinkDecor.NONE);
+ }
+
+ private String getQueue(RegexResult arg) {
+ if (arg.get("LOL_THEN_ENT", 0) != null) {
+ return arg.get("LOL_THEN_ENT", 0).trim();
+ }
+ if (arg.get("ENT_THEN_LOL", 0) != null) {
+ return arg.get("ENT_THEN_LOL", 0).trim();
+ }
+ throw new IllegalArgumentException();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandMouseOver.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandMouseOver.java
new file mode 100644
index 0000000..342bdba
--- /dev/null
+++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandMouseOver.java
@@ -0,0 +1,123 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.classdiagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.classdiagram.ClassDiagram;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.CommandMultilines2;
+import net.sourceforge.plantuml.command.MultilinesStrategy;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexOr;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.StringUtils;
+
+public class CommandMouseOver extends CommandMultilines2<ClassDiagram> {
+
+ public CommandMouseOver() {
+ super(getRegexConcat(), MultilinesStrategy.REMOVE_STARTING_QUOTE);
+ }
+
+ @Override
+ public String getPatternEnd() {
+ return "(?i)^[%s]*\\}[%s]*$";
+ }
+
+ private static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("mouseover[%s]+"), //
+ new RegexOr(//
+ new RegexLeaf("NAME1", "(\\.?[\\p{L}0-9_]+(?:\\.[\\p{L}0-9_]+)*)"), //
+ new RegexLeaf("NAME3", "[%g]([^%g]+)[%g]")), //
+ new RegexLeaf("[%s]*\\{[%s]*$"));
+ }
+
+ public CommandExecutionResult executeNow(ClassDiagram system, List<String> lines) {
+ StringUtils.trim(lines, false);
+ final RegexResult line0 = getStartingPattern().matcher(lines.get(0).trim());
+ Code code = Code.of(line0.get("NAME1", 0));
+ if (code == null) {
+ code = Code.of(line0.get("NAME3", 0));
+ }
+ if (system.leafExist(code) == false) {
+ return CommandExecutionResult.error("No such entity");
+ }
+ final IEntity entity = system.getLeafsget(code);
+ for (String s : lines.subList(1, lines.size() - 1)) {
+ entity.mouseOver(s);
+ }
+
+ return CommandExecutionResult.ok();
+ }
+
+ // private Entity executeArg0(Map<String, RegexPartialMatch> arg) {
+ //
+ // final EntityType type = EntityType.getEntityType(arg.get("TYPE").get(0).goUpperCase());
+ // final String code;
+ // final String display;
+ // if (arg.get("NAME1").get(1) != null) {
+ // code = arg.get("NAME1").get(1);
+ // display = arg.get("NAME1").get(0);
+ // } else if (arg.get("NAME3").get(0) != null) {
+ // code = arg.get("NAME3").get(0);
+ // display = arg.get("NAME3").get(0);
+ // } else {
+ // code = arg.get("NAME2").get(0);
+ // display = arg.get("NAME2").get(1);
+ // }
+ // final String stereotype = arg.get("STEREO").get(0);
+ // final String generic = arg.get("GENERIC").get(0);
+ //
+ // if (system.entityExist(code)) {
+ // final Entity result = (Entity) system.getOrCreateClass(code);
+ // result.muteToType(type);
+ // return result;
+ // }
+ // final Entity entity = system.createEntity(code, display, type);
+ // if (stereotype != null) {
+ // entity.setStereotype(new Stereotype(stereotype, system.getSkinParam().getCircledCharacterRadius(),
+ // system.getSkinParam().getFont(FontParam.CIRCLED_CHARACTER, null)));
+ // }
+ // if (generic != null) {
+ // entity.setGeneric(generic);
+ // }
+ // return entity;
+ // }
+
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandNamespaceSeparator.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandNamespaceSeparator.java
new file mode 100644
index 0000000..e34e545
--- /dev/null
+++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandNamespaceSeparator.java
@@ -0,0 +1,59 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.classdiagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.classdiagram.ClassDiagram;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+
+public class CommandNamespaceSeparator extends SingleLineCommand<ClassDiagram> {
+
+ public CommandNamespaceSeparator() {
+ super("(?i)^set[%s]namespaceseparator[%s](\\S+)$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ClassDiagram diagram, List<String> arg) {
+ final String s = arg.get(0);
+ if ("none".equalsIgnoreCase(s)) {
+ diagram.setNamespaceSeparator(null);
+ } else {
+ diagram.setNamespaceSeparator(s);
+ }
+ return CommandExecutionResult.ok();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandStereotype.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandStereotype.java
new file mode 100644
index 0000000..1119154
--- /dev/null
+++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandStereotype.java
@@ -0,0 +1,63 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.classdiagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.classdiagram.ClassDiagram;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+
+public class CommandStereotype extends SingleLineCommand<ClassDiagram> {
+
+ public CommandStereotype() {
+ super("(?i)^([\\p{L}0-9_.]+|[%g][^%g]+[%g])[%s]*(\\<\\<.*\\>\\>)$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ClassDiagram diagram, List<String> arg) {
+ final Code code = Code.of(arg.get(0));
+ final String stereotype = arg.get(1);
+ final IEntity entity = diagram.getOrCreateLeaf(code, null, null);
+ entity.setStereotype(new Stereotype(stereotype, diagram.getSkinParam().getCircledCharacterRadius(), diagram
+ .getSkinParam().getFont(FontParam.CIRCLED_CHARACTER, null, false), diagram.getSkinParam().getIHtmlColorSet()));
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandUrl.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandUrl.java
new file mode 100644
index 0000000..8253358
--- /dev/null
+++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandUrl.java
@@ -0,0 +1,73 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.classdiagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
+import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+
+public class CommandUrl extends SingleLineCommand<AbstractEntityDiagram> {
+
+ public CommandUrl() {
+ super("(?i)^url[%s]*(?:of|for)?[%s]+([\\p{L}0-9_.]+|[%g][^%g]+[%g])[%s]+(?:is)?[%s]*(" + UrlBuilder.getRegexp() + ")$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(AbstractEntityDiagram diagram, List<String> arg) {
+ final Code code = Code.of(arg.get(0));
+ final String urlString = arg.get(1);
+ final IEntity entity;
+ if (diagram.leafExist(code)) {
+ entity = diagram.getOrCreateLeaf(code, null, null);
+ } else if (diagram.isGroup(code)) {
+ entity = diagram.getGroup(code);
+ } else {
+ return CommandExecutionResult.error(code + " does not exist");
+ }
+ // final IEntity entity = diagram.getOrCreateLeaf(code, null);
+ final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
+ final Url url = urlBuilder.getUrl(urlString);
+ entity.addUrl(url);
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/command/GenericRegexProducer.java b/src/net/sourceforge/plantuml/classdiagram/command/GenericRegexProducer.java
new file mode 100644
index 0000000..e01708e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/classdiagram/command/GenericRegexProducer.java
@@ -0,0 +1,56 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.classdiagram.command;
+
+
+public class GenericRegexProducer {
+
+ public final static String PATTERN = "[^\\<\\>]" + getGenericRegex(4);
+
+ // \<[^\<\>]([^\<\>]|\<\>)*\>
+ static final private String part1 = "(?:[^\\<\\>]|\\<";
+ static final private String part2 = "\\>)*";
+
+ static String getGenericRegex(int level) {
+ if (level < 0) {
+ throw new IllegalArgumentException();
+ }
+ if (level == 0) {
+ return part1 + part2;
+ }
+ return part1 + getGenericRegex(level - 1) + part2;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/command/JavaClass.java b/src/net/sourceforge/plantuml/classdiagram/command/JavaClass.java
new file mode 100644
index 0000000..9a74912
--- /dev/null
+++ b/src/net/sourceforge/plantuml/classdiagram/command/JavaClass.java
@@ -0,0 +1,86 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.classdiagram.command;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+
+class JavaClass {
+
+ private final String name;
+ private final String javaPackage;
+ private final List<String> parents = new ArrayList<String>();
+ private final LeafType type;
+ private final LeafType parentType;
+
+ public JavaClass(String javaPackage, String name, String p, LeafType type, LeafType parentType) {
+ this.name = name;
+ this.javaPackage = javaPackage;
+ if (p == null) {
+ p = "";
+ }
+ final StringTokenizer st = new StringTokenizer(p.trim(), ",");
+ while (st.hasMoreTokens()) {
+ this.parents.add(st.nextToken().trim().replaceAll("\\<.*", ""));
+ }
+ this.type = type;
+ this.parentType = parentType;
+ }
+
+ public final String getName() {
+ return name;
+ }
+
+ public final LeafType getType() {
+ return type;
+ }
+
+ public final List<String> getParents() {
+ return Collections.unmodifiableList(parents);
+ }
+
+ public final LeafType getParentType() {
+ return parentType;
+ }
+
+ public final String getJavaPackage() {
+ return javaPackage;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/classdiagram/command/JavaFile.java b/src/net/sourceforge/plantuml/classdiagram/command/JavaFile.java
new file mode 100644
index 0000000..727d9b0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/classdiagram/command/JavaFile.java
@@ -0,0 +1,111 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.classdiagram.command;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+
+class JavaFile {
+
+ private static final Pattern classDefinition = MyPattern
+ .cmpile("^(?:public[%s]+|abstract[%s]+|final[%s]+)*(class|interface|enum|annotation)[%s]+(\\w+)(?:.*\\b(extends|implements)[%s]+([\\w%s,]+))?");
+
+ private static final Pattern packageDefinition = MyPattern.cmpile("^package[%s]+([\\w+.]+)[%s]*;");
+
+ private final List<JavaClass> all = new ArrayList<JavaClass>();
+
+ public JavaFile(File f) throws IOException {
+ BufferedReader br = null;
+ try {
+ br = new BufferedReader(new FileReader(f));
+ initFromReader(br);
+ } finally {
+ if (br != null) {
+ br.close();
+ }
+ }
+ }
+
+ private void initFromReader(BufferedReader br) throws IOException {
+ String javaPackage = null;
+ String s;
+ while ((s = br.readLine()) != null) {
+ s = s.trim();
+ final Matcher matchPackage = packageDefinition.matcher(s);
+ if (matchPackage.find()) {
+ javaPackage = matchPackage.group(1);
+ } else {
+ final Matcher matchClassDefinition = classDefinition.matcher(s);
+ if (matchClassDefinition.find()) {
+ final String n = matchClassDefinition.group(2);
+ final String p = matchClassDefinition.group(4);
+ final LeafType type = LeafType.valueOf(StringUtils.goUpperCase(matchClassDefinition.group(1)));
+ final LeafType parentType = getParentType(type, matchClassDefinition.group(3));
+ all.add(new JavaClass(javaPackage, n, p, type, parentType));
+ }
+ }
+ }
+ }
+
+ static LeafType getParentType(LeafType type, String extendsOrImplements) {
+ if (extendsOrImplements == null) {
+ return null;
+ }
+ if (type == LeafType.CLASS) {
+ if (extendsOrImplements.equals("extends")) {
+ return LeafType.CLASS;
+ }
+ return LeafType.INTERFACE;
+ }
+ return LeafType.INTERFACE;
+ }
+
+ public List<JavaClass> getJavaClasses() {
+ return Collections.unmodifiableList(all);
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/code/ArobaseStringCompressor.java b/src/net/sourceforge/plantuml/code/ArobaseStringCompressor.java
new file mode 100644
index 0000000..6acd628
--- /dev/null
+++ b/src/net/sourceforge/plantuml/code/ArobaseStringCompressor.java
@@ -0,0 +1,118 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.code;
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.preproc.ReadLine;
+import net.sourceforge.plantuml.preproc.ReadLineReader;
+import net.sourceforge.plantuml.preproc.UncommentReadLine;
+
+public class ArobaseStringCompressor implements StringCompressor {
+
+ private final static Pattern p = MyPattern.cmpile("(?s)(?i)^[%s]*(@startuml[^\\n\\r]*)?[%s]*(.*?)[%s]*(@enduml)?[%s]*$");
+
+ public String compress(final String data) throws IOException {
+ final ReadLine r = new UncommentReadLine(new ReadLineReader(new StringReader(data)));
+ final StringBuilder sb = new StringBuilder();
+ final StringBuilder full = new StringBuilder();
+ String s = null;
+ boolean startDone = false;
+ while ((s = r.readLine()) != null) {
+ append(full, s);
+ if (s.startsWith("@startuml")) {
+ startDone = true;
+ } else if (s.startsWith("@enduml")) {
+ return sb.toString();
+ } else if (startDone) {
+ append(sb, s);
+ }
+ }
+ if (startDone == false) {
+ return compressOld(full.toString());
+ }
+ return sb.toString();
+ }
+
+ private void append(final StringBuilder sb, String s) {
+ if (sb.length() > 0) {
+ sb.append('\n');
+ }
+ sb.append(s);
+ }
+
+ private String compressOld(String s) throws IOException {
+ final Matcher m = p.matcher(s);
+ if (m.find()) {
+ return clean(m.group(2));
+ }
+ return "";
+ }
+
+ public String decompress(String s) throws IOException {
+ String result = clean(s);
+ if (result.startsWith("@start")) {
+ return result;
+ }
+ result = "@startuml\n" + result;
+ if (result.endsWith("\n") == false) {
+ result += "\n";
+ }
+ result += "@enduml";
+ return result;
+ }
+
+ private String clean(String s) {
+ s = s.trim();
+ s = clean1(s);
+ s = s.replaceAll("@enduml[^\\n\\r]*", "");
+ s = s.replaceAll("@startuml[^\\n\\r]*", "");
+ s = s.trim();
+ return s;
+ }
+
+ private String clean1(String s) {
+ final Matcher m = p.matcher(s);
+ if (m.matches()) {
+ return m.group(2);
+ }
+ return s;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/code/AsciiEncoder.java b/src/net/sourceforge/plantuml/code/AsciiEncoder.java
new file mode 100644
index 0000000..4ae50a9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/code/AsciiEncoder.java
@@ -0,0 +1,120 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.code;
+
+public class AsciiEncoder implements URLEncoder {
+
+ final private char encode6bit[] = new char[64];
+ final private byte decode6bit[] = new byte[128];
+
+ public AsciiEncoder() {
+ for (byte b = 0; b < 64; b++) {
+ encode6bit[b] = encode6bit(b);
+ decode6bit[encode6bit[b]] = b;
+ }
+ }
+
+ public String encode(byte data[]) {
+ final StringBuilder resu = new StringBuilder((data.length * 4 + 2) / 3);
+ for (int i = 0; i < data.length; i += 3) {
+ append3bytes(resu, data[i] & 0xFF, i + 1 < data.length ? data[i + 1] & 0xFF : 0,
+ i + 2 < data.length ? data[i + 2] & 0xFF : 0);
+ }
+ return resu.toString();
+ }
+
+ public byte[] decode(String s) {
+ if (s.length() % 4 != 0) {
+ throw new IllegalArgumentException("Cannot decode " + s);
+ }
+ final byte data[] = new byte[(s.length() * 3 + 3) / 4];
+ int pos = 0;
+ for (int i = 0; i < s.length(); i += 4) {
+ decode3bytes(data, pos, s.charAt(i), s.charAt(i + 1), s.charAt(i + 2), s.charAt(i + 3));
+ pos += 3;
+ }
+ return data;
+ }
+
+ public int decode6bit(char c) {
+ return decode6bit[c];
+ }
+
+ public char encode6bit(byte b) {
+ assert b >= 0 && b < 64;
+ if (b < 10) {
+ return (char) ('0' + b);
+ }
+ b -= 10;
+ if (b < 26) {
+ return (char) ('A' + b);
+ }
+ b -= 26;
+ if (b < 26) {
+ return (char) ('a' + b);
+ }
+ b -= 26;
+ if (b == 0) {
+ return '-';
+ }
+ if (b == 1) {
+ return '_';
+ }
+ assert false;
+ return '?';
+ }
+
+ private void append3bytes(StringBuilder sb, int b1, int b2, int b3) {
+ final int c1 = b1 >> 2;
+ final int c2 = ((b1 & 0x3) << 4) | (b2 >> 4);
+ final int c3 = ((b2 & 0xF) << 2) | (b3 >> 6);
+ final int c4 = b3 & 0x3F;
+ sb.append(encode6bit[c1 & 0x3F]);
+ sb.append(encode6bit[c2 & 0x3F]);
+ sb.append(encode6bit[c3 & 0x3F]);
+ sb.append(encode6bit[c4 & 0x3F]);
+ }
+
+ private void decode3bytes(byte r[], int pos, char cc1, char cc2, char cc3, char cc4) {
+ final int c1 = decode6bit[cc1];
+ final int c2 = decode6bit[cc2];
+ final int c3 = decode6bit[cc3];
+ final int c4 = decode6bit[cc4];
+ r[pos] = (byte) ((c1 << 2) | (c2 >> 4));
+ r[pos + 1] = (byte) (((c2 & 0x0F) << 4) | (c3 >> 2));
+ r[pos + 2] = (byte) (((c3 & 0x3) << 6) | c4);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/code/Base64Coder.java b/src/net/sourceforge/plantuml/code/Base64Coder.java
new file mode 100644
index 0000000..259fbd2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/code/Base64Coder.java
@@ -0,0 +1,327 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+// Copyright 2003-2010 Christian d'Heureuse, Inventec Informatik AG, Zurich, Switzerland
+// www.source-code.biz, www.inventec.ch/chdh
+//
+// This module is multi-licensed and may be used under the terms
+// of any of the following licenses:
+//
+// EPL, Eclipse Public License, V1.0 or later, http://www.eclipse.org/legal
+// LGPL, GNU Lesser General Public License, V2.1 or later, http://www.gnu.org/licenses/lgpl.html
+// GPL, GNU General Public License, V2 or later, http://www.gnu.org/licenses/gpl.html
+// AGPL, GNU Affero General Public License V3 or later, http://www.gnu.org/licenses/agpl.html
+// AL, Apache License, V2.0 or later, http://www.apache.org/licenses
+// BSD, BSD License, http://www.opensource.org/licenses/bsd-license.php
+// MIT, MIT License, http://www.opensource.org/licenses/MIT
+//
+// Please contact the author if you need another license.
+// This module is provided "as is", without warranties of any kind.
+//
+// Project home page: www.source-code.biz/base64coder/java
+
+package net.sourceforge.plantuml.code;
+
+/**
+ * A Base64 encoder/decoder.
+ *
+ * <p>
+ * This class is used to encode and decode data in Base64 format as described in RFC 1521.
+ * <p>
+ * Project home page: <a href="http://www.source-code.biz/base64coder/java/">www.source-code.biz/base64coder/java</a><br>
+ * Author: Christian d'Heureuse, Inventec Informatik AG, Zurich, Switzerland<br>
+ * Multi-licensed: EPL / LGPL / GPL / AL / BSD / MIT.
+ *
+ * @author Christian d'Heureuse, Inventec Informatik AG, Zurich, Switzerland, www.source-code.biz
+ */
+public class Base64Coder {
+
+ // The line separator string of the operating system.
+ private static final String systemLineSeparator = System.getProperty("line.separator");
+
+ // Mapping table from 6-bit nibbles to Base64 characters.
+ private static final char[] map1 = new char[64];
+ static {
+ int i = 0;
+ for (char c = 'A'; c <= 'Z'; c++)
+ map1[i++] = c;
+ for (char c = 'a'; c <= 'z'; c++)
+ map1[i++] = c;
+ for (char c = '0'; c <= '9'; c++)
+ map1[i++] = c;
+ map1[i++] = '+';
+ map1[i++] = '/';
+ }
+
+ // Mapping table from Base64 characters to 6-bit nibbles.
+ private static final byte[] map2 = new byte[128];
+ static {
+ for (int i = 0; i < map2.length; i++)
+ map2[i] = -1;
+ for (int i = 0; i < 64; i++)
+ map2[map1[i]] = (byte) i;
+ }
+
+ /**
+ * Encodes a string into Base64 format. No blanks or line breaks are inserted.
+ *
+ * @param s
+ * A String to be encoded.
+ * @return A String containing the Base64 encoded data.
+ */
+ public static String encodeString(String s) {
+ return new String(encode(s.getBytes()));
+ }
+
+ /**
+ * Encodes a byte array into Base 64 format and breaks the output into lines of 76 characters. This method is
+ * compatible with <code>sun.misc.BASE64Encoder.encodeBuffer(byte[])</code>.
+ *
+ * @param in
+ * An array containing the data bytes to be encoded.
+ * @return A String containing the Base64 encoded data, broken into lines.
+ */
+ public static String encodeLines(byte[] in) {
+ return encodeLines(in, 0, in.length, 76, systemLineSeparator);
+ }
+
+ /**
+ * Encodes a byte array into Base 64 format and breaks the output into lines.
+ *
+ * @param in
+ * An array containing the data bytes to be encoded.
+ * @param iOff
+ * Offset of the first byte in <code>in</code> to be processed.
+ * @param iLen
+ * Number of bytes to be processed in <code>in</code>, starting at <code>iOff</code>.
+ * @param lineLen
+ * Line length for the output data. Should be a multiple of 4.
+ * @param lineSeparator
+ * The line separator to be used to separate the output lines.
+ * @return A String containing the Base64 encoded data, broken into lines.
+ */
+ public static String encodeLines(byte[] in, int iOff, int iLen, int lineLen, String lineSeparator) {
+ int blockLen = (lineLen * 3) / 4;
+ if (blockLen <= 0)
+ throw new IllegalArgumentException();
+ int lines = (iLen + blockLen - 1) / blockLen;
+ int bufLen = ((iLen + 2) / 3) * 4 + lines * lineSeparator.length();
+ StringBuilder buf = new StringBuilder(bufLen);
+ int ip = 0;
+ while (ip < iLen) {
+ int l = Math.min(iLen - ip, blockLen);
+ buf.append(encode(in, iOff + ip, l));
+ buf.append(lineSeparator);
+ ip += l;
+ }
+ return buf.toString();
+ }
+
+ /**
+ * Encodes a byte array into Base64 format. No blanks or line breaks are inserted in the output.
+ *
+ * @param in
+ * An array containing the data bytes to be encoded.
+ * @return A character array containing the Base64 encoded data.
+ */
+ public static char[] encode(byte[] in) {
+ return encode(in, 0, in.length);
+ }
+
+ /**
+ * Encodes a byte array into Base64 format. No blanks or line breaks are inserted in the output.
+ *
+ * @param in
+ * An array containing the data bytes to be encoded.
+ * @param iLen
+ * Number of bytes to process in <code>in</code>.
+ * @return A character array containing the Base64 encoded data.
+ */
+ public static char[] encode(byte[] in, int iLen) {
+ return encode(in, 0, iLen);
+ }
+
+ /**
+ * Encodes a byte array into Base64 format. No blanks or line breaks are inserted in the output.
+ *
+ * @param in
+ * An array containing the data bytes to be encoded.
+ * @param iOff
+ * Offset of the first byte in <code>in</code> to be processed.
+ * @param iLen
+ * Number of bytes to process in <code>in</code>, starting at <code>iOff</code>.
+ * @return A character array containing the Base64 encoded data.
+ */
+ public static char[] encode(byte[] in, int iOff, int iLen) {
+ int oDataLen = (iLen * 4 + 2) / 3; // output length without padding
+ int oLen = ((iLen + 2) / 3) * 4; // output length including padding
+ char[] out = new char[oLen];
+ int ip = iOff;
+ int iEnd = iOff + iLen;
+ int op = 0;
+ while (ip < iEnd) {
+ int i0 = in[ip++] & 0xff;
+ int i1 = ip < iEnd ? in[ip++] & 0xff : 0;
+ int i2 = ip < iEnd ? in[ip++] & 0xff : 0;
+ int o0 = i0 >>> 2;
+ int o1 = ((i0 & 3) << 4) | (i1 >>> 4);
+ int o2 = ((i1 & 0xf) << 2) | (i2 >>> 6);
+ int o3 = i2 & 0x3F;
+ out[op++] = map1[o0];
+ out[op++] = map1[o1];
+ out[op] = op < oDataLen ? map1[o2] : '=';
+ op++;
+ out[op] = op < oDataLen ? map1[o3] : '=';
+ op++;
+ }
+ return out;
+ }
+
+ /**
+ * Decodes a string from Base64 format. No blanks or line breaks are allowed within the Base64 encoded input data.
+ *
+ * @param s
+ * A Base64 String to be decoded.
+ * @return A String containing the decoded data.
+ * @throws IllegalArgumentException
+ * If the input is not valid Base64 encoded data.
+ */
+ public static String decodeString(String s) {
+ return new String(decode(s));
+ }
+
+ /**
+ * Decodes a byte array from Base64 format and ignores line separators, tabs and blanks. CR, LF, Tab and Space
+ * characters are ignored in the input data. This method is compatible with
+ * <code>sun.misc.BASE64Decoder.decodeBuffer(String)</code>.
+ *
+ * @param s
+ * A Base64 String to be decoded.
+ * @return An array containing the decoded data bytes.
+ * @throws IllegalArgumentException
+ * If the input is not valid Base64 encoded data.
+ */
+ public static byte[] decodeLines(String s) {
+ char[] buf = new char[s.length()];
+ int p = 0;
+ for (int ip = 0; ip < s.length(); ip++) {
+ char c = s.charAt(ip);
+ if (c != ' ' && c != '\r' && c != '\n' && c != '\t')
+ buf[p++] = c;
+ }
+ return decode(buf, 0, p);
+ }
+
+ /**
+ * Decodes a byte array from Base64 format. No blanks or line breaks are allowed within the Base64 encoded input
+ * data.
+ *
+ * @param s
+ * A Base64 String to be decoded.
+ * @return An array containing the decoded data bytes.
+ * @throws IllegalArgumentException
+ * If the input is not valid Base64 encoded data.
+ */
+ public static byte[] decode(String s) {
+ return decode(s.toCharArray());
+ }
+
+ /**
+ * Decodes a byte array from Base64 format. No blanks or line breaks are allowed within the Base64 encoded input
+ * data.
+ *
+ * @param in
+ * A character array containing the Base64 encoded data.
+ * @return An array containing the decoded data bytes.
+ * @throws IllegalArgumentException
+ * If the input is not valid Base64 encoded data.
+ */
+ public static byte[] decode(char[] in) {
+ return decode(in, 0, in.length);
+ }
+
+ /**
+ * Decodes a byte array from Base64 format. No blanks or line breaks are allowed within the Base64 encoded input
+ * data.
+ *
+ * @param in
+ * A character array containing the Base64 encoded data.
+ * @param iOff
+ * Offset of the first character in <code>in</code> to be processed.
+ * @param iLen
+ * Number of characters to process in <code>in</code>, starting at <code>iOff</code>.
+ * @return An array containing the decoded data bytes.
+ * @throws IllegalArgumentException
+ * If the input is not valid Base64 encoded data.
+ */
+ public static byte[] decode(char[] in, int iOff, int iLen) {
+ if (iLen % 4 != 0)
+ throw new IllegalArgumentException("Length of Base64 encoded input string is not a multiple of 4.");
+ while (iLen > 0 && in[iOff + iLen - 1] == '=')
+ iLen--;
+ int oLen = (iLen * 3) / 4;
+ byte[] out = new byte[oLen];
+ int ip = iOff;
+ int iEnd = iOff + iLen;
+ int op = 0;
+ while (ip < iEnd) {
+ int i0 = in[ip++];
+ int i1 = in[ip++];
+ int i2 = ip < iEnd ? in[ip++] : 'A';
+ int i3 = ip < iEnd ? in[ip++] : 'A';
+ if (i0 > 127 || i1 > 127 || i2 > 127 || i3 > 127)
+ throw new IllegalArgumentException("Illegal character in Base64 encoded data.");
+ int b0 = map2[i0];
+ int b1 = map2[i1];
+ int b2 = map2[i2];
+ int b3 = map2[i3];
+ if (b0 < 0 || b1 < 0 || b2 < 0 || b3 < 0)
+ throw new IllegalArgumentException("Illegal character in Base64 encoded data.");
+ int o0 = (b0 << 2) | (b1 >>> 4);
+ int o1 = ((b1 & 0xf) << 4) | (b2 >>> 2);
+ int o2 = ((b2 & 3) << 6) | b3;
+ out[op++] = (byte) o0;
+ if (op < oLen)
+ out[op++] = (byte) o1;
+ if (op < oLen)
+ out[op++] = (byte) o2;
+ }
+ return out;
+ }
+
+ // Dummy constructor.
+ private Base64Coder() {
+ }
+
+} // end class Base64Coder
diff --git a/src/net/sourceforge/plantuml/code/Compression.java b/src/net/sourceforge/plantuml/code/Compression.java
new file mode 100644
index 0000000..755753d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/code/Compression.java
@@ -0,0 +1,56 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.code;
+
+import java.io.IOException;
+
+public interface Compression {
+
+ /**
+ * Shrinks the given <code>in</code> array with length <code>len</code>
+ *
+ * @return a newly created array with the compressed data.
+ */
+ byte[] compress(final byte[] in);
+
+ /**
+ * Grows the given <code>in</code> array with length <code>len</code>
+ * compressed with the <code>shrink</code> method.
+ *
+ * @return a newly created array with the expanded data.
+ */
+ byte[] decompress(byte[] in) throws IOException;
+
+}
diff --git a/src/net/sourceforge/plantuml/code/CompressionGZip.java b/src/net/sourceforge/plantuml/code/CompressionGZip.java
new file mode 100644
index 0000000..8bf964f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/code/CompressionGZip.java
@@ -0,0 +1,83 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.code;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.zip.GZIPInputStream;
+import java.util.zip.GZIPOutputStream;
+
+public class CompressionGZip implements Compression {
+
+ class MyGZIPOutputStream extends GZIPOutputStream {
+
+ public MyGZIPOutputStream(OutputStream baos) throws IOException {
+ super(baos);
+ def.setLevel(9);
+ }
+
+ }
+
+ public byte[] compress(byte[] in) {
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try {
+ final GZIPOutputStream gz = new MyGZIPOutputStream(baos);
+ gz.write(in);
+ gz.close();
+ baos.close();
+ return baos.toByteArray();
+ } catch (IOException e) {
+ throw new IllegalStateException(e.toString());
+ }
+ }
+
+ public byte[] decompress(byte[] in) throws IOException {
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ final ByteArrayInputStream bais = new ByteArrayInputStream(in);
+ final GZIPInputStream gz = new GZIPInputStream(bais);
+ int read;
+ while ((read = gz.read()) != -1) {
+ baos.write(read);
+ }
+ gz.close();
+ bais.close();
+ baos.close();
+ return baos.toByteArray();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/code/CompressionHuffman.java b/src/net/sourceforge/plantuml/code/CompressionHuffman.java
new file mode 100644
index 0000000..d7687c3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/code/CompressionHuffman.java
@@ -0,0 +1,76 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.code;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.zip.Deflater;
+import java.util.zip.DeflaterOutputStream;
+import java.util.zip.InflaterInputStream;
+
+public class CompressionHuffman implements Compression {
+
+ public byte[] compress(byte[] in) {
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final Deflater deflater = new Deflater(Deflater.HUFFMAN_ONLY);
+ deflater.setLevel(9);
+ final DeflaterOutputStream gz = new DeflaterOutputStream(baos, deflater);
+ try {
+ gz.write(in);
+ gz.close();
+ baos.close();
+ return baos.toByteArray();
+ } catch (IOException e) {
+ throw new IllegalStateException(e.toString());
+ }
+ }
+
+ public byte[] decompress(byte[] in) throws IOException {
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ final ByteArrayInputStream bais = new ByteArrayInputStream(in);
+ final InflaterInputStream gz = new InflaterInputStream(bais);
+ int read;
+ while ((read = gz.read()) != -1) {
+ baos.write(read);
+ }
+ gz.close();
+ bais.close();
+ baos.close();
+ return baos.toByteArray();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/code/CompressionNone.java b/src/net/sourceforge/plantuml/code/CompressionNone.java
new file mode 100644
index 0000000..ec57e82
--- /dev/null
+++ b/src/net/sourceforge/plantuml/code/CompressionNone.java
@@ -0,0 +1,47 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.code;
+
+public class CompressionNone implements Compression {
+
+ public byte[] compress(byte[] in) {
+ return in;
+ }
+
+ public byte[] decompress(byte[] in) {
+ return in;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/code/CompressionZlib.java b/src/net/sourceforge/plantuml/code/CompressionZlib.java
new file mode 100644
index 0000000..440ef10
--- /dev/null
+++ b/src/net/sourceforge/plantuml/code/CompressionZlib.java
@@ -0,0 +1,113 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.code;
+
+import java.io.IOException;
+import java.util.zip.DataFormatException;
+import java.util.zip.Deflater;
+import java.util.zip.Inflater;
+
+public class CompressionZlib implements Compression {
+
+ public byte[] compress(byte[] in) {
+ int len = in.length * 2;
+ byte[] result = null;
+ while (result == null) {
+ result = tryCompress(in, len);
+ len *= 2;
+ }
+ return result;
+ }
+
+ private byte[] tryCompress(byte[] in, final int len) {
+ // Compress the bytes
+ final Deflater compresser = new Deflater(9, true);
+ compresser.setInput(in);
+ compresser.finish();
+
+ final byte[] output = new byte[len];
+ final int compressedDataLength = compresser.deflate(output);
+ if (compresser.finished() == false) {
+ return null;
+ }
+ final byte[] result = copyArray(output, compressedDataLength);
+ return result;
+ }
+
+ public byte[] decompress(byte[] in) throws IOException {
+
+ final byte in2[] = new byte[in.length + 256];
+ for (int i = 0; i < in.length; i++) {
+ in2[i] = in[i];
+ }
+
+ int len = in.length * 5;
+ byte[] result = null;
+ while (result == null) {
+ result = tryDecompress(in2, len);
+ len *= 2;
+ }
+ return result;
+ }
+
+ private byte[] tryDecompress(byte[] in, final int len) throws IOException {
+ // Decompress the bytes
+ final byte[] tmp = new byte[len];
+ final Inflater decompresser = new Inflater(true);
+ decompresser.setInput(in);
+ try {
+ final int resultLength = decompresser.inflate(tmp);
+ if (decompresser.finished() == false) {
+ return null;
+ }
+ decompresser.end();
+
+ final byte[] result = copyArray(tmp, resultLength);
+ return result;
+ } catch (DataFormatException e) {
+ // e.printStackTrace();
+ throw new IOException(e.toString());
+ }
+ }
+
+ private byte[] copyArray(final byte[] data, final int len) {
+ final byte[] result = new byte[len];
+ for (int i = 0; i < result.length; i++) {
+ result[i] = data[i];
+ }
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/code/StringCompressor.java b/src/net/sourceforge/plantuml/code/StringCompressor.java
new file mode 100644
index 0000000..a24f49f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/code/StringCompressor.java
@@ -0,0 +1,45 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.code;
+
+import java.io.IOException;
+
+public interface StringCompressor {
+
+ String compress(String s) throws IOException;
+
+ String decompress(String compressed) throws IOException;
+
+}
diff --git a/src/net/sourceforge/plantuml/code/StringCompressorNone.java b/src/net/sourceforge/plantuml/code/StringCompressorNone.java
new file mode 100644
index 0000000..3d958f0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/code/StringCompressorNone.java
@@ -0,0 +1,48 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.code;
+
+import java.io.IOException;
+
+public class StringCompressorNone implements StringCompressor {
+
+ public String compress(String s) throws IOException {
+ return s;
+ }
+
+ public String decompress(String stringAnnoted) throws IOException {
+ return stringAnnoted;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/code/Transcoder.java b/src/net/sourceforge/plantuml/code/Transcoder.java
new file mode 100644
index 0000000..a5445f5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/code/Transcoder.java
@@ -0,0 +1,44 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.code;
+
+import java.io.IOException;
+
+public interface Transcoder {
+
+ public String encode(String text) throws IOException;
+
+ public String decode(String code) throws IOException;
+}
diff --git a/src/net/sourceforge/plantuml/code/TranscoderImpl.java b/src/net/sourceforge/plantuml/code/TranscoderImpl.java
new file mode 100644
index 0000000..16ddfb4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/code/TranscoderImpl.java
@@ -0,0 +1,76 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.code;
+
+import java.io.IOException;
+
+public class TranscoderImpl implements Transcoder {
+
+ private final Compression compression;
+ private final URLEncoder urlEncoder;
+ private final StringCompressor stringCompressor;
+
+ public TranscoderImpl() {
+ this(new AsciiEncoder(), new StringCompressorNone(), new CompressionHuffman());
+ }
+
+ public TranscoderImpl(URLEncoder urlEncoder, Compression compression) {
+ this(urlEncoder, new ArobaseStringCompressor(), compression);
+ }
+
+ public TranscoderImpl(URLEncoder urlEncoder, StringCompressor stringCompressor, Compression compression) {
+ this.compression = compression;
+ this.urlEncoder = urlEncoder;
+ this.stringCompressor = stringCompressor;
+ }
+
+ public String encode(String text) throws IOException {
+
+ final String stringAnnoted = stringCompressor.compress(text);
+
+ final byte[] data = stringAnnoted.getBytes("UTF-8");
+ final byte[] compressedData = compression.compress(data);
+
+ return urlEncoder.encode(compressedData);
+ }
+
+ public String decode(String code) throws IOException {
+ final byte compressedData[] = urlEncoder.decode(code);
+ final byte data[] = compression.decompress(compressedData);
+
+ return stringCompressor.decompress(new String(data, "UTF-8"));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/code/TranscoderSmart.java b/src/net/sourceforge/plantuml/code/TranscoderSmart.java
new file mode 100644
index 0000000..00e3c63
--- /dev/null
+++ b/src/net/sourceforge/plantuml/code/TranscoderSmart.java
@@ -0,0 +1,55 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.code;
+
+import java.io.IOException;
+
+public class TranscoderSmart implements Transcoder {
+
+ private final Transcoder oldOne = new TranscoderImpl(new AsciiEncoder(), new CompressionHuffman());
+ private final Transcoder zlib = new TranscoderImpl(new AsciiEncoder(), new CompressionZlib());
+
+
+ public String decode(String code) throws IOException {
+ try {
+ return zlib.decode(code);
+ } catch (Exception ex) {
+ return oldOne.decode(code);
+ }
+ }
+ public String encode(String text) throws IOException {
+ return zlib.encode(text);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/code/TranscoderUtil.java b/src/net/sourceforge/plantuml/code/TranscoderUtil.java
new file mode 100644
index 0000000..f984e79
--- /dev/null
+++ b/src/net/sourceforge/plantuml/code/TranscoderUtil.java
@@ -0,0 +1,43 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.code;
+
+public class TranscoderUtil {
+
+ public static Transcoder getDefaultTranscoder() {
+ return new TranscoderSmart();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/code/URLEncoder.java b/src/net/sourceforge/plantuml/code/URLEncoder.java
new file mode 100644
index 0000000..b250cde
--- /dev/null
+++ b/src/net/sourceforge/plantuml/code/URLEncoder.java
@@ -0,0 +1,43 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.code;
+
+public interface URLEncoder {
+
+ String encode(byte data[]);
+
+ byte[] decode(String s);
+
+}
diff --git a/src/net/sourceforge/plantuml/command/Command.java b/src/net/sourceforge/plantuml/command/Command.java
new file mode 100644
index 0000000..83bb005
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/Command.java
@@ -0,0 +1,49 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.core.Diagram;
+
+public interface Command<D extends Diagram> {
+
+ CommandExecutionResult execute(D diagram, List<String> lines);
+
+ CommandControl isValid(List<String> lines);
+
+ String[] getDescription();
+
+}
diff --git a/src/net/sourceforge/plantuml/command/CommandAffineTransform.java b/src/net/sourceforge/plantuml/command/CommandAffineTransform.java
new file mode 100644
index 0000000..09fe16f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/CommandAffineTransform.java
@@ -0,0 +1,55 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command;
+
+import java.util.Collections;
+import java.util.List;
+
+import net.sourceforge.plantuml.UmlDiagram;
+
+public class CommandAffineTransform extends SingleLineCommand<UmlDiagram> {
+
+ public CommandAffineTransform() {
+ super("(?i)^!transformation[%s]+([^{}]*)$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(UmlDiagram diagram, List<String> arg) {
+ final String value = arg.get(0);
+ diagram.setAnimation(Collections.singletonList(value));
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/CommandAffineTransformMultiline.java b/src/net/sourceforge/plantuml/command/CommandAffineTransformMultiline.java
new file mode 100644
index 0000000..79ee9ac
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/CommandAffineTransformMultiline.java
@@ -0,0 +1,58 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.UmlDiagram;
+
+public class CommandAffineTransformMultiline extends CommandMultilines<UmlDiagram> {
+
+ public CommandAffineTransformMultiline() {
+ super("(?i)^!transformation[%s]+\\{[%s]*$");
+ }
+
+ @Override
+ public String getPatternEnd() {
+ return "(?i)^[%s]*!\\}[%s]*$";
+ }
+
+ public CommandExecutionResult execute(final UmlDiagram diagram, List<String> lines) {
+ final List<String> data = lines.subList(1, lines.size() - 1);
+ diagram.setAnimation(data);
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/CommandComment.java b/src/net/sourceforge/plantuml/command/CommandComment.java
new file mode 100644
index 0000000..62c8757
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/CommandComment.java
@@ -0,0 +1,52 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.core.Diagram;
+
+public class CommandComment extends SingleLineCommand<Diagram> {
+
+ public CommandComment() {
+ super("(?i)^[%s]*([%q].*||/[%q].*[%q]/[%s]*)$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(Diagram diagram, List<String> arg) {
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/CommandControl.java b/src/net/sourceforge/plantuml/command/CommandControl.java
new file mode 100644
index 0000000..40de1ef
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/CommandControl.java
@@ -0,0 +1,40 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command;
+
+public enum CommandControl {
+ OK, NOT_OK, OK_PARTIAL
+
+}
diff --git a/src/net/sourceforge/plantuml/command/CommandEndPackage.java b/src/net/sourceforge/plantuml/command/CommandEndPackage.java
new file mode 100644
index 0000000..c7f40dd
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/CommandEndPackage.java
@@ -0,0 +1,59 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram;
+import net.sourceforge.plantuml.cucadiagram.EntityUtils;
+import net.sourceforge.plantuml.cucadiagram.IGroup;
+
+public class CommandEndPackage extends SingleLineCommand<AbstractEntityDiagram> {
+
+ public CommandEndPackage() {
+ super("(?i)^\\}$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(AbstractEntityDiagram diagram, List<String> arg) {
+ final IGroup currentPackage = diagram.getCurrentGroup();
+ if (EntityUtils.groupRoot(currentPackage)) {
+ return CommandExecutionResult.error("No package or namespace defined");
+ }
+ diagram.endGroup();
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/CommandExecutionResult.java b/src/net/sourceforge/plantuml/command/CommandExecutionResult.java
new file mode 100644
index 0000000..e3c4ecc
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/CommandExecutionResult.java
@@ -0,0 +1,85 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+
+public class CommandExecutionResult {
+
+ private final String error;
+ private final AbstractPSystem newDiagram;
+
+ private CommandExecutionResult(String error, AbstractPSystem newDiagram) {
+ this.error = error;
+ this.newDiagram = newDiagram;
+ }
+
+ public CommandExecutionResult withDiagram(AbstractPSystem newDiagram) {
+ return new CommandExecutionResult(error, newDiagram);
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + " " + error;
+ }
+
+ public static CommandExecutionResult newDiagram(AbstractPSystem result) {
+ return new CommandExecutionResult(null, result);
+ }
+
+ public static CommandExecutionResult ok() {
+ return new CommandExecutionResult(null, null);
+ }
+
+ public static CommandExecutionResult error(String error) {
+ return new CommandExecutionResult(error, null);
+ }
+
+ public boolean isOk() {
+ return error == null;
+ }
+
+ public String getError() {
+ if (isOk()) {
+ throw new IllegalStateException();
+ }
+ return error;
+ }
+
+ public AbstractPSystem getNewDiagram() {
+ return newDiagram;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/CommandFootboxIgnored.java b/src/net/sourceforge/plantuml/command/CommandFootboxIgnored.java
new file mode 100644
index 0000000..57254a7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/CommandFootboxIgnored.java
@@ -0,0 +1,51 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.UmlDiagram;
+
+public class CommandFootboxIgnored extends SingleLineCommand<UmlDiagram> {
+
+ public CommandFootboxIgnored() {
+ super("(?i)^(hide|show)?[%s]*footbox$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(UmlDiagram diagram, List<String> arg) {
+ return CommandExecutionResult.ok();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/command/CommandFooter.java b/src/net/sourceforge/plantuml/command/CommandFooter.java
new file mode 100644
index 0000000..80e4058
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/CommandFooter.java
@@ -0,0 +1,60 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.UmlDiagram;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+
+public class CommandFooter extends SingleLineCommand<UmlDiagram> {
+
+ public CommandFooter() {
+ super("(?i)^(?:(left|right|center)?[%s]*)footer(?:[%s]*:[%s]*|[%s]+)(.*[\\p{L}0-9_.].*)$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(UmlDiagram diagram, List<String> arg) {
+ final String align = arg.get(0);
+ if (align != null) {
+ diagram.setFooterAlignment(HorizontalAlignment.valueOf(StringUtils.goUpperCase(align)));
+ }
+ diagram.setFooter(Display.getWithNewlines(arg.get(1)));
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/CommandHeader.java b/src/net/sourceforge/plantuml/command/CommandHeader.java
new file mode 100644
index 0000000..ad4bf3f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/CommandHeader.java
@@ -0,0 +1,60 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.UmlDiagram;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+
+public class CommandHeader extends SingleLineCommand<UmlDiagram> {
+
+ public CommandHeader() {
+ super("(?i)^(?:(left|right|center)?[%s]*)header(?:[%s]*:[%s]*|[%s]+)(.*[\\p{L}0-9_.].*)$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(UmlDiagram diagram, List<String> arg) {
+ final String align = arg.get(0);
+ if (align != null) {
+ diagram.setHeaderAlignment(HorizontalAlignment.valueOf(StringUtils.goUpperCase(align)));
+ }
+ diagram.setHeader(Display.getWithNewlines(arg.get(1)));
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/CommandHideUnlinked.java b/src/net/sourceforge/plantuml/command/CommandHideUnlinked.java
new file mode 100644
index 0000000..202e1f7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/CommandHideUnlinked.java
@@ -0,0 +1,53 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.UmlDiagram;
+
+public class CommandHideUnlinked extends SingleLineCommand<UmlDiagram> {
+
+ public CommandHideUnlinked() {
+ super("(?i)^(hide|show)[%s]+unlinked$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(UmlDiagram diagram, List<String> arg) {
+ diagram.setHideUnlinkedData(arg.get(0).equalsIgnoreCase("hide"));
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/CommandMinwidth.java b/src/net/sourceforge/plantuml/command/CommandMinwidth.java
new file mode 100644
index 0000000..30eddf9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/CommandMinwidth.java
@@ -0,0 +1,55 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.UmlDiagram;
+
+public class CommandMinwidth extends SingleLineCommand<UmlDiagram> {
+
+ public CommandMinwidth() {
+ super("(?i)^minwidth[%s]+(\\d+)$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(UmlDiagram system, List<String> arg) {
+
+ final int minwidth = Integer.parseInt(arg.get(0));
+ system.setMinwidth(minwidth);
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/CommandMultilines.java b/src/net/sourceforge/plantuml/command/CommandMultilines.java
new file mode 100644
index 0000000..9bfc582
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/CommandMultilines.java
@@ -0,0 +1,93 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command;
+
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.core.Diagram;
+
+public abstract class CommandMultilines<S extends Diagram> implements Command<S> {
+
+ private final Pattern starting;
+
+ public CommandMultilines(String patternStart) {
+ if (patternStart.startsWith("(?i)^") == false || patternStart.endsWith("$") == false) {
+ throw new IllegalArgumentException("Bad pattern " + patternStart);
+ }
+ this.starting = MyPattern.cmpile(patternStart);
+ }
+
+ public abstract String getPatternEnd();
+
+ public String[] getDescription() {
+ return new String[] { "START: " + starting.pattern(), "END: " + getPatternEnd() };
+ }
+
+ final public CommandControl isValid(List<String> lines) {
+ if (isCommandForbidden()) {
+ return CommandControl.NOT_OK;
+ }
+ Matcher m1 = starting.matcher(lines.get(0).trim());
+ if (m1.matches() == false) {
+ return CommandControl.NOT_OK;
+ }
+ if (lines.size() == 1) {
+ return CommandControl.OK_PARTIAL;
+ }
+
+ m1 = MyPattern.cmpile(getPatternEnd()).matcher(lines.get(lines.size() - 1).trim());
+ if (m1.matches() == false) {
+ return CommandControl.OK_PARTIAL;
+ }
+
+ actionIfCommandValid();
+ return CommandControl.OK;
+ }
+
+ protected boolean isCommandForbidden() {
+ return false;
+ }
+
+ protected void actionIfCommandValid() {
+ }
+
+ protected final Pattern getStartingPattern() {
+ return starting;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/CommandMultilines2.java b/src/net/sourceforge/plantuml/command/CommandMultilines2.java
new file mode 100644
index 0000000..8f6866a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/CommandMultilines2.java
@@ -0,0 +1,103 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command;
+
+import java.util.List;
+import java.util.regex.Matcher;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.core.Diagram;
+
+public abstract class CommandMultilines2<S extends Diagram> implements Command<S> {
+
+ private final RegexConcat starting;
+
+ private final MultilinesStrategy strategy;
+
+ public CommandMultilines2(RegexConcat patternStart, MultilinesStrategy strategy) {
+ if (patternStart.getPattern().startsWith("^") == false || patternStart.getPattern().endsWith("$") == false) {
+ throw new IllegalArgumentException("Bad pattern " + patternStart.getPattern());
+ }
+ this.strategy = strategy;
+ this.starting = patternStart;
+ }
+
+ public abstract String getPatternEnd();
+
+ public String[] getDescription() {
+ return new String[] { "START: " + starting.getPattern(), "END: " + getPatternEnd() };
+ }
+
+ final public CommandControl isValid(List<String> lines) {
+ lines = strategy.filter(lines);
+ if (isCommandForbidden()) {
+ return CommandControl.NOT_OK;
+ }
+ final boolean result1 = starting.match(lines.get(0).trim());
+ if (result1 == false) {
+ return CommandControl.NOT_OK;
+ }
+ if (lines.size() == 1) {
+ return CommandControl.OK_PARTIAL;
+ }
+
+ final Matcher m1 = MyPattern.cmpile(getPatternEnd()).matcher(lines.get(lines.size() - 1).trim());
+ if (m1.matches() == false) {
+ return CommandControl.OK_PARTIAL;
+ }
+
+ actionIfCommandValid();
+ return CommandControl.OK;
+ }
+
+ public final CommandExecutionResult execute(S system, List<String> lines) {
+ return executeNow(system, strategy.filter(lines));
+ }
+
+ public abstract CommandExecutionResult executeNow(S system, List<String> lines);
+
+ protected boolean isCommandForbidden() {
+ return false;
+ }
+
+ protected void actionIfCommandValid() {
+ }
+
+ protected final RegexConcat getStartingPattern() {
+ return starting;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/CommandMultilinesBracket.java b/src/net/sourceforge/plantuml/command/CommandMultilinesBracket.java
new file mode 100644
index 0000000..3449bd3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/CommandMultilinesBracket.java
@@ -0,0 +1,108 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command;
+
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.core.Diagram;
+
+public abstract class CommandMultilinesBracket<S extends Diagram> implements Command<S> {
+
+ private final Pattern starting;
+
+ public CommandMultilinesBracket(String patternStart) {
+ if (patternStart.startsWith("(?i)^") == false || patternStart.endsWith("$") == false) {
+ throw new IllegalArgumentException("Bad pattern " + patternStart);
+ }
+ this.starting = MyPattern.cmpile(patternStart);
+ }
+
+ protected boolean isCommandForbidden() {
+ return false;
+ }
+
+ public String[] getDescription() {
+ return new String[] { "BRACKET: " + starting.pattern() };
+ }
+
+ protected void actionIfCommandValid() {
+ }
+
+ protected final Pattern getStartingPattern() {
+ return starting;
+ }
+
+ final public CommandControl isValid(List<String> lines) {
+ if (isCommandForbidden()) {
+ return CommandControl.NOT_OK;
+ }
+ final Matcher m1 = starting.matcher(lines.get(0).trim());
+ if (m1.matches() == false) {
+ return CommandControl.NOT_OK;
+ }
+ if (lines.size() == 1) {
+ return CommandControl.OK_PARTIAL;
+ }
+
+ int level = 1;
+ for (int i = 1; i < lines.size(); i++) {
+ final String s = lines.get(i).trim();
+ if (isLineConsistent(s, level) == false) {
+ return CommandControl.NOT_OK;
+ }
+ if (s.endsWith("{")) {
+ level++;
+ }
+ if (s.endsWith("}")) {
+ level--;
+ }
+ if (level < 0) {
+ return CommandControl.NOT_OK;
+ }
+ }
+
+ if (level != 0) {
+ return CommandControl.OK_PARTIAL;
+ }
+
+ actionIfCommandValid();
+ return CommandControl.OK;
+ }
+
+ protected abstract boolean isLineConsistent(String line, int level);
+}
diff --git a/src/net/sourceforge/plantuml/command/CommandMultilinesComment.java b/src/net/sourceforge/plantuml/command/CommandMultilinesComment.java
new file mode 100644
index 0000000..95fc0af
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/CommandMultilinesComment.java
@@ -0,0 +1,56 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.core.Diagram;
+
+public class CommandMultilinesComment extends CommandMultilines<Diagram> {
+
+ public CommandMultilinesComment() {
+ super("(?i)^[%s]*/[%q].*$");
+ }
+
+ @Override
+ public String getPatternEnd() {
+ return "(?i)^.*[%q]/[%s]*$";
+ }
+
+ public CommandExecutionResult execute(final Diagram diagram, List<String> lines) {
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/CommandMultilinesFooter.java b/src/net/sourceforge/plantuml/command/CommandMultilinesFooter.java
new file mode 100644
index 0000000..52ff984
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/CommandMultilinesFooter.java
@@ -0,0 +1,74 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command;
+
+import java.util.List;
+import java.util.regex.Matcher;
+
+import net.sourceforge.plantuml.UmlDiagram;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.StringUtils;
+
+public class CommandMultilinesFooter extends CommandMultilines<UmlDiagram> {
+
+ public CommandMultilinesFooter() {
+ super("(?i)^(?:(left|right|center)?[%s]*)footer$");
+ }
+
+ @Override
+ public String getPatternEnd() {
+ return "(?i)^end[%s]?footer$";
+ }
+
+ public CommandExecutionResult execute(final UmlDiagram diagram, List<String> lines) {
+ StringUtils.trim(lines, false);
+ final Matcher m = getStartingPattern().matcher(lines.get(0).trim());
+ if (m.find() == false) {
+ throw new IllegalStateException();
+ }
+ final String align = m.group(1);
+ if (align != null) {
+ diagram.setFooterAlignment(HorizontalAlignment.valueOf(StringUtils.goUpperCase(align)));
+ }
+ final Display strings = Display.create(lines.subList(1, lines.size() - 1));
+ if (strings.size() > 0) {
+ diagram.setFooter(strings);
+ return CommandExecutionResult.ok();
+ }
+ return CommandExecutionResult.error("Empty footer");
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/CommandMultilinesHeader.java b/src/net/sourceforge/plantuml/command/CommandMultilinesHeader.java
new file mode 100644
index 0000000..598618b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/CommandMultilinesHeader.java
@@ -0,0 +1,75 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command;
+
+import java.util.List;
+import java.util.regex.Matcher;
+
+import net.sourceforge.plantuml.UmlDiagram;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.StringUtils;
+
+public class CommandMultilinesHeader extends CommandMultilines<UmlDiagram> {
+
+ public CommandMultilinesHeader() {
+ super("(?i)^(?:(left|right|center)?[%s]*)header$");
+ }
+
+ @Override
+ public String getPatternEnd() {
+ return "(?i)^end[%s]?header$";
+ }
+
+
+ public CommandExecutionResult execute(final UmlDiagram diagram, List<String> lines) {
+ StringUtils.trim(lines, false);
+ final Matcher m = getStartingPattern().matcher(lines.get(0).trim());
+ if (m.find() == false) {
+ throw new IllegalStateException();
+ }
+ final String align = m.group(1);
+ if (align != null) {
+ diagram.setHeaderAlignment(HorizontalAlignment.valueOf(StringUtils.goUpperCase(align)));
+ }
+ final Display strings = Display.create(lines.subList(1, lines.size() - 1));
+ if (strings.size() > 0) {
+ diagram.setHeader(strings);
+ return CommandExecutionResult.ok();
+ }
+ return CommandExecutionResult.error("Empty header");
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/CommandMultilinesLegend.java b/src/net/sourceforge/plantuml/command/CommandMultilinesLegend.java
new file mode 100644
index 0000000..79225b5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/CommandMultilinesLegend.java
@@ -0,0 +1,85 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.UmlDiagram;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.VerticalAlignment;
+
+public class CommandMultilinesLegend extends CommandMultilines2<UmlDiagram> {
+
+ public CommandMultilinesLegend() {
+ super(getRegexConcat(), MultilinesStrategy.REMOVE_STARTING_QUOTE);
+ }
+
+ private static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("legend"), //
+ new RegexLeaf("VALIGN", "(?:[%s]+(top|bottom))?"), //
+ new RegexLeaf("ALIGN", "(?:[%s]+(left|right|center))?"), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ public String getPatternEnd() {
+ return "(?i)^end[%s]?legend$";
+ }
+
+ @Override
+ public CommandExecutionResult executeNow(UmlDiagram diagram, List<String> lines) {
+ StringUtils.trim(lines, false);
+ final RegexResult line0 = getStartingPattern().matcher(lines.get(0).trim());
+ final String align = line0.get("ALIGN", 0);
+ final String valign = line0.get("VALIGN", 0);
+ final Display strings = Display.create(lines.subList(1, lines.size() - 1)).removeEmptyColumns();
+ if (strings.size() > 0) {
+ final VerticalAlignment valignment = VerticalAlignment.fromString(valign);
+ HorizontalAlignment alignment = HorizontalAlignment.fromString(align);
+ if (alignment == null) {
+ alignment = HorizontalAlignment.CENTER;
+ }
+ diagram.setLegend(strings, alignment, valignment);
+ return CommandExecutionResult.ok();
+ }
+ return CommandExecutionResult.error("No legend defined");
+ }
+}
diff --git a/src/net/sourceforge/plantuml/command/CommandMultilinesTitle.java b/src/net/sourceforge/plantuml/command/CommandMultilinesTitle.java
new file mode 100644
index 0000000..9741906
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/CommandMultilinesTitle.java
@@ -0,0 +1,63 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.UmlDiagram;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.StringUtils;
+
+public class CommandMultilinesTitle extends CommandMultilines<UmlDiagram> {
+
+ public CommandMultilinesTitle() {
+ super("(?i)^title$");
+ }
+
+ @Override
+ public String getPatternEnd() {
+ return "(?i)^end[%s]?title$";
+ }
+
+ public CommandExecutionResult execute(final UmlDiagram diagram, List<String> lines) {
+ final Display strings = Display.create(lines.subList(1, lines.size() - 1)).removeEmptyColumns();
+ if (strings.size() > 0) {
+ diagram.setTitle(strings);
+ return CommandExecutionResult.ok();
+ }
+ return CommandExecutionResult.error("No title defined");
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/CommandNamespace.java b/src/net/sourceforge/plantuml/command/CommandNamespace.java
new file mode 100644
index 0000000..fa72a6f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/CommandNamespace.java
@@ -0,0 +1,82 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command;
+
+import net.sourceforge.plantuml.classdiagram.ClassDiagram;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.GroupType;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.IGroup;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+
+public class CommandNamespace extends SingleLineCommand2<ClassDiagram> {
+
+ public CommandNamespace() {
+ super(getRegexConcat());
+ }
+
+ private static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^namespace[%s]+"), //
+ new RegexLeaf("NAME", "([\\p{L}0-9_][\\p{L}0-9_.:]*)"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("COLOR", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), //
+ new RegexLeaf("[%s]*\\{$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ClassDiagram diagram, RegexResult arg) {
+ final Code code = Code.of(arg.get("NAME", 0));
+ final IGroup currentPackage = diagram.getCurrentGroup();
+ final IEntity p = diagram.getOrCreateNamespace(code, Display.getWithNewlines(code), GroupType.PACKAGE,
+ currentPackage);
+ final String stereotype = arg.get("STEREOTYPE", 0);
+ if (stereotype != null) {
+ p.setStereotype(new Stereotype(stereotype));
+ }
+ final String color = arg.get("COLOR", 0);
+ if (color != null) {
+ p.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(color));
+ }
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/CommandNope.java b/src/net/sourceforge/plantuml/command/CommandNope.java
new file mode 100644
index 0000000..5d5e9cf
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/CommandNope.java
@@ -0,0 +1,52 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.core.Diagram;
+
+public class CommandNope extends SingleLineCommand<Diagram> {
+
+ public CommandNope() {
+ super("(?i)^[%s]*$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(Diagram diagram, List<String> arg) {
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/CommandPackage.java b/src/net/sourceforge/plantuml/command/CommandPackage.java
new file mode 100644
index 0000000..41f4fe8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/CommandPackage.java
@@ -0,0 +1,112 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
+import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.GroupType;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.IGroup;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.utils.UniqueSequence;
+
+public class CommandPackage extends SingleLineCommand2<AbstractEntityDiagram> {
+
+ public CommandPackage() {
+ super(getRegexConcat());
+ }
+
+ private static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^package[%s]+"), //
+ new RegexLeaf("NAME", "([%g][^%g]+[%g]|[^#%s{}]*)"), //
+ new RegexLeaf("AS", "(?:[%s]+as[%s]+([\\p{L}0-9_.]+))?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("COLOR", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), //
+ new RegexLeaf("[%s]*\\{$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(AbstractEntityDiagram diagram, RegexResult arg) {
+ final Code code;
+ final String display;
+ final String name = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("NAME", 0));
+ if (arg.get("AS", 0) == null) {
+ if (name.length() == 0) {
+ code = Code.of("##" + UniqueSequence.getValue());
+ display = null;
+ } else {
+ code = Code.of(name);
+ display = code.getFullName();
+ }
+ } else {
+ display = name;
+ code = Code.of(arg.get("AS", 0));
+ }
+ final IGroup currentPackage = diagram.getCurrentGroup();
+ final IEntity p = diagram.getOrCreateGroup(code, Display.getWithNewlines(display), GroupType.PACKAGE,
+ currentPackage);
+ final String stereotype = arg.get("STEREOTYPE", 0);
+ if (stereotype != null) {
+ p.setStereotype(new Stereotype(stereotype));
+ }
+
+ final String urlString = arg.get("URL", 0);
+ if (urlString != null) {
+ final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
+ final Url url = urlBuilder.getUrl(urlString);
+ p.addUrl(url);
+ }
+
+ final String color = arg.get("COLOR", 0);
+ if (color != null) {
+ p.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(color));
+ }
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/CommandPackageEmpty.java b/src/net/sourceforge/plantuml/command/CommandPackageEmpty.java
new file mode 100644
index 0000000..3a00526
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/CommandPackageEmpty.java
@@ -0,0 +1,82 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.GroupType;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.IGroup;
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.utils.UniqueSequence;
+
+public class CommandPackageEmpty extends SingleLineCommand<AbstractEntityDiagram> {
+
+ public CommandPackageEmpty() {
+ super(
+ "(?i)^package[%s]+([%g][^%g]+[%g]|[^#%s{}]*)(?:[%s]+as[%s]+([\\p{L}0-9_.]+))?[%s]*(#[0-9a-fA-F]{6}|#?\\w+)?[%s]*\\{[%s]*\\}$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(AbstractEntityDiagram diagram, List<String> arg) {
+ final Code code;
+ final String display;
+ if (arg.get(1) == null) {
+ if (StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get(0)).length() == 0) {
+ code = Code.of("##" + UniqueSequence.getValue());
+ display = null;
+ } else {
+ code = Code.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get(0)));
+ display = code.getFullName();
+ }
+ } else {
+ display = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get(0));
+ code = Code.of(arg.get(1));
+ }
+ final IGroup currentPackage = diagram.getCurrentGroup();
+ final IEntity p = diagram.getOrCreateGroup(code, Display.getWithNewlines(display), GroupType.PACKAGE,
+ currentPackage);
+ final String color = arg.get(2);
+ if (color != null) {
+ p.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(color));
+ }
+ diagram.endGroup();
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/CommandPage.java b/src/net/sourceforge/plantuml/command/CommandPage.java
new file mode 100644
index 0000000..51fef9f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/CommandPage.java
@@ -0,0 +1,60 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram;
+
+public class CommandPage extends SingleLineCommand<AbstractEntityDiagram> {
+
+ public CommandPage() {
+ super("(?i)^page[%s]+(\\d+)[%s]*x[%s]*(\\d+)$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(AbstractEntityDiagram classDiagram, List<String> arg) {
+
+ final int horizontal = Integer.parseInt(arg.get(0));
+ final int vertical = Integer.parseInt(arg.get(1));
+ if (horizontal <= 0 || vertical <= 0) {
+ return CommandExecutionResult.error("Argument must be positive");
+ }
+ classDiagram.setHorizontalPages(horizontal);
+ classDiagram.setVerticalPages(vertical);
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/CommandPragma.java b/src/net/sourceforge/plantuml/command/CommandPragma.java
new file mode 100644
index 0000000..ff088ba
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/CommandPragma.java
@@ -0,0 +1,54 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.UmlDiagram;
+
+public class CommandPragma extends SingleLineCommand<UmlDiagram> {
+
+ public CommandPragma() {
+ super("(?i)^!pragma[%s]+([A-Za-z_][A-Za-z_0-9]*)(?:[%s]+(.*))?$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(UmlDiagram system, List<String> arg) {
+ system.getPragma().define(StringUtils.goLowerCase(arg.get(0)), arg.get(1));
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/CommandRankDir.java b/src/net/sourceforge/plantuml/command/CommandRankDir.java
new file mode 100644
index 0000000..43788ab
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/CommandRankDir.java
@@ -0,0 +1,58 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.SkinParam;
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
+import net.sourceforge.plantuml.cucadiagram.Rankdir;
+
+public class CommandRankDir extends SingleLineCommand<CucaDiagram> {
+
+ public CommandRankDir() {
+ super("(?i)^(left[%s]to[%s]right|top[%s]to[%s]bottom)[%s]+direction$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(CucaDiagram diagram, List<String> arg) {
+ final String s = StringUtils.goUpperCase(arg.get(0)).replace(' ', '_');
+ ((SkinParam) diagram.getSkinParam()).setRankdir(Rankdir.valueOf(s));
+ // diagram.setRankdir(Rankdir.valueOf(s));
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/CommandRotate.java b/src/net/sourceforge/plantuml/command/CommandRotate.java
new file mode 100644
index 0000000..727b26e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/CommandRotate.java
@@ -0,0 +1,54 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.UmlDiagram;
+
+public class CommandRotate extends SingleLineCommand<UmlDiagram> {
+
+ public CommandRotate() {
+ super("(?i)^rotate$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(UmlDiagram diagram, List<String> arg) {
+
+ diagram.setRotation(true);
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/CommandScale.java b/src/net/sourceforge/plantuml/command/CommandScale.java
new file mode 100644
index 0000000..0cc2841
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/CommandScale.java
@@ -0,0 +1,58 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.ScaleSimple;
+import net.sourceforge.plantuml.UmlDiagram;
+
+public class CommandScale extends SingleLineCommand<UmlDiagram> {
+
+ public CommandScale() {
+ super("(?i)^scale[%s]+([0-9.]+)(?:[%s]*/[%s]*([0-9.]+))?$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(UmlDiagram diagram, List<String> arg) {
+ double scale = Double.parseDouble(arg.get(0));
+ if (arg.get(1) != null) {
+ scale /= Double.parseDouble(arg.get(1));
+ }
+ diagram.setScale(new ScaleSimple(scale));
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/CommandScaleWidthAndHeight.java b/src/net/sourceforge/plantuml/command/CommandScaleWidthAndHeight.java
new file mode 100644
index 0000000..48b42e4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/CommandScaleWidthAndHeight.java
@@ -0,0 +1,56 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.ScaleWidthAndHeight;
+import net.sourceforge.plantuml.UmlDiagram;
+
+public class CommandScaleWidthAndHeight extends SingleLineCommand<UmlDiagram> {
+
+ public CommandScaleWidthAndHeight() {
+ super("(?i)^scale[%s]+([0-9.]+)[%s]*[*x][%s]*([0-9.]+)$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(UmlDiagram diagram, List<String> arg) {
+ final double width = Double.parseDouble(arg.get(0));
+ final double height = Double.parseDouble(arg.get(1));
+ diagram.setScale(new ScaleWidthAndHeight(width, height));
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/CommandScaleWidthOrHeight.java b/src/net/sourceforge/plantuml/command/CommandScaleWidthOrHeight.java
new file mode 100644
index 0000000..35b2cdb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/CommandScaleWidthOrHeight.java
@@ -0,0 +1,61 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.ScaleHeight;
+import net.sourceforge.plantuml.ScaleWidth;
+import net.sourceforge.plantuml.UmlDiagram;
+
+public class CommandScaleWidthOrHeight extends SingleLineCommand<UmlDiagram> {
+
+ public CommandScaleWidthOrHeight() {
+ super("(?i)^scale[%s]+([0-9.]+)[%s]+(width|height)$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(UmlDiagram diagram, List<String> arg) {
+ final double size = Double.parseDouble(arg.get(0));
+ final boolean width = "width".equalsIgnoreCase(arg.get(1));
+ if (width) {
+ diagram.setScale(new ScaleWidth(size));
+ } else {
+ diagram.setScale(new ScaleHeight(size));
+ }
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/CommandSkinParam.java b/src/net/sourceforge/plantuml/command/CommandSkinParam.java
new file mode 100644
index 0000000..b68cdcd
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/CommandSkinParam.java
@@ -0,0 +1,54 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.UmlDiagram;
+
+public class CommandSkinParam extends SingleLineCommand<UmlDiagram> {
+
+ public CommandSkinParam() {
+ super("(?i)^(skinparam|skinparamlocked)[%s]+([\\w.]*(?:\\<\\<.*\\>\\>)?[\\w.]*)[%s]+([^{}]*)$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(UmlDiagram diagram, List<String> arg) {
+ arg.get(0).endsWith("locked");
+ diagram.setParam(arg.get(1), arg.get(2));
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/CommandSkinParamMultilines.java b/src/net/sourceforge/plantuml/command/CommandSkinParamMultilines.java
new file mode 100644
index 0000000..18445eb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/CommandSkinParamMultilines.java
@@ -0,0 +1,116 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.UmlDiagram;
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.StringUtils;
+
+public class CommandSkinParamMultilines extends CommandMultilinesBracket<UmlDiagram> {
+
+ static class Context {
+ private List<String> strings = new ArrayList<String>();
+
+ public void push(String s) {
+ strings.add(s);
+ }
+
+ public void pop() {
+ strings.remove(strings.size() - 1);
+ }
+
+ public String getFullParam() {
+ final StringBuilder sb = new StringBuilder();
+ for (String s : strings) {
+ sb.append(s);
+ }
+ return sb.toString();
+ }
+ }
+
+ private final static Pattern p1 = MyPattern.cmpile("^([\\w.]*(?:\\<\\<.*\\>\\>)?[\\w.]*)[%s]+(?:(\\{)|(.*))$|^\\}?$");
+
+ public CommandSkinParamMultilines() {
+ super("(?i)^skinparam[%s]*(?:[%s]+([\\w.]*(?:\\<\\<.*\\>\\>)?[\\w.]*))?[%s]*\\{$");
+ }
+
+ @Override
+ protected boolean isLineConsistent(String line, int level) {
+ line = line.trim();
+ return p1.matcher(line).matches();
+ }
+
+ public CommandExecutionResult execute(UmlDiagram diagram, List<String> lines) {
+ final Context context = new Context();
+ final Matcher mStart = getStartingPattern().matcher(lines.get(0).trim());
+ if (mStart.find() == false) {
+ throw new IllegalStateException();
+ }
+ if (mStart.group(1) != null) {
+ context.push(mStart.group(1));
+ }
+
+ lines = new ArrayList<String>(lines.subList(1, lines.size() - 1));
+ StringUtils.trim(lines, true);
+
+ for (String s : lines) {
+ assert s.length() > 0;
+ if (s.equals("}")) {
+ context.pop();
+ continue;
+ }
+ final Matcher m = p1.matcher(s);
+ if (m.find() == false) {
+ throw new IllegalStateException();
+ }
+ if (m.group(2) != null) {
+ context.push(m.group(1));
+ } else if (m.group(3) != null) {
+ final String key = context.getFullParam() + m.group(1);
+ diagram.setParam(key, m.group(3));
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/CommandSpriteFile.java b/src/net/sourceforge/plantuml/command/CommandSpriteFile.java
new file mode 100644
index 0000000..1481cc7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/CommandSpriteFile.java
@@ -0,0 +1,84 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command;
+
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+
+import javax.imageio.ImageIO;
+
+import net.sourceforge.plantuml.FileSystem;
+import net.sourceforge.plantuml.Log;
+import net.sourceforge.plantuml.UmlDiagram;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.ugraphic.SpriteImage;
+
+public class CommandSpriteFile extends SingleLineCommand2<UmlDiagram> {
+
+ public CommandSpriteFile() {
+ super(getRegexConcat());
+ }
+
+ private static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("sprite[%s]+\\$?"), //
+ new RegexLeaf("NAME", "([\\p{L}0-9_]+)[%s]*"), //
+ new RegexLeaf("[%s]+"), //
+ new RegexLeaf("FILE", "(.*)"), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(UmlDiagram system, RegexResult arg) {
+ final String src = arg.get("FILE", 0);
+ final BufferedImage im;
+ try {
+ final File f = FileSystem.getInstance().getFile(src);
+ if (f.exists() == false) {
+ return CommandExecutionResult.error("File does not exist: " + src);
+ }
+ im = ImageIO.read(f);
+ } catch (IOException e) {
+ Log.error("Error reading " + src + " " + e);
+ return CommandExecutionResult.error("Cannot read: " + src);
+ }
+ system.addSprite(arg.get("NAME", 0), new SpriteImage(im));
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/CommandTitle.java b/src/net/sourceforge/plantuml/command/CommandTitle.java
new file mode 100644
index 0000000..36c268b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/CommandTitle.java
@@ -0,0 +1,54 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.UmlDiagram;
+import net.sourceforge.plantuml.cucadiagram.Display;
+
+public class CommandTitle extends SingleLineCommand<UmlDiagram> {
+
+ public CommandTitle() {
+ super("(?i)^title(?:[%s]*:[%s]*|[%s]+)(.*[\\p{L}0-9_.].*)$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(UmlDiagram diagram, List<String> arg) {
+ diagram.setTitle(Display.getWithNewlines(arg.get(0)));
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/FactorySpriteCommand.java b/src/net/sourceforge/plantuml/command/FactorySpriteCommand.java
new file mode 100644
index 0000000..14673f1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/FactorySpriteCommand.java
@@ -0,0 +1,139 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
+
+import net.sourceforge.plantuml.UmlDiagram;
+import net.sourceforge.plantuml.command.note.SingleMultiFactoryCommand;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.ugraphic.Sprite;
+import net.sourceforge.plantuml.ugraphic.SpriteGrayLevel;
+import net.sourceforge.plantuml.StringUtils;
+
+public final class FactorySpriteCommand implements SingleMultiFactoryCommand<UmlDiagram> {
+
+ private RegexConcat getRegexConcatMultiLine() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("sprite[%s]+\\$?"), //
+ new RegexLeaf("NAME", "([\\p{L}0-9_]+)[%s]*"), //
+ new RegexLeaf("DIM", "(?:\\[(\\d+)x(\\d+)/(\\d+)(z)?\\])?"), //
+ new RegexLeaf("[%s]*\\{"), //
+ new RegexLeaf("$"));
+ }
+
+ private RegexConcat getRegexConcatSingleLine() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("sprite[%s]+\\$?"), //
+ new RegexLeaf("NAME", "([\\p{L}0-9_]+)[%s]*"), //
+ new RegexLeaf("DIM", "(?:\\[(\\d+)x(\\d+)/(\\d+)(z)\\])?"), //
+ new RegexLeaf("[%s]+"), //
+ new RegexLeaf("DATA", "([-_A-Za-z0-9]+)"), //
+ new RegexLeaf("$"));
+ }
+
+ public Command<UmlDiagram> createSingleLine() {
+ return new SingleLineCommand2<UmlDiagram>(getRegexConcatSingleLine()) {
+
+ @Override
+ protected CommandExecutionResult executeArg(final UmlDiagram system, RegexResult arg) {
+ return executeInternal(system, arg, Arrays.asList(arg.get("DATA", 0)));
+ }
+
+ };
+ }
+
+ public Command<UmlDiagram> createMultiLine() {
+ return new CommandMultilines2<UmlDiagram>(getRegexConcatMultiLine(), MultilinesStrategy.REMOVE_STARTING_QUOTE) {
+
+ @Override
+ public String getPatternEnd() {
+ return "(?i)^end[%s]?sprite|\\}$";
+ }
+
+ public CommandExecutionResult executeNow(final UmlDiagram system, List<String> lines) {
+ StringUtils.trim(lines, true);
+ final RegexResult line0 = getStartingPattern().matcher(lines.get(0).trim());
+
+ final List<String> strings = StringUtils.removeEmptyColumns(lines.subList(1, lines.size() - 1));
+ if (strings.size() == 0) {
+ return CommandExecutionResult.error("No sprite defined.");
+ }
+ return executeInternal(system, line0, strings);
+ }
+
+ };
+ }
+
+ private CommandExecutionResult executeInternal(UmlDiagram system, RegexResult line0,
+ final List<String> strings) {
+ try {
+ final Sprite sprite;
+ if (line0.get("DIM", 0) == null) {
+ sprite = SpriteGrayLevel.GRAY_16.buildSprite(-1, -1, strings);
+ } else {
+ final int width = Integer.parseInt(line0.get("DIM", 0));
+ final int height = Integer.parseInt(line0.get("DIM", 1));
+ final int nbColor = Integer.parseInt(line0.get("DIM", 2));
+ if (nbColor != 4 && nbColor != 8 && nbColor != 16) {
+ return CommandExecutionResult.error("Only 4, 8 or 16 graylevel are allowed.");
+ }
+ final SpriteGrayLevel level = SpriteGrayLevel.get(nbColor);
+ if (line0.get("DIM", 3) == null) {
+ sprite = level.buildSprite(width, height, strings);
+ } else {
+ sprite = level.buildSpriteZ(width, height, concat(strings));
+ }
+ }
+ system.addSprite(line0.get("NAME", 0), sprite);
+ return CommandExecutionResult.ok();
+ } catch (IOException e) {
+ return CommandExecutionResult.error("Cannot decode sprite.");
+ }
+ }
+
+ private String concat(final List<String> strings) {
+ final StringBuilder sb = new StringBuilder();
+ for (String s : strings) {
+ sb.append(s.trim());
+ }
+ return sb.toString();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/MultilinesStrategy.java b/src/net/sourceforge/plantuml/command/MultilinesStrategy.java
new file mode 100644
index 0000000..af492b7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/MultilinesStrategy.java
@@ -0,0 +1,62 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command;
+
+import java.util.Iterator;
+import java.util.List;
+
+public enum MultilinesStrategy {
+ REMOVE_STARTING_QUOTE, KEEP_STARTING_QUOTE;
+
+ public List<String> filter(List<String> lines) {
+ if (this == REMOVE_STARTING_QUOTE) {
+ filterQuote(lines);
+ }
+ return lines;
+ }
+
+ private void filterQuote(List<String> lines) {
+ for (final Iterator<String> it = lines.iterator(); it.hasNext();) {
+ final String s = it.next();
+ if (hasStartingQuote(s)) {
+ it.remove();
+ }
+ }
+ }
+
+ private boolean hasStartingQuote(String s) {
+ return s.trim().startsWith("\'");
+ }
+}
diff --git a/src/net/sourceforge/plantuml/command/PSystemAbstractFactory.java b/src/net/sourceforge/plantuml/command/PSystemAbstractFactory.java
new file mode 100644
index 0000000..2c6d3dc
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/PSystemAbstractFactory.java
@@ -0,0 +1,70 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.ErrorUml;
+import net.sourceforge.plantuml.ErrorUmlType;
+import net.sourceforge.plantuml.PSystemError;
+import net.sourceforge.plantuml.api.PSystemFactory;
+import net.sourceforge.plantuml.core.DiagramType;
+import net.sourceforge.plantuml.core.UmlSource;
+
+public abstract class PSystemAbstractFactory implements PSystemFactory {
+
+ private final DiagramType type;
+
+ protected PSystemAbstractFactory(DiagramType type) {
+ this.type = type;
+ }
+
+ final protected AbstractPSystem buildEmptyError(UmlSource source) {
+ final PSystemError result = new PSystemError(source, new ErrorUml(ErrorUmlType.SYNTAX_ERROR,
+ "Empty description", 1));
+ result.setSource(source);
+ return result;
+ }
+
+ final protected PSystemError buildEmptyError(UmlSource source, String err) {
+ final PSystemError result = new PSystemError(source, new ErrorUml(ErrorUmlType.EXECUTION_ERROR, err, 1));
+ result.setSource(source);
+ return result;
+ }
+
+ final public DiagramType getDiagramType() {
+ return type;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/PSystemBasicFactory.java b/src/net/sourceforge/plantuml/command/PSystemBasicFactory.java
new file mode 100644
index 0000000..5977a6d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/PSystemBasicFactory.java
@@ -0,0 +1,93 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.ErrorUml;
+import net.sourceforge.plantuml.ErrorUmlType;
+import net.sourceforge.plantuml.PSystemError;
+import net.sourceforge.plantuml.core.Diagram;
+import net.sourceforge.plantuml.core.DiagramType;
+import net.sourceforge.plantuml.core.UmlSource;
+import net.sourceforge.plantuml.utils.StartUtils;
+import net.sourceforge.plantuml.version.IteratorCounter;
+
+public abstract class PSystemBasicFactory<P extends AbstractPSystem> extends PSystemAbstractFactory {
+
+ public PSystemBasicFactory(DiagramType diagramType) {
+ super(diagramType);
+ }
+
+ public PSystemBasicFactory() {
+ this(DiagramType.UML);
+ }
+
+ public abstract P executeLine(P system, String line);
+
+ public P init(String startLine) {
+ return null;
+ }
+
+
+ final public Diagram createSystem(UmlSource source) {
+ final IteratorCounter it = source.iterator();
+ final String startLine = it.next();
+ P system = init(startLine);
+ while (it.hasNext()) {
+ final String s = it.next();
+ if (StartUtils.isArobaseEndDiagram(s)) {
+ if (source.getTotalLineCount() == 2) {
+ return buildEmptyError(source);
+ }
+ if (system != null) {
+ system.setSource(source);
+ }
+ return system;
+ }
+ system = executeLine(system, s);
+ if (system == null) {
+ return new PSystemError(source, new ErrorUml(ErrorUmlType.SYNTAX_ERROR, "Syntax Error?",
+ it.currentNum() - 1));
+ }
+ }
+ if (system != null) {
+ system.setSource(source);
+ }
+ return system;
+ }
+
+
+
+}
diff --git a/src/net/sourceforge/plantuml/command/PSystemSingleLineFactory.java b/src/net/sourceforge/plantuml/command/PSystemSingleLineFactory.java
new file mode 100644
index 0000000..8273af6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/PSystemSingleLineFactory.java
@@ -0,0 +1,84 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.ErrorUml;
+import net.sourceforge.plantuml.ErrorUmlType;
+import net.sourceforge.plantuml.PSystemError;
+import net.sourceforge.plantuml.core.Diagram;
+import net.sourceforge.plantuml.core.DiagramType;
+import net.sourceforge.plantuml.core.UmlSource;
+import net.sourceforge.plantuml.utils.StartUtils;
+import net.sourceforge.plantuml.version.IteratorCounter;
+
+public abstract class PSystemSingleLineFactory extends PSystemAbstractFactory {
+
+ protected abstract AbstractPSystem executeLine(String line);
+
+ protected PSystemSingleLineFactory() {
+ super(DiagramType.UML);
+ }
+
+ final public Diagram createSystem(UmlSource source) {
+
+ if (source.isEmpty()) {
+ return buildEmptyError(source);
+ }
+
+ final IteratorCounter it = source.iterator();
+ final String startLine = it.next();
+ if (StartUtils.isArobaseStartDiagram(startLine) == false) {
+ throw new UnsupportedOperationException();
+ }
+
+ if (it.hasNext() == false) {
+ return buildEmptyError(source);
+ }
+ final String s = it.next();
+ if (StartUtils.isArobaseEndDiagram(s)) {
+ return buildEmptyError(source);
+ }
+ final AbstractPSystem sys = executeLine(s);
+ if (sys == null) {
+ return new PSystemError(source, new ErrorUml(ErrorUmlType.SYNTAX_ERROR, "Syntax Error?",
+ it.currentNum() - 1));
+ }
+ sys.setSource(source);
+ return sys;
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/Position.java b/src/net/sourceforge/plantuml/command/Position.java
new file mode 100644
index 0000000..00b03f3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/Position.java
@@ -0,0 +1,64 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command;
+
+import net.sourceforge.plantuml.cucadiagram.Rankdir;
+
+public enum Position {
+ RIGHT, LEFT, BOTTOM, TOP;
+
+ public Position withRankdir(Rankdir rankdir) {
+ if (rankdir == null) {
+ throw new IllegalArgumentException();
+ }
+ if (rankdir == Rankdir.TOP_TO_BOTTOM) {
+ // Default
+ return this;
+ }
+ if (this == RIGHT) {
+ return BOTTOM;
+ }
+ if (this == LEFT) {
+ return TOP;
+ }
+ if (this == BOTTOM) {
+ return RIGHT;
+ }
+ if (this == TOP) {
+ return LEFT;
+ }
+ throw new IllegalStateException();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/command/ProtectedCommand.java b/src/net/sourceforge/plantuml/command/ProtectedCommand.java
new file mode 100644
index 0000000..d21a512
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/ProtectedCommand.java
@@ -0,0 +1,83 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintWriter;
+import java.util.List;
+
+import net.sourceforge.plantuml.Log;
+import net.sourceforge.plantuml.core.Diagram;
+import net.sourceforge.plantuml.version.Version;
+
+public class ProtectedCommand<S extends Diagram> implements Command<S> {
+
+ private final Command<S> cmd;
+
+ public ProtectedCommand(Command<S> cmd) {
+ this.cmd = cmd;
+ }
+
+ public CommandExecutionResult execute(S system, List<String> lines) {
+ try {
+ final CommandExecutionResult result = cmd.execute(system, lines);
+// if (result.isOk()) {
+// // TRACECOMMAND
+// System.err.println("CMD = " + cmd.getClass());
+// }
+ return result;
+ } catch (Throwable t) {
+ t.printStackTrace();
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final PrintWriter pw = new PrintWriter(baos);
+ t.printStackTrace(pw);
+ Log.error("Error " + t);
+ String msg = "You should send a mail to plantuml@gmail.com with this log (V" + Version.versionString()
+ + ")";
+ Log.error(msg);
+ msg += " " + new String(baos.toByteArray());
+ return CommandExecutionResult.error(msg);
+ }
+ }
+
+ public CommandControl isValid(List<String> lines) {
+ return cmd.isValid(lines);
+ }
+
+ public String[] getDescription() {
+ return cmd.getDescription();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/SingleLineCommand.java b/src/net/sourceforge/plantuml/command/SingleLineCommand.java
new file mode 100644
index 0000000..328e7ec
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/SingleLineCommand.java
@@ -0,0 +1,112 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command;
+
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.core.Diagram;
+import net.sourceforge.plantuml.StringUtils;
+
+public abstract class SingleLineCommand<S extends Diagram> implements Command<S> {
+
+ private final Pattern pattern;
+
+ public SingleLineCommand(String pattern) {
+ if (pattern == null) {
+ throw new IllegalArgumentException();
+ }
+ if (pattern.startsWith("(?i)^") == false || pattern.endsWith("$") == false) {
+ throw new IllegalArgumentException("Bad pattern " + pattern);
+ }
+
+ this.pattern = MyPattern.cmpile(pattern);
+ }
+
+ public String[] getDescription() {
+ return new String[] { pattern.pattern() };
+ }
+
+ final public CommandControl isValid(List<String> lines) {
+ if (lines.size() != 1) {
+ return CommandControl.NOT_OK;
+ }
+ if (isCommandForbidden()) {
+ return CommandControl.NOT_OK;
+ }
+ final String line = lines.get(0).trim();
+ final Matcher m = pattern.matcher(line);
+ final boolean result = m.find();
+ if (result) {
+ actionIfCommandValid();
+ }
+ return result ? CommandControl.OK : CommandControl.NOT_OK;
+ }
+
+ protected boolean isCommandForbidden() {
+ return false;
+ }
+
+ protected void actionIfCommandValid() {
+ }
+
+ public final CommandExecutionResult execute(S system, List<String> lines) {
+ if (lines.size() != 1) {
+ throw new IllegalArgumentException();
+ }
+ final String line = lines.get(0).trim();
+ if (isForbidden(line)) {
+ return CommandExecutionResult.error("Forbidden line " + line);
+ }
+ final List<String> arg = getSplit(line);
+ if (arg == null) {
+ return CommandExecutionResult.error("Cannot parse line " + line);
+ }
+ return executeArg(system, arg);
+ }
+
+ protected boolean isForbidden(String line) {
+ return false;
+ }
+
+ protected abstract CommandExecutionResult executeArg(S system, List<String> arg);
+
+ final public List<String> getSplit(String line) {
+ return StringUtils.getSplit(pattern, line);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/SingleLineCommand2.java b/src/net/sourceforge/plantuml/command/SingleLineCommand2.java
new file mode 100644
index 0000000..685d913
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/SingleLineCommand2.java
@@ -0,0 +1,112 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.PSystemError;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.core.Diagram;
+
+public abstract class SingleLineCommand2<S extends Diagram> implements Command<S> {
+
+ private final RegexConcat pattern;
+
+ public SingleLineCommand2(RegexConcat pattern) {
+ if (pattern == null) {
+ throw new IllegalArgumentException();
+ }
+ if (pattern.getPattern().startsWith("^") == false || pattern.getPattern().endsWith("$") == false) {
+ throw new IllegalArgumentException("Bad pattern " + pattern.getPattern());
+ }
+
+ this.pattern = pattern;
+ }
+
+ public String[] getDescription() {
+ return new String[] { pattern.getPattern() };
+ }
+
+ final public CommandControl isValid(List<String> lines) {
+ if (lines.size() != 1) {
+ return CommandControl.NOT_OK;
+ }
+ if (isCommandForbidden()) {
+ return CommandControl.NOT_OK;
+ }
+ final String line = lines.get(0).trim();
+ final boolean result = pattern.match(line);
+ if (result) {
+ actionIfCommandValid();
+ }
+ return result ? CommandControl.OK : CommandControl.NOT_OK;
+ }
+
+ protected boolean isCommandForbidden() {
+ return false;
+ }
+
+ protected void actionIfCommandValid() {
+ }
+
+ public final CommandExecutionResult execute(S system, List<String> lines) {
+ if (lines.size() != 1) {
+ throw new IllegalArgumentException();
+ }
+ final String line = lines.get(0).trim();
+ if (isForbidden(line)) {
+ return CommandExecutionResult.error("Forbidden line " + line);
+ }
+
+ final RegexResult arg = pattern.matcher(line);
+ if (arg == null) {
+ return CommandExecutionResult.error("Cannot parse line " + line);
+ }
+ if (system instanceof PSystemError) {
+ return CommandExecutionResult.error("PSystemError cannot be cast");
+ }
+ // System.err.println("lines="+lines);
+ // System.err.println("pattern="+pattern.getPattern());
+ return executeArg(system, arg);
+ }
+
+ protected boolean isForbidden(String line) {
+ return false;
+ }
+
+ protected abstract CommandExecutionResult executeArg(S system, RegexResult arg);
+
+}
diff --git a/src/net/sourceforge/plantuml/command/UmlDiagramFactory.java b/src/net/sourceforge/plantuml/command/UmlDiagramFactory.java
new file mode 100644
index 0000000..8cda6c5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/UmlDiagramFactory.java
@@ -0,0 +1,264 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.ErrorUml;
+import net.sourceforge.plantuml.ErrorUmlType;
+import net.sourceforge.plantuml.OptionFlags;
+import net.sourceforge.plantuml.PSystemError;
+import net.sourceforge.plantuml.classdiagram.command.CommandHideShow;
+import net.sourceforge.plantuml.classdiagram.command.CommandHideShow3;
+import net.sourceforge.plantuml.core.Diagram;
+import net.sourceforge.plantuml.core.DiagramType;
+import net.sourceforge.plantuml.core.UmlSource;
+import net.sourceforge.plantuml.suggest.SuggestEngine;
+import net.sourceforge.plantuml.suggest.SuggestEngineResult;
+import net.sourceforge.plantuml.suggest.SuggestEngineStatus;
+import net.sourceforge.plantuml.utils.StartUtils;
+import net.sourceforge.plantuml.version.IteratorCounter;
+
+public abstract class UmlDiagramFactory extends PSystemAbstractFactory {
+
+ private final List<Command> cmds;
+
+ protected UmlDiagramFactory() {
+ this(DiagramType.UML);
+ }
+
+ protected UmlDiagramFactory(DiagramType type) {
+ super(type);
+ cmds = createCommands();
+ }
+
+ final public Diagram createSystem(UmlSource source) {
+ final IteratorCounter it = source.iterator();
+ final String startLine = it.next();
+ if (StartUtils.isArobaseStartDiagram(startLine) == false) {
+ throw new UnsupportedOperationException();
+ }
+
+ if (source.isEmpty()) {
+ return buildEmptyError(source);
+ }
+ AbstractPSystem sys = createEmptyDiagram();
+
+ while (it.hasNext()) {
+ final String line = it.next();
+ if (StartUtils.isArobaseEndDiagram(line)) {
+ final String err = checkFinalError(sys);
+ if (err != null) {
+ return buildEmptyError(source, err);
+ }
+ if (source.getTotalLineCount() == 2) {
+ return buildEmptyError(source);
+ }
+ if (sys == null) {
+ return null;
+ }
+ sys.makeDiagramReady();
+ if (sys.isOk() == false) {
+ return null;
+ }
+ sys.setSource(source);
+ return sys;
+ }
+ sys = executeOneLine(sys, source, it, line);
+ if (sys instanceof PSystemError) {
+ return sys;
+ }
+ }
+ sys.setSource(source);
+ return sys;
+
+ }
+
+ private AbstractPSystem executeOneLine(AbstractPSystem sys, UmlSource source, final IteratorCounter it,
+ final String line) {
+ final CommandControl commandControl = isValid(Arrays.asList(line));
+ if (commandControl == CommandControl.NOT_OK) {
+ final ErrorUml err = new ErrorUml(ErrorUmlType.SYNTAX_ERROR, "Syntax Error?", it.currentNum() - 1);
+ if (OptionFlags.getInstance().isUseSuggestEngine()) {
+ final SuggestEngine engine = new SuggestEngine(source, this);
+ final SuggestEngineResult result = engine.tryToSuggest(sys);
+ if (result.getStatus() == SuggestEngineStatus.ONE_SUGGESTION) {
+ err.setSuggest(result);
+ }
+ }
+ sys = new PSystemError(source, err);
+ } else if (commandControl == CommandControl.OK_PARTIAL) {
+ final boolean ok = manageMultiline(sys, line, it);
+ if (ok == false) {
+ sys = new PSystemError(source, new ErrorUml(ErrorUmlType.EXECUTION_ERROR, "Syntax Error?",
+ it.currentNum() - 1));
+
+ }
+ } else if (commandControl == CommandControl.OK) {
+ Command cmd = createCommand(Arrays.asList(line));
+ final CommandExecutionResult result = sys.executeCommand(cmd, Arrays.asList(line));
+ if (result.isOk() == false) {
+ sys = new PSystemError(source, new ErrorUml(ErrorUmlType.EXECUTION_ERROR, result.getError(),
+ it.currentNum() - 1));
+ }
+ if (result.getNewDiagram() != null) {
+ sys = result.getNewDiagram();
+ }
+ } else {
+ assert false;
+ }
+ return sys;
+ }
+
+ private boolean manageMultiline(AbstractPSystem system, final String init, IteratorCounter it) {
+ final List<String> lines = new ArrayList<String>();
+ addOneSingleLineManageEmbedded(lines, init, it);
+ while (it.hasNext()) {
+ final String s = it.next();
+ if (StartUtils.isArobaseEndDiagram(s)) {
+ return false;
+ }
+ addOneSingleLineManageEmbedded(lines, s, it);
+ final CommandControl commandControl = isValid(lines);
+ if (commandControl == CommandControl.NOT_OK) {
+ // throw new IllegalStateException();
+ return false;
+ }
+ if (commandControl == CommandControl.OK) {
+ final Command cmd = createCommand(lines);
+ final CommandExecutionResult result = system.executeCommand(cmd, lines);
+ return result.isOk();
+ }
+ }
+ return false;
+
+ }
+
+ private void addOneSingleLineManageEmbedded(final List<String> lines, final String linetoBeAdded, IteratorCounter it) {
+ lines.add(linetoBeAdded);
+ if (linetoBeAdded.trim().equals("{{")) {
+ while (it.hasNext()) {
+ final String s = it.next();
+ lines.add(s);
+ if (s.trim().equals("}}")) {
+ return;
+ }
+ }
+ }
+ }
+
+ // -----------------------------------
+
+ public String checkFinalError(AbstractPSystem system) {
+ return null;
+ }
+
+ final public CommandControl isValid(List<String> lines) {
+ for (Command cmd : cmds) {
+ final CommandControl result = cmd.isValid(lines);
+ if (result == CommandControl.OK || result == CommandControl.OK_PARTIAL) {
+ return result;
+ }
+ }
+ return CommandControl.NOT_OK;
+
+ }
+
+ final public Command createCommand(List<String> lines) {
+ for (Command cmd : cmds) {
+ final CommandControl result = cmd.isValid(lines);
+ if (result == CommandControl.OK) {
+ return cmd;
+ } else if (result == CommandControl.OK_PARTIAL) {
+ throw new IllegalArgumentException();
+ }
+ }
+ throw new IllegalArgumentException();
+ }
+
+ protected abstract List<Command> createCommands();
+
+ public abstract AbstractPSystem createEmptyDiagram();
+
+ final protected void addCommonCommands(List<Command> cmds) {
+ cmds.add(new CommandNope());
+ cmds.add(new CommandComment());
+ cmds.add(new CommandMultilinesComment());
+ cmds.add(new CommandPragma());
+ cmds.add(new CommandTitle());
+ cmds.add(new CommandMultilinesTitle());
+ cmds.add(new CommandMultilinesLegend());
+
+ cmds.add(new CommandFooter());
+ cmds.add(new CommandMultilinesFooter());
+
+ cmds.add(new CommandHeader());
+ cmds.add(new CommandMultilinesHeader());
+
+ cmds.add(new CommandSkinParam());
+ cmds.add(new CommandSkinParamMultilines());
+ cmds.add(new CommandMinwidth());
+ cmds.add(new CommandRotate());
+ cmds.add(new CommandScale());
+ cmds.add(new CommandScaleWidthAndHeight());
+ cmds.add(new CommandScaleWidthOrHeight());
+ cmds.add(new CommandAffineTransform());
+ cmds.add(new CommandAffineTransformMultiline());
+ cmds.add(new CommandHideUnlinked());
+ final FactorySpriteCommand factorySpriteCommand = new FactorySpriteCommand();
+ cmds.add(factorySpriteCommand.createMultiLine());
+ cmds.add(factorySpriteCommand.createSingleLine());
+ cmds.add(new CommandSpriteFile());
+
+ cmds.add(new CommandHideShow3());
+ cmds.add(new CommandHideShow());
+
+
+ }
+
+ final public List<String> getDescription() {
+ final List<String> result = new ArrayList<String>();
+ for (Command cmd : createCommands()) {
+ result.addAll(Arrays.asList(cmd.getDescription()));
+ }
+ return Collections.unmodifiableList(result);
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/note/FactoryNoteActivityCommand.java b/src/net/sourceforge/plantuml/command/note/FactoryNoteActivityCommand.java
new file mode 100644
index 0000000..a004c68
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/note/FactoryNoteActivityCommand.java
@@ -0,0 +1,159 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command.note;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
+import net.sourceforge.plantuml.activitydiagram.ActivityDiagram;
+import net.sourceforge.plantuml.command.Command;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.CommandMultilines2;
+import net.sourceforge.plantuml.command.MultilinesStrategy;
+import net.sourceforge.plantuml.command.Position;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.cucadiagram.LinkDecor;
+import net.sourceforge.plantuml.cucadiagram.LinkType;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.utils.UniqueSequence;
+
+public final class FactoryNoteActivityCommand implements SingleMultiFactoryCommand<ActivityDiagram> {
+
+ private RegexConcat getRegexConcatMultiLine() {
+ return new RegexConcat(new RegexLeaf("^note[%s]+"), //
+ new RegexLeaf("POSITION", "(right|left|top|bottom)[%s]*"), //
+ new RegexLeaf("COLOR", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("$"));
+ }
+
+ private RegexConcat getRegexConcatSingleLine() {
+ return new RegexConcat(new RegexLeaf("^note[%s]+"), //
+ new RegexLeaf("POSITION", "(right|left|top|bottom)[%s]*"), //
+ new RegexLeaf("COLOR", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), //
+ new RegexLeaf("[%s]*:[%s]*"), //
+ new RegexLeaf("NOTE", "(.*)"), //
+ new RegexLeaf("$"));
+ }
+
+ public Command<ActivityDiagram> createMultiLine() {
+ return new CommandMultilines2<ActivityDiagram>(getRegexConcatMultiLine(),
+ MultilinesStrategy.KEEP_STARTING_QUOTE) {
+
+ @Override
+ public String getPatternEnd() {
+ return "(?i)^end[%s]?note$";
+ }
+
+ public final CommandExecutionResult executeNow(final ActivityDiagram system, List<String> lines) {
+ // StringUtils.trim(lines, true);
+ final RegexResult arg = getStartingPattern().matcher(lines.get(0).trim());
+ Display strings = Display.create(StringUtils.removeEmptyColumns(lines.subList(1, lines.size() - 1)));
+
+ Url url = null;
+ if (strings.size() > 0) {
+ final UrlBuilder urlBuilder = new UrlBuilder(system.getSkinParam().getValue("topurl"),
+ ModeUrl.STRICT);
+ url = urlBuilder.getUrl(strings.get(0).toString());
+ }
+ if (url != null) {
+ strings = strings.subList(1, strings.size());
+ }
+
+ // final String s = StringUtils.getMergedLines(strings);
+
+ final IEntity note = system.createLeaf(UniqueSequence.getCode("GMN"), strings, LeafType.NOTE, null);
+ if (url != null) {
+ note.addUrl(url);
+ }
+ return executeInternal(system, arg, note);
+ }
+ };
+ }
+
+ public Command<ActivityDiagram> createSingleLine() {
+ return new SingleLineCommand2<ActivityDiagram>(getRegexConcatSingleLine()) {
+
+ @Override
+ protected CommandExecutionResult executeArg(final ActivityDiagram system, RegexResult arg) {
+ final IEntity note = system.createNote(UniqueSequence.getCode("GN"),
+ Display.getWithNewlines(arg.get("NOTE", 0)));
+ return executeInternal(system, arg, note);
+ }
+ };
+ }
+
+ private CommandExecutionResult executeInternal(ActivityDiagram diagram, RegexResult arg, IEntity note) {
+
+ note.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0)));
+
+ IEntity activity = diagram.getLastEntityConsulted();
+ if (activity == null) {
+ activity = diagram.getStart();
+ }
+
+ final Link link;
+
+ final Position position = Position.valueOf(StringUtils.goUpperCase(arg.get("POSITION", 0))).withRankdir(
+ diagram.getSkinParam().getRankdir());
+
+ final LinkType type = new LinkType(LinkDecor.NONE, LinkDecor.NONE).getDashed();
+
+ if (position == Position.RIGHT) {
+ link = new Link(activity, note, type, null, 1);
+ } else if (position == Position.LEFT) {
+ link = new Link(note, activity, type, null, 1);
+ } else if (position == Position.BOTTOM) {
+ link = new Link(activity, note, type, null, 2);
+ } else if (position == Position.TOP) {
+ link = new Link(note, activity, type, null, 2);
+ } else {
+ throw new IllegalArgumentException();
+ }
+ diagram.addLink(link);
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/note/FactoryNoteCommand.java b/src/net/sourceforge/plantuml/command/note/FactoryNoteCommand.java
new file mode 100644
index 0000000..32964b3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/note/FactoryNoteCommand.java
@@ -0,0 +1,121 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command.note;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram;
+import net.sourceforge.plantuml.command.Command;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.CommandMultilines2;
+import net.sourceforge.plantuml.command.MultilinesStrategy;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+import net.sourceforge.plantuml.graphic.HtmlColorSet;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.StringUtils;
+
+public final class FactoryNoteCommand implements SingleMultiFactoryCommand<AbstractEntityDiagram> {
+
+ private RegexConcat getRegexConcatMultiLine() {
+ return new RegexConcat(new RegexLeaf("^(note)[%s]+"), //
+ new RegexLeaf("CODE", "as[%s]+([\\p{L}0-9_.]+)"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("COLOR", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), //
+ new RegexLeaf("$") //
+ );
+ }
+
+ private RegexConcat getRegexConcatSingleLine() {
+ return new RegexConcat(new RegexLeaf("^note[%s]+"), //
+ new RegexLeaf("DISPLAY", "[%g]([^%g]+)[%g][%s]+as[%s]+"), //
+ new RegexLeaf("CODE", "([\\p{L}0-9_.]+)[%s]*"), //
+ new RegexLeaf("COLOR", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), //
+ new RegexLeaf("$") //
+ );
+
+ }
+
+ public Command<AbstractEntityDiagram> createSingleLine() {
+ return new SingleLineCommand2<AbstractEntityDiagram>(getRegexConcatSingleLine()) {
+
+ @Override
+ protected CommandExecutionResult executeArg(final AbstractEntityDiagram system, RegexResult arg) {
+ final String display = arg.get("DISPLAY", 0);
+ return executeInternal(system, arg, StringUtils.getWithNewlines2(display));
+ }
+
+ };
+ }
+
+ public Command<AbstractEntityDiagram> createMultiLine() {
+ return new CommandMultilines2<AbstractEntityDiagram>(getRegexConcatMultiLine(),
+ MultilinesStrategy.KEEP_STARTING_QUOTE) {
+
+ @Override
+ public String getPatternEnd() {
+ return "(?i)^end[%s]?note$";
+ }
+
+ public CommandExecutionResult executeNow(final AbstractEntityDiagram system, List<String> lines) {
+ // StringUtils.trim(lines, false);
+ final RegexResult line0 = getStartingPattern().matcher(lines.get(0).trim());
+
+ final List<String> strings = StringUtils.removeEmptyColumns(lines.subList(1, lines.size() - 1));
+
+ return executeInternal(system, line0, strings);
+ }
+ };
+ }
+
+ private CommandExecutionResult executeInternal(AbstractEntityDiagram diagram, RegexResult arg,
+ final List<? extends CharSequence> display) {
+ final Code code = Code.of(arg.get("CODE", 0));
+ if (diagram.leafExist(code)) {
+ return CommandExecutionResult.error("Note already created: " + code.getFullName());
+ }
+ final IEntity entity = diagram.createLeaf(code, Display.create(display), LeafType.NOTE, null);
+ assert entity != null;
+ entity.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0)));
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/note/FactoryNoteOnEntityCommand.java b/src/net/sourceforge/plantuml/command/note/FactoryNoteOnEntityCommand.java
new file mode 100644
index 0000000..c2d34ea
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/note/FactoryNoteOnEntityCommand.java
@@ -0,0 +1,183 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command.note;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
+import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram;
+import net.sourceforge.plantuml.command.Command;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.CommandMultilines2;
+import net.sourceforge.plantuml.command.MultilinesStrategy;
+import net.sourceforge.plantuml.command.Position;
+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.RegexOr;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.cucadiagram.LinkDecor;
+import net.sourceforge.plantuml.cucadiagram.LinkType;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.utils.UniqueSequence;
+
+public final class FactoryNoteOnEntityCommand implements SingleMultiFactoryCommand<AbstractEntityDiagram> {
+
+ private final IRegex partialPattern;
+
+ public FactoryNoteOnEntityCommand(IRegex partialPattern) {
+ this.partialPattern = partialPattern;
+ }
+
+ private RegexConcat getRegexConcatSingleLine(IRegex partialPattern) {
+ return new RegexConcat(new RegexLeaf("^note[%s]+"), //
+ new RegexLeaf("POSITION", "(right|left|top|bottom)"), //
+ new RegexOr(//
+ new RegexConcat(new RegexLeaf("[%s]+of[%s]+"), partialPattern), //
+ new RegexLeaf("")), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("COLOR", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), //
+ new RegexLeaf("[%s]*:[%s]*"), //
+ new RegexLeaf("NOTE", "(.*)"), //
+ new RegexLeaf("$") //
+ );
+ }
+
+ private RegexConcat getRegexConcatMultiLine(IRegex partialPattern) {
+ return new RegexConcat(new RegexLeaf("^note[%s]+"), //
+ new RegexLeaf("POSITION", "(right|left|top|bottom)"), //
+ new RegexOr(//
+ new RegexConcat(new RegexLeaf("[%s]+of[%s]+"), partialPattern), //
+ new RegexLeaf("")), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("COLOR", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), //
+ new RegexLeaf("[%s]*\\{?"), //
+ new RegexLeaf("$") //
+ );
+ }
+
+ public Command<AbstractEntityDiagram> createSingleLine() {
+ return new SingleLineCommand2<AbstractEntityDiagram>(getRegexConcatSingleLine(partialPattern)) {
+
+ @Override
+ protected CommandExecutionResult executeArg(final AbstractEntityDiagram system, RegexResult arg) {
+ final String s = arg.get("NOTE", 0);
+ return executeInternal(arg, system, null, StringUtils.getWithNewlines2(s));
+ }
+ };
+ }
+
+ public Command<AbstractEntityDiagram> createMultiLine() {
+ return new CommandMultilines2<AbstractEntityDiagram>(getRegexConcatMultiLine(partialPattern),
+ MultilinesStrategy.KEEP_STARTING_QUOTE) {
+
+ @Override
+ public String getPatternEnd() {
+ return "(?i)^(end[%s]?note|\\})$";
+ }
+
+ public CommandExecutionResult executeNow(final AbstractEntityDiagram system, List<String> lines) {
+ // StringUtils.trim(lines, false);
+ final RegexResult line0 = getStartingPattern().matcher(lines.get(0).trim());
+
+ List<String> strings = StringUtils.removeEmptyColumns(lines.subList(1, lines.size() - 1));
+ Url url = null;
+ if (strings.size() > 0) {
+ final UrlBuilder urlBuilder = new UrlBuilder(system.getSkinParam().getValue("topurl"),
+ ModeUrl.STRICT);
+ url = urlBuilder.getUrl(strings.get(0));
+ }
+ if (url != null) {
+ strings = strings.subList(1, strings.size());
+ }
+
+ return executeInternal(line0, system, url, strings);
+ }
+ };
+ }
+
+ private CommandExecutionResult executeInternal(RegexResult line0, AbstractEntityDiagram diagram, Url url,
+ List<? extends CharSequence> s) {
+
+ final String pos = line0.get("POSITION", 0);
+
+ final Code code = Code.of(line0.get("ENTITY", 0));
+ final IEntity cl1;
+ if (code == null) {
+ cl1 = diagram.getLastEntity();
+ if (cl1 == null) {
+ return CommandExecutionResult.error("Nothing to note to");
+ }
+ } else {
+ cl1 = diagram.getOrCreateLeaf(code, null, null);
+ }
+
+ final IEntity note = diagram.createLeaf(UniqueSequence.getCode("GMN"), Display.create(s), LeafType.NOTE, null);
+ note.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(line0.get("COLOR", 0)));
+ if (url != null) {
+ note.addUrl(url);
+ }
+
+ final Position position = Position.valueOf(StringUtils.goUpperCase(pos)).withRankdir(diagram.getSkinParam().getRankdir());
+ final Link link;
+
+ final LinkType type = new LinkType(LinkDecor.NONE, LinkDecor.NONE).getDashed();
+ if (position == Position.RIGHT) {
+ link = new Link(cl1, note, type, null, 1);
+ link.setHorizontalSolitary(true);
+ } else if (position == Position.LEFT) {
+ link = new Link(note, cl1, type, null, 1);
+ link.setHorizontalSolitary(true);
+ } else if (position == Position.BOTTOM) {
+ link = new Link(cl1, note, type, null, 2);
+ } else if (position == Position.TOP) {
+ link = new Link(note, cl1, type, null, 2);
+ } else {
+ throw new IllegalArgumentException();
+ }
+ diagram.addLink(link);
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/note/FactoryNoteOnLinkCommand.java b/src/net/sourceforge/plantuml/command/note/FactoryNoteOnLinkCommand.java
new file mode 100644
index 0000000..f1fabe5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/note/FactoryNoteOnLinkCommand.java
@@ -0,0 +1,131 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command.note;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
+import net.sourceforge.plantuml.command.Command;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.CommandMultilines2;
+import net.sourceforge.plantuml.command.MultilinesStrategy;
+import net.sourceforge.plantuml.command.Position;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.StringUtils;
+
+public final class FactoryNoteOnLinkCommand implements SingleMultiFactoryCommand<CucaDiagram> {
+
+ private RegexConcat getRegexConcatSingleLine() {
+ return new RegexConcat(new RegexLeaf("^note[%s]+"), //
+ new RegexLeaf("POSITION", "(right|left|top|bottom)?[%s]*on[%s]+link"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("COLOR", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), //
+ new RegexLeaf("[%s]*:[%s]*"), //
+ new RegexLeaf("NOTE", "(.*)"), //
+ new RegexLeaf("$"));
+ }
+
+ private RegexConcat getRegexConcatMultiLine() {
+ return new RegexConcat(new RegexLeaf("^note[%s]+"), //
+ new RegexLeaf("POSITION", "(right|left|top|bottom)?[%s]*on[%s]+link"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("COLOR", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), //
+ new RegexLeaf("$"));
+ }
+
+ public Command<CucaDiagram> createMultiLine() {
+ return new CommandMultilines2<CucaDiagram>(getRegexConcatMultiLine(), MultilinesStrategy.KEEP_STARTING_QUOTE) {
+
+ @Override
+ public String getPatternEnd() {
+ return "(?i)^end[%s]?note$";
+ }
+
+ public CommandExecutionResult executeNow(final CucaDiagram system, List<String> lines) {
+ final List<String> strings = StringUtils.removeEmptyColumns(lines.subList(1, lines.size() - 1));
+ if (strings.size() > 0) {
+ final RegexResult arg = getStartingPattern().matcher(lines.get(0));
+ return executeInternal(system, strings, arg);
+ }
+ return CommandExecutionResult.error("No note defined");
+ }
+
+ };
+ }
+
+ public Command<CucaDiagram> createSingleLine() {
+ return new SingleLineCommand2<CucaDiagram>(getRegexConcatSingleLine()) {
+
+ @Override
+ protected CommandExecutionResult executeArg(final CucaDiagram system, RegexResult arg) {
+ final List<String> note = StringUtils.getWithNewlines2(arg.get("NOTE", 0));
+ return executeInternal(system, note, arg);
+ }
+ };
+ }
+
+ private CommandExecutionResult executeInternal(CucaDiagram diagram, List<? extends CharSequence> note,
+ final RegexResult arg) {
+ final Link link = diagram.getLastLink();
+ if (link == null) {
+ return CommandExecutionResult.error("No link defined");
+ }
+ Position position = Position.BOTTOM;
+ if (arg.get("POSITION", 0) != null) {
+ position = Position.valueOf(StringUtils.goUpperCase(arg.get("POSITION", 0)));
+ }
+ Url url = null;
+ if (note.size() > 0) {
+ final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
+ url = urlBuilder.getUrl(note.get(0).toString());
+ }
+ if (url != null) {
+ note = note.subList(1, note.size());
+ }
+ link.addNote(Display.create(note), position,
+ diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0)));
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/note/SingleMultiFactoryCommand.java b/src/net/sourceforge/plantuml/command/note/SingleMultiFactoryCommand.java
new file mode 100644
index 0000000..69c0851
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/note/SingleMultiFactoryCommand.java
@@ -0,0 +1,46 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command.note;
+
+import net.sourceforge.plantuml.command.Command;
+import net.sourceforge.plantuml.core.Diagram;
+
+public interface SingleMultiFactoryCommand<D extends Diagram> {
+
+ public Command<D> createSingleLine();
+
+ public Command<D> createMultiLine();
+
+}
diff --git a/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteCommand.java b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteCommand.java
new file mode 100644
index 0000000..af502ba
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteCommand.java
@@ -0,0 +1,129 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command.note.sequence;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.Command;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.CommandMultilines2;
+import net.sourceforge.plantuml.command.MultilinesStrategy;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.note.SingleMultiFactoryCommand;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColorSet;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.sequencediagram.Note;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+import net.sourceforge.plantuml.sequencediagram.NoteStyle;
+import net.sourceforge.plantuml.sequencediagram.Participant;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+import net.sourceforge.plantuml.StringUtils;
+
+public final class FactorySequenceNoteCommand implements SingleMultiFactoryCommand<SequenceDiagram> {
+
+ private RegexConcat getRegexConcatMultiLine() {
+ return new RegexConcat(//
+ new RegexLeaf("^"), //
+ new RegexLeaf("VMERGE", "(/)?[%s]*"), //
+ new RegexLeaf("STYLE", "(note|hnote|rnote)[%s]+"), //
+ new RegexLeaf("POSITION", "(right|left|over)[%s]+"), //
+ new RegexLeaf("PARTICIPANT", "(?:of[%s]+)?([\\p{L}0-9_.@]+|[%g][^%g]+[%g])[%s]*"), //
+ new RegexLeaf("COLOR", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), //
+ new RegexLeaf("$"));
+ }
+
+ private RegexConcat getRegexConcatSingleLine() {
+ return new RegexConcat(//
+ new RegexLeaf("^"), //
+ new RegexLeaf("VMERGE", "(/)?[%s]*"), //
+ new RegexLeaf("STYLE", "(note|hnote|rnote)[%s]+"), //
+ new RegexLeaf("POSITION", "(right|left|over)[%s]+"), //
+ new RegexLeaf("PARTICIPANT", "(?:of[%s])?([\\p{L}0-9_.@]+|[%g][^%g]+[%g])[%s]*"), //
+ new RegexLeaf("COLOR", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), //
+ new RegexLeaf("[%s]*:[%s]*"), //
+ new RegexLeaf("NOTE", "(.*)"), //
+ new RegexLeaf("$"));
+ }
+
+ public Command<SequenceDiagram> createMultiLine() {
+ return new CommandMultilines2<SequenceDiagram>(getRegexConcatMultiLine(),
+ MultilinesStrategy.KEEP_STARTING_QUOTE) {
+
+ @Override
+ public String getPatternEnd() {
+ return "(?i)^end[%s]?(note|hnote|rnote)$";
+ }
+
+ public CommandExecutionResult executeNow(final SequenceDiagram system, List<String> lines) {
+ final RegexResult line0 = getStartingPattern().matcher(lines.get(0).trim());
+ final List<String> strings = StringUtils.removeEmptyColumns(lines.subList(1, lines.size() - 1));
+ return executeInternal(system, line0, strings);
+ }
+ };
+ }
+
+ public Command<SequenceDiagram> createSingleLine() {
+ return new SingleLineCommand2<SequenceDiagram>(getRegexConcatSingleLine()) {
+
+ @Override
+ protected CommandExecutionResult executeArg(final SequenceDiagram system, RegexResult arg) {
+ final List<String> strings = StringUtils.getWithNewlines2(arg.get("NOTE", 0));
+ return executeInternal(system, arg, strings);
+ }
+
+ };
+ }
+
+ private CommandExecutionResult executeInternal(SequenceDiagram diagram, RegexResult arg, final List<String> strings) {
+ final Participant p = diagram.getOrCreateParticipant(StringUtils
+ .eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("PARTICIPANT", 0)));
+
+ final NotePosition position = NotePosition.valueOf(StringUtils.goUpperCase(arg.get("POSITION", 0)));
+
+ if (strings.size() > 0) {
+ final boolean tryMerge = arg.get("VMERGE", 0) != null;
+ final Note note = new Note(p, position, Display.create(strings));
+ note.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0)));
+ note.setStyle(NoteStyle.getNoteStyle(arg.get("STYLE", 0)));
+ diagram.addNote(note, tryMerge);
+ }
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOnArrowCommand.java b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOnArrowCommand.java
new file mode 100644
index 0000000..ea1cf43
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOnArrowCommand.java
@@ -0,0 +1,129 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command.note.sequence;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
+import net.sourceforge.plantuml.command.Command;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.CommandMultilines2;
+import net.sourceforge.plantuml.command.MultilinesStrategy;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.note.SingleMultiFactoryCommand;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.sequencediagram.AbstractMessage;
+import net.sourceforge.plantuml.sequencediagram.EventWithDeactivate;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+import net.sourceforge.plantuml.StringUtils;
+
+public final class FactorySequenceNoteOnArrowCommand implements SingleMultiFactoryCommand<SequenceDiagram> {
+
+ private RegexConcat getRegexConcatMultiLine() {
+ return new RegexConcat(new RegexLeaf("^note[%s]+"), //
+ new RegexLeaf("POSITION", "(right|left)[%s]*"), //
+ new RegexLeaf("COLOR", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), //
+ new RegexLeaf("$"));
+ }
+
+ private RegexConcat getRegexConcatSingleLine() {
+ return new RegexConcat(new RegexLeaf("^note[%s]+"), //
+ new RegexLeaf("POSITION", "(right|left)[%s]*"), //
+ new RegexLeaf("COLOR", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), //
+ new RegexLeaf("[%s]*:[%s]*"), //
+ new RegexLeaf("NOTE", "(.*)"), //
+ new RegexLeaf("$"));
+ }
+
+ public Command<SequenceDiagram> createSingleLine() {
+ return new SingleLineCommand2<SequenceDiagram>(getRegexConcatSingleLine()) {
+
+ @Override
+ protected CommandExecutionResult executeArg(final SequenceDiagram system, RegexResult arg) {
+ final List<String> strings = StringUtils.getWithNewlines2(arg.get("NOTE", 0));
+ return executeInternal(system, arg, strings);
+ }
+
+ };
+ }
+
+ public Command<SequenceDiagram> createMultiLine() {
+ return new CommandMultilines2<SequenceDiagram>(getRegexConcatMultiLine(),
+ MultilinesStrategy.KEEP_STARTING_QUOTE) {
+
+ @Override
+ public String getPatternEnd() {
+ return "(?i)^end[%s]?note$";
+ }
+
+ public CommandExecutionResult executeNow(final SequenceDiagram system, List<String> lines) {
+ final RegexResult line0 = getStartingPattern().matcher(lines.get(0).trim());
+ final List<String> in = StringUtils.removeEmptyColumns(lines.subList(1, lines.size() - 1));
+
+ return executeInternal(system, line0, in);
+ }
+
+ };
+ }
+
+ private CommandExecutionResult executeInternal(SequenceDiagram system, final RegexResult line0, List<String> in) {
+ final EventWithDeactivate m = system.getLastEventWithDeactivate();
+ if (m instanceof AbstractMessage) {
+ final NotePosition position = NotePosition.valueOf(StringUtils.goUpperCase(line0.get("POSITION", 0)));
+ final Url url;
+ if (in.size() > 0) {
+ final UrlBuilder urlBuilder = new UrlBuilder(system.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
+ url = urlBuilder.getUrl(in.get(0).toString());
+ } else {
+ url = null;
+ }
+ if (url != null) {
+ in = in.subList(1, in.size());
+ }
+
+ ((AbstractMessage) m).setNote(Display.create(in), position, line0.get("COLOR", 0), url);
+ }
+
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOverSeveralCommand.java b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOverSeveralCommand.java
new file mode 100644
index 0000000..dc1aa3d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOverSeveralCommand.java
@@ -0,0 +1,132 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command.note.sequence;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.Command;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.CommandMultilines2;
+import net.sourceforge.plantuml.command.MultilinesStrategy;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.note.SingleMultiFactoryCommand;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.sequencediagram.Note;
+import net.sourceforge.plantuml.sequencediagram.NoteStyle;
+import net.sourceforge.plantuml.sequencediagram.Participant;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+import net.sourceforge.plantuml.StringUtils;
+
+public final class FactorySequenceNoteOverSeveralCommand implements SingleMultiFactoryCommand<SequenceDiagram> {
+
+ private RegexConcat getRegexConcatMultiLine() {
+ return new RegexConcat( //
+ new RegexLeaf("^"), //
+ new RegexLeaf("VMERGE", "(/)?[%s]*"), //
+ new RegexLeaf("STYLE", "(note|hnote|rnote)[%s]+over[%s]+"), //
+ new RegexLeaf("P1", "([\\p{L}0-9_.@]+|[%g][^%g]+[%g])[%s]*\\,[%s]*"), //
+ new RegexLeaf("P2", "([\\p{L}0-9_.@]+|[%g][^%g]+[%g])[%s]*"), //
+ new RegexLeaf("COLOR", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), //
+ new RegexLeaf("$") //
+ );
+ }
+
+ private RegexConcat getRegexConcatSingleLine() {
+ return new RegexConcat( //
+ new RegexLeaf("^"), //
+ new RegexLeaf("VMERGE", "(/)?[%s]*"), //
+ new RegexLeaf("STYLE", "(note|hnote|rnote)[%s]+over[%s]+"), //
+ new RegexLeaf("P1", "([\\p{L}0-9_.@]+|[%g][^%g]+[%g])[%s]*\\,[%s]*"), //
+ new RegexLeaf("P2", "([\\p{L}0-9_.@]+|[%g][^%g]+[%g])[%s]*"), //
+ new RegexLeaf("COLOR", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), //
+ new RegexLeaf("[%s]*:[%s]*"), //
+ new RegexLeaf("NOTE", "(.*)"), //
+ new RegexLeaf("$"));
+ }
+
+ public Command<SequenceDiagram> createSingleLine() {
+ return new SingleLineCommand2<SequenceDiagram>(getRegexConcatSingleLine()) {
+
+ @Override
+ protected CommandExecutionResult executeArg(final SequenceDiagram system, RegexResult arg) {
+ final List<String> strings = StringUtils.getWithNewlines2(arg.get("NOTE", 0));
+
+ return executeInternal(system, arg, strings);
+ }
+
+ };
+ }
+
+ public Command<SequenceDiagram> createMultiLine() {
+ return new CommandMultilines2<SequenceDiagram>(getRegexConcatMultiLine(),
+ MultilinesStrategy.KEEP_STARTING_QUOTE) {
+
+ @Override
+ public String getPatternEnd() {
+ return "(?i)^end[%s]?(note|hnote|rnote)$";
+ }
+
+ public CommandExecutionResult executeNow(final SequenceDiagram system, List<String> lines) {
+ final RegexResult line0 = getStartingPattern().matcher(lines.get(0).trim());
+ final List<String> strings = StringUtils.removeEmptyColumns(lines.subList(1, lines.size() - 1));
+
+ return executeInternal(system, line0, strings);
+ }
+
+ };
+ }
+
+ private CommandExecutionResult executeInternal(SequenceDiagram diagram, final RegexResult line0,
+ final List<String> strings) {
+ final Participant p1 = diagram.getOrCreateParticipant(StringUtils
+ .eventuallyRemoveStartingAndEndingDoubleQuote(line0.get("P1", 0)));
+ final Participant p2 = diagram.getOrCreateParticipant(StringUtils
+ .eventuallyRemoveStartingAndEndingDoubleQuote(line0.get("P2", 0)));
+
+ if (strings.size() > 0) {
+ final boolean tryMerge = line0.get("VMERGE", 0) != null;
+ final Note note = new Note(p1, p2, Display.create(strings));
+ note.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(line0.get("COLOR", 0)));
+ note.setStyle(NoteStyle.getNoteStyle(line0.get("STYLE", 0)));
+ diagram.addNote(note, tryMerge);
+ }
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/regex/IRegex.java b/src/net/sourceforge/plantuml/command/regex/IRegex.java
new file mode 100644
index 0000000..788ea6f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/regex/IRegex.java
@@ -0,0 +1,48 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command.regex;
+
+import java.util.Iterator;
+import java.util.Map;
+
+public interface IRegex {
+
+ public String getPattern();
+
+ public int count();
+
+ public Map<String, RegexPartialMatch> createPartialMatch(Iterator<String> it);
+
+}
diff --git a/src/net/sourceforge/plantuml/command/regex/MatcherIterator.java b/src/net/sourceforge/plantuml/command/regex/MatcherIterator.java
new file mode 100644
index 0000000..217994d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/regex/MatcherIterator.java
@@ -0,0 +1,61 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command.regex;
+
+import java.util.Iterator;
+import java.util.regex.Matcher;
+
+public class MatcherIterator implements Iterator<String> {
+
+ private int cpt = 1;
+ private final Matcher matcher;
+
+ MatcherIterator(Matcher matcher) {
+ this.matcher = matcher;
+ }
+
+ public boolean hasNext() {
+ return cpt <= matcher.groupCount();
+ }
+
+ public String next() {
+ return matcher.group(cpt++);
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/regex/MyPattern.java b/src/net/sourceforge/plantuml/command/regex/MyPattern.java
new file mode 100644
index 0000000..5edb14e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/regex/MyPattern.java
@@ -0,0 +1,99 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command.regex;
+
+import java.util.regex.Pattern;
+
+// Splitter.java to be finished
+public abstract class MyPattern {
+
+ public static Pattern cmpile(String p) {
+ p = transformAndCheck(p);
+ return Pattern.compile(p);
+ }
+
+ public static Pattern cmpileNockeck(String p) {
+ p = transform(p);
+ return Pattern.compile(p);
+ }
+
+ public static Pattern cmpile(String p, int type) {
+ p = transformAndCheck(p);
+ return Pattern.compile(p, type);
+ }
+
+ public static Pattern cmpileNockeck(String p, int type) {
+ p = transform(p);
+ return Pattern.compile(p, type);
+ }
+
+ private static String transformAndCheck(String p) {
+ // if (p.contains("\\s")) {
+ // Thread.dumpStack();
+ // System.err.println(p);
+ // System.exit(0);
+ // }
+ // if (p.contains("'")) {
+ // Thread.dumpStack();
+ // System.err.println(p);
+ // System.exit(0);
+ // }
+ // if (p.contains("\"")) {
+ // Thread.dumpStack();
+ // System.err.println(p);
+ // System.exit(0);
+ // }
+ p = transform(p);
+ // if (p.contains(" ") || p.contains("%")) {
+ // Thread.dumpStack();
+ // System.err.println(p);
+ // System.exit(0);
+ // }
+ return p;
+ }
+
+ private static String transform(String p) {
+ // Replace ReadLineReader.java
+ p = p.replaceAll("%s", "\\\\s\u00A0"); // space
+ p = p.replaceAll("%q", "'\u2018\u2019"); // quote
+ p = p.replaceAll("%g", "\"\u201c\u201d\u00ab\u00bb"); // double quote
+ return p;
+ }
+
+ public static boolean mtches(String input, String regex) {
+ return cmpile(regex).matcher(input).matches();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/regex/RegexComposed.java b/src/net/sourceforge/plantuml/command/regex/RegexComposed.java
new file mode 100644
index 0000000..7ee181d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/regex/RegexComposed.java
@@ -0,0 +1,97 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command.regex;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public abstract class RegexComposed implements IRegex {
+
+ private final List<IRegex> partials;
+
+ abstract protected Pattern getFull();
+
+ public RegexComposed(IRegex... partial) {
+ this.partials = Arrays.asList(partial);
+ }
+
+ public Map<String, RegexPartialMatch> createPartialMatch(Iterator<String> it) {
+ final Map<String, RegexPartialMatch> result = new HashMap<String, RegexPartialMatch>();
+ for (IRegex r : partials) {
+ result.putAll(r.createPartialMatch(it));
+ }
+ return result;
+ }
+
+ final public int count() {
+ int cpt = getStartCount();
+ for (IRegex r : partials) {
+ cpt += r.count();
+ }
+ return cpt;
+ }
+
+ protected int getStartCount() {
+ return 0;
+ }
+
+ public RegexResult matcher(String s) {
+ final Matcher matcher = getFull().matcher(s);
+ if (matcher.find() == false) {
+ throw new IllegalArgumentException(getClass()+" "+s);
+ }
+
+ final Iterator<String> it = new MatcherIterator(matcher);
+ return new RegexResult(createPartialMatch(it));
+ }
+
+ final public boolean match(String s) {
+ return getFull().matcher(s).find();
+ }
+
+ final public String getPattern() {
+ return getFull().pattern();
+ }
+
+ final protected List<IRegex> getPartials() {
+ return partials;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/regex/RegexConcat.java b/src/net/sourceforge/plantuml/command/regex/RegexConcat.java
new file mode 100644
index 0000000..c122787
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/regex/RegexConcat.java
@@ -0,0 +1,57 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command.regex;
+
+import java.util.regex.Pattern;
+
+public class RegexConcat extends RegexComposed implements IRegex {
+
+ private final Pattern full;
+
+ public RegexConcat(IRegex... partial) {
+ super(partial);
+ final StringBuilder sb = new StringBuilder();
+ for (IRegex p : partial) {
+ sb.append(p.getPattern());
+ }
+ this.full = MyPattern.cmpileNockeck(sb.toString(), Pattern.CASE_INSENSITIVE);
+ }
+
+ @Override
+ protected Pattern getFull() {
+ return full;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/regex/RegexLeaf.java b/src/net/sourceforge/plantuml/command/regex/RegexLeaf.java
new file mode 100644
index 0000000..af196ff
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/regex/RegexLeaf.java
@@ -0,0 +1,85 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command.regex;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+public class RegexLeaf implements IRegex {
+
+ private final Pattern pattern;
+ private final String name;
+
+ private int count = -1;
+
+ public RegexLeaf(String regex) {
+ this(null, regex);
+ }
+
+ public RegexLeaf(String name, String regex) {
+ this.pattern = MyPattern.cmpile(regex, Pattern.CASE_INSENSITIVE);
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getPattern() {
+ return pattern.pattern();
+ }
+
+ public int count() {
+ if (count == -1) {
+ count = pattern.matcher("").groupCount();
+ }
+ return count;
+ }
+
+ public Map<String, RegexPartialMatch> createPartialMatch(Iterator<String> it) {
+ final RegexPartialMatch m = new RegexPartialMatch(name);
+ for (int i = 0; i < count(); i++) {
+ final String group = it.next();
+ m.add(group);
+ }
+ if (name == null) {
+ return Collections.emptyMap();
+ }
+ return Collections.singletonMap(name, m);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/regex/RegexOptional.java b/src/net/sourceforge/plantuml/command/regex/RegexOptional.java
new file mode 100644
index 0000000..801917f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/regex/RegexOptional.java
@@ -0,0 +1,56 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command.regex;
+
+import java.util.regex.Pattern;
+
+public class RegexOptional extends RegexComposed implements IRegex {
+
+ private final Pattern full;
+
+ public RegexOptional(IRegex partial) {
+ super(partial);
+ final StringBuilder sb = new StringBuilder("(?:");
+ sb.append(partial.getPattern());
+ sb.append(")?");
+ this.full = MyPattern.cmpileNockeck(sb.toString(), Pattern.CASE_INSENSITIVE);
+ }
+
+ @Override
+ protected Pattern getFull() {
+ return full;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/regex/RegexOr.java b/src/net/sourceforge/plantuml/command/regex/RegexOr.java
new file mode 100644
index 0000000..15fc139
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/regex/RegexOr.java
@@ -0,0 +1,88 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command.regex;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+public class RegexOr extends RegexComposed implements IRegex {
+
+ private final Pattern full;
+ private final String name;
+
+ public RegexOr(IRegex... partial) {
+ this(null, partial);
+ }
+
+ public RegexOr(String name, IRegex... partial) {
+ super(partial);
+ this.name = name;
+ final StringBuilder sb = new StringBuilder("(");
+ if (name == null) {
+ sb.append("?:");
+ }
+ for (IRegex p : partial) {
+ sb.append(p.getPattern());
+ sb.append("|");
+ }
+ sb.setLength(sb.length() - 1);
+ sb.append(')');
+ this.full = MyPattern.cmpileNockeck(sb.toString());
+ }
+
+ @Override
+ protected Pattern getFull() {
+ return full;
+ }
+
+ protected int getStartCount() {
+ return 1;
+ }
+
+ final public Map<String, RegexPartialMatch> createPartialMatch(Iterator<String> it) {
+ final Map<String, RegexPartialMatch> result = new HashMap<String, RegexPartialMatch>();
+ final String fullGroup = name == null ? null : it.next();
+ result.putAll(super.createPartialMatch(it));
+ if (name != null) {
+ final RegexPartialMatch m = new RegexPartialMatch(name);
+ m.add(fullGroup);
+ result.put(name, m);
+ }
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/regex/RegexPartialMatch.java b/src/net/sourceforge/plantuml/command/regex/RegexPartialMatch.java
new file mode 100644
index 0000000..e0a5725
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/regex/RegexPartialMatch.java
@@ -0,0 +1,71 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command.regex;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+public class RegexPartialMatch implements Iterable<String> {
+
+ private final List<String> data = new ArrayList<String>();
+
+ public RegexPartialMatch(String name) {
+
+ }
+
+ public void add(String group) {
+ data.add(group);
+ }
+
+ public int size() {
+ return data.size();
+ }
+
+ public String get(int i) {
+ return data.get(i);
+ }
+
+ public Iterator<String> iterator() {
+ return Collections.unmodifiableCollection(data).iterator();
+ }
+
+ @Override
+ public String toString() {
+ return "{" + data + "}";
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/command/regex/RegexResult.java b/src/net/sourceforge/plantuml/command/regex/RegexResult.java
new file mode 100644
index 0000000..d3b3f8a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/command/regex/RegexResult.java
@@ -0,0 +1,85 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.command.regex;
+
+import java.util.Collections;
+import java.util.Map;
+
+public class RegexResult {
+
+ private final Map<String, RegexPartialMatch> data;
+
+ public RegexResult(Map<String, RegexPartialMatch> data) {
+ this.data = Collections.unmodifiableMap(data);
+ }
+
+ @Override
+ public String toString() {
+ return data.toString();
+ }
+
+ public RegexPartialMatch get(String key) {
+ return data.get(key);
+ }
+
+ public String get(String key, int num) {
+ final RegexPartialMatch reg = data.get(key);
+ if (reg == null) {
+ return null;
+ }
+ return reg.get(num);
+ }
+
+ public String getLazzy(String key, int num) {
+ for (Map.Entry<String, RegexPartialMatch> ent : data.entrySet()) {
+ if (ent.getKey().startsWith(key) == false) {
+ continue;
+ }
+ final RegexPartialMatch match = ent.getValue();
+ if (num >= match.size()) {
+ continue;
+ }
+ if (match.get(num) != null) {
+ return ent.getValue().get(num);
+ }
+ }
+ return null;
+ }
+
+ public int size() {
+ return data.size();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/compositediagram/CompositeDiagram.java b/src/net/sourceforge/plantuml/compositediagram/CompositeDiagram.java
new file mode 100644
index 0000000..064dfe4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/compositediagram/CompositeDiagram.java
@@ -0,0 +1,62 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.compositediagram;
+
+import net.sourceforge.plantuml.UmlDiagramType;
+import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+import net.sourceforge.plantuml.graphic.USymbol;
+
+public class CompositeDiagram extends AbstractEntityDiagram {
+
+ @Override
+ public IEntity getOrCreateLeaf(Code code, LeafType type, USymbol symbol) {
+ if (type == null) {
+ if (isGroup(code)) {
+ return getGroup(code);
+ }
+ return getOrCreateLeafDefault(code, LeafType.BLOCK, symbol);
+ }
+ return getOrCreateLeafDefault(code, type, symbol);
+ }
+
+ @Override
+ public UmlDiagramType getUmlDiagramType() {
+ return UmlDiagramType.COMPOSITE;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/compositediagram/CompositeDiagramFactory.java b/src/net/sourceforge/plantuml/compositediagram/CompositeDiagramFactory.java
new file mode 100644
index 0000000..3115e93
--- /dev/null
+++ b/src/net/sourceforge/plantuml/compositediagram/CompositeDiagramFactory.java
@@ -0,0 +1,65 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.compositediagram;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.command.Command;
+import net.sourceforge.plantuml.command.UmlDiagramFactory;
+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 {
+
+ @Override
+ protected List<Command> createCommands() {
+ final List<Command> cmds = new ArrayList<Command>();
+ cmds.add(new CommandCreateBlock());
+ cmds.add(new CommandLinkBlock());
+ cmds.add(new CommandCreatePackageBlock());
+ cmds.add(new CommandEndPackageBlock());
+ addCommonCommands(cmds);
+
+ return cmds;
+ }
+
+ @Override
+ public CompositeDiagram createEmptyDiagram() {
+ return new CompositeDiagram();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/compositediagram/command/CommandCreateBlock.java b/src/net/sourceforge/plantuml/compositediagram/command/CommandCreateBlock.java
new file mode 100644
index 0000000..20a89d2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/compositediagram/command/CommandCreateBlock.java
@@ -0,0 +1,64 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.compositediagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.compositediagram.CompositeDiagram;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+
+public class CommandCreateBlock extends SingleLineCommand<CompositeDiagram> {
+
+ public CommandCreateBlock() {
+ super("(?i)^(?:block[%s]+)(?:[%g]([^%g]+)[%g][%s]+as[%s]+)?([\\p{L}0-9_.]+)$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(CompositeDiagram diagram, List<String> arg) {
+ String display = arg.get(0);
+ final Code code = Code.of(arg.get(1));
+ if (display == null) {
+ display = code.getFullName();
+ }
+ final IEntity ent = diagram.getOrCreateLeaf(code, null, null);
+ ent.setDisplay(Display.getWithNewlines(display));
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/compositediagram/command/CommandCreatePackageBlock.java b/src/net/sourceforge/plantuml/compositediagram/command/CommandCreatePackageBlock.java
new file mode 100644
index 0000000..aa0214a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/compositediagram/command/CommandCreatePackageBlock.java
@@ -0,0 +1,65 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.compositediagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.compositediagram.CompositeDiagram;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.GroupType;
+import net.sourceforge.plantuml.cucadiagram.IGroup;
+
+public class CommandCreatePackageBlock extends SingleLineCommand<CompositeDiagram> {
+
+ public CommandCreatePackageBlock() {
+ super("(?i)^block[%s]+(?:[%g]([^%g]+)[%g][%s]+as[%s]+)?([\\p{L}0-9_.]+)(?:[%s]*\\{|[%s]+begin)$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(CompositeDiagram diagram, List<String> arg) {
+ final IGroup currentPackage = diagram.getCurrentGroup();
+ String display = arg.get(0);
+ final Code code = Code.of(arg.get(1));
+ if (display == null) {
+ display = code.getFullName();
+ }
+ diagram.getOrCreateGroup(code, Display.getWithNewlines(display), GroupType.PACKAGE, currentPackage);
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/compositediagram/command/CommandEndPackageBlock.java b/src/net/sourceforge/plantuml/compositediagram/command/CommandEndPackageBlock.java
new file mode 100644
index 0000000..7fcd3af
--- /dev/null
+++ b/src/net/sourceforge/plantuml/compositediagram/command/CommandEndPackageBlock.java
@@ -0,0 +1,60 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.compositediagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.compositediagram.CompositeDiagram;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+
+public class CommandEndPackageBlock extends SingleLineCommand<CompositeDiagram> {
+
+ public CommandEndPackageBlock() {
+ super("(?i)^(end[%s]?block|\\})$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(CompositeDiagram diagram, List<String> arg) {
+ final IEntity currentPackage = diagram.getCurrentGroup();
+ if (currentPackage == null) {
+ return CommandExecutionResult.error("No inner block defined");
+ }
+ diagram.endGroup();
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/compositediagram/command/CommandLinkBlock.java b/src/net/sourceforge/plantuml/compositediagram/command/CommandLinkBlock.java
new file mode 100644
index 0000000..f492f6c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/compositediagram/command/CommandLinkBlock.java
@@ -0,0 +1,84 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.compositediagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.compositediagram.CompositeDiagram;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.cucadiagram.LinkDecor;
+import net.sourceforge.plantuml.cucadiagram.LinkType;
+
+public class CommandLinkBlock extends SingleLineCommand<CompositeDiagram> {
+
+ public CommandLinkBlock() {
+ super("(?i)^([\\p{L}0-9_.]+)[%s]*(\\[\\]|\\*\\))?([=-]+|\\.+)(\\[\\]|\\(\\*)?[%s]*([\\p{L}0-9_.]+)[%s]*(?::[%s]*(\\S*+))?$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(CompositeDiagram diagram, List<String> arg) {
+ final IEntity cl1 = diagram.getOrCreateLeaf(Code.of(arg.get(0)), null, null);
+ final IEntity cl2 = diagram.getOrCreateLeaf(Code.of(arg.get(4)), null, null);
+
+ final String deco1 = arg.get(1);
+ final String deco2 = arg.get(3);
+ LinkType linkType = new LinkType(getLinkDecor(deco1), getLinkDecor(deco2));
+
+ if ("*)".equals(deco1)) {
+ linkType = linkType.getInterfaceProvider();
+ } else if ("(*".equals(deco2)) {
+ linkType = linkType.getInterfaceUser();
+ }
+
+ final String queue = arg.get(2);
+
+ final Link link = new Link(cl1, cl2, linkType, Display.getWithNewlines(arg.get(5)), queue.length());
+ diagram.addLink(link);
+ return CommandExecutionResult.ok();
+ }
+
+ private LinkDecor getLinkDecor(String s) {
+ if ("[]".equals(s)) {
+ return LinkDecor.SQUARRE_toberemoved;
+ }
+ return LinkDecor.NONE;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/core/Diagram.java b/src/net/sourceforge/plantuml/core/Diagram.java
new file mode 100644
index 0000000..95193cf
--- /dev/null
+++ b/src/net/sourceforge/plantuml/core/Diagram.java
@@ -0,0 +1,93 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.core;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import net.sourceforge.plantuml.FileFormatOption;
+
+/**
+ * Represents a single diagram. A Diagram could be a UML (sequence diagram, class diagram...) or an non-UML diagram.
+ *
+ * @author Arnaud Roques
+ */
+public interface Diagram {
+
+ /**
+ * Export the diagram as an image to some format. Note that a diagram could be drawn as several images (think about
+ * <code>new page</code> for sequence diagram for example).
+ *
+ * @param os
+ * where to write the image
+ * @param num
+ * useually 0 (index of the image to be exported for this diagram).
+ * @param fileFormat
+ * file format to use
+ *
+ * @return a description of the generated image
+ *
+ * @throws IOException
+ */
+ ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormat) throws IOException;
+
+ /**
+ * Number of images in this diagram (usually, 1)
+ *
+ * @return usually 1
+ */
+ int getNbImages();
+
+ DiagramDescription getDescription();
+
+ String getMetadata();
+
+ String getWarningOrError();
+
+ /**
+ * The original source of the diagram
+ *
+ * @return
+ */
+ UmlSource getSource();
+
+ /**
+ * Check if the Diagram have some links.
+ *
+ * @return
+ */
+ public boolean hasUrl();
+
+}
diff --git a/src/net/sourceforge/plantuml/core/DiagramDescription.java b/src/net/sourceforge/plantuml/core/DiagramDescription.java
new file mode 100644
index 0000000..0cc6f6b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/core/DiagramDescription.java
@@ -0,0 +1,45 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.core;
+
+public interface DiagramDescription {
+
+ String getDescription();
+
+ String getCmapData();
+
+ public String getType();
+
+}
diff --git a/src/net/sourceforge/plantuml/core/DiagramDescriptionImpl.java b/src/net/sourceforge/plantuml/core/DiagramDescriptionImpl.java
new file mode 100644
index 0000000..d8715d8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/core/DiagramDescriptionImpl.java
@@ -0,0 +1,74 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.core;
+
+public class DiagramDescriptionImpl implements DiagramDescription {
+
+ private final String description;
+ private final String cmapData;
+ private final Class clazz;
+
+ public DiagramDescriptionImpl(String description, Class clazz) {
+ this(description, clazz, null);
+ }
+
+ private DiagramDescriptionImpl(String description, Class clazz, String cmapData) {
+ this.description = description;
+ this.cmapData = cmapData;
+ this.clazz = clazz;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public String getType() {
+ return clazz.getSimpleName();
+ }
+
+ public String getCmapData() {
+ return cmapData;
+ }
+
+ public DiagramDescription withCMapData(String cmapData) {
+ return new DiagramDescriptionImpl(this.description, this.clazz, cmapData);
+ }
+
+ @Override
+ public String toString() {
+ return description;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/core/DiagramType.java b/src/net/sourceforge/plantuml/core/DiagramType.java
new file mode 100644
index 0000000..73a2c57
--- /dev/null
+++ b/src/net/sourceforge/plantuml/core/DiagramType.java
@@ -0,0 +1,79 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.core;
+
+public enum DiagramType {
+ UML, DITAA, DOT, PROJECT, JCCKIT, SALT, TURING, FLOW, CREOLE, JUNGLE, CUTE, UNKNOWN;
+
+ static public DiagramType getTypeFromArobaseStart(String s) {
+// if (s.startsWith("@startuml2")) {
+// return UML2;
+// }
+ if (s.startsWith("@startuml")) {
+ return UML;
+ }
+ if (s.startsWith("@startdot")) {
+ return DOT;
+ }
+ if (s.startsWith("@startjcckit")) {
+ return JCCKIT;
+ }
+ if (s.startsWith("@startditaa")) {
+ return DITAA;
+ }
+ if (s.startsWith("@startproject")) {
+ return PROJECT;
+ }
+ if (s.startsWith("@startsalt")) {
+ return SALT;
+ }
+ if (s.startsWith("@startturing")) {
+ return TURING;
+ }
+ if (s.startsWith("@startflow")) {
+ return FLOW;
+ }
+ if (s.startsWith("@startcreole")) {
+ return CREOLE;
+ }
+ if (s.startsWith("@starttree")) {
+ return JUNGLE;
+ }
+ if (s.startsWith("@startcute")) {
+ return CUTE;
+ }
+ return UNKNOWN;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/core/ImageData.java b/src/net/sourceforge/plantuml/core/ImageData.java
new file mode 100644
index 0000000..c9ffc25
--- /dev/null
+++ b/src/net/sourceforge/plantuml/core/ImageData.java
@@ -0,0 +1,88 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.core;
+
+// Remove CmapData and Dimension2D
+// Merge CucaDiagramFileMakerResult
+/**
+ * Information about a generated image for a diagram.
+ * For some diagrams, there are some position information about elements
+ * from the diagram. In that case, the method <code>containsCMapData()</code> returns
+ * <code>true</code> and you can retrieve those information using
+ * <code>getCMapData()</code> method.
+ *
+ * @author Arnaud Roques
+ *
+ */
+public interface ImageData {
+
+ /**
+ * Width in pixel of the image.
+ * @return
+ */
+ public int getWidth();
+
+ /**
+ * Height in pixel of the image.
+ * @return
+ */
+ public int getHeight();
+
+ /**
+ * Indicates if the image has some position information.
+ * @return <code>true</code> if the image has position information.
+ */
+ public boolean containsCMapData();
+
+ /**
+ * Return position information as a CMap formated string.
+ * For example, if you call this method with <code>nameId</code>
+ * set to "foo_map", you will get something like:
+ *
+ * <code><pre>
+ * &lt;map id="foo_map" name="foo_map"&gt;
+ * &lt;area shape="rect" id="..." href="..." title="..." alt="" coords="64,68,93,148"/&gt;
+ * &lt;/map&gt;
+ * </pre></code>
+ *
+ * @param nameId thie id to be used in the cmap data string.
+ * @return
+ */
+ public String getCMapData(String nameId);
+
+ public String getWarningOrError();
+
+
+}
diff --git a/src/net/sourceforge/plantuml/core/UmlSource.java b/src/net/sourceforge/plantuml/core/UmlSource.java
new file mode 100644
index 0000000..9bbc7ea
--- /dev/null
+++ b/src/net/sourceforge/plantuml/core/UmlSource.java
@@ -0,0 +1,189 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.core;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.utils.StartUtils;
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.version.IteratorCounter;
+import net.sourceforge.plantuml.version.IteratorCounterImpl;
+
+/**
+ * Represents the textual source of some diagram.
+ * The source should start with a <code>@startfoo</code> and end with <code>@endfoo</code>.
+ * <p>
+ * So the diagram does not have to be a UML one.
+ *
+ * @author Arnaud Roques
+ *
+ */
+final public class UmlSource {
+
+ final private List<String> source;
+
+ /**
+ * Build the source from a text.
+ *
+ * @param source the source of the diagram
+ * @param checkEndingBackslash <code>true</code> if an ending backslash means that a line has
+ * to be collapsed with the following one.
+ */
+ public UmlSource(List<? extends CharSequence> source, boolean checkEndingBackslash) {
+ final List<String> tmp = new ArrayList<String>();
+ // final DiagramType type =
+ // DiagramType.getTypeFromArobaseStart(source.get(0).toString());
+ if (checkEndingBackslash) {
+ final StringBuilder pending = new StringBuilder();
+ for (CharSequence cs : source) {
+ final String s = cs.toString();
+ if (StringUtils.endsWithBackslash(s)) {
+ pending.append(s.substring(0, s.length() - 1));
+ } else {
+ pending.append(s);
+ tmp.add(pending.toString());
+ pending.setLength(0);
+ }
+ }
+ } else {
+ for (CharSequence s : source) {
+ tmp.add(s.toString());
+ }
+ }
+ this.source = Collections.unmodifiableList(tmp);
+ }
+
+
+ /**
+ * Retrieve the type of the diagram.
+ * This is based on the first line <code>@startfoo</code>.
+ *
+ * @return the type of the diagram.
+ */
+ public DiagramType getDiagramType() {
+ return DiagramType.getTypeFromArobaseStart(source.get(0));
+ }
+
+ /**
+ * Allows to iterator over the source.
+ *
+ * @return a iterator that allow counting line number.
+ */
+ public IteratorCounter iterator() {
+ return new IteratorCounterImpl(source.iterator());
+ }
+
+ /**
+ * Return the source as a single String with <code>\n</code> as line separator.
+ *
+ * @return the whole diagram source
+ */
+ public String getPlainString() {
+ final StringBuilder sb = new StringBuilder();
+ for (String s : source) {
+ sb.append(s);
+ sb.append('\r');
+ sb.append('\n');
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Return a specific line of the diagram description.
+ *
+ * @param n line number, starting at 0
+ * @return
+ */
+ public String getLine(int n) {
+ return source.get(n);
+ }
+
+ /**
+ * Return the number of line in the diagram.
+ *
+ * @return
+ */
+ public int getTotalLineCount() {
+ return source.size();
+ }
+
+ /**
+ * Check if a source diagram description is empty.
+ * Does not take comment line into account.
+ *
+ * @return <code>true<code> if the diagram does not contain information.
+ */
+ public boolean isEmpty() {
+ for (String s : source) {
+ if (StartUtils.isArobaseStartDiagram(s)) {
+ continue;
+ }
+ if (StartUtils.isArobaseEndDiagram(s)) {
+ continue;
+ }
+ if (s.matches("\\s*'.*")) {
+ continue;
+ }
+ if (s.trim().length() != 0) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Retrieve the title, if defined in the diagram source.
+ * Never return <code>null</code>.
+ * @return
+ */
+ public Display getTitle() {
+ final Pattern p = MyPattern.cmpile("(?i)^[%s]*title[%s]+(.+)$");
+ for (String s : source) {
+ final Matcher m = p.matcher(s);
+ final boolean ok = m.matches();
+ if (ok) {
+ return Display.create(m.group(1));
+ }
+ }
+ return Display.empty();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/creole/Atom.java b/src/net/sourceforge/plantuml/creole/Atom.java
new file mode 100644
index 0000000..8a5ea86
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/Atom.java
@@ -0,0 +1,51 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+interface Atom extends UShape {
+
+ public Dimension2D calculateDimension(StringBounder stringBounder);
+
+ public double getStartingAltitude(StringBounder stringBounder);
+
+ public void drawU(UGraphic ug);
+
+}
diff --git a/src/net/sourceforge/plantuml/creole/AtomEmbededSystem.java b/src/net/sourceforge/plantuml/creole/AtomEmbededSystem.java
new file mode 100644
index 0000000..83dcfa7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/AtomEmbededSystem.java
@@ -0,0 +1,114 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.awt.geom.Dimension2D;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.List;
+
+import javax.imageio.ImageIO;
+
+import net.sourceforge.plantuml.BlockUml;
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.EmbededDiagram;
+import net.sourceforge.plantuml.FileFormat;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.core.Diagram;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UImage;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+class AtomEmbededSystem implements Atom {
+
+ final private List<? extends CharSequence> lines;
+
+ public AtomEmbededSystem(EmbededDiagram sys) {
+ this.lines = sys.getLines().as();
+ }
+
+ public double getStartingAltitude(StringBounder stringBounder) {
+ return 0;
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ try {
+ final BufferedImage im = getImage();
+ return new Dimension2DDouble(im.getWidth(), im.getHeight());
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ return new Dimension2DDouble(42, 42);
+ }
+
+ public void drawU(UGraphic ug) {
+ try {
+ final BufferedImage im = getImage();
+ final UShape image = new UImage(im);
+ ug.draw(image);
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ private BufferedImage getImage() throws IOException, InterruptedException {
+ final Diagram system = getSystem();
+ final ByteArrayOutputStream os = new ByteArrayOutputStream();
+ system.exportDiagram(os, 0, new FileFormatOption(FileFormat.PNG));
+ os.close();
+ final ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray());
+ final BufferedImage im = ImageIO.read(is);
+ is.close();
+ return im;
+ }
+
+ // public HorizontalAlignment getHorizontalAlignment() {
+ // return HorizontalAlignment.LEFT;
+ // }
+ //
+ private Diagram getSystem() throws IOException, InterruptedException {
+ final BlockUml blockUml = new BlockUml(lines, 0);
+ return blockUml.getDiagram();
+
+ }
+}
diff --git a/src/net/sourceforge/plantuml/creole/AtomImg.java b/src/net/sourceforge/plantuml/creole/AtomImg.java
new file mode 100644
index 0000000..4e7c255
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/AtomImg.java
@@ -0,0 +1,137 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.awt.Font;
+import java.awt.geom.Dimension2D;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLConnection;
+
+import javax.imageio.ImageIO;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.FileSystem;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.ImgValign;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UImage;
+
+public class AtomImg implements Atom {
+
+ private final BufferedImage image;
+
+ private AtomImg(BufferedImage image) {
+ this.image = image;
+ }
+
+ public static Atom create(String src, final ImgValign valign, final int vspace) {
+ final UFont font = new UFont("Monospaced", Font.PLAIN, 14);
+ final FontConfiguration fc = new FontConfiguration(font, HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true);
+ try {
+ final File f = FileSystem.getInstance().getFile(src);
+ if (f.exists() == false) {
+ // Check if valid URL
+ if (src.startsWith("http:") || src.startsWith("https:")) {
+ final byte image[] = getFile(src);
+ final BufferedImage read = ImageIO.read(new ByteArrayInputStream(image));
+ if (read == null) {
+ return AtomText.create("(Cannot decode: " + src + ")", fc);
+ }
+ return new AtomImg(read);
+ }
+ return AtomText.create("(File not found: " + f + ")", fc);
+ }
+ if (f.getName().endsWith(".svg")) {
+ // return new AtomImg(new TileImageSvg(f));
+ throw new UnsupportedOperationException();
+ }
+ final BufferedImage read = ImageIO.read(f);
+ if (read == null) {
+ return AtomText.create("(Cannot decode: " + f + ")", fc);
+ }
+ return new AtomImg(ImageIO.read(f));
+ } catch (IOException e) {
+ return AtomText.create("ERROR " + e.toString(), fc);
+ }
+ }
+
+ // Added by Alain Corbiere
+ static byte[] getFile(String host) throws IOException {
+ final ByteArrayOutputStream image = new ByteArrayOutputStream();
+ InputStream input = null;
+ try {
+ final URL url = new URL(host);
+ final URLConnection connection = url.openConnection();
+ input = connection.getInputStream();
+ final byte[] buffer = new byte[1024];
+ int read;
+ while ((read = input.read(buffer)) > 0) {
+ image.write(buffer, 0, read);
+ }
+ image.close();
+ return image.toByteArray();
+ } finally {
+ if (input != null) {
+ input.close();
+ }
+ }
+ }
+
+ // End
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(image.getWidth(), image.getHeight());
+ }
+
+ public double getStartingAltitude(StringBounder stringBounder) {
+ return 0;
+ }
+
+ public void drawU(UGraphic ug) {
+ // final double h = calculateDimension(ug.getStringBounder()).getHeight();
+ ug.draw(new UImage(image));
+ // tileImage.drawU(ug.apply(new UTranslate(0, -h)));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/creole/AtomOpenIcon.java b/src/net/sourceforge/plantuml/creole/AtomOpenIcon.java
new file mode 100644
index 0000000..5c56544
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/AtomOpenIcon.java
@@ -0,0 +1,74 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.openiconic.OpenIcon;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class AtomOpenIcon implements Atom {
+
+ private final OpenIcon openIcon;
+ private final FontConfiguration fontConfiguration;
+ private final double factor;
+
+ public AtomOpenIcon(OpenIcon openIcon, FontConfiguration fontConfiguration) {
+ this.openIcon = openIcon;
+ this.fontConfiguration = fontConfiguration;
+ this.factor = fontConfiguration.getSize2D() / 12;
+ }
+
+ private TextBlock asTextBlock() {
+ return TextBlockUtils.withMargin(openIcon.asTextBlock(fontConfiguration.getColor(), factor), 1, 0);
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return asTextBlock().calculateDimension(stringBounder);
+ }
+
+ public double getStartingAltitude(StringBounder stringBounder) {
+ return -3 * factor;
+ }
+
+ public void drawU(UGraphic ug) {
+ asTextBlock().drawU(ug);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/creole/AtomSpace.java b/src/net/sourceforge/plantuml/creole/AtomSpace.java
new file mode 100644
index 0000000..76bb1bc
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/AtomSpace.java
@@ -0,0 +1,66 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class AtomSpace implements Atom {
+
+ private final double width;
+
+ public static Atom create(double width) {
+ return new AtomSpace(width);
+ }
+
+ private AtomSpace(double width) {
+ this.width = width;
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(width, 1);
+ }
+
+ public double getStartingAltitude(StringBounder stringBounder) {
+ return 0;
+ }
+
+ public void drawU(UGraphic ug) {
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/creole/AtomSprite.java b/src/net/sourceforge/plantuml/creole/AtomSprite.java
new file mode 100644
index 0000000..a8c2df2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/AtomSprite.java
@@ -0,0 +1,66 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class AtomSprite implements Atom {
+
+ private final TextBlock sprite;
+ private final FontConfiguration fontConfiguration;
+
+ public AtomSprite(TextBlock sprite, FontConfiguration fontConfiguration) {
+ this.sprite = sprite;
+ this.fontConfiguration = fontConfiguration;
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return sprite.calculateDimension(stringBounder);
+ }
+
+ public double getStartingAltitude(StringBounder stringBounder) {
+ return -3;
+ }
+
+ public void drawU(UGraphic ug) {
+ sprite.drawU(ug);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/creole/AtomTable.java b/src/net/sourceforge/plantuml/creole/AtomTable.java
new file mode 100644
index 0000000..468b7e8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/AtomTable.java
@@ -0,0 +1,209 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.awt.geom.Dimension2D;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class AtomTable implements Atom {
+
+ class Line {
+ private final List<Atom> cells = new ArrayList<Atom>();
+
+ public void add(Atom cell) {
+ cells.add(cell);
+ }
+
+ public int size() {
+ return cells.size();
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + " " + cells.size();
+ }
+ }
+
+ private final List<Line> lines = new ArrayList<Line>();
+ private final Map<Atom, Position> positions = new HashMap<Atom, Position>();
+ private final HtmlColor lineColor;
+
+ public AtomTable(HtmlColor lineColor) {
+ this.lineColor = lineColor;
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ initMap(stringBounder);
+ final double width = getEndingX(getNbCols() - 1);
+ final double height = getEndingY(getNbLines() - 1);
+ return new Dimension2DDouble(width, height);
+ }
+
+ public double getStartingAltitude(StringBounder stringBounder) {
+ return 0;
+ }
+
+ public void drawU(UGraphic ug) {
+ initMap(ug.getStringBounder());
+ for (Line line : lines) {
+ for (Atom cell : line.cells) {
+ final Position pos = positions.get(cell);
+ cell.drawU(ug.apply(pos.getTranslate()));
+ }
+ }
+ ug = ug.apply(new UChangeColor(lineColor));
+ final ULine hline = new ULine(getEndingX(getNbCols() - 1), 0);
+ for (int i = 0; i <= getNbLines(); i++) {
+ ug.apply(new UTranslate(0, getStartingY(i))).draw(hline);
+ }
+ final ULine vline = new ULine(0, getEndingY(getNbLines() - 1));
+ for (int i = 0; i <= getNbCols(); i++) {
+ ug.apply(new UTranslate(getStartingX(i), 0)).draw(vline);
+ }
+
+ }
+
+ private void initMap(StringBounder stringBounder) {
+ if (positions.size() > 0) {
+ return;
+ }
+ for (Line line : lines) {
+ for (Atom cell : line.cells) {
+ final Dimension2D dim = cell.calculateDimension(stringBounder);
+ final Position pos = new Position(0, 0, dim);
+ positions.put(cell, pos);
+ }
+ }
+ for (int i = 0; i < lines.size(); i++) {
+ for (int j = 0; j < lines.get(i).size(); j++) {
+ final Atom cell = lines.get(i).cells.get(j);
+ final Dimension2D dim = cell.calculateDimension(stringBounder);
+ final double x = getStartingX(j);
+ final double y = getStartingY(i);
+ final Position pos = new Position(x, y, dim);
+ positions.put(cell, pos);
+ }
+ }
+ }
+
+ private double getStartingX(int col) {
+ double result = 0;
+ for (int i = 0; i < col; i++) {
+ result += getColWidth(i);
+ }
+ return result;
+ }
+
+ private double getEndingX(int col) {
+ double result = 0;
+ for (int i = 0; i <= col; i++) {
+ result += getColWidth(i);
+ }
+ return result;
+ }
+
+ private double getStartingY(int line) {
+ double result = 0;
+ for (int i = 0; i < line; i++) {
+ result += getLineHeight(i);
+ }
+ return result;
+ }
+
+ private double getEndingY(int line) {
+ double result = 0;
+ for (int i = 0; i <= line; i++) {
+ result += getLineHeight(i);
+ }
+ return result;
+ }
+
+ private double getColWidth(int col) {
+ double result = 0;
+ for (int i = 0; i < getNbLines(); i++) {
+ final double width = getPosition(i, col).getWidth();
+ result = Math.max(result, width);
+ }
+ return result;
+ }
+
+ private double getLineHeight(int line) {
+ double result = 0;
+ for (int i = 0; i < getNbCols(); i++) {
+ final double height = getPosition(line, i).getHeight();
+ result = Math.max(result, height);
+ }
+ return result;
+ }
+
+ private Position getPosition(int line, int col) {
+ final Line l = lines.get(line);
+ final Atom atom = l.cells.get(col);
+ return positions.get(atom);
+ }
+
+ private int getNbCols() {
+ return lines.get(0).size();
+ }
+
+ private int getNbLines() {
+ return lines.size();
+ }
+
+ private Line lastLine() {
+ return lines.get(lines.size() - 1);
+ }
+
+ public void addCell(Atom cell) {
+ lastLine().add(cell);
+ positions.clear();
+ }
+
+ public void newLine() {
+ lines.add(new Line());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/creole/AtomText.java b/src/net/sourceforge/plantuml/creole/AtomText.java
new file mode 100644
index 0000000..02c998f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/AtomText.java
@@ -0,0 +1,250 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.awt.font.LineMetrics;
+import java.awt.geom.Dimension2D;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.Log;
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UText;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+import net.sourceforge.plantuml.utils.CharHidder;
+
+public class AtomText implements Atom {
+
+ interface DelayedDouble {
+ public double getDouble(StringBounder stringBounder);
+ }
+
+ private static DelayedDouble ZERO = new DelayedDouble() {
+ public double getDouble(StringBounder stringBounder) {
+ return 0;
+ }
+ };
+
+ private final FontConfiguration fontConfiguration;
+ private final String text;
+ private final DelayedDouble marginLeft;
+ private final DelayedDouble marginRight;
+ private final Url url;
+
+ public static Atom create(String text, FontConfiguration fontConfiguration) {
+ return new AtomText(text, fontConfiguration, null, ZERO, ZERO);
+ }
+
+ public static Atom createUrl(Url url, FontConfiguration fontConfiguration) {
+ fontConfiguration = fontConfiguration.hyperlink();
+ return new AtomText(url.getLabel(), fontConfiguration, url, ZERO, ZERO);
+ }
+
+ public static AtomText createHeading(String text, FontConfiguration fontConfiguration, int order) {
+ if (order == 0) {
+ fontConfiguration = fontConfiguration.bigger(4).bold();
+ } else if (order == 1) {
+ fontConfiguration = fontConfiguration.bigger(2).bold();
+ } else if (order == 2) {
+ fontConfiguration = fontConfiguration.bigger(1).bold();
+ } else {
+ fontConfiguration = fontConfiguration.italic();
+ }
+ return new AtomText(text, fontConfiguration, null, ZERO, ZERO);
+ }
+
+ public static Atom createListNumber(final FontConfiguration fontConfiguration, final int order, int localNumber) {
+ final DelayedDouble left = new DelayedDouble() {
+ public double getDouble(StringBounder stringBounder) {
+ final Dimension2D dim = stringBounder.calculateDimension(fontConfiguration.getFont(), "9. ");
+ return dim.getWidth() * order;
+ }
+ };
+ final DelayedDouble right = new DelayedDouble() {
+ public double getDouble(StringBounder stringBounder) {
+ final Dimension2D dim = stringBounder.calculateDimension(fontConfiguration.getFont(), ".");
+ return dim.getWidth();
+ }
+ };
+ return new AtomText("" + (localNumber + 1) + ".", fontConfiguration, null, left, right);
+ }
+
+ @Override
+ public String toString() {
+ return text + " " + fontConfiguration;
+ }
+
+ private AtomText(String text, FontConfiguration style, Url url, DelayedDouble marginLeft, DelayedDouble marginRight) {
+ this.marginLeft = marginLeft;
+ this.marginRight = marginRight;
+ //this.text = StringUtils.showComparatorCharacters(StringUtils.manageBackslash(text));
+ this.text = StringUtils.showComparatorCharacters(CharHidder.unhide(text));
+ this.fontConfiguration = style;
+ this.url = url;
+ }
+
+ public FontConfiguration getFontConfiguration() {
+ return fontConfiguration;
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D rect = stringBounder.calculateDimension(fontConfiguration.getFont(), text);
+ Log.debug("g2d=" + rect);
+ Log.debug("Size for " + text + " is " + rect);
+ double h = rect.getHeight();
+ if (h < 10) {
+ h = 10;
+ }
+ final double width = text.indexOf('\t') == -1 ? rect.getWidth() : getWidth(stringBounder);
+ final double left = marginLeft.getDouble(stringBounder);
+ final double right = marginRight.getDouble(stringBounder);
+
+ return new Dimension2DDouble(width + left + right, h);
+ }
+
+ private double getDescent() {
+ final LineMetrics fm = TextBlockUtils.getLineMetrics(fontConfiguration.getFont(), text);
+ final double descent = fm.getDescent();
+ return descent;
+ }
+
+ public double getFontSize2D() {
+ return fontConfiguration.getFont().getSize2D();
+ }
+
+ public double getStartingAltitude(StringBounder stringBounder) {
+ return fontConfiguration.getSpace();
+ }
+
+ private double getTabSize(StringBounder stringBounder) {
+ return stringBounder.calculateDimension(fontConfiguration.getFont(), " ").getWidth();
+ }
+
+ public void drawU(UGraphic ug) {
+ if (ug.isSpecialTxt()) {
+ ug.draw(this);
+ return;
+ }
+ if (url != null) {
+ ug.startUrl(url);
+ }
+ ug = ug.apply(new UChangeColor(fontConfiguration.getColor()));
+ if (marginLeft != ZERO) {
+ ug = ug.apply(new UTranslate(marginLeft.getDouble(ug.getStringBounder()), 0));
+ }
+
+ final StringTokenizer tokenizer = new StringTokenizer(text, "\t", true);
+
+ double x = 0;
+ // final int ypos = fontConfiguration.getSpace();
+ final Dimension2D rect = ug.getStringBounder().calculateDimension(fontConfiguration.getFont(), text);
+ final double descent = getDescent();
+ final double ypos = rect.getHeight() - descent;
+ if (tokenizer.hasMoreTokens()) {
+ final double tabSize = getTabSize(ug.getStringBounder());
+ while (tokenizer.hasMoreTokens()) {
+ final String s = tokenizer.nextToken();
+ if (s.equals("\t")) {
+ final double remainder = x % tabSize;
+ x += tabSize - remainder;
+ } else {
+ final UText utext = new UText(s, fontConfiguration);
+ final Dimension2D dim = ug.getStringBounder().calculateDimension(fontConfiguration.getFont(), s);
+ ug.apply(new UTranslate(x, ypos)).draw(utext);
+ x += dim.getWidth();
+ }
+ }
+ }
+ if (url != null) {
+ ug.closeAction();
+ }
+ }
+
+ private double getWidth(StringBounder stringBounder) {
+ return getWidth(stringBounder, text);
+ }
+
+ private double getWidth(StringBounder stringBounder, String text) {
+ final StringTokenizer tokenizer = new StringTokenizer(text, "\t", true);
+ final double tabSize = getTabSize(stringBounder);
+ double x = 0;
+ while (tokenizer.hasMoreTokens()) {
+ final String s = tokenizer.nextToken();
+ if (s.equals("\t")) {
+ final double remainder = x % tabSize;
+ x += tabSize - remainder;
+ } else {
+ final Dimension2D dim = stringBounder.calculateDimension(fontConfiguration.getFont(), s);
+ x += dim.getWidth();
+ }
+ }
+ return x;
+ }
+
+ public List<AtomText> getSplitted(StringBounder stringBounder, double maxWidth) {
+ final List<AtomText> result = new ArrayList<AtomText>();
+ final StringTokenizer st = new StringTokenizer(text, " ", true);
+ final StringBuilder currentLine = new StringBuilder();
+ while (st.hasMoreTokens()) {
+ final String token = st.nextToken();
+ final double w = getWidth(stringBounder, currentLine + token);
+ if (w > maxWidth) {
+ result.add(new AtomText(currentLine.toString(), fontConfiguration, url, marginLeft, marginRight));
+ currentLine.setLength(0);
+ if (token.startsWith(" ") == false) {
+ currentLine.append(token);
+ }
+ } else {
+ currentLine.append(token);
+ }
+ }
+ result.add(new AtomText(currentLine.toString(), fontConfiguration, url, marginLeft, marginRight));
+ return Collections.unmodifiableList(result);
+
+ }
+
+ public final String getText() {
+ return text;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/creole/AtomWithMargin.java b/src/net/sourceforge/plantuml/creole/AtomWithMargin.java
new file mode 100644
index 0000000..9e4180f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/AtomWithMargin.java
@@ -0,0 +1,68 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class AtomWithMargin implements Atom {
+
+ private final double marginY1;
+ private final double marginY2;
+ private final Atom atom;
+
+ public AtomWithMargin(Atom atom, double marginY1, double marginY2) {
+ this.atom = atom;
+ this.marginY1 = marginY1;
+ this.marginY2 = marginY2;
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return Dimension2DDouble.delta(atom.calculateDimension(stringBounder), 0, marginY1 + marginY2);
+ }
+
+ public double getStartingAltitude(StringBounder stringBounder) {
+ return atom.getStartingAltitude(stringBounder);
+ }
+
+ public void drawU(UGraphic ug) {
+ atom.drawU(ug.apply(new UTranslate(0, marginY1)));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/creole/Bullet.java b/src/net/sourceforge/plantuml/creole/Bullet.java
new file mode 100644
index 0000000..76720f6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/Bullet.java
@@ -0,0 +1,110 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class Bullet implements Atom {
+
+ private final FontConfiguration fontConfiguration;
+ private final int order;
+
+ public Bullet(FontConfiguration fontConfiguration, int order) {
+ this.fontConfiguration = fontConfiguration;
+ this.order = order;
+ }
+
+ private double getWidth(StringBounder stringBounder) {
+ final Dimension2D dim = stringBounder.calculateDimension(fontConfiguration.getFont(), "W");
+ return dim.getWidth() * (order + 1);
+ }
+
+ public void drawU(UGraphic ug) {
+ if (order == 0) {
+ drawU0(ug);
+ } else {
+ drawU1(ug);
+ }
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ if (order == 0) {
+ return calculateDimension0(stringBounder);
+ }
+ return calculateDimension1(stringBounder);
+ }
+
+ private void drawU0(UGraphic ug) {
+ final HtmlColor color = fontConfiguration.getColor();
+ ug = ug.apply(new UChangeColor(color)).apply(new UChangeBackColor(color)).apply(new UStroke(0));
+ // final double width = getWidth(ug.getStringBounder());
+ ug = ug.apply(new UTranslate(3, 0));
+ ug.draw(new UEllipse(5, 5));
+ }
+
+ public double getStartingAltitude(StringBounder stringBounder) {
+ return -5;
+ }
+
+ private Dimension2D calculateDimension0(StringBounder stringBounder) {
+ return new Dimension2DDouble(getWidth(stringBounder), 5);
+ }
+
+ private void drawU1(UGraphic ug) {
+ final HtmlColor color = fontConfiguration.getColor();
+ ug = ug.apply(new UChangeColor(color)).apply(new UChangeBackColor(color)).apply(new UStroke(0));
+ final double width = getWidth(ug.getStringBounder());
+ ug = ug.apply(new UTranslate(width - 5, 0));
+ ug.draw(new URectangle(3.5, 3.5));
+ }
+
+ private Dimension2D calculateDimension1(StringBounder stringBounder) {
+ return new Dimension2DDouble(getWidth(stringBounder), 3);
+ }
+
+
+}
diff --git a/src/net/sourceforge/plantuml/creole/Command.java b/src/net/sourceforge/plantuml/creole/Command.java
new file mode 100644
index 0000000..f5e260d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/Command.java
@@ -0,0 +1,42 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.creole;
+
+public interface Command {
+
+ public int matchingSize(String line);
+
+ public String executeAndGetRemaining(String line, StripeSimple stripe);
+}
diff --git a/src/net/sourceforge/plantuml/creole/CommandCreoleColorAndSizeChange.java b/src/net/sourceforge/plantuml/creole/CommandCreoleColorAndSizeChange.java
new file mode 100644
index 0000000..27c824a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/CommandCreoleColorAndSizeChange.java
@@ -0,0 +1,96 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorSet;
+
+public class CommandCreoleColorAndSizeChange implements Command {
+
+ private final Pattern pattern;
+
+ public static final String fontPattern = "\\<font(?:[%s]+size[%s]*=[%s]*[%g]?(\\d+)[%g]?|[%s]+color[%s]*=[%s]*[%g]?(#[0-9a-fA-F]{6}|\\w+)[%g]?)+[%s]*\\>";
+
+ public static Command create() {
+ return new CommandCreoleColorAndSizeChange("^(?i)(" + fontPattern + "(.*?)\\</font\\>)");
+ }
+
+ public static Command createEol() {
+ return new CommandCreoleColorAndSizeChange("^(?i)(" + fontPattern + "(.*))$");
+ }
+
+ private CommandCreoleColorAndSizeChange(String p) {
+ this.pattern = MyPattern.cmpile(p);
+
+ }
+
+ public int matchingSize(String line) {
+ final Matcher m = pattern.matcher(line);
+ if (m.find() == false) {
+ return 0;
+ }
+ return m.group(1).length();
+ }
+
+ public String executeAndGetRemaining(String line, StripeSimple stripe) {
+ final Matcher m = pattern.matcher(line);
+ if (m.find() == false) {
+ throw new IllegalStateException();
+ }
+ // for (int i = 1; i <= m.groupCount(); i++) {
+ // System.err.println("i=" + i + " " + m.group(i));
+ // }
+
+ final FontConfiguration fc1 = stripe.getActualFontConfiguration();
+ FontConfiguration fc2 = fc1;
+ if (m.group(2) != null) {
+ fc2 = fc2.changeSize(Integer.parseInt(m.group(2)));
+ }
+ if (m.group(3) != null) {
+ final HtmlColor color = HtmlColorSet.getInstance().getColorIfValid(m.group(3));
+ fc2 = fc2.changeColor(color);
+ }
+
+ stripe.setActualFontConfiguration(fc2);
+ stripe.analyzeAndAdd(m.group(4));
+ stripe.setActualFontConfiguration(fc1);
+ return line.substring(m.group(1).length());
+ }
+}
diff --git a/src/net/sourceforge/plantuml/creole/CommandCreoleColorChange.java b/src/net/sourceforge/plantuml/creole/CommandCreoleColorChange.java
new file mode 100644
index 0000000..106ce4e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/CommandCreoleColorChange.java
@@ -0,0 +1,85 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorSet;
+import net.sourceforge.plantuml.graphic.Splitter;
+
+public class CommandCreoleColorChange implements Command {
+
+ private final Pattern pattern;
+
+ public static Command create() {
+ return new CommandCreoleColorChange("^(?i)(" + Splitter.fontColorPattern2 + "(.*?)\\</color\\>)");
+ }
+
+ public static Command createEol() {
+ return new CommandCreoleColorChange("^(?i)(" + Splitter.fontColorPattern2 + "(.*)$)");
+ }
+
+ private CommandCreoleColorChange(String p) {
+ this.pattern = MyPattern.cmpile(p);
+
+ }
+
+ public int matchingSize(String line) {
+ final Matcher m = pattern.matcher(line);
+ if (m.find() == false) {
+ return 0;
+ }
+ return m.group(2).length();
+ }
+
+ public String executeAndGetRemaining(String line, StripeSimple stripe) {
+ final Matcher m = pattern.matcher(line);
+ if (m.find() == false) {
+ throw new IllegalStateException();
+ }
+ final FontConfiguration fc1 = stripe.getActualFontConfiguration();
+ final HtmlColor color = HtmlColorSet.getInstance().getColorIfValid(m.group(2));
+ final FontConfiguration fc2 = fc1.changeColor(color);
+ stripe.setActualFontConfiguration(fc2);
+ stripe.analyzeAndAdd(m.group(3));
+ stripe.setActualFontConfiguration(fc1);
+ return line.substring(m.group(1).length());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/creole/CommandCreoleExposantChange.java b/src/net/sourceforge/plantuml/creole/CommandCreoleExposantChange.java
new file mode 100644
index 0000000..c221c4b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/CommandCreoleExposantChange.java
@@ -0,0 +1,85 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.FontPosition;
+
+public class CommandCreoleExposantChange implements Command {
+
+ private final Pattern pattern;
+ private final FontPosition position;
+
+ private CommandCreoleExposantChange(String p, FontPosition position) {
+ this.pattern = MyPattern.cmpile(p);
+ this.position = position;
+ }
+
+ public static Command create(FontPosition position) {
+ return new CommandCreoleExposantChange("^(?i)(" + "\\<" + position.getHtmlTag() + "\\>" + "(.*?)\\</"
+ + position.getHtmlTag() + "\\>)", position);
+ }
+
+ // public static Command createLegacyEol(FontStyle style) {
+ // return new CommandCreoleExposantChange("^(" + style.getActivationPattern() + "(.+))$", style);
+ // }
+
+ public int matchingSize(String line) {
+ final Matcher m = pattern.matcher(line);
+ if (m.find() == false) {
+ return 0;
+ }
+ return m.group(2).length();
+ }
+
+ public String executeAndGetRemaining(String line, StripeSimple stripe) {
+ final Matcher m = pattern.matcher(line);
+ if (m.find() == false) {
+ throw new IllegalStateException();
+ }
+ final FontConfiguration fc1 = stripe.getActualFontConfiguration();
+ final FontConfiguration fc2 = fc1.changeFontPosition(position);
+
+ stripe.setActualFontConfiguration(fc2);
+ stripe.analyzeAndAdd(m.group(2));
+ stripe.setActualFontConfiguration(fc1);
+ return line.substring(m.group(1).length());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/creole/CommandCreoleFontFamilyChange.java b/src/net/sourceforge/plantuml/creole/CommandCreoleFontFamilyChange.java
new file mode 100644
index 0000000..f633351
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/CommandCreoleFontFamilyChange.java
@@ -0,0 +1,83 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.Splitter;
+
+public class CommandCreoleFontFamilyChange implements Command {
+
+ private final Pattern pattern;
+
+ public static Command create() {
+ return new CommandCreoleFontFamilyChange("^(?i)(" + Splitter.fontFamilyPattern + "(.*?)\\</font\\>)");
+ }
+
+ public static Command createEol() {
+ return new CommandCreoleFontFamilyChange("^(?i)(" + Splitter.fontFamilyPattern + "(.*)$)");
+ }
+
+ private CommandCreoleFontFamilyChange(String p) {
+ this.pattern = MyPattern.cmpile(p);
+
+ }
+
+ public int matchingSize(String line) {
+ final Matcher m = pattern.matcher(line);
+ if (m.find() == false) {
+ return 0;
+ }
+ return m.group(1).length();
+ }
+
+ public String executeAndGetRemaining(String line, StripeSimple stripe) {
+ final Matcher m = pattern.matcher(line);
+ if (m.find() == false) {
+ throw new IllegalStateException();
+ }
+ final FontConfiguration fc1 = stripe.getActualFontConfiguration();
+ final String family = m.group(2);
+ final FontConfiguration fc2 = fc1.changeFamily(family);
+ stripe.setActualFontConfiguration(fc2);
+ stripe.analyzeAndAdd(m.group(3));
+ stripe.setActualFontConfiguration(fc1);
+ return line.substring(m.group(1).length());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/creole/CommandCreoleImg.java b/src/net/sourceforge/plantuml/creole/CommandCreoleImg.java
new file mode 100644
index 0000000..c901bdc
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/CommandCreoleImg.java
@@ -0,0 +1,79 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.graphic.Splitter;
+
+public class CommandCreoleImg implements Command {
+
+ private final Pattern pattern;
+
+ private CommandCreoleImg(String p) {
+ this.pattern = MyPattern.cmpile(p);
+ }
+
+ public static Command create() {
+ return new CommandCreoleImg("^(?i)(" + Splitter.imgPatternNoSrcColon + ")");
+ }
+
+ public int matchingSize(String line) {
+ final Matcher m = pattern.matcher(line);
+ if (m.find() == false) {
+ return 0;
+ }
+ return m.group(1).length();
+ }
+
+ public String executeAndGetRemaining(String line, StripeSimple stripe) {
+ final Matcher m = pattern.matcher(line);
+ if (m.find() == false) {
+ throw new IllegalStateException();
+ }
+ // final int size = Integer.parseInt(m.group(2));
+ // final FontConfiguration fc1 = stripe.getActualFontConfiguration();
+ // final FontConfiguration fc2 = fc1.changeSize(size);
+ // stripe.setActualFontConfiguration(fc2);
+ // stripe.analyzeAndAdd(m.group(3));
+ final String src = m.group(2);
+ stripe.addImage(src);
+ // stripe.setActualFontConfiguration(fc1);
+ return line.substring(m.group(1).length());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/creole/CommandCreoleMonospaced.java b/src/net/sourceforge/plantuml/creole/CommandCreoleMonospaced.java
new file mode 100644
index 0000000..4c0b235
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/CommandCreoleMonospaced.java
@@ -0,0 +1,76 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+
+public class CommandCreoleMonospaced implements Command {
+
+ private final Pattern pattern;
+
+ public static Command create() {
+ return new CommandCreoleMonospaced("^(?i)([%g][%g](.*?)[%g][%g])");
+ }
+
+ private CommandCreoleMonospaced(String p) {
+ this.pattern = MyPattern.cmpile(p);
+ }
+
+ public int matchingSize(String line) {
+ final Matcher m = pattern.matcher(line);
+ if (m.find() == false) {
+ return 0;
+ }
+ return m.group(1).length();
+ }
+
+ public String executeAndGetRemaining(String line, StripeSimple stripe) {
+ final Matcher m = pattern.matcher(line);
+ if (m.find() == false) {
+ throw new IllegalStateException();
+ }
+ final FontConfiguration fc1 = stripe.getActualFontConfiguration();
+ final FontConfiguration fc2 = fc1.changeFamily("monospaced");
+ stripe.setActualFontConfiguration(fc2);
+ stripe.analyzeAndAdd(m.group(2));
+ stripe.setActualFontConfiguration(fc1);
+ return line.substring(m.group(1).length());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/creole/CommandCreoleOpenIcon.java b/src/net/sourceforge/plantuml/creole/CommandCreoleOpenIcon.java
new file mode 100644
index 0000000..e27af9a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/CommandCreoleOpenIcon.java
@@ -0,0 +1,73 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.graphic.Splitter;
+
+public class CommandCreoleOpenIcon implements Command {
+
+ private final Pattern pattern;
+
+ private CommandCreoleOpenIcon(String p) {
+ this.pattern = MyPattern.cmpile(p);
+ }
+
+ public static Command create() {
+ return new CommandCreoleOpenIcon("^(?i)(" + Splitter.openiconPattern + ")");
+ }
+
+ public int matchingSize(String line) {
+ final Matcher m = pattern.matcher(line);
+ if (m.find() == false) {
+ return 0;
+ }
+ return m.group(1).length();
+ }
+
+ public String executeAndGetRemaining(String line, StripeSimple stripe) {
+ final Matcher m = pattern.matcher(line);
+ if (m.find() == false) {
+ throw new IllegalStateException();
+ }
+ final String src = m.group(2);
+ stripe.addOpenIcon(src);
+ return line.substring(m.group(1).length());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/creole/CommandCreoleSizeChange.java b/src/net/sourceforge/plantuml/creole/CommandCreoleSizeChange.java
new file mode 100644
index 0000000..7dadfaa
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/CommandCreoleSizeChange.java
@@ -0,0 +1,84 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.Splitter;
+
+public class CommandCreoleSizeChange implements Command {
+
+ private final Pattern pattern;
+
+ public static Command create() {
+ return new CommandCreoleSizeChange("^(?i)(" + Splitter.fontSizePattern2 + "(.*?)\\</size\\>)");
+ }
+
+ public static Command createEol() {
+ return new CommandCreoleSizeChange("^(?i)(" + Splitter.fontSizePattern2 + "(.*)$)");
+ }
+
+ private CommandCreoleSizeChange(String p) {
+ this.pattern = MyPattern.cmpile(p);
+
+ }
+
+ public int matchingSize(String line) {
+ final Matcher m = pattern.matcher(line);
+ if (m.find() == false) {
+ return 0;
+ }
+ return m.group(2).length();
+ }
+
+ public String executeAndGetRemaining(String line, StripeSimple stripe) {
+ final Matcher m = pattern.matcher(line);
+ if (m.find() == false) {
+ throw new IllegalStateException();
+ }
+ final int size = Integer.parseInt(m.group(2));
+ final FontConfiguration fc1 = stripe.getActualFontConfiguration();
+ final FontConfiguration fc2 = fc1.changeSize(size);
+ // final FontConfiguration fc2 = new AddStyle(style, null).apply(fc1);
+ stripe.setActualFontConfiguration(fc2);
+ stripe.analyzeAndAdd(m.group(3));
+ stripe.setActualFontConfiguration(fc1);
+ return line.substring(m.group(1).length());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/creole/CommandCreoleSpace.java b/src/net/sourceforge/plantuml/creole/CommandCreoleSpace.java
new file mode 100644
index 0000000..261e6ef
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/CommandCreoleSpace.java
@@ -0,0 +1,78 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+
+public class CommandCreoleSpace implements Command {
+
+ private final Pattern pattern;
+
+ private CommandCreoleSpace(String p) {
+ this.pattern = MyPattern.cmpile(p);
+ }
+
+ public static Command create() {
+ return new CommandCreoleSpace("^(?i)(\\<space:(\\d+)/?\\>)");
+ }
+
+ public int matchingSize(String line) {
+ final Matcher m = pattern.matcher(line);
+ if (m.find() == false) {
+ return 0;
+ }
+ return m.group(1).length();
+ }
+
+ public String executeAndGetRemaining(String line, StripeSimple stripe) {
+ final Matcher m = pattern.matcher(line);
+ if (m.find() == false) {
+ throw new IllegalStateException();
+ }
+ // final int size = Integer.parseInt(m.group(2));
+ // final FontConfiguration fc1 = stripe.getActualFontConfiguration();
+ // final FontConfiguration fc2 = fc1.changeSize(size);
+ // stripe.setActualFontConfiguration(fc2);
+ // stripe.analyzeAndAdd(m.group(3));
+ final int size = Integer.parseInt(m.group(2));
+ stripe.addSpace(size);
+ // stripe.setActualFontConfiguration(fc1);
+ return line.substring(m.group(1).length());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/creole/CommandCreoleSprite.java b/src/net/sourceforge/plantuml/creole/CommandCreoleSprite.java
new file mode 100644
index 0000000..26b65ad
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/CommandCreoleSprite.java
@@ -0,0 +1,73 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.graphic.Splitter;
+
+public class CommandCreoleSprite implements Command {
+
+ private final Pattern pattern;
+
+ private CommandCreoleSprite(String p) {
+ this.pattern = MyPattern.cmpile(p);
+ }
+
+ public static Command create() {
+ return new CommandCreoleSprite("^(?i)(" + Splitter.spritePattern2 + ")");
+ }
+
+ public int matchingSize(String line) {
+ final Matcher m = pattern.matcher(line);
+ if (m.find() == false) {
+ return 0;
+ }
+ return m.group(1).length();
+ }
+
+ public String executeAndGetRemaining(String line, StripeSimple stripe) {
+ final Matcher m = pattern.matcher(line);
+ if (m.find() == false) {
+ throw new IllegalStateException();
+ }
+ final String src = m.group(2);
+ stripe.addSprite(src);
+ return line.substring(m.group(1).length());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/creole/CommandCreoleStyle.java b/src/net/sourceforge/plantuml/creole/CommandCreoleStyle.java
new file mode 100644
index 0000000..333a689
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/CommandCreoleStyle.java
@@ -0,0 +1,102 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.graphic.AddStyle;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.FontStyle;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+
+public class CommandCreoleStyle implements Command {
+
+ private final Pattern p;
+ private final FontStyle style;
+ private final boolean tryExtendedColor;
+
+ public static CommandCreoleStyle createCreole(FontStyle style) {
+ return new CommandCreoleStyle("^(" + style.getCreoleSyntax() + "(.+?)" + style.getCreoleSyntax() + ")", style,
+ false);
+ }
+
+ public static Command createLegacy(FontStyle style) {
+ return new CommandCreoleStyle("^((" + style.getActivationPattern() + ")(.+?)" + style.getDeactivationPattern()
+ + ")", style, style.canHaveExtendedColor());
+ }
+
+ public static Command createLegacyEol(FontStyle style) {
+ return new CommandCreoleStyle("^((" + style.getActivationPattern() + ")(.+))$", style,
+ style.canHaveExtendedColor());
+ }
+
+ private CommandCreoleStyle(String p, FontStyle style, boolean tryExtendedColor) {
+ this.p = MyPattern.cmpile(p);
+ this.style = style;
+ this.tryExtendedColor = tryExtendedColor;
+ }
+
+ private HtmlColor getExtendedColor(Matcher m) {
+ if (tryExtendedColor) {
+ return style.getExtendedColor(m.group(2));
+ }
+ return null;
+ }
+
+ public String executeAndGetRemaining(final String line, StripeSimple stripe) {
+ final Matcher m = p.matcher(line);
+ if (m.find() == false) {
+ throw new IllegalStateException();
+ }
+ final FontConfiguration fc1 = stripe.getActualFontConfiguration();
+ final FontConfiguration fc2 = new AddStyle(style, getExtendedColor(m)).apply(fc1);
+ stripe.setActualFontConfiguration(fc2);
+ final int groupCount = m.groupCount();
+ stripe.analyzeAndAdd(m.group(groupCount));
+ stripe.setActualFontConfiguration(fc1);
+ return line.substring(m.group(1).length());
+ }
+
+ public int matchingSize(String line) {
+ final Matcher m = p.matcher(line);
+ if (m.find() == false) {
+ return 0;
+ }
+ return m.group(1).length();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/creole/CommandCreoleSvgAttributeChange.java b/src/net/sourceforge/plantuml/creole/CommandCreoleSvgAttributeChange.java
new file mode 100644
index 0000000..6b7f146
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/CommandCreoleSvgAttributeChange.java
@@ -0,0 +1,88 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.Splitter;
+import net.sourceforge.plantuml.graphic.SvgAttributes;
+
+public class CommandCreoleSvgAttributeChange implements Command {
+
+ private final Pattern pattern;
+
+ public static final String fontPattern = Splitter.svgAttributePattern;
+
+ public static Command create() {
+ return new CommandCreoleSvgAttributeChange("^(?i)(" + fontPattern + "(.*?)\\</text\\>)");
+ }
+
+ public static Command createEol() {
+ return new CommandCreoleSvgAttributeChange("^(?i)(" + fontPattern + "(.*))$");
+ }
+
+ private CommandCreoleSvgAttributeChange(String p) {
+ this.pattern = MyPattern.cmpile(p);
+ }
+
+ public int matchingSize(String line) {
+ final Matcher m = pattern.matcher(line);
+ if (m.find() == false) {
+ return 0;
+ }
+ return m.group(1).length();
+ }
+
+ public String executeAndGetRemaining(String line, StripeSimple stripe) {
+ final Matcher m = pattern.matcher(line);
+ if (m.find() == false) {
+ throw new IllegalStateException();
+ }
+
+ final FontConfiguration fc1 = stripe.getActualFontConfiguration();
+ FontConfiguration fc2 = fc1;
+ if (m.group(2) != null) {
+ fc2 = fc2.changeAttributes(new SvgAttributes(m.group(2)));
+ }
+
+ stripe.setActualFontConfiguration(fc2);
+ stripe.analyzeAndAdd(m.group(3));
+ stripe.setActualFontConfiguration(fc1);
+ return line.substring(m.group(1).length());
+ }
+}
diff --git a/src/net/sourceforge/plantuml/creole/CommandCreoleUrl.java b/src/net/sourceforge/plantuml/creole/CommandCreoleUrl.java
new file mode 100644
index 0000000..23b0acc
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/CommandCreoleUrl.java
@@ -0,0 +1,87 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
+import net.sourceforge.plantuml.command.regex.MyPattern;
+
+public class CommandCreoleUrl implements Command {
+
+ private final Pattern pattern;
+ private final ISkinSimple skinParam;
+
+ public static Command create(ISkinSimple skinParam) {
+ return new CommandCreoleUrl(skinParam, "^(" + UrlBuilder.getRegexp() + ")");
+ }
+
+ private CommandCreoleUrl(ISkinSimple skinParam, String p) {
+ this.pattern = MyPattern.cmpile(p);
+ this.skinParam = skinParam;
+
+ }
+
+ public int matchingSize(String line) {
+ final Matcher m = pattern.matcher(line);
+ if (m.find() == false) {
+ return 0;
+ }
+ return m.group(1).length();
+ }
+
+ public String executeAndGetRemaining(String line, StripeSimple stripe) {
+ final Matcher m = pattern.matcher(line);
+ if (m.find() == false) {
+ throw new IllegalStateException();
+ }
+ final UrlBuilder urlBuilder = new UrlBuilder(skinParam.getValue("topurl"), ModeUrl.STRICT);
+ final Url url = urlBuilder.getUrl(m.group(1));
+ stripe.addUrl(url);
+
+// final int size = Integer.parseInt(m.group(2));
+// final FontConfiguration fc1 = stripe.getActualFontConfiguration();
+// final FontConfiguration fc2 = fc1.changeSize(size);
+// // final FontConfiguration fc2 = new AddStyle(style, null).apply(fc1);
+// stripe.setActualFontConfiguration(fc2);
+ // stripe.analyzeAndAdd("AZERTY");
+// stripe.setActualFontConfiguration(fc1);
+ return line.substring(m.group(1).length());
+ }
+}
diff --git a/src/net/sourceforge/plantuml/creole/CreoleContext.java b/src/net/sourceforge/plantuml/creole/CreoleContext.java
new file mode 100644
index 0000000..c1f66de
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/CreoleContext.java
@@ -0,0 +1,61 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class CreoleContext {
+
+ private final List<Integer> stack = new ArrayList<Integer>();
+
+ public int getLocalNumber(int order) {
+ ensureStackOk(order);
+ final int n = stack.get(order);
+ stack.set(order, n + 1);
+ return n;
+ }
+
+ private void ensureStackOk(int order) {
+ while (stack.size() <= order) {
+ stack.add(0);
+ }
+ while (stack.size() > order + 1) {
+ stack.remove(order + 1);
+ }
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/creole/CreoleHorizontalLine.java b/src/net/sourceforge/plantuml/creole/CreoleHorizontalLine.java
new file mode 100644
index 0000000..730899d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/CreoleHorizontalLine.java
@@ -0,0 +1,107 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.cucadiagram.Display;
+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;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UHorizontalLine;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class CreoleHorizontalLine implements Atom {
+
+ private final FontConfiguration fontConfiguration;
+ private final String line;
+ private final char style;
+ private final ISkinSimple skinParam;
+
+ public static CreoleHorizontalLine create(FontConfiguration fontConfiguration, String line, char style,
+ ISkinSimple skinParam) {
+ return new CreoleHorizontalLine(fontConfiguration, line, style, skinParam);
+ }
+
+ private CreoleHorizontalLine(FontConfiguration fontConfiguration, String line, char style, ISkinSimple skinParam) {
+ this.fontConfiguration = fontConfiguration;
+ this.line = line;
+ this.style = style;
+ this.skinParam = skinParam;
+ }
+
+ private UHorizontalLine getHorizontalLine() {
+ if (line.length() == 0) {
+ return UHorizontalLine.infinite(0, 0, style);
+ }
+ final TextBlock tb = getTitle();
+ return UHorizontalLine.infinite(0, 0, tb, style);
+ }
+
+ private TextBlock getTitle() {
+ if (line.length() == 0) {
+ return TextBlockUtils.empty(0, 0);
+ }
+ final CreoleParser parser = new CreoleParser(fontConfiguration, HorizontalAlignment.LEFT, skinParam, false);
+ final Sheet sheet = parser.createSheet(Display.getWithNewlines(line));
+ final TextBlock tb = new SheetBlock1(sheet, 0, skinParam.getPadding());
+ return tb;
+ }
+
+ public void drawU(UGraphic ug) {
+ // ug = ug.apply(new UChangeColor(fontConfiguration.getColor()));
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ ug = ug.apply(new UTranslate(0, dim.getHeight() / 2));
+ ug.draw(getHorizontalLine());
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ if (line.length() == 0) {
+ return new Dimension2DDouble(10, 10);
+ }
+ final TextBlock tb = getTitle();
+ return tb.calculateDimension(stringBounder);
+ }
+
+ public double getStartingAltitude(StringBounder stringBounder) {
+ return 0;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/creole/CreoleParser.java b/src/net/sourceforge/plantuml/creole/CreoleParser.java
new file mode 100644
index 0000000..0e19af8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/CreoleParser.java
@@ -0,0 +1,95 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.util.Arrays;
+import java.util.List;
+
+import net.sourceforge.plantuml.EmbededDiagram;
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+
+public class CreoleParser {
+
+ private final FontConfiguration fontConfiguration;
+ private final ISkinSimple skinParam;
+ private final HorizontalAlignment horizontalAlignment;
+ private final boolean modeSimpleLine;
+
+ public CreoleParser(FontConfiguration fontConfiguration, HorizontalAlignment horizontalAlignment,
+ ISkinSimple skinParam, boolean modeSimpleLine) {
+ this.modeSimpleLine = modeSimpleLine;
+ this.fontConfiguration = fontConfiguration;
+ this.skinParam = skinParam;
+ this.horizontalAlignment = horizontalAlignment;
+ }
+
+ private Stripe createStripe(String line, CreoleContext context, Stripe lastStripe) {
+ if (lastStripe instanceof StripeTable && line.startsWith("|") && line.endsWith("|")) {
+ final StripeTable table = (StripeTable) lastStripe;
+ table.analyzeAndAddNormal(line);
+ return null;
+ } else if (line.startsWith("|=") && line.endsWith("|")) {
+ return new StripeTable(fontConfiguration, skinParam, line);
+ }
+ return new CreoleStripeSimpleParser(line, context, fontConfiguration, skinParam, modeSimpleLine).createStripe(context);
+ }
+
+ public Sheet createSheet(Display display) {
+ final Sheet sheet = new Sheet(horizontalAlignment);
+ if (display != null) {
+ final CreoleContext context = new CreoleContext();
+ for (CharSequence cs : display) {
+ final Stripe stripe;
+ if (cs instanceof EmbededDiagram) {
+ final Atom atom = new AtomEmbededSystem((EmbededDiagram) cs);
+ stripe = new Stripe() {
+ public List<Atom> getAtoms() {
+ return Arrays.asList(atom);
+ }
+ };
+ } else {
+ stripe = createStripe(cs.toString(), context, sheet.getLastStripe());
+ }
+ if (stripe != null) {
+ sheet.add(stripe);
+ }
+ }
+ }
+ return sheet;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/creole/CreoleStripeSimpleParser.java b/src/net/sourceforge/plantuml/creole/CreoleStripeSimpleParser.java
new file mode 100644
index 0000000..569615b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/CreoleStripeSimpleParser.java
@@ -0,0 +1,143 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.utils.CharHidder;
+
+public class CreoleStripeSimpleParser {
+
+ final private String line;
+ final private StripeStyle style;
+ private final boolean modeSimpleLine;
+
+ private final FontConfiguration fontConfiguration;
+ private final ISkinSimple skinParam;
+
+ public CreoleStripeSimpleParser(String line, CreoleContext creoleContext, FontConfiguration fontConfiguration,
+ ISkinSimple skinParam, boolean modeSimpleLine) {
+ this.fontConfiguration = fontConfiguration;
+ this.modeSimpleLine = modeSimpleLine;
+ this.skinParam = skinParam;
+
+ final Pattern p4 = MyPattern.cmpile("^--([^-]*)--$");
+ final Matcher m4 = p4.matcher(line);
+ if (m4.find()) {
+ this.line = m4.group(1);
+ this.style = new StripeStyle(StripeStyleType.HORIZONTAL_LINE, 0, '-');
+ return;
+ }
+
+ final Pattern p5 = MyPattern.cmpile("^==([^=]*)==$");
+ final Matcher m5 = p5.matcher(line);
+ if (m5.find()) {
+ this.line = m5.group(1);
+ this.style = new StripeStyle(StripeStyleType.HORIZONTAL_LINE, 0, '=');
+ return;
+ }
+ final Pattern p5b = MyPattern.cmpile("^===*==$");
+ final Matcher m5b = p5b.matcher(line);
+ if (m5b.find()) {
+ this.line = "";
+ this.style = new StripeStyle(StripeStyleType.HORIZONTAL_LINE, 0, '=');
+ return;
+ }
+
+ if (modeSimpleLine == false) {
+ final Pattern p6 = MyPattern.cmpile("^__([^_]*)__$");
+ final Matcher m6 = p6.matcher(line);
+ if (m6.find()) {
+ this.line = m6.group(1);
+ this.style = new StripeStyle(StripeStyleType.HORIZONTAL_LINE, 0, '_');
+ return;
+ }
+ }
+
+ final Pattern p7 = MyPattern.cmpile("^\\.\\.([^\\.]*)\\.\\.$");
+ final Matcher m7 = p7.matcher(line);
+ if (m7.find()) {
+ this.line = m7.group(1);
+ this.style = new StripeStyle(StripeStyleType.HORIZONTAL_LINE, 0, '.');
+ return;
+ }
+
+ if (modeSimpleLine == false) {
+ final Pattern p1 = MyPattern.cmpile("^(\\*+)([^*]+(?:[^*]|\\*\\*[^*]+\\*\\*)*)$");
+ final Matcher m1 = p1.matcher(line);
+ if (m1.find()) {
+ this.line = m1.group(2).trim();
+ final int order = m1.group(1).length() - 1;
+ this.style = new StripeStyle(StripeStyleType.LIST_WITHOUT_NUMBER, order, '\0');
+ return;
+ }
+ }
+
+ if (modeSimpleLine == false) {
+ final Pattern p2 = MyPattern.cmpile("^(#+)(.+)$");
+ final Matcher m2 = p2.matcher(CharHidder.hide(line));
+ if (m2.find()) {
+ this.line = CharHidder.unhide(m2.group(2)).trim();
+ final int order = CharHidder.unhide(m2.group(1)).length() - 1;
+ this.style = new StripeStyle(StripeStyleType.LIST_WITH_NUMBER, order, '\0');
+ return;
+ }
+ }
+
+ final Pattern p3 = MyPattern.cmpile("^(=+)(.+)$");
+ final Matcher m3 = p3.matcher(line);
+ if (m3.find()) {
+ this.line = m3.group(2).trim();
+ final int order = m3.group(1).length() - 1;
+ this.style = new StripeStyle(StripeStyleType.HEADING, order, '\0');
+ return;
+ }
+
+ this.line = line;
+ this.style = new StripeStyle(StripeStyleType.NORMAL, 0, '\0');
+
+ }
+
+ public Stripe createStripe(CreoleContext context) {
+ final StripeSimple result = new StripeSimple(fontConfiguration, style, context, skinParam, modeSimpleLine);
+ result.analyzeAndAdd(line);
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/creole/Fission.java b/src/net/sourceforge/plantuml/creole/Fission.java
new file mode 100644
index 0000000..d28d158
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/Fission.java
@@ -0,0 +1,109 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+
+public class Fission {
+
+ private final Stripe stripe;
+ private final double maxWidth;
+
+ public Fission(Stripe stripe, double maxWidth) {
+ this.stripe = stripe;
+ this.maxWidth = maxWidth;
+ }
+
+ public List<Stripe> getSplitted(StringBounder stringBounder) {
+ if (maxWidth == 0) {
+ return Arrays.asList(stripe);
+ }
+ final List<Stripe> result = new ArrayList<Stripe>();
+ StripeSimple current = new StripeSimple();
+ for (Atom a1 : stripe.getAtoms()) {
+ for (Atom atom : getSplitted(stringBounder, a1)) {
+ final double width = atom.calculateDimension(stringBounder).getWidth();
+ if (current.totalWidth + width > maxWidth) {
+ result.add(current);
+ current = new StripeSimple();
+ }
+ current.addAtom(atom, width);
+ }
+ }
+ if (current.totalWidth > 0) {
+ result.add(current);
+ }
+ return Collections.unmodifiableList(result);
+ }
+
+ private Collection<? extends Atom> getSplitted(StringBounder stringBounder, Atom atom) {
+ if (atom instanceof AtomText) {
+ return ((AtomText) atom).getSplitted(stringBounder, maxWidth);
+ }
+ return Collections.singleton(atom);
+ }
+
+ private List<Stripe> getSplittedSimple() {
+ final StripeSimple result = new StripeSimple();
+ for (Atom atom : stripe.getAtoms()) {
+ result.addAtom(atom, 0);
+
+ }
+ return Arrays.asList((Stripe) result);
+ }
+
+ static class StripeSimple implements Stripe {
+
+ private final List<Atom> atoms = new ArrayList<Atom>();
+ private double totalWidth;
+
+ public List<Atom> getAtoms() {
+ return Collections.unmodifiableList(atoms);
+ }
+
+ private void addAtom(Atom atom, double width) {
+ this.atoms.add(atom);
+ this.totalWidth += width;
+ }
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/creole/PSystemCreole.java b/src/net/sourceforge/plantuml/creole/PSystemCreole.java
new file mode 100644
index 0000000..a1c0535
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/PSystemCreole.java
@@ -0,0 +1,91 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.awt.Font;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.core.DiagramDescription;
+import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+import net.sourceforge.plantuml.ugraphic.ImageBuilder;
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public class PSystemCreole extends AbstractPSystem {
+
+ private final List<String> lines = new ArrayList<String>();
+
+ public PSystemCreole() {
+ }
+
+ public DiagramDescription getDescription() {
+ return new DiagramDescriptionImpl("(Creole)", getClass());
+ }
+
+ public void doCommandLine(String line) {
+ lines.add(line);
+ }
+
+ public ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormat) throws IOException {
+ final Display display = Display.create(lines);
+ final UFont font = new UFont("Serif", Font.PLAIN, 14);
+ final FontConfiguration fontConfiguration = new FontConfiguration(font, HtmlColorUtils.BLACK,
+ HtmlColorUtils.BLUE, true);
+ final Sheet sheet = new CreoleParser(fontConfiguration, HorizontalAlignment.LEFT, null, false)
+ .createSheet(display);
+ final SheetBlock1 sheetBlock = new SheetBlock1(sheet, 0, 0);
+
+ final ImageBuilder builder = new ImageBuilder(new ColorMapperIdentity(), 1.0, null, null, null, 0, 0, null, false);
+ builder.addUDrawable(sheetBlock);
+ return builder.writeImageTOBEMOVED(fileFormat.getFileFormat(), os);
+
+ // final Dimension2D dim = TextBlockUtils.getDimension(sheetBlock);
+ // final UGraphic2 ug = fileFormat.createUGraphic(new ColorMapperIdentity(), 1, dim, null, false);
+ // // sheetBlock.drawU(ug.apply(new UTranslate(0, 10)));
+ // sheetBlock.drawU(ug);
+ // ug.writeImageTOBEMOVED(os, null, 96);
+ // return new ImageDataSimple(dim);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/creole/PSystemCreoleFactory.java b/src/net/sourceforge/plantuml/creole/PSystemCreoleFactory.java
new file mode 100644
index 0000000..3a81d1a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/PSystemCreoleFactory.java
@@ -0,0 +1,60 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.creole;
+
+import net.sourceforge.plantuml.command.PSystemBasicFactory;
+import net.sourceforge.plantuml.core.DiagramType;
+
+public class PSystemCreoleFactory extends PSystemBasicFactory<PSystemCreole> {
+
+ public PSystemCreoleFactory() {
+ super(DiagramType.CREOLE);
+ }
+
+ public PSystemCreole init(String startLine) {
+ if (getDiagramType() == DiagramType.CREOLE) {
+ return new PSystemCreole();
+ }
+
+ return null;
+ }
+
+ @Override
+ public PSystemCreole executeLine(PSystemCreole system, String line) {
+ system.doCommandLine(line);
+ return system;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/creole/Position.java b/src/net/sourceforge/plantuml/creole/Position.java
new file mode 100644
index 0000000..b9abc12
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/Position.java
@@ -0,0 +1,118 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.ugraphic.MinMax;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class Position {
+
+ private final double x;
+ private final double y;
+ private final Dimension2D dim;
+
+ public Position(double x, double y, Dimension2D dim) {
+ this.x = x;
+ this.y = y;
+ this.dim = dim;
+// if (dim.getHeight() == 0) {
+// throw new IllegalArgumentException();
+// }
+// if (dim.getWidth() == 0) {
+// throw new IllegalArgumentException();
+// }
+ }
+
+ @Override
+ public String toString() {
+ return "x=" + x + " y=" + y + " dim=" + dim;
+ }
+
+ public Position align(double height) {
+ final double dy = height - dim.getHeight();
+ return translateY(dy);
+ }
+
+ public final double getMinY() {
+ return y;
+ }
+
+ public final double getMaxY() {
+ return y + getHeight();
+ }
+
+ public UGraphic translate(UGraphic ug) {
+ return ug.apply(new UTranslate(x, y));
+ }
+
+ public Position translateY(double dy) {
+ return new Position(x, y + dy, dim);
+ }
+
+ public Position translateX(double dx) {
+ return new Position(x + dx, y, dim);
+ }
+
+ public MinMax update(MinMax minMax) {
+ return minMax.addPoint(x + dim.getWidth(), y + dim.getHeight());
+ }
+
+ public void drawDebug(UGraphic ug) {
+ // ug = ug.apply(new UChangeColor(HtmlColorUtils.BLACK)).apply(new UChangeBackColor(HtmlColorUtils.LIGHT_GRAY));
+ ug = ug.apply(new UChangeColor(HtmlColorUtils.BLACK)).apply(new UChangeBackColor(null));
+ ug = ug.apply(new UTranslate(x, y));
+ ug.draw(new URectangle(dim));
+ }
+
+ public double getHeight() {
+ return dim.getHeight();
+ }
+
+ public double getWidth() {
+ return dim.getWidth();
+ }
+
+ public UTranslate getTranslate() {
+ return new UTranslate(x, y);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/creole/Sea.java b/src/net/sourceforge/plantuml/creole/Sea.java
new file mode 100644
index 0000000..3f452ad
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/Sea.java
@@ -0,0 +1,130 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.awt.geom.Dimension2D;
+import java.util.HashMap;
+import java.util.Map;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.MinMax;
+
+public class Sea {
+
+ private double currentX;
+ private final Map<Atom, Position> positions = new HashMap<Atom, Position>();
+ private final StringBounder stringBounder;
+
+ public Sea(StringBounder stringBounder) {
+ this.stringBounder = stringBounder;
+ }
+
+ public void add(Atom atom) {
+ final Dimension2D dim = atom.calculateDimension(stringBounder);
+ final double y = 0;
+ final Position position = new Position(currentX, y, dim);
+ positions.put(atom, position);
+ currentX += dim.getWidth();
+ }
+
+ public Position getPosition(Atom atom) {
+ return positions.get(atom);
+ }
+
+ public void doAlign() {
+ for (Map.Entry<Atom, Position> ent : new HashMap<Atom, Position>(positions).entrySet()) {
+ final Position pos = ent.getValue();
+ final Atom atom = ent.getKey();
+ final double height = atom.calculateDimension(stringBounder).getHeight();
+ final Position newPos = pos.translateY(-height + atom.getStartingAltitude(stringBounder));
+ positions.put(atom, newPos);
+ }
+ }
+
+ public void translateMinYto(double newValue) {
+ final double delta = newValue - getMinY();
+ for (Map.Entry<Atom, Position> ent : new HashMap<Atom, Position>(positions).entrySet()) {
+ final Position pos = ent.getValue();
+ final Atom atom = ent.getKey();
+ positions.put(atom, pos.translateY(delta));
+ }
+ }
+
+ public void exportAllPositions(Map<Atom, Position> destination) {
+ destination.putAll(positions);
+ }
+
+ public double getMinY() {
+ if (positions.size() == 0) {
+ throw new IllegalStateException();
+ }
+ double result = Double.MAX_VALUE;
+ for (Position pos : positions.values()) {
+ if (result > pos.getMinY()) {
+ result = pos.getMinY();
+ }
+ }
+ return result;
+ }
+
+ public double getMaxY() {
+ if (positions.size() == 0) {
+ throw new IllegalStateException();
+ }
+ double result = -Double.MAX_VALUE;
+ for (Position pos : positions.values()) {
+ if (result < pos.getMaxY()) {
+ result = pos.getMaxY();
+ }
+ }
+ return result;
+ }
+
+ public double getHeight() {
+ return getMaxY() - getMinY();
+ }
+
+ public MinMax update(MinMax minMax) {
+ for (Position position : positions.values()) {
+ minMax = position.update(minMax);
+ }
+ return minMax;
+ }
+
+ public final double getWidth() {
+ return currentX;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/creole/Sheet.java b/src/net/sourceforge/plantuml/creole/Sheet.java
new file mode 100644
index 0000000..93c29c9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/Sheet.java
@@ -0,0 +1,71 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+
+public class Sheet implements Iterable<Stripe> {
+
+ private final List<Stripe> stripes = new ArrayList<Stripe>();
+ private final HorizontalAlignment horizontalAlignment;
+
+ public Sheet(HorizontalAlignment horizontalAlignment) {
+ this.horizontalAlignment = horizontalAlignment;
+ }
+
+ public void add(Stripe stripe) {
+ stripes.add(stripe);
+ }
+
+ public Iterator<Stripe> iterator() {
+ return stripes.iterator();
+ }
+
+ public Stripe getLastStripe() {
+ final int size = stripes.size();
+ if (size == 0) {
+ return null;
+ }
+ return stripes.get(size - 1);
+ }
+
+ public final HorizontalAlignment getHorizontalAlignment() {
+ return horizontalAlignment;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/creole/SheetBlock1.java b/src/net/sourceforge/plantuml/creole/SheetBlock1.java
new file mode 100644
index 0000000..222cb15
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/SheetBlock1.java
@@ -0,0 +1,158 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.awt.geom.Dimension2D;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.ugraphic.MinMax;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class SheetBlock1 implements TextBlock, Atom, Stencil {
+
+ private final Sheet sheet;
+ private List<Stripe> stripes;
+ private Map<Stripe, Double> heights;
+ private Map<Stripe, Double> widths;
+ private Map<Atom, Position> positions;
+ private MinMax minMax;
+ private final double maxWidth;
+ private final double padding;
+
+ public SheetBlock1(Sheet sheet, double maxWidth, double padding) {
+ this.sheet = sheet;
+ this.maxWidth = maxWidth;
+ this.padding = padding;
+ }
+
+ private void initMap(StringBounder stringBounder) {
+ if (positions != null) {
+ return;
+ }
+ stripes = new ArrayList<Stripe>();
+ for (Stripe stripe : sheet) {
+ stripes.addAll(new Fission(stripe, maxWidth).getSplitted(stringBounder));
+ }
+ positions = new LinkedHashMap<Atom, Position>();
+ widths = new LinkedHashMap<Stripe, Double>();
+ heights = new LinkedHashMap<Stripe, Double>();
+ minMax = MinMax.getEmpty(true);
+ double y = 0;
+ for (Stripe stripe : stripes) {
+ if (stripe.getAtoms().size() == 0) {
+ continue;
+ }
+ final Sea sea = new Sea(stringBounder);
+ for (Atom atom : stripe.getAtoms()) {
+ sea.add(atom);
+ }
+ sea.doAlign();
+ sea.translateMinYto(y);
+ sea.exportAllPositions(positions);
+ final double width = sea.getWidth();
+ widths.put(stripe, width);
+ minMax = sea.update(minMax);
+ final double height = sea.getHeight();
+ heights.put(stripe, height);
+ y += height;
+ }
+ final int coef;
+ if (sheet.getHorizontalAlignment() == HorizontalAlignment.CENTER) {
+ coef = 2;
+ } else if (sheet.getHorizontalAlignment() == HorizontalAlignment.RIGHT) {
+ coef = 1;
+ } else {
+ coef = 0;
+ }
+ if (coef != 0) {
+ double maxWidth = 0;
+ for (Double v : widths.values()) {
+ if (v > maxWidth) {
+ maxWidth = v;
+ }
+ }
+ for (Map.Entry<Stripe, Double> ent : widths.entrySet()) {
+ final double diff = maxWidth - ent.getValue();
+ if (diff > 0) {
+ for (Atom atom : ent.getKey().getAtoms()) {
+ final Position pos = positions.get(atom);
+ positions.put(atom, pos.translateX(diff / coef));
+ }
+ }
+
+ }
+
+ }
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ initMap(stringBounder);
+ return Dimension2DDouble.delta(minMax.getDimension(), 2 * padding);
+ }
+
+ public void drawU(UGraphic ug) {
+ initMap(ug.getStringBounder());
+ if (padding > 0) {
+ ug = ug.apply(new UTranslate(padding, padding));
+ }
+ for (Stripe stripe : stripes) {
+ for (Atom atom : stripe.getAtoms()) {
+ final Position position = positions.get(atom);
+ atom.drawU(position.translate(ug));
+ // position.drawDebug(ug);
+ }
+ }
+ }
+
+ public double getStartingAltitude(StringBounder stringBounder) {
+ return 0;
+ }
+
+ public double getStartingX(StringBounder stringBounder, double y) {
+ return 0;
+ }
+
+ public double getEndingX(StringBounder stringBounder, double y) {
+ return calculateDimension(stringBounder).getWidth();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/creole/SheetBlock2.java b/src/net/sourceforge/plantuml/creole/SheetBlock2.java
new file mode 100644
index 0000000..4db2090
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/SheetBlock2.java
@@ -0,0 +1,74 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UGraphicStencil;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+
+public class SheetBlock2 implements TextBlock, Atom {
+
+ private final SheetBlock1 block;
+ private final UStroke defaultStroke;
+ private final Stencil stencil;
+
+ public SheetBlock2(SheetBlock1 block, Stencil stencil, UStroke defaultStroke) {
+ this.block = block;
+ this.stencil = stencil;
+ this.defaultStroke = defaultStroke;
+ if (stencil == null) {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return block.calculateDimension(stringBounder);
+ }
+
+ public void drawU(UGraphic ug) {
+ if (stencil != null) {
+ ug = new UGraphicStencil(ug, stencil, defaultStroke);
+ }
+ block.drawU(ug);
+ }
+
+ public double getStartingAltitude(StringBounder stringBounder) {
+ return 0;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/creole/Stencil.java b/src/net/sourceforge/plantuml/creole/Stencil.java
new file mode 100644
index 0000000..be1ee03
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/Stencil.java
@@ -0,0 +1,45 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.creole;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+
+public interface Stencil {
+
+ public double getStartingX(StringBounder stringBounder, double y);
+
+ public double getEndingX(StringBounder stringBounder, double y);
+
+}
diff --git a/src/net/sourceforge/plantuml/creole/Stripe.java b/src/net/sourceforge/plantuml/creole/Stripe.java
new file mode 100644
index 0000000..04ac5d1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/Stripe.java
@@ -0,0 +1,43 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.util.List;
+
+public interface Stripe {
+
+ public List<Atom> getAtoms();
+
+}
diff --git a/src/net/sourceforge/plantuml/creole/StripeSimple.java b/src/net/sourceforge/plantuml/creole/StripeSimple.java
new file mode 100644
index 0000000..468b05c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/StripeSimple.java
@@ -0,0 +1,201 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.FontPosition;
+import net.sourceforge.plantuml.graphic.FontStyle;
+import net.sourceforge.plantuml.graphic.ImgValign;
+import net.sourceforge.plantuml.openiconic.OpenIcon;
+import net.sourceforge.plantuml.ugraphic.Sprite;
+import net.sourceforge.plantuml.utils.CharHidder;
+
+public class StripeSimple implements Stripe {
+
+ final private List<Atom> atoms = new ArrayList<Atom>();
+ private final List<Command> commands = new ArrayList<Command>();
+
+ private FontConfiguration fontConfiguration;
+
+ final private StripeStyle style;
+ final private ISkinSimple skinParam;
+
+ public StripeSimple(FontConfiguration fontConfiguration, StripeStyle style, CreoleContext context,
+ ISkinSimple skinParam, boolean modeSimpleLine) {
+ this.fontConfiguration = fontConfiguration;
+ this.style = style;
+ this.skinParam = skinParam;
+
+ // class Splitter
+ this.commands.add(CommandCreoleStyle.createCreole(FontStyle.BOLD));
+ this.commands.add(CommandCreoleStyle.createLegacy(FontStyle.BOLD));
+ this.commands.add(CommandCreoleStyle.createLegacyEol(FontStyle.BOLD));
+ this.commands.add(CommandCreoleStyle.createCreole(FontStyle.ITALIC));
+ this.commands.add(CommandCreoleStyle.createLegacy(FontStyle.ITALIC));
+ this.commands.add(CommandCreoleStyle.createLegacyEol(FontStyle.ITALIC));
+ if (modeSimpleLine == false) {
+ this.commands.add(CommandCreoleStyle.createCreole(FontStyle.UNDERLINE));
+ }
+ this.commands.add(CommandCreoleStyle.createLegacy(FontStyle.UNDERLINE));
+ this.commands.add(CommandCreoleStyle.createLegacyEol(FontStyle.UNDERLINE));
+ this.commands.add(CommandCreoleStyle.createCreole(FontStyle.STRIKE));
+ this.commands.add(CommandCreoleStyle.createLegacy(FontStyle.STRIKE));
+ this.commands.add(CommandCreoleStyle.createLegacyEol(FontStyle.STRIKE));
+ this.commands.add(CommandCreoleStyle.createCreole(FontStyle.WAVE));
+ this.commands.add(CommandCreoleStyle.createLegacy(FontStyle.WAVE));
+ this.commands.add(CommandCreoleStyle.createLegacyEol(FontStyle.WAVE));
+ this.commands.add(CommandCreoleStyle.createLegacy(FontStyle.BACKCOLOR));
+ this.commands.add(CommandCreoleStyle.createLegacyEol(FontStyle.BACKCOLOR));
+ this.commands.add(CommandCreoleSizeChange.create());
+ this.commands.add(CommandCreoleSizeChange.createEol());
+ this.commands.add(CommandCreoleColorChange.create());
+ this.commands.add(CommandCreoleColorChange.createEol());
+ this.commands.add(CommandCreoleColorAndSizeChange.create());
+ this.commands.add(CommandCreoleColorAndSizeChange.createEol());
+ this.commands.add(CommandCreoleExposantChange.create(FontPosition.EXPOSANT));
+ this.commands.add(CommandCreoleExposantChange.create(FontPosition.INDICE));
+ this.commands.add(CommandCreoleImg.create());
+ this.commands.add(CommandCreoleOpenIcon.create());
+ this.commands.add(CommandCreoleSprite.create());
+ this.commands.add(CommandCreoleSpace.create());
+ this.commands.add(CommandCreoleFontFamilyChange.create());
+ this.commands.add(CommandCreoleFontFamilyChange.createEol());
+ this.commands.add(CommandCreoleMonospaced.create());
+ this.commands.add(CommandCreoleUrl.create(skinParam));
+ this.commands.add(CommandCreoleSvgAttributeChange.create());
+
+ final Atom header = style.getHeader(fontConfiguration, context);
+
+ if (header != null) {
+ atoms.add(header);
+ }
+ }
+
+ public List<Atom> getAtoms() {
+ if (atoms.size() == 0) {
+ atoms.add(AtomText.create(" ", fontConfiguration));
+ }
+ return Collections.unmodifiableList(atoms);
+ }
+
+ public FontConfiguration getActualFontConfiguration() {
+ return fontConfiguration;
+ }
+
+ public void setActualFontConfiguration(FontConfiguration fontConfiguration) {
+ this.fontConfiguration = fontConfiguration;
+ }
+
+ public void analyzeAndAdd(String line) {
+ if (line == null) {
+ throw new IllegalArgumentException();
+ }
+ line = CharHidder.hide(line);
+ if (style.getType() == StripeStyleType.HEADING) {
+ atoms.add(AtomText.createHeading(line, fontConfiguration, style.getOrder()));
+ } else if (style.getType() == StripeStyleType.HORIZONTAL_LINE) {
+ atoms.add(CreoleHorizontalLine.create(fontConfiguration, line, style.getStyle(), skinParam));
+ } else {
+ modifyStripe(line);
+ }
+ }
+
+ public void addImage(String src) {
+ atoms.add(AtomImg.create(src, ImgValign.TOP, 0));
+ }
+
+ public void addSpace(int size) {
+ atoms.add(AtomSpace.create(size));
+ }
+
+ public void addUrl(Url url) {
+ atoms.add(AtomText.createUrl(url, fontConfiguration));
+ }
+
+ public void addSprite(String src) {
+ final Sprite sprite = skinParam.getSprite(src);
+ if (sprite != null) {
+ atoms.add(new AtomSprite(sprite.asTextBlock(fontConfiguration.getColor()), fontConfiguration));
+ }
+ }
+
+ public void addOpenIcon(String src) {
+ final OpenIcon openIcon = OpenIcon.retrieve(src);
+ if (openIcon != null) {
+ atoms.add(new AtomOpenIcon(openIcon, fontConfiguration));
+ }
+ }
+
+ private void modifyStripe(String line) {
+ final StringBuilder pending = new StringBuilder();
+
+ while (line.length() > 0) {
+ final Command cmd = searchCommand(line);
+ if (cmd == null) {
+ pending.append(line.charAt(0));
+ line = line.substring(1);
+ } else {
+ addPending(pending);
+ line = cmd.executeAndGetRemaining(line, this);
+ }
+ }
+ addPending(pending);
+ }
+
+ private void addPending(StringBuilder pending) {
+ if (pending.length() == 0) {
+ return;
+ }
+ atoms.add(AtomText.create(pending.toString(), fontConfiguration));
+ pending.setLength(0);
+ }
+
+ private Command searchCommand(String line) {
+ for (Command cmd : commands) {
+ final int i = cmd.matchingSize(line);
+ if (i != 0) {
+ return cmd;
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/creole/StripeStyle.java b/src/net/sourceforge/plantuml/creole/StripeStyle.java
new file mode 100644
index 0000000..0e422af
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/StripeStyle.java
@@ -0,0 +1,73 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.creole;
+
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+
+public class StripeStyle {
+
+ private final StripeStyleType type;
+ private final int order;
+ private final char style;
+
+ public StripeStyle(StripeStyleType type, int order, char style) {
+ this.type = type;
+ this.order = order;
+ this.style = style;
+ }
+
+ public final StripeStyleType getType() {
+ return type;
+ }
+
+ public Atom getHeader(FontConfiguration fontConfiguration, CreoleContext context) {
+ if (type == StripeStyleType.LIST_WITHOUT_NUMBER) {
+ return new Bullet(fontConfiguration, order);
+ }
+ if (type == StripeStyleType.LIST_WITH_NUMBER) {
+ final int localNumber = context.getLocalNumber(order);
+ return AtomText.createListNumber(fontConfiguration, order, localNumber);
+ }
+ return null;
+ }
+
+ public final int getOrder() {
+ return order;
+ }
+
+ public char getStyle() {
+ return style;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/creole/StripeStyleType.java b/src/net/sourceforge/plantuml/creole/StripeStyleType.java
new file mode 100644
index 0000000..c7f53b9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/StripeStyleType.java
@@ -0,0 +1,39 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.creole;
+
+public enum StripeStyleType {
+ NORMAL, HEADING, LIST_WITHOUT_NUMBER, LIST_WITH_NUMBER, HORIZONTAL_LINE
+}
diff --git a/src/net/sourceforge/plantuml/creole/StripeTable.java b/src/net/sourceforge/plantuml/creole/StripeTable.java
new file mode 100644
index 0000000..9bb57b0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/StripeTable.java
@@ -0,0 +1,133 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.creole;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+
+public class StripeTable implements Stripe {
+
+ static enum Mode {
+ HEADER, NORMAL
+ };
+
+ private FontConfiguration fontConfiguration;
+ final private ISkinSimple skinParam;
+ final private AtomTable table;
+ final private Atom marged;
+ final private StripeStyle stripeStyle = new StripeStyle(StripeStyleType.NORMAL, 0, '\0');
+
+ public StripeTable(FontConfiguration fontConfiguration, ISkinSimple skinParam, String line) {
+ this.fontConfiguration = fontConfiguration;
+ this.skinParam = skinParam;
+ this.table = new AtomTable(fontConfiguration.getColor());
+ this.marged = new AtomWithMargin(table, 2, 2);
+ analyzeAndAddInternal(line, Mode.HEADER);
+ }
+
+ public List<Atom> getAtoms() {
+ return Collections.<Atom> singletonList(marged);
+ }
+
+ private static Atom asAtom(List<StripeSimple> cells, double padding) {
+ final Sheet sheet = new Sheet(HorizontalAlignment.LEFT);
+ for (StripeSimple cell : cells) {
+ sheet.add(cell);
+ }
+ return new SheetBlock1(sheet, 0, padding);
+ }
+
+ private void analyzeAndAddInternal(String line, Mode mode) {
+ table.newLine();
+ for (final StringTokenizer st = new StringTokenizer(line, "|"); st.hasMoreTokens();) {
+ String v = st.nextToken();
+ if (mode == Mode.HEADER && v.startsWith("=")) {
+ v = v.substring(1);
+ }
+ final List<String> lines = getWithNewlinesInternal(v);
+ final List<StripeSimple> cells = new ArrayList<StripeSimple>();
+ for (String s : lines) {
+ final StripeSimple cell = new StripeSimple(getFontConfiguration(mode), stripeStyle,
+ new CreoleContext(), skinParam, false);
+ cell.analyzeAndAdd(s);
+ cells.add(cell);
+ }
+ table.addCell(asAtom(cells, skinParam.getPadding()));
+ }
+ }
+
+ private static List<String> getWithNewlinesInternal(String s) {
+ final List<String> result = new ArrayList<String>();
+ final StringBuilder current = new StringBuilder();
+ for (int i = 0; i < s.length(); i++) {
+ final char c = s.charAt(i);
+ if (c == '\\' && i < s.length() - 1) {
+ final char c2 = s.charAt(i + 1);
+ i++;
+ if (c2 == 'n') {
+ result.add(current.toString());
+ current.setLength(0);
+ } else if (c2 == '\\') {
+ current.append(c2);
+ } else {
+ current.append(c);
+ current.append(c2);
+ }
+ } else {
+ current.append(c);
+ }
+ }
+ result.add(current.toString());
+ return result;
+ }
+
+ private FontConfiguration getFontConfiguration(Mode mode) {
+ if (mode == Mode.NORMAL) {
+ return fontConfiguration;
+ }
+ return fontConfiguration.bold();
+ }
+
+ public void analyzeAndAddNormal(String line) {
+ analyzeAndAddInternal(line, Mode.NORMAL);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/creole/UCreole.java b/src/net/sourceforge/plantuml/creole/UCreole.java
new file mode 100644
index 0000000..677052e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/creole/UCreole.java
@@ -0,0 +1,41 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.creole;
+
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+
+public interface UCreole extends UShape {
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/BlockMember.java b/src/net/sourceforge/plantuml/cucadiagram/BlockMember.java
new file mode 100644
index 0000000..404d652
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/BlockMember.java
@@ -0,0 +1,45 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.graphic.TextBlock;
+
+public interface BlockMember {
+
+ public TextBlock asTextBlock(FontParam fontParam, ISkinParam skinParam);
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/BlockMemberImpl.java b/src/net/sourceforge/plantuml/cucadiagram/BlockMemberImpl.java
new file mode 100644
index 0000000..14c1229
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/BlockMemberImpl.java
@@ -0,0 +1,64 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockLineBefore;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+
+public class BlockMemberImpl implements BlockMember {
+
+ private final List<Member> members = new ArrayList<Member>();
+
+ public BlockMemberImpl(List<Member> members) {
+ this.members.addAll(members);
+ }
+
+ public List<Member> getAll() {
+ return Collections.unmodifiableList(members);
+ }
+
+ public TextBlock asTextBlock(FontParam fontParam, ISkinParam skinParam) {
+ return new TextBlockLineBefore(TextBlockUtils.withMargin((TextBlock) new MethodsOrFieldsArea(members,
+ fontParam, skinParam), 6, 4));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/Bodier.java b/src/net/sourceforge/plantuml/cucadiagram/Bodier.java
new file mode 100644
index 0000000..2d3670d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/Bodier.java
@@ -0,0 +1,169 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.skin.VisibilityModifier;
+import net.sourceforge.plantuml.StringUtils;
+
+public class Bodier {
+
+ private final List<String> rawBody = new ArrayList<String>();
+ private final Set<VisibilityModifier> hides;
+ private final LeafType type;
+ private List<Member> methodsToDisplay;
+ private List<Member> fieldsToDisplay;
+ private final boolean manageModifier;
+
+ public Bodier(LeafType type, Set<VisibilityModifier> hides) {
+ this.hides = hides;
+ this.type = type;
+ this.manageModifier = type == null ? false : type.manageModifier();
+ }
+
+ public void addFieldOrMethod(String s) {
+ // Empty cache
+ methodsToDisplay = null;
+ fieldsToDisplay = null;
+ rawBody.add(s);
+ }
+
+ public boolean isBodyEnhanced() {
+ for (String s : rawBody) {
+ if (BodyEnhanced.isBlockSeparator(s)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public BlockMember getBodyEnhanced() {
+ return new BlockMember() {
+ public TextBlock asTextBlock(FontParam fontParam, ISkinParam skinParam) {
+ final BodyEnhanced result = new BodyEnhanced(rawBody, fontParam, skinParam, manageModifier);
+ return result;
+ }
+ };
+ }
+
+ private LeafType getEntityType() {
+ return type;
+ }
+
+ private boolean isMethod(String s) {
+ if (getEntityType() == LeafType.ANNOTATION || getEntityType() == LeafType.ABSTRACT_CLASS
+ || getEntityType() == LeafType.CLASS || getEntityType() == LeafType.INTERFACE
+ || getEntityType() == LeafType.ENUM) {
+ return StringUtils.isMethod(s);
+ }
+ return false;
+ }
+
+ public List<Member> getMethodsToDisplay() {
+ if (methodsToDisplay == null) {
+ methodsToDisplay = new ArrayList<Member>();
+ for (int i = 0; i < rawBody.size(); i++) {
+ final String s = rawBody.get(i);
+ if (isMethod(i, rawBody) == false) {
+ continue;
+ }
+ if (s.length() == 0 && methodsToDisplay.size() == 0) {
+ continue;
+ }
+ final Member m = new Member(s, true, manageModifier);
+ if (hides == null || hides.contains(m.getVisibilityModifier()) == false) {
+ methodsToDisplay.add(m);
+ }
+ }
+ removeFinalEmptyMembers(methodsToDisplay);
+ }
+ return Collections.unmodifiableList(methodsToDisplay);
+ }
+
+ private boolean isMethod(int i, List<String> rawBody) {
+ if (i > 0 && i < rawBody.size() - 1 && rawBody.get(i).length() == 0 && isMethod(rawBody.get(i - 1))
+ && isMethod(rawBody.get(i + 1))) {
+ return true;
+ }
+ return isMethod(rawBody.get(i));
+ }
+
+ public List<Member> getFieldsToDisplay() {
+ if (fieldsToDisplay == null) {
+ fieldsToDisplay = new ArrayList<Member>();
+ for (String s : rawBody) {
+ if (isMethod(s) == true) {
+ continue;
+ }
+ if (s.length() == 0 && fieldsToDisplay.size() == 0) {
+ continue;
+ }
+ final Member m = new Member(s, false, manageModifier);
+ if (hides == null || hides.contains(m.getVisibilityModifier()) == false) {
+ fieldsToDisplay.add(m);
+ }
+ }
+ removeFinalEmptyMembers(fieldsToDisplay);
+ }
+ return Collections.unmodifiableList(fieldsToDisplay);
+ }
+
+ private void removeFinalEmptyMembers(List<Member> result) {
+ while (result.size() > 0 && result.get(result.size() - 1).getDisplay(false).trim().length() == 0) {
+ result.remove(result.size() - 1);
+ }
+ }
+
+ public boolean hasUrl() {
+ for (Member m : getFieldsToDisplay()) {
+ if (m.hasUrl()) {
+ return true;
+ }
+ }
+ for (Member m : getMethodsToDisplay()) {
+ if (m.hasUrl()) {
+ return true;
+ }
+ }
+ return true;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced.java b/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced.java
new file mode 100644
index 0000000..1941f05
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced.java
@@ -0,0 +1,187 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+import java.awt.geom.Dimension2D;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.Url;
+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.TextBlockLineBefore;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.graphic.TextBlockVertical2;
+import net.sourceforge.plantuml.skin.rose.Rose;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.StringUtils;
+
+public class BodyEnhanced implements TextBlock {
+
+ private TextBlock area2;
+ private final FontConfiguration titleConfig;
+ private final List<String> rawBody;
+ private final FontParam fontParam;
+ private final ISkinParam skinParam;
+ private final boolean lineFirst;
+ private final HorizontalAlignment align;
+ private final boolean manageHorizontalLine;
+ private final boolean manageModifier;
+ private final List<Url> urls = new ArrayList<Url>();
+
+ public BodyEnhanced(List<String> rawBody, FontParam fontParam, ISkinParam skinParam, boolean manageModifier) {
+ this.rawBody = new ArrayList<String>(rawBody);
+ this.fontParam = fontParam;
+ this.skinParam = skinParam;
+
+ this.titleConfig = new FontConfiguration(skinParam.getFont(fontParam, null, false), new Rose().getFontColor(skinParam,
+ fontParam), skinParam.getHyperlinkColor(), skinParam.useUnderlineForHyperlink());
+ this.lineFirst = true;
+ this.align = HorizontalAlignment.LEFT;
+ this.manageHorizontalLine = true;
+ this.manageModifier = manageModifier;
+ }
+
+ public BodyEnhanced(Display display, FontParam fontParam, ISkinParam skinParam, HorizontalAlignment align,
+ Stereotype stereotype, boolean manageHorizontalLine, boolean manageModifier) {
+ this.rawBody = new ArrayList<String>();
+ for (CharSequence s : display) {
+ this.rawBody.add(s.toString());
+ }
+ this.fontParam = fontParam;
+ this.skinParam = skinParam;
+
+ this.titleConfig = new FontConfiguration(skinParam, fontParam, stereotype);
+ this.lineFirst = false;
+ this.align = align;
+ this.manageHorizontalLine = manageHorizontalLine;
+ this.manageModifier = manageModifier;
+
+ }
+
+ private TextBlock decorate(StringBounder stringBounder, TextBlock b, char separator, TextBlock title) {
+ if (separator == 0) {
+ return b;
+ }
+ if (title == null) {
+ return new TextBlockLineBefore(TextBlockUtils.withMargin(b, 6, 4), separator);
+ }
+ final Dimension2D dimTitle = title.calculateDimension(stringBounder);
+ final TextBlock raw = new TextBlockLineBefore(TextBlockUtils.withMargin(b, 6, 6, dimTitle.getHeight() / 2, 4),
+ separator, title);
+ return TextBlockUtils.withMargin(raw, 0, 0, dimTitle.getHeight() / 2, 0);
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return getArea(stringBounder).calculateDimension(stringBounder);
+ }
+
+ private TextBlock getArea(StringBounder stringBounder) {
+ if (area2 != null) {
+ return area2;
+ }
+ urls.clear();
+ final List<TextBlock> blocks = new ArrayList<TextBlock>();
+
+ char separator = lineFirst ? '_' : 0;
+ TextBlock title = null;
+ List<Member> members = new ArrayList<Member>();
+ for (String s : rawBody) {
+ if (manageHorizontalLine && isBlockSeparator(s)) {
+ blocks.add(decorate(stringBounder, new MethodsOrFieldsArea(members, fontParam, skinParam, align),
+ separator, title));
+ separator = s.charAt(0);
+ title = getTitle(s, skinParam);
+ members = new ArrayList<Member>();
+ } else {
+ final Member m = new Member(s, StringUtils.isMethod(s), manageModifier);
+ members.add(m);
+ if (m.getUrl() != null) {
+ urls.add(m.getUrl());
+ }
+ }
+ }
+ blocks.add(decorate(stringBounder, new MethodsOrFieldsArea(members, fontParam, skinParam, align), separator,
+ title));
+
+ if (blocks.size() == 1) {
+ this.area2 = blocks.get(0);
+ } else {
+ this.area2 = new TextBlockVertical2(blocks, align);
+ }
+
+ return area2;
+ }
+
+ public static boolean isBlockSeparator(String s) {
+ if (s.startsWith("--") && s.endsWith("--")) {
+ return true;
+ }
+ if (s.startsWith("==") && s.endsWith("==")) {
+ return true;
+ }
+ if (s.startsWith("..") && s.endsWith("..") && s.equals("...") == false) {
+ return true;
+ }
+ if (s.startsWith("__") && s.endsWith("__")) {
+ return true;
+ }
+ return false;
+ }
+
+ private TextBlock getTitle(String s, ISkinSimple spriteContainer) {
+ if (s.length() <= 4) {
+ return null;
+ }
+ s = s.substring(2, s.length() - 2).trim();
+ return TextBlockUtils
+ .create(Display.getWithNewlines(s), titleConfig, HorizontalAlignment.LEFT, spriteContainer);
+ }
+
+ public void drawU(UGraphic ug) {
+ getArea(ug.getStringBounder()).drawU(ug);
+ }
+
+ public List<Url> getUrls() {
+ return Collections.unmodifiableList(urls);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced2.java b/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced2.java
new file mode 100644
index 0000000..88ada3d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced2.java
@@ -0,0 +1,156 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+import java.awt.geom.Dimension2D;
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockLineBefore;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.graphic.TextBlockVertical2;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class BodyEnhanced2 implements TextBlock {
+
+ private TextBlock area2;
+ private final FontConfiguration titleConfig;
+ private final Display rawBody2;
+ private final ISkinSimple spriteContainer;
+
+ private final HorizontalAlignment align;
+
+ // private final List<Url> urls = new ArrayList<Url>();
+
+ public BodyEnhanced2(Display rawBody, FontParam fontParam, ISkinSimple spriteContainer, HorizontalAlignment align,
+ FontConfiguration titleConfig) {
+ this.rawBody2 = rawBody;
+ this.spriteContainer = spriteContainer;
+
+ this.titleConfig = titleConfig;
+ this.align = align;
+ }
+
+ private TextBlock decorate(StringBounder stringBounder, TextBlock b, char separator, TextBlock title) {
+ if (separator == 0) {
+ return b;
+ }
+ if (title == null) {
+ return new TextBlockLineBefore(TextBlockUtils.withMargin(b, 0, 4), separator);
+ }
+ final Dimension2D dimTitle = title.calculateDimension(stringBounder);
+ final TextBlock raw = new TextBlockLineBefore(TextBlockUtils.withMargin(b, 0, 6, dimTitle.getHeight() / 2, 4),
+ separator, title);
+ return TextBlockUtils.withMargin(raw, 0, 0, dimTitle.getHeight() / 2, 0);
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return getArea(stringBounder).calculateDimension(stringBounder);
+ }
+
+ private TextBlock getArea(StringBounder stringBounder) {
+ if (area2 != null) {
+ return area2;
+ }
+ // urls.clear();
+ final List<TextBlock> blocks = new ArrayList<TextBlock>();
+
+ char separator = 0;
+ TextBlock title = null;
+ Display members2 = Display.empty();
+ for (CharSequence s : rawBody2) {
+ if (isBlockSeparator(s.toString())) {
+ blocks.add(decorate(stringBounder, getTextBlock(members2, stringBounder), separator, title));
+ separator = s.charAt(0);
+ title = getTitle(s.toString(), spriteContainer);
+ members2 = Display.empty();
+ } else {
+ members2 = members2.add(s);
+ }
+ }
+ blocks.add(decorate(stringBounder, getTextBlock(members2, stringBounder), separator, title));
+
+ if (blocks.size() == 1) {
+ this.area2 = blocks.get(0);
+ } else {
+ this.area2 = new TextBlockVertical2(blocks, align);
+ }
+
+ return area2;
+ }
+
+ private TextBlock getTextBlock(Display members2, StringBounder stringBounder) {
+ final TextBlock result = TextBlockUtils.create(members2, titleConfig, align, spriteContainer);
+ return result;
+ }
+
+ public static boolean isBlockSeparator(String s) {
+ if (s.startsWith("--") && s.endsWith("--")) {
+ return true;
+ }
+ if (s.startsWith("==") && s.endsWith("==")) {
+ return true;
+ }
+ if (s.startsWith("..") && s.endsWith("..")) {
+ return true;
+ }
+ if (s.startsWith("__") && s.endsWith("__")) {
+ return true;
+ }
+ return false;
+ }
+
+ private TextBlock getTitle(String s, ISkinSimple spriteContainer) {
+ if (s.length() <= 4) {
+ return null;
+ }
+ s = s.substring(2, s.length() - 2).trim();
+ return TextBlockUtils
+ .create(Display.getWithNewlines(s), titleConfig, HorizontalAlignment.LEFT, spriteContainer);
+ }
+
+ public void drawU(UGraphic ug) {
+ getArea(ug.getStringBounder()).drawU(ug);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/Code.java b/src/net/sourceforge/plantuml/cucadiagram/Code.java
new file mode 100644
index 0000000..df20990
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/Code.java
@@ -0,0 +1,159 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+import java.util.Map;
+
+import net.sourceforge.plantuml.StringUtils;
+
+public class Code implements Comparable<Code> {
+
+ private final String fullName;
+ private final String separator;
+
+ private Code(String fullName, String separator) {
+ if (fullName == null) {
+ throw new IllegalArgumentException();
+ }
+ this.fullName = fullName;
+ this.separator = separator;
+ }
+
+// public String getNamespaceSeparator() {
+// return separator;
+// }
+
+ public Code withSeparator(String separator) {
+ if (separator == null) {
+ throw new IllegalArgumentException();
+ }
+ if (this.separator != null && this.separator.equals(separator) == false) {
+ throw new IllegalStateException();
+ }
+ return new Code(fullName, separator);
+ }
+
+ public static Code of(String code) {
+ return of(code, null);
+ }
+
+ public static Code of(String code, String separator) {
+ if (code == null) {
+ return null;
+ }
+ return new Code(code, separator);
+ }
+
+ public final String getFullName() {
+ return fullName;
+ }
+
+ @Override
+ public String toString() {
+ return fullName + "(" + separator + ")";
+ }
+
+ @Override
+ public int hashCode() {
+ return fullName.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ final Code other = (Code) obj;
+ return this.fullName.equals(other.fullName);
+ }
+
+ public Code addSuffix(String suffix) {
+ return new Code(fullName + suffix, separator);
+ }
+
+ public int compareTo(Code other) {
+ return this.fullName.compareTo(other.fullName);
+ }
+
+ public Code eventuallyRemoveStartingAndEndingDoubleQuote(String format) {
+ return Code.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(fullName, format), separator);
+ }
+
+ private final String getNamespace(Map<Code, ILeaf> leafs) {
+ String name = this.getFullName();
+ if (separator == null) {
+ throw new IllegalArgumentException(toString());
+ }
+ do {
+ final int x = name.lastIndexOf(separator);
+ if (x == -1) {
+ return null;
+ }
+ name = name.substring(0, x);
+ } while (leafs.containsKey(Code.of(name, separator)));
+ return name;
+ }
+
+ public final Code getShortName(Map<Code, ILeaf> leafs) {
+ if (separator == null) {
+ throw new IllegalArgumentException();
+ }
+ final String code = this.getFullName();
+ final String namespace = getNamespace(leafs);
+ if (namespace == null) {
+ return Code.of(code, separator);
+ }
+ return Code.of(code.substring(namespace.length() + separator.length()), separator);
+ }
+
+ public final Code getFullyQualifiedCode(IGroup g) {
+ if (separator == null) {
+ throw new IllegalArgumentException();
+ }
+ final String full = this.getFullName();
+ if (full.startsWith(separator)) {
+ return Code.of(full.substring(separator.length()), separator);
+ }
+ if (full.contains(separator)) {
+ return Code.of(full, separator);
+ }
+ if (EntityUtils.groupRoot(g)) {
+ return Code.of(full, separator);
+ }
+ final Code namespace2 = g.getNamespace2();
+ if (namespace2 == null) {
+ return Code.of(full, separator);
+ }
+ return Code.of(namespace2.fullName + separator + full, separator);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/CucaDiagram.java b/src/net/sourceforge/plantuml/cucadiagram/CucaDiagram.java
new file mode 100644
index 0000000..568debb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/CucaDiagram.java
@@ -0,0 +1,590 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import net.sourceforge.plantuml.FileFormat;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.Log;
+import net.sourceforge.plantuml.OptionFlags;
+import net.sourceforge.plantuml.UmlDiagram;
+import net.sourceforge.plantuml.UmlDiagramType;
+import net.sourceforge.plantuml.api.ImageDataSimple;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.cucadiagram.dot.CucaDiagramTxtMaker;
+import net.sourceforge.plantuml.cucadiagram.entity.EntityFactory;
+import net.sourceforge.plantuml.graphic.USymbol;
+import net.sourceforge.plantuml.hector2.CucaDiagramFileMakerHectorC1;
+import net.sourceforge.plantuml.skin.VisibilityModifier;
+import net.sourceforge.plantuml.svek.CucaDiagramFileMaker;
+import net.sourceforge.plantuml.svek.CucaDiagramFileMakerSvek;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.xmi.CucaDiagramXmiMaker;
+
+public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, PortionShower {
+
+ private int horizontalPages = 1;
+ private int verticalPages = 1;
+ private final Set<LeafType> hiddenType = new HashSet<LeafType>();
+
+ protected final EntityFactory entityFactory = new EntityFactory(hiddenType);
+ protected IGroup currentGroup = entityFactory.getRootGroup();
+
+ private boolean visibilityModifierPresent;
+
+ public abstract IEntity getOrCreateLeaf(Code code, LeafType type, USymbol symbol);
+
+ public String getNamespaceSeparator() {
+ return null;
+ }
+
+ @Override
+ public boolean hasUrl() {
+ for (IEntity entity : getGroups(true)) {
+ if (entity.hasUrl()) {
+ return true;
+ }
+ }
+ for (IEntity entity : getLeafs().values()) {
+ if (entity.hasUrl()) {
+ return true;
+ }
+ }
+ for (Link link : getLinks()) {
+ if (link.hasUrl()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ // public ILeaf getOrCreateLeaf1(Code code, LeafType type) {
+ // return getOrCreateLeaf1Default(code, type);
+ // }
+
+ final protected ILeaf getOrCreateLeafDefault(Code code, LeafType type, USymbol symbol) {
+ if (type == null) {
+ throw new IllegalArgumentException();
+ }
+ ILeaf result = getLeafs().get(code);
+ if (result == null) {
+ result = createLeafInternal(code, Display.getWithNewlines(code), type, getCurrentGroup(), symbol);
+ result.setUSymbol(symbol);
+ }
+ this.lastEntity = result;
+ return result;
+ }
+
+ public ILeaf createLeaf(Code code, Display display, LeafType type, USymbol symbol) {
+ if (getLeafs().containsKey(code)) {
+ throw new IllegalArgumentException("Already known: " + code);
+ }
+ return createLeafInternal(code, display, type, getCurrentGroup(), symbol);
+ }
+
+ final protected ILeaf createLeafInternal(Code code, Display display, LeafType type, IGroup group, USymbol symbol) {
+ if (display == null) {
+ display = Display.getWithNewlines(code);
+ }
+ final ILeaf leaf = entityFactory.createLeaf(code, display, type, group, getHides(), getNamespaceSeparator());
+ entityFactory.addLeaf(leaf);
+ this.lastEntity = leaf;
+ leaf.setUSymbol(symbol);
+ return leaf;
+ }
+
+ public boolean leafExist(Code code) {
+ return getLeafs().containsKey(code);
+ }
+
+ final public Collection<IGroup> getChildrenGroups(IGroup parent) {
+ final Collection<IGroup> result = new ArrayList<IGroup>();
+ for (IGroup gg : getGroups(false)) {
+ if (gg.getParentContainer() == parent) {
+ result.add(gg);
+ }
+ }
+ return Collections.unmodifiableCollection(result);
+ }
+
+ final public IGroup getOrCreateGroup(Code code, Display display, GroupType type, IGroup parent) {
+ final IGroup g = getOrCreateGroupInternal(code, display, null, type, parent);
+ currentGroup = g;
+ return g;
+ }
+
+ private IGroup getOrCreateGroupInternal(Code code, Display display, Code namespace2, GroupType type,
+ IGroup parent) {
+ IGroup result = entityFactory.getGroups().get(code);
+ if (result != null) {
+ return result;
+ }
+ if (entityFactory.getLeafs().containsKey(code)) {
+ result = entityFactory.muteToGroup(code, namespace2, type, parent);
+ result.setDisplay(display);
+ } else {
+ result = entityFactory.createGroup(code, display, namespace2, type, parent, getHides(),
+ getNamespaceSeparator());
+ }
+ entityFactory.addGroup(result);
+ return result;
+ }
+
+ public final IGroup getCurrentGroup() {
+ return currentGroup;
+ }
+
+ public final IGroup getGroup(Code code) {
+ final IGroup p = entityFactory.getGroups().get(code);
+ if (p == null) {
+ throw new IllegalArgumentException();
+ // return null;
+ }
+ return p;
+ }
+
+ public void endGroup() {
+ if (EntityUtils.groupRoot(currentGroup)) {
+ Log.error("No parent group");
+ return;
+ }
+ currentGroup = currentGroup.getParentContainer();
+ }
+
+ public final boolean isGroup(Code code) {
+ return entityFactory.getGroups().containsKey(code);
+ }
+
+ public final Collection<IGroup> getGroups(boolean withRootGroup) {
+ if (withRootGroup == false) {
+ return entityFactory.getGroups().values();
+ }
+ final Collection<IGroup> result = new ArrayList<IGroup>();
+ result.add(getRootGroup());
+ result.addAll(entityFactory.getGroups().values());
+ return Collections.unmodifiableCollection(result);
+ }
+
+ public IGroup getRootGroup() {
+ return entityFactory.getRootGroup();
+
+ }
+
+ final protected Map<Code, ILeaf> getLeafs() {
+ return entityFactory.getLeafs();
+ }
+
+ public Collection<ILeaf> getLeafsvalues() {
+ return getLeafs().values();
+ }
+
+ public final int getLeafssize() {
+ return getLeafs().size();
+ }
+
+ public final ILeaf getLeafsget(Code code) {
+ return getLeafs().get(code);
+ }
+
+ final public void addLink(Link link) {
+ entityFactory.addLink(link);
+ }
+
+ final protected void removeLink(Link link) {
+ entityFactory.removeLink(link);
+ }
+
+ final public List<Link> getLinks() {
+ return entityFactory.getLinks();
+ }
+
+ final public int getHorizontalPages() {
+ return horizontalPages;
+ }
+
+ final public void setHorizontalPages(int horizontalPages) {
+ this.horizontalPages = horizontalPages;
+ }
+
+ final public int getVerticalPages() {
+ return verticalPages;
+ }
+
+ final public void setVerticalPages(int verticalPages) {
+ this.verticalPages = verticalPages;
+ }
+
+ // final public List<File> createPng2(File pngFile) throws IOException, InterruptedException {
+ // final CucaDiagramPngMaker3 maker = new CucaDiagramPngMaker3(this);
+ // return maker.createPng(pngFile);
+ // }
+ //
+ // final public void createPng2(OutputStream os) throws IOException {
+ // final CucaDiagramPngMaker3 maker = new CucaDiagramPngMaker3(this);
+ // maker.createPng(os);
+ // }
+
+ abstract protected List<String> getDotStrings();
+
+ final public String[] getDotStringSkek() {
+ final List<String> result = new ArrayList<String>();
+ for (String s : getDotStrings()) {
+ if (s.startsWith("nodesep") || s.startsWith("ranksep")) {
+ result.add(s);
+ }
+ }
+ final String aspect = getPragma().getValue("aspect");
+ if (aspect != null) {
+ result.add("aspect=" + aspect + ";");
+ }
+ return result.toArray(new String[result.size()]);
+ }
+
+ private void createFilesXmi(OutputStream suggestedFile, FileFormat fileFormat) throws IOException {
+ final CucaDiagramXmiMaker maker = new CucaDiagramXmiMaker(this, fileFormat);
+ maker.createFiles(suggestedFile);
+ }
+
+ @Override
+ protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption)
+ throws IOException {
+ final FileFormat fileFormat = fileFormatOption.getFileFormat();
+
+ if (fileFormat == FileFormat.ATXT || fileFormat == FileFormat.UTXT) {
+ try {
+ createFilesTxt(os, index, fileFormat);
+ } catch (Throwable t) {
+ t.printStackTrace(new PrintStream(os));
+ }
+ return new ImageDataSimple();
+ }
+
+ if (fileFormat.name().startsWith("XMI")) {
+ createFilesXmi(os, fileFormat);
+ return new ImageDataSimple();
+ }
+
+ if (getUmlDiagramType() == UmlDiagramType.COMPOSITE) {
+ throw new UnsupportedOperationException();
+ }
+
+ final CucaDiagramFileMaker maker = OptionFlags.USE_HECTOR ? new CucaDiagramFileMakerHectorC1(this)
+ : new CucaDiagramFileMakerSvek(this);
+ final ImageData result = maker.createFile(os, getDotStrings(), fileFormatOption);
+
+ if (result == null) {
+ return new ImageDataSimple();
+ }
+ this.warningOrError = result.getWarningOrError();
+ return result;
+ }
+
+ private String warningOrError;
+
+ @Override
+ public String getWarningOrError() {
+ final String generalWarningOrError = super.getWarningOrError();
+ if (warningOrError == null) {
+ return generalWarningOrError;
+ }
+ if (generalWarningOrError == null) {
+ return warningOrError;
+ }
+ return generalWarningOrError + "\n" + warningOrError;
+ }
+
+ private void createFilesTxt(OutputStream os, int index, FileFormat fileFormat) throws IOException {
+ final CucaDiagramTxtMaker maker = new CucaDiagramTxtMaker(this, fileFormat);
+ maker.createFiles(os, index);
+ }
+
+ // public final Rankdir getRankdir() {
+ // return rankdir;
+ // }
+ //
+ // public final void setRankdir(Rankdir rankdir) {
+ // this.rankdir = rankdir;
+ // }
+
+ public boolean isAutarkic(IGroup g) {
+ if (g.getGroupType() == GroupType.PACKAGE) {
+ return false;
+ }
+ if (g.getGroupType() == GroupType.INNER_ACTIVITY) {
+ return true;
+ }
+ if (g.getGroupType() == GroupType.CONCURRENT_ACTIVITY) {
+ return true;
+ }
+ if (g.getGroupType() == GroupType.CONCURRENT_STATE) {
+ return true;
+ }
+ if (getChildrenGroups(g).size() > 0) {
+ return false;
+ }
+ for (Link link : getLinks()) {
+ if (EntityUtils.isPureInnerLink3(g, link) == false) {
+ return false;
+ }
+ }
+ for (ILeaf leaf : g.getLeafsDirect()) {
+ if (leaf.getEntityPosition() != EntityPosition.NORMAL) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private static boolean isNumber(String s) {
+ return s.matches("[+-]?(\\.?\\d+|\\d+\\.\\d*)");
+ }
+
+ public void resetPragmaLabel() {
+ getPragma().undefine("labeldistance");
+ getPragma().undefine("labelangle");
+ }
+
+ public String getLabeldistance() {
+ if (getPragma().isDefine("labeldistance")) {
+ final String s = getPragma().getValue("labeldistance");
+ if (isNumber(s)) {
+ return s;
+ }
+ }
+ if (getPragma().isDefine("defaultlabeldistance")) {
+ final String s = getPragma().getValue("defaultlabeldistance");
+ if (isNumber(s)) {
+ return s;
+ }
+ }
+ // Default in dot 1.0
+ return "1.7";
+ }
+
+ public String getLabelangle() {
+ if (getPragma().isDefine("labelangle")) {
+ final String s = getPragma().getValue("labelangle");
+ if (isNumber(s)) {
+ return s;
+ }
+ }
+ if (getPragma().isDefine("defaultlabelangle")) {
+ final String s = getPragma().getValue("defaultlabelangle");
+ if (isNumber(s)) {
+ return s;
+ }
+ }
+ // Default in dot -25
+ return "25";
+ }
+
+ final public boolean isEmpty(IGroup gToTest) {
+ for (IEntity gg : getGroups(false)) {
+ if (gg == gToTest) {
+ continue;
+ }
+ if (gg.getParentContainer() == gToTest) {
+ return false;
+ }
+ }
+ return gToTest.size() == 0;
+ }
+
+ public final boolean isVisibilityModifierPresent() {
+ return visibilityModifierPresent;
+ }
+
+ public final void setVisibilityModifierPresent(boolean visibilityModifierPresent) {
+ this.visibilityModifierPresent = visibilityModifierPresent;
+ }
+
+ public final boolean showPortion(EntityPortion portion, IEntity entity) {
+ if (getSkinParam().strictUmlStyle() && portion == EntityPortion.CIRCLED_CHARACTER) {
+ return false;
+ }
+ boolean result = true;
+ for (HideOrShow cmd : hideOrShows) {
+ if (cmd.portion == portion && cmd.gender.contains(entity)) {
+ result = cmd.show;
+ }
+ }
+ return result;
+ }
+
+ public final void hideOrShow(EntityGender gender, Set<EntityPortion> portions, boolean show) {
+ for (EntityPortion portion : portions) {
+ this.hideOrShows.add(new HideOrShow(gender, portion, show));
+ }
+ }
+
+ public void hideOrShow(Set<VisibilityModifier> visibilities, boolean show) {
+ if (show) {
+ hides.removeAll(visibilities);
+ } else {
+ hides.addAll(visibilities);
+ }
+ }
+
+ public void hideOrShow(ILeaf leaf, boolean show) {
+ leaf.setRemoved(!show);
+ }
+
+ public void hideOrShow(LeafType leafType, boolean show) {
+ if (show) {
+ hiddenType.remove(leafType);
+ } else {
+ hiddenType.add(leafType);
+ }
+ }
+
+ private final List<HideOrShow> hideOrShows = new ArrayList<HideOrShow>();
+ private final Set<VisibilityModifier> hides = new HashSet<VisibilityModifier>();
+
+ static class HideOrShow {
+ private final EntityGender gender;
+ private final EntityPortion portion;
+ private final boolean show;
+
+ public HideOrShow(EntityGender gender, EntityPortion portion, boolean show) {
+ this.gender = gender;
+ this.portion = portion;
+ this.show = show;
+ }
+ }
+
+ @Override
+ public int getNbImages() {
+ return this.horizontalPages * this.verticalPages;
+ }
+
+ public final Set<VisibilityModifier> getHides() {
+ return Collections.unmodifiableSet(hides);
+ }
+
+ public ColorMapper getColorMapper() {
+ return getSkinParam().getColorMapper();
+ }
+
+ final public boolean isStandalone(IEntity ent) {
+ for (final Link link : getLinks()) {
+ if (link.getEntity1() == ent || link.getEntity2() == ent) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ final public Link getLastLink() {
+ final List<Link> links = getLinks();
+ for (int i = links.size() - 1; i >= 0; i--) {
+ final Link link = links.get(i);
+ if (link.getEntity1().getEntityType() != LeafType.NOTE
+ && link.getEntity2().getEntityType() != LeafType.NOTE) {
+ return link;
+ }
+ }
+ return null;
+ }
+
+ private ILeaf lastEntity = null;
+
+ final public ILeaf getLastEntity() {
+ // for (final Iterator<ILeaf> it = getLeafs().values().iterator(); it.hasNext();) {
+ // final ILeaf ent = it.next();
+ // if (it.hasNext() == false) {
+ // return ent;
+ // }
+ // }
+ // return null;
+ return lastEntity;
+ }
+
+ final public EntityFactory getEntityFactory() {
+ return entityFactory;
+ }
+
+ public void applySingleStrategy() {
+ final MagmaList magmaList = new MagmaList();
+
+ for (IGroup g : getGroups(true)) {
+ final List<ILeaf> standalones = new ArrayList<ILeaf>();
+ // final SingleStrategy singleStrategy = g.getSingleStrategy();
+
+ for (ILeaf ent : g.getLeafsDirect()) {
+ if (isStandalone(ent)) {
+ standalones.add(ent);
+ }
+ }
+ if (standalones.size() < 3) {
+ continue;
+ }
+ final Magma magma = new Magma(this, standalones);
+ magma.putInSquare();
+ magmaList.add(magma);
+
+ // for (Link link : singleStrategy.generateLinks(standalones)) {
+ // addLink(link);
+ // }
+ }
+
+ for (IGroup g : getGroups(true)) {
+ final MagmaList magmas = magmaList.getMagmas(g);
+ if (magmas.size() < 3) {
+ continue;
+ }
+ magmas.putInSquare();
+ }
+
+ }
+
+ public boolean isHideEmptyDescriptionForState() {
+ return false;
+ }
+
+ protected void incRawLayout() {
+ entityFactory.incRawLayout();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/Display.java b/src/net/sourceforge/plantuml/cucadiagram/Display.java
new file mode 100644
index 0000000..4fe93ca
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/Display.java
@@ -0,0 +1,271 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import net.sourceforge.plantuml.EmbededDiagram;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+
+public class Display implements Iterable<CharSequence> {
+
+ private final List<CharSequence> display = new ArrayList<CharSequence>();
+ private final HorizontalAlignment naturalHorizontalAlignment;
+
+ public boolean isWhite() {
+ return display.size() == 0 || (display.size() == 1 && display.get(0).toString().matches("\\s*"));
+ }
+
+ public static Display empty() {
+ return new Display((HorizontalAlignment) null);
+ }
+
+ public static Display create(CharSequence... s) {
+ return create(Arrays.asList(s));
+ }
+
+ public static Display create(List<? extends CharSequence> other) {
+ return new Display(other, null);
+ }
+
+ public static Display getWithNewlines(Code s) {
+ return getWithNewlines(s.getFullName());
+ }
+
+ public static Display getWithNewlines(String s) {
+ if (s == null) {
+ return null;
+ }
+ final List<String> result = new ArrayList<String>();
+ final StringBuilder current = new StringBuilder();
+ HorizontalAlignment naturalHorizontalAlignment = null;
+ for (int i = 0; i < s.length(); i++) {
+ final char c = s.charAt(i);
+ if (c == '\\' && i < s.length() - 1) {
+ final char c2 = s.charAt(i + 1);
+ i++;
+ if (c2 == 'n' || c2 == 'r' || c2 == 'l') {
+ if (c2 == 'r') {
+ naturalHorizontalAlignment = HorizontalAlignment.RIGHT;
+ } else if (c2 == 'l') {
+ naturalHorizontalAlignment = HorizontalAlignment.LEFT;
+ }
+ result.add(current.toString());
+ current.setLength(0);
+ } else if (c2 == 't') {
+ current.append('\t');
+ } else if (c2 == '\\') {
+ current.append(c2);
+ } else {
+ current.append(c);
+ current.append(c2);
+ }
+ } else {
+ current.append(c);
+ }
+ }
+ result.add(current.toString());
+ return new Display(result, naturalHorizontalAlignment);
+ }
+
+ private Display(Display other) {
+ this(other.naturalHorizontalAlignment);
+ this.display.addAll(other.display);
+ }
+
+ private Display(HorizontalAlignment naturalHorizontalAlignment) {
+ this.naturalHorizontalAlignment = naturalHorizontalAlignment;
+ }
+
+ private Display(List<? extends CharSequence> other, HorizontalAlignment naturalHorizontalAlignment) {
+ this(naturalHorizontalAlignment);
+ this.display.addAll(manageEmbededDiagrams2(other));
+ }
+
+ private static List<CharSequence> manageEmbededDiagrams2(final List<? extends CharSequence> strings) {
+ final List<CharSequence> result = new ArrayList<CharSequence>();
+ final Iterator<? extends CharSequence> it = strings.iterator();
+ while (it.hasNext()) {
+ CharSequence s = it.next();
+ if (s != null && s.toString().trim().equals("{{")) {
+ final List<CharSequence> other = new ArrayList<CharSequence>();
+ other.add("@startuml");
+ while (it.hasNext()) {
+ final CharSequence s2 = it.next();
+ if (s2 != null && s2.toString().trim().equals("}}")) {
+ break;
+ }
+ other.add(s2);
+ }
+ other.add("@enduml");
+ s = new EmbededDiagram(Display.create(other));
+ }
+ result.add(s);
+ }
+ return result;
+ }
+
+ public Display underlined() {
+ final List<CharSequence> result = new ArrayList<CharSequence>();
+ for (CharSequence line : display) {
+ result.add("<u>" + line);
+ }
+ return new Display(result, this.naturalHorizontalAlignment);
+ }
+
+ @Override
+ public String toString() {
+ return display.toString();
+ }
+
+ @Override
+ public int hashCode() {
+ return display.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ return this.display.equals(((Display) other).display);
+ }
+
+ public Display addAll(Display other) {
+ final Display result = new Display(this);
+ result.display.addAll(other.display);
+ return result;
+ }
+
+ public Display addFirst(CharSequence s) {
+ final Display result = new Display(this);
+ result.display.add(0, s);
+ return result;
+ }
+
+ public Display add(CharSequence s) {
+ final Display result = new Display(this);
+ result.display.add(s);
+ return result;
+ }
+
+ private boolean firstColumnRemovable() {
+ boolean allEmpty = true;
+ for (CharSequence s : this) {
+ if (s.length() == 0) {
+ continue;
+ }
+ allEmpty = false;
+ final char c = s.charAt(0);
+ if (c != ' ' && c != '\t') {
+ return false;
+ }
+ }
+ return allEmpty == false;
+ }
+
+ public Display removeEmptyColumns() {
+ if (firstColumnRemovable() == false) {
+ return this;
+ }
+ final Display result = new Display(this);
+ do {
+ for (int i = 0; i < result.size(); i++) {
+ final CharSequence s = result.get(i);
+ if (s.length() > 0) {
+ result.display.set(i, s.toString().substring(1));
+ }
+ }
+ } while (result.firstColumnRemovable());
+ return result;
+ }
+
+ public int size() {
+ return display.size();
+ }
+
+ public CharSequence get(int i) {
+ return display.get(i);
+ }
+
+ public Iterator<CharSequence> iterator() {
+ return Collections.unmodifiableList(display).iterator();
+ }
+
+ public Display subList(int i, int size) {
+ return new Display(display.subList(i, size), this.naturalHorizontalAlignment);
+ }
+
+ public List<? extends CharSequence> as() {
+ return Collections.unmodifiableList(display);
+ }
+
+ public Url initUrl() {
+ if (this.size() == 0) {
+ return null;
+ }
+ final UrlBuilder urlBuilder = new UrlBuilder(null, ModeUrl.AT_START);
+ return urlBuilder.getUrl(this.get(0).toString().trim());
+ }
+
+ public Display removeUrl(Url url) {
+ if (url == null) {
+ return this;
+ }
+ final Display result = new Display(this.naturalHorizontalAlignment);
+ result.display.add(UrlBuilder.purgeUrl(this.get(0).toString()));
+ result.display.addAll(this.subList(1, this.size()).display);
+ return result;
+ }
+
+ public boolean hasUrl() {
+ final UrlBuilder urlBuilder = new UrlBuilder(null, ModeUrl.ANYWHERE);
+ for (CharSequence s : this) {
+ if (urlBuilder.getUrl(s.toString()) != null) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public HorizontalAlignment getNaturalHorizontalAlignment() {
+ return naturalHorizontalAlignment;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/Display2.java b/src/net/sourceforge/plantuml/cucadiagram/Display2.java
new file mode 100644
index 0000000..bb8884c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/Display2.java
@@ -0,0 +1,241 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
+
+public class Display2 implements Iterable<CharSequence> {
+
+ private final List<CharSequence> display = new ArrayList<CharSequence>();
+
+ public static Display2 empty() {
+ return new Display2();
+ }
+
+ public static Display2 create(CharSequence... s) {
+ if (s.length==1 && s[0]==null) {
+ return empty();
+ }
+ return new Display2(Arrays.asList(s));
+ }
+
+ public static Display2 create(List<? extends CharSequence> other) {
+ return new Display2(other);
+ }
+
+ public static Display2 getWithNewlines(Code s) {
+ return getWithNewlines(s.getFullName());
+ }
+
+ public static Display2 getWithNewlines(String s) {
+ if (s == null) {
+ return null;
+ }
+ final Display2 result = new Display2();
+ result.display.addAll(getWithNewlinesInternal(s));
+ return result;
+ }
+
+ private Display2(List<? extends CharSequence> other) {
+ for (CharSequence s : other) {
+ this.display.addAll(getWithNewlinesInternal(s));
+ }
+ }
+
+ private Display2(Display2 other) {
+ this.display.addAll(other.display);
+ }
+
+ private Display2() {
+ }
+
+ public Display2 underlined() {
+ final List<CharSequence> result = new ArrayList<CharSequence>();
+ for (CharSequence line : display) {
+ result.add("<u>" + line);
+ }
+ return new Display2(result);
+ }
+
+ @Override
+ public String toString() {
+ return display.toString();
+ }
+
+ @Override
+ public int hashCode() {
+ return display.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ return this.display.equals(((Display2) other).display);
+ }
+
+ public Display2 addAll(Display2 other) {
+ final Display2 result = new Display2(this);
+ result.display.addAll(other.display);
+ return result;
+ }
+
+ public Display2 addFirst(CharSequence s) {
+ final Display2 result = new Display2(this);
+ result.display.addAll(0, getWithNewlinesInternal(s));
+ return result;
+ }
+
+ public Display2 add(CharSequence s) {
+ final Display2 result = new Display2(this);
+ result.display.addAll(getWithNewlinesInternal(s));
+ return result;
+ }
+
+ private boolean firstColumnRemovable() {
+ boolean allEmpty = true;
+ for (CharSequence s : this) {
+ if (s.length() == 0) {
+ continue;
+ }
+ allEmpty = false;
+ final char c = s.charAt(0);
+ if (c != ' ' && c != '\t') {
+ return false;
+ }
+ }
+ return allEmpty == false;
+ }
+
+ public Display2 removeEmptyColumns() {
+ if (firstColumnRemovable() == false) {
+ return this;
+ }
+ final Display2 result = new Display2(this);
+ do {
+ for (int i = 0; i < result.size(); i++) {
+ final CharSequence s = result.get(i);
+ if (s.length() > 0) {
+ result.display.set(i, s.toString().substring(1));
+ }
+ }
+ } while (result.firstColumnRemovable());
+ return result;
+ }
+
+ public int size() {
+ return display.size();
+ }
+
+ public CharSequence get(int i) {
+ return display.get(i);
+ }
+
+ public Iterator<CharSequence> iterator() {
+ return Collections.unmodifiableList(display).iterator();
+ }
+
+ public Display2 subList(int i, int size) {
+ final Display2 result = new Display2();
+ result.display.addAll(display.subList(i, size));
+ return result;
+ }
+
+ public List<? extends CharSequence> as() {
+ return Collections.unmodifiableList(display);
+ }
+
+ private static List<String> getWithNewlinesInternal(CharSequence s) {
+ final List<String> result = new ArrayList<String>();
+ final StringBuilder current = new StringBuilder();
+ for (int i = 0; i < s.length(); i++) {
+ final char c = s.charAt(i);
+ if (c == '\\' && i < s.length() - 1) {
+ final char c2 = s.charAt(i + 1);
+ i++;
+ if (c2 == 'n') {
+ result.add(current.toString());
+ current.setLength(0);
+ } else if (c2 == 't') {
+ current.append('\t');
+ } else if (c2 == '\\') {
+ current.append(c2);
+ } else {
+ current.append(c);
+ current.append(c2);
+ }
+ } else {
+ current.append(c);
+ }
+ }
+ result.add(current.toString());
+ return result;
+ }
+
+ public Url initUrl() {
+ if (this.size() == 0) {
+ return null;
+ }
+ final UrlBuilder urlBuilder = new UrlBuilder(null, ModeUrl.AT_START);
+ return urlBuilder.getUrl(this.get(0).toString().trim());
+ }
+
+ public Display2 removeUrl(Url url) {
+ if (url == null) {
+ return this;
+ }
+ final Display2 result = new Display2();
+ result.display.add(UrlBuilder.purgeUrl(this.get(0).toString()));
+ result.display.addAll(this.subList(1, this.size()).display);
+ return result;
+ }
+
+ public boolean hasUrl() {
+ final UrlBuilder urlBuilder = new UrlBuilder(null, ModeUrl.ANYWHERE);
+ for (CharSequence s : this) {
+ if (urlBuilder.getUrl(s.toString()) != null) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/EntityGender.java b/src/net/sourceforge/plantuml/cucadiagram/EntityGender.java
new file mode 100644
index 0000000..23d90a5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/EntityGender.java
@@ -0,0 +1,39 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+public interface EntityGender {
+ public boolean contains(IEntity test);
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/EntityGenderUtils.java b/src/net/sourceforge/plantuml/cucadiagram/EntityGenderUtils.java
new file mode 100644
index 0000000..3c6acc4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/EntityGenderUtils.java
@@ -0,0 +1,124 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+public class EntityGenderUtils {
+
+ static public EntityGender byEntityType(final LeafType type) {
+ return new EntityGender() {
+ public boolean contains(IEntity test) {
+ return test.getEntityType() == type;
+ }
+ };
+ }
+
+ static public EntityGender byEntityAlone(final IEntity entity) {
+ return new EntityGender() {
+ public boolean contains(IEntity test) {
+ return test.getUid().equals(entity.getUid());
+ }
+ };
+ }
+
+ static public EntityGender byStereotype(final String stereotype) {
+ return new EntityGender() {
+ public boolean contains(IEntity test) {
+ if (test.getStereotype() == null) {
+ return false;
+ }
+ return stereotype.equals(test.getStereotype().getLabel(false));
+ }
+ };
+ }
+
+ static public EntityGender byPackage(final IGroup group) {
+ if (EntityUtils.groupRoot(group)) {
+ throw new IllegalArgumentException();
+ }
+ return new EntityGender() {
+ public boolean contains(IEntity test) {
+ if (EntityUtils.groupRoot(test.getParentContainer())) {
+ return false;
+ }
+ if (group == test.getParentContainer()) {
+ return true;
+ }
+ return false;
+ }
+ };
+ }
+
+ static public EntityGender and(final EntityGender g1, final EntityGender g2) {
+ return new EntityGender() {
+ public boolean contains(IEntity test) {
+ return g1.contains(test) && g2.contains(test);
+ }
+ };
+ }
+
+
+ static public EntityGender all() {
+ return new EntityGender() {
+ public boolean contains(IEntity test) {
+ return true;
+ }
+ };
+ }
+
+ static public EntityGender emptyMethods() {
+ return new EntityGender() {
+ public boolean contains(IEntity test) {
+ return test.getMethodsToDisplay().size()==0;
+ }
+ };
+ }
+
+ static public EntityGender emptyFields() {
+ return new EntityGender() {
+ public boolean contains(IEntity test) {
+ return test.getFieldsToDisplay().size()==0;
+ }
+ };
+ }
+
+ static public EntityGender emptyMembers() {
+ return new EntityGender() {
+ public boolean contains(IEntity test) {
+ return test.getMethodsToDisplay().size()==0 && test.getFieldsToDisplay().size()==0;
+ }
+ };
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/EntityPortion.java b/src/net/sourceforge/plantuml/cucadiagram/EntityPortion.java
new file mode 100644
index 0000000..bd8f321
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/EntityPortion.java
@@ -0,0 +1,39 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+public enum EntityPortion {
+ FIELD, METHOD, CIRCLED_CHARACTER, STEREOTYPE, LOLLIPOP, ENTIRELY
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/EntityPosition.java b/src/net/sourceforge/plantuml/cucadiagram/EntityPosition.java
new file mode 100644
index 0000000..ed34fef
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/EntityPosition.java
@@ -0,0 +1,40 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+public enum EntityPosition {
+
+ NORMAL, ENTRY_POINT, EXIT_POINT
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/EntityUtils.java b/src/net/sourceforge/plantuml/cucadiagram/EntityUtils.java
new file mode 100644
index 0000000..db1fda3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/EntityUtils.java
@@ -0,0 +1,94 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+
+public abstract class EntityUtils {
+
+ public static boolean groupRoot(IGroup g) {
+ if (g == null) {
+ throw new IllegalStateException();
+ }
+ return g instanceof GroupRoot;
+ }
+
+ private static boolean isParent(IGroup groupToBeTested, IGroup parentGroup) {
+ if (groupToBeTested.isGroup() == false) {
+ // Very strange!
+ return false;
+ }
+ if (groupToBeTested.isGroup() == false) {
+ throw new IllegalArgumentException();
+ }
+ while (EntityUtils.groupRoot(groupToBeTested) == false) {
+ if (groupToBeTested == parentGroup) {
+ return true;
+ }
+ groupToBeTested = groupToBeTested.getParentContainer();
+ if (groupToBeTested.isGroup() == false) {
+ throw new IllegalStateException();
+ }
+ }
+ return false;
+ }
+
+ public static boolean isPureInnerLink12(IGroup group, Link link) {
+ if (group.isGroup() == false) {
+ throw new IllegalArgumentException();
+ }
+ final IEntity e1 = link.getEntity1();
+ final IEntity e2 = link.getEntity2();
+ final IGroup group1 = e1.getParentContainer();
+ final IGroup group2 = e2.getParentContainer();
+ if (isParent(group1, group) && isParent(group2, group)) {
+ return true;
+ }
+ return false;
+ }
+
+ public static boolean isPureInnerLink3(IGroup group, Link link) {
+ if (group.isGroup() == false) {
+ throw new IllegalArgumentException();
+ }
+ final IEntity e1 = link.getEntity1();
+ final IEntity e2 = link.getEntity2();
+ final IGroup group1 = e1.getParentContainer();
+ final IGroup group2 = e2.getParentContainer();
+ if (isParent(group2, group) == isParent(group1, group)) {
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/GroupHierarchy.java b/src/net/sourceforge/plantuml/cucadiagram/GroupHierarchy.java
new file mode 100644
index 0000000..67228c1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/GroupHierarchy.java
@@ -0,0 +1,44 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+import java.util.Collection;
+
+public interface GroupHierarchy {
+
+ public Collection<IGroup> getChildrenGroups(IGroup parent);
+
+ public boolean isEmpty(IGroup g);
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/GroupPrinter.java b/src/net/sourceforge/plantuml/cucadiagram/GroupPrinter.java
new file mode 100644
index 0000000..6e3a0cb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/GroupPrinter.java
@@ -0,0 +1,97 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+public class GroupPrinter {
+
+ private final PrintWriter pw;
+
+ private GroupPrinter(PrintWriter pw) {
+ this.pw = pw;
+ }
+
+ private void printGroup(IGroup group) {
+ pw.println("<table border=1 cellpadding=8 cellspacing=0>");
+ pw.println("<tr>");
+ pw.println("<td bgcolor=#DDDDDD>");
+ pw.println(group.getCode());
+ pw.println("<tr>");
+ pw.println("<td>");
+ if (group.getLeafsDirect().size() == 0) {
+ pw.println("<i>No direct leaf</i>");
+ } else {
+ for (ILeaf leaf : group.getLeafsDirect()) {
+ pw.println("<ul>");
+ printLeaf(leaf);
+ pw.println("</ul>");
+ }
+ }
+ pw.println("</td>");
+ pw.println("</tr>");
+ if (group.getChildren().size() > 0) {
+ pw.println("<tr>");
+ pw.println("<td>");
+ for (IGroup g : group.getChildren()) {
+ pw.println("<br>");
+ printGroup(g);
+ pw.println("<br>");
+ }
+ pw.println("</td>");
+ pw.println("</tr>");
+ }
+ pw.println("</table>");
+ }
+
+ private void printLeaf(ILeaf leaf) {
+ pw.println("<li>" + leaf.getCode());
+ }
+
+ public static void print(File f, IGroup rootGroup) {
+ try {
+ final PrintWriter pw = new PrintWriter(f);
+ pw.println("<html>");
+ new GroupPrinter(pw).printGroup(rootGroup);
+ pw.println("</html>");
+ pw.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/GroupRoot.java b/src/net/sourceforge/plantuml/cucadiagram/GroupRoot.java
new file mode 100644
index 0000000..bb9441a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/GroupRoot.java
@@ -0,0 +1,281 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.cucadiagram.entity.EntityFactory;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.USymbol;
+import net.sourceforge.plantuml.svek.IEntityImage;
+import net.sourceforge.plantuml.svek.PackageStyle;
+import net.sourceforge.plantuml.svek.SingleStrategy;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+
+public class GroupRoot implements IGroup {
+
+ private final EntityFactory entityFactory;
+
+ public GroupRoot(EntityFactory entityFactory) {
+ this.entityFactory = entityFactory;
+ }
+
+ public Collection<ILeaf> getLeafsDirect() {
+ final List<ILeaf> result = new ArrayList<ILeaf>();
+ for (ILeaf ent : entityFactory.getLeafs().values()) {
+ if (ent.getParentContainer() == this) {
+ result.add(ent);
+ }
+ }
+ return Collections.unmodifiableCollection(result);
+
+ }
+
+ public boolean isGroup() {
+ return true;
+ }
+
+ public Display getDisplay() {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void setDisplay(Display display) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public LeafType getEntityType() {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getUid() {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public Url getUrl99() {
+ return null;
+
+ }
+
+ public Stereotype getStereotype() {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void setStereotype(Stereotype stereotype) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public List<Member> getFieldsToDisplay() {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public List<Member> getMethodsToDisplay() {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public BlockMember getBody(PortionShower portionShower) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public Code getCode() {
+ return Code.of("__ROOT__");
+ }
+
+ public LongCode getLongCode() {
+ return null;
+ }
+
+ public BlockMember getMouseOver() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void addFieldOrMethod(String s) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void mouseOver(String s) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void addUrl(Url url) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public HtmlColor getSpecificBackColor() {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void setSpecificBackcolor(HtmlColor specificBackcolor) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public IGroup getParentContainer() {
+ return null;
+ }
+
+ public boolean containsLeafRecurse(ILeaf entity) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public Collection<IGroup> getChildren() {
+ final List<IGroup> result = new ArrayList<IGroup>();
+ for (IGroup ent : entityFactory.getGroups().values()) {
+ if (ent.getParentContainer() == this) {
+ result.add(ent);
+ }
+ }
+ return Collections.unmodifiableCollection(result);
+ }
+
+ public void moveEntitiesTo(IGroup dest) {
+ throw new UnsupportedOperationException();
+ }
+
+ public int size() {
+ throw new UnsupportedOperationException();
+ }
+
+ public GroupType getGroupType() {
+ return null;
+ }
+
+ public Code getNamespace2() {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public boolean isAutonom() {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void setAutonom(boolean autonom) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public PackageStyle getPackageStyle() {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void overideImage(IEntityImage img, LeafType state) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isHidden() {
+ return false;
+ }
+
+ public USymbol getUSymbol() {
+ return null;
+ // throw new UnsupportedOperationException();
+ }
+
+ public void setUSymbol(USymbol symbol) {
+ throw new UnsupportedOperationException();
+ }
+
+ public SingleStrategy getSingleStrategy() {
+ return SingleStrategy.SQUARRE;
+ }
+
+ public boolean isRemoved() {
+ return false;
+ }
+
+ public HtmlColor getSpecificLineColor() {
+ return null;
+ }
+
+ public void setSpecificLineColor(HtmlColor specificLinecolor) {
+ throw new UnsupportedOperationException();
+ }
+
+ public UStroke getSpecificLineStroke() {
+ return null;
+ }
+
+ public void setSpecificLineStroke(UStroke specificLineStoke) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean hasUrl() {
+ return false;
+ }
+
+ public int getHectorLayer() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setHectorLayer(int layer) {
+ throw new UnsupportedOperationException();
+ }
+
+ public FontParam getTitleFontParam() {
+ throw new UnsupportedOperationException();
+ }
+
+ public int getRawLayout() {
+ throw new UnsupportedOperationException();
+ }
+
+ public char getConcurrentSeparator() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setConcurrentSeparator(char separator) {
+ throw new UnsupportedOperationException();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/GroupType.java b/src/net/sourceforge/plantuml/cucadiagram/GroupType.java
new file mode 100644
index 0000000..f7a81a3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/GroupType.java
@@ -0,0 +1,40 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+public enum GroupType {
+
+ PACKAGE, STATE, CONCURRENT_STATE, INNER_ACTIVITY, CONCURRENT_ACTIVITY
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/IEntity.java b/src/net/sourceforge/plantuml/cucadiagram/IEntity.java
new file mode 100644
index 0000000..76696d5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/IEntity.java
@@ -0,0 +1,96 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.Hideable;
+import net.sourceforge.plantuml.LineConfigurable;
+import net.sourceforge.plantuml.Removeable;
+import net.sourceforge.plantuml.SpecificBackcolorable;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.graphic.USymbol;
+
+public interface IEntity extends SpecificBackcolorable, Hideable, Removeable, LineConfigurable {
+
+ public Code getCode();
+
+ public LongCode getLongCode();
+
+ public USymbol getUSymbol();
+
+ public void setUSymbol(USymbol symbol);
+
+ public LeafType getEntityType();
+
+ public Display getDisplay();
+
+ public IGroup getParentContainer();
+
+ public void setDisplay(Display display);
+
+ public String getUid();
+
+ public Url getUrl99();
+
+ public Stereotype getStereotype();
+
+ public void setStereotype(Stereotype stereotype);
+
+ public List<Member> getFieldsToDisplay();
+
+ public List<Member> getMethodsToDisplay();
+
+ public BlockMember getBody(PortionShower portionShower);
+
+ public BlockMember getMouseOver();
+
+ public void addFieldOrMethod(String s);
+
+ public void mouseOver(String s);
+
+ public void addUrl(Url url);
+
+ public boolean isGroup();
+
+ public boolean hasUrl();
+
+ public int getHectorLayer();
+
+ public void setHectorLayer(int layer);
+
+ public int getRawLayout();
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/IGroup.java b/src/net/sourceforge/plantuml/cucadiagram/IGroup.java
new file mode 100644
index 0000000..c321636
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/IGroup.java
@@ -0,0 +1,75 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+import java.util.Collection;
+
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.svek.IEntityImage;
+import net.sourceforge.plantuml.svek.PackageStyle;
+import net.sourceforge.plantuml.svek.SingleStrategy;
+
+public interface IGroup extends IEntity {
+
+ public boolean containsLeafRecurse(ILeaf entity);
+
+ public Collection<ILeaf> getLeafsDirect();
+
+ public Collection<IGroup> getChildren();
+
+ public void moveEntitiesTo(IGroup dest);
+
+ public int size();
+
+ public GroupType getGroupType();
+
+ public Code getNamespace2();
+
+ public boolean isAutonom();
+
+ public void setAutonom(boolean autonom);
+
+ public PackageStyle getPackageStyle();
+
+ public void overideImage(IEntityImage img, LeafType state);
+
+ public SingleStrategy getSingleStrategy();
+
+ public FontParam getTitleFontParam();
+
+ public char getConcurrentSeparator();
+
+ public void setConcurrentSeparator(char separator);
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/ILeaf.java b/src/net/sourceforge/plantuml/cucadiagram/ILeaf.java
new file mode 100644
index 0000000..207b87e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/ILeaf.java
@@ -0,0 +1,75 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+import net.sourceforge.plantuml.cucadiagram.dot.Neighborhood;
+import net.sourceforge.plantuml.graphic.USymbol;
+import net.sourceforge.plantuml.svek.IEntityImage;
+
+public interface ILeaf extends IEntity {
+
+ public EntityPosition getEntityPosition();
+
+ public void setContainer(IGroup container);
+
+ public boolean isTop();
+
+ public void setTop(boolean top);
+
+ public boolean hasNearDecoration();
+
+ public void setNearDecoration(boolean nearDecoration);
+
+ public int getXposition();
+
+ public void setXposition(int pos);
+
+ public IEntityImage getSvekImage();
+
+ public String getGeneric();
+
+ public void muteToType(LeafType newType, USymbol newSymbol);
+
+ public void setGeneric(String generic);
+
+ public void setSvekImage(IEntityImage svekImage);
+
+ public void setRemoved(boolean removed);
+
+ public void setNeighborhood(Neighborhood neighborhood);
+
+ public Neighborhood getNeighborhood();
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/Ident.java b/src/net/sourceforge/plantuml/cucadiagram/Ident.java
new file mode 100644
index 0000000..4adf427
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/Ident.java
@@ -0,0 +1,78 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+import net.sourceforge.plantuml.StringUtils;
+
+public class Ident implements Comparable<Ident> {
+
+ private final String ident;
+
+ private Ident(String ident) {
+ if (ident == null) {
+ throw new IllegalArgumentException();
+ }
+ this.ident = ident;
+ }
+
+ public static Ident of(String code) {
+ return new Ident(code);
+ }
+
+ @Override
+ public String toString() {
+ return ident;
+ }
+
+ @Override
+ public int hashCode() {
+ return ident.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ final Ident other = (Ident) obj;
+ return this.ident.equals(other.ident);
+ }
+
+ public int compareTo(Ident other) {
+ return this.ident.compareTo(other.ident);
+ }
+
+ private Ident eventuallyRemoveStartingAndEndingDoubleQuote() {
+ return Ident.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(ident));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/LeafType.java b/src/net/sourceforge/plantuml/cucadiagram/LeafType.java
new file mode 100644
index 0000000..9db70c3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/LeafType.java
@@ -0,0 +1,84 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+import net.sourceforge.plantuml.StringUtils;
+
+public enum LeafType {
+
+ EMPTY_PACKAGE,
+
+ ABSTRACT_CLASS, CLASS, INTERFACE, ANNOTATION, LOLLIPOP, NOTE, OBJECT, ASSOCIATION, ENUM,
+
+ USECASE,
+
+ DESCRIPTION,
+
+ ARC_CIRCLE,
+
+ ACTIVITY, BRANCH, SYNCHRO_BAR, CIRCLE_START, CIRCLE_END, POINT_FOR_ASSOCIATION, ACTIVITY_CONCURRENT,
+
+ STATE, STATE_CONCURRENT, PSEUDO_STATE, STATE_CHOICE, STATE_FORK_JOIN,
+
+ BLOCK,
+
+ STILL_UNKNOWN;
+
+ public static LeafType getLeafType(String arg0) {
+ arg0 = StringUtils.goUpperCase(arg0);
+ if (arg0.startsWith("ABSTRACT")) {
+ return LeafType.ABSTRACT_CLASS;
+ }
+ return LeafType.valueOf(arg0);
+ }
+
+ public boolean isLikeClass() {
+ return this == LeafType.ANNOTATION || this == LeafType.ABSTRACT_CLASS || this == LeafType.CLASS
+ || this == LeafType.INTERFACE || this == LeafType.ENUM;
+ }
+
+ public String toHtml() {
+ final String html = StringUtils.goLowerCase(toString().replace('_', ' '));
+ return StringUtils.capitalize(html);
+ }
+
+ public boolean manageModifier() {
+ if (this == ANNOTATION || this == ABSTRACT_CLASS || this == CLASS || this == INTERFACE || this == ENUM
+ || this == OBJECT) {
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/Link.java b/src/net/sourceforge/plantuml/cucadiagram/Link.java
new file mode 100644
index 0000000..32cb61c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/Link.java
@@ -0,0 +1,498 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Hideable;
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.OptionFlags;
+import net.sourceforge.plantuml.Removeable;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.command.Position;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorSet;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.graphic.USymbolInterface;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.utils.UniqueSequence;
+
+public class Link implements Hideable, Removeable {
+
+ final private IEntity cl1;
+ final private IEntity cl2;
+ private LinkType type;
+ final private Display label;
+
+ private int length;
+ final private String qualifier1;
+ final private String qualifier2;
+ final private String uid = "LNK" + UniqueSequence.getValue();
+
+ private Display note;
+ private Position notePosition;
+ private HtmlColor noteColor;
+
+ private boolean invis = false;
+ private double weight = 1.0;
+
+ private final String labeldistance;
+ private final String labelangle;
+
+ private HtmlColor specificColor;
+ private boolean constraint = true;
+ private boolean inverted = false;
+ private LinkArrow linkArrow = LinkArrow.NONE;
+
+ private boolean opale;
+ private boolean horizontalSolitary;
+ private String sametail;
+
+ private Url url;
+
+ public Link(IEntity cl1, IEntity cl2, LinkType type, Display label, int length) {
+ this(cl1, cl2, type, label, length, null, null, null, null, null);
+ }
+
+ public Link(IEntity cl1, IEntity cl2, LinkType type, Display label, int length, String qualifier1,
+ String qualifier2, String labeldistance, String labelangle) {
+ this(cl1, cl2, type, label, length, qualifier1, qualifier2, labeldistance, labelangle, null);
+ }
+
+ public Link(IEntity cl1, IEntity cl2, LinkType type, Display label, int length, String qualifier1,
+ String qualifier2, String labeldistance, String labelangle, HtmlColor specificColor) {
+ if (length < 1) {
+ throw new IllegalArgumentException();
+ }
+ if (cl1 == null) {
+ throw new IllegalArgumentException();
+ }
+ if (cl2 == null) {
+ throw new IllegalArgumentException();
+ }
+
+ this.cl1 = cl1;
+ this.cl2 = cl2;
+ this.type = type;
+ if (label == null) {
+ this.label = null;
+ } else if (doWeHaveToRemoveUrlAtStart(label)) {
+ this.url = label.initUrl();
+ this.label = label.removeUrl(url);
+ } else {
+ this.label = label;
+ }
+ this.length = length;
+ this.qualifier1 = qualifier1;
+ this.qualifier2 = qualifier2;
+ this.labeldistance = labeldistance;
+ this.labelangle = labelangle;
+ this.specificColor = specificColor;
+ if (qualifier1 != null) {
+ ((ILeaf) cl1).setNearDecoration(true);
+ }
+ if (qualifier2 != null) {
+ ((ILeaf) cl2).setNearDecoration(true);
+ }
+// if (type.getDecor2() == LinkDecor.EXTENDS) {
+// setSametail(cl1.getUid());
+// }
+ }
+
+ private static boolean doWeHaveToRemoveUrlAtStart(Display label) {
+ if (label.size() == 0) {
+ return false;
+ }
+ final String s = label.get(0).toString();
+ if (s.matches("^\\[\\[\\S+\\]\\].+$")) {
+ return true;
+ }
+ return false;
+ }
+
+ public Link getInv() {
+ // if (getLength() == 1) {
+ // final int x = cl1.getXposition();
+ // cl2.setXposition(x-1);
+ // }
+ final Link result = new Link(cl2, cl1, getType().getInversed(), label, length, qualifier2, qualifier1,
+ labeldistance, labelangle, specificColor);
+ result.inverted = true;
+ return result;
+ }
+
+ public void goDashed() {
+ type = type.getDashed();
+ }
+
+ public void goDotted() {
+ type = type.getDotted();
+ }
+
+ private boolean hidden = false;
+
+ public void goHidden() {
+ this.hidden = true;
+ }
+
+ public void goNorank() {
+ setConstraint(false);
+ }
+
+ public void goBold() {
+ type = type.getBold();
+ }
+
+ public String getLabeldistance() {
+ // Default in dot 1.0
+ return labeldistance;
+ }
+
+ public String getLabelangle() {
+ // Default in dot -25
+ return labelangle;
+ }
+
+ public String getUid() {
+ return uid;
+ }
+
+ public final boolean isInvis() {
+ if (type.isInvisible()) {
+ return true;
+ }
+ return invis;
+ }
+
+ public final void setInvis(boolean invis) {
+ this.invis = invis;
+ }
+
+ public boolean isBetween(IEntity cl1, IEntity cl2) {
+ if (cl1.equals(this.cl1) && cl2.equals(this.cl2)) {
+ return true;
+ }
+ if (cl1.equals(this.cl2) && cl2.equals(this.cl1)) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + " {" + length + "} " + cl1 + "-->" + cl2;
+ }
+
+ public IEntity getEntity1() {
+ return cl1;
+ }
+
+ public IEntity getEntity2() {
+ return cl2;
+ }
+
+ public LinkType getType() {
+ if (opale) {
+ return new LinkType(LinkDecor.NONE, LinkDecor.NONE);
+ }
+ if (getSametail() != null) {
+ return new LinkType(LinkDecor.NONE, LinkDecor.NONE);
+ }
+ LinkType result = type;
+ if (OptionFlags.USE_INTERFACE_EYE1) {
+ if (isLollipopInterfaceEye(cl1)) {
+ type = type.withLollipopInterfaceEye1();
+ }
+ if (isLollipopInterfaceEye(cl2)) {
+ type = type.withLollipopInterfaceEye2();
+ }
+ }
+ return result;
+ }
+
+ private LinkType getTypeSpecialForPrinting() {
+ if (opale) {
+ return new LinkType(LinkDecor.NONE, LinkDecor.NONE);
+ }
+ LinkType result = type;
+ if (OptionFlags.USE_INTERFACE_EYE1) {
+ if (isLollipopInterfaceEye(cl1)) {
+ type = type.withLollipopInterfaceEye1();
+ }
+ if (isLollipopInterfaceEye(cl2)) {
+ type = type.withLollipopInterfaceEye2();
+ }
+ }
+ return result;
+ }
+
+ private boolean isLollipopInterfaceEye(IEntity ent) {
+ return ent.getUSymbol() instanceof USymbolInterface;
+ }
+
+ public Display getLabel() {
+ return label;
+ }
+
+ public int getLength() {
+ return length;
+ }
+
+ public final void setLength(int length) {
+ this.length = length;
+ }
+
+ public String getQualifier1() {
+ return qualifier1;
+ }
+
+ public String getQualifier2() {
+ return qualifier2;
+ }
+
+ public final double getWeight() {
+ return weight;
+ }
+
+ public final void setWeight(double weight) {
+ this.weight = weight;
+ }
+
+ public final Display getNote() {
+ return note;
+ }
+
+ public final HtmlColor getNoteColor() {
+ return noteColor;
+ }
+
+ public final Position getNotePosition() {
+ return notePosition;
+ }
+
+ public final void addNote(Display note, Position position, HtmlColor noteColor) {
+ this.note = note;
+ this.notePosition = position;
+ this.noteColor = noteColor;
+ }
+
+ public final void addNote(String n, Position position, HtmlColor noteColor) {
+ this.note = Display.getWithNewlines(n);
+ this.notePosition = position;
+ this.noteColor = noteColor;
+ }
+
+ public boolean isAutoLinkOfAGroup() {
+ if (getEntity1().isGroup() == false) {
+ return false;
+ }
+ if (getEntity2().isGroup() == false) {
+ return false;
+ }
+ if (getEntity1() == getEntity2()) {
+ return true;
+ }
+ return false;
+ }
+
+ public boolean containsType(LeafType type) {
+ if (getEntity1().getEntityType() == type || getEntity2().getEntityType() == type) {
+ return true;
+ }
+ return false;
+ }
+
+ public boolean contains(IEntity entity) {
+ if (getEntity1() == entity || getEntity2() == entity) {
+ return true;
+ }
+ return false;
+ }
+
+ public IEntity getOther(IEntity entity) {
+ if (getEntity1() == entity) {
+ return getEntity2();
+ }
+ if (getEntity2() == entity) {
+ return getEntity1();
+ }
+ throw new IllegalArgumentException();
+ }
+
+ public double getMarginDecors1(StringBounder stringBounder, UFont fontQualif, ISkinSimple spriteContainer) {
+ final double q = getQualifierMargin(stringBounder, fontQualif, qualifier1, spriteContainer);
+ final LinkDecor decor = getType().getDecor1();
+ return decor.getMargin() + q;
+ }
+
+ public double getMarginDecors2(StringBounder stringBounder, UFont fontQualif, ISkinSimple spriteContainer) {
+ final double q = getQualifierMargin(stringBounder, fontQualif, qualifier2, spriteContainer);
+ final LinkDecor decor = getType().getDecor2();
+ return decor.getMargin() + q;
+ }
+
+ private double getQualifierMargin(StringBounder stringBounder, UFont fontQualif, String qualif,
+ ISkinSimple spriteContainer) {
+ if (qualif != null) {
+ final TextBlock b = TextBlockUtils.create(Display.create(qualif), new FontConfiguration(fontQualif,
+ HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true), HorizontalAlignment.LEFT, spriteContainer);
+ final Dimension2D dim = b.calculateDimension(stringBounder);
+ return Math.max(dim.getWidth(), dim.getHeight());
+ }
+ return 0;
+ }
+
+ public HtmlColor getSpecificColor() {
+ return specificColor;
+ }
+
+ public void setSpecificColor(String s) {
+ this.specificColor = HtmlColorSet.getInstance().getColorIfValid(s);
+ }
+
+ public final boolean isConstraint() {
+ return constraint;
+ }
+
+ public final void setConstraint(boolean constraint) {
+ this.constraint = constraint;
+ }
+
+ public void setOpale(boolean opale) {
+ this.opale = opale;
+ }
+
+ public final void setHorizontalSolitary(boolean horizontalSolitary) {
+ this.horizontalSolitary = horizontalSolitary;
+ }
+
+ public final boolean isHorizontalSolitary() {
+ return horizontalSolitary;
+ }
+
+ public final LinkArrow getLinkArrow() {
+ if (inverted) {
+ return linkArrow.reverse();
+ }
+ return linkArrow;
+ }
+
+ public final void setLinkArrow(LinkArrow linkArrow) {
+ this.linkArrow = linkArrow;
+ }
+
+ public final boolean isInverted() {
+ return inverted;
+ }
+
+ public boolean hasEntryPoint() {
+ return (getEntity1().isGroup() == false && ((ILeaf) getEntity1()).getEntityPosition() != EntityPosition.NORMAL)
+ || (getEntity2().isGroup() == false && ((ILeaf) getEntity2()).getEntityPosition() != EntityPosition.NORMAL);
+ }
+
+ public boolean hasTwoEntryPointsSameContainer() {
+ return getEntity1().isGroup() == false && getEntity2().isGroup() == false
+ && ((ILeaf) getEntity1()).getEntityPosition() != EntityPosition.NORMAL
+ && ((ILeaf) getEntity2()).getEntityPosition() != EntityPosition.NORMAL
+ && getEntity1().getParentContainer() == getEntity2().getParentContainer();
+ }
+
+ public Url getUrl() {
+ return url;
+ }
+
+ public void setUrl(Url url) {
+ this.url = url;
+ }
+
+ public boolean isHidden() {
+ return hidden || cl1.isHidden() || cl2.isHidden();
+ }
+
+ public boolean sameConnections(Link other) {
+ if (this.cl1 == other.cl1 && this.cl2 == other.cl2) {
+ return true;
+ }
+ if (this.cl1 == other.cl2 && this.cl2 == other.cl1) {
+ return true;
+ }
+ return false;
+ }
+
+ public boolean doesTouch(Link other) {
+ if (this.cl1 == other.cl1) {
+ return true;
+ }
+ if (this.cl1 == other.cl2) {
+ return true;
+ }
+ if (this.cl2 == other.cl1) {
+ return true;
+ }
+ if (this.cl2 == other.cl2) {
+ return true;
+ }
+ return false;
+ }
+
+ public boolean isAutolink() {
+ return cl1 == cl2;
+ }
+
+ public boolean isRemoved() {
+ return cl1.isRemoved() || cl2.isRemoved();
+ }
+
+ public boolean hasUrl() {
+ if (label != null && label.hasUrl()) {
+ return true;
+ }
+ return getUrl() != null;
+ }
+
+ public String getSametail() {
+ return sametail;
+ }
+
+ public void setSametail(String sametail) {
+ this.sametail = sametail;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/LinkArrow.java b/src/net/sourceforge/plantuml/cucadiagram/LinkArrow.java
new file mode 100644
index 0000000..e611792
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/LinkArrow.java
@@ -0,0 +1,51 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+public enum LinkArrow {
+
+ NONE, DIRECT_NORMAL, BACKWARD;
+
+ public LinkArrow reverse() {
+ if (this == DIRECT_NORMAL) {
+ return BACKWARD;
+ }
+ if (this == BACKWARD) {
+ return DIRECT_NORMAL;
+ }
+ return NONE;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/LinkDecor.java b/src/net/sourceforge/plantuml/cucadiagram/LinkDecor.java
new file mode 100644
index 0000000..98d65f6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/LinkDecor.java
@@ -0,0 +1,111 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+import net.sourceforge.plantuml.OptionFlags;
+import net.sourceforge.plantuml.svek.extremity.ExtremityFactory;
+import net.sourceforge.plantuml.svek.extremity.ExtremityFactoryArrow;
+import net.sourceforge.plantuml.svek.extremity.ExtremityFactoryArrowAndCircle;
+import net.sourceforge.plantuml.svek.extremity.ExtremityFactoryCircle;
+import net.sourceforge.plantuml.svek.extremity.ExtremityFactoryCircleConnect;
+import net.sourceforge.plantuml.svek.extremity.ExtremityFactoryCircleCross;
+import net.sourceforge.plantuml.svek.extremity.ExtremityFactoryDiamond;
+import net.sourceforge.plantuml.svek.extremity.ExtremityFactoryParenthesis;
+import net.sourceforge.plantuml.svek.extremity.ExtremityFactoryPlus;
+import net.sourceforge.plantuml.svek.extremity.ExtremityFactorySquarre;
+import net.sourceforge.plantuml.svek.extremity.ExtremityFactoryTriangle;
+
+public enum LinkDecor {
+
+ NONE(2, false, 0), EXTENDS(30, false, 2), COMPOSITION(15, true, 1.3), AGREGATION(15, false, 1.3),
+
+ ARROW(10, true, 0.5), ARROW_TRIANGLE(10, true, 0.8), ARROW_AND_CIRCLE(10, false, 0.5),
+
+ CIRCLE(0, false, 0.5), CIRCLE_CONNECT(0, false, 0.5), PARENTHESIS(0, false, OptionFlags.USE_INTERFACE_EYE2 ? 0.5
+ : 1.0), SQUARRE(0, false, 0.5),
+
+ CIRCLE_CROSS(0, false, 0.5), PLUS(0, false, 1.5), SQUARRE_toberemoved(30, false, 0);
+
+ private final double arrowSize;
+ private final int margin;
+ private final boolean fill;
+
+ private LinkDecor(int margin, boolean fill, double arrowSize) {
+ this.margin = margin;
+ this.fill = fill;
+ this.arrowSize = arrowSize;
+ }
+
+ public int getMargin() {
+ return margin;
+ }
+
+ public boolean isFill() {
+ return fill;
+ }
+
+ public double getArrowSize() {
+ return arrowSize;
+ }
+
+ public ExtremityFactory getExtremityFactory() {
+ if (this == LinkDecor.PLUS) {
+ return new ExtremityFactoryPlus();
+ } else if (this == LinkDecor.ARROW_TRIANGLE) {
+ return new ExtremityFactoryTriangle();
+ } else if (this == LinkDecor.CIRCLE_CROSS) {
+ return new ExtremityFactoryCircleCross();
+ } else if (this == LinkDecor.ARROW) {
+ return new ExtremityFactoryArrow();
+ } else if (this == LinkDecor.ARROW_AND_CIRCLE) {
+ return new ExtremityFactoryArrowAndCircle();
+ } else if (this == LinkDecor.AGREGATION) {
+ return new ExtremityFactoryDiamond(false);
+ } else if (this == LinkDecor.COMPOSITION) {
+ return new ExtremityFactoryDiamond(true);
+ } else if (this == LinkDecor.CIRCLE) {
+ return new ExtremityFactoryCircle();
+ } else if (this == LinkDecor.SQUARRE) {
+ return new ExtremityFactorySquarre();
+ } else if (this == LinkDecor.PARENTHESIS) {
+ return new ExtremityFactoryParenthesis();
+ } else if (this == LinkDecor.CIRCLE_CONNECT) {
+ return new ExtremityFactoryCircleConnect();
+ }
+
+ return null;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/LinkHat.java b/src/net/sourceforge/plantuml/cucadiagram/LinkHat.java
new file mode 100644
index 0000000..f2c93f4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/LinkHat.java
@@ -0,0 +1,53 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+
+public enum LinkHat {
+
+ NONE /*, SQUARRE, CIRCLE, CIRCLE_CONNECT;
+
+ public ExtremityFactory getExtremityFactory() {
+ if (this == LinkHat.CIRCLE) {
+ return new ExtremityFactoryCircle();
+ }
+ if (this == LinkHat.CIRCLE_CONNECT) {
+ return new ExtremityFactoryCircleConnect();
+ }
+ return null;
+ }
+ */
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/LinkMiddleDecor.java b/src/net/sourceforge/plantuml/cucadiagram/LinkMiddleDecor.java
new file mode 100644
index 0000000..f3fbce2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/LinkMiddleDecor.java
@@ -0,0 +1,62 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+import net.sourceforge.plantuml.svek.extremity.MiddleCircleCircledMode;
+import net.sourceforge.plantuml.svek.extremity.MiddleFactory;
+import net.sourceforge.plantuml.svek.extremity.MiddleFactoryCircle;
+import net.sourceforge.plantuml.svek.extremity.MiddleFactoryCircleCircled;
+
+public enum LinkMiddleDecor {
+
+ NONE, CIRCLE, CIRCLE_CIRCLED, CIRCLE_CIRCLED1, CIRCLE_CIRCLED2;
+
+ public MiddleFactory getMiddleFactory() {
+ if (this == CIRCLE) {
+ return new MiddleFactoryCircle();
+ }
+ if (this == CIRCLE_CIRCLED) {
+ return new MiddleFactoryCircleCircled(MiddleCircleCircledMode.BOTH);
+ }
+ if (this == CIRCLE_CIRCLED1) {
+ return new MiddleFactoryCircleCircled(MiddleCircleCircledMode.MODE1);
+ }
+ if (this == CIRCLE_CIRCLED2) {
+ return new MiddleFactoryCircleCircled(MiddleCircleCircledMode.MODE2);
+ }
+ throw new UnsupportedOperationException();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/LinkStyle.java b/src/net/sourceforge/plantuml/cucadiagram/LinkStyle.java
new file mode 100644
index 0000000..96ff57f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/LinkStyle.java
@@ -0,0 +1,43 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+public enum LinkStyle {
+
+ NORMAL, DASHED, DOTTED, BOLD, INVISIBLE,
+
+ DOUBLE_tobedone, __toremove_INTERFACE_PROVIDER, __toremove_INTERFACE_USER;
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/LinkType.java b/src/net/sourceforge/plantuml/cucadiagram/LinkType.java
new file mode 100644
index 0000000..e26fe7e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/LinkType.java
@@ -0,0 +1,245 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+import net.sourceforge.plantuml.ugraphic.UStroke;
+
+public class LinkType {
+
+ private final LinkHat hat1;
+ private final LinkDecor decor1;
+ private final LinkStyle style;
+ private final LinkDecor decor2;
+ private final LinkHat hat2;
+ private final LinkMiddleDecor middleDecor;
+
+ public LinkType(LinkDecor decor1, LinkDecor decor2) {
+ this(LinkHat.NONE, decor1, decor2, LinkHat.NONE);
+ }
+
+ public LinkType(LinkHat hat1, LinkDecor decor1, LinkDecor decor2, LinkHat hat2) {
+ this(hat1, decor1, LinkStyle.NORMAL, LinkMiddleDecor.NONE, decor2, hat2);
+ }
+
+ // public boolean contains(LinkDecor decors) {
+ // return decor1 == decors || decor2 == decors;
+ // }
+
+ @Override
+ public String toString() {
+ return decor1 + "-" + style + "-" + decor2;
+ }
+
+ @Override
+ public int hashCode() {
+ return toString().hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ final LinkType other = (LinkType) obj;
+ return this.decor1 == other.decor1 && this.decor2 == other.decor2 && this.style == other.style;
+ }
+
+ private LinkType(LinkHat hat1, LinkDecor decor1, LinkStyle style, LinkMiddleDecor middleDecor, LinkDecor decor2,
+ LinkHat hat2) {
+ this.decor1 = decor1;
+ this.style = style;
+ this.decor2 = decor2;
+ this.middleDecor = middleDecor;
+ this.hat1 = hat1;
+ this.hat2 = hat2;
+ }
+
+ public boolean isDashed() {
+ return style == LinkStyle.DASHED;
+ }
+
+ public boolean isDotted() {
+ return style == LinkStyle.DOTTED;
+ }
+
+ public boolean isBold() {
+ return style == LinkStyle.BOLD;
+ }
+
+ public boolean isInvisible() {
+ return style == LinkStyle.INVISIBLE;
+ }
+
+ public LinkType getDashed() {
+ return new LinkType(hat1, decor1, LinkStyle.DASHED, middleDecor, decor2, hat2);
+ }
+
+ public LinkType getDotted() {
+ return new LinkType(hat1, decor1, LinkStyle.DOTTED, middleDecor, decor2, hat2);
+ }
+
+ public LinkType getBold() {
+ return new LinkType(hat1, decor1, LinkStyle.BOLD, middleDecor, decor2, hat2);
+ }
+
+ public LinkType getInterfaceProvider() {
+ return new LinkType(hat1, decor1, LinkStyle.__toremove_INTERFACE_PROVIDER, middleDecor, decor2, hat2);
+ }
+
+ public LinkType getInterfaceUser() {
+ return new LinkType(hat1, decor1, LinkStyle.__toremove_INTERFACE_USER, middleDecor, decor2, hat2);
+ }
+
+ public LinkType getInversed() {
+ return new LinkType(hat2, decor2, style, middleDecor, decor1, hat1);
+ }
+
+ public LinkType withMiddleCircle() {
+ return new LinkType(hat1, decor1, style, LinkMiddleDecor.CIRCLE, decor2, hat2);
+ }
+
+ public LinkType withMiddleCircleCircled() {
+ return new LinkType(hat1, decor1, style, LinkMiddleDecor.CIRCLE_CIRCLED, decor2, hat2);
+ }
+
+ public LinkType withMiddleCircleCircled1() {
+ return new LinkType(hat1, decor1, style, LinkMiddleDecor.CIRCLE_CIRCLED1, decor2, hat2);
+ }
+
+ public LinkType withMiddleCircleCircled2() {
+ return new LinkType(hat1, decor1, style, LinkMiddleDecor.CIRCLE_CIRCLED2, decor2, hat2);
+ }
+
+ public LinkType getInvisible() {
+ return new LinkType(hat1, decor1, LinkStyle.INVISIBLE, middleDecor, decor2, hat2);
+ }
+
+ public String getSpecificDecorationSvek() {
+ final StringBuilder sb = new StringBuilder();
+
+ final boolean isEmpty1 = decor1 == LinkDecor.NONE && hat1 == LinkHat.NONE;
+ final boolean isEmpty2 = decor2 == LinkDecor.NONE && hat2 == LinkHat.NONE;
+
+ if (isEmpty1 && isEmpty2) {
+ sb.append("arrowtail=none");
+ sb.append(",arrowhead=none");
+ } else if (isEmpty1 == false && isEmpty2 == false) {
+ sb.append("dir=both,");
+ sb.append("arrowtail=empty");
+ sb.append(",arrowhead=empty");
+ } else if (isEmpty1 && isEmpty2 == false) {
+ sb.append("arrowtail=empty");
+ sb.append(",arrowhead=none");
+ sb.append(",dir=back");
+ } else if (isEmpty1 == false && isEmpty2) {
+ sb.append("arrowtail=none");
+ sb.append(",arrowhead=empty");
+ }
+
+ final double arrowsize = Math.max(decor1.getArrowSize(), decor2.getArrowSize());
+ if (arrowsize > 0) {
+ sb.append(",arrowsize=" + arrowsize);
+ }
+ return sb.toString();
+ }
+
+ public final LinkDecor getDecor1() {
+ return decor1;
+ }
+
+ public final LinkStyle getStyle() {
+ return style;
+ }
+
+ public final LinkDecor getDecor2() {
+ return decor2;
+ }
+
+ public boolean isExtendsOrAgregationOrCompositionOrPlus() {
+ return isExtends() || isAgregationOrComposition() || isPlus();
+ }
+
+ private boolean isExtends() {
+ return decor1 == LinkDecor.EXTENDS || decor2 == LinkDecor.EXTENDS;
+ }
+
+ private boolean isPlus() {
+ return decor1 == LinkDecor.PLUS || decor2 == LinkDecor.PLUS;
+ }
+
+ private boolean isAgregationOrComposition() {
+ return decor1 == LinkDecor.AGREGATION || decor2 == LinkDecor.AGREGATION || decor1 == LinkDecor.COMPOSITION
+ || decor2 == LinkDecor.COMPOSITION;
+ }
+
+ public LinkType getPart1() {
+ return new LinkType(hat1, decor1, style, middleDecor, LinkDecor.NONE, LinkHat.NONE);
+ }
+
+ public LinkType getPart2() {
+ return new LinkType(LinkHat.NONE, LinkDecor.NONE, style, middleDecor, decor2, hat2);
+ }
+
+ public UStroke getStroke() {
+ if (style == LinkStyle.DASHED) {
+ return new UStroke(7, 7, 1);
+ }
+ if (style == LinkStyle.DOTTED) {
+ return new UStroke(1, 3, 1);
+ }
+ if (style == LinkStyle.BOLD) {
+ return new UStroke(2);
+ }
+ return new UStroke();
+ }
+
+ public LinkMiddleDecor getMiddleDecor() {
+ return middleDecor;
+ }
+
+ public LinkHat getHat1() {
+ return hat1;
+ }
+
+ public LinkHat getHat2() {
+ return hat2;
+ }
+
+ public LinkType withLollipopInterfaceEye2() {
+ return new LinkType(hat1, LinkDecor.NONE, style, middleDecor, decor2, hat2);
+ }
+
+ public LinkType withLollipopInterfaceEye1() {
+ return new LinkType(hat1, decor1, style, middleDecor, LinkDecor.NONE, hat2);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/LongCode.java b/src/net/sourceforge/plantuml/cucadiagram/LongCode.java
new file mode 100644
index 0000000..6750d05
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/LongCode.java
@@ -0,0 +1,91 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+import net.sourceforge.plantuml.StringUtils;
+
+public class LongCode implements Comparable<LongCode> {
+
+ private final String fullName;
+ private final String separator;
+
+ private LongCode(String fullName, String separator) {
+ if (fullName == null) {
+ throw new IllegalArgumentException();
+ }
+ this.fullName = fullName;
+ this.separator = separator;
+ }
+
+ public String getNamespaceSeparator() {
+ return separator;
+ }
+
+ public static LongCode of(String code, String separator) {
+ if (code == null) {
+ throw new IllegalStateException();
+ }
+ return new LongCode(code, separator);
+ }
+
+ public final String getFullName() {
+ return fullName;
+ }
+
+ @Override
+ public String toString() {
+ return fullName + "(" + separator + ")";
+ }
+
+ @Override
+ public int hashCode() {
+ return fullName.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ final LongCode other = (LongCode) obj;
+ return this.fullName.equals(other.fullName);
+ }
+
+ public int compareTo(LongCode other) {
+ return this.fullName.compareTo(other.fullName);
+ }
+
+ private LongCode eventuallyRemoveStartingAndEndingDoubleQuote() {
+ return LongCode.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(fullName), separator);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/Magma.java b/src/net/sourceforge/plantuml/cucadiagram/Magma.java
new file mode 100644
index 0000000..0b6cfaa
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/Magma.java
@@ -0,0 +1,111 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+import java.util.List;
+
+class Magma {
+
+ private final CucaDiagram system;
+ private final List<ILeaf> standalones;
+ private final LinkType linkType = new LinkType(LinkDecor.NONE, LinkDecor.NONE).getInvisible();
+
+ public Magma(CucaDiagram system, List<ILeaf> standalones) {
+ this.system = system;
+ this.standalones = standalones;
+ }
+
+ public void putInSquare() {
+ final SquareLinker<ILeaf> linker = new SquareLinker<ILeaf>() {
+ public void topDown(ILeaf top, ILeaf down) {
+ system.addLink(new Link(top, down, linkType, null, 2));
+ }
+
+ public void leftRight(ILeaf left, ILeaf right) {
+ system.addLink(new Link(left, right, linkType, null, 1));
+ }
+ };
+ new SquareMaker<ILeaf>().putInSquare(standalones, linker);
+ }
+
+ public IGroup getContainer() {
+ final IGroup parent = standalones.get(0).getParentContainer();
+ if (parent == null) {
+ return null;
+ }
+ return parent.getParentContainer();
+ }
+
+ public boolean isComplete() {
+ final IGroup parent = getContainer();
+ if (parent == null) {
+ return false;
+ }
+ return parent.size() == standalones.size();
+ }
+
+ private int squareSize() {
+ return SquareMaker.computeBranch(standalones.size());
+ }
+
+ private ILeaf getTopLeft() {
+ return standalones.get(0);
+ }
+
+ private ILeaf getBottomLeft() {
+ int result = SquareMaker.getBottomLeft(standalones.size());
+ return standalones.get(result);
+ }
+
+ private ILeaf getTopRight() {
+ final int s = squareSize();
+ return standalones.get(s - 1);
+ }
+
+ @Override
+ public String toString() {
+ return standalones.get(0).getParentContainer() + " " + standalones.toString() + " " + isComplete();
+ }
+
+ public void linkToDown(Magma down) {
+ system.addLink(new Link(this.getBottomLeft(), down.getTopLeft(), linkType, null, 2));
+
+ }
+
+ public void linkToRight(Magma right) {
+ system.addLink(new Link(this.getTopRight(), right.getTopLeft(), linkType, null, 1));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/MagmaList.java b/src/net/sourceforge/plantuml/cucadiagram/MagmaList.java
new file mode 100644
index 0000000..0ff97f0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/MagmaList.java
@@ -0,0 +1,76 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+import java.util.ArrayList;
+import java.util.List;
+
+class MagmaList {
+
+ private final List<Magma> all = new ArrayList<Magma>();
+
+ public void add(Magma magma) {
+ all.add(magma);
+ }
+
+ public MagmaList getMagmas(IGroup group) {
+ final MagmaList result = new MagmaList();
+ for (Magma m : all) {
+ if (m.getContainer() == group) {
+ result.add(m);
+ }
+ }
+ return result;
+ }
+
+ public int size() {
+ return all.size();
+ }
+
+ public void putInSquare() {
+ final SquareLinker<Magma> linker = new SquareLinker<Magma>() {
+ public void topDown(Magma top, Magma down) {
+ top.linkToDown(down);
+ }
+
+ public void leftRight(Magma left, Magma right) {
+ left.linkToRight(right);
+ }
+ };
+ new SquareMaker<Magma>().putInSquare(all, linker);
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/Member.java b/src/net/sourceforge/plantuml/cucadiagram/Member.java
new file mode 100644
index 0000000..1f21968
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/Member.java
@@ -0,0 +1,192 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.skin.VisibilityModifier;
+
+public class Member {
+
+ private final String display;
+ private final boolean staticModifier;
+ private final boolean abstractModifier;
+ private final Url url;
+ private final boolean hasUrl;
+
+ private final VisibilityModifier visibilityModifier;
+
+ public Member(String display, boolean isMethod, boolean manageModifier) {
+ this.hasUrl = new UrlBuilder(null, ModeUrl.ANYWHERE).getUrl(display) != null;
+ final Pattern pstart = MyPattern.cmpile("^(" + UrlBuilder.getRegexp() + ")([^\\[\\]]+)$");
+ final Matcher mstart = pstart.matcher(display);
+
+ if (mstart.matches()) {
+ if (mstart.groupCount() != 5) {
+ throw new IllegalStateException();
+ }
+ final UrlBuilder urlBuilder = new UrlBuilder(null, ModeUrl.AT_START);
+ url = urlBuilder.getUrl(mstart.group(1));
+ url.setMember(true);
+ display = /* mstart.group(1).trim() + */mstart.group(mstart.groupCount()).trim();
+ } else {
+ final Pattern pend = MyPattern.cmpile("^((?:[^\\[\\]]|\\[[^\\[\\]]*\\])+)(" + UrlBuilder.getRegexp() + ")$");
+ final Matcher mend = pend.matcher(display);
+
+ if (mend.matches()) {
+ if (mend.groupCount() != 5) {
+ throw new IllegalStateException();
+ }
+ final UrlBuilder urlBuilder = new UrlBuilder(null, ModeUrl.AT_END);
+ url = urlBuilder.getUrl(mend.group(2));
+ url.setMember(true);
+ display = mend.group(1).trim();
+ } else {
+ url = null;
+ }
+ }
+
+ final String lower = StringUtils.goLowerCase(display);
+
+ if (manageModifier) {
+ this.staticModifier = lower.contains("{static}") || lower.contains("{classifier}");
+ this.abstractModifier = lower.contains("{abstract}");
+ String displayClean = display.replaceAll("(?i)\\{(static|classifier|abstract)\\}", "").trim();
+ if (displayClean.length() == 0) {
+ displayClean = " ";
+ }
+
+ if (VisibilityModifier.isVisibilityCharacter(displayClean.charAt(0))) {
+ visibilityModifier = VisibilityModifier.getVisibilityModifier(display.charAt(0), isMethod == false);
+ this.display = displayClean.substring(1).trim();
+ } else {
+ this.display = displayClean;
+ visibilityModifier = null;
+ }
+ } else {
+ this.staticModifier = false;
+ this.visibilityModifier = null;
+ this.abstractModifier = false;
+ display = display.trim();
+ this.display = display.length() == 0 ? " " : display.trim();
+ }
+ }
+
+ public String getDisplay(boolean withVisibilityChar) {
+ if (withVisibilityChar) {
+ return getDisplayWithVisibilityChar();
+ }
+ return getDisplayWithoutVisibilityChar();
+ }
+
+ public String getDisplayWithoutVisibilityChar() {
+ // assert display.length() == 0 || VisibilityModifier.isVisibilityCharacter(display.charAt(0)) == false;
+ return display;
+ }
+
+ public String getDisplayWithVisibilityChar() {
+ if (isPrivate()) {
+ return "-" + display;
+ }
+ if (isPublic()) {
+ return "+" + display;
+ }
+ if (isPackagePrivate()) {
+ return "~" + display;
+ }
+ if (isProtected()) {
+ return "#" + display;
+ }
+ return display;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ final Member other = (Member) obj;
+ return this.display.equals(other.display);
+ }
+
+ @Override
+ public int hashCode() {
+ return display.hashCode();
+ }
+
+ public final boolean isStatic() {
+ return staticModifier;
+ }
+
+ public final boolean isAbstract() {
+ return abstractModifier;
+ }
+
+ private boolean isPrivate() {
+ return visibilityModifier == VisibilityModifier.PRIVATE_FIELD
+ || visibilityModifier == VisibilityModifier.PRIVATE_METHOD;
+ }
+
+ private boolean isProtected() {
+ return visibilityModifier == VisibilityModifier.PROTECTED_FIELD
+ || visibilityModifier == VisibilityModifier.PROTECTED_METHOD;
+ }
+
+ private boolean isPublic() {
+ return visibilityModifier == VisibilityModifier.PUBLIC_FIELD
+ || visibilityModifier == VisibilityModifier.PUBLIC_METHOD;
+ }
+
+ private boolean isPackagePrivate() {
+ return visibilityModifier == VisibilityModifier.PACKAGE_PRIVATE_FIELD
+ || visibilityModifier == VisibilityModifier.PACKAGE_PRIVATE_METHOD;
+ }
+
+ public final VisibilityModifier getVisibilityModifier() {
+ return visibilityModifier;
+ }
+
+ public final Url getUrl() {
+ return url;
+ }
+
+ public boolean hasUrl() {
+ return hasUrl;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/MethodsOrFieldsArea.java b/src/net/sourceforge/plantuml/cucadiagram/MethodsOrFieldsArea.java
new file mode 100644
index 0000000..2b28f67
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/MethodsOrFieldsArea.java
@@ -0,0 +1,224 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+import java.awt.geom.Dimension2D;
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.graphic.TextBlockWidth;
+import net.sourceforge.plantuml.skin.VisibilityModifier;
+import net.sourceforge.plantuml.skin.rose.Rose;
+import net.sourceforge.plantuml.ugraphic.PlacementStrategy;
+import net.sourceforge.plantuml.ugraphic.PlacementStrategyVisibility;
+import net.sourceforge.plantuml.ugraphic.PlacementStrategyY1Y2Center;
+import net.sourceforge.plantuml.ugraphic.PlacementStrategyY1Y2Left;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULayoutGroup;
+import net.sourceforge.plantuml.utils.CharHidder;
+
+public class MethodsOrFieldsArea implements TextBlockWidth, TextBlock {
+
+ private final UFont font;
+ private final ISkinParam skinParam;
+ private final HtmlColor color;
+ private final HtmlColor hyperlinkColor;
+ private final boolean useUnderlineForHyperlink;
+ private final Rose rose = new Rose();
+ private final List<Member> members = new ArrayList<Member>();
+ private final HorizontalAlignment align;
+
+ public MethodsOrFieldsArea(List<Member> members, FontParam fontParam, ISkinParam skinParam) {
+ this(members, fontParam, skinParam, HorizontalAlignment.LEFT);
+ }
+
+ public MethodsOrFieldsArea(List<Member> members, FontParam fontParam, ISkinParam skinParam,
+ HorizontalAlignment align) {
+ this.align = align;
+ this.skinParam = skinParam;
+ this.font = skinParam.getFont(fontParam, null, false);
+ this.color = rose.getFontColor(skinParam, fontParam);
+ this.hyperlinkColor = skinParam.getHyperlinkColor();
+ this.useUnderlineForHyperlink = skinParam.useUnderlineForHyperlink();
+ this.members.addAll(members);
+ }
+
+ private boolean hasSmallIcon() {
+ if (skinParam.classAttributeIconSize() == 0) {
+ return false;
+ }
+ for (Member m : members) {
+ if (m.getVisibilityModifier() != null) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ double smallIcon = 0;
+ if (hasSmallIcon()) {
+ smallIcon = skinParam.getCircledCharacterRadius() + 3;
+ }
+ double x = 0;
+ double y = 0;
+ for (Member m : members) {
+ final TextBlock bloc = createTextBlock(m);
+ final Dimension2D dim = bloc.calculateDimension(stringBounder);
+ x = Math.max(dim.getWidth(), x);
+ y += dim.getHeight();
+ }
+ x += smallIcon;
+ return new Dimension2DDouble(x, y);
+ }
+
+ private TextBlock createTextBlock(Member m) {
+ final boolean withVisibilityChar = skinParam.classAttributeIconSize() == 0;
+ String s = m.getDisplay(withVisibilityChar);
+ if (withVisibilityChar && s.startsWith("#")) {
+ s = CharHidder.addTileAtBegin(s);
+ }
+ FontConfiguration config = new FontConfiguration(font, color, hyperlinkColor, useUnderlineForHyperlink);
+ if (m.isAbstract()) {
+ config = config.italic();
+ }
+ if (m.isStatic()) {
+ config = config.underline();
+ }
+ final TextBlock bloc = TextBlockUtils.create(Display.getWithNewlines(s), config, align, skinParam, true);
+ return new TextBlockTracer(m, bloc);
+ }
+
+ static class TextBlockTracer implements TextBlock {
+
+ private final TextBlock bloc;
+ private final Url url;
+
+ public TextBlockTracer(Member m, TextBlock bloc) {
+ this.bloc = bloc;
+ this.url = m.getUrl();
+ }
+
+ public void drawU(UGraphic ug) {
+ if (url != null) {
+ ug.startUrl(url);
+ }
+ bloc.drawU(ug);
+ if (url != null) {
+ ug.closeAction();
+ }
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dim = bloc.calculateDimension(stringBounder);
+ return dim;
+ }
+
+ }
+
+ private TextBlock getUBlock(final VisibilityModifier modifier) {
+ if (modifier == null) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(1, 1);
+ }
+ };
+ }
+ final HtmlColor back = modifier.getBackground() == null ? null : rose.getHtmlColor(skinParam,
+ modifier.getBackground());
+ final HtmlColor fore = rose.getHtmlColor(skinParam, modifier.getForeground());
+
+ final TextBlock uBlock = modifier.getUBlock(skinParam.classAttributeIconSize(), fore, back);
+ return uBlock;
+ }
+
+ public TextBlock asTextBlock(final double widthToUse) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ MethodsOrFieldsArea.this.drawU(ug);
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return MethodsOrFieldsArea.this.calculateDimension(stringBounder);
+ }
+ };
+ }
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ final ULayoutGroup group;
+ if (hasSmallIcon()) {
+ group = new ULayoutGroup(new PlacementStrategyVisibility(ug.getStringBounder(),
+ skinParam.getCircledCharacterRadius() + 3));
+ for (Member att : members) {
+ final TextBlock bloc = createTextBlock(att);
+ final VisibilityModifier modifier = att.getVisibilityModifier();
+ group.add(getUBlock(modifier));
+ group.add(bloc);
+ }
+ } else {
+ final PlacementStrategy placementStrategy;
+ if (align == HorizontalAlignment.LEFT) {
+ placementStrategy = new PlacementStrategyY1Y2Left(ug.getStringBounder());
+ } else if (align == HorizontalAlignment.CENTER) {
+ placementStrategy = new PlacementStrategyY1Y2Center(ug.getStringBounder());
+ } else {
+ throw new IllegalStateException();
+ }
+ group = new ULayoutGroup(placementStrategy);
+ for (Member att : members) {
+ final TextBlock bloc = createTextBlock(att);
+ group.add(bloc);
+ }
+ }
+ group.drawU(ug, 0, 0, dim.getWidth(), dim.getHeight());
+ }
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/Namespace.java b/src/net/sourceforge/plantuml/cucadiagram/Namespace.java
new file mode 100644
index 0000000..f43dd98
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/Namespace.java
@@ -0,0 +1,71 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+public class Namespace {
+
+ private final String namespace;
+
+ private Namespace(String namespace) {
+ if (namespace == null) {
+ throw new IllegalArgumentException();
+ }
+ this.namespace = namespace;
+ }
+
+ public final String getNamespace() {
+ return namespace;
+ }
+
+ public static Namespace of(String namespace) {
+ return new Namespace(namespace);
+ }
+
+ @Override
+ public int hashCode() {
+ return namespace.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ final Namespace other = (Namespace) obj;
+ return this.namespace.equals(other.namespace);
+ }
+
+ public boolean isMain() {
+ return namespace.length() == 0;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/PortionShower.java b/src/net/sourceforge/plantuml/cucadiagram/PortionShower.java
new file mode 100644
index 0000000..abddcff
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/PortionShower.java
@@ -0,0 +1,41 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+
+public interface PortionShower {
+
+ boolean showPortion(EntityPortion portion, IEntity entity);
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/Rankdir.java b/src/net/sourceforge/plantuml/cucadiagram/Rankdir.java
new file mode 100644
index 0000000..7e4ddf9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/Rankdir.java
@@ -0,0 +1,40 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+public enum Rankdir {
+ LEFT_TO_RIGHT, TOP_TO_BOTTOM;
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/RuleType.java b/src/net/sourceforge/plantuml/cucadiagram/RuleType.java
new file mode 100644
index 0000000..855cb11
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/RuleType.java
@@ -0,0 +1,39 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+public enum RuleType {
+ SHOW, HIDE
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/SquareLinker.java b/src/net/sourceforge/plantuml/cucadiagram/SquareLinker.java
new file mode 100644
index 0000000..2ae5709
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/SquareLinker.java
@@ -0,0 +1,43 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+interface SquareLinker<O extends Object> {
+
+ public void leftRight(O left, O right);
+
+ public void topDown(O top, O down);
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/SquareMaker.java b/src/net/sourceforge/plantuml/cucadiagram/SquareMaker.java
new file mode 100644
index 0000000..48bad05
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/SquareMaker.java
@@ -0,0 +1,83 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+import java.util.List;
+
+class SquareMaker<O extends Object> {
+
+ public void putInSquare(List<O> data, SquareLinker<O> linker) {
+ final int branch = computeBranch(data.size());
+ int headBranch = 0;
+ for (int i = 1; i < data.size(); i++) {
+ final int dist = i - headBranch;
+ final O ent2 = data.get(i);
+ if (dist == branch) {
+ final O ent1 = data.get(headBranch);
+ linker.topDown(ent1, ent2);
+ headBranch = i;
+ } else {
+ final O ent1 = data.get(i - 1);
+ linker.leftRight(ent1, ent2);
+ }
+ }
+
+ }
+
+ static int computeBranch(final int size) {
+ final double sqrt = Math.sqrt(size);
+ final int r = (int) sqrt;
+ if (r * r == size) {
+ return r;
+ }
+ return r + 1;
+ }
+
+ static int getBottomLeft(final int size) {
+ final int s = computeBranch(size);
+ final int line = (size - 1) / s;
+ return line * s;
+ }
+
+ // static int getBottomLeft(final int size) {
+ // final int s = computeBranch(size);
+ // int result = s * (s - 1);
+ // while (result >= size) {
+ // result -= s;
+ // }
+ // return result;
+ // }
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/Stereotype.java b/src/net/sourceforge/plantuml/cucadiagram/Stereotype.java
new file mode 100644
index 0000000..db7b444
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/Stereotype.java
@@ -0,0 +1,236 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.Hideable;
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.IHtmlColorSet;
+import net.sourceforge.plantuml.svek.PackageStyle;
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public class Stereotype implements CharSequence, Hideable {
+ private final static Pattern circleChar = MyPattern
+ .cmpile("\\<\\<[%s]*\\(?(\\S)[%s]*,[%s]*(#[0-9a-fA-F]{6}|\\w+)[%s]*(?:[),](.*?))?\\>\\>");
+ private final static Pattern circleSprite = MyPattern
+ .cmpile("\\<\\<[%s]*\\(?\\$([\\p{L}0-9_]+)[%s]*(?:,[%s]*(#[0-9a-fA-F]{6}|\\w+))?[%s]*(?:[),](.*?))?\\>\\>");
+
+ private final String label;
+ private final HtmlColor htmlColor;
+ private final char character;
+ private final String sprite;
+ private final double radius;
+ private final UFont circledFont;
+ private final boolean automaticPackageStyle;
+
+ public Stereotype(String label, double radius, UFont circledFont, IHtmlColorSet htmlColorSet) {
+ this(label, radius, circledFont, true, htmlColorSet);
+ }
+
+ public Stereotype(String label, double radius, UFont circledFont, boolean automaticPackageStyle,
+ IHtmlColorSet htmlColorSet) {
+ if (label == null) {
+ throw new IllegalArgumentException();
+ }
+ if (label.startsWith("<<") == false || label.endsWith(">>") == false) {
+ throw new IllegalArgumentException(label);
+ }
+ this.automaticPackageStyle = automaticPackageStyle;
+ this.radius = radius;
+ this.circledFont = circledFont;
+ final Matcher mCircleChar = circleChar.matcher(label);
+ final Matcher mCircleSprite = circleSprite.matcher(label);
+ if (mCircleSprite.find()) {
+ if (StringUtils.isNotEmpty(mCircleSprite.group(3))) {
+ this.label = "<<" + mCircleSprite.group(3) + ">>";
+ } else {
+ this.label = null;
+ }
+ final String colName = mCircleSprite.group(2);
+ final HtmlColor col = htmlColorSet.getColorIfValid(colName);
+ this.htmlColor = col == null ? HtmlColorUtils.BLACK : col;
+ this.sprite = mCircleSprite.group(1);
+ this.character = '\0';
+ } else if (mCircleChar.find()) {
+ if (StringUtils.isNotEmpty(mCircleChar.group(3))) {
+ this.label = "<<" + mCircleChar.group(3) + ">>";
+ } else {
+ this.label = null;
+ }
+ final String colName = mCircleChar.group(2);
+ this.htmlColor = htmlColorSet.getColorIfValid(colName);
+ this.character = mCircleChar.group(1).charAt(0);
+ this.sprite = null;
+ } else {
+ this.label = label;
+ this.character = '\0';
+ this.htmlColor = null;
+ this.sprite = null;
+ }
+ }
+
+ public Stereotype(String label) {
+ this(label, true);
+ }
+
+ public Stereotype(String label, boolean automaticPackageStyle) {
+ this.automaticPackageStyle = automaticPackageStyle;
+ this.label = label;
+ this.htmlColor = null;
+ this.character = '\0';
+ this.radius = 0;
+ this.circledFont = null;
+ this.sprite = null;
+ }
+
+ public HtmlColor getHtmlColor() {
+ return htmlColor;
+ }
+
+ public char getCharacter() {
+ return character;
+ }
+
+ public final String getSprite() {
+ return sprite;
+ }
+
+ public boolean isWithOOSymbol() {
+ return "<<O-O>>".equalsIgnoreCase(label);
+ }
+
+ public String getLabel(boolean withGuillement) {
+ assert label == null || label.length() > 0;
+ if (isWithOOSymbol()) {
+ return null;
+ }
+ if (withGuillement) {
+ return manageGuillemet(label);
+ }
+ return label;
+ }
+
+ public boolean isSpotted() {
+ return character != 0;
+ }
+
+ @Override
+ public String toString() {
+ if (label == null) {
+ return "" + character;
+ }
+ if (character == 0) {
+ return label;
+ }
+ return character + " " + label;
+ }
+
+ public char charAt(int arg0) {
+ return toString().charAt(arg0);
+ }
+
+ public int length() {
+ return toString().length();
+ }
+
+ public CharSequence subSequence(int arg0, int arg1) {
+ return toString().subSequence(arg0, arg1);
+ }
+
+ public double getRadius() {
+ return radius;
+ }
+
+ public final UFont getCircledFont() {
+ return circledFont;
+ }
+
+ public List<String> getLabels(boolean useGuillemet) {
+ if (getLabel(false) == null) {
+ return null;
+ }
+ final List<String> result = new ArrayList<String>();
+ final Pattern p = MyPattern.cmpile("\\<\\<.*?\\>\\>");
+ final Matcher m = p.matcher(getLabel(false));
+ while (m.find()) {
+ if (useGuillemet) {
+ result.add(manageGuillemet(m.group()));
+ } else {
+ result.add(m.group());
+ }
+ }
+ return Collections.unmodifiableList(result);
+ }
+
+ private static String manageGuillemet(String st) {
+ if (st.startsWith("<< ")) {
+ st = "\u00AB" + st.substring(3);
+ } else if (st.startsWith("<<")) {
+ st = "\u00AB" + st.substring(2);
+ }
+ if (st.endsWith(" >>")) {
+ st = st.substring(0, st.length() - 3) + "\u00BB";
+ } else if (st.endsWith(">>")) {
+ st = st.substring(0, st.length() - 2) + "\u00BB";
+ }
+ return st;
+ }
+
+ public PackageStyle getPackageStyle() {
+ if (automaticPackageStyle == false) {
+ return null;
+ }
+ for (PackageStyle p : EnumSet.allOf(PackageStyle.class)) {
+ if (("<<" + p + ">>").equalsIgnoreCase(label)) {
+ return p;
+ }
+ }
+ return null;
+ }
+
+ public boolean isHidden() {
+ return "<<hidden>>".equalsIgnoreCase(label);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/UnparsableGraphvizException.java b/src/net/sourceforge/plantuml/cucadiagram/UnparsableGraphvizException.java
new file mode 100644
index 0000000..220aca2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/UnparsableGraphvizException.java
@@ -0,0 +1,58 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram;
+
+public class UnparsableGraphvizException extends RuntimeException {
+
+ private final String graphvizVersion;
+ private final String svg;
+ private final String diagramSource;
+
+ public UnparsableGraphvizException(Exception cause, String graphvizVersion, String svg, String diagramSource) {
+ super(cause);
+ this.graphvizVersion = graphvizVersion;
+ this.svg = svg;
+ this.diagramSource = diagramSource;
+ }
+
+ public String getGraphvizVersion() {
+ return graphvizVersion;
+ }
+
+ public final String getDebugData() {
+ return "SVG=" + svg + "\r\nDIAGRAM=" + diagramSource;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/AbstractGraphviz.java b/src/net/sourceforge/plantuml/cucadiagram/dot/AbstractGraphviz.java
new file mode 100644
index 0000000..34f3c89
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/dot/AbstractGraphviz.java
@@ -0,0 +1,190 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram.dot;
+
+import java.io.File;
+import java.io.OutputStream;
+import java.util.Arrays;
+import java.util.List;
+
+import net.sourceforge.plantuml.Log;
+import net.sourceforge.plantuml.OptionFlags;
+import net.sourceforge.plantuml.StringUtils;
+
+abstract class AbstractGraphviz implements Graphviz {
+
+ private final File dotExe;
+ private final String dotString;
+ private final String[] type;
+
+ static boolean isWindows() {
+ return File.separatorChar == '\\';
+ }
+
+ AbstractGraphviz(String dotString, String... type) {
+ if (type == null) {
+ throw new IllegalArgumentException();
+ }
+ this.dotExe = searchDotExe();
+ this.dotString = dotString;
+ this.type = type;
+ }
+
+ private File searchDotExe() {
+ if (OptionFlags.getInstance().getDotExecutable() == null) {
+ final String getenv = GraphvizUtils.getenvGraphvizDot();
+ if (getenv == null) {
+ return specificDotExe();
+ }
+ return new File(getenv);
+ }
+
+ return new File(OptionFlags.getInstance().getDotExecutable());
+
+ }
+
+ abstract protected File specificDotExe();
+
+ final public ProcessState createFile3(OutputStream os) {
+ if (dotString == null) {
+ throw new IllegalArgumentException();
+ }
+
+ if (illegalDotExe()) {
+ // createPngNoGraphviz(os, new FileFormatOption(FileFormat.valueOf(type[0].goUpperCase())));
+ throw new IllegalStateException();
+ }
+ final String cmd[] = getCommandLine();
+ ProcessRunner p = null;
+ ProcessState state = null;
+ try {
+ Log.info("Starting Graphviz process " + Arrays.asList(cmd));
+ Log.info("DotString size: " + dotString.length());
+ p = new ProcessRunner(cmd);
+ state = p.run(dotString.getBytes(), os);
+ // if (state == ProcessState.TERMINATED_OK) {
+ // result = true;
+ // }
+ Log.info("Ending process ok");
+ } catch (Throwable e) {
+ e.printStackTrace();
+ Log.error("Error: " + e);
+ Log.error("The command was " + cmd);
+ Log.error("");
+ Log.error("Try java -jar plantuml.jar -testdot to figure out the issue");
+ Log.error("");
+ } finally {
+ Log.info("Ending Graphviz process");
+ }
+ if (OptionFlags.getInstance().isCheckDotError() && p != null && p.getError().length() > 0) {
+ Log.error("GraphViz error stream : " + p.getError());
+ if (OptionFlags.getInstance().isCheckDotError()) {
+ throw new IllegalStateException("Dot error " + p.getError());
+ }
+ }
+ if (OptionFlags.getInstance().isCheckDotError() && p != null && p.getOut().length() > 0) {
+ Log.error("GraphViz out stream : " + p.getOut());
+ if (OptionFlags.getInstance().isCheckDotError()) {
+ throw new IllegalStateException("Dot out " + p.getOut());
+ }
+ }
+ return state;
+ }
+
+ public boolean illegalDotExe() {
+ return dotExe == null || dotExe.isFile() == false || dotExe.canRead() == false;
+ }
+
+ final public String dotVersion() {
+ final String cmd[] = getCommandLineVersion();
+ return executeCmd(cmd);
+ }
+
+ private String executeCmd(final String cmd[]) {
+ final ProcessRunner p = new ProcessRunner(cmd);
+ final ProcessState state = p.run(null, null);
+ if (state.differs(ProcessState.TERMINATED_OK())) {
+ return "?";
+ }
+ final StringBuilder sb = new StringBuilder();
+ if (StringUtils.isNotEmpty(p.getOut())) {
+ sb.append(p.getOut());
+ }
+ if (StringUtils.isNotEmpty(p.getError())) {
+ if (sb.length() > 0) {
+ sb.append(' ');
+ }
+ sb.append(p.getError());
+ }
+ return sb.toString().replace('\n', ' ').trim();
+ }
+
+ final String[] getCommandLine() {
+ if (OptionFlags.ADD_NICE_FOR_DOT) {
+ final String[] result = new String[type.length + 1 + 3];
+ result[0] = "/bin/nice";
+ result[1] = "-n";
+ result[2] = "10";
+ result[3] = getDotExe().getAbsolutePath();
+ for (int i = 0; i < type.length; i++) {
+ result[i + 4] = "-T" + type[i];
+ }
+ return result;
+ }
+ final String[] result = new String[type.length + 1];
+ result[0] = getDotExe().getAbsolutePath();
+ for (int i = 0; i < type.length; i++) {
+ result[i + 1] = "-T" + type[i];
+ }
+ return result;
+ }
+
+ final String[] getCommandLineVersion() {
+ return new String[] { getDotExe().getAbsolutePath(), "-V" };
+ }
+
+ public final File getDotExe() {
+ return dotExe;
+ }
+
+ public final String getDotString() {
+ return dotString;
+ }
+
+ public final List<String> getType() {
+ return Arrays.asList(type);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramPngMaker3.java b/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramPngMaker3.java
new file mode 100644
index 0000000..28641bb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramPngMaker3.java
@@ -0,0 +1,160 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram.dot;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Dimension2D;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import javax.imageio.ImageIO;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.EmptyImageBuilder;
+import net.sourceforge.plantuml.Log;
+import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.graph.ANode;
+import net.sourceforge.plantuml.graph.ANodeImpl;
+import net.sourceforge.plantuml.graph.Board;
+import net.sourceforge.plantuml.graph.BoardExplorer;
+import net.sourceforge.plantuml.graph.Graph5;
+import net.sourceforge.plantuml.graph.Heap;
+import net.sourceforge.plantuml.graph.Zoda2;
+
+public final class CucaDiagramPngMaker3 {
+
+ private final CucaDiagram diagram;
+
+ public CucaDiagramPngMaker3(CucaDiagram diagram) {
+ this.diagram = diagram;
+ }
+
+ public void createPng(OutputStream os) throws IOException {
+ final Zoda2 zoda2 = new Zoda2();
+
+ for (Link link : diagram.getLinks()) {
+ final String s = link.getEntity1().getCode() + "->" + link.getEntity2().getCode();
+ // Log.error("CucaDiagramPngMaker3:: " + s);
+ final int diffHeight = link.getLength() - 1;
+ // Log.error("CucaDiagramPngMaker3:: " + s + " " + diffHeight);
+ zoda2.addLink(s, diffHeight, link);
+ }
+ for (IEntity ent : diagram.getLeafsvalues()) {
+ ANode n = zoda2.getNode(ent.getCode().getFullName());
+ if (n == null) {
+ n = zoda2.createAloneNode(ent.getCode().getFullName());
+ }
+ ((ANodeImpl) n).setUserData(ent);
+ }
+
+ final List<Graph5> graphs = getGraphs3(zoda2.getHeaps());
+
+ final Dimension2D totalDim = getTotalDimension(graphs);
+ final EmptyImageBuilder im = new EmptyImageBuilder(totalDim.getWidth(), totalDim.getHeight(),
+ Color.WHITE);
+
+ double x = 0;
+
+ final Graphics2D g2d = im.getGraphics2D();
+
+ for (Graph5 g : graphs) {
+ g2d.setTransform(new AffineTransform());
+ g2d.translate(x, 0);
+ g.draw(g2d);
+ x += g.getDimension().getWidth();
+ }
+
+ ImageIO.write(im.getBufferedImage(), "png", os);
+ }
+
+ private Dimension2D getTotalDimension(List<Graph5> graphs) {
+ double width = 0;
+ double height = 0;
+ for (Graph5 g : graphs) {
+ width += g.getDimension().getWidth();
+ height = Math.max(height, g.getDimension().getHeight());
+ }
+ return new Dimension2DDouble(width, height);
+
+ }
+
+ private List<Graph5> getGraphs3(Collection<Heap> heaps) {
+ final List<Graph5> result = new ArrayList<Graph5>();
+ for (Heap h : heaps) {
+ h.computeRows();
+ Board board = new Board(h.getNodes(), h.getLinks());
+
+ final BoardExplorer boardExplorer = new BoardExplorer(board);
+ final long start = System.currentTimeMillis();
+ for (int i = 0; i < 400; i++) {
+ final boolean finished = boardExplorer.onePass();
+ if (finished) {
+ break;
+ }
+ if (i % 100 == 0) {
+ Log.info("" + i + " boardExplorer.getBestCost()=" + boardExplorer.getBestCost() + " "
+ + boardExplorer.collectionSize());
+ }
+ }
+ Log.info("################# DURATION = " + (System.currentTimeMillis() - start));
+ board = boardExplorer.getBestBoard();
+
+ result.add(new Graph5(board));
+ }
+ return result;
+ }
+
+// public List<File> createPng(File pngFile) throws IOException {
+// OutputStream os = null;
+// try {
+// os = new BufferedOutputStream(new FileOutputStream(pngFile));
+// createPng(os);
+// } finally {
+// if (os != null) {
+// os.close();
+// }
+// }
+//
+// return new PngSplitter(pngFile, diagram.getHorizontalPages(), diagram.getVerticalPages(), diagram.getMetadata(), 96)
+// .getFiles();
+// }
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramSimplifierActivity.java b/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramSimplifierActivity.java
new file mode 100644
index 0000000..b07abf7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramSimplifierActivity.java
@@ -0,0 +1,90 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram.dot;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
+import net.sourceforge.plantuml.cucadiagram.IGroup;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+import net.sourceforge.plantuml.svek.GroupPngMakerActivity;
+import net.sourceforge.plantuml.svek.IEntityImage;
+
+public final class CucaDiagramSimplifierActivity {
+
+ private final CucaDiagram diagram;
+
+ public CucaDiagramSimplifierActivity(CucaDiagram diagram, List<String> dotStrings) throws IOException,
+ InterruptedException {
+ this.diagram = diagram;
+ boolean changed;
+ do {
+ changed = false;
+ final Collection<IGroup> groups = new ArrayList<IGroup>(diagram.getGroups(false));
+ for (IGroup g : groups) {
+ if (diagram.isAutarkic(g)) {
+// final EntityType type;
+// if (g.zgetGroupType() == GroupType.INNER_ACTIVITY) {
+// type = EntityType.ACTIVITY;
+// } else if (g.zgetGroupType() == GroupType.CONCURRENT_ACTIVITY) {
+// type = EntityType.ACTIVITY_CONCURRENT;
+// } else {
+// throw new IllegalStateException();
+// }
+
+ final IEntityImage img = computeImage(g);
+ g.overideImage(img, LeafType.ACTIVITY);
+
+ changed = true;
+ }
+ }
+ } while (changed);
+ }
+
+// private void computeImageGroup(EntityMutable g, EntityMutable proxy, List<String> dotStrings) throws IOException,
+// InterruptedException {
+// final GroupPngMakerActivity maker = new GroupPngMakerActivity(diagram, g);
+// proxy.setSvekImage(maker.getImage());
+// }
+
+ private IEntityImage computeImage(IGroup g) throws IOException, InterruptedException {
+ final GroupPngMakerActivity maker = new GroupPngMakerActivity(diagram, g);
+ return maker.getImage();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramSimplifierState.java b/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramSimplifierState.java
new file mode 100644
index 0000000..4d09f5c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramSimplifierState.java
@@ -0,0 +1,91 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram.dot;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
+import net.sourceforge.plantuml.cucadiagram.GroupType;
+import net.sourceforge.plantuml.cucadiagram.IGroup;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+import net.sourceforge.plantuml.svek.GroupPngMakerState;
+import net.sourceforge.plantuml.svek.IEntityImage;
+
+public final class CucaDiagramSimplifierState {
+
+ private final CucaDiagram diagram;
+
+ public CucaDiagramSimplifierState(CucaDiagram diagram, List<String> dotStrings) throws IOException,
+ InterruptedException {
+ this.diagram = diagram;
+ boolean changed;
+ do {
+ changed = false;
+ final Collection<IGroup> groups = putConcurrentStateAtEnd(diagram.getGroups(false));
+ for (IGroup g : groups) {
+ if (diagram.isAutarkic(g)) {
+ final IEntityImage img = computeImage(g);
+ g.overideImage(img, g.getGroupType() == GroupType.CONCURRENT_STATE ? LeafType.STATE_CONCURRENT
+ : LeafType.STATE);
+
+ changed = true;
+ }
+ }
+ } while (changed);
+ }
+
+ private Collection<IGroup> putConcurrentStateAtEnd(Collection<IGroup> groups) {
+ final List<IGroup> result = new ArrayList<IGroup>();
+ final List<IGroup> end = new ArrayList<IGroup>();
+ for (IGroup g : groups) {
+ if (g.getGroupType() == GroupType.CONCURRENT_STATE) {
+ end.add(g);
+ } else {
+ result.add(g);
+ }
+ }
+ result.addAll(end);
+ return result;
+ }
+
+ private IEntityImage computeImage(IGroup g) throws IOException, InterruptedException {
+ final GroupPngMakerState maker = new GroupPngMakerState(diagram, g);
+ return maker.getImage();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramTxtMaker.java b/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramTxtMaker.java
new file mode 100644
index 0000000..9368f47
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/dot/CucaDiagramTxtMaker.java
@@ -0,0 +1,182 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram.dot;
+
+import java.awt.geom.Point2D;
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import net.sourceforge.plantuml.FileFormat;
+import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.cucadiagram.Member;
+import net.sourceforge.plantuml.posimo.Block;
+import net.sourceforge.plantuml.posimo.Cluster;
+import net.sourceforge.plantuml.posimo.GraphvizSolverB;
+import net.sourceforge.plantuml.posimo.Path;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+import net.sourceforge.plantuml.ugraphic.txt.UGraphicTxt;
+import net.sourceforge.plantuml.StringUtils;
+
+public final class CucaDiagramTxtMaker {
+
+ // private final CucaDiagram diagram;
+ private final FileFormat fileFormat;
+ private final UGraphicTxt globalUg = new UGraphicTxt();
+
+ private static double getXPixelPerChar() {
+ return 5;
+ }
+
+ private static double getYPixelPerChar() {
+ return 10;
+ }
+
+ public CucaDiagramTxtMaker(CucaDiagram diagram, FileFormat fileFormat) throws IOException {
+ // this.diagram = diagram;
+ this.fileFormat = fileFormat;
+
+ final Cluster root = new Cluster(null, 0, 0);
+ int uid = 0;
+
+ final Map<IEntity, Block> blocks = new HashMap<IEntity, Block>();
+
+ for (IEntity ent : diagram.getLeafsvalues()) {
+ // printClass(ent);
+ // ug.translate(0, getHeight(ent) + 1);
+ final double width = getWidth(ent) * getXPixelPerChar();
+ final double height = getHeight(ent) * getYPixelPerChar();
+ final Block b = new Block(uid++, width, height, null);
+ root.addBloc(b);
+ blocks.put(ent, b);
+ }
+
+ final GraphvizSolverB solver = new GraphvizSolverB();
+
+ final Collection<Path> paths = new ArrayList<Path>();
+ for (Link link : diagram.getLinks()) {
+ final Block b1 = blocks.get(link.getEntity1());
+ final Block b2 = blocks.get(link.getEntity2());
+ paths.add(new Path(b1, b2, null, link.getLength()));
+ }
+ solver.solve(root, paths);
+ for (Path p : paths) {
+ p.getDotPath().draw(globalUg.getCharArea(), getXPixelPerChar(), getYPixelPerChar());
+ }
+ for (IEntity ent : diagram.getLeafsvalues()) {
+ final Block b = blocks.get(ent);
+ final Point2D p = b.getPosition();
+ printClass(
+ ent,
+ (UGraphicTxt) globalUg.apply(new UTranslate(p.getX() / getXPixelPerChar(), p.getY()
+ / getYPixelPerChar())));
+ }
+
+ }
+
+ private void printClass(final IEntity ent, UGraphicTxt ug) {
+ final int w = getWidth(ent);
+ final int h = getHeight(ent);
+ ug.getCharArea().drawBoxSimple(0, 0, w, h);
+ ug.getCharArea().drawStringsLR(ent.getDisplay().as(), 1, 1);
+ int y = 2;
+ ug.getCharArea().drawHLine('-', y, 1, w - 1);
+ y++;
+ for (Member att : ent.getFieldsToDisplay()) {
+ final List<String> disp = StringUtils.getWithNewlines2(att.getDisplay(true));
+ ug.getCharArea().drawStringsLR(disp, 1, y);
+ y += StringUtils.getHeight(disp);
+ }
+ ug.getCharArea().drawHLine('-', y, 1, w - 1);
+ y++;
+ for (Member att : ent.getMethodsToDisplay()) {
+ final List<String> disp = StringUtils.getWithNewlines2(att.getDisplay(true));
+ ug.getCharArea().drawStringsLR(disp, 1, y);
+ y += StringUtils.getHeight(disp);
+ }
+ }
+
+ public List<File> createFiles(File suggestedFile) throws IOException {
+ if (fileFormat == FileFormat.UTXT) {
+ globalUg.getCharArea().print(new PrintStream(suggestedFile, "UTF-8"));
+ } else {
+ globalUg.getCharArea().print(new PrintStream(suggestedFile));
+ }
+ return Collections.singletonList(suggestedFile);
+ }
+
+ private int getHeight(IEntity entity) {
+ int result = StringUtils.getHeight(entity.getDisplay());
+ for (Member att : entity.getMethodsToDisplay()) {
+ result += StringUtils.getHeight(Display.getWithNewlines(att.getDisplay(true)));
+ }
+ for (Member att : entity.getFieldsToDisplay()) {
+ result += StringUtils.getHeight(Display.getWithNewlines(att.getDisplay(true)));
+ }
+ return result + 4;
+ }
+
+ private int getWidth(IEntity entity) {
+ int result = StringUtils.getWidth(entity.getDisplay());
+ for (Member att : entity.getMethodsToDisplay()) {
+ final int w = StringUtils.getWidth(Display.getWithNewlines(att.getDisplay(true)));
+ if (w > result) {
+ result = w;
+ }
+ }
+ for (Member att : entity.getFieldsToDisplay()) {
+ final int w = StringUtils.getWidth(Display.getWithNewlines(att.getDisplay(true)));
+ if (w > result) {
+ result = w;
+ }
+ }
+ return result + 2;
+ }
+
+ public void createFiles(OutputStream os, int index) {
+ globalUg.getCharArea().print(new PrintStream(os));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/DebugTrace.java b/src/net/sourceforge/plantuml/cucadiagram/dot/DebugTrace.java
new file mode 100644
index 0000000..3175659
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/dot/DebugTrace.java
@@ -0,0 +1,70 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram.dot;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.PrintWriter;
+
+public class DebugTrace {
+
+ private static final File out = new File("debug" + System.currentTimeMillis() + ".txt");
+
+ private static PrintWriter pw;
+
+ private synchronized static PrintWriter getPrintWriter() {
+ if (pw == null) {
+ try {
+ pw = new PrintWriter(out);
+ } catch (FileNotFoundException e) {
+
+ }
+ }
+ return pw;
+ }
+
+ public synchronized static void DEBUG(String s) {
+ final PrintWriter pw = getPrintWriter();
+ pw.println(s);
+ pw.flush();
+ }
+
+ public synchronized static void DEBUG(String s, Throwable t) {
+ DEBUG(s);
+ t.printStackTrace(pw);
+ pw.flush();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/DotData.java b/src/net/sourceforge/plantuml/cucadiagram/dot/DotData.java
new file mode 100644
index 0000000..63e3c25
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/dot/DotData.java
@@ -0,0 +1,229 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram.dot;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.Pragma;
+import net.sourceforge.plantuml.UmlDiagramType;
+import net.sourceforge.plantuml.cucadiagram.EntityPortion;
+import net.sourceforge.plantuml.cucadiagram.GroupHierarchy;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.IGroup;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.cucadiagram.LinkDecor;
+import net.sourceforge.plantuml.cucadiagram.PortionShower;
+import net.sourceforge.plantuml.cucadiagram.entity.EntityFactory;
+import net.sourceforge.plantuml.svek.DotMode;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+
+final public class DotData implements PortionShower {
+
+ final private List<Link> links;
+ final private Collection<ILeaf> leafs;
+ final private UmlDiagramType umlDiagramType;
+ final private ISkinParam skinParam;
+ // final private Rankdir rankdir;
+ final private GroupHierarchy groupHierarchy;
+ final private IGroup topParent;
+ final private PortionShower portionShower;
+ final private boolean isHideEmptyDescriptionForState;
+ final private DotMode dotMode;
+ final private String namespaceSeparator;
+ final private Pragma pragma;
+
+ private final ColorMapper colorMapper;
+ private final EntityFactory entityFactory;
+
+ public DotData(IGroup topParent, List<Link> links, Collection<ILeaf> leafs, UmlDiagramType umlDiagramType,
+ ISkinParam skinParam, GroupHierarchy groupHierarchy, PortionShower portionShower, ColorMapper colorMapper,
+ EntityFactory entityFactory, boolean isHideEmptyDescriptionForState, DotMode dotMode,
+ String namespaceSeparator, Pragma pragma) {
+ this.namespaceSeparator = namespaceSeparator;
+ this.pragma = pragma;
+ this.topParent = topParent;
+ if (topParent == null) {
+ throw new IllegalArgumentException();
+ }
+ this.dotMode = dotMode;
+ this.isHideEmptyDescriptionForState = isHideEmptyDescriptionForState;
+ this.colorMapper = colorMapper;
+ this.links = links;
+ this.leafs = leafs;
+ this.umlDiagramType = umlDiagramType;
+ this.skinParam = skinParam;
+ // this.rankdir = rankdir;
+ this.groupHierarchy = groupHierarchy;
+ this.portionShower = portionShower;
+ this.entityFactory = entityFactory;
+ }
+
+ public DotData(IGroup topParent, List<Link> links, Collection<ILeaf> leafs, UmlDiagramType umlDiagramType,
+ ISkinParam skinParam, GroupHierarchy groupHierarchy, ColorMapper colorMapper, EntityFactory entityFactory,
+ boolean isHideEmptyDescriptionForState, DotMode dotMode, String namespaceSeparator, Pragma pragma) {
+ this(topParent, links, leafs, umlDiagramType, skinParam, groupHierarchy, new PortionShower() {
+ public boolean showPortion(EntityPortion portion, IEntity entity) {
+ return true;
+ }
+ }, colorMapper, entityFactory, isHideEmptyDescriptionForState, dotMode, namespaceSeparator, pragma);
+ }
+
+ public UmlDiagramType getUmlDiagramType() {
+ return umlDiagramType;
+ }
+
+ public ISkinParam getSkinParam() {
+ return skinParam;
+ }
+
+ public GroupHierarchy getGroupHierarchy() {
+ return groupHierarchy;
+ }
+
+ public List<Link> getLinks() {
+ return links;
+ }
+
+ public Collection<ILeaf> getLeafs() {
+ return leafs;
+ }
+
+ public final IGroup getTopParent() {
+ return topParent;
+ }
+
+ public boolean isEmpty(IGroup g) {
+ return groupHierarchy.isEmpty(g);
+ }
+
+ public boolean showPortion(EntityPortion portion, IEntity entity) {
+ return portionShower.showPortion(portion, entity);
+ }
+
+ public final ColorMapper getColorMapper() {
+ return colorMapper;
+ }
+
+ public IGroup getRootGroup() {
+ return entityFactory.getRootGroup();
+ }
+
+ public final boolean isHideEmptyDescriptionForState() {
+ return isHideEmptyDescriptionForState;
+ }
+
+ public final DotMode getDotMode() {
+ return dotMode;
+ }
+
+ public final String getNamespaceSeparator() {
+ return namespaceSeparator;
+ }
+
+ public Pragma getPragma() {
+ return pragma;
+ }
+
+ public void removeIrrelevantSametail() {
+ final Map<String, Integer> sametails = new HashMap<String, Integer>();
+ for (Link link : links) {
+ if (link.getType().getDecor2() == LinkDecor.EXTENDS) {
+ link.setSametail(link.getEntity1().getUid());
+ }
+ final String sametail = link.getSametail();
+ if (sametail == null) {
+ continue;
+ }
+ final Integer value = sametails.get(sametail);
+ sametails.put(sametail, value == null ? 1 : value + 1);
+ }
+ final Collection<String> toremove = new HashSet<String>();
+ final int limit = skinParam.groupInheritance();
+ for (Map.Entry<String, Integer> ent : sametails.entrySet()) {
+ final String key = ent.getKey();
+ if (ent.getValue() < limit) {
+ toremove.add(key);
+ } else {
+ final List<Link> some = new ArrayList<Link>();
+ for (Link link : links) {
+ if (key.equals(link.getSametail())) {
+ some.add(link);
+ }
+ }
+ final ILeaf leaf = getLeaf(key);
+ final Neighborhood neighborhood = new Neighborhood(leaf, some, getLinksOfThisLeaf(leaf));
+ leaf.setNeighborhood(neighborhood);
+ }
+ }
+
+ for (Link link : links) {
+ final String sametail = link.getSametail();
+ if (sametail == null) {
+ continue;
+ }
+ if (toremove.contains(sametail)) {
+ link.setSametail(null);
+ }
+ }
+ }
+
+ private List<Link> getLinksOfThisLeaf(ILeaf leaf) {
+ final List<Link> result = new ArrayList<Link>();
+ for (Link link : links) {
+ if (link.contains(leaf)) {
+ result.add(link);
+ }
+ }
+ return result;
+ }
+
+ private ILeaf getLeaf(String key) {
+ for (ILeaf entity : leafs) {
+ if (entity.getUid().equals(key)) {
+ return entity;
+ }
+ }
+ return null;
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/DotMaker2.java b/src/net/sourceforge/plantuml/cucadiagram/dot/DotMaker2.java
new file mode 100644
index 0000000..5d41b7f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/dot/DotMaker2.java
@@ -0,0 +1,49 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram.dot;
+
+final public class DotMaker2 {
+
+ private static boolean isJunit = false;
+
+ public static void goJunit() {
+ isJunit = true;
+ }
+
+ public static final boolean isJunit() {
+ return isJunit;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/DotSplines.java b/src/net/sourceforge/plantuml/cucadiagram/dot/DotSplines.java
new file mode 100644
index 0000000..92f9f46
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/dot/DotSplines.java
@@ -0,0 +1,40 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram.dot;
+
+public enum DotSplines {
+ POLYLINE, ORTHO, SPLINES
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/Graphviz.java b/src/net/sourceforge/plantuml/cucadiagram/dot/Graphviz.java
new file mode 100644
index 0000000..9af8ffd
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/dot/Graphviz.java
@@ -0,0 +1,49 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram.dot;
+
+import java.io.File;
+import java.io.OutputStream;
+
+public interface Graphviz {
+
+ ProcessState createFile3(OutputStream os);
+
+ File getDotExe();
+
+ String dotVersion();
+
+ boolean illegalDotExe();
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizLayoutStrategy.java b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizLayoutStrategy.java
new file mode 100644
index 0000000..527ab32
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizLayoutStrategy.java
@@ -0,0 +1,61 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram.dot;
+
+import java.io.File;
+
+import net.sourceforge.plantuml.OptionFlags;
+
+public enum GraphvizLayoutStrategy {
+ DOT, NEATO, FDP, TWOPI, CIRCO;
+
+ public File getSystemForcedExecutable() {
+ return getSystemForcedDot();
+ }
+
+ private File getSystemForcedDot() {
+ if (OptionFlags.getInstance().getDotExecutable() == null) {
+ final String getenv = GraphvizUtils.getenvGraphvizDot();
+ if (getenv == null) {
+ return null;
+ }
+ return new File(getenv);
+ }
+
+ return new File(OptionFlags.getInstance().getDotExecutable());
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizLinux.java b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizLinux.java
new file mode 100644
index 0000000..99fee24
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizLinux.java
@@ -0,0 +1,56 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram.dot;
+
+import java.io.File;
+
+class GraphvizLinux extends AbstractGraphviz {
+
+ GraphvizLinux(String dotString, String... type) {
+ super(dotString, type);
+ }
+
+ @Override
+ protected File specificDotExe() {
+ final File usrLocalBinDot = new File("/usr/local/bin/dot");
+
+ if (usrLocalBinDot.exists()) {
+ return usrLocalBinDot;
+ }
+ final File usrBinDot = new File("/usr/bin/dot");
+ return usrBinDot;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizUtils.java b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizUtils.java
new file mode 100644
index 0000000..878bfe3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizUtils.java
@@ -0,0 +1,222 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram.dot;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.StringUtils;
+
+public class GraphvizUtils {
+
+ private static int DOT_VERSION_LIMIT = 226;
+
+ private static boolean isWindows() {
+ return File.separatorChar == '\\';
+ }
+
+ @Deprecated
+ public static Graphviz create(String dotString, String... type) {
+ final AbstractGraphviz result;
+ if (isWindows()) {
+ result = new GraphvizWindows(dotString, type);
+ } else {
+ result = new GraphvizLinux(dotString, type);
+ }
+ // if (OptionFlags.GRAPHVIZCACHE) {
+ // return new GraphvizCached(result);
+ // }
+ return result;
+ }
+
+ // public static Graphviz create2(GraphvizLayoutStrategy strategy, String
+ // dotString, String... type) {
+ // return new AbstractGraphviz2(getOS(), strategy, dotString, type);
+ // }
+
+ static public File getDotExe() {
+ return create(null, "png").getDotExe();
+ }
+
+ public static String getenvGraphvizDot() {
+ final String env = System.getProperty("GRAPHVIZ_DOT");
+ if (StringUtils.isNotEmpty(env)) {
+ return StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(env);
+ }
+ final String getenv = System.getenv("GRAPHVIZ_DOT");
+ if (StringUtils.isNotEmpty(getenv)) {
+ return StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(getenv);
+ }
+ return null;
+ }
+
+ public static String getenvLogData() {
+ final String env = System.getProperty("PLANTUML_LOGDATA");
+ if (StringUtils.isNotEmpty(env)) {
+ return env;
+ }
+ return System.getenv("PLANTUML_LOGDATA");
+ }
+
+ private static String dotVersion = null;
+
+ public static String dotVersion() throws IOException, InterruptedException {
+ if (dotVersion == null) {
+ if (GraphvizUtils.getDotExe() == null) {
+ dotVersion = "Error: Dot not installed";
+ } else if (GraphvizUtils.getDotExe().exists() == false) {
+ dotVersion = "Error: " + GraphvizUtils.getDotExe().getAbsolutePath() + " does not exist";
+ } else if (GraphvizUtils.getDotExe().isFile() == false) {
+ dotVersion = "Error: " + GraphvizUtils.getDotExe().getAbsolutePath() + " is not a file";
+ } else if (GraphvizUtils.getDotExe().canRead() == false) {
+ dotVersion = "Error: " + GraphvizUtils.getDotExe().getAbsolutePath() + " cannot be read";
+ } else {
+ dotVersion = create(null, "png").dotVersion();
+ }
+ }
+ return dotVersion;
+ }
+
+ public static int retrieveVersion(String s) {
+ if (s == null) {
+ return -1;
+ }
+ final Pattern p = Pattern.compile("\\s([12].\\d\\d)\\D");
+ final Matcher m = p.matcher(s);
+ if (m.find() == false) {
+ return -1;
+ }
+ return Integer.parseInt(m.group(1).replaceAll("\\.", ""));
+ }
+
+ public static int getDotVersion() throws IOException, InterruptedException {
+ return retrieveVersion(dotVersion());
+ }
+
+ static public List<String> getTestDotStrings(boolean withRichText) {
+ String red = "";
+ String bold = "";
+ if (withRichText) {
+ red = "<b><color:red>";
+ bold = "<b>";
+ }
+ final List<String> result = new ArrayList<String>();
+ final String ent = GraphvizUtils.getenvGraphvizDot();
+ if (ent == null) {
+ result.add("The environment variable GRAPHVIZ_DOT has not been set");
+ } else {
+ result.add("The environment variable GRAPHVIZ_DOT has been set to " + ent);
+ }
+ final File dotExe = GraphvizUtils.getDotExe();
+ result.add("Dot executable is " + dotExe);
+
+ boolean ok = true;
+ if (dotExe == null) {
+ result.add(red + "Error: No dot executable found");
+ ok = false;
+ } else if (dotExe.exists() == false) {
+ result.add(red + "Error: file does not exist");
+ ok = false;
+ } else if (dotExe.isFile() == false) {
+ result.add(red + "Error: not a valid file");
+ ok = false;
+ } else if (dotExe.canRead() == false) {
+ result.add(red + "Error: cannot be read");
+ ok = false;
+ }
+
+ if (ok) {
+ try {
+ final String version = GraphvizUtils.dotVersion();
+ result.add("Dot version: " + version);
+ final int v = GraphvizUtils.getDotVersion();
+ if (v == -1) {
+ result.add("Warning : cannot determine dot version");
+ } else if (v < DOT_VERSION_LIMIT) {
+ result.add(bold + "Warning : Your dot installation seems old");
+ result.add(bold + "Some diagrams may have issues");
+ } else {
+ final String err = getTestCreateSimpleFile();
+ if (err == null) {
+ result.add(bold + "Installation seems OK. File generation OK");
+ } else {
+ result.add(red + err);
+ }
+ }
+ } catch (Exception e) {
+ result.add(red + e.toString());
+ e.printStackTrace();
+ }
+ } else {
+ result.add("Error: only sequence diagrams will be generated");
+ }
+
+ return Collections.unmodifiableList(result);
+ }
+
+ static String getTestCreateSimpleFile() throws IOException {
+ final Graphviz graphviz2 = GraphvizUtils.create("digraph foo { test; }", "svg");
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final ProcessState state = graphviz2.createFile3(baos);
+ if (state.differs(ProcessState.TERMINATED_OK())) {
+ return "Error: timeout " + state;
+ }
+
+ final byte data[] = baos.toByteArray();
+
+ if (data.length == 0) {
+ return "Error: dot generates empty file. Check you dot installation.";
+ }
+ final String s = new String(data);
+ if (s.indexOf("<svg") == -1) {
+ return "Error: dot generates unreadable SVG file. Check you dot installation.";
+ }
+ return null;
+ }
+
+ // public static OS getOS() {
+ // if (isWindows()) {
+ // return new OSWindows();
+ // }
+ // return new OSLinux();
+ // }
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizVersion.java b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizVersion.java
new file mode 100644
index 0000000..54f0d38
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizVersion.java
@@ -0,0 +1,44 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram.dot;
+
+public interface GraphvizVersion {
+ public boolean useShield();
+
+ public boolean useProtectionWhenThereALinkFromOrToGroup();
+
+ // COMMON, V2_34_0
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizVersionFinder.java b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizVersionFinder.java
new file mode 100644
index 0000000..fea579c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizVersionFinder.java
@@ -0,0 +1,108 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram.dot;
+
+import java.io.File;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.StringUtils;
+
+public class GraphvizVersionFinder {
+
+ final private File dotExe;
+ final private static GraphvizVersion DEFAULT = new GraphvizVersion() {
+ public boolean useShield() {
+ return true;
+ }
+
+ public boolean useProtectionWhenThereALinkFromOrToGroup() {
+ return true;
+ }
+ };
+
+ public GraphvizVersionFinder(File dotExe) {
+ this.dotExe = dotExe;
+ }
+
+ public GraphvizVersion getVersion() {
+ final String dotVersion = dotVersion();
+ final Pattern p = Pattern.compile("\\d\\.\\d\\d");
+ final Matcher m = p.matcher(dotVersion);
+ final boolean find = m.find();
+ if (find == false) {
+ return DEFAULT;
+ }
+ final String vv = m.group(0);
+ final int v = Integer.parseInt(vv.replaceAll("\\.", ""));
+ return new GraphvizVersion() {
+ public boolean useShield() {
+ return v <= 228;
+ }
+
+ public boolean useProtectionWhenThereALinkFromOrToGroup() {
+ // return v < 238;
+ return true;
+ }
+
+ };
+ }
+
+ public String dotVersion() {
+ final String cmd[] = getCommandLine();
+
+ final ProcessRunner p = new ProcessRunner(cmd);
+ final ProcessState state = p.run(null, null);
+ if (state.differs(ProcessState.TERMINATED_OK())) {
+ return "?";
+ }
+ final StringBuilder sb = new StringBuilder();
+ if (StringUtils.isNotEmpty(p.getOut())) {
+ sb.append(p.getOut());
+ }
+ if (StringUtils.isNotEmpty(p.getError())) {
+ if (sb.length() > 0) {
+ sb.append(' ');
+ }
+ sb.append(p.getError());
+ }
+ return sb.toString().replace('\n', ' ').trim();
+ }
+
+ private String[] getCommandLine() {
+ return new String[] { dotExe.getAbsolutePath(), "-V" };
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizVersions.java b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizVersions.java
new file mode 100644
index 0000000..b05ff49
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizVersions.java
@@ -0,0 +1,72 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram.dot;
+
+import java.io.File;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+public class GraphvizVersions {
+
+ private final static GraphvizVersions singleton = new GraphvizVersions();
+
+ private final Map<File, GraphvizVersion> map = new ConcurrentHashMap<File, GraphvizVersion>();
+
+ private GraphvizVersions() {
+ }
+
+ public static GraphvizVersions getInstance() {
+ return singleton;
+ }
+
+ public GraphvizVersion getVersion(File f) {
+ if (f == null) {
+ return null;
+ }
+ GraphvizVersion result = map.get(f);
+ if (result != null) {
+ return result;
+ }
+ result = checkVersionSlow(f.getAbsolutePath());
+ map.put(f, result);
+ return result;
+ }
+
+ static GraphvizVersion checkVersionSlow(String pathExecutable) {
+ final GraphvizVersionFinder finder = new GraphvizVersionFinder(new File(pathExecutable));
+ return finder.getVersion();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizWindows.java b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizWindows.java
new file mode 100644
index 0000000..254b792
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizWindows.java
@@ -0,0 +1,94 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram.dot;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import net.sourceforge.plantuml.StringUtils;
+
+class GraphvizWindows extends AbstractGraphviz {
+
+ @Override
+ protected File specificDotExe() {
+ final File result = searchInDir(new File("c:/Program Files"));
+ if (result != null) {
+ return result;
+ }
+ final File result86 = searchInDir(new File("c:/Program Files (x86)"));
+ if (result86 != null) {
+ return result86;
+ }
+ final File resultEclipse = searchInDir(new File("c:/eclipse/graphviz"));
+ if (resultEclipse != null) {
+ return resultEclipse;
+ }
+ return null;
+ }
+
+ private static File searchInDir(final File programFile) {
+ if (programFile.exists() == false || programFile.isDirectory() == false) {
+ return null;
+ }
+ final List<File> dots = new ArrayList<File>();
+ for (File f : programFile.listFiles(new FileFilter() {
+ public boolean accept(File pathname) {
+ return pathname.isDirectory() && StringUtils.goLowerCase(pathname.getName()).startsWith("graphviz");
+ }
+ })) {
+ final File result = new File(new File(f, "bin"), "dot.exe");
+ if (result.exists() && result.canRead()) {
+ dots.add(result.getAbsoluteFile());
+ }
+ }
+ return higherVersion(dots);
+ }
+
+ static File higherVersion(List<File> dots) {
+ if (dots.size() == 0) {
+ return null;
+ }
+ Collections.sort(dots, Collections.reverseOrder());
+ return dots.get(0);
+ }
+
+ GraphvizWindows(String dotString, String... type) {
+ super(dotString, type);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/Neighborhood.java b/src/net/sourceforge/plantuml/cucadiagram/dot/Neighborhood.java
new file mode 100644
index 0000000..3dbe58c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/dot/Neighborhood.java
@@ -0,0 +1,189 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram.dot;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.svek.Bibliotekon;
+import net.sourceforge.plantuml.svek.Line;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class Neighborhood {
+
+ private final ILeaf leaf;
+ private final List<Link> sametailLinks;
+ private final List<Link> allButSametails;
+
+ public Neighborhood(ILeaf leaf, List<Link> sametailLinks, List<Link> all) {
+ this.leaf = leaf;
+ this.sametailLinks = sametailLinks;
+ this.allButSametails = new ArrayList<Link>(all);
+ allButSametails.removeAll(sametailLinks);
+ }
+
+ public void drawU(UGraphic ug, double minX, double minY, Bibliotekon bibliotekon, Dimension2D shapeDim) {
+ final Set<Point2D> contactPoints = new HashSet<Point2D>();
+ for (Link link : sametailLinks) {
+ final Line line = bibliotekon.getLine(link);
+ final Point2D contact = line.getStartContactPoint();
+ contactPoints.add(contact);
+ }
+ final Rectangle2D rect = new Rectangle2D.Double(minX, minY, shapeDim.getWidth(), shapeDim.getHeight());
+ final Point2D center = new Point2D.Double(rect.getCenterX(), rect.getCenterY());
+
+ for (Point2D pt : contactPoints) {
+ final Point2D inter = intersection(rect, center, pt);
+ if (inter == null) {
+ // System.err.println("rect=" + rect);
+ // System.err.println("center=" + center);
+ // System.err.println("pt=" + pt);
+ assert false;
+ continue;
+ }
+ final double theta = Math.atan2(center.getX() - pt.getX(), -(center.getY() - pt.getY()));
+ final Point2D middle = drawExtends(ug, inter, theta);
+ drawLine(ug, middle, pt);
+ }
+
+ for (Link link : allButSametails) {
+ final Line line = bibliotekon.getLine(link);
+ final Point2D contact = link.getEntity1() == leaf ? line.getStartContactPoint() : line.getEndContactPoint();
+ if (contact == null) {
+ assert false;
+ continue;
+ }
+ final Point2D inter = intersection(rect, center, contact);
+ if (inter == null) {
+ assert false;
+ continue;
+ }
+ drawLine(ug, inter, contact);
+ }
+ }
+
+ private Point2D drawExtends(UGraphic ug, Point2D contact, double theta) {
+ final UPolygon poly = new UPolygon();
+ poly.addPoint(0, 0);
+ poly.addPoint(7, 20);
+ poly.addPoint(-7, 20);
+ poly.rotate(theta);
+ final UTranslate translate = new UTranslate(contact);
+ ug.apply(translate).draw(poly);
+ final Point2D p1 = translate.getTranslated(poly.getPoints().get(1));
+ final Point2D p2 = translate.getTranslated(poly.getPoints().get(2));
+ return new Point2D.Double((p1.getX() + p2.getX()) / 2, (p1.getY() + p2.getY()) / 2);
+ }
+
+ static Point2D intersection(Rectangle2D rect, Point2D pt1, Point2D pt2) {
+ Point2D p;
+ p = intersection(new Point2D.Double(rect.getMinX(), rect.getMinY()),
+ new Point2D.Double(rect.getMaxX(), rect.getMinY()), pt1, pt2);
+ if (p != null) {
+ return p;
+ }
+ p = intersection(new Point2D.Double(rect.getMinX(), rect.getMaxY()),
+ new Point2D.Double(rect.getMaxX(), rect.getMaxY()), pt1, pt2);
+ if (p != null) {
+ return p;
+ }
+ p = intersection(new Point2D.Double(rect.getMinX(), rect.getMinY()),
+ new Point2D.Double(rect.getMinX(), rect.getMaxY()), pt1, pt2);
+ if (p != null) {
+ return p;
+ }
+ p = intersection(new Point2D.Double(rect.getMaxX(), rect.getMinY()),
+ new Point2D.Double(rect.getMaxX(), rect.getMaxY()), pt1, pt2);
+ if (p != null) {
+ return p;
+ }
+ return null;
+ }
+
+ static private Point2D intersection(Point2D pt1, Point2D pt2, Point2D pt3, Point2D pt4) {
+ // System.err.println("Checking intersection of " + pt1 + "-" + pt2 + " and " + pt3 + "-" + pt4);
+ return intersection(pt1.getX(), pt1.getY(), pt2.getX(), pt2.getY(), pt3.getX(), pt3.getY(), pt4.getX(),
+ pt4.getY());
+ }
+
+ private static final double epsilon = .001;
+
+ static private Point2D intersection(double x1, double y1, double x2, double y2, double x3, double y3, double x4,
+ double y4) {
+ final double d = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4);
+ if (d == 0) {
+ return null;
+
+ }
+ final double xi = ((x3 - x4) * (x1 * y2 - y1 * x2) - (x1 - x2) * (x3 * y4 - y3 * x4)) / d;
+ final double yi = ((y3 - y4) * (x1 * y2 - y1 * x2) - (y1 - y2) * (x3 * y4 - y3 * x4)) / d;
+
+ final Point2D.Double p = new Point2D.Double(xi, yi);
+ if (xi + epsilon < Math.min(x1, x2) || xi - epsilon > Math.max(x1, x2)) {
+ return null;
+ }
+ if (xi + epsilon < Math.min(x3, x4) || xi - epsilon > Math.max(x3, x4)) {
+ return null;
+ }
+ if (yi + epsilon < Math.min(y1, y2) || yi - epsilon > Math.max(y1, y2)) {
+ return null;
+ }
+ if (yi + epsilon < Math.min(y3, y4) || yi - epsilon > Math.max(y3, y4)) {
+ return null;
+ }
+ return p;
+ }
+
+ private void drawLine(UGraphic ug, Point2D pt1, Point2D pt2) {
+ drawLine(ug, pt1.getX(), pt1.getY(), pt2.getX(), pt2.getY());
+ }
+
+ private void drawLine(UGraphic ug, double x1, double y1, double x2, double y2) {
+ final ULine line = new ULine(x2 - x1, y2 - y1);
+ ug.apply(new UTranslate(x1, y1)).draw(line);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/OS.java b/src/net/sourceforge/plantuml/cucadiagram/dot/OS.java
new file mode 100644
index 0000000..29d9a85
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/dot/OS.java
@@ -0,0 +1,51 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram.dot;
+
+import java.io.File;
+
+abstract class OS {
+
+ static boolean isWindows() {
+ return File.separatorChar == '\\';
+ }
+
+ abstract String getFileName(GraphvizLayoutStrategy strategy);
+
+ abstract File getExecutable(GraphvizLayoutStrategy strategy);
+
+ public abstract String getCommand(GraphvizLayoutStrategy strategy);
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/OSLinux.java b/src/net/sourceforge/plantuml/cucadiagram/dot/OSLinux.java
new file mode 100644
index 0000000..6ccfc85
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/dot/OSLinux.java
@@ -0,0 +1,69 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram.dot;
+
+import java.io.File;
+
+import net.sourceforge.plantuml.StringUtils;
+
+class OSLinux extends OS {
+
+ @Override
+ File getExecutable(GraphvizLayoutStrategy strategy) {
+ final File result = strategy.getSystemForcedExecutable();
+ if (result != null) {
+ return result;
+ }
+ final String fileName = getFileName(strategy);
+ final File usrLocalBin = new File("/usr/local/bin/" + fileName);
+
+ if (usrLocalBin.exists()) {
+ return usrLocalBin;
+ }
+ final File usrBin = new File("/usr/bin/" + fileName);
+ return usrBin;
+ }
+
+ @Override
+ String getFileName(GraphvizLayoutStrategy strategy) {
+ return StringUtils.goLowerCase(strategy.name());
+ }
+
+ @Override
+ public String getCommand(GraphvizLayoutStrategy strategy) {
+ return getExecutable(strategy).getAbsolutePath();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/OSWindows.java b/src/net/sourceforge/plantuml/cucadiagram/dot/OSWindows.java
new file mode 100644
index 0000000..e40c6aa
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/dot/OSWindows.java
@@ -0,0 +1,97 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram.dot;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import net.sourceforge.plantuml.StringUtils;
+
+class OSWindows extends OS {
+
+ @Override
+ File getExecutable(GraphvizLayoutStrategy strategy) {
+ File result = strategy.getSystemForcedExecutable();
+ if (result != null) {
+ return result;
+ }
+ result = searchInDir(new File("c:/Program Files"), strategy);
+ if (result != null) {
+ return result;
+ }
+ result = searchInDir(new File("c:/Program Files (x86)"), strategy);
+ return result;
+ }
+
+ private File searchInDir(final File programFile, GraphvizLayoutStrategy strategy) {
+ if (programFile.exists() == false || programFile.isDirectory() == false) {
+ return null;
+ }
+ final List<File> dots = new ArrayList<File>();
+ for (File f : programFile.listFiles(new FileFilter() {
+ public boolean accept(File pathname) {
+ return pathname.isDirectory() && pathname.getName().startsWith("Graphviz");
+ }
+ })) {
+ final File result = new File(new File(f, "bin"), getFileName(strategy));
+ if (result.exists() && result.canRead()) {
+ dots.add(result.getAbsoluteFile());
+ }
+ }
+ return higherVersion(dots);
+ }
+
+ static File higherVersion(List<File> dots) {
+ if (dots.size() == 0) {
+ return null;
+ }
+ Collections.sort(dots, Collections.reverseOrder());
+ return dots.get(0);
+ }
+
+ @Override
+ String getFileName(GraphvizLayoutStrategy strategy) {
+ return StringUtils.goLowerCase(strategy.name()) + ".exe";
+ }
+
+ @Override
+ public String getCommand(GraphvizLayoutStrategy strategy) {
+ return "\"" + getExecutable(strategy).getAbsolutePath() + "\"";
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/ProcessRunner.java b/src/net/sourceforge/plantuml/cucadiagram/dot/ProcessRunner.java
new file mode 100644
index 0000000..d73686b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/dot/ProcessRunner.java
@@ -0,0 +1,284 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram.dot;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+import net.sourceforge.plantuml.api.MyRunnable;
+import net.sourceforge.plantuml.api.TimeoutExecutor;
+
+public class ProcessRunner {
+ // http://steveliles.github.io/invoking_processes_from_java.html
+ public static long TIMEOUT = 15 * 60 * 1000L;
+
+ private final String[] cmd;
+
+ private String error;
+ private String out;
+
+ private volatile ProcessState state = ProcessState.INIT();
+ private final Lock changeState = new ReentrantLock();
+
+ public ProcessRunner(String[] cmd) {
+ this.cmd = cmd;
+ }
+
+ public ProcessState run(byte in[], OutputStream redirection) {
+ return run(in, redirection, null);
+ }
+
+ public ProcessState run(byte in[], OutputStream redirection, File dir) {
+ if (this.state.differs(ProcessState.INIT())) {
+ throw new IllegalStateException();
+ }
+ this.state = ProcessState.RUNNING();
+ final MainThread mainThread = new MainThread(cmd, dir, redirection, in);
+ try {
+ final boolean done = new TimeoutExecutor(TIMEOUT).executeNow(mainThread);
+ } finally {
+ changeState.lock();
+ try {
+ if (state.equals(ProcessState.RUNNING())) {
+ state = ProcessState.TIMEOUT();
+ // mainThread.cancel();
+ }
+ } finally {
+ changeState.unlock();
+ }
+ }
+ if (state.equals(ProcessState.TERMINATED_OK())) {
+ assert mainThread != null;
+ this.error = mainThread.getError();
+ this.out = mainThread.getOut();
+ }
+ return state;
+ }
+
+ class MainThread implements MyRunnable {
+
+ private final String[] cmd;
+ private final File dir;
+ private final OutputStream redirection;
+ private final byte[] in;
+ private volatile Process process;
+ private volatile ThreadStream errorStream;
+ private volatile ThreadStream outStream;
+
+ public MainThread(String[] cmd, File dir, OutputStream redirection, byte[] in) {
+ this.cmd = cmd;
+ this.dir = dir;
+ this.redirection = redirection;
+ this.in = in;
+ }
+
+ public String getOut() {
+ return outStream.getString();
+ }
+
+ public String getError() {
+ return errorStream.getString();
+ }
+
+ public void runJob() throws InterruptedException {
+ try {
+ startThreads();
+ if (state.equals(ProcessState.RUNNING())) {
+ final int result = joinInternal();
+ }
+ } finally {
+ changeState.lock();
+ try {
+ if (state.equals(ProcessState.RUNNING())) {
+ state = ProcessState.TERMINATED_OK();
+ }
+ } finally {
+ changeState.unlock();
+ }
+ if (process != null) {
+ process.destroy();
+ close(process.getErrorStream());
+ close(process.getOutputStream());
+ close(process.getInputStream());
+ }
+ }
+
+ }
+
+ public void cancelJob() {
+ // The changeState lock is ok
+ // assert changeState.tryLock();
+ // assert state == ProcessState.TIMEOUT;
+ if (process != null) {
+ errorStream.cancel();
+ outStream.cancel();
+ process.destroy();
+ // interrupt();
+ close(process.getErrorStream());
+ close(process.getOutputStream());
+ close(process.getInputStream());
+ }
+ }
+
+ private void startThreads() {
+ try {
+ process = Runtime.getRuntime().exec(cmd, null, dir);
+ } catch (IOException e) {
+ e.printStackTrace();
+ changeState.lock();
+ try {
+ state = ProcessState.IO_EXCEPTION1(e);
+ } finally {
+ changeState.unlock();
+ }
+ e.printStackTrace();
+ return;
+ }
+ errorStream = new ThreadStream(process.getErrorStream(), null);
+ outStream = new ThreadStream(process.getInputStream(), redirection);
+ errorStream.start();
+ outStream.start();
+ if (in != null) {
+ final OutputStream os = process.getOutputStream();
+ try {
+ try {
+ os.write(in);
+ } finally {
+ os.close();
+ }
+ } catch (IOException e) {
+ changeState.lock();
+ try {
+ state = ProcessState.IO_EXCEPTION2(e);
+ } finally {
+ changeState.unlock();
+ }
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public int joinInternal() throws InterruptedException {
+ errorStream.join();
+ outStream.join();
+ final int result = process.waitFor();
+ return result;
+ }
+
+ }
+
+ class ThreadStream extends Thread {
+
+ private volatile InputStream streamToRead;
+ private volatile OutputStream redirection;
+ private volatile StringBuffer sb = new StringBuffer();
+
+ ThreadStream(InputStream streamToRead, OutputStream redirection) {
+ this.streamToRead = streamToRead;
+ this.redirection = redirection;
+ }
+
+ public String getString() {
+ if (sb==null) {
+ return "";
+ }
+ return sb.toString();
+ }
+
+ public void cancel() {
+ assert state.equals(ProcessState.TIMEOUT()) || state.equals(ProcessState.RUNNING()) : state;
+ this.interrupt();
+ sb = null;
+ streamToRead = null;
+ redirection = null;
+ // Because of this, some NPE may occurs in run() method, but we do not care
+ }
+
+ @Override
+ public void run() {
+ int read = 0;
+ try {
+ while ((read = streamToRead.read()) != -1) {
+ if (state.equals(ProcessState.TIMEOUT())) {
+ return;
+ }
+ if (redirection == null) {
+ sb.append((char) read);
+ } else {
+ redirection.write(read);
+ }
+ }
+ } catch (Throwable e) {
+ System.err.println("ProcessRunnerA " + e);
+ e.printStackTrace();
+ sb.append('\n');
+ sb.append(e.toString());
+ }
+ }
+ }
+
+ public final String getError() {
+ return error;
+ }
+
+ public final String getOut() {
+ return out;
+ }
+
+ private void close(InputStream is) {
+ try {
+ if (is != null) {
+ is.close();
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void close(OutputStream os) {
+ try {
+ if (os != null) {
+ os.close();
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/ProcessState.java b/src/net/sourceforge/plantuml/cucadiagram/dot/ProcessState.java
new file mode 100644
index 0000000..2d22593
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/dot/ProcessState.java
@@ -0,0 +1,101 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram.dot;
+
+import java.io.IOException;
+
+public class ProcessState {
+
+ private final String name;
+ private final IOException cause;
+
+ private ProcessState(String name, IOException cause) {
+ this.name = name;
+ this.cause = cause;
+ }
+
+ @Override
+ public String toString() {
+ if (cause == null) {
+ return name;
+ }
+ return name + " " + cause.toString();
+ }
+
+ private final static ProcessState INIT = new ProcessState("INIT", null);
+ private final static ProcessState RUNNING = new ProcessState("RUNNING", null);
+ private final static ProcessState TERMINATED_OK = new ProcessState("TERMINATED_OK", null);
+ private final static ProcessState TIMEOUT = new ProcessState("TIMEOUT", null);
+
+ // INIT, RUNNING, TERMINATED_OK, TIMEOUT, IO_EXCEPTION1, IO_EXCEPTION2;
+
+ public static ProcessState INIT() {
+ return INIT;
+ }
+
+ public static ProcessState RUNNING() {
+ return RUNNING;
+ }
+
+ public static ProcessState TERMINATED_OK() {
+ return TERMINATED_OK;
+ }
+
+ public static ProcessState TIMEOUT() {
+ return TIMEOUT;
+ }
+
+ public static ProcessState IO_EXCEPTION1(IOException e) {
+ return new ProcessState("IO_EXCEPTION1", e);
+ }
+
+ public static ProcessState IO_EXCEPTION2(IOException e) {
+ return new ProcessState("IO_EXCEPTION2", e);
+ }
+
+ public boolean differs(ProcessState other) {
+ return name.equals(other.name) == false;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ final ProcessState other = (ProcessState) o;
+ return name.equals(other.name);
+ }
+
+ public Throwable getCause() {
+ return cause;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/entity/EntityFactory.java b/src/net/sourceforge/plantuml/cucadiagram/entity/EntityFactory.java
new file mode 100644
index 0000000..e99da6b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/entity/EntityFactory.java
@@ -0,0 +1,246 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram.entity;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import net.sourceforge.plantuml.cucadiagram.Bodier;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.GroupRoot;
+import net.sourceforge.plantuml.cucadiagram.GroupType;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.IGroup;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.cucadiagram.LongCode;
+import net.sourceforge.plantuml.skin.VisibilityModifier;
+
+public class EntityFactory {
+
+ private final Map<Code, ILeaf> leafs = new Protect<ILeaf>(new LinkedHashMap<Code, ILeaf>());
+ private final List<Link> links = new ArrayList<Link>();
+ private final Map<Code, IGroup> groups = new Protect<IGroup>(new LinkedHashMap<Code, IGroup>());
+ private int rawLayout;
+
+ private final IGroup rootGroup = new GroupRoot(this);
+ private final Set<LeafType> hiddenTypes;
+
+ public EntityFactory(Set<LeafType> hiddenTypes) {
+ this.hiddenTypes = hiddenTypes;
+ }
+
+ public boolean isHidden(LeafType leafType) {
+ return hiddenTypes.contains(leafType);
+ }
+
+ public ILeaf createLeaf(Code code, Display display, LeafType entityType, IGroup parentContainer,
+ Set<VisibilityModifier> hides, String namespaceSeparator) {
+ if (entityType == null) {
+ throw new IllegalArgumentException();
+ }
+ final Bodier bodier = new Bodier(entityType, hides);
+ final LongCode longCode = getLongCode(code, namespaceSeparator);
+ final EntityImpl result = new EntityImpl(this, code, bodier, parentContainer, entityType, longCode,
+ namespaceSeparator, rawLayout);
+ result.setDisplay(display);
+ return result;
+ }
+
+ private LongCode getLongCode(Code code, String namespaceSeparator) {
+ final LongCode result = LongCode.of(code.getFullName(), namespaceSeparator);
+ // if (result.toString().equals(code.toString()) == false) {
+ // System.err.println("result=" + result);
+ // System.err.println(" code =" + code);
+ // throw new UnsupportedOperationException();
+ // }
+ return result;
+ }
+
+ public IGroup createGroup(Code code, Display display, Code namespace2, GroupType groupType, IGroup parentContainer,
+ Set<VisibilityModifier> hides, String namespaceSeparator) {
+ if (groupType == null) {
+ throw new IllegalArgumentException();
+ }
+ final Bodier bodier = new Bodier(null, hides);
+ final LongCode longCode = getLongCode(code, namespaceSeparator);
+ final EntityImpl result = new EntityImpl(this, code, bodier, parentContainer, groupType, namespace2, longCode,
+ namespaceSeparator, rawLayout);
+ if (display != null) {
+ result.setDisplay(display);
+ }
+ return result;
+ }
+
+ public IGroup getRootGroup() {
+ return rootGroup;
+ }
+
+ public final Map<Code, ILeaf> getLeafs() {
+ return Collections.unmodifiableMap(leafs);
+ }
+
+ public void addLeaf(ILeaf entity) {
+ leafs.put(entity.getCode(), entity);
+ }
+
+ public void incRawLayout() {
+ rawLayout++;
+ }
+
+ void removeLeaf(Code code) {
+ final IEntity removed = leafs.remove(code);
+ if (removed == null) {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ public void addGroup(IGroup group) {
+ groups.put(group.getCode(), group);
+ }
+
+ void removeGroup(Code code) {
+ final IEntity removed = groups.remove(code);
+ if (removed == null) {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ public final Map<Code, IGroup> getGroups() {
+ return Collections.unmodifiableMap(groups);
+ }
+
+ public final List<Link> getLinks() {
+ return Collections.unmodifiableList(links);
+ }
+
+ public void addLink(Link link) {
+ links.add(link);
+ }
+
+ public void removeLink(Link link) {
+ final boolean ok = links.remove(link);
+ if (ok == false) {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ public IGroup muteToGroup(Code code, Code namespace2, GroupType type, IGroup parent) {
+ final ILeaf leaf = getLeafs().get(code);
+ ((EntityImpl) leaf).muteToGroup(namespace2, type, parent);
+ final IGroup result = (IGroup) leaf;
+ removeLeaf(code);
+ return result;
+ }
+
+ static class Protect<O extends Object> implements Map<Code, O> {
+
+ private final Map<Code, O> m;
+
+ public Protect(Map<Code, O> data) {
+ this.m = data;
+ }
+
+ public O remove(Object key) {
+ if (key instanceof Code == false) {
+ throw new IllegalArgumentException();
+ }
+ return m.remove(key);
+ }
+
+ public O get(Object key) {
+ if (key instanceof Code == false) {
+ throw new IllegalArgumentException();
+ }
+ return m.get(key);
+ }
+
+ public Set<Code> keySet() {
+ return m.keySet();
+ }
+
+ public void putAll(Map<? extends Code, ? extends O> m) {
+ this.m.putAll(m);
+ }
+
+ public boolean containsKey(Object key) {
+ if (key instanceof Code == false) {
+ throw new IllegalArgumentException();
+ }
+ return m.containsKey(key);
+ }
+
+ public boolean isEmpty() {
+ return m.isEmpty();
+ }
+
+ public O put(Code key, O value) {
+ if (key instanceof Code == false) {
+ throw new IllegalArgumentException();
+ }
+ return m.put(key, value);
+ }
+
+ public boolean containsValue(Object value) {
+ return m.containsValue(value);
+ }
+
+ public Set<Map.Entry<Code, O>> entrySet() {
+ return m.entrySet();
+ }
+
+ public Collection<O> values() {
+ return m.values();
+ }
+
+ public void clear() {
+ m.clear();
+
+ }
+
+ public int size() {
+ return m.size();
+ }
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cucadiagram/entity/EntityImpl.java b/src/net/sourceforge/plantuml/cucadiagram/entity/EntityImpl.java
new file mode 100644
index 0000000..2fd8d5e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cucadiagram/entity/EntityImpl.java
@@ -0,0 +1,652 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cucadiagram.entity;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.cucadiagram.BlockMember;
+import net.sourceforge.plantuml.cucadiagram.BlockMemberImpl;
+import net.sourceforge.plantuml.cucadiagram.Bodier;
+import net.sourceforge.plantuml.cucadiagram.BodyEnhanced;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.EntityPortion;
+import net.sourceforge.plantuml.cucadiagram.EntityPosition;
+import net.sourceforge.plantuml.cucadiagram.EntityUtils;
+import net.sourceforge.plantuml.cucadiagram.GroupRoot;
+import net.sourceforge.plantuml.cucadiagram.GroupType;
+import net.sourceforge.plantuml.cucadiagram.IGroup;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.cucadiagram.LongCode;
+import net.sourceforge.plantuml.cucadiagram.Member;
+import net.sourceforge.plantuml.cucadiagram.PortionShower;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.cucadiagram.dot.Neighborhood;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockVertical2;
+import net.sourceforge.plantuml.graphic.USymbol;
+import net.sourceforge.plantuml.svek.IEntityImage;
+import net.sourceforge.plantuml.svek.PackageStyle;
+import net.sourceforge.plantuml.svek.SingleStrategy;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.utils.UniqueSequence;
+
+final class EntityImpl implements ILeaf, IGroup {
+
+ private final EntityFactory entityFactory;
+
+ // Entity
+ private final Code code;
+ private final LongCode longCode;
+
+ private Url url;
+
+ private final Bodier bodier;
+ private final String uid = StringUtils.getUid("cl", UniqueSequence.getValue());
+ private Display display = Display.empty();
+
+ private LeafType leafType;
+ private Stereotype stereotype;
+ private String generic;
+ private IGroup parentContainer;
+
+ private boolean top;
+
+ private final List<String> mouseOver = new ArrayList<String>();
+
+ // Group
+ private Code namespace2;
+
+ private GroupType groupType;
+
+ private boolean autonom = true;
+
+ // Other
+
+ private HtmlColor specificBackcolor;
+ private boolean nearDecoration = false;
+ private int xposition;
+ private IEntityImage svekImage;
+
+ private boolean removed = false;
+ private HtmlColor specificLineColor;
+ private UStroke specificStroke;
+ private USymbol symbol;
+ private final int rawLayout;
+ private char concurrentSeparator;
+
+ // Back to Entity
+ public final boolean isTop() {
+ checkNotGroup();
+ return top;
+ }
+
+ public final void setTop(boolean top) {
+ checkNotGroup();
+ this.top = top;
+ }
+
+ private EntityImpl(EntityFactory entityFactory, Code code, Bodier bodier, IGroup parentContainer,
+ LongCode longCode, String namespaceSeparator, int rawLayout) {
+ if (code == null) {
+ throw new IllegalArgumentException();
+ }
+ this.entityFactory = entityFactory;
+ this.bodier = bodier;
+ this.code = code;
+ this.parentContainer = parentContainer;
+ this.longCode = longCode;
+ this.rawLayout = rawLayout;
+ }
+
+ EntityImpl(EntityFactory entityFactory, Code code, Bodier bodier, IGroup parentContainer, LeafType leafType,
+ LongCode longCode, String namespaceSeparator, int rawLayout) {
+ this(entityFactory, code, bodier, parentContainer, longCode, namespaceSeparator, rawLayout);
+ this.leafType = leafType;
+ }
+
+ EntityImpl(EntityFactory entityFactory, Code code, Bodier bodier, IGroup parentContainer, GroupType groupType,
+ Code namespace2, LongCode longCode, String namespaceSeparator, int rawLayout) {
+ this(entityFactory, code, bodier, parentContainer, longCode, namespaceSeparator, rawLayout);
+ this.groupType = groupType;
+ this.namespace2 = namespace2;
+ }
+
+ public void setContainer(IGroup container) {
+ checkNotGroup();
+ if (container == null) {
+ throw new IllegalArgumentException();
+ }
+ this.parentContainer = container;
+ }
+
+ public LeafType getEntityType() {
+ return leafType;
+ }
+
+ public void muteToType(LeafType newType, USymbol newSymbol) {
+ checkNotGroup();
+ if (newType == null) {
+ throw new IllegalArgumentException();
+ }
+ if (leafType != LeafType.STILL_UNKNOWN) {
+ if (leafType != LeafType.ANNOTATION && leafType != LeafType.ABSTRACT_CLASS && leafType != LeafType.CLASS
+ && leafType != LeafType.ENUM && leafType != LeafType.INTERFACE) {
+ throw new IllegalArgumentException("type=" + leafType);
+ }
+ if (newType != LeafType.ANNOTATION && newType != LeafType.ABSTRACT_CLASS && newType != LeafType.CLASS
+ && newType != LeafType.ENUM && newType != LeafType.INTERFACE) {
+ throw new IllegalArgumentException("newtype=" + newType);
+ }
+ }
+ this.leafType = newType;
+ this.symbol = newSymbol;
+ }
+
+ public Code getCode() {
+ return code;
+ }
+
+ public Display getDisplay() {
+ return display;
+ }
+
+ public void setDisplay(Display display) {
+ this.display = display;
+ }
+
+ public String getUid() {
+ return uid;
+ }
+
+ public Stereotype getStereotype() {
+ return stereotype;
+ }
+
+ public final void setStereotype(Stereotype stereotype) {
+ this.stereotype = stereotype;
+ }
+
+ public final IGroup getParentContainer() {
+ if (parentContainer == null) {
+ throw new IllegalArgumentException();
+ }
+ return parentContainer;
+ }
+
+ @Override
+ public String toString() {
+ return code + " " + display + "(" + leafType + ") " + xposition + " " + getUid();
+ }
+
+ public HtmlColor getSpecificBackColor() {
+ return specificBackcolor;
+ }
+
+ public void setSpecificBackcolor(HtmlColor color) {
+ this.specificBackcolor = color;
+ }
+
+ public final Url getUrl99() {
+ return url;
+ }
+
+ public boolean hasUrl() {
+ if (display != null && display.hasUrl()) {
+ return true;
+ }
+ if (bodier.hasUrl()) {
+ return true;
+ }
+ return url != null;
+ }
+
+ public final void addUrl(Url url) {
+ this.url = url;
+ }
+
+ public final boolean hasNearDecoration() {
+ checkNotGroup();
+ return nearDecoration;
+ }
+
+ public final void setNearDecoration(boolean nearDecoration) {
+ // checkNotGroup();
+ this.nearDecoration = nearDecoration;
+ }
+
+ public int getXposition() {
+ checkNotGroup();
+ return xposition;
+ }
+
+ public void setXposition(int pos) {
+ checkNotGroup();
+ xposition = pos;
+ }
+
+ public final IEntityImage getSvekImage() {
+ checkNotGroup();
+ return svekImage;
+ }
+
+ public final void setSvekImage(IEntityImage svekImage) {
+ checkNotGroup();
+ this.svekImage = svekImage;
+ }
+
+ public final void setGeneric(String generic) {
+ checkNotGroup();
+ this.generic = generic;
+ }
+
+ public final String getGeneric() {
+ checkNotGroup();
+ return generic;
+ }
+
+ public BlockMember getBody(final PortionShower portionShower) {
+ checkNotGroup();
+ final boolean showMethods = portionShower.showPortion(EntityPortion.METHOD, EntityImpl.this);
+ final boolean showFields = portionShower.showPortion(EntityPortion.FIELD, EntityImpl.this);
+ if (getEntityType().isLikeClass() && bodier.isBodyEnhanced()) {
+ if (showMethods && showFields) {
+ return bodier.getBodyEnhanced();
+ }
+ return new BlockMember() {
+ public TextBlock asTextBlock(FontParam fontParam, ISkinParam skinParam) {
+ return null;
+ }
+ };
+ }
+ return new BlockMember() {
+ public TextBlock asTextBlock(FontParam fontParam, ISkinParam skinParam) {
+ if (getEntityType().isLikeClass()) {
+
+ if (showFields && showMethods) {
+ return new TextBlockVertical2(new BlockMemberImpl(getFieldsToDisplay()).asTextBlock(fontParam,
+ skinParam),
+ new BlockMemberImpl(getMethodsToDisplay()).asTextBlock(fontParam, skinParam),
+ HorizontalAlignment.LEFT);
+ } else if (showFields) {
+ return new BlockMemberImpl(getFieldsToDisplay()).asTextBlock(fontParam, skinParam);
+ } else if (showMethods) {
+ return new BlockMemberImpl(getMethodsToDisplay()).asTextBlock(fontParam, skinParam);
+ }
+ return null;
+ }
+ if (getEntityType() == LeafType.OBJECT) {
+ return new BlockMemberImpl(getFieldsToDisplay()).asTextBlock(fontParam, skinParam);
+ }
+ throw new UnsupportedOperationException();
+ }
+ };
+ }
+
+ public BlockMember getMouseOver() {
+ if (mouseOver.size() == 0) {
+ return null;
+ }
+ return new BlockMember() {
+ public TextBlock asTextBlock(FontParam fontParam, ISkinParam skinParam) {
+ return new BodyEnhanced(mouseOver, fontParam, skinParam, leafType.manageModifier());
+ }
+ };
+ }
+
+ public void mouseOver(String s) {
+ mouseOver.add(s);
+ }
+
+ public List<Member> getFieldsToDisplay() {
+ // checkNotGroup();
+ return bodier.getFieldsToDisplay();
+ }
+
+ public List<Member> getMethodsToDisplay() {
+ // checkNotGroup();
+ return bodier.getMethodsToDisplay();
+ }
+
+ public void addFieldOrMethod(String s) {
+ // checkNotGroup();
+ bodier.addFieldOrMethod(s);
+ }
+
+ public EntityPosition getEntityPosition() {
+ checkNotGroup();
+ if (leafType != LeafType.STATE) {
+ return EntityPosition.NORMAL;
+ }
+ if (getParentContainer() instanceof GroupRoot) {
+ return EntityPosition.NORMAL;
+ }
+ final Stereotype stereotype = getStereotype();
+ if (stereotype == null) {
+ return EntityPosition.NORMAL;
+ }
+ final String label = stereotype.getLabel(false);
+ if ("<<entrypoint>>".equalsIgnoreCase(label)) {
+ return EntityPosition.ENTRY_POINT;
+ }
+ if ("<<exitpoint>>".equalsIgnoreCase(label)) {
+ return EntityPosition.EXIT_POINT;
+ }
+ return EntityPosition.NORMAL;
+
+ }
+
+ // ----------
+
+ private void checkGroup() {
+ if (isGroup() == false) {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ private void checkNotGroup() {
+ if (isGroup()) {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ public boolean containsLeafRecurse(ILeaf leaf) {
+ if (leaf == null) {
+ throw new IllegalArgumentException();
+ }
+ if (leaf.isGroup()) {
+ throw new IllegalArgumentException();
+ }
+ checkGroup();
+ if (leaf.getParentContainer() == this) {
+ return true;
+ }
+ for (IGroup child : getChildren()) {
+ if (child.containsLeafRecurse(leaf)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public Collection<ILeaf> getLeafsDirect() {
+ checkGroup();
+ final List<ILeaf> result = new ArrayList<ILeaf>();
+ for (ILeaf ent : entityFactory.getLeafs().values()) {
+ if (ent.isGroup()) {
+ throw new IllegalStateException();
+ }
+ if (ent.getParentContainer() == this) {
+ result.add(ent);
+ }
+ }
+ return Collections.unmodifiableCollection(result);
+ }
+
+ public Collection<IGroup> getChildren() {
+ checkGroup();
+ final Collection<IGroup> result = new ArrayList<IGroup>();
+ for (IGroup g : entityFactory.getGroups().values()) {
+ if (g != this && g.getParentContainer() == this) {
+ result.add(g);
+ }
+ }
+ return Collections.unmodifiableCollection(result);
+ }
+
+ public void moveEntitiesTo(IGroup dest) {
+ checkGroup();
+ if (dest.isGroup() == false) {
+ throw new UnsupportedOperationException();
+ }
+ for (ILeaf ent : getLeafsDirect()) {
+ ((EntityImpl) ent).parentContainer = dest;
+ }
+ for (IGroup g : dest.getChildren()) {
+ // ((EntityImpl) g).parentContainer = dest;
+ throw new IllegalStateException();
+ }
+
+ for (IGroup g : getChildren()) {
+ if (g == dest) {
+ continue;
+ }
+ ((EntityImpl) g).parentContainer = dest;
+ }
+
+ }
+
+ public int size() {
+ checkGroup();
+ return getLeafsDirect().size();
+ }
+
+ public GroupType getGroupType() {
+ checkGroup();
+ return groupType;
+ }
+
+ public Code getNamespace2() {
+ checkGroup();
+ return namespace2;
+ }
+
+ public boolean isAutonom() {
+ checkGroup();
+ return autonom;
+ }
+
+ public void setAutonom(boolean autonom) {
+ this.autonom = autonom;
+
+ }
+
+ public PackageStyle getPackageStyle() {
+ checkGroup();
+ if (stereotype == null) {
+ return null;
+ }
+ return stereotype.getPackageStyle();
+ }
+
+ public boolean isGroup() {
+ if (groupType != null && leafType != null) {
+ throw new IllegalStateException();
+ }
+ if (groupType != null) {
+ return true;
+ }
+ if (leafType != null) {
+ return false;
+ }
+ throw new IllegalStateException();
+ }
+
+ // ---- other
+
+ public void overideImage(IEntityImage img, LeafType leafType) {
+ checkGroup();
+ this.svekImage = img;
+ this.url = null;
+
+ for (final Link link : new ArrayList<Link>(entityFactory.getLinks())) {
+ if (EntityUtils.isPureInnerLink12(this, link)) {
+ entityFactory.removeLink(link);
+ }
+ }
+
+ entityFactory.removeGroup(this.getCode());
+ for (ILeaf ent : new ArrayList<ILeaf>(entityFactory.getLeafs().values())) {
+ if (this != ent && this == ent.getParentContainer()) {
+ entityFactory.removeLeaf(ent.getCode());
+ }
+ }
+
+ entityFactory.addLeaf(this);
+ this.groupType = null;
+ this.leafType = leafType;
+ }
+
+ void muteToGroup(Code namespace2, GroupType groupType, IGroup parentContainer) {
+ checkNotGroup();
+ if (parentContainer.isGroup() == false) {
+ throw new IllegalArgumentException();
+ }
+ this.namespace2 = namespace2;
+ this.groupType = groupType;
+ this.leafType = null;
+ this.parentContainer = parentContainer;
+ }
+
+ public boolean isHidden() {
+ if (entityFactory.isHidden(leafType)) {
+ return true;
+ }
+ if (stereotype != null) {
+ return stereotype.isHidden();
+ }
+ return false;
+ }
+
+ public USymbol getUSymbol() {
+ return symbol;
+ }
+
+ public void setUSymbol(USymbol symbol) {
+ this.symbol = symbol;
+ }
+
+ public SingleStrategy getSingleStrategy() {
+ return SingleStrategy.SQUARRE;
+ }
+
+ public boolean isRemoved() {
+ if (isGroup()) {
+ if (getLeafsDirect().size() == 0) {
+ return false;
+ }
+ for (ILeaf leaf : getLeafsDirect()) {
+ if (leaf.isRemoved() == false) {
+ return false;
+ }
+ }
+ for (IGroup g : getChildren()) {
+ if (g.isRemoved() == false) {
+ return false;
+ }
+ }
+ return true;
+ }
+ return removed;
+ }
+
+ public void setRemoved(boolean removed) {
+ this.removed = removed;
+ }
+
+ public HtmlColor getSpecificLineColor() {
+ return specificLineColor;
+ }
+
+ public void setSpecificLineColor(HtmlColor specificLinecolor) {
+ this.specificLineColor = specificLinecolor;
+ }
+
+ public UStroke getSpecificLineStroke() {
+ return specificStroke;
+ }
+
+ public void setSpecificLineStroke(UStroke specificLineStroke) {
+ this.specificStroke = specificLineStroke;
+ }
+
+ private int layer;
+
+ public int getHectorLayer() {
+ return layer;
+ }
+
+ public void setHectorLayer(int layer) {
+ this.layer = layer;
+ if (layer > 1000) {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ public LongCode getLongCode() {
+ return longCode;
+ }
+
+ public FontParam getTitleFontParam() {
+ if (symbol != null) {
+ return symbol.getFontParam();
+ }
+ return getGroupType() == GroupType.STATE ? FontParam.STATE : FontParam.PACKAGE;
+ }
+
+ public final int getRawLayout() {
+ return rawLayout;
+ }
+
+ public char getConcurrentSeparator() {
+ return concurrentSeparator;
+ }
+
+ public void setConcurrentSeparator(char separator) {
+ this.concurrentSeparator = separator;
+ }
+
+ private Neighborhood neighborhood;
+
+ public void setNeighborhood(Neighborhood neighborhood) {
+ this.neighborhood = neighborhood;
+ }
+
+ public Neighborhood getNeighborhood() {
+ return neighborhood;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/ApolloniusSolver.java b/src/net/sourceforge/plantuml/cute/ApolloniusSolver.java
new file mode 100644
index 0000000..929d884
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/ApolloniusSolver.java
@@ -0,0 +1,131 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cute;
+
+// http://rosettacode.org/wiki/Problem_of_Apollonius#Java
+public class ApolloniusSolver {
+
+ static class Circle {
+ public double[] center;
+ public double radius;
+
+ public Circle(double[] center, double radius) {
+ this.center = center;
+ this.radius = radius;
+ }
+
+ public String toString() {
+ return String.format("Circle[x=%.2f,y=%.2f,r=%.2f]", center[0], center[1], radius);
+ }
+ }
+
+ /**
+ * Solves the Problem of Apollonius (finding a circle tangent to three other circles in the plane). The method uses
+ * approximately 68 heavy operations (multiplication, division, square-roots).
+ *
+ * @param c1
+ * One of the circles in the problem
+ * @param c2
+ * One of the circles in the problem
+ * @param c3
+ * One of the circles in the problem
+ * @param s1
+ * An indication if the solution should be externally or internally tangent (+1/-1) to c1
+ * @param s2
+ * An indication if the solution should be externally or internally tangent (+1/-1) to c2
+ * @param s3
+ * An indication if the solution should be externally or internally tangent (+1/-1) to c3
+ * @return The circle that is tangent to c1, c2 and c3.
+ */
+ public static Circle solveApollonius(Circle c1, Circle c2, Circle c3, int s1, int s2, int s3) {
+ double x1 = c1.center[0];
+ double y1 = c1.center[1];
+ double r1 = c1.radius;
+ double x2 = c2.center[0];
+ double y2 = c2.center[1];
+ double r2 = c2.radius;
+ double x3 = c3.center[0];
+ double y3 = c3.center[1];
+ double r3 = c3.radius;
+
+ // Currently optimized for fewest multiplications. Should be optimized for
+ // readability
+ double v11 = 2 * x2 - 2 * x1;
+ double v12 = 2 * y2 - 2 * y1;
+ double v13 = x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2 - r1 * r1 + r2 * r2;
+ double v14 = 2 * s2 * r2 - 2 * s1 * r1;
+
+ double v21 = 2 * x3 - 2 * x2;
+ double v22 = 2 * y3 - 2 * y2;
+ double v23 = x2 * x2 - x3 * x3 + y2 * y2 - y3 * y3 - r2 * r2 + r3 * r3;
+ double v24 = 2 * s3 * r3 - 2 * s2 * r2;
+
+ double w12 = v12 / v11;
+ double w13 = v13 / v11;
+ double w14 = v14 / v11;
+
+ double w22 = v22 / v21 - w12;
+ double w23 = v23 / v21 - w13;
+ double w24 = v24 / v21 - w14;
+
+ double P = -w23 / w22;
+ double Q = w24 / w22;
+ double M = -w12 * P - w13;
+ double N = w14 - w12 * Q;
+
+ double a = N * N + Q * Q - 1;
+ double b = 2 * M * N - 2 * N * x1 + 2 * P * Q - 2 * Q * y1 + 2 * s1 * r1;
+ double c = x1 * x1 + M * M - 2 * M * x1 + P * P + y1 * y1 - 2 * P * y1 - r1 * r1;
+
+ // Find a root of a quadratic equation. This requires the circle centers not
+ // to be e.g. colinear
+ double D = b * b - 4 * a * c;
+ double rs = (-b - Math.sqrt(D)) / (2 * a);
+ double xs = M + N * rs;
+ double ys = P + Q * rs;
+ return new Circle(new double[] { xs, ys }, rs);
+ }
+
+ public static void main(final String[] args) {
+ Circle c1 = new Circle(new double[] { 0, 0 }, 1);
+ Circle c2 = new Circle(new double[] { 4, 0 }, 1);
+ Circle c3 = new Circle(new double[] { 2, 4 }, 2);
+ // Expects "Circle[x=2.00,y=2.10,r=3.90]" (green circle in image)
+ System.out.println(solveApollonius(c1, c2, c3, 1, 1, 1));
+ // Expects "Circle[x=2.00,y=0.83,r=1.17]" (red circle in image)
+ System.out.println(solveApollonius(c1, c2, c3, -1, -1, -1));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/ApolloniusSolver2.java b/src/net/sourceforge/plantuml/cute/ApolloniusSolver2.java
new file mode 100644
index 0000000..6fb38d9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/ApolloniusSolver2.java
@@ -0,0 +1,110 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cute;
+
+import java.awt.geom.Point2D;
+
+// http://rosettacode.org/wiki/Problem_of_Apollonius#Java
+public class ApolloniusSolver2 {
+
+ /**
+ * Solves the Problem of Apollonius (finding a circle tangent to three other circles in the plane). The method uses
+ * approximately 68 heavy operations (multiplication, division, square-roots).
+ *
+ * @param c1
+ * One of the circles in the problem
+ * @param c2
+ * One of the circles in the problem
+ * @param c3
+ * One of the circles in the problem
+ * @param s1
+ * An indication if the solution should be externally or internally tangent (+1/-1) to c1
+ * @param s2
+ * An indication if the solution should be externally or internally tangent (+1/-1) to c2
+ * @param s3
+ * An indication if the solution should be externally or internally tangent (+1/-1) to c3
+ * @return The circle that is tangent to c1, c2 and c3.
+ */
+ public static Balloon solveApollonius(Balloon c1, Balloon c2, Balloon c3, int s1, int s2, int s3) {
+ double x1 = c1.getCenter().getX();
+ double y1 = c1.getCenter().getY();
+ double r1 = c1.getRadius();
+ double x2 = c2.getCenter().getX();
+ double y2 = c2.getCenter().getY();
+ double r2 = c2.getRadius();
+ double x3 = c3.getCenter().getX();
+ double y3 = c3.getCenter().getY();
+ double r3 = c3.getRadius();
+
+ // Currently optimized for fewest multiplications. Should be optimized for
+ // readability
+ double v11 = 2 * x2 - 2 * x1;
+ double v12 = 2 * y2 - 2 * y1;
+ double v13 = x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2 - r1 * r1 + r2 * r2;
+ double v14 = 2 * s2 * r2 - 2 * s1 * r1;
+
+ double v21 = 2 * x3 - 2 * x2;
+ double v22 = 2 * y3 - 2 * y2;
+ double v23 = x2 * x2 - x3 * x3 + y2 * y2 - y3 * y3 - r2 * r2 + r3 * r3;
+ double v24 = 2 * s3 * r3 - 2 * s2 * r2;
+
+ double w12 = v12 / v11;
+ double w13 = v13 / v11;
+ double w14 = v14 / v11;
+
+ double w22 = v22 / v21 - w12;
+ double w23 = v23 / v21 - w13;
+ double w24 = v24 / v21 - w14;
+
+ double P = -w23 / w22;
+ double Q = w24 / w22;
+ double M = -w12 * P - w13;
+ double N = w14 - w12 * Q;
+
+ double a = N * N + Q * Q - 1;
+ double b = 2 * M * N - 2 * N * x1 + 2 * P * Q - 2 * Q * y1 + 2 * s1 * r1;
+ double c = x1 * x1 + M * M - 2 * M * x1 + P * P + y1 * y1 - 2 * P * y1 - r1 * r1;
+
+ // Find a root of a quadratic equation. This requires the circle centers not
+ // to be e.g. colinear
+ double D = b * b - 4 * a * c;
+ double rs = (-b - Math.sqrt(D)) / (2 * a);
+ double xs = M + N * rs;
+ double ys = P + Q * rs;
+ return new Balloon(new Point2D.Double(xs, ys), rs);
+ }
+
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/Arc.java b/src/net/sourceforge/plantuml/cute/Arc.java
new file mode 100644
index 0000000..547d29c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/Arc.java
@@ -0,0 +1,114 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cute;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.ugraphic.UPath;
+
+public class Arc {
+
+ private final Segment segment;
+ private final Tension tension;
+
+ public Tension getTension() {
+ return tension;
+ }
+
+ public Arc(final MyPoint2D a, final MyPoint2D b) {
+ this(a, b, Tension.none());
+ }
+
+ private Arc(final MyPoint2D a, final MyPoint2D b, Tension tension) {
+ this.segment = new Segment(a, b);
+ this.tension = tension;
+ }
+
+ public MyPoint2D getA() {
+ return (MyPoint2D) segment.getA();
+ }
+
+ public MyPoint2D getB() {
+ return (MyPoint2D) segment.getB();
+ }
+
+ public Arc withNoTension() {
+ return new Arc(getA(), getB(), Tension.none());
+ }
+
+ public Arc withTension(String tensionString) {
+ if (tensionString == null) {
+ return this;
+ }
+ final double newTension = Double.parseDouble(tensionString);
+ return new Arc(getA(), getB(), new Tension(newTension));
+ }
+
+ public Arc rotateZoom(RotationZoom rotationZoom) {
+ return new Arc(getA().rotateZoom(rotationZoom), getB().rotateZoom(rotationZoom),
+ tension.rotateZoom(rotationZoom));
+ }
+
+// public void appendTo(UPath path) {
+// if (tension.isNone()) {
+// path.lineTo(getB());
+// } else {
+// final double a = segment.getLength() / 2;
+// final double b = getTension().getValue();
+// final double radius = (a * a + b * b) / 2 / b;
+// final int sweep_flag = 1;
+// path.arcTo(getB(), radius, 0, sweep_flag);
+// }
+// }
+
+ public Point2D getTensionPoint() {
+ if (tension.isNone()) {
+ throw new IllegalArgumentException();
+ }
+ return segment.getOrthoPoint(-tension.getValue());
+ }
+
+ // public void appendTo(UPath path) {
+ // if (path.isEmpty()) {
+ // path.moveTo(getA());
+ // }
+ // path.lineTo(getB());
+ // }
+
+ public double getLength() {
+ return segment.getLength();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/Balloon.java b/src/net/sourceforge/plantuml/cute/Balloon.java
new file mode 100644
index 0000000..1730f81
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/Balloon.java
@@ -0,0 +1,124 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cute;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class Balloon implements UDrawable {
+
+ private final Point2D center;
+ private final double radius;
+
+ public Balloon(Point2D center, double radius) {
+ if (radius < 0) {
+ throw new IllegalArgumentException();
+ }
+ this.center = center;
+ this.radius = radius;
+ }
+
+ public static Balloon fromRadiusSegment(Segment centerToContact) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Point2D getPointOnCircle(double a) {
+ return new Point2D.Double(center.getX() + radius * Math.cos(a), center.getY() + radius * Math.sin(a));
+ }
+
+ public Segment getSegmentCenterToPointOnCircle(double a) {
+ return new Segment(center, getPointOnCircle(a));
+ }
+
+ public Balloon translate(UTranslate translate) {
+ return new Balloon(translate.getTranslated(center), radius);
+ }
+
+ public Balloon rotate(RotationZoom rotationZoom) {
+ return new Balloon(rotationZoom.getPoint(center), rotationZoom.applyZoom(radius));
+ }
+
+ @Override
+ public String toString() {
+ return "Balloon(" + center + "," + radius + ")";
+ }
+
+ public Point2D getCenter() {
+ return center;
+ }
+
+ public double getRadius() {
+ return radius;
+ }
+
+ public void drawU(UGraphic ug) {
+ UEllipse circle = new UEllipse(2 * radius, 2 * radius);
+ ug.apply(new UTranslate(center.getX() - circle.getWidth() / 2, center.getY() - circle.getHeight() / 2)).draw(
+ circle);
+ }
+
+ public Balloon getInsideTangentBalloon1(double angle, double curvation) {
+ final double f = radius - curvation;
+ final double e = (radius * radius - f * f) / 2 / radius;
+ final RotationZoom rotation = RotationZoom.rotationInRadians(angle);
+ final Point2D p1 = rotation.getPoint(f, e);
+ final Point2D newCenter = new Point2D.Double(center.getX() + p1.getX(), center.getY() + p1.getY());
+ return new Balloon(newCenter, e);
+ }
+
+ public Balloon getInsideTangentBalloon2(double angle, double curvation) {
+ final double f = radius - curvation;
+ final double e = (radius * radius - f * f) / 2 / radius;
+ final RotationZoom rotation = RotationZoom.rotationInRadians(angle);
+ final Point2D p1 = rotation.getPoint(f, -e);
+ final Point2D newCenter = new Point2D.Double(center.getX() + p1.getX(), center.getY() + p1.getY());
+ return new Balloon(newCenter, e);
+ }
+
+ public Point2D getPointOnCirclePassingByThisPoint(Point2D passingBy) {
+ final Segment seg = new Segment(center, passingBy);
+ return seg.getFromAtoB(radius);
+ }
+
+ public Point2D getPointOnCircleOppositeToThisPoint(Point2D passingBy) {
+ final Segment seg = new Segment(center, passingBy);
+ return seg.getFromAtoB(-radius);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/BetweenCorners.java b/src/net/sourceforge/plantuml/cute/BetweenCorners.java
new file mode 100644
index 0000000..cb25b9e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/BetweenCorners.java
@@ -0,0 +1,194 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cute;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UPath;
+
+public class BetweenCorners {
+
+ private final TriangleCorner corner1;
+ private final TriangleCorner corner2;
+ private final Tension tension;
+
+ private Balloon inside1;
+ private Balloon inside2;
+ private Balloon contact;
+ private Balloon apo;
+ private Point2D apopt1;
+ private Point2D apopt2;
+
+ public BetweenCorners(TriangleCorner corner1, TriangleCorner corner2, Tension tension) {
+ this.corner1 = corner1;
+ this.corner2 = corner2;
+ this.tension = tension;
+
+ if (corner1.hasCurvation()) {
+ inside1 = corner1.getBalloonInside();
+ }
+ if (corner2.hasCurvation()) {
+ inside2 = corner2.getBalloonInside();
+ }
+ if (tension.isNone() == false) {
+ contact = new Balloon(getTensionPoint(), getLength() / 1000.0);
+ }
+
+ if (inside1 != null && inside2 != null && contact != null) {
+ apo = ApolloniusSolver2.solveApollonius(inside1, inside2, contact, 1, 1, 1);
+ apopt1 = apo.getPointOnCirclePassingByThisPoint(inside1.getCenter());
+ apopt2 = apo.getPointOnCirclePassingByThisPoint(inside2.getCenter());
+ }
+
+ }
+
+ public Point2D getPointJ() {
+ if (getCorner1().hasCurvation() == false) {
+ return getCorner1().getO();
+ }
+ if (tension.isNone()) {
+ return getCorner1().getOnSegmentA(getCorner1().getCurvation());
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ public Point2D getPointK() {
+ if (getCorner1().hasCurvation() == false) {
+ return getCorner1().getO();
+ }
+ if (tension.isNone()) {
+ return getCorner1().getOnSegmentB(getCorner1().getCurvation());
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ private double getBalloonRadius() {
+ return getCorner1().getBalloonInside().getRadius();
+ }
+
+ public void initPath(UPath path) {
+ if (apo != null) {
+ path.moveTo(apopt2);
+ } else {
+ path.moveTo(getPointK());
+ }
+ }
+
+ public void addToPath(UPath path, int swepFlag) {
+ if (apo != null) {
+ path.arcTo(apopt1, getCorner1().getBalloonInside().getRadius(), 0, 1);
+ path.arcTo(apopt2, apo.getRadius(), 0, 1);
+ // } else if (getTension().isNone()) {
+ // path.lineTo(getPointJ());
+ // if (getCorner2().hasCurvation()) {
+ // path.arcTo(getPointK(), getBalloonRadius(), 0, swepFlag);
+ // }
+ // } else {
+ // // final int sweep_flag = 1;
+ // path.arcTo(getPointJ(), getRadiusFuzzy1(), 0, swepFlag);
+ // if (getCorner2().hasCurvation()) {
+ // path.arcTo(getPointK(), getBalloonRadius(), 0, swepFlag);
+ // }
+ // }
+ } else {
+ path.lineTo(getPointJ());
+ if (getCorner1().hasCurvation()) {
+ path.arcTo(getPointK(), getBalloonRadius(), 0, swepFlag);
+ }
+ }
+ }
+
+ public void debugMe(UGraphic ug) {
+ if (getCorner2().hasCurvation() == false) {
+ return;
+ }
+ if (tension.isNone()) {
+ return;
+ }
+ inside1.drawU(ug);
+ inside2.drawU(ug);
+ // getSegment().debugMe(ug);
+ contact.drawU(ug);
+
+ new Balloon(apopt1, 5).drawU(ug);
+ new Balloon(apopt2, 5).drawU(ug);
+
+ // getSegmentCross().debugMe(ug);
+
+ apo.drawU(ug);
+ //
+ // final Point2D newCenter = getSegmentCross().getOrthoPoint(-50);
+ // new Segment(newCenter, getCorner1().getBalloonInside().getCenter()).debugMe(ug);
+ // new Segment(newCenter, getCorner2().getBalloonInside().getCenter()).debugMe(ug);
+
+ }
+
+ private double getRadiusFuzzy1() {
+ final double a = getLength() / 2;
+ final double b = getTension().getValue();
+ final double radius = (a * a + b * b) / 2 / b;
+ return radius;
+ }
+
+ private Segment getSegment() {
+ return new Segment(getCorner1().getO(), getCorner2().getO());
+ }
+
+ private Point2D getTensionPoint() {
+ return getSegment().getOrthoPoint(getTension().getValue());
+ }
+
+ private Segment getSegmentCross() {
+ return new Segment(getCorner1().getCornerOrBalloonCenter(), getCorner2().getCornerOrBalloonCenter());
+ }
+
+ public Tension getTension() {
+ return tension;
+ }
+
+ public TriangleCorner getCorner1() {
+ return corner1;
+ }
+
+ public TriangleCorner getCorner2() {
+ return corner2;
+ }
+
+ public double getLength() {
+ return getSegment().getLength();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/Cheese.java b/src/net/sourceforge/plantuml/cute/Cheese.java
new file mode 100644
index 0000000..e27b5f6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/Cheese.java
@@ -0,0 +1,130 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cute;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UPath;
+
+public class Cheese implements CuteShape {
+
+ private final MyDouble radius;
+ private final MyDouble startAngle;
+ private final MyDouble endAngle;
+ private final RotationZoom rotationZoom;
+
+ public Cheese(VarArgs varArgs) {
+ this.radius = varArgs.getAsMyDouble("radius");
+ this.startAngle = varArgs.getAsMyDouble("start").toRadians();
+ this.endAngle = varArgs.getAsMyDouble("end").toRadians();
+ this.rotationZoom = RotationZoom.none();
+ }
+
+ public Cheese(MyDouble radius, MyDouble startAngle, MyDouble endAngle, RotationZoom rotation) {
+ this.radius = radius;
+ this.startAngle = startAngle;
+ this.endAngle = endAngle;
+ this.rotationZoom = rotation;
+ }
+
+ public void drawU(UGraphic ug) {
+ final Balloon balloon = new Balloon(new Point2D.Double(), radius.getValue())
+ .rotate(rotationZoom);
+
+ final double angle1 = rotationZoom.applyRotation(startAngle.getValue());
+ final double angle2 = rotationZoom.applyRotation(endAngle.getValue());
+
+ final Point2D ptA = balloon.getPointOnCircle(angle1);
+ final Point2D ptB = balloon.getPointOnCircle(angle2);
+
+ // balloon.drawU(ug.apply(new UChangeBackColor(null)).apply(new UChangeColor(HtmlColorUtils.BLACK)));
+ final UPath path = new UPath();
+ final Point2D ptA0;
+ if (radius.hasCurvation()) {
+ ptA0 = balloon.getSegmentCenterToPointOnCircle(angle1).getFromAtoB(radius.getCurvation(0));
+ path.moveTo(ptA0);
+ } else {
+ ptA0 = null;
+ path.moveTo(balloon.getCenter());
+ }
+ final Balloon insideA;
+ if (startAngle.hasCurvation()) {
+ insideA = balloon.getInsideTangentBalloon1(angle1, startAngle.getCurvation(0));
+ final Point2D ptA1 = balloon.getSegmentCenterToPointOnCircle(angle1).getFromAtoB(
+ radius.getValue() - startAngle.getCurvation(0));
+ final Point2D ptA2 = balloon.getPointOnCirclePassingByThisPoint(insideA.getCenter());
+ path.lineTo(ptA1);
+ path.arcTo(ptA2, insideA.getRadius(), 0, 1);
+ } else {
+ insideA = null;
+ path.lineTo(ptA);
+ }
+ final Balloon insideB;
+ if (endAngle.hasCurvation()) {
+ insideB = balloon.getInsideTangentBalloon2(angle2, endAngle.getCurvation(0));
+ final Point2D ptB1 = balloon.getPointOnCirclePassingByThisPoint(insideB.getCenter());
+ final Point2D ptB2 = balloon.getSegmentCenterToPointOnCircle(angle2).getFromAtoB(
+ radius.getValue() - endAngle.getCurvation(0));
+
+ path.arcTo(ptB1, balloon.getRadius(), 0, 1);
+ path.arcTo(ptB2, insideB.getRadius(), 0, 1);
+ } else {
+ insideB = null;
+ path.arcTo(ptB, balloon.getRadius(), 0, 1);
+ }
+ if (radius.hasCurvation()) {
+ final Point2D ptB0 = balloon.getSegmentCenterToPointOnCircle(angle2).getFromAtoB(radius.getCurvation(0));
+ path.lineTo(ptB0);
+ path.arcTo(ptA0, radius.getCurvation(0), 0, 1);
+ } else {
+ path.lineTo(balloon.getCenter());
+ }
+ path.closePath();
+ ug.draw(path);
+
+ // if (startAngle.hasCurvation()) {
+ // insideA.drawU(ug.apply(new UChangeColor(HtmlColorUtils.BLACK)).apply(new UChangeBackColor(null)));
+ // }
+ // if (endAngle.hasCurvation()) {
+ // insideB.drawU(ug.apply(new UChangeColor(HtmlColorUtils.BLACK)).apply(new UChangeBackColor(null)));
+ // }
+ }
+
+ public CuteShape rotateZoom(RotationZoom other) {
+ return new Cheese(radius, startAngle, endAngle, rotationZoom.compose(other));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/Circle.java b/src/net/sourceforge/plantuml/cute/Circle.java
new file mode 100644
index 0000000..117dc92
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/Circle.java
@@ -0,0 +1,65 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cute;
+
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class Circle implements CuteShape {
+
+ private final double radius;
+
+ public Circle(VarArgs varArgs) {
+ this.radius = varArgs.getAsDouble("radius");
+ }
+
+ private Circle(double radius) {
+ this.radius = radius;
+ }
+
+ public void drawU(UGraphic ug) {
+ ug = ug.apply(new UTranslate(-radius, -radius));
+ ug.draw(new UEllipse(2 * radius, 2 * radius));
+ }
+
+ public Circle rotateZoom(RotationZoom rotationZoom) {
+ if (rotationZoom.isNone()) {
+ return this;
+ }
+ return new Circle(rotationZoom.applyZoom(radius));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/Corner.java b/src/net/sourceforge/plantuml/cute/Corner.java
new file mode 100644
index 0000000..3f87bf9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/Corner.java
@@ -0,0 +1,45 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cute;
+
+public class Corner {
+
+ private final double curvation;
+
+ public Corner(double curvation) {
+ this.curvation = curvation;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/Crossing.java b/src/net/sourceforge/plantuml/cute/Crossing.java
new file mode 100644
index 0000000..c81cd49
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/Crossing.java
@@ -0,0 +1,67 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cute;
+
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class Crossing {
+
+ private final Balloon balloon;
+ private final InfiniteLine line;
+
+ public Crossing(Balloon balloon, InfiniteLine line) {
+ this.balloon = balloon;
+ this.line = line;
+ }
+
+ public List<Point2D> intersection() {
+ final List<Point2D> result = new ArrayList<Point2D>();
+
+ final UTranslate tr = new UTranslate(balloon.getCenter());
+ final UTranslate trInverse = tr.reverse();
+
+ final CrossingSimple simple = new CrossingSimple(balloon.getRadius(), line.translate(trInverse));
+ for (Point2D pt : simple.intersection()) {
+ result.add(tr.getTranslated(pt));
+ }
+
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/CrossingSimple.java b/src/net/sourceforge/plantuml/cute/CrossingSimple.java
new file mode 100644
index 0000000..6c3a8db
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/CrossingSimple.java
@@ -0,0 +1,90 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cute;
+
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+import java.util.List;
+
+public class CrossingSimple {
+
+ // http://mathworld.wolfram.com/Circle-LineIntersection.html
+
+ private final double radius;
+ private final InfiniteLine line;
+
+ public CrossingSimple(double radius, InfiniteLine line) {
+ this.radius = radius;
+ this.line = line;
+ }
+
+ private double pow2(double x) {
+ return x * x;
+ }
+
+ private double sgn(double x) {
+ if (x < 0) {
+ return -1;
+ }
+ return 1;
+ }
+
+ public List<Point2D> intersection() {
+ final List<Point2D> result = new ArrayList<Point2D>();
+ final double delta = pow2(radius * line.getDr()) - pow2(line.getDiscriminant());
+
+ if (delta < 0) {
+ return result;
+ }
+
+ double x;
+ double y;
+
+ x = (line.getDiscriminant() * line.getDeltaY() + sgn(line.getDeltaY()) * line.getDeltaX() * Math.sqrt(delta))
+ / pow2(line.getDr());
+ y = (-line.getDiscriminant() * line.getDeltaX() + Math.abs(line.getDeltaY()) * Math.sqrt(delta))
+ / pow2(line.getDr());
+ result.add(new Point2D.Double(x, y));
+
+ x = (line.getDiscriminant() * line.getDeltaY() - sgn(line.getDeltaY()) * line.getDeltaX() * Math.sqrt(delta))
+ / pow2(line.getDr());
+ y = (-line.getDiscriminant() * line.getDeltaX() - Math.abs(line.getDeltaY()) * Math.sqrt(delta))
+ / pow2(line.getDr());
+ result.add(new Point2D.Double(x, y));
+
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/CutePath.java b/src/net/sourceforge/plantuml/cute/CutePath.java
new file mode 100644
index 0000000..28627b8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/CutePath.java
@@ -0,0 +1,179 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cute;
+
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UPath;
+
+public class CutePath {
+
+ private final List<Arc> arcs = new ArrayList<Arc>();
+
+ public CutePath(String value) {
+
+ MyPoint2D lastAdded = null;
+ String tension = null;
+
+ final StringTokenizer spl = new StringTokenizer(value, "~:", true);
+ while (spl.hasMoreTokens()) {
+ final String token = spl.nextToken();
+ if (token.equals(":")) {
+ continue;
+ } else if (token.equals("~")) {
+ tension = spl.nextToken();
+ final String next = spl.nextToken();
+ if (next.equals("~") == false) {
+ throw new IllegalArgumentException();
+ }
+ } else {
+ final StringTokenizer st = new StringTokenizer(token.replaceAll("[()]", ""), ",^");
+ final MyPoint2D current = new MyPoint2D(st);
+ if (lastAdded != null) {
+ add(new Arc(lastAdded, current).withTension(tension));
+ }
+ lastAdded = current;
+ tension = null;
+ }
+ }
+ add(new Arc(lastAdded, arcs.get(0).getA()).withTension(tension));
+
+ }
+
+ public CutePath() {
+ }
+
+ public void add(Arc arc) {
+ if (arcs.size() > 0) {
+ final Arc last = arcs.get(arcs.size() - 1);
+ if (last.getB().equals(arc.getA()) == false) {
+ throw new IllegalArgumentException("last=" + last.getB() + " arc=" + arc.getA());
+ }
+ }
+ this.arcs.add(arc);
+ }
+
+ private final MyPoint2D getMyPoint2D(int i) {
+ return getArc(i).getA();
+ }
+
+ private Arc getArc(int i) {
+ if (i == -1) {
+ return arcs.get(arcs.size() - 1);
+ }
+ if (i == arcs.size()) {
+ return arcs.get(0);
+ }
+ if (i == arcs.size() + 1) {
+ return arcs.get(1);
+ }
+ return arcs.get(i);
+ }
+
+ private UPath toUPath() {
+ final TriangleCorner corner0 = new TriangleCorner(getMyPoint2D(0), getMyPoint2D(1), getMyPoint2D(2));
+ final int swepFlag = corner0.determinant() < 0 ? 0 : 1;
+
+ final UPath path = new UPath();
+ final BetweenCorners betweenCornersLast = new BetweenCorners(getCorner(arcs.size() - 1),
+ getCorner(arcs.size()), arcs.get(arcs.size() - 1).getTension());
+ betweenCornersLast.initPath(path);
+ for (int i = 0; i < arcs.size(); i++) {
+
+ // if (i == 0) {
+ // if (getMyPoint2D(i).hasCurvation()) {
+ // path.moveTo(getPointK(i));
+ // } else {
+ // path.moveTo(arcs.get(i).getA());
+ // }
+ // }
+
+ final BetweenCorners betweenCorners = new BetweenCorners(getCorner(i), getCorner(i + 1), arcs.get(i)
+ .getTension());
+ betweenCorners.addToPath(path, swepFlag);
+
+ }
+ path.closePath();
+ return path;
+ }
+
+ private void debugMe(UGraphic ug) {
+ for (int i = 0; i < arcs.size(); i++) {
+ final BetweenCorners betweenCorners = new BetweenCorners(getCorner(i), getCorner(i + 1), arcs.get(i)
+ .getTension());
+ betweenCorners.debugMe(ug.apply(new UChangeColor(HtmlColorUtils.BLACK)).apply(new UChangeBackColor(null)));
+ }
+ }
+
+ private Point2D getPointK(final int j) {
+ if (getMyPoint2D(j).hasCurvation()) {
+ return getCorner(j).getOnSegmentB(getMyPoint2D(j).getCurvation(0));
+ }
+ return arcs.get(j - 1).getB();
+ }
+
+ private TriangleCorner getCorner(int i) {
+ return new TriangleCorner(getMyPoint2D(i), getMyPoint2D(i - 1), getMyPoint2D(i + 1));
+ }
+
+ public void drawU(UGraphic ug) {
+ final UPath path = toUPath();
+ ug.draw(path);
+// debugMe(ug);
+ }
+
+ public CutePath rotateZoom(RotationZoom rotationZoom) {
+ final CutePath result = new CutePath();
+ for (Arc arc : arcs) {
+ result.arcs.add(arc.rotateZoom(rotationZoom));
+ }
+ return result;
+ }
+
+ public CutePath withNoTension() {
+ final CutePath result = new CutePath();
+ for (Arc arc : arcs) {
+ result.arcs.add(arc.withNoTension());
+ }
+ return result;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/cute/CuteShape.java b/src/net/sourceforge/plantuml/cute/CuteShape.java
new file mode 100644
index 0000000..7616adc
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/CuteShape.java
@@ -0,0 +1,43 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cute;
+
+import net.sourceforge.plantuml.graphic.UDrawable;
+
+public interface CuteShape extends UDrawable {
+
+ public UDrawable rotateZoom(RotationZoom other);
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/CuteShapeFactory.java b/src/net/sourceforge/plantuml/cute/CuteShapeFactory.java
new file mode 100644
index 0000000..bc1726f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/CuteShapeFactory.java
@@ -0,0 +1,81 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cute;
+
+import java.util.Map;
+
+public class CuteShapeFactory {
+
+ private final Map<String, Group> groups;
+
+ public CuteShapeFactory(Map<String, Group> groups) {
+ this.groups = groups;
+
+ }
+
+ public Positionned createCuteShapePositionned(String data) {
+ final VarArgs varArgs = new VarArgs(data);
+ return new PositionnedImpl(createCuteShape(data), varArgs);
+ }
+
+ private CuteShape createCuteShape(String data) {
+ data = data.toLowerCase().trim();
+ final VarArgs varArgs = new VarArgs(data);
+ if (data.startsWith("circle ")) {
+ return new Circle(varArgs);
+ }
+ if (data.startsWith("cheese ")) {
+ return new Cheese(varArgs);
+ }
+ if (data.startsWith("stick ")) {
+ return new Stick(varArgs);
+ }
+ if (data.startsWith("rectangle ") || data.startsWith("rect ")) {
+ return new Rectangle(varArgs);
+ }
+ if (data.startsWith("triangle ")) {
+ return new Triangle(varArgs);
+ }
+ final String first = data.split(" ")[0];
+ System.err.println("Looking for group " + first + " in " + groups.keySet());
+ final Group group = groups.get(first);
+ if (group == null) {
+ throw new IllegalArgumentException("Cannot find group " + first + " in " + groups.keySet());
+ }
+ System.err.println("Found group " + first + " in " + groups.keySet());
+ return group;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/Group.java b/src/net/sourceforge/plantuml/cute/Group.java
new file mode 100644
index 0000000..3749543
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/Group.java
@@ -0,0 +1,125 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cute;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class Group implements Positionned {
+
+ private final String groupName;
+ private final List<Positionned> shapes;
+ private final Group parent;
+ private final Map<String, Group> children;
+
+ // private final List<Group> children = new ArrayList<Group>();
+
+ @Override
+ public String toString() {
+ return "Group " + groupName + " (" + shapes.size() + ") ";
+ }
+
+ // public static Group fromList(List<Positionned> shapes) {
+ // return new Group("Automatic", shapes);
+ // }
+
+ public static Group createRoot() {
+ return new Group(null, "ROOT");
+ }
+
+ private Group(Group parent, String groupName) {
+ this.parent = parent;
+ this.groupName = groupName;
+ this.shapes = new ArrayList<Positionned>();
+ this.children = new HashMap<String, Group>();
+ }
+
+ private Group(Group parent, String groupName, List<Positionned> shapes) {
+ this.parent = parent;
+ this.groupName = groupName;
+ this.shapes = shapes;
+ this.children = null;
+ }
+
+ public Group createChild(String childName) {
+ final Group result = new Group(this, childName);
+ this.children.put(childName, result);
+ return result;
+ }
+
+ public void drawU(UGraphic ug) {
+ for (Positionned shape : shapes) {
+ shape.drawU(ug);
+ }
+ }
+
+ public void add(Positionned shape) {
+ shapes.add(shape);
+ }
+
+ public String getName() {
+ return groupName;
+ }
+
+ public Positionned rotateZoom(RotationZoom rotationZoom) {
+ if (rotationZoom.isNone()) {
+ return this;
+ }
+ final List<Positionned> result = new ArrayList<Positionned>();
+ for (Positionned shape : shapes) {
+ result.add(shape.rotateZoom(rotationZoom));
+ }
+ return new Group(parent, groupName + "->" + rotationZoom, result);
+ }
+
+ public Positionned translate(UTranslate translation) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Group getParent() {
+ return parent;
+ }
+
+ public Map<String, Group> getChildren() {
+ return Collections.unmodifiableMap(children);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/InfiniteLine.java b/src/net/sourceforge/plantuml/cute/InfiniteLine.java
new file mode 100644
index 0000000..8423d84
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/InfiniteLine.java
@@ -0,0 +1,76 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cute;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class InfiniteLine {
+
+ private final Point2D a;
+ private final Point2D b;
+
+ public InfiniteLine(Point2D a, Point2D b) {
+ this.a = a;
+ this.b = b;
+ }
+
+ @Override
+ public String toString() {
+ return "{" + a + ";" + b + "}";
+ }
+
+ public double getDeltaX() {
+ return b.getX() - a.getX();
+ }
+
+ public double getDeltaY() {
+ return b.getY() - a.getY();
+ }
+
+ public double getDr() {
+ return a.distance(b);
+ }
+
+ public double getDiscriminant() {
+ return a.getX() * b.getY() - b.getX() * a.getY();
+ }
+
+ public InfiniteLine translate(UTranslate translate) {
+ return new InfiniteLine(translate.getTranslated(a), translate.getTranslated(b));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/MyDouble.java b/src/net/sourceforge/plantuml/cute/MyDouble.java
new file mode 100644
index 0000000..6f85713
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/MyDouble.java
@@ -0,0 +1,90 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cute;
+
+import java.util.StringTokenizer;
+
+public class MyDouble {
+
+ private static final double NO_CURVE = java.lang.Double.MIN_VALUE;
+ private final double value;
+ private final double curvation;
+
+ public MyDouble(String s) {
+ final StringTokenizer st = new StringTokenizer(s, ",");
+ this.value = java.lang.Double.parseDouble(st.nextToken());
+ if (st.hasMoreTokens()) {
+ this.curvation = java.lang.Double.parseDouble(st.nextToken());
+ } else {
+ this.curvation = NO_CURVE;
+ }
+ }
+
+ @Override
+ public String toString() {
+ return value + "[" + curvation + "]";
+ }
+
+ private MyDouble(double value, double curvation) {
+ this.value = value;
+ this.curvation = curvation;
+ }
+
+ public double getCurvation(double def) {
+ if (curvation == NO_CURVE) {
+ return def;
+ }
+ return curvation;
+ }
+
+ public double getValue() {
+ return value;
+ }
+
+ public boolean hasCurvation() {
+ return curvation != NO_CURVE;
+ }
+
+ public MyDouble rotateZoom(RotationZoom rotationZoom) {
+ final double newValue = rotationZoom.applyZoom(value);
+ final double curvation = this.curvation == NO_CURVE ? NO_CURVE : rotationZoom.applyZoom(this.curvation);
+ return new MyDouble(newValue, curvation);
+ }
+
+ public MyDouble toRadians() {
+ return new MyDouble(Math.toRadians(value), curvation);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/MyPoint2D.java b/src/net/sourceforge/plantuml/cute/MyPoint2D.java
new file mode 100644
index 0000000..b74cf17
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/MyPoint2D.java
@@ -0,0 +1,120 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cute;
+
+import java.awt.geom.Point2D;
+import java.util.StringTokenizer;
+
+public class MyPoint2D extends Point2D {
+
+ public static final double NO_CURVE = 0;
+ private final double x;
+ private final double y;
+ private final double curvation;
+
+ public MyPoint2D(StringTokenizer st) {
+ this.x = java.lang.Double.parseDouble(st.nextToken());
+ this.y = java.lang.Double.parseDouble(st.nextToken());
+ if (st.hasMoreTokens()) {
+ this.curvation = java.lang.Double.parseDouble(st.nextToken());
+ } else {
+ this.curvation = NO_CURVE;
+ }
+ }
+
+ @Override
+ public boolean equals(Object arg0) {
+ final MyPoint2D other = (MyPoint2D) arg0;
+ return this.x == other.x && this.y == other.y && this.curvation == other.curvation;
+ }
+
+ public static MyPoint2D from(double x, double y) {
+ return new MyPoint2D(x, y, NO_CURVE);
+ }
+
+ public MyPoint2D withCurvation(double curvation) {
+ if (curvation == NO_CURVE) {
+ return this;
+ }
+ return new MyPoint2D(x, y, curvation);
+ }
+
+ private MyPoint2D(Point2D p, double curvation) {
+ this.x = p.getX();
+ this.y = p.getY();
+ this.curvation = curvation;
+ }
+
+ private MyPoint2D(double x, double y, double curvation) {
+ this.x = x;
+ this.y = y;
+ this.curvation = curvation;
+ }
+
+ @Override
+ public String toString() {
+ return "(" + x + "," + y + ")";
+ }
+
+ public double getCurvation(double def) {
+ if (curvation == NO_CURVE) {
+ return def;
+ }
+ return curvation;
+ }
+
+ public double getX() {
+ return x;
+ }
+
+ public double getY() {
+ return y;
+ }
+
+ public void setLocation(double arg0, double arg1) {
+ throw new UnsupportedOperationException();
+ }
+
+ public MyPoint2D rotateZoom(RotationZoom rotationZoom) {
+ final Point2D p = rotationZoom.getPoint(x, y);
+ final double curvation = this.curvation == NO_CURVE ? NO_CURVE : rotationZoom.applyZoom(this.curvation);
+ return new MyPoint2D(p, curvation);
+ }
+
+ public boolean hasCurvation() {
+ return curvation != NO_CURVE;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/PSystemCute.java b/src/net/sourceforge/plantuml/cute/PSystemCute.java
new file mode 100644
index 0000000..f1cb15e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/PSystemCute.java
@@ -0,0 +1,94 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cute;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.core.DiagramDescription;
+import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+import net.sourceforge.plantuml.ugraphic.ImageBuilder;
+
+public class PSystemCute extends AbstractPSystem {
+
+ // private final List<Positionned> shapes = new ArrayList<Positionned>();
+ // private final Map<String, Group> groups = new HashMap<String, Group>();
+ private final Group root = Group.createRoot();
+ private Group currentGroup = root;
+
+ public PSystemCute() {
+ }
+
+ public DiagramDescription getDescription() {
+ return new DiagramDescriptionImpl("(Cute)", getClass());
+ }
+
+ public void doCommandLine(String line) {
+ line = line.trim();
+ if (line.length()==0 || line.startsWith("'")) {
+ return;
+ }
+ if (line.startsWith("group ")) {
+ final StringTokenizer st = new StringTokenizer(line);
+ st.nextToken();
+ final String groupName = st.nextToken();
+ currentGroup = currentGroup.createChild(groupName);
+ } else if (line.startsWith("}")) {
+ currentGroup = currentGroup.getParent();
+ } else {
+ final Positionned shape = new CuteShapeFactory(currentGroup.getChildren()).createCuteShapePositionned(line);
+ // if (currentGroup == null) {
+ // shapes.add(shape);
+ // } else {
+ currentGroup.add(shape);
+ // }
+ }
+ }
+
+ public ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormat) throws IOException {
+ final ImageBuilder builder = new ImageBuilder(new ColorMapperIdentity(), 1.0, null, null, null, 10, 10, null, false);
+ builder.addUDrawable(root);
+ return builder.writeImageTOBEMOVED(fileFormat.getFileFormat(), os);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/cute/PSystemCuteFactory.java b/src/net/sourceforge/plantuml/cute/PSystemCuteFactory.java
new file mode 100644
index 0000000..1550495
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/PSystemCuteFactory.java
@@ -0,0 +1,60 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cute;
+
+import net.sourceforge.plantuml.command.PSystemBasicFactory;
+import net.sourceforge.plantuml.core.DiagramType;
+
+public class PSystemCuteFactory extends PSystemBasicFactory<PSystemCute> {
+
+ public PSystemCuteFactory(DiagramType type) {
+ super(type);
+ }
+
+ public PSystemCute init(String startLine) {
+ if (getDiagramType() == DiagramType.CUTE) {
+ return new PSystemCute();
+ }
+
+ return null;
+ }
+
+ @Override
+ public PSystemCute executeLine(PSystemCute system, String line) {
+ system.doCommandLine(line);
+ return system;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/Positionned.java b/src/net/sourceforge/plantuml/cute/Positionned.java
new file mode 100644
index 0000000..6cd6e4e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/Positionned.java
@@ -0,0 +1,45 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cute;
+
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public interface Positionned extends CuteShape {
+
+ public Positionned rotateZoom(RotationZoom rotation);
+
+ public Positionned translate(UTranslate translation);
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/PositionnedImpl.java b/src/net/sourceforge/plantuml/cute/PositionnedImpl.java
new file mode 100644
index 0000000..d907968
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/PositionnedImpl.java
@@ -0,0 +1,106 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cute;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class PositionnedImpl implements Positionned {
+
+ private final CuteShape cuteShape;
+ private final HtmlColor color;
+ private final UTranslate position;
+ private final RotationZoom rotationZoom;
+
+ @Override
+ public String toString() {
+ return "Positionned " + position + " " + cuteShape;
+ }
+
+ public PositionnedImpl(CuteShape cuteShape, VarArgs args) {
+ this.cuteShape = cuteShape;
+ this.color = args.getAsColor("color");
+ this.position = args.getPosition();
+ this.rotationZoom = RotationZoom.fromVarArgs(args);
+ }
+
+ private PositionnedImpl(CuteShape cuteShape, HtmlColor color, UTranslate position, RotationZoom rotationZoom) {
+ this.cuteShape = cuteShape;
+ this.color = color;
+ this.position = position;
+ this.rotationZoom = rotationZoom;
+ }
+
+ public PositionnedImpl(Group group, RotationZoom rotation) {
+ this.cuteShape = group;
+ this.color = HtmlColorUtils.BLACK;
+ this.position = new UTranslate();
+ this.rotationZoom = rotation;
+ }
+
+ public PositionnedImpl(Group group, UTranslate translation) {
+ this.cuteShape = group;
+ this.color = HtmlColorUtils.BLACK;
+ this.position = translation;
+ this.rotationZoom = RotationZoom.none();
+ }
+
+ private UGraphic applyColor(UGraphic ug) {
+ return ug.apply(new UChangeBackColor(color)).apply(new UChangeColor(color));
+
+ }
+
+ public void drawU(UGraphic ug) {
+ ug = applyColor(ug);
+ ug = ug.apply(position);
+ final UDrawable tmp = rotationZoom.isNone() ? cuteShape : cuteShape.rotateZoom(rotationZoom);
+ // System.err.println("rotationZoom=" + rotationZoom + " tmp=" + tmp);
+ tmp.drawU(ug);
+ }
+
+ public Positionned rotateZoom(RotationZoom other) {
+ return new PositionnedImpl(cuteShape, color, other.getUTranslate(position), rotationZoom.compose(other));
+ }
+
+ public Positionned translate(UTranslate other) {
+ return new PositionnedImpl(cuteShape, color, position.compose(other), rotationZoom);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/Rectangle.java b/src/net/sourceforge/plantuml/cute/Rectangle.java
new file mode 100644
index 0000000..c04ad7e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/Rectangle.java
@@ -0,0 +1,105 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cute;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UPath;
+
+public class Rectangle implements CuteShape {
+
+ private final double width;
+ private final double height;
+ private final RotationZoom rotationZoom;
+ private final double curvation;
+
+ public Rectangle(VarArgs varArgs) {
+ final Point2D dim = varArgs.getAsPoint("dimension");
+ this.width = dim.getX();
+ this.height = dim.getY();
+ this.rotationZoom = RotationZoom.none();
+ this.curvation = varArgs.getAsDouble("curve", MyPoint2D.NO_CURVE);
+ }
+
+ private Rectangle(double width, double height, RotationZoom rotationZoom, double curvation) {
+ this.width = width;
+ this.height = height;
+ this.rotationZoom = rotationZoom;
+ this.curvation = curvation;
+ }
+
+ public void drawU(UGraphic ug) {
+ CutePath cutePath = new CutePath();
+ cutePath.add(new Arc(MyPoint2D.from(0, 0).withCurvation(curvation), MyPoint2D.from(width, 0).withCurvation(
+ curvation)));
+ cutePath.add(new Arc(MyPoint2D.from(width, 0).withCurvation(curvation), MyPoint2D.from(width, height)
+ .withCurvation(curvation)));
+ cutePath.add(new Arc(MyPoint2D.from(width, height).withCurvation(curvation), MyPoint2D.from(0, height)
+ .withCurvation(curvation)));
+ cutePath.add(new Arc(MyPoint2D.from(0, height).withCurvation(curvation), MyPoint2D.from(0, 0).withCurvation(
+ curvation)));
+ cutePath = cutePath.rotateZoom(rotationZoom);
+ cutePath.drawU(ug);
+ }
+
+ public void drawUOld(UGraphic ug) {
+ final UPath path = new UPath();
+ if (curvation == MyPoint2D.NO_CURVE) {
+ path.moveTo(rotationZoom.getPoint(0, 0));
+ path.lineTo(rotationZoom.getPoint(width, 0));
+ path.lineTo(rotationZoom.getPoint(width, height));
+ path.lineTo(rotationZoom.getPoint(0, height));
+ path.lineTo(rotationZoom.getPoint(0, 0));
+ } else {
+ path.moveTo(rotationZoom.getPoint(width, curvation));
+ path.lineTo(rotationZoom.getPoint(width, height - curvation));
+ path.arcTo(rotationZoom.getPoint(width - curvation, height), curvation, 0, 1);
+ path.lineTo(rotationZoom.getPoint(curvation, height));
+ path.arcTo(rotationZoom.getPoint(0, height - curvation), curvation, 0, 1);
+ path.lineTo(rotationZoom.getPoint(0, curvation));
+ path.arcTo(rotationZoom.getPoint(curvation, 0), curvation, 0, 1);
+ path.lineTo(rotationZoom.getPoint(width - curvation, 0));
+ path.arcTo(rotationZoom.getPoint(width, curvation), curvation, 0, 1);
+ }
+ path.closePath();
+ ug.draw(path);
+ }
+
+ public Rectangle rotateZoom(RotationZoom other) {
+ return new Rectangle(width, height, rotationZoom.compose(other), curvation);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/RotationZoom.java b/src/net/sourceforge/plantuml/cute/RotationZoom.java
new file mode 100644
index 0000000..aa84f3e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/RotationZoom.java
@@ -0,0 +1,128 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cute;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class RotationZoom {
+
+ private final double angle;
+ private final double zoom;
+
+ private RotationZoom(double angle, double zoom) {
+ if (zoom < 0) {
+ throw new IllegalArgumentException();
+ }
+ this.angle = angle;
+ this.zoom = zoom;
+ }
+
+ public RotationZoom compose(RotationZoom other) {
+ return new RotationZoom(this.angle + other.angle, this.zoom * other.zoom);
+ }
+
+ @Override
+ public String toString() {
+ return "Rotation=" + Math.toDegrees(angle) + " Zoom=" + zoom;
+ }
+
+ public static RotationZoom fromVarArgs(VarArgs varArgs) {
+ final double radians = Math.toRadians(varArgs.getAsDouble("rotation", 0));
+ final double scale = varArgs.getAsDouble("scale", 1);
+ return new RotationZoom(radians, scale);
+ }
+
+ public static RotationZoom rotationInDegrees(double angle) {
+ return new RotationZoom(Math.toRadians(angle), 1);
+ }
+
+ public static RotationZoom rotationInRadians(double angle) {
+ return new RotationZoom(angle, 1);
+ }
+
+ public static RotationZoom zoom(double zoom) {
+ return new RotationZoom(0, zoom);
+ }
+
+ public RotationZoom inverse() {
+ return new RotationZoom(-angle, 1 / zoom);
+ }
+
+ public double getAngleDegree() {
+ return Math.toDegrees(angle);
+ }
+
+ static public RotationZoom builtRotationOnYaxis(Point2D toRotate) {
+ final double a = Math.atan2(toRotate.getX(), toRotate.getY());
+ return new RotationZoom(a, 1);
+ }
+
+ public Point2D.Double getPoint(double x, double y) {
+ if (angle == 0) {
+ return new Point2D.Double(x * zoom, y * zoom);
+ }
+ final double x1 = Math.cos(angle) * x - Math.sin(angle) * y;
+ final double y1 = Math.sin(angle) * x + Math.cos(angle) * y;
+ return new Point2D.Double(x1 * zoom, y1 * zoom);
+ }
+
+ public Point2D getPoint(Point2D p) {
+ return getPoint(p.getX(), p.getY());
+ }
+
+ public UTranslate getUTranslate(UTranslate translate) {
+ return new UTranslate(getPoint(translate.getDx(), translate.getDy()));
+
+ }
+
+ public static RotationZoom none() {
+ return new RotationZoom(0, 1);
+ }
+
+ public boolean isNone() {
+ return angle == 0 && zoom == 1;
+ }
+
+ public double applyZoom(double value) {
+ return value * zoom;
+ }
+
+ public double applyRotation(double alpha) {
+ return angle + alpha;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/Segment.java b/src/net/sourceforge/plantuml/cute/Segment.java
new file mode 100644
index 0000000..ce63eef
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/Segment.java
@@ -0,0 +1,109 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cute;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class Segment {
+
+ private final Point2D a;
+ private final Point2D b;
+ private final double length;
+
+ public Segment(Point2D a, Point2D b) {
+ this.a = a;
+ this.b = b;
+ this.length = a.distance(b);
+ if (length < 0.0001) {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ public Point2D getFromAtoB(double dist) {
+ final double dx = b.getX() - a.getX();
+ final double dy = b.getY() - a.getY();
+ final double coef = dist / length;
+ final double x = dx * coef;
+ final double y = dy * coef;
+ return new Point2D.Double(a.getX() + x, a.getY() + y);
+ }
+
+ public Point2D getA() {
+ return a;
+ }
+
+ public Point2D getB() {
+ return b;
+ }
+
+ public Point2D getMiddle() {
+ return new Point2D.Double((a.getX() + b.getX()) / 2, (a.getY() + b.getY()) / 2);
+ }
+
+ private Point2D orthoDirection() {
+ final double dx = b.getX() - a.getX();
+ final double dy = b.getY() - a.getY();
+ return new Point2D.Double(-dy / length, dx / length);
+ }
+
+ public Point2D getOrthoPoint(double value) {
+ final Point2D ortho = orthoDirection();
+ final double dx = -ortho.getX() * value;
+ final double dy = -ortho.getY() * value;
+ return new Point2D.Double((a.getX() + b.getX()) / 2 + dx, (a.getY() + b.getY()) / 2 + dy);
+ }
+
+
+ private boolean isLeft(Point2D point) {
+ return ((b.getX() - a.getX()) * (point.getY() - a.getY()) - (b.getY() - a.getY()) * (point.getX() - a.getX())) > 0;
+ }
+
+ public double getLength() {
+ return length;
+ }
+
+ public void debugMe(UGraphic ug) {
+ final double dx = b.getX() - a.getX();
+ final double dy = b.getY() - a.getY();
+ ug = ug.apply(new UTranslate(a));
+ ug.draw(new ULine(dx, dy));
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/Stick.java b/src/net/sourceforge/plantuml/cute/Stick.java
new file mode 100644
index 0000000..54acf3c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/Stick.java
@@ -0,0 +1,99 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cute;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UPath;
+
+public class Stick implements CuteShape {
+
+ private final double width;
+ private final double height;
+ private final RotationZoom rotationZoom;
+
+ public Stick(VarArgs varArgs) {
+ final Point2D dim = varArgs.getAsPoint("dimension");
+ this.width = dim.getX();
+ this.height = dim.getY();
+ this.rotationZoom = RotationZoom.none();
+ }
+
+ private Stick(double width, double height, RotationZoom rotation) {
+ this.width = width;
+ this.height = height;
+ this.rotationZoom = rotation;
+ }
+
+ public void drawU(UGraphic ug) {
+ if (width > height) {
+ drawRotate1(ug);
+ } else {
+ drawRotate2(ug);
+ }
+ }
+
+ private void drawRotate1(UGraphic ug) {
+ assert width > height;
+ final UPath path = new UPath();
+ final double small = height / 2;
+ path.moveTo(rotationZoom.getPoint(small, 0));
+ path.lineTo(rotationZoom.getPoint(width - small, 0));
+ path.arcTo(rotationZoom.getPoint(width - small, height), small, 0, 1);
+ path.lineTo(rotationZoom.getPoint(small, height));
+ path.arcTo(rotationZoom.getPoint(small, 0), small, 0, 1);
+ path.closePath();
+ ug.draw(path);
+ }
+
+ private void drawRotate2(UGraphic ug) {
+ assert height > width;
+ final UPath path = new UPath();
+ final double small = width / 2;
+ path.moveTo(rotationZoom.getPoint(width, small));
+ path.lineTo(rotationZoom.getPoint(width, height - small));
+ path.arcTo(rotationZoom.getPoint(0, height - small), small, 0, 1);
+ path.lineTo(rotationZoom.getPoint(0, small));
+ path.arcTo(rotationZoom.getPoint(width, small), small, 0, 1);
+ path.closePath();
+ ug.draw(path);
+ }
+
+ public Stick rotateZoom(RotationZoom other) {
+ return new Stick(width, height, this.rotationZoom.compose(other));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/Tension.java b/src/net/sourceforge/plantuml/cute/Tension.java
new file mode 100644
index 0000000..de13d5b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/Tension.java
@@ -0,0 +1,61 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cute;
+
+public class Tension {
+
+ private final double tension;
+
+ public Tension(double tension) {
+ this.tension = tension;
+ }
+
+ public static Tension none() {
+ return new Tension(0);
+ }
+
+ public Tension rotateZoom(RotationZoom rotationZoom) {
+ return new Tension(rotationZoom.applyZoom(tension));
+ }
+
+ public boolean isNone() {
+ return tension == 0;
+ }
+
+ public double getValue() {
+ return tension;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/Triangle.java b/src/net/sourceforge/plantuml/cute/Triangle.java
new file mode 100644
index 0000000..2a6ef81
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/Triangle.java
@@ -0,0 +1,68 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cute;
+
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class Triangle implements CuteShape {
+
+ private final CutePath cutePath;
+
+ public Triangle(VarArgs varArgs) {
+ this(varArgs.getPointList("points"));
+ }
+
+ private Triangle(CutePath cutePath) {
+ this.cutePath = cutePath;
+ // if (points.size() != 3) {
+ // throw new IllegalArgumentException();
+ // }
+ }
+
+ public Triangle rotateZoom(final RotationZoom angle) {
+ if (angle.isNone()) {
+ return this;
+ }
+ return new Triangle(cutePath.rotateZoom(angle));
+ }
+
+ public void drawU(UGraphic ug) {
+ cutePath.drawU(ug);
+ // ug = ug.apply(new UChangeBackColor(null)).apply(new UChangeColor(HtmlColorUtils.BLACK));
+ // cutePath.withNoTension().drawU(
+ // ug.apply(new UChangeBackColor(null)).apply(new UChangeColor(HtmlColorUtils.BLACK)));
+
+ }
+}
diff --git a/src/net/sourceforge/plantuml/cute/TriangleCorner.java b/src/net/sourceforge/plantuml/cute/TriangleCorner.java
new file mode 100644
index 0000000..7b9cb4a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/TriangleCorner.java
@@ -0,0 +1,142 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cute;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class TriangleCorner {
+
+ private final Point2D o;
+ private final Point2D a;
+ private final Point2D b;
+ private final TriangleCornerSimple simple;
+ private final UTranslate translateO;
+ private final UTranslate translateOreverse;
+
+ private final RotationZoom rotation;
+ private final RotationZoom rotationInverse;
+
+ @Override
+ public String toString() {
+ return "Corner " + o + " a=" + a + " b=" + b;
+ }
+
+ public boolean hasCurvation() {
+ return ((MyPoint2D) o).hasCurvation();
+ }
+
+ public double getCurvation() {
+ if (hasCurvation() == false) {
+ throw new IllegalStateException();
+ }
+ return ((MyPoint2D) o).getCurvation(0);
+ }
+
+ public TriangleCorner(Point2D o, Point2D a, Point2D b) {
+ this.o = o;
+ this.a = a;
+ this.b = b;
+ this.translateO = new UTranslate(o);
+ this.translateOreverse = translateO.reverse();
+ final Point2D a2 = translateOreverse.getTranslated(a);
+ final Point2D b2 = translateOreverse.getTranslated((b));
+
+ final Point2D a3, b3;
+ if (a2.getX() == 0) {
+ a3 = a2;
+ b3 = b2;
+ this.rotation = RotationZoom.none();
+ this.rotationInverse = RotationZoom.none();
+ } else {
+ this.rotation = RotationZoom.builtRotationOnYaxis(a2);
+ this.rotationInverse = rotation.inverse();
+ a3 = rotation.getPoint(a2);
+ b3 = rotation.getPoint(b2);
+ }
+
+ this.simple = new TriangleCornerSimple(a3, b3);
+ }
+
+ public Point2D getOnSegmentA(double dist) {
+ final Segment seg = new Segment(o, a);
+ return seg.getFromAtoB(dist);
+ }
+
+ public Point2D getOnSegmentB(double dist) {
+ final Segment seg = new Segment(o, b);
+ return seg.getFromAtoB(dist);
+ }
+
+ public Balloon getCenterWithFixedRadius(double radius) {
+ final Point2D centerSimple = simple.getCenterWithFixedRadius(radius);
+ return new Balloon(rotationInverse.getPoint(translateO.getTranslated(centerSimple)), radius);
+ }
+
+ private Balloon getBalloonWithFixedY(double y) {
+ Balloon result = simple.getBalloonWithFixedY(y);
+ result = result.rotate(rotationInverse);
+ result = result.translate(translateO);
+ return result;
+ }
+
+ public Point2D getCornerOrBalloonCenter() {
+ if (hasCurvation()) {
+ return getBalloonInside().getCenter();
+ }
+ return getO();
+ }
+
+ public double determinant() {
+ final double ux = a.getX() - o.getX();
+ final double uy = a.getY() - o.getY();
+ final double vx = b.getX() - o.getX();
+ final double vy = b.getY() - o.getY();
+ return ux * vy - uy * vx;
+ }
+
+ public Point2D getO() {
+ return o;
+ }
+
+ public Balloon getBalloonInside() {
+ if (hasCurvation() == false) {
+ throw new IllegalStateException();
+ }
+ return getBalloonWithFixedY(getCurvation());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/TriangleCornerSimple.java b/src/net/sourceforge/plantuml/cute/TriangleCornerSimple.java
new file mode 100644
index 0000000..0dbbed0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/TriangleCornerSimple.java
@@ -0,0 +1,116 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cute;
+
+import java.awt.geom.Point2D;
+
+public class TriangleCornerSimple {
+
+ private final Point2D a;
+ private final Point2D b;
+
+ @Override
+ public String toString() {
+ return "TriangleCornerSimple a=" + a + " " + Math.toDegrees(getAngleA()) + " b=" + b + " "
+ + Math.toDegrees(getAngleB());
+ }
+
+ public TriangleCornerSimple(Point2D a, Point2D b) {
+ if (isZero(a.getX()) == false) {
+ throw new IllegalArgumentException("a=" + a);
+ }
+ this.a = a;
+ this.b = b;
+ }
+
+ private static boolean isZero(double v) {
+ return Math.abs(v) < 0.0001;
+ }
+
+ double getAngleA() {
+ return getAngle(a);
+ }
+
+ double getAngleB() {
+ return getAngle(b);
+ }
+
+ double getAngle(Point2D pt) {
+ final double dx = pt.getX();
+ final double dy = pt.getY();
+ return Math.atan2(dy, dx);
+
+ }
+
+ static double solveY(double alpha, double x) {
+ if (alpha < 0 || alpha > Math.PI / 2) {
+ throw new IllegalArgumentException();
+ }
+ return x * Math.tan(alpha);
+ }
+
+ static double solveX(double alpha, double y) {
+ if (alpha < -Math.PI / 2 || alpha > Math.PI / 2) {
+ // throw new IllegalArgumentException("y=" + y + " alpha=" + Math.toDegrees(alpha));
+ }
+ final double beta = Math.PI / 2 - alpha;
+ // System.err.println("alpha1=" + Math.toDegrees(alpha));
+ // System.err.println("beta11=" + Math.toDegrees(beta));
+ // System.err.println("XX=" + y * Math.tan(beta));
+ return y * Math.tan(beta);
+
+ }
+
+ public Point2D getCenterWithFixedRadius(double radius) {
+ final double alpha = (getAngleA() + getAngleB()) / 2;
+ final double y = solveY(alpha, radius);
+ return new Point2D.Double(radius, y);
+ }
+
+ public Balloon getBalloonWithFixedY(double y) {
+ // System.err.println("TriangleCornerSimple::getCenterWithFixedY y=" + y);
+ // System.err.println("a=" + a + " " + Math.toDegrees(getAngleA()));
+ // System.err.println("b=" + b + " " + Math.toDegrees(getAngleB()));
+ final double alpha = (getAngleA() + getAngleB()) / 2;
+ // System.err.println("alpha=" + Math.toDegrees(alpha));
+ final double sign = Math.signum(a.getY());
+ // System.err.println("sgn=" + sign);
+ final double x = solveX(alpha, y);
+ final Balloon result = new Balloon(new Point2D.Double(x * sign, y * sign), Math.abs(x));
+ // System.err.println("result=" + result);
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/cute/VarArgs.java b/src/net/sourceforge/plantuml/cute/VarArgs.java
new file mode 100644
index 0000000..5b8ff53
--- /dev/null
+++ b/src/net/sourceforge/plantuml/cute/VarArgs.java
@@ -0,0 +1,131 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.cute;
+
+import java.awt.geom.Point2D;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorSet;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class VarArgs {
+
+ private final Map<String, String> args = new HashMap<String, String>();
+
+ public VarArgs(String data) {
+ for (String s : data.split("\\s")) {
+ if (s.contains("=")) {
+ final StringTokenizer st = new StringTokenizer(s, "=");
+ final String key = st.nextToken();
+ final String value = st.nextToken();
+ args.put(key, value);
+ }
+ }
+ // System.err.println("arg=" + args);
+ }
+
+ @Override
+ public String toString() {
+ return args.toString();
+ }
+
+ public double getAsDouble(String k, double def) {
+ if (args.containsKey(k)) {
+ return getAsDouble(k);
+ }
+ return def;
+ }
+
+ public double getAsDouble(String k) {
+ final String value = args.get(k);
+ if (value == null) {
+ throw new IllegalArgumentException("no key " + k);
+ }
+ return Double.parseDouble(value);
+ }
+
+ public MyDouble getAsMyDouble(String k) {
+ final String value = args.get(k);
+ if (value == null) {
+ throw new IllegalArgumentException("no key " + k);
+ }
+ return new MyDouble(value);
+ }
+
+ public HtmlColor getAsColor(String k) {
+ final String value = args.get(k);
+ if (value == null) {
+ return HtmlColorUtils.BLACK;
+ }
+ final HtmlColor result = HtmlColorSet.getInstance().getColorIfValid(value);
+ if (result == null) {
+ return HtmlColorUtils.BLACK;
+ }
+ return result;
+ }
+
+ public Point2D getAsPoint(String k) {
+ final String value = args.get(k);
+ if (value == null) {
+ throw new IllegalArgumentException("no key " + k);
+ }
+ final StringTokenizer st = new StringTokenizer(value.replaceAll("[()]", ""), ",");
+ return new Point2D.Double(Double.parseDouble(st.nextToken()), Double.parseDouble(st.nextToken()));
+ }
+
+ public Point2D getAsPoint(String k, Point2D def) {
+ if (args.containsKey(k)) {
+ return getAsPoint(k);
+ }
+ return def;
+ }
+
+ public CutePath getPointList(String k) {
+ final String value = args.get(k);
+ if (value == null) {
+ throw new IllegalArgumentException("no key " + k);
+ }
+ return new CutePath(value);
+ }
+
+ public UTranslate getPosition() {
+ return new UTranslate(getAsPoint("position", new Point2D.Double()));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/descdiagram/DescriptionDiagram.java b/src/net/sourceforge/plantuml/descdiagram/DescriptionDiagram.java
new file mode 100644
index 0000000..03c0fd3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/descdiagram/DescriptionDiagram.java
@@ -0,0 +1,143 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.descdiagram;
+
+import net.sourceforge.plantuml.UmlDiagramType;
+import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+import net.sourceforge.plantuml.graphic.USymbol;
+import net.sourceforge.plantuml.StringUtils;
+
+public class DescriptionDiagram extends AbstractEntityDiagram {
+
+ private String namespaceSeparator = null;
+
+ @Override
+ public ILeaf getOrCreateLeaf(Code code, LeafType type, USymbol symbol) {
+ if (namespaceSeparator != null) {
+ code = code.withSeparator(namespaceSeparator);
+ }
+ if (namespaceSeparator != null && code.getFullName().contains(namespaceSeparator)) {
+ // System.err.println("code=" + code);
+ final Code fullyCode = code;
+ // final String namespace = fullyCode.getNamespace(getLeafs());
+ // System.err.println("namespace=" + namespace);
+ }
+ if (type == null) {
+ String code2 = code.getFullName();
+ if (code2.startsWith("[") && code2.endsWith("]")) {
+ final USymbol sym = getSkinParam().useUml2ForComponent() ? USymbol.COMPONENT2 : USymbol.COMPONENT1;
+ return getOrCreateLeafDefault(code.eventuallyRemoveStartingAndEndingDoubleQuote("\"([:"),
+ LeafType.DESCRIPTION, sym);
+ }
+ if (code2.startsWith(":") && code2.endsWith(":")) {
+ return getOrCreateLeafDefault(code.eventuallyRemoveStartingAndEndingDoubleQuote("\"([:"),
+ LeafType.DESCRIPTION, USymbol.ACTOR);
+ }
+ if (code2.startsWith("()")) {
+ code2 = code2.substring(2).trim();
+ code2 = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(code2);
+ return getOrCreateLeafDefault(Code.of(code2), LeafType.DESCRIPTION, USymbol.INTERFACE);
+ }
+ code = code.eventuallyRemoveStartingAndEndingDoubleQuote("\"([:");
+ return getOrCreateLeafDefault(code, LeafType.STILL_UNKNOWN, symbol);
+ }
+ return getOrCreateLeafDefault(code, type, symbol);
+ }
+
+ // @Override
+ // public ILeaf createLeaf(Code code, List<? extends CharSequence> display, LeafType type) {
+ // if (type != LeafType.COMPONENT) {
+ // return super.createLeaf(code, display, type);
+ // }
+ // code = code.getFullyQualifiedCode(getCurrentGroup());
+ // if (super.leafExist(code)) {
+ // throw new IllegalArgumentException("Already known: " + code);
+ // }
+ // return createEntityWithNamespace(code, display, type);
+ // }
+
+ // private ILeaf createEntityWithNamespace(Code fullyCode, List<? extends CharSequence> display, LeafType type) {
+ // IGroup group = getCurrentGroup();
+ // final String namespace = fullyCode.getNamespace(getLeafs());
+ // if (namespace != null && (EntityUtils.groupRoot(group) || group.getCode().equals(namespace) == false)) {
+ // group = getOrCreateGroupInternal(Code.of(namespace), StringUtils.getWithNewlines(namespace), namespace,
+ // GroupType.PACKAGE, getRootGroup());
+ // }
+ // return createLeafInternal(fullyCode,
+ // display == null ? StringUtils.getWithNewlines(fullyCode.getShortName(getLeafs())) : display, type,
+ // group);
+ // }
+
+ private boolean isUsecase() {
+ for (ILeaf leaf : getLeafsvalues()) {
+ final LeafType type = leaf.getEntityType();
+ final USymbol usymbol = leaf.getUSymbol();
+ if (type == LeafType.USECASE || usymbol == USymbol.ACTOR) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public void makeDiagramReady() {
+ super.makeDiagramReady();
+ final LeafType defaultType = isUsecase() ? LeafType.DESCRIPTION : LeafType.DESCRIPTION;
+ final USymbol defaultSymbol = isUsecase() ? USymbol.ACTOR : USymbol.INTERFACE;
+ for (ILeaf leaf : getLeafsvalues()) {
+ if (leaf.getEntityType() == LeafType.STILL_UNKNOWN) {
+ leaf.muteToType(defaultType, defaultSymbol);
+ }
+ }
+ }
+
+ @Override
+ public UmlDiagramType getUmlDiagramType() {
+ return UmlDiagramType.DESCRIPTION;
+ }
+
+ public void setNamespaceSeparator(String namespaceSeparator) {
+ this.namespaceSeparator = namespaceSeparator;
+ }
+
+ public String getNamespaceSeparator() {
+ return namespaceSeparator;
+ }
+
+
+}
diff --git a/src/net/sourceforge/plantuml/descdiagram/DescriptionDiagramFactory.java b/src/net/sourceforge/plantuml/descdiagram/DescriptionDiagramFactory.java
new file mode 100644
index 0000000..dfb2c7f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/descdiagram/DescriptionDiagramFactory.java
@@ -0,0 +1,128 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.descdiagram;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.classdiagram.command.CommandUrl;
+import net.sourceforge.plantuml.command.Command;
+import net.sourceforge.plantuml.command.CommandEndPackage;
+import net.sourceforge.plantuml.command.CommandFootboxIgnored;
+import net.sourceforge.plantuml.command.CommandPackage;
+import net.sourceforge.plantuml.command.CommandPage;
+import net.sourceforge.plantuml.command.CommandRankDir;
+import net.sourceforge.plantuml.command.UmlDiagramFactory;
+import net.sourceforge.plantuml.command.note.FactoryNoteCommand;
+import net.sourceforge.plantuml.command.note.FactoryNoteOnEntityCommand;
+import net.sourceforge.plantuml.command.note.FactoryNoteOnLinkCommand;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexOr;
+import net.sourceforge.plantuml.descdiagram.command.CommandCreateElementFull;
+import net.sourceforge.plantuml.descdiagram.command.CommandCreateElementMultilines;
+import net.sourceforge.plantuml.descdiagram.command.CommandLinkElement;
+import net.sourceforge.plantuml.descdiagram.command.CommandNamespaceSeparator;
+import net.sourceforge.plantuml.descdiagram.command.CommandNewpage;
+import net.sourceforge.plantuml.descdiagram.command.CommandPackageWithUSymbol;
+
+public class DescriptionDiagramFactory extends UmlDiagramFactory {
+
+ @Override
+ public DescriptionDiagram createEmptyDiagram() {
+ return new DescriptionDiagram();
+ }
+
+ @Override
+ protected List<Command> createCommands() {
+ final List<Command> cmds = new ArrayList<Command>();
+
+ cmds.add(new CommandFootboxIgnored());
+ cmds.add(new CommandNamespaceSeparator());
+ cmds.add(new CommandRankDir());
+ cmds.add(new CommandNewpage(this));
+ addCommonCommands(cmds);
+
+ cmds.add(new CommandPage());
+ cmds.add(new CommandLinkElement());
+ //
+ cmds.add(new CommandPackageWithUSymbol());
+ cmds.add(new CommandPackage());
+ cmds.add(new CommandEndPackage());
+ // addCommand(new CommandNamespace());
+ // addCommand(new CommandEndNamespace());
+ final FactoryNoteCommand factoryNoteCommand = new FactoryNoteCommand();
+ cmds.add(factoryNoteCommand.createMultiLine());
+
+ final FactoryNoteOnEntityCommand factoryNoteOnEntityCommand = new FactoryNoteOnEntityCommand(new RegexOr(
+ "ENTITY", //
+ new RegexLeaf("[\\p{L}0-9_.]+"), //
+ new RegexLeaf("\\(\\)[%s]*[\\p{L}0-9_.]+"), //
+ new RegexLeaf("\\(\\)[%s]*[%g][^%g]+[%g]"), //
+ new RegexLeaf("\\[[^\\]*]+[^\\]]*\\]"), //
+ new RegexLeaf("\\((?!\\*\\))[^\\)]+\\)"), //
+ new RegexLeaf(":[^:]+:"), //
+ new RegexLeaf("[%g][^%g]+[%g]") //
+ ));
+ cmds.add(factoryNoteOnEntityCommand.createSingleLine());
+
+ cmds.add(factoryNoteCommand.createSingleLine());
+ cmds.add(new CommandUrl());
+ // addCommand(new CommandCreateComponent2());
+ cmds.add(new CommandCreateElementFull());
+ cmds.add(new CommandCreateElementMultilines());
+ // addCommand(new CommandCreateElementTyped());
+ // addCommand(new CommandCreateCircleInterface());
+ // addCommand(new CommandCreateActorInComponent());
+
+ cmds.add(factoryNoteOnEntityCommand.createMultiLine());
+ cmds.add(factoryNoteCommand.createMultiLine());
+
+ final FactoryNoteOnLinkCommand factoryNoteOnLinkCommand = new FactoryNoteOnLinkCommand();
+ cmds.add(factoryNoteOnLinkCommand.createSingleLine());
+ cmds.add(factoryNoteOnLinkCommand.createMultiLine());
+
+ return cmds;
+ }
+
+ @Override
+ public String checkFinalError(AbstractPSystem system) {
+ if (system instanceof DescriptionDiagram) {
+ ((DescriptionDiagram) system).applySingleStrategy();
+ }
+ return super.checkFinalError(system);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/descdiagram/command/CommandCreateElementFull.java b/src/net/sourceforge/plantuml/descdiagram/command/CommandCreateElementFull.java
new file mode 100644
index 0000000..5273fd5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/descdiagram/command/CommandCreateElementFull.java
@@ -0,0 +1,228 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.descdiagram.command;
+
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexOr;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.descdiagram.DescriptionDiagram;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.USymbol;
+import net.sourceforge.plantuml.StringUtils;
+
+public class CommandCreateElementFull extends SingleLineCommand2<DescriptionDiagram> {
+
+ public CommandCreateElementFull() {
+ super(getRegexConcat());
+ }
+
+ private static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf(
+ "SYMBOL",
+ "(?:(artifact|actor|folder|package|rectangle|node|frame|cloud|database|queue|storage|agent|usecase|component|boundary|control|entity|interface|\\(\\))[%s]+)?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexOr(//
+ new RegexLeaf("CODE1", CODE_WITH_QUOTE), //
+ new RegexConcat(//
+ new RegexLeaf("DISPLAY2", DISPLAY), //
+ new RegexLeaf("STEREOTYPE2", "(?:[%s]+(\\<\\<.+\\>\\>))?"), //
+ new RegexLeaf("[%s]*as[%s]+"), //
+ new RegexLeaf("CODE2", CODE)), //
+ new RegexConcat(//
+ new RegexLeaf("CODE3", CODE), //
+ new RegexLeaf("STEREOTYPE3", "(?:[%s]+(\\<\\<.+\\>\\>))?"), //
+ new RegexLeaf("[%s]+as[%s]*"), //
+ new RegexLeaf("DISPLAY3", DISPLAY)), //
+ new RegexConcat(//
+ new RegexLeaf("DISPLAY4", DISPLAY_WITHOUT_QUOTE), //
+ new RegexLeaf("STEREOTYPE4", "(?:[%s]+(\\<\\<.+\\>\\>))?"), //
+ new RegexLeaf("[%s]*as[%s]+"), //
+ new RegexLeaf("CODE4", CODE)) //
+ ), //
+ new RegexLeaf("STEREOTYPE", "(?:[%s]*(\\<\\<.+\\>\\>))?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("COLOR", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), //
+ new RegexLeaf("$"));
+ }
+
+ private static final String CODE_CORE = "[\\p{L}0-9_.]+|\\(\\)[%s]*[\\p{L}0-9_.]+|\\(\\)[%s]*[%g][^%g]+[%g]|:[^:]+:|\\([^()]+\\)|\\[[^\\[\\]]+\\]";
+ private static final String CODE = "(" + CODE_CORE + ")";
+ private static final String CODE_WITH_QUOTE = "(" + CODE_CORE + "|[%g][^%g]+[%g])";
+
+ private static final String DISPLAY_CORE = "[%g][^%g]+[%g]|:[^:]+:|\\([^()]+\\)|\\[[^\\[\\]]+\\]";
+ private static final String DISPLAY = "(" + DISPLAY_CORE + ")";
+ private static final String DISPLAY_WITHOUT_QUOTE = "(" + DISPLAY_CORE + "|[\\p{L}0-9_.]+)";
+
+ @Override
+ final protected boolean isForbidden(String line) {
+ if (line.matches("^[\\p{L}0-9_.]+$")) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(DescriptionDiagram diagram, RegexResult arg) {
+ String codeRaw = arg.getLazzy("CODE", 0);
+ final String displayRaw = arg.getLazzy("DISPLAY", 0);
+ final char codeChar = getCharEncoding(codeRaw);
+ final char codeDisplay = getCharEncoding(displayRaw);
+ final String symbol;
+ if (codeRaw.startsWith("()")) {
+ symbol = "interface";
+ codeRaw = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(codeRaw.substring(2).trim());
+ } else if (codeChar == '(' || codeDisplay == '(') {
+ symbol = "usecase";
+ } else if (codeChar == ':' || codeDisplay == ':') {
+ symbol = "actor";
+ } else if (codeChar == '[' || codeDisplay == '[') {
+ symbol = "component";
+ } else {
+ symbol = arg.get("SYMBOL", 0);
+ }
+
+ final LeafType type;
+ final USymbol usymbol;
+
+ if (symbol == null) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.ACTOR;
+ } else if (symbol.equalsIgnoreCase("artifact")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.ARTIFACT;
+ } else if (symbol.equalsIgnoreCase("folder")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.FOLDER;
+ } else if (symbol.equalsIgnoreCase("package")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.PACKAGE;
+ } else if (symbol.equalsIgnoreCase("rectangle")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.RECTANGLE;
+ } else if (symbol.equalsIgnoreCase("node")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.NODE;
+ } else if (symbol.equalsIgnoreCase("frame")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.FRAME;
+ } else if (symbol.equalsIgnoreCase("cloud")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.CLOUD;
+ } else if (symbol.equalsIgnoreCase("database")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.DATABASE;
+ } else if (symbol.equalsIgnoreCase("queue")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.QUEUE;
+ } else if (symbol.equalsIgnoreCase("storage")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.STORAGE;
+ } else if (symbol.equalsIgnoreCase("agent")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.AGENT;
+ } else if (symbol.equalsIgnoreCase("actor")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.ACTOR;
+ } else if (symbol.equalsIgnoreCase("component")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = diagram.getSkinParam().useUml2ForComponent() ? USymbol.COMPONENT2 : USymbol.COMPONENT1;
+ } else if (symbol.equalsIgnoreCase("boundary")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.BOUNDARY;
+ } else if (symbol.equalsIgnoreCase("control")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.CONTROL;
+ } else if (symbol.equalsIgnoreCase("entity")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.ENTITY_DOMAIN;
+ } else if (symbol.equalsIgnoreCase("interface")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.INTERFACE;
+ } else if (symbol.equalsIgnoreCase("()")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.INTERFACE;
+ } else if (symbol.equalsIgnoreCase("usecase")) {
+ type = LeafType.USECASE;
+ usymbol = null;
+ } else {
+ throw new IllegalStateException();
+ }
+
+ final Code code = Code.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(codeRaw));
+ String display = displayRaw;
+ if (display == null) {
+ display = code.getFullName();
+ }
+ display = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(display);
+ final String stereotype = arg.getLazzy("STEREOTYPE", 0);
+ final IEntity entity = diagram.getOrCreateLeaf(code, type, usymbol);
+ entity.setDisplay(Display.getWithNewlines(display));
+ entity.setUSymbol(usymbol);
+ if (stereotype != null) {
+ entity.setStereotype(new Stereotype(stereotype, diagram.getSkinParam().getCircledCharacterRadius(), diagram
+ .getSkinParam().getFont(FontParam.CIRCLED_CHARACTER, null, false), diagram.getSkinParam()
+ .getIHtmlColorSet()));
+ }
+
+ final String urlString = arg.get("URL", 0);
+ if (urlString != null) {
+ final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
+ final Url url = urlBuilder.getUrl(urlString);
+ entity.addUrl(url);
+ }
+
+ entity.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0)));
+ return CommandExecutionResult.ok();
+ }
+
+ private char getCharEncoding(final String codeRaw) {
+ return codeRaw != null && codeRaw.length() > 2 ? codeRaw.charAt(0) : 0;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/descdiagram/command/CommandCreateElementMultilines.java b/src/net/sourceforge/plantuml/descdiagram/command/CommandCreateElementMultilines.java
new file mode 100644
index 0000000..d5ac192
--- /dev/null
+++ b/src/net/sourceforge/plantuml/descdiagram/command/CommandCreateElementMultilines.java
@@ -0,0 +1,129 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.descdiagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.CommandMultilines2;
+import net.sourceforge.plantuml.command.MultilinesStrategy;
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.descdiagram.DescriptionDiagram;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.USymbol;
+import net.sourceforge.plantuml.StringUtils;
+
+public class CommandCreateElementMultilines extends CommandMultilines2<DescriptionDiagram> {
+
+ enum Mode {
+ EXTENDS, IMPLEMENTS
+ };
+
+ public CommandCreateElementMultilines() {
+ super(getRegexConcat(), MultilinesStrategy.REMOVE_STARTING_QUOTE);
+ }
+
+ @Override
+ public String getPatternEnd() {
+ return "(?i)^(.*)[%g]$";
+ }
+
+ private static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("TYPE", "(usecase|database)[%s]+"), //
+ new RegexLeaf("CODE", "([\\p{L}0-9_.]+)"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("STEREO", "(\\<\\<.+\\>\\>)?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("COLOR", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("DESC", "as[%s]*[%g](.*)$"));
+ }
+
+ public CommandExecutionResult executeNow(DescriptionDiagram diagram, List<String> lines) {
+ StringUtils.trim(lines, false);
+ final RegexResult line0 = getStartingPattern().matcher(lines.get(0).trim());
+ final String symbol = StringUtils.goUpperCase(line0.get("TYPE", 0));
+ final LeafType type;
+ final USymbol usymbol;
+
+ if (symbol.equalsIgnoreCase("usecase")) {
+ type = LeafType.USECASE;
+ usymbol = null;
+ } else if (symbol.equalsIgnoreCase("database")) {
+ type = LeafType.DESCRIPTION;
+ usymbol = USymbol.DATABASE;
+ } else {
+ throw new IllegalStateException();
+ }
+
+ final Code code = Code.of(line0.get("CODE", 0));
+ Display display = Display.create(lines.subList(1, lines.size() - 1));
+ final String descStart = line0.get("DESC", 0);
+ if (StringUtils.isNotEmpty(descStart)) {
+ display = display.addFirst(descStart);
+ }
+
+ final List<String> lineLast = StringUtils.getSplit(MyPattern.cmpile(getPatternEnd()),
+ lines.get(lines.size() - 1));
+ if (StringUtils.isNotEmpty(lineLast.get(0))) {
+ display = display.add(lineLast.get(0));
+ }
+
+ final String stereotype = line0.get("STEREO", 0);
+
+ final ILeaf result = diagram.createLeaf(code, display, type, usymbol);
+ result.setUSymbol(usymbol);
+ if (stereotype != null) {
+ result.setStereotype(new Stereotype(stereotype, diagram.getSkinParam().getCircledCharacterRadius(), diagram
+ .getSkinParam().getFont(FontParam.CIRCLED_CHARACTER, null, false), diagram.getSkinParam()
+ .getIHtmlColorSet()));
+ }
+
+ result.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(line0.get("COLOR", 0)));
+
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/descdiagram/command/CommandLinkElement.java b/src/net/sourceforge/plantuml/descdiagram/command/CommandLinkElement.java
new file mode 100644
index 0000000..5b045e2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/descdiagram/command/CommandLinkElement.java
@@ -0,0 +1,333 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.descdiagram.command;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.Direction;
+import net.sourceforge.plantuml.classdiagram.command.CommandLinkClass;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.cucadiagram.LinkDecor;
+import net.sourceforge.plantuml.cucadiagram.LinkType;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.descdiagram.DescriptionDiagram;
+import net.sourceforge.plantuml.graphic.USymbol;
+import net.sourceforge.plantuml.StringUtils;
+
+public class CommandLinkElement extends SingleLineCommand2<DescriptionDiagram> {
+
+ public CommandLinkElement() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(
+ new RegexLeaf("^"), //
+ getGroup("ENT1"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("LABEL1", "(?:[%g]([^%g]+)[%g])?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("HEAD2", "(0\\)|<<|[<^*+#0)]|<\\||[%s]+o)?"), //
+ new RegexLeaf("BODY1", "([-=.~]+)"), //
+ new RegexLeaf("ARROW_STYLE1",
+ "(?:\\[((?:#\\w+|dotted|dashed|bold|hidden)(?:,#\\w+|,dotted|,dashed|,bold|,hidden)*)\\])?"),
+ new RegexLeaf("DIRECTION", "(?:(left|right|up|down|le?|ri?|up?|do?)(?=[-=.~0()]))?"), //
+ new RegexLeaf("INSIDE", "(?:(0|\\(0\\)|\\(0|0\\))(?=[-=.~]))?"), //
+ new RegexLeaf("ARROW_STYLE2",
+ "(?:\\[((?:#\\w+|dotted|dashed|bold|hidden)(?:,#\\w+|,dotted|,dashed|,bold|,hidden)*)\\])?"),
+ new RegexLeaf("BODY2", "([-=.~]*)"), //
+ new RegexLeaf("HEAD1", "(\\(0|>>|[>^*+#0(]|\\|>|o[%s]+)?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("LABEL2", "(?:[%g]([^%g]+)[%g])?"), //
+ new RegexLeaf("[%s]*"), //
+ getGroup("ENT2"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("LABEL_LINK", "(?::[%s]*(.+))?$"));
+ }
+
+ private LinkType getLinkType(RegexResult arg) {
+ final String head1 = trimAndLowerCase(arg.get("HEAD1", 0));
+ final String head2 = trimAndLowerCase(arg.get("HEAD2", 0));
+ LinkDecor d1 = LinkDecor.NONE;
+ LinkDecor d2 = LinkDecor.NONE;
+
+ if (head1.equals("(0")) {
+ d1 = LinkDecor.CIRCLE_CONNECT;
+ } else if (head1.equals("#")) {
+ d1 = LinkDecor.SQUARRE;
+ } else if (head1.equals("0")) {
+ d1 = LinkDecor.CIRCLE;
+ } else if (head1.equals("(")) {
+ d1 = LinkDecor.PARENTHESIS;
+ } else if (head1.equals(">")) {
+ d1 = LinkDecor.ARROW;
+ } else if (head1.equals("*")) {
+ d1 = LinkDecor.COMPOSITION;
+ } else if (head1.equals("o")) {
+ d1 = LinkDecor.AGREGATION;
+ } else if (head1.equals("+")) {
+ d1 = LinkDecor.PLUS;
+ } else if (head1.equals(">>")) {
+ d1 = LinkDecor.ARROW_TRIANGLE;
+ } else if (head1.equals("^")) {
+ d1 = LinkDecor.EXTENDS;
+ } else if (head1.equals("|>")) {
+ d1 = LinkDecor.EXTENDS;
+ }
+
+ if (head2.equals("0)")) {
+ d2 = LinkDecor.CIRCLE_CONNECT;
+ } else if (head2.equals("#")) {
+ d2 = LinkDecor.SQUARRE;
+ } else if (head2.equals("0")) {
+ d2 = LinkDecor.CIRCLE;
+ } else if (head2.equals(")")) {
+ d2 = LinkDecor.PARENTHESIS;
+ } else if (head2.equals("<")) {
+ d2 = LinkDecor.ARROW;
+ } else if (head2.equals("*")) {
+ d2 = LinkDecor.COMPOSITION;
+ } else if (head2.equals("o")) {
+ d2 = LinkDecor.AGREGATION;
+ } else if (head2.equals("+")) {
+ d2 = LinkDecor.PLUS;
+ } else if (head2.equals("<<")) {
+ d2 = LinkDecor.ARROW_TRIANGLE;
+ } else if (head2.equals("^")) {
+ d2 = LinkDecor.EXTENDS;
+ } else if (head2.equals("<|")) {
+ d2 = LinkDecor.EXTENDS;
+ }
+
+ LinkType result = new LinkType(d1, d2);
+ final String queue = getQueue(arg);
+ if (queue.contains(".")) {
+ result = result.getDashed();
+ } else if (queue.contains("~")) {
+ result = result.getDotted();
+ } else if (queue.contains("=")) {
+ result = result.getBold();
+ }
+
+ final String middle = arg.get("INSIDE", 0);
+ if ("0".equals(middle)) {
+ result = result.withMiddleCircle();
+ } else if ("0)".equals(middle)) {
+ result = result.withMiddleCircleCircled1();
+ } else if ("(0".equals(middle)) {
+ result = result.withMiddleCircleCircled2();
+ } else if ("(0)".equals(middle)) {
+ result = result.withMiddleCircleCircled();
+ }
+ return result;
+ }
+
+ private static String trimAndLowerCase(String s) {
+ if (s == null) {
+ return "";
+ }
+ return StringUtils.goLowerCase(s.trim());
+ }
+
+ private Direction getDirection(RegexResult arg) {
+ final String dir = arg.get("DIRECTION", 0);
+ if (dir == null) {
+ return StringUtils.getQueueDirection(getQueue(arg));
+ // return Direction.DOWN;
+ }
+ return StringUtils.getQueueDirection(dir);
+ }
+
+ private String getQueue(RegexResult arg) {
+ return arg.get("BODY1", 0) + arg.get("BODY2", 0);
+ }
+
+ private static RegexLeaf getGroup(String name) {
+ return new RegexLeaf(
+ name,
+ "([\\p{L}0-9_.]+|\\(\\)[%s]*[\\p{L}0-9_.]+|\\(\\)[%s]*[%g][^%g]+[%g]|:[^:]+:|(?!\\[\\*\\])\\[[^\\[\\]]+\\]|\\((?!\\*\\))[^)]+\\))(?:[%s]*(\\<\\<.*\\>\\>))?");
+ }
+
+ static class Labels {
+ private String firstLabel;
+ private String secondLabel;
+ private String labelLink;
+
+ Labels(RegexResult arg) {
+ firstLabel = arg.get("LABEL1", 0);
+ secondLabel = arg.get("LABEL2", 0);
+ labelLink = arg.get("LABEL_LINK", 0);
+
+ if (labelLink != null) {
+ if (firstLabel == null && secondLabel == null) {
+ init();
+ }
+ labelLink = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(labelLink);
+ }
+
+ }
+
+ private void init() {
+ final Pattern p1 = MyPattern.cmpile("^[%g]([^%g]+)[%g]([^%g]+)[%g]([^%g]+)[%g]$");
+ final Matcher m1 = p1.matcher(labelLink);
+ if (m1.matches()) {
+ firstLabel = m1.group(1);
+ labelLink = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(m1.group(2).trim()).trim();
+ secondLabel = m1.group(3);
+ return;
+ }
+ final Pattern p2 = MyPattern.cmpile("^[%g]([^%g]+)[%g]([^%g]+)$");
+ final Matcher m2 = p2.matcher(labelLink);
+ if (m2.matches()) {
+ firstLabel = m2.group(1);
+ labelLink = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(m2.group(2).trim()).trim();
+ secondLabel = null;
+ return;
+ }
+ final Pattern p3 = MyPattern.cmpile("^([^%g]+)[%g]([^%g]+)[%g]$");
+ final Matcher m3 = p3.matcher(labelLink);
+ if (m3.matches()) {
+ firstLabel = null;
+ labelLink = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(m3.group(1).trim()).trim();
+ secondLabel = m3.group(2);
+ }
+ }
+
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(DescriptionDiagram diagram, RegexResult arg) {
+ final Code ent1 = Code.of(arg.get("ENT1", 0));
+ final Code ent2 = Code.of(arg.get("ENT2", 0));
+
+ if (diagram.isGroup(ent1) && diagram.isGroup(ent2)) {
+ return executePackageLink(diagram, arg);
+ }
+ // if (diagram.isGroup(ent1) || diagram.isGroup(ent2)) {
+ // return CommandExecutionResult.error("Package can be only linked to other package");
+ // }
+
+ final IEntity cl1 = diagram.isGroup(ent1) ? diagram.getGroup(Code.of(arg.get("ENT1", 0))) : getOrCreateLeaf(
+ diagram, ent1);
+ final IEntity cl2 = diagram.isGroup(ent2) ? diagram.getGroup(Code.of(arg.get("ENT2", 0))) : getOrCreateLeaf(
+ diagram, ent2);
+
+ if (arg.get("ENT1", 1) != null) {
+ cl1.setStereotype(new Stereotype(arg.get("ENT1", 1)));
+ }
+ if (arg.get("ENT2", 1) != null) {
+ cl2.setStereotype(new Stereotype(arg.get("ENT2", 1)));
+ }
+
+ final LinkType linkType = getLinkType(arg);
+ final Direction dir = getDirection(arg);
+ final String queue;
+ if (dir == Direction.LEFT || dir == Direction.RIGHT) {
+ queue = "-";
+ } else {
+ queue = getQueue(arg);
+ }
+
+ final Labels labels = new Labels(arg);
+
+ Link link = new Link(cl1, cl2, linkType, Display.getWithNewlines(labels.labelLink), queue.length(),
+ labels.firstLabel, labels.secondLabel, diagram.getLabeldistance(), diagram.getLabelangle());
+
+ if (dir == Direction.LEFT || dir == Direction.UP) {
+ link = link.getInv();
+ }
+ CommandLinkClass.applyStyle(arg.getLazzy("ARROW_STYLE", 0), link);
+ diagram.addLink(link);
+ return CommandExecutionResult.ok();
+ }
+
+ private ILeaf getOrCreateLeaf(DescriptionDiagram diagram, final Code code2) {
+ final String code = code2.getFullName();
+ if (code.startsWith("()")) {
+ return diagram.getOrCreateLeaf(
+ Code.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(code.substring(2).trim())),
+ LeafType.DESCRIPTION, USymbol.INTERFACE);
+ }
+ final char codeChar = code.length() > 2 ? code.charAt(0) : 0;
+ if (codeChar == '(') {
+ return diagram.getOrCreateLeaf(code2.eventuallyRemoveStartingAndEndingDoubleQuote("\"([:"),
+ LeafType.USECASE, USymbol.USECASE);
+ } else if (codeChar == ':') {
+ return diagram.getOrCreateLeaf(code2.eventuallyRemoveStartingAndEndingDoubleQuote("\"([:"),
+ LeafType.DESCRIPTION, USymbol.ACTOR);
+ } else if (codeChar == '[') {
+ final USymbol sym = diagram.getSkinParam().useUml2ForComponent() ? USymbol.COMPONENT2 : USymbol.COMPONENT1;
+ return diagram.getOrCreateLeaf(code2.eventuallyRemoveStartingAndEndingDoubleQuote("\"([:"),
+ LeafType.DESCRIPTION, sym);
+ }
+
+ return diagram.getOrCreateLeaf(code2, null, null);
+ }
+
+ private CommandExecutionResult executePackageLink(DescriptionDiagram diagram, RegexResult arg) {
+ final IEntity cl1 = diagram.getGroup(Code.of(arg.get("ENT1", 0)));
+ final IEntity cl2 = diagram.getGroup(Code.of(arg.get("ENT2", 0)));
+
+ final LinkType linkType = getLinkType(arg);
+ final Direction dir = getDirection(arg);
+ final String queue;
+ if (dir == Direction.LEFT || dir == Direction.RIGHT) {
+ queue = "-";
+ } else {
+ queue = getQueue(arg);
+ }
+
+ Link link = new Link(cl1, cl2, linkType, Display.getWithNewlines(arg.get("LABEL_LINK", 0)), queue.length());
+ if (dir == Direction.LEFT || dir == Direction.UP) {
+ link = link.getInv();
+ }
+ CommandLinkClass.applyStyle(arg.getLazzy("ARROW_STYLE", 0), link);
+ diagram.addLink(link);
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/descdiagram/command/CommandNamespaceSeparator.java b/src/net/sourceforge/plantuml/descdiagram/command/CommandNamespaceSeparator.java
new file mode 100644
index 0000000..c033296
--- /dev/null
+++ b/src/net/sourceforge/plantuml/descdiagram/command/CommandNamespaceSeparator.java
@@ -0,0 +1,59 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.descdiagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.descdiagram.DescriptionDiagram;
+
+public class CommandNamespaceSeparator extends SingleLineCommand<DescriptionDiagram> {
+
+ public CommandNamespaceSeparator() {
+ super("(?i)^set[%s]namespaceseparator[%s](\\S+)$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(DescriptionDiagram diagram, List<String> arg) {
+ final String s = arg.get(0);
+ if ("none".equalsIgnoreCase(s)) {
+ diagram.setNamespaceSeparator(null);
+ } else {
+ diagram.setNamespaceSeparator(s);
+ }
+ return CommandExecutionResult.ok();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/descdiagram/command/CommandNewpage.java b/src/net/sourceforge/plantuml/descdiagram/command/CommandNewpage.java
new file mode 100644
index 0000000..21198ac
--- /dev/null
+++ b/src/net/sourceforge/plantuml/descdiagram/command/CommandNewpage.java
@@ -0,0 +1,67 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.descdiagram.command;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.NewpagedDiagram;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.UmlDiagramFactory;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+
+public class CommandNewpage extends SingleLineCommand2<AbstractPSystem> {
+
+ private final UmlDiagramFactory factory;
+
+ public CommandNewpage(UmlDiagramFactory factory) {
+ super(getRegexConcat());
+ this.factory = factory;
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("newpage"), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(AbstractPSystem diagram, RegexResult arg) {
+ // NewpagedDiagram result = NewpagedDiagram.newpage(diagram, factory.createEmptyDiagram());
+ NewpagedDiagram result = new NewpagedDiagram(diagram, factory.createEmptyDiagram());
+ return CommandExecutionResult.newDiagram(result);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/descdiagram/command/CommandPackageWithUSymbol.java b/src/net/sourceforge/plantuml/descdiagram/command/CommandPackageWithUSymbol.java
new file mode 100644
index 0000000..dfbaf85
--- /dev/null
+++ b/src/net/sourceforge/plantuml/descdiagram/command/CommandPackageWithUSymbol.java
@@ -0,0 +1,108 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.descdiagram.command;
+
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.GroupType;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.IGroup;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.USymbol;
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.utils.UniqueSequence;
+
+public class CommandPackageWithUSymbol extends SingleLineCommand2<AbstractEntityDiagram> {
+
+ public CommandPackageWithUSymbol() {
+ super(getRegexConcat());
+ }
+
+ private static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("SYMBOL", "(package|rectangle|node|artifact|folder|frame|cloud|database|storage|component|card)"), //
+ new RegexLeaf("[%s]+"), //
+ new RegexLeaf("NAME", "([%g][^%g]+[%g]|[^#%s{}]*)"), //
+ new RegexLeaf("AS", "(?:[%s]+as[%s]+([\\p{L}0-9_.]+))?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("COLOR", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), //
+ new RegexLeaf("[%s]*\\{$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(AbstractEntityDiagram diagram, RegexResult arg) {
+ final Code code;
+ final String display;
+ final String name = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("NAME", 0));
+ if (arg.get("AS", 0) == null) {
+ if (name.length() == 0) {
+ code = UniqueSequence.getCode("##");
+ display = null;
+ } else {
+ code = Code.of(name);
+ display = code.getFullName();
+ }
+ } else {
+ display = name;
+ code = Code.of(arg.get("AS", 0));
+ }
+ final IGroup currentPackage = diagram.getCurrentGroup();
+ final IEntity p = diagram.getOrCreateGroup(code, Display.getWithNewlines(display),
+ GroupType.PACKAGE, currentPackage);
+ p.setUSymbol(USymbol.getFromString(arg.get("SYMBOL", 0)));
+ final String stereotype = arg.get("STEREOTYPE", 0);
+ if (stereotype != null) {
+ p.setStereotype(new Stereotype(stereotype, false));
+ }
+ final String color = arg.get("COLOR", 0);
+ if (color != null) {
+ p.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(color));
+ }
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/directdot/PSystemDot.java b/src/net/sourceforge/plantuml/directdot/PSystemDot.java
new file mode 100644
index 0000000..2ca1332
--- /dev/null
+++ b/src/net/sourceforge/plantuml/directdot/PSystemDot.java
@@ -0,0 +1,90 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.directdot;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Arrays;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.CounterOutputStream;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.api.ImageDataSimple;
+import net.sourceforge.plantuml.core.DiagramDescription;
+import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.cucadiagram.dot.Graphviz;
+import net.sourceforge.plantuml.cucadiagram.dot.GraphvizUtils;
+import net.sourceforge.plantuml.cucadiagram.dot.ProcessState;
+import net.sourceforge.plantuml.graphic.GraphicStrings;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+import net.sourceforge.plantuml.ugraphic.UGraphicUtils;
+
+public class PSystemDot extends AbstractPSystem {
+
+ private final String data;
+
+ public PSystemDot(String data) {
+ this.data = data;
+ }
+
+ public DiagramDescription getDescription() {
+ return new DiagramDescriptionImpl("(Dot)", getClass());
+ }
+
+ public ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormat) throws IOException {
+ final Graphviz graphviz = GraphvizUtils
+ .create(data, StringUtils.goLowerCase(fileFormat.getFileFormat().name()));
+ if (graphviz.illegalDotExe()) {
+ final TextBlock result = GraphicStrings.createDefault(Arrays.asList("There is an issue with your Dot/Graphviz installation"), false);
+ UGraphicUtils.writeImage(os, null, fileFormat, new ColorMapperIdentity(), HtmlColorUtils.WHITE, result);
+ return new ImageDataSimple();
+ }
+ final CounterOutputStream counter = new CounterOutputStream(os);
+ final ProcessState state = graphviz.createFile3(counter);
+ if (state.differs(ProcessState.TERMINATED_OK())) {
+ throw new IllegalStateException("Timeout1 " + state);
+ }
+ if (counter.getLength() == 0) {
+ final TextBlock result = GraphicStrings.createDefault(Arrays.asList("Graphivz has crashed"), false);
+ UGraphicUtils.writeImage(os, null, fileFormat, new ColorMapperIdentity(), HtmlColorUtils.WHITE, result);
+ }
+
+ return new ImageDataSimple();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/directdot/PSystemDotFactory.java b/src/net/sourceforge/plantuml/directdot/PSystemDotFactory.java
new file mode 100644
index 0000000..dcc9fef
--- /dev/null
+++ b/src/net/sourceforge/plantuml/directdot/PSystemDotFactory.java
@@ -0,0 +1,68 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.directdot;
+
+import net.sourceforge.plantuml.command.PSystemBasicFactory;
+import net.sourceforge.plantuml.core.DiagramType;
+
+public class PSystemDotFactory extends PSystemBasicFactory<PSystemDot> {
+
+ private StringBuilder data;
+
+ public PSystemDotFactory(DiagramType diagramType) {
+ super(diagramType);
+ }
+
+ @Override
+ public PSystemDot init(String startLine) {
+ data = null;
+ return null;
+ }
+
+ @Override
+ public PSystemDot executeLine(PSystemDot system, String line) {
+ if (system == null && line.matches("(di)?graph\\s+\\w+\\s+\\{")) {
+ data = new StringBuilder(line);
+ data.append("\n");
+ return new PSystemDot(data.toString());
+ }
+ if (data == null || system == null) {
+ return null;
+ }
+ data.append(line);
+ data.append("\n");
+ return new PSystemDot(data.toString());
+ }
+}
diff --git a/src/net/sourceforge/plantuml/donors/PSystemDonors.java b/src/net/sourceforge/plantuml/donors/PSystemDonors.java
new file mode 100644
index 0000000..fdcc790
--- /dev/null
+++ b/src/net/sourceforge/plantuml/donors/PSystemDonors.java
@@ -0,0 +1,121 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.donors;
+
+import java.awt.Font;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.code.Transcoder;
+import net.sourceforge.plantuml.code.TranscoderImpl;
+import net.sourceforge.plantuml.core.DiagramDescription;
+import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.graphic.GraphicPosition;
+import net.sourceforge.plantuml.graphic.GraphicStrings;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+import net.sourceforge.plantuml.ugraphic.ImageBuilder;
+import net.sourceforge.plantuml.ugraphic.UAntiAliasing;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.version.PSystemVersion;
+
+public class PSystemDonors extends AbstractPSystem {
+
+ public static final String DONORS = "UDfTaikosZ0CXlTw2gypquT8IOTEu5pcqEcYEv7e41sCH6s7DddwYhR11gsiqUtx9TU--cyKu9KI1LTBKc7iu1jLsVG4MyrkY50lfRY7TSWXcc17Uuo9KTop3WArz1hSMYdDT7s-lrl6aeu2Mom6IOA65uSzrBcrNc0tPeG9rbpTcoYq2-KOOPVeF92ubUhPz3NB78gmEJsKQe2LUXRtfcCaQCU7UFMX9cHnpWnF1JMUIjT6rPv-e_IspjN0rlM0OJAbRpVPSe3daZxDyEBvOWKDTqSZlqLOu4kyjPO2eg8BDFE9KvZS5WVj4ThhqdyCQEsBl8fyFfVPSR8r2IRBCpxZQl_1q_5EbVHtxjzAjaRUobv2uXc-vd2lyCJTGDvzHlPJgS3F9KoCZsWjeNngiVivKdJDk0zef_LP_dVzIDGDRXCmOaOwaFtOue2_hX_DKjn6Bmn_0C5QlDy0";
+
+ // public ImageData exportDiagram(OutputStream os, int num, FileFormatOption
+ // fileFormat) throws IOException {
+ // return getGraphicStrings().exportDiagram(os, fileFormat);
+ // }
+
+ public ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormat) throws IOException {
+ final GraphicStrings result = getGraphicStrings();
+ final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(),
+ getMetadata(), null, 0, 0, null, false);
+ imageBuilder.addUDrawable(result);
+ return imageBuilder.writeImageTOBEMOVED(fileFormat.getFileFormat(), os);
+ }
+
+ private GraphicStrings getGraphicStrings() throws IOException {
+ final List<String> lines = new ArrayList<String>();
+ lines.add("<b>Special thanks to our sponsors and donors !");
+ lines.add(" ");
+ int i = 0;
+ final List<String> donors = getDonors();
+ final int maxLine = (donors.size() + 1) / 2;
+ for (String d : donors) {
+ lines.add(d);
+ i++;
+ if (i == maxLine) {
+ lines.add(" ");
+ lines.add(" ");
+ i = 0;
+ }
+ }
+ lines.add(" ");
+ final UFont font = new UFont("SansSerif", Font.PLAIN, 12);
+ final GraphicStrings graphicStrings = new GraphicStrings(lines, font, HtmlColorUtils.BLACK,
+ HtmlColorUtils.WHITE, UAntiAliasing.ANTI_ALIASING_ON, PSystemVersion.getPlantumlImage(),
+ GraphicPosition.BACKGROUND_CORNER_BOTTOM_RIGHT);
+ graphicStrings.setMaxLine(maxLine + 2);
+ return graphicStrings;
+ }
+
+ private List<String> getDonors() throws IOException {
+ final List<String> lines = new ArrayList<String>();
+ final Transcoder t = new TranscoderImpl();
+ final String s = t.decode(DONORS).replace('*', '.');
+ final StringTokenizer st = new StringTokenizer(s, "\n");
+ while (st.hasMoreTokens()) {
+ lines.add(st.nextToken());
+ }
+ return lines;
+ }
+
+ public DiagramDescription getDescription() {
+ return new DiagramDescriptionImpl("(Donors)", getClass());
+ }
+
+ public static PSystemDonors create() {
+ return new PSystemDonors();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/donors/PSystemDonorsFactory.java b/src/net/sourceforge/plantuml/donors/PSystemDonorsFactory.java
new file mode 100644
index 0000000..360d5bb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/donors/PSystemDonorsFactory.java
@@ -0,0 +1,50 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.donors;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.command.PSystemSingleLineFactory;
+
+public class PSystemDonorsFactory extends PSystemSingleLineFactory {
+
+ @Override
+ protected AbstractPSystem executeLine(String line) {
+ if (line.matches("(?i)^(donors)\\s*$")) {
+ return PSystemDonors.create();
+ }
+ return null;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/eggs/EggUtils.java b/src/net/sourceforge/plantuml/eggs/EggUtils.java
new file mode 100644
index 0000000..eb681fc
--- /dev/null
+++ b/src/net/sourceforge/plantuml/eggs/EggUtils.java
@@ -0,0 +1,101 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.eggs;
+
+import java.math.BigInteger;
+
+import net.sourceforge.plantuml.StringUtils;
+
+public class EggUtils {
+
+ public static String fromByteArrays(byte data[]) {
+ final StringBuilder sb = new StringBuilder();
+ for (byte b : data) {
+ final String hex = Integer.toHexString(b & 0xFF);
+ if (hex.length() == 1) {
+ sb.append('0');
+ }
+ sb.append(hex);
+ }
+ return sb.toString();
+ }
+
+ public static byte[] toByteArrays(String s) {
+ final byte[] result = new byte[s.length() / 2];
+ for (int i = 0; i < result.length; i++) {
+ result[i] = (byte) Integer.parseInt(s.substring(i * 2, i * 2 + 2), 16);
+ }
+ return result;
+ }
+
+ public static BigInteger fromSecretSentence(String s) {
+ BigInteger result = BigInteger.ZERO;
+ final BigInteger twentySix = BigInteger.valueOf(26);
+ s = s.replace('\u00E9', 'e');
+ s = s.replace('\u00EA', 'e');
+ for (char c : s.toCharArray()) {
+ final int num = convertChar(c);
+ if (num != -1) {
+ result = result.multiply(twentySix);
+ result = result.add(BigInteger.valueOf(num));
+
+ }
+ }
+ return result;
+
+ }
+
+ private static int convertChar(char c) {
+ c = StringUtils.goLowerCase(c);
+ if (c >= 'a' && c <= 'z') {
+ return c - 'a';
+ }
+ return -1;
+ }
+
+ public static byte[] xor(byte data[], byte key[]) {
+ final byte[] result = new byte[data.length];
+ int pos = 0;
+ for (int i = 0; i < result.length; i++) {
+ result[i] = (byte) (data[i] ^ key[pos++]);
+ if (pos == key.length) {
+ pos = 0;
+ }
+
+ }
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/eggs/GraphicsPath.java b/src/net/sourceforge/plantuml/eggs/GraphicsPath.java
new file mode 100644
index 0000000..371de2c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/eggs/GraphicsPath.java
@@ -0,0 +1,83 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.eggs;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import net.sourceforge.plantuml.EmptyImageBuilder;
+import net.sourceforge.plantuml.api.ImageDataSimple;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.png.PngIO;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UMotif;
+import net.sourceforge.plantuml.ugraphic.g2d.UGraphicG2d;
+
+public class GraphicsPath {
+
+ private final String path;
+ private final ColorMapper colorMapper;
+
+ public GraphicsPath(ColorMapper colorMapper, String path) {
+ this.path = path;
+ this.colorMapper = colorMapper;
+ }
+
+ public ImageData writeImage(OutputStream os) throws IOException {
+ final BufferedImage im = createImage();
+ PngIO.write(im, os, 96);
+ return new ImageDataSimple(im.getWidth(), im.getHeight());
+ }
+
+ private BufferedImage createImage() {
+ final EmptyImageBuilder builder = new EmptyImageBuilder(50, 50, Color.WHITE);
+ final BufferedImage im = builder.getBufferedImage();
+ final Graphics2D g2d = builder.getGraphics2D();
+
+ final UGraphicG2d ug = new UGraphicG2d(colorMapper, g2d, 1.0);
+ ug.setBufferedImage(im);
+ final UMotif motif = new UMotif(path);
+ motif.drawHorizontal(ug.apply(new UChangeColor(HtmlColorUtils.BLACK)), 20, 20, 1);
+
+ g2d.dispose();
+ return im;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/eggs/PSystemAppleTwo.java b/src/net/sourceforge/plantuml/eggs/PSystemAppleTwo.java
new file mode 100644
index 0000000..f9fe288
--- /dev/null
+++ b/src/net/sourceforge/plantuml/eggs/PSystemAppleTwo.java
@@ -0,0 +1,732 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.eggs;
+
+import java.awt.Font;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.imageio.ImageIO;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.core.DiagramDescription;
+import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.graphic.GraphicPosition;
+import net.sourceforge.plantuml.graphic.GraphicStrings;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+import net.sourceforge.plantuml.ugraphic.ImageBuilder;
+import net.sourceforge.plantuml.ugraphic.UAntiAliasing;
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public class PSystemAppleTwo extends AbstractPSystem {
+
+ private final List<String> strings = new ArrayList<String>();
+ private final BufferedImage image;
+
+ public PSystemAppleTwo() throws IOException {
+ strings.add(" <b><size:16>Apple //e for ever!");
+ strings.add(" ");
+
+ final InputStream is = new ByteArrayInputStream(imm);
+ image = ImageIO.read(is);
+ is.close();
+ }
+
+ public ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormat) throws IOException {
+ final GraphicStrings result = getGraphicStrings();
+ final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(),
+ getMetadata(), null, 0, 0, null, false);
+ imageBuilder.addUDrawable(result);
+ return imageBuilder.writeImageTOBEMOVED(fileFormat.getFileFormat(), os);
+ }
+
+ 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,
+ UAntiAliasing.ANTI_ALIASING_ON, image, GraphicPosition.BOTTOM);
+ result.setMinWidth(200);
+ return result;
+ }
+
+ public DiagramDescription getDescription() {
+ return new DiagramDescriptionImpl("(Apple //e)", getClass());
+ }
+
+ private static final byte imm[] = new byte[] { (byte) 255, (byte) 216, (byte) 255, (byte) 224, (byte) 0, (byte) 16,
+ (byte) 74, (byte) 70, (byte) 73, (byte) 70, (byte) 0, (byte) 1, (byte) 1, (byte) 1, (byte) 0, (byte) 96,
+ (byte) 0, (byte) 96, (byte) 0, (byte) 0, (byte) 255, (byte) 219, (byte) 0, (byte) 67, (byte) 0, (byte) 10,
+ (byte) 7, (byte) 7, (byte) 8, (byte) 7, (byte) 6, (byte) 10, (byte) 8, (byte) 8, (byte) 8, (byte) 11,
+ (byte) 10, (byte) 10, (byte) 11, (byte) 14, (byte) 24, (byte) 16, (byte) 14, (byte) 13, (byte) 13,
+ (byte) 14, (byte) 29, (byte) 21, (byte) 22, (byte) 17, (byte) 24, (byte) 35, (byte) 31, (byte) 37,
+ (byte) 36, (byte) 34, (byte) 31, (byte) 34, (byte) 33, (byte) 38, (byte) 43, (byte) 55, (byte) 47,
+ (byte) 38, (byte) 41, (byte) 52, (byte) 41, (byte) 33, (byte) 34, (byte) 48, (byte) 65, (byte) 49,
+ (byte) 52, (byte) 57, (byte) 59, (byte) 62, (byte) 62, (byte) 62, (byte) 37, (byte) 46, (byte) 68,
+ (byte) 73, (byte) 67, (byte) 60, (byte) 72, (byte) 55, (byte) 61, (byte) 62, (byte) 59, (byte) 255,
+ (byte) 219, (byte) 0, (byte) 67, (byte) 1, (byte) 10, (byte) 11, (byte) 11, (byte) 14, (byte) 13,
+ (byte) 14, (byte) 28, (byte) 16, (byte) 16, (byte) 28, (byte) 59, (byte) 40, (byte) 34, (byte) 40,
+ (byte) 59, (byte) 59, (byte) 59, (byte) 59, (byte) 59, (byte) 59, (byte) 59, (byte) 59, (byte) 59,
+ (byte) 59, (byte) 59, (byte) 59, (byte) 59, (byte) 59, (byte) 59, (byte) 59, (byte) 59, (byte) 59,
+ (byte) 59, (byte) 59, (byte) 59, (byte) 59, (byte) 59, (byte) 59, (byte) 59, (byte) 59, (byte) 59,
+ (byte) 59, (byte) 59, (byte) 59, (byte) 59, (byte) 59, (byte) 59, (byte) 59, (byte) 59, (byte) 59,
+ (byte) 59, (byte) 59, (byte) 59, (byte) 59, (byte) 59, (byte) 59, (byte) 59, (byte) 59, (byte) 59,
+ (byte) 59, (byte) 59, (byte) 59, (byte) 59, (byte) 59, (byte) 255, (byte) 192, (byte) 0, (byte) 17,
+ (byte) 8, (byte) 0, (byte) 136, (byte) 0, (byte) 200, (byte) 3, (byte) 1, (byte) 34, (byte) 0, (byte) 2,
+ (byte) 17, (byte) 1, (byte) 3, (byte) 17, (byte) 1, (byte) 255, (byte) 196, (byte) 0, (byte) 31, (byte) 0,
+ (byte) 0, (byte) 1, (byte) 5, (byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 0,
+ (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 1, (byte) 2, (byte) 3,
+ (byte) 4, (byte) 5, (byte) 6, (byte) 7, (byte) 8, (byte) 9, (byte) 10, (byte) 11, (byte) 255, (byte) 196,
+ (byte) 0, (byte) 181, (byte) 16, (byte) 0, (byte) 2, (byte) 1, (byte) 3, (byte) 3, (byte) 2, (byte) 4,
+ (byte) 3, (byte) 5, (byte) 5, (byte) 4, (byte) 4, (byte) 0, (byte) 0, (byte) 1, (byte) 125, (byte) 1,
+ (byte) 2, (byte) 3, (byte) 0, (byte) 4, (byte) 17, (byte) 5, (byte) 18, (byte) 33, (byte) 49, (byte) 65,
+ (byte) 6, (byte) 19, (byte) 81, (byte) 97, (byte) 7, (byte) 34, (byte) 113, (byte) 20, (byte) 50,
+ (byte) 129, (byte) 145, (byte) 161, (byte) 8, (byte) 35, (byte) 66, (byte) 177, (byte) 193, (byte) 21,
+ (byte) 82, (byte) 209, (byte) 240, (byte) 36, (byte) 51, (byte) 98, (byte) 114, (byte) 130, (byte) 9,
+ (byte) 10, (byte) 22, (byte) 23, (byte) 24, (byte) 25, (byte) 26, (byte) 37, (byte) 38, (byte) 39,
+ (byte) 40, (byte) 41, (byte) 42, (byte) 52, (byte) 53, (byte) 54, (byte) 55, (byte) 56, (byte) 57,
+ (byte) 58, (byte) 67, (byte) 68, (byte) 69, (byte) 70, (byte) 71, (byte) 72, (byte) 73, (byte) 74,
+ (byte) 83, (byte) 84, (byte) 85, (byte) 86, (byte) 87, (byte) 88, (byte) 89, (byte) 90, (byte) 99,
+ (byte) 100, (byte) 101, (byte) 102, (byte) 103, (byte) 104, (byte) 105, (byte) 106, (byte) 115, (byte) 116,
+ (byte) 117, (byte) 118, (byte) 119, (byte) 120, (byte) 121, (byte) 122, (byte) 131, (byte) 132, (byte) 133,
+ (byte) 134, (byte) 135, (byte) 136, (byte) 137, (byte) 138, (byte) 146, (byte) 147, (byte) 148, (byte) 149,
+ (byte) 150, (byte) 151, (byte) 152, (byte) 153, (byte) 154, (byte) 162, (byte) 163, (byte) 164, (byte) 165,
+ (byte) 166, (byte) 167, (byte) 168, (byte) 169, (byte) 170, (byte) 178, (byte) 179, (byte) 180, (byte) 181,
+ (byte) 182, (byte) 183, (byte) 184, (byte) 185, (byte) 186, (byte) 194, (byte) 195, (byte) 196, (byte) 197,
+ (byte) 198, (byte) 199, (byte) 200, (byte) 201, (byte) 202, (byte) 210, (byte) 211, (byte) 212, (byte) 213,
+ (byte) 214, (byte) 215, (byte) 216, (byte) 217, (byte) 218, (byte) 225, (byte) 226, (byte) 227, (byte) 228,
+ (byte) 229, (byte) 230, (byte) 231, (byte) 232, (byte) 233, (byte) 234, (byte) 241, (byte) 242, (byte) 243,
+ (byte) 244, (byte) 245, (byte) 246, (byte) 247, (byte) 248, (byte) 249, (byte) 250, (byte) 255, (byte) 196,
+ (byte) 0, (byte) 31, (byte) 1, (byte) 0, (byte) 3, (byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 1,
+ (byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0,
+ (byte) 1, (byte) 2, (byte) 3, (byte) 4, (byte) 5, (byte) 6, (byte) 7, (byte) 8, (byte) 9, (byte) 10,
+ (byte) 11, (byte) 255, (byte) 196, (byte) 0, (byte) 181, (byte) 17, (byte) 0, (byte) 2, (byte) 1, (byte) 2,
+ (byte) 4, (byte) 4, (byte) 3, (byte) 4, (byte) 7, (byte) 5, (byte) 4, (byte) 4, (byte) 0, (byte) 1,
+ (byte) 2, (byte) 119, (byte) 0, (byte) 1, (byte) 2, (byte) 3, (byte) 17, (byte) 4, (byte) 5, (byte) 33,
+ (byte) 49, (byte) 6, (byte) 18, (byte) 65, (byte) 81, (byte) 7, (byte) 97, (byte) 113, (byte) 19,
+ (byte) 34, (byte) 50, (byte) 129, (byte) 8, (byte) 20, (byte) 66, (byte) 145, (byte) 161, (byte) 177,
+ (byte) 193, (byte) 9, (byte) 35, (byte) 51, (byte) 82, (byte) 240, (byte) 21, (byte) 98, (byte) 114,
+ (byte) 209, (byte) 10, (byte) 22, (byte) 36, (byte) 52, (byte) 225, (byte) 37, (byte) 241, (byte) 23,
+ (byte) 24, (byte) 25, (byte) 26, (byte) 38, (byte) 39, (byte) 40, (byte) 41, (byte) 42, (byte) 53,
+ (byte) 54, (byte) 55, (byte) 56, (byte) 57, (byte) 58, (byte) 67, (byte) 68, (byte) 69, (byte) 70,
+ (byte) 71, (byte) 72, (byte) 73, (byte) 74, (byte) 83, (byte) 84, (byte) 85, (byte) 86, (byte) 87,
+ (byte) 88, (byte) 89, (byte) 90, (byte) 99, (byte) 100, (byte) 101, (byte) 102, (byte) 103, (byte) 104,
+ (byte) 105, (byte) 106, (byte) 115, (byte) 116, (byte) 117, (byte) 118, (byte) 119, (byte) 120, (byte) 121,
+ (byte) 122, (byte) 130, (byte) 131, (byte) 132, (byte) 133, (byte) 134, (byte) 135, (byte) 136, (byte) 137,
+ (byte) 138, (byte) 146, (byte) 147, (byte) 148, (byte) 149, (byte) 150, (byte) 151, (byte) 152, (byte) 153,
+ (byte) 154, (byte) 162, (byte) 163, (byte) 164, (byte) 165, (byte) 166, (byte) 167, (byte) 168, (byte) 169,
+ (byte) 170, (byte) 178, (byte) 179, (byte) 180, (byte) 181, (byte) 182, (byte) 183, (byte) 184, (byte) 185,
+ (byte) 186, (byte) 194, (byte) 195, (byte) 196, (byte) 197, (byte) 198, (byte) 199, (byte) 200, (byte) 201,
+ (byte) 202, (byte) 210, (byte) 211, (byte) 212, (byte) 213, (byte) 214, (byte) 215, (byte) 216, (byte) 217,
+ (byte) 218, (byte) 226, (byte) 227, (byte) 228, (byte) 229, (byte) 230, (byte) 231, (byte) 232, (byte) 233,
+ (byte) 234, (byte) 242, (byte) 243, (byte) 244, (byte) 245, (byte) 246, (byte) 247, (byte) 248, (byte) 249,
+ (byte) 250, (byte) 255, (byte) 218, (byte) 0, (byte) 12, (byte) 3, (byte) 1, (byte) 0, (byte) 2, (byte) 17,
+ (byte) 3, (byte) 17, (byte) 0, (byte) 63, (byte) 0, (byte) 246, (byte) 106, (byte) 40, (byte) 162,
+ (byte) 128, (byte) 10, (byte) 40, (byte) 162, (byte) 128, (byte) 43, (byte) 221, (byte) 92, (byte) 253,
+ (byte) 153, (byte) 3, (byte) 121, (byte) 79, (byte) 41, (byte) 39, (byte) 133, (byte) 66, (byte) 185,
+ (byte) 253, (byte) 72, (byte) 21, (byte) 145, (byte) 115, (byte) 173, (byte) 106, (byte) 157, (byte) 45,
+ (byte) 180, (byte) 146, (byte) 191, (byte) 237, (byte) 73, (byte) 42, (byte) 31, (byte) 208, (byte) 55,
+ (byte) 245, (byte) 173, (byte) 59, (byte) 225, (byte) 157, (byte) 159, (byte) 83, (byte) 92, (byte) 61,
+ (byte) 182, (byte) 181, (byte) 169, (byte) 181, (byte) 149, (byte) 188, (byte) 243, (byte) 223, (byte) 91,
+ (byte) 71, (byte) 44, (byte) 209, (byte) 171, (byte) 149, (byte) 54, (byte) 228, (byte) 129, (byte) 144,
+ (byte) 9, (byte) 254, (byte) 44, (byte) 247, (byte) 245, (byte) 172, (byte) 165, (byte) 39, (byte) 114,
+ (byte) 210, (byte) 69, (byte) 251, (byte) 155, (byte) 239, (byte) 19, (byte) 78, (byte) 113, (byte) 135,
+ (byte) 133, (byte) 79, (byte) 240, (byte) 196, (byte) 168, (byte) 63, (byte) 92, (byte) 147, (byte) 250,
+ (byte) 213, (byte) 80, (byte) 254, (byte) 34, (byte) 67, (byte) 129, (byte) 53, (byte) 222, (byte) 115,
+ (byte) 221, (byte) 203, (byte) 127, (byte) 141, (byte) 52, (byte) 107, (byte) 183, (byte) 185, (byte) 192,
+ (byte) 213, (byte) 180, (byte) 188, (byte) 142, (byte) 205, (byte) 106, (byte) 223, (byte) 252, (byte) 120,
+ (byte) 84, (byte) 131, (byte) 90, (byte) 212, (byte) 63, (byte) 232, (byte) 41, (byte) 164, (byte) 127,
+ (byte) 224, (byte) 51, (byte) 127, (byte) 241, (byte) 250, (byte) 139, (byte) 190, (byte) 229, (byte) 104,
+ (byte) 39, (byte) 159, (byte) 226, (byte) 64, (byte) 120, (byte) 158, (byte) 232, (byte) 255, (byte) 0,
+ (byte) 192, (byte) 88, (byte) 255, (byte) 0, (byte) 74, (byte) 67, (byte) 121, (byte) 226, (byte) 96,
+ (byte) 121, (byte) 158, (byte) 243, (byte) 131, (byte) 198, (byte) 32, (byte) 110, (byte) 127, (byte) 241,
+ (byte) 202, (byte) 144, (byte) 107, (byte) 119, (byte) 223, (byte) 244, (byte) 16, (byte) 210, (byte) 88,
+ (byte) 250, (byte) 8, (byte) 136, (byte) 255, (byte) 0, (byte) 218, (byte) 198, (byte) 158, (byte) 53,
+ (byte) 203, (byte) 220, (byte) 224, (byte) 73, (byte) 167, (byte) 183, (byte) 209, (byte) 138, (byte) 255,
+ (byte) 0, (byte) 83, (byte) 74, (byte) 236, (byte) 44, (byte) 66, (byte) 53, (byte) 63, (byte) 18,
+ (byte) 131, (byte) 180, (byte) 205, (byte) 121, (byte) 248, (byte) 218, (byte) 31, (byte) 254, (byte) 34,
+ (byte) 156, (byte) 53, (byte) 143, (byte) 16, (byte) 142, (byte) 179, (byte) 207, (byte) 199, (byte) 247,
+ (byte) 173, (byte) 64, (byte) 254, (byte) 105, (byte) 86, (byte) 6, (byte) 181, (byte) 169, (byte) 127,
+ (byte) 207, (byte) 173, (byte) 131, (byte) 255, (byte) 0, (byte) 219, (byte) 211, (byte) 47, (byte) 254,
+ (byte) 211, (byte) 52, (byte) 241, (byte) 172, (byte) 234, (byte) 196, (byte) 241, (byte) 166, (byte) 88,
+ (byte) 48, (byte) 246, (byte) 191, (byte) 147, (byte) 255, (byte) 0, (byte) 140, (byte) 83, (byte) 187,
+ (byte) 2, (byte) 161, (byte) 215, (byte) 181, (byte) 213, (byte) 25, (byte) 55, (byte) 79, (byte) 248,
+ (byte) 194, (byte) 131, (byte) 255, (byte) 0, (byte) 101, (byte) 163, (byte) 254, (byte) 18, (byte) 61,
+ (byte) 100, (byte) 114, (byte) 110, (byte) 112, (byte) 61, (byte) 227, (byte) 65, (byte) 253, (byte) 42,
+ (byte) 231, (byte) 246, (byte) 206, (byte) 168, (byte) 57, (byte) 109, (byte) 46, (byte) 215, (byte) 254,
+ (byte) 3, (byte) 122, (byte) 231, (byte) 255, (byte) 0, (byte) 104, (byte) 138, (byte) 81, (byte) 175,
+ (byte) 95, (byte) 15, (byte) 189, (byte) 166, (byte) 1, (byte) 254, (byte) 237, (byte) 206, (byte) 127,
+ (byte) 154, (byte) 138, (byte) 46, (byte) 251, (byte) 133, (byte) 151, (byte) 98, (byte) 160, (byte) 241,
+ (byte) 54, (byte) 172, (byte) 188, (byte) 153, (byte) 227, (byte) 56, (byte) 245, (byte) 9, (byte) 82,
+ (byte) 47, (byte) 136, (byte) 181, (byte) 210, (byte) 55, (byte) 36, (byte) 45, (byte) 34, (byte) 255,
+ (byte) 0, (byte) 121, (byte) 45, (byte) 139, (byte) 143, (byte) 204, (byte) 86, (byte) 134, (byte) 153,
+ (byte) 172, (byte) 46, (byte) 177, (byte) 101, (byte) 117, (byte) 34, (byte) 197, (byte) 36, (byte) 45,
+ (byte) 4, (byte) 175, (byte) 4, (byte) 138, (byte) 236, (byte) 15, (byte) 204, (byte) 160, (byte) 19,
+ (byte) 211, (byte) 168, (byte) 230, (byte) 132, (byte) 211, (byte) 165, (byte) 142, (byte) 118, (byte) 104,
+ (byte) 239, (byte) 25, (byte) 119, (byte) 73, (byte) 189, (byte) 129, (byte) 81, (byte) 202, (byte) 231,
+ (byte) 59, (byte) 126, (byte) 152, (byte) 226, (byte) 142, (byte) 103, (byte) 220, (byte) 44, (byte) 140,
+ (byte) 209, (byte) 226, (byte) 173, (byte) 88, (byte) 16, (byte) 79, (byte) 144, (byte) 65, (byte) 231,
+ (byte) 5, (byte) 63, (byte) 250, (byte) 249, (byte) 167, (byte) 127, (byte) 194, (byte) 95, (byte) 169,
+ (byte) 47, (byte) 38, (byte) 43, (byte) 102, (byte) 3, (byte) 146, (byte) 54, (byte) 48, (byte) 255,
+ (byte) 0, (byte) 217, (byte) 171, (byte) 50, (byte) 225, (byte) 118, (byte) 201, (byte) 34, (byte) 246,
+ (byte) 87, (byte) 35, (byte) 167, (byte) 185, (byte) 170, (byte) 237, (byte) 83, (byte) 205, (byte) 46,
+ (byte) 227, (byte) 178, (byte) 61, (byte) 58, (byte) 55, (byte) 89, (byte) 35, (byte) 87, (byte) 83,
+ (byte) 149, (byte) 97, (byte) 144, (byte) 125, (byte) 69, (byte) 62, (byte) 178, (byte) 252, (byte) 61,
+ (byte) 113, (byte) 246, (byte) 141, (byte) 14, (byte) 217, (byte) 179, (byte) 146, (byte) 139, (byte) 229,
+ (byte) 159, (byte) 248, (byte) 9, (byte) 199, (byte) 242, (byte) 197, (byte) 106, (byte) 87, (byte) 74,
+ (byte) 119, (byte) 70, (byte) 33, (byte) 69, (byte) 20, (byte) 83, (byte) 0, (byte) 162, (byte) 138,
+ (byte) 40, (byte) 0, (byte) 162, (byte) 138, (byte) 40, (byte) 0, (byte) 162, (byte) 138, (byte) 40,
+ (byte) 0, (byte) 162, (byte) 138, (byte) 40, (byte) 2, (byte) 181, (byte) 224, (byte) 253, (byte) 218,
+ (byte) 253, (byte) 107, (byte) 202, (byte) 245, (byte) 112, (byte) 97, (byte) 142, (byte) 201, (byte) 84,
+ (byte) 227, (byte) 98, (byte) 178, (byte) 140, (byte) 123, (byte) 96, (byte) 127, (byte) 74, (byte) 245,
+ (byte) 91, (byte) 177, (byte) 152, (byte) 135, (byte) 177, (byte) 175, (byte) 46, (byte) 241, (byte) 26,
+ (byte) 20, (byte) 158, (byte) 37, (byte) 56, (byte) 225, (byte) 229, (byte) 0, (byte) 99, (byte) 253,
+ (byte) 161, (byte) 88, (byte) 207, (byte) 114, (byte) 227, (byte) 177, (byte) 199, (byte) 94, (byte) 11,
+ (byte) 155, (byte) 251, (byte) 249, (byte) 101, (byte) 121, (byte) 164, (byte) 42, (byte) 174, (byte) 81,
+ (byte) 20, (byte) 49, (byte) 194, (byte) 237, (byte) 249, (byte) 78, (byte) 7, (byte) 185, (byte) 6,
+ (byte) 180, (byte) 52, (byte) 125, (byte) 58, (byte) 53, (byte) 156, (byte) 25, (byte) 162, (byte) 71,
+ (byte) 207, (byte) 247, (byte) 192, (byte) 111, (byte) 231, (byte) 78, (byte) 181, (byte) 69, (byte) 49,
+ (byte) 22, (byte) 199, (byte) 223, (byte) 146, (byte) 70, (byte) 252, (byte) 221, (byte) 143, (byte) 245,
+ (byte) 171, (byte) 208, (byte) 29, (byte) 146, (byte) 2, (byte) 43, (byte) 101, (byte) 162, (byte) 49,
+ (byte) 111, (byte) 83, (byte) 164, (byte) 131, (byte) 72, (byte) 181, (byte) 104, (byte) 195, (byte) 44,
+ (byte) 17, (byte) 129, (byte) 140, (byte) 240, (byte) 130, (byte) 164, (byte) 146, (byte) 194, (byte) 203,
+ (byte) 162, (byte) 194, (byte) 83, (byte) 28, (byte) 96, (byte) 128, (byte) 217, (byte) 231, (byte) 175,
+ (byte) 229, (byte) 69, (byte) 133, (byte) 223, (byte) 238, (byte) 128, (byte) 207, (byte) 106, (byte) 145,
+ (byte) 229, (byte) 6, (byte) 168, (byte) 30, (byte) 166, (byte) 117, (byte) 214, (byte) 159, (byte) 0,
+ (byte) 145, (byte) 188, (byte) 164, (byte) 194, (byte) 103, (byte) 140, (byte) 129, (byte) 156, (byte) 126,
+ (byte) 21, (byte) 151, (byte) 113, (byte) 96, (byte) 64, (byte) 37, (byte) 93, (byte) 212, (byte) 255,
+ (byte) 0, (byte) 178, (byte) 228, (byte) 127, (byte) 90, (byte) 218, (byte) 185, (byte) 151, (byte) 142,
+ (byte) 43, (byte) 53, (byte) 230, (byte) 39, (byte) 140, (byte) 210, (byte) 29, (byte) 236, (byte) 97,
+ (byte) 77, (byte) 29, (byte) 228, (byte) 71, (byte) 228, (byte) 185, (byte) 153, (byte) 123, (byte) 242,
+ (byte) 217, (byte) 254, (byte) 117, (byte) 99, (byte) 64, (byte) 188, (byte) 212, (byte) 134, (byte) 187,
+ (byte) 107, (byte) 12, (byte) 215, (byte) 38, (byte) 104, (byte) 100, (byte) 44, (byte) 25, (byte) 89,
+ (byte) 20, (byte) 17, (byte) 242, (byte) 147, (byte) 144, (byte) 64, (byte) 29, (byte) 197, (byte) 93,
+ (byte) 145, (byte) 65, (byte) 228, (byte) 210, (byte) 105, (byte) 113, (byte) 168, (byte) 214, (byte) 109,
+ (byte) 155, (byte) 28, (byte) 135, (byte) 63, (byte) 250, (byte) 9, (byte) 169, (byte) 146, (byte) 86,
+ (byte) 8, (byte) 201, (byte) 220, (byte) 234, (byte) 124, (byte) 34, (byte) 127, (byte) 119, (byte) 173,
+ (byte) 199, (byte) 233, (byte) 168, (byte) 74, (byte) 223, (byte) 154, (byte) 175, (byte) 248, (byte) 87,
+ (byte) 79, (byte) 92, (byte) 199, (byte) 132, (byte) 191, (byte) 227, (byte) 243, (byte) 93, (byte) 143,
+ (byte) 176, (byte) 187, (byte) 45, (byte) 215, (byte) 212, (byte) 176, (byte) 254, (byte) 149, (byte) 211,
+ (byte) 175, (byte) 32, (byte) 31, (byte) 106, (byte) 230, (byte) 55, (byte) 56, (byte) 219, (byte) 209,
+ (byte) 139, (byte) 139, (byte) 128, (byte) 58, (byte) 9, (byte) 152, (byte) 126, (byte) 166, (byte) 170,
+ (byte) 53, (byte) 93, (byte) 212, (byte) 70, (byte) 46, (byte) 238, (byte) 127, (byte) 235, (byte) 187,
+ (byte) 255, (byte) 0, (byte) 232, (byte) 77, (byte) 84, (byte) 24, (byte) 212, (byte) 148, (byte) 117,
+ (byte) 126, (byte) 12, (byte) 184, (byte) 6, (byte) 11, (byte) 155, (byte) 98, (byte) 126, (byte) 235,
+ (byte) 135, (byte) 25, (byte) 247, (byte) 24, (byte) 254, (byte) 131, (byte) 243, (byte) 174, (byte) 162,
+ (byte) 184, (byte) 63, (byte) 10, (byte) 220, (byte) 121, (byte) 26, (byte) 226, (byte) 33, (byte) 56,
+ (byte) 19, (byte) 163, (byte) 39, (byte) 63, (byte) 159, (byte) 244, (byte) 174, (byte) 238, (byte) 186,
+ (byte) 105, (byte) 187, (byte) 196, (byte) 202, (byte) 75, (byte) 81, (byte) 104, (byte) 162, (byte) 138,
+ (byte) 178, (byte) 66, (byte) 138, (byte) 40, (byte) 160, (byte) 2, (byte) 138, (byte) 40, (byte) 160,
+ (byte) 2, (byte) 138, (byte) 40, (byte) 160, (byte) 2, (byte) 138, (byte) 40, (byte) 160, (byte) 10,
+ (byte) 247, (byte) 127, (byte) 234, (byte) 9, (byte) 244, (byte) 34, (byte) 188, (byte) 215, (byte) 197,
+ (byte) 75, (byte) 139, (byte) 248, (byte) 135, (byte) 253, (byte) 52, (byte) 148, (byte) 127, (byte) 227,
+ (byte) 194, (byte) 189, (byte) 50, (byte) 228, (byte) 102, (byte) 221, (byte) 171, (byte) 205, (byte) 124,
+ (byte) 87, (byte) 197, (byte) 236, (byte) 39, (byte) 254, (byte) 154, (byte) 74, (byte) 127, (byte) 85,
+ (byte) 172, (byte) 103, (byte) 185, (byte) 113, (byte) 216, (byte) 229, (byte) 108, (byte) 159, (byte) 253,
+ (byte) 10, (byte) 220, (byte) 250, (byte) 198, (byte) 191, (byte) 202, (byte) 174, (byte) 198, (byte) 220,
+ (byte) 138, (byte) 205, (byte) 180, (byte) 56, (byte) 180, (byte) 128, (byte) 122, (byte) 32, (byte) 31,
+ (byte) 149, (byte) 91, (byte) 141, (byte) 186, (byte) 86, (byte) 199, (byte) 59, (byte) 220, (byte) 232,
+ (byte) 109, (byte) 37, (byte) 2, (byte) 33, (byte) 207, (byte) 52, (byte) 247, (byte) 185, (byte) 219,
+ (byte) 222, (byte) 179, (byte) 160, (byte) 124, (byte) 39, (byte) 90, (byte) 116, (byte) 143, (byte) 129,
+ (byte) 78, (byte) 227, (byte) 38, (byte) 146, (byte) 125, (byte) 245, (byte) 3, (byte) 250, (byte) 211,
+ (byte) 21, (byte) 179, (byte) 77, (byte) 145, (byte) 248, (byte) 160, (byte) 67, (byte) 36, (byte) 147,
+ (byte) 60, (byte) 84, (byte) 186, (byte) 79, (byte) 58, (byte) 189, (byte) 184, (byte) 245, (byte) 111,
+ (byte) 232, (byte) 106, (byte) 163, (byte) 18, (byte) 77, (byte) 90, (byte) 210, (byte) 71, (byte) 252,
+ (byte) 77, (byte) 109, (byte) 191, (byte) 223, (byte) 254, (byte) 148, (byte) 158, (byte) 195, (byte) 91,
+ (byte) 157, (byte) 79, (byte) 132, (byte) 255, (byte) 0, (byte) 228, (byte) 51, (byte) 174, (byte) 175,
+ (byte) 253, (byte) 54, (byte) 67, (byte) 249, (byte) 188, (byte) 191, (byte) 225, (byte) 93, (byte) 60,
+ (byte) 99, (byte) 247, (byte) 106, (byte) 79, (byte) 112, (byte) 43, (byte) 150, (byte) 240, (byte) 153,
+ (byte) 198, (byte) 187, (byte) 173, (byte) 251, (byte) 200, (byte) 191, (byte) 250, (byte) 28, (byte) 191,
+ (byte) 227, (byte) 93, (byte) 76, (byte) 103, (byte) 247, (byte) 72, (byte) 48, (byte) 79, (byte) 202,
+ (byte) 58, (byte) 125, (byte) 43, (byte) 152, (byte) 232, (byte) 103, (byte) 35, (byte) 170, (byte) 140,
+ (byte) 94, (byte) 220, (byte) 15, (byte) 250, (byte) 106, (byte) 199, (byte) 245, (byte) 53, (byte) 154,
+ (byte) 213, (byte) 161, (byte) 172, (byte) 200, (byte) 201, (byte) 172, (byte) 79, (byte) 27, (byte) 40,
+ (byte) 40, (byte) 228, (byte) 237, (byte) 97, (byte) 215, (byte) 119, (byte) 4, (byte) 254, (byte) 24,
+ (byte) 34, (byte) 179, (byte) 92, (byte) 212, (byte) 50, (byte) 209, (byte) 53, (byte) 140, (byte) 205,
+ (byte) 14, (byte) 161, (byte) 109, (byte) 34, (byte) 156, (byte) 21, (byte) 153, (byte) 79, (byte) 235,
+ (byte) 94, (byte) 159, (byte) 94, (byte) 79, (byte) 19, (byte) 133, (byte) 184, (byte) 141, (byte) 137,
+ (byte) 198, (byte) 28, (byte) 28, (byte) 231, (byte) 222, (byte) 189, (byte) 96, (byte) 86, (byte) 244,
+ (byte) 182, (byte) 51, (byte) 152, (byte) 180, (byte) 81, (byte) 69, (byte) 106, (byte) 64, (byte) 81,
+ (byte) 69, (byte) 20, (byte) 0, (byte) 81, (byte) 69, (byte) 20, (byte) 0, (byte) 81, (byte) 69, (byte) 20,
+ (byte) 0, (byte) 81, (byte) 69, (byte) 20, (byte) 1, (byte) 28, (byte) 195, (byte) 48, (byte) 191,
+ (byte) 210, (byte) 188, (byte) 215, (byte) 198, (byte) 3, (byte) 253, (byte) 34, (byte) 31, (byte) 247,
+ (byte) 165, (byte) 255, (byte) 0, (byte) 217, (byte) 107, (byte) 210, (byte) 228, (byte) 25, (byte) 141,
+ (byte) 135, (byte) 168, (byte) 175, (byte) 55, (byte) 241, (byte) 136, (byte) 255, (byte) 0, (byte) 72,
+ (byte) 132, (byte) 255, (byte) 0, (byte) 181, (byte) 39, (byte) 254, (byte) 201, (byte) 89, (byte) 79,
+ (byte) 114, (byte) 226, (byte) 112, (byte) 240, (byte) 182, (byte) 17, (byte) 151, (byte) 251, (byte) 146,
+ (byte) 200, (byte) 191, (byte) 147, (byte) 176, (byte) 171, (byte) 49, (byte) 190, (byte) 42, (byte) 175,
+ (byte) 221, (byte) 185, (byte) 158, (byte) 62, (byte) 226, (byte) 82, (byte) 199, (byte) 254, (byte) 5,
+ (byte) 134, (byte) 255, (byte) 0, (byte) 217, (byte) 170, (byte) 236, (byte) 54, (byte) 238, (byte) 216,
+ (byte) 35, (byte) 161, (byte) 173, (byte) 86, (byte) 198, (byte) 13, (byte) 106, (byte) 93, (byte) 134,
+ (byte) 76, (byte) 12, (byte) 158, (byte) 148, (byte) 231, (byte) 155, (byte) 119, (byte) 21, (byte) 25,
+ (byte) 2, (byte) 40, (byte) 241, (byte) 222, (byte) 171, (byte) 249, (byte) 148, (byte) 192, (byte) 176,
+ (byte) 37, (byte) 197, (byte) 33, (byte) 147, (byte) 53, (byte) 84, (byte) 189, (byte) 39, (byte) 155,
+ (byte) 72, (byte) 46, (byte) 88, (byte) 105, (byte) 0, (byte) 171, (byte) 122, (byte) 83, (byte) 143,
+ (byte) 237, (byte) 75, (byte) 111, (byte) 250, (byte) 232, (byte) 5, (byte) 101, (byte) 51, (byte) 213,
+ (byte) 253, (byte) 24, (byte) 238, (byte) 213, (byte) 109, (byte) 6, (byte) 122, (byte) 201, (byte) 252,
+ (byte) 129, (byte) 63, (byte) 210, (byte) 147, (byte) 216, (byte) 22, (byte) 231, (byte) 85, (byte) 225,
+ (byte) 118, (byte) 199, (byte) 136, (byte) 245, (byte) 81, (byte) 234, (byte) 73, (byte) 252, (byte) 164,
+ (byte) 111, (byte) 241, (byte) 174, (byte) 186, (byte) 48, (byte) 60, (byte) 181, (byte) 200, (byte) 228,
+ (byte) 10, (byte) 227, (byte) 60, (byte) 52, (byte) 216, (byte) 241, (byte) 93, (byte) 242, (byte) 250,
+ (byte) 199, (byte) 43, (byte) 126, (byte) 82, (byte) 175, (byte) 248, (byte) 215, (byte) 103, (byte) 23,
+ (byte) 220, (byte) 252, (byte) 127, (byte) 173, (byte) 115, (byte) 35, (byte) 162, (byte) 71, (byte) 39,
+ (byte) 173, (byte) 32, (byte) 26, (byte) 165, (byte) 219, (byte) 115, (byte) 146, (byte) 16, (byte) 117,
+ (byte) 246, (byte) 83, (byte) 254, (byte) 126, (byte) 130, (byte) 177, (byte) 166, (byte) 32, (byte) 119,
+ (byte) 226, (byte) 182, (byte) 124, (byte) 69, (byte) 32, (byte) 139, (byte) 81, (byte) 186, (byte) 245,
+ (byte) 33, (byte) 14, (byte) 63, (byte) 5, (byte) 172, (byte) 24, (byte) 109, (byte) 47, (byte) 53,
+ (byte) 55, (byte) 253, (byte) 218, (byte) 236, (byte) 132, (byte) 28, (byte) 25, (byte) 24, (byte) 113,
+ (byte) 248, (byte) 122, (byte) 159, (byte) 242, (byte) 113, (byte) 72, (byte) 181, (byte) 177, (byte) 93,
+ (byte) 167, (byte) 253, (byte) 224, (byte) 84, (byte) 203, (byte) 49, (byte) 56, (byte) 0, (byte) 117,
+ (byte) 39, (byte) 210, (byte) 189, (byte) 58, (byte) 231, (byte) 196, (byte) 54, (byte) 176, (byte) 79,
+ (byte) 229, (byte) 162, (byte) 60, (byte) 216, (byte) 234, (byte) 202, (byte) 64, (byte) 31, (byte) 175,
+ (byte) 90, (byte) 229, (byte) 116, (byte) 253, (byte) 34, (byte) 11, (byte) 33, (byte) 242, (byte) 21,
+ (byte) 18, (byte) 145, (byte) 204, (byte) 178, (byte) 2, (byte) 73, (byte) 250, (byte) 96, (byte) 112,
+ (byte) 61, (byte) 191, (byte) 60, (byte) 213, (byte) 209, (byte) 106, (byte) 63, (byte) 231, (byte) 162,
+ (byte) 49, (byte) 250, (byte) 31, (byte) 234, (byte) 42, (byte) 226, (byte) 218, (byte) 37, (byte) 171,
+ (byte) 238, (byte) 110, (byte) 175, (byte) 136, (byte) 45, (byte) 207, (byte) 222, (byte) 133, (byte) 199,
+ (byte) 210, (byte) 88, (byte) 207, (byte) 254, (byte) 205, (byte) 82, (byte) 13, (byte) 114, (byte) 212,
+ (byte) 255, (byte) 0, (byte) 4, (byte) 191, (byte) 130, (byte) 134, (byte) 254, (byte) 68, (byte) 215,
+ (byte) 62, (byte) 45, (byte) 155, (byte) 213, (byte) 63, (byte) 25, (byte) 20, (byte) 127, (byte) 51,
+ (byte) 71, (byte) 217, (byte) 155, (byte) 217, (byte) 190, (byte) 142, (byte) 15, (byte) 245, (byte) 167,
+ (byte) 207, (byte) 33, (byte) 114, (byte) 163, (byte) 164, (byte) 26, (byte) 189, (byte) 169, (byte) 237,
+ (byte) 48, (byte) 250, (byte) 192, (byte) 255, (byte) 0, (byte) 225, (byte) 75, (byte) 253, (byte) 175,
+ (byte) 99, (byte) 156, (byte) 25, (byte) 246, (byte) 159, (byte) 246, (byte) 145, (byte) 135, (byte) 243,
+ (byte) 21, (byte) 203, (byte) 152, (byte) 121, (byte) 195, (byte) 46, (byte) 8, (byte) 235, (byte) 145,
+ (byte) 72, (byte) 242, (byte) 164, (byte) 67, (byte) 229, (byte) 33, (byte) 219, (byte) 182, (byte) 41,
+ (byte) 169, (byte) 177, (byte) 114, (byte) 163, (byte) 174, (byte) 183, (byte) 189, (byte) 182, (byte) 186,
+ (byte) 37, (byte) 96, (byte) 157, (byte) 36, (byte) 101, (byte) 25, (byte) 32, (byte) 30, (byte) 69,
+ (byte) 21, (byte) 129, (byte) 225, (byte) 167, (byte) 102, (byte) 212, (byte) 102, (byte) 220, (byte) 73,
+ (byte) 38, (byte) 46, (byte) 191, (byte) 66, (byte) 63, (byte) 198, (byte) 138, (byte) 210, (byte) 46,
+ (byte) 234, (byte) 228, (byte) 181, (byte) 99, (byte) 168, (byte) 162, (byte) 138, (byte) 42, (byte) 132,
+ (byte) 20, (byte) 81, (byte) 69, (byte) 0, (byte) 53, (byte) 134, (byte) 65, (byte) 30, (byte) 162,
+ (byte) 184, (byte) 63, (byte) 17, (byte) 216, (byte) 75, (byte) 125, (byte) 118, (byte) 60, (byte) 160,
+ (byte) 27, (byte) 203, (byte) 39, (byte) 43, (byte) 144, (byte) 51, (byte) 144, (byte) 190, (byte) 191,
+ (byte) 74, (byte) 239, (byte) 24, (byte) 133, (byte) 4, (byte) 146, (byte) 0, (byte) 3, (byte) 36,
+ (byte) 154, (byte) 228, (byte) 117, (byte) 41, (byte) 188, (byte) 61, (byte) 125, (byte) 40, (byte) 55,
+ (byte) 83, (byte) 72, (byte) 207, (byte) 16, (byte) 40, (byte) 36, (byte) 141, (byte) 102, (byte) 78,
+ (byte) 255, (byte) 0, (byte) 222, (byte) 80, (byte) 1, (byte) 233, (byte) 235, (byte) 89, (byte) 84,
+ (byte) 42, (byte) 39, (byte) 23, (byte) 123, (byte) 225, (byte) 171, (byte) 201, (byte) 231, (byte) 19,
+ (byte) 165, (byte) 179, (byte) 68, (byte) 224, (byte) 96, (byte) 149, (byte) 145, (byte) 8, (byte) 108,
+ (byte) 116, (byte) 200, (byte) 207, (byte) 63, (byte) 134, (byte) 63, (byte) 149, (byte) 39, (byte) 246,
+ (byte) 118, (byte) 167, (byte) 18, (byte) 5, (byte) 22, (byte) 146, (byte) 57, (byte) 232, (byte) 74,
+ (byte) 198, (byte) 216, (byte) 253, (byte) 51, (byte) 93, (byte) 71, (byte) 217, (byte) 124, (byte) 49,
+ (byte) 252, (byte) 26, (byte) 244, (byte) 144, (byte) 158, (byte) 152, (byte) 125, (byte) 102, (byte) 81,
+ (byte) 250, (byte) 59, (byte) 212, (byte) 145, (byte) 233, (byte) 118, (byte) 115, (byte) 241, (byte) 103,
+ (byte) 226, (byte) 121, (byte) 219, (byte) 61, (byte) 60, (byte) 185, (byte) 160, (byte) 155, (byte) 255,
+ (byte) 0, (byte) 66, (byte) 86, (byte) 169, (byte) 83, (byte) 104, (byte) 171, (byte) 38, (byte) 113,
+ (byte) 83, (byte) 218, (byte) 223, (byte) 15, (byte) 191, (byte) 105, (byte) 34, (byte) 253, (byte) 84,
+ (byte) 143, (byte) 253, (byte) 8, (byte) 10, (byte) 164, (byte) 203, (byte) 42, (byte) 253, (byte) 232,
+ (byte) 219, (byte) 240, (byte) 32, (byte) 255, (byte) 0, (byte) 42, (byte) 244, (byte) 143, (byte) 248,
+ (byte) 71, (byte) 245, (byte) 56, (byte) 190, (byte) 104, (byte) 245, (byte) 105, (byte) 95, (byte) 143,
+ (byte) 249, (byte) 109, (byte) 111, (byte) 30, (byte) 63, (byte) 241, (byte) 213, (byte) 90, (byte) 67,
+ (byte) 166, (byte) 107, (byte) 153, (byte) 255, (byte) 0, (byte) 143, (byte) 251, (byte) 22, (byte) 29,
+ (byte) 54, (byte) 155, (byte) 103, (byte) 255, (byte) 0, (byte) 227, (byte) 148, (byte) 253, (byte) 161,
+ (byte) 62, (byte) 205, (byte) 30, (byte) 108, (byte) 86, (byte) 99, (byte) 210, (byte) 9, (byte) 143,
+ (byte) 210, (byte) 38, (byte) 255, (byte) 0, (byte) 10, (byte) 102, (byte) 38, (byte) 255, (byte) 0,
+ (byte) 158, (byte) 19, (byte) 127, (byte) 223, (byte) 166, (byte) 255, (byte) 0, (byte) 10, (byte) 244,
+ (byte) 71, (byte) 211, (byte) 117, (byte) 126, (byte) 127, (byte) 208, (byte) 52, (byte) 185, (byte) 207,
+ (byte) 171, (byte) 59, (byte) 39, (byte) 254, (byte) 200, (byte) 213, (byte) 3, (byte) 216, (byte) 234,
+ (byte) 73, (byte) 247, (byte) 252, (byte) 57, (byte) 167, (byte) 185, (byte) 207, (byte) 252, (byte) 177,
+ (byte) 185, (byte) 25, (byte) 253, (byte) 98, (byte) 20, (byte) 253, (byte) 160, (byte) 189, (byte) 154,
+ (byte) 56, (byte) 34, (byte) 179, (byte) 127, (byte) 207, (byte) 9, (byte) 191, (byte) 239, (byte) 211,
+ (byte) 127, (byte) 133, (byte) 106, (byte) 248, (byte) 126, (byte) 25, (byte) 155, (byte) 92, (byte) 180,
+ (byte) 38, (byte) 25, (byte) 2, (byte) 161, (byte) 102, (byte) 102, (byte) 101, (byte) 35, (byte) 31,
+ (byte) 35, (byte) 122, (byte) 245, (byte) 231, (byte) 21, (byte) 209, (byte) 73, (byte) 107, (byte) 56,
+ (byte) 255, (byte) 0, (byte) 91, (byte) 225, (byte) 75, (byte) 156, (byte) 122, (byte) 197, (byte) 60,
+ (byte) 68, (byte) 127, (byte) 232, (byte) 98, (byte) 155, (byte) 11, (byte) 219, (byte) 90, (byte) 74,
+ (byte) 37, (byte) 254, (byte) 195, (byte) 213, (byte) 33, (byte) 96, (byte) 15, (byte) 34, (byte) 35,
+ (byte) 39, (byte) 111, (byte) 246, (byte) 93, (byte) 168, (byte) 117, (byte) 52, (byte) 26, (byte) 133,
+ (byte) 152, (byte) 190, (byte) 26, (byte) 111, (byte) 248, (byte) 172, (byte) 46, (byte) 125, (byte) 224,
+ (byte) 159, (byte) 255, (byte) 0, (byte) 70, (byte) 199, (byte) 93, (byte) 188, (byte) 127, (byte) 112,
+ (byte) 253, (byte) 79, (byte) 243, (byte) 174, (byte) 19, (byte) 195, (byte) 2, (byte) 87, (byte) 241,
+ (byte) 91, (byte) 74, (byte) 109, (byte) 174, (byte) 163, (byte) 83, (byte) 4, (byte) 191, (byte) 52,
+ (byte) 182, (byte) 242, (byte) 70, (byte) 57, (byte) 116, (byte) 56, (byte) 249, (byte) 128, (byte) 231,
+ (byte) 143, (byte) 210, (byte) 187, (byte) 57, (byte) 110, (byte) 227, (byte) 180, (byte) 143, (byte) 116,
+ (byte) 188, (byte) 41, (byte) 220, (byte) 217, (byte) 200, (byte) 236, (byte) 195, (byte) 143, (byte) 215,
+ (byte) 244, (byte) 172, (byte) 139, (byte) 145, (byte) 201, (byte) 248, (byte) 171, (byte) 82, (byte) 139,
+ (byte) 79, (byte) 213, (byte) 247, (byte) 203, (byte) 100, (byte) 46, (byte) 132, (byte) 135, (byte) 104,
+ (byte) 87, (byte) 144, (byte) 168, (byte) 27, (byte) 85, (byte) 14, (byte) 72, (byte) 193, (byte) 207,
+ (byte) 222, (byte) 233, (byte) 237, (byte) 223, (byte) 60, (byte) 81, (byte) 79, (byte) 25, (byte) 67,
+ (byte) 128, (byte) 26, (byte) 192, (byte) 160, (byte) 3, (byte) 133, (byte) 73, (byte) 65, (byte) 254,
+ (byte) 130, (byte) 163, (byte) 248, (byte) 147, (byte) 58, (byte) 90, (byte) 223, (byte) 219, (byte) 187,
+ (byte) 134, (byte) 101, (byte) 33, (byte) 219, (byte) 228, (byte) 93, (byte) 199, (byte) 145, (byte) 24,
+ (byte) 254, (byte) 149, (byte) 196, (byte) 255, (byte) 0, (byte) 107, (byte) 91, (byte) 19, (byte) 203,
+ (byte) 72, (byte) 163, (byte) 253, (byte) 168, (byte) 95, (byte) 252, (byte) 43, (byte) 120, (byte) 194,
+ (byte) 45, (byte) 106, (byte) 67, (byte) 108, (byte) 239, (byte) 215, (byte) 198, (byte) 186, (byte) 104,
+ (byte) 225, (byte) 237, (byte) 238, (byte) 198, (byte) 61, (byte) 21, (byte) 63, (byte) 248, (byte) 161,
+ (byte) 82, (byte) 199, (byte) 227, (byte) 13, (byte) 33, (byte) 241, (byte) 151, (byte) 120, (byte) 243,
+ (byte) 211, (byte) 112, (byte) 207, (byte) 254, (byte) 131, (byte) 154, (byte) 224, (byte) 132, (byte) 158,
+ (byte) 110, (byte) 217, (byte) 85, (byte) 91, (byte) 100, (byte) 136, (byte) 25, (byte) 24, (byte) 169,
+ (byte) 27, (byte) 128, (byte) 102, (byte) 25, (byte) 25, (byte) 247, (byte) 4, (byte) 126, (byte) 6,
+ (byte) 131, (byte) 46, (byte) 196, (byte) 203, (byte) 182, (byte) 213, (byte) 4, (byte) 100, (byte) 147,
+ (byte) 199, (byte) 90, (byte) 175, (byte) 103, (byte) 17, (byte) 115, (byte) 51, (byte) 209, (byte) 87,
+ (byte) 196, (byte) 250, (byte) 43, (byte) 112, (byte) 47, (byte) 9, (byte) 63, (byte) 245, (byte) 198,
+ (byte) 79, (byte) 234, (byte) 181, (byte) 98, (byte) 29, (byte) 91, (byte) 79, (byte) 185, (byte) 144,
+ (byte) 71, (byte) 21, (byte) 204, (byte) 108, (byte) 228, (byte) 18, (byte) 23, (byte) 112, (byte) 207,
+ (byte) 3, (byte) 39, (byte) 3, (byte) 169, (byte) 224, (byte) 19, (byte) 248, (byte) 87, (byte) 155,
+ (byte) 69, (byte) 34, (byte) 56, (byte) 249, (byte) 27, (byte) 119, (byte) 161, (byte) 21, (byte) 167,
+ (byte) 161, (byte) 182, (byte) 221, (byte) 102, (byte) 220, (byte) 247, (byte) 219, (byte) 40, (byte) 252,
+ (byte) 227, (byte) 97, (byte) 253, (byte) 105, (byte) 58, (byte) 106, (byte) 195, (byte) 82, (byte) 103,
+ (byte) 111, (byte) 52, (byte) 172, (byte) 252, (byte) 46, (byte) 85, (byte) 125, (byte) 61, (byte) 106,
+ (byte) 12, (byte) 96, (byte) 99, (byte) 240, (byte) 169, (byte) 202, (byte) 212, (byte) 101, (byte) 107,
+ (byte) 3, (byte) 67, (byte) 83, (byte) 195, (byte) 7, (byte) 254, (byte) 38, (byte) 50, (byte) 231,
+ (byte) 254, (byte) 120, (byte) 159, (byte) 253, (byte) 8, (byte) 81, (byte) 75, (byte) 225, (byte) 180,
+ (byte) 35, (byte) 82, (byte) 118, (byte) 231, (byte) 2, (byte) 18, (byte) 9, (byte) 199, (byte) 251,
+ (byte) 75, (byte) 69, (byte) 111, (byte) 13, (byte) 140, (byte) 158, (byte) 231, (byte) 83, (byte) 69,
+ (byte) 20, (byte) 85, (byte) 8, (byte) 41, (byte) 172, (byte) 202, (byte) 168, (byte) 89, (byte) 136,
+ (byte) 10, (byte) 7, (byte) 36, (byte) 210, (byte) 59, (byte) 172, (byte) 104, (byte) 89, (byte) 206,
+ (byte) 0, (byte) 234, (byte) 107, (byte) 50, (byte) 123, (byte) 212, (byte) 153, (byte) 202, (byte) 188,
+ (byte) 37, (byte) 226, (byte) 237, (byte) 243, (byte) 17, (byte) 248, (byte) 241, (byte) 82, (byte) 221,
+ (byte) 134, (byte) 149, (byte) 200, (byte) 239, (byte) 47, (byte) 26, (byte) 228, (byte) 152, (byte) 227,
+ (byte) 202, (byte) 197, (byte) 233, (byte) 221, (byte) 170, (byte) 151, (byte) 151, (byte) 20, (byte) 201,
+ (byte) 204, (byte) 104, (byte) 87, (byte) 28, (byte) 54, (byte) 7, (byte) 205, (byte) 255, (byte) 0,
+ (byte) 214, (byte) 255, (byte) 0, (byte) 61, (byte) 58, (byte) 217, (byte) 117, (byte) 180, (byte) 158,
+ (byte) 65, (byte) 31, (byte) 149, (byte) 60, (byte) 104, (byte) 6, (byte) 231, (byte) 97, (byte) 200,
+ (byte) 62, (byte) 220, (byte) 245, (byte) 255, (byte) 0, (byte) 235, (byte) 115, (byte) 193, (byte) 230,
+ (byte) 95, (byte) 46, (byte) 208, (byte) 253, (byte) 219, (byte) 163, (byte) 207, (byte) 170, (byte) 19,
+ (byte) 89, (byte) 61, (byte) 77, (byte) 17, (byte) 158, (byte) 108, (byte) 237, (byte) 143, (byte) 88,
+ (byte) 23, (byte) 240, (byte) 36, (byte) 127, (byte) 42, (byte) 175, (byte) 54, (byte) 143, (byte) 167,
+ (byte) 78, (byte) 49, (byte) 37, (byte) 170, (byte) 48, (byte) 247, (byte) 231, (byte) 249, (byte) 230,
+ (byte) 181, (byte) 205, (byte) 164, (byte) 103, (byte) 238, (byte) 221, (byte) 196, (byte) 126, (byte) 191,
+ (byte) 45, (byte) 31, (byte) 96, (byte) 145, (byte) 190, (byte) 228, (byte) 145, (byte) 55, (byte) 209,
+ (byte) 243, (byte) 253, (byte) 41, (byte) 89, (byte) 133, (byte) 209, (byte) 203, (byte) 220, (byte) 105,
+ (byte) 30, (byte) 28, (byte) 177, (byte) 144, (byte) 44, (byte) 162, (byte) 218, (byte) 217, (byte) 200,
+ (byte) 200, (byte) 201, (byte) 69, (byte) 63, (byte) 94, (byte) 153, (byte) 20, (byte) 244, (byte) 181,
+ (byte) 211, (byte) 179, (byte) 182, (byte) 13, (byte) 126, (byte) 72, (byte) 200, (byte) 63, (byte) 118,
+ (byte) 27, (byte) 246, (byte) 31, (byte) 160, (byte) 113, (byte) 90, (byte) 18, (byte) 120, (byte) 78,
+ (byte) 79, (byte) 53, (byte) 230, (byte) 89, (byte) 239, (byte) 11, (byte) 200, (byte) 114, (byte) 205,
+ (byte) 231, (byte) 1, (byte) 159, (byte) 110, (byte) 48, (byte) 106, (byte) 164, (byte) 158, (byte) 18,
+ (byte) 186, (byte) 199, (byte) 55, (byte) 37, (byte) 143, (byte) 253, (byte) 52, (byte) 181, (byte) 14,
+ (byte) 127, (byte) 70, (byte) 231, (byte) 252, (byte) 105, (byte) 217, (byte) 245, (byte) 27, (byte) 113,
+ (byte) 182, (byte) 132, (byte) 137, (byte) 166, (byte) 94, (byte) 227, (byte) 117, (byte) 174, (byte) 175,
+ (byte) 118, (byte) 71, (byte) 247, (byte) 153, (byte) 203, (byte) 255, (byte) 0, (byte) 232, (byte) 91,
+ (byte) 169, (byte) 77, (byte) 182, (byte) 186, (byte) 135, (byte) 141, (byte) 105, (byte) 155, (byte) 31,
+ (byte) 194, (byte) 97, (byte) 139, (byte) 255, (byte) 0, (byte) 141, (byte) 131, (byte) 250, (byte) 214,
+ (byte) 115, (byte) 248, (byte) 70, (byte) 97, (byte) 255, (byte) 0, (byte) 44, (byte) 108, (byte) 206,
+ (byte) 14, (byte) 114, (byte) 208, (byte) 24, (byte) 255, (byte) 0, (byte) 161, (byte) 173, (byte) 29,
+ (byte) 39, (byte) 74, (byte) 26, (byte) 126, (byte) 247, (byte) 149, (byte) 209, (byte) 166, (byte) 147,
+ (byte) 130, (byte) 35, (byte) 56, (byte) 69, (byte) 95, (byte) 65, (byte) 211, (byte) 63, (byte) 92,
+ (byte) 127, (byte) 92, (byte) 161, (byte) 33, (byte) 124, (byte) 207, (byte) 17, (byte) 39, (byte) 11,
+ (byte) 45, (byte) 148, (byte) 131, (byte) 214, (byte) 72, (byte) 73, (byte) 63, (byte) 163, (byte) 143,
+ (byte) 229, (byte) 74, (byte) 47, (byte) 245, (byte) 216, (byte) 190, (byte) 245, (byte) 157, (byte) 180,
+ (byte) 196, (byte) 127, (byte) 207, (byte) 48, (byte) 201, (byte) 253, (byte) 90, (byte) 180, (byte) 48,
+ (byte) 126, (byte) 180, (byte) 224, (byte) 15, (byte) 231, (byte) 72, (byte) 101, (byte) 1, (byte) 173,
+ (byte) 106, (byte) 163, (byte) 253, (byte) 102, (byte) 134, (byte) 20, (byte) 122, (byte) 173, (byte) 211,
+ (byte) 31, (byte) 231, (byte) 24, (byte) 254, (byte) 116, (byte) 198, (byte) 215, (byte) 81, (byte) 198,
+ (byte) 219, (byte) 173, (byte) 26, (byte) 241, (byte) 186, (byte) 224, (byte) 175, (byte) 150, (byte) 71,
+ (byte) 39, (byte) 61, (byte) 75, (byte) 131, (byte) 255, (byte) 0, (byte) 234, (byte) 173, (byte) 46,
+ (byte) 248, (byte) 252, (byte) 205, (byte) 57, (byte) 229, (byte) 16, (byte) 199, (byte) 187, (byte) 156,
+ (byte) 14, (byte) 128, (byte) 127, (byte) 42, (byte) 5, (byte) 99, (byte) 138, (byte) 241, (byte) 77,
+ (byte) 192, (byte) 212, (byte) 110, (byte) 32, (byte) 157, (byte) 109, (byte) 228, (byte) 137, (byte) 22,
+ (byte) 63, (byte) 44, (byte) 9, (byte) 217, (byte) 50, (byte) 79, (byte) 83, (byte) 209, (byte) 142,
+ (byte) 56, (byte) 199, (byte) 83, (byte) 216, (byte) 215, (byte) 57, (byte) 60, (byte) 16, (byte) 164,
+ (byte) 139, (byte) 27, (byte) 199, (byte) 9, (byte) 103, (byte) 206, (byte) 54, (byte) 149, (byte) 113,
+ (byte) 198, (byte) 123, (byte) 174, (byte) 64, (byte) 233, (byte) 252, (byte) 143, (byte) 66, (byte) 43,
+ (byte) 168, (byte) 215, (byte) 230, (byte) 55, (byte) 183, (byte) 10, (byte) 3, (byte) 65, (byte) 186,
+ (byte) 55, (byte) 70, (byte) 223, (byte) 59, (byte) 98, (byte) 54, (byte) 251, (byte) 223, (byte) 41,
+ (byte) 245, (byte) 206, (byte) 56, (byte) 3, (byte) 168, (byte) 13, (byte) 233, (byte) 85, (byte) 103,
+ (byte) 179, (byte) 188, (byte) 189, (byte) 71, (byte) 242, (byte) 116, (byte) 171, (byte) 50, (byte) 204,
+ (byte) 191, (byte) 122, (byte) 198, (byte) 9, (byte) 64, (byte) 31, (byte) 48, (byte) 111, (byte) 226,
+ (byte) 24, (byte) 29, (byte) 8, (byte) 227, (byte) 28, (byte) 55, (byte) 126, (byte) 49, (byte) 211,
+ (byte) 77, (byte) 251, (byte) 166, (byte) 82, (byte) 90, (byte) 156, (byte) 133, (byte) 236, (byte) 12,
+ (byte) 183, (byte) 150, (byte) 235, (byte) 109, (byte) 251, (byte) 165, (byte) 116, (byte) 145, (byte) 164,
+ (byte) 218, (byte) 163, (byte) 230, (byte) 198, (byte) 192, (byte) 58, (byte) 143, (byte) 246, (byte) 169,
+ (byte) 5, (byte) 169, (byte) 152, (byte) 136, (byte) 166, (byte) 145, (byte) 165, (byte) 141, (byte) 136,
+ (byte) 12, (byte) 164, (byte) 46, (byte) 15, (byte) 62, (byte) 192, (byte) 86, (byte) 244, (byte) 186,
+ (byte) 93, (byte) 228, (byte) 92, (byte) 203, (byte) 28, (byte) 113, (byte) 251, (byte) 60, (byte) 241,
+ (byte) 131, (byte) 249, (byte) 110, (byte) 205, (byte) 71, (byte) 30, (byte) 159, (byte) 117, (byte) 47,
+ (byte) 250, (byte) 171, (byte) 57, (byte) 165, (byte) 199, (byte) 59, (byte) 162, (byte) 132, (byte) 183,
+ (byte) 234, (byte) 5, (byte) 105, (byte) 161, (byte) 55, (byte) 118, (byte) 51, (byte) 101, (byte) 209,
+ (byte) 45, (byte) 47, (byte) 103, (byte) 6, (byte) 68, (byte) 105, (byte) 102, (byte) 147, (byte) 10,
+ (byte) 25, (byte) 216, (byte) 51, (byte) 30, (byte) 138, (byte) 6, (byte) 79, (byte) 62, (byte) 128,
+ (byte) 126, (byte) 21, (byte) 111, (byte) 64, (byte) 210, (byte) 109, (byte) 173, (byte) 53, (byte) 120,
+ (byte) 37, (byte) 129, (byte) 202, (byte) 228, (byte) 227, (byte) 29, (byte) 71, (byte) 63, (byte) 141,
+ (byte) 109, (byte) 233, (byte) 26, (byte) 129, (byte) 209, (byte) 94, (byte) 113, (byte) 117, (byte) 246,
+ (byte) 155, (byte) 101, (byte) 152, (byte) 47, (byte) 42, (byte) 160, (byte) 19, (byte) 130, (byte) 120,
+ (byte) 33, (byte) 177, (byte) 235, (byte) 80, (byte) 45, (byte) 228, (byte) 55, (byte) 94, (byte) 35,
+ (byte) 89, (byte) 161, (byte) 152, (byte) 202, (byte) 178, (byte) 93, (byte) 33, (byte) 220, (byte) 196,
+ (byte) 100, (byte) 229, (byte) 134, (byte) 123, (byte) 250, (byte) 231, (byte) 30, (byte) 216, (byte) 168,
+ (byte) 247, (byte) 155, (byte) 105, (byte) 173, (byte) 7, (byte) 100, (byte) 146, (byte) 119, (byte) 215,
+ (byte) 177, (byte) 214, (byte) 176, (byte) 228, (byte) 213, (byte) 121, (byte) 164, (byte) 218, (byte) 226,
+ (byte) 56, (byte) 212, (byte) 201, (byte) 41, (byte) 25, (byte) 10, (byte) 14, (byte) 49, (byte) 238,
+ (byte) 79, (byte) 97, (byte) 254, (byte) 7, (byte) 0, (byte) 224, (byte) 225, (byte) 210, (byte) 76,
+ (byte) 242, (byte) 187, (byte) 69, (byte) 109, (byte) 141, (byte) 192, (byte) 225, (byte) 229, (byte) 35,
+ (byte) 33, (byte) 61, (byte) 135, (byte) 171, (byte) 126, (byte) 131, (byte) 190, (byte) 113, (byte) 180,
+ (byte) 190, (byte) 24, (byte) 86, (byte) 8, (byte) 202, (byte) 140, (byte) 156, (byte) 156, (byte) 150,
+ (byte) 39, (byte) 37, (byte) 142, (byte) 7, (byte) 39, (byte) 215, (byte) 255, (byte) 0, (byte) 172,
+ (byte) 43, (byte) 152, (byte) 216, (byte) 185, (byte) 225, (byte) 200, (byte) 60, (byte) 173, (byte) 87,
+ (byte) 204, (byte) 119, (byte) 50, (byte) 74, (byte) 209, (byte) 48, (byte) 45, (byte) 140, (byte) 0,
+ (byte) 50, (byte) 188, (byte) 1, (byte) 216, (byte) 127, (byte) 128, (byte) 201, (byte) 39, (byte) 154,
+ (byte) 42, (byte) 93, (byte) 12, (byte) 255, (byte) 0, (byte) 196, (byte) 208, (byte) 127, (byte) 184,
+ (byte) 194, (byte) 138, (byte) 214, (byte) 27, (byte) 25, (byte) 189, (byte) 206, (byte) 158, (byte) 152,
+ (byte) 238, (byte) 168, (byte) 165, (byte) 152, (byte) 224, (byte) 10, (byte) 29, (byte) 213, (byte) 20,
+ (byte) 179, (byte) 28, (byte) 1, (byte) 89, (byte) 151, (byte) 51, (byte) 180, (byte) 242, (byte) 99,
+ (byte) 149, (byte) 3, (byte) 166, (byte) 123, (byte) 127, (byte) 245, (byte) 255, (byte) 0, (byte) 207,
+ (byte) 213, (byte) 202, (byte) 86, (byte) 4, (byte) 174, (byte) 54, (byte) 230, (byte) 225, (byte) 238,
+ (byte) 31, (byte) 28, (byte) 170, (byte) 131, (byte) 211, (byte) 211, (byte) 255, (byte) 0, (byte) 175,
+ (byte) 254, (byte) 126, (byte) 180, (byte) 53, (byte) 43, (byte) 248, (byte) 244, (byte) 219, (byte) 38,
+ (byte) 153, (byte) 204, (byte) 69, (byte) 254, (byte) 236, (byte) 105, (byte) 38, (byte) 62, (byte) 118,
+ (byte) 244, (byte) 232, (byte) 79, (byte) 191, (byte) 3, (byte) 160, (byte) 53, (byte) 120, (byte) 0,
+ (byte) 56, (byte) 3, (byte) 35, (byte) 182, (byte) 43, (byte) 151, (byte) 214, (byte) 32, (byte) 186,
+ (byte) 184, (byte) 251, (byte) 68, (byte) 177, (byte) 45, (byte) 203, (byte) 179, (byte) 137, (byte) 4,
+ (byte) 34, (byte) 9, (byte) 140, (byte) 160, (byte) 28, (byte) 124, (byte) 167, (byte) 98, (byte) 18,
+ (byte) 6, (byte) 62, (byte) 92, (byte) 241, (byte) 233, (byte) 156, (byte) 214, (byte) 90, (byte) 189,
+ (byte) 77, (byte) 52, (byte) 71, (byte) 63, (byte) 172, (byte) 107, (byte) 115, (byte) 107, (byte) 22,
+ (byte) 242, (byte) 51, (byte) 181, (byte) 178, (byte) 136, (byte) 207, (byte) 151, (byte) 19, (byte) 67,
+ (byte) 41, (byte) 92, (byte) 177, (byte) 56, (byte) 222, (byte) 20, (byte) 156, (byte) 119, (byte) 199,
+ (byte) 174, (byte) 51, (byte) 239, (byte) 78, (byte) 142, (byte) 246, (byte) 255, (byte) 0, (byte) 251,
+ (byte) 68, (byte) 132, (byte) 184, (byte) 188, (byte) 40, (byte) 97, (byte) 12, (byte) 203, (byte) 21,
+ (byte) 217, (byte) 113, (byte) 184, (byte) 177, (byte) 231, (byte) 61, (byte) 73, (byte) 249, (byte) 72,
+ (byte) 252, (byte) 61, (byte) 14, (byte) 40, (byte) 184, (byte) 211, (byte) 210, (byte) 214, (byte) 91,
+ (byte) 85, (byte) 197, (byte) 223, (byte) 151, (byte) 2, (byte) 54, (byte) 67, (byte) 68, (byte) 9,
+ (byte) 83, (byte) 133, (byte) 11, (byte) 213, (byte) 112, (byte) 6, (byte) 55, (byte) 113, (byte) 236,
+ (byte) 181, (byte) 71, (byte) 201, (byte) 141, (byte) 173, (byte) 164, (byte) 6, (byte) 72, (byte) 196,
+ (byte) 211, (byte) 92, (byte) 130, (byte) 223, (byte) 185, (byte) 31, (byte) 42, (byte) 121, (byte) 157,
+ (byte) 114, (byte) 15, (byte) 63, (byte) 39, (byte) 59, (byte) 70, (byte) 59, (byte) 129, (byte) 72,
+ (byte) 11, (byte) 208, (byte) 107, (byte) 186, (byte) 180, (byte) 80, (byte) 89, (byte) 187, (byte) 92,
+ (byte) 207, (byte) 153, (byte) 78, (byte) 11, (byte) 60, (byte) 10, (byte) 251, (byte) 151, (byte) 4,
+ (byte) 228, (byte) 119, (byte) 35, (byte) 145, (byte) 201, (byte) 237, (byte) 223, (byte) 140, (byte) 84,
+ (byte) 237, (byte) 226, (byte) 205, (byte) 66, (byte) 56, (byte) 238, (byte) 143, (byte) 155, (byte) 4,
+ (byte) 173, (byte) 9, (byte) 253, (byte) 216, (byte) 146, (byte) 50, (byte) 9, (byte) 24, (byte) 29,
+ (byte) 74, (byte) 225, (byte) 122, (byte) 231, (byte) 211, (byte) 159, (byte) 65, (byte) 129, (byte) 84,
+ (byte) 163, (byte) 130, (byte) 36, (byte) 189, (byte) 105, (byte) 35, (byte) 104, (byte) 22, (byte) 59,
+ (byte) 120, (byte) 151, (byte) 203, (byte) 0, (byte) 186, (byte) 6, (byte) 56, (byte) 108, (byte) 237,
+ (byte) 4, (byte) 17, (byte) 156, (byte) 96, (byte) 115, (byte) 237, (byte) 239, (byte) 76, (byte) 91,
+ (byte) 105, (byte) 222, (byte) 210, (byte) 218, (byte) 220, (byte) 202, (byte) 210, (byte) 53, (byte) 227,
+ (byte) 111, (byte) 153, (byte) 86, (byte) 225, (byte) 91, (byte) 113, (byte) 10, (byte) 9, (byte) 220,
+ (byte) 27, (byte) 1, (byte) 79, (byte) 11, (byte) 199, (byte) 177, (byte) 29, (byte) 133, (byte) 49,
+ (byte) 155, (byte) 145, (byte) 120, (byte) 190, (byte) 228, (byte) 92, (byte) 172, (byte) 97, (byte) 108,
+ (byte) 217, (byte) 36, (byte) 66, (byte) 200, (byte) 233, (byte) 33, (byte) 64, (byte) 57, (byte) 28,
+ (byte) 100, (byte) 245, (byte) 56, (byte) 201, (byte) 237, (byte) 248, (byte) 98, (byte) 172, (byte) 65,
+ (byte) 227, (byte) 137, (byte) 140, (byte) 16, (byte) 74, (byte) 246, (byte) 115, (byte) 42, (byte) 203,
+ (byte) 32, (byte) 143, (byte) 11, (byte) 114, (byte) 25, (byte) 129, (byte) 44, (byte) 71, (byte) 76,
+ (byte) 122, (byte) 14, (byte) 228, (byte) 117, (byte) 252, (byte) 107, (byte) 157, (byte) 144, (byte) 92,
+ (byte) 43, (byte) 222, (byte) 223, (byte) 58, (byte) 22, (byte) 22, (byte) 160, (byte) 196, (byte) 26,
+ (byte) 72, (byte) 17, (byte) 151, (byte) 43, (byte) 134, (byte) 195, (byte) 31, (byte) 169, (byte) 198,
+ (byte) 125, (byte) 198, (byte) 15, (byte) 81, (byte) 81, (byte) 53, (byte) 160, (byte) 133, (byte) 45,
+ (byte) 237, (byte) 36, (byte) 72, (byte) 198, (byte) 73, (byte) 146, (byte) 67, (byte) 36, (byte) 82,
+ (byte) 70, (byte) 207, (byte) 131, (byte) 247, (byte) 88, (byte) 117, (byte) 193, (byte) 207, (byte) 233,
+ (byte) 138, (byte) 44, (byte) 35, (byte) 179, (byte) 143, (byte) 199, (byte) 10, (byte) 30, (byte) 84,
+ (byte) 146, (byte) 43, (byte) 196, (byte) 120, (byte) 66, (byte) 153, (byte) 23, (byte) 201, (byte) 86,
+ (byte) 218, (byte) 8, (byte) 39, (byte) 57, (byte) 207, (byte) 160, (byte) 255, (byte) 0, (byte) 12,
+ (byte) 243, (byte) 86, (byte) 35, (byte) 241, (byte) 197, (byte) 131, (byte) 136, (byte) 183, (byte) 220,
+ (byte) 5, (byte) 89, (byte) 64, (byte) 43, (byte) 230, (byte) 196, (byte) 70, (byte) 114, (byte) 51,
+ (byte) 142, (byte) 7, (byte) 167, (byte) 225, (byte) 232, (byte) 77, (byte) 112, (byte) 161, (byte) 227,
+ (byte) 243, (byte) 47, (byte) 38, (byte) 85, (byte) 82, (byte) 71, (byte) 238, (byte) 149, (byte) 97,
+ (byte) 148, (byte) 118, (byte) 249, (byte) 115, (byte) 176, (byte) 142, (byte) 65, (byte) 36, (byte) 30,
+ (byte) 123, (byte) 103, (byte) 165, (byte) 77, (byte) 30, (byte) 200, (byte) 18, (byte) 218, (byte) 216,
+ (byte) 153, (byte) 62, (byte) 210, (byte) 177, (byte) 147, (byte) 27, (byte) 9, (byte) 183, (byte) 34,
+ (byte) 54, (byte) 210, (byte) 48, (byte) 48, (byte) 64, (byte) 3, (byte) 57, (byte) 29, (byte) 248,
+ (byte) 35, (byte) 182, (byte) 40, (byte) 11, (byte) 30, (byte) 133, (byte) 105, (byte) 173, (byte) 217,
+ (byte) 95, (byte) 150, (byte) 16, (byte) 165, (byte) 188, (byte) 204, (byte) 167, (byte) 5, (byte) 76,
+ (byte) 101, (byte) 24, (byte) 113, (byte) 232, (byte) 220, (byte) 254, (byte) 149, (byte) 108, (byte) 205,
+ (byte) 22, (byte) 15, (byte) 250, (byte) 24, (byte) 83, (byte) 219, (byte) 14, (byte) 71, (byte) 242,
+ (byte) 172, (byte) 15, (byte) 11, (byte) 104, (byte) 247, (byte) 54, (byte) 22, (byte) 242, (byte) 94,
+ (byte) 94, (byte) 51, (byte) 139, (byte) 155, (byte) 189, (byte) 164, (byte) 198, (byte) 78, (byte) 54,
+ (byte) 168, (byte) 233, (byte) 145, (byte) 221, (byte) 185, (byte) 231, (byte) 250, (byte) 115, (byte) 157,
+ (byte) 226, (byte) 63, (byte) 217, (byte) 95, (byte) 251, (byte) 228, (byte) 127, (byte) 133, (byte) 23,
+ (byte) 21, (byte) 134, (byte) 198, (byte) 246, (byte) 113, (byte) 68, (byte) 136, (byte) 240, (byte) 200,
+ (byte) 48, (byte) 48, (byte) 88, (byte) 177, (byte) 228, (byte) 250, (byte) 253, (byte) 127, (byte) 198,
+ (byte) 178, (byte) 53, (byte) 235, (byte) 216, (byte) 6, (byte) 32, (byte) 183, (byte) 82, (byte) 175,
+ (byte) 143, (byte) 152, (byte) 150, (byte) 206, (byte) 1, (byte) 254, (byte) 167, (byte) 249, (byte) 84,
+ (byte) 154, (byte) 165, (byte) 202, (byte) 136, (byte) 252, (byte) 161, (byte) 134, (byte) 207, (byte) 64,
+ (byte) 123, (byte) 251, (byte) 214, (byte) 20, (byte) 185, (byte) 98, (byte) 89, (byte) 137, (byte) 44,
+ (byte) 78, (byte) 73, (byte) 39, (byte) 169, (byte) 160, (byte) 102, (byte) 7, (byte) 138, (byte) 142,
+ (byte) 52, (byte) 66, (byte) 115, (byte) 130, (byte) 110, (byte) 98, (byte) 239, (byte) 232, (byte) 178,
+ (byte) 255, (byte) 0, (byte) 241, (byte) 85, (byte) 201, (byte) 196, (byte) 98, (byte) 126, (byte) 89,
+ (byte) 85, (byte) 143, (byte) 184, (byte) 174, (byte) 195, (byte) 196, (byte) 177, (byte) 121, (byte) 186,
+ (byte) 28, (byte) 153, (byte) 255, (byte) 0, (byte) 150, (byte) 114, (byte) 43, (byte) 244, (byte) 247,
+ (byte) 11, (byte) 255, (byte) 0, (byte) 179, (byte) 87, (byte) 22, (byte) 150, (byte) 11, (byte) 213,
+ (byte) 102, (byte) 157, (byte) 125, (byte) 196, (byte) 135, (byte) 250, (byte) 154, (byte) 222, (byte) 27,
+ (byte) 25, (byte) 200, (byte) 212, (byte) 183, (byte) 185, (byte) 184, (byte) 135, (byte) 30, (byte) 69,
+ (byte) 204, (byte) 208, (byte) 143, (byte) 250, (byte) 98, (byte) 251, (byte) 127, (byte) 149, (byte) 91,
+ (byte) 254, (byte) 209, (byte) 191, (byte) 63, (byte) 52, (byte) 151, (byte) 215, (byte) 19, (byte) 96,
+ (byte) 103, (byte) 247, (byte) 242, (byte) 180, (byte) 159, (byte) 204, (byte) 226, (byte) 178, (byte) 213,
+ (byte) 150, (byte) 217, (byte) 34, (byte) 71, (byte) 18, (byte) 76, (byte) 207, (byte) 38, (byte) 208,
+ (byte) 217, (byte) 203, (byte) 156, (byte) 140, (byte) 128, (byte) 121, (byte) 0, (byte) 1, (byte) 180,
+ (byte) 246, (byte) 207, (byte) 60, (byte) 231, (byte) 140, (byte) 77, (byte) 43, (byte) 19, (byte) 19,
+ (byte) 132, (byte) 141, (byte) 214, (byte) 77, (byte) 135, (byte) 104, (byte) 32, (byte) 156, (byte) 156,
+ (byte) 113, (byte) 156, (byte) 86, (byte) 150, (byte) 68, (byte) 154, (byte) 209, (byte) 107, (byte) 26,
+ (byte) 132, (byte) 35, (byte) 17, (byte) 204, (byte) 136, (byte) 63, (byte) 217, (byte) 130, (byte) 32,
+ (byte) 127, (byte) 61, (byte) 185, (byte) 253, (byte) 106, (byte) 253, (byte) 134, (byte) 181, (byte) 117,
+ (byte) 115, (byte) 168, (byte) 90, (byte) 219, (byte) 204, (byte) 161, (byte) 214, (byte) 73, (byte) 146,
+ (byte) 51, (byte) 151, (byte) 144, (byte) 99, (byte) 115, (byte) 1, (byte) 192, (byte) 12, (byte) 6,
+ (byte) 121, (byte) 244, (byte) 197, (byte) 114, (byte) 210, (byte) 182, (byte) 162, (byte) 187, (byte) 124,
+ (byte) 152, (byte) 226, (byte) 101, (byte) 11, (byte) 243, (byte) 229, (byte) 246, (byte) 252, (byte) 222,
+ (byte) 221, (byte) 120, (byte) 171, (byte) 218, (byte) 20, (byte) 215, (byte) 103, (byte) 95, (byte) 211,
+ (byte) 146, (byte) 107, (byte) 95, (byte) 45, (byte) 126, (byte) 215, (byte) 15, (byte) 204, (byte) 31,
+ (byte) 112, (byte) 255, (byte) 0, (byte) 88, (byte) 190, (byte) 194, (byte) 165, (byte) 164, (byte) 23,
+ (byte) 61, (byte) 49, (byte) 34, (byte) 72, (byte) 163, (byte) 84, (byte) 69, (byte) 10, (byte) 160,
+ (byte) 96, (byte) 40, (byte) 24, (byte) 0, (byte) 82, (byte) 17, (byte) 252, (byte) 234, (byte) 96,
+ (byte) 50, (byte) 128, (byte) 251, (byte) 85, (byte) 123, (byte) 169, (byte) 225, (byte) 182, (byte) 129,
+ (byte) 230, (byte) 158, (byte) 69, (byte) 138, (byte) 40, (byte) 198, (byte) 89, (byte) 152, (byte) 224,
+ (byte) 10, (byte) 230, (byte) 53, (byte) 47, (byte) 104, (byte) 132, (byte) 13, (byte) 81, (byte) 51,
+ (byte) 221, (byte) 88, (byte) 15, (byte) 202, (byte) 138, (byte) 161, (byte) 225, (byte) 221, (byte) 62,
+ (byte) 255, (byte) 0, (byte) 87, (byte) 212, (byte) 33, (byte) 213, (byte) 231, (byte) 243, (byte) 44,
+ (byte) 244, (byte) 248, (byte) 78, (byte) 235, (byte) 104, (byte) 72, (byte) 195, (byte) 206, (byte) 113,
+ (byte) 141, (byte) 205, (byte) 232, (byte) 190, (byte) 131, (byte) 243, (byte) 246, (byte) 43, (byte) 88,
+ (byte) 232, (byte) 181, (byte) 33, (byte) 157, (byte) 85, (byte) 237, (byte) 220, (byte) 22, (byte) 216,
+ (byte) 251, (byte) 66, (byte) 72, (byte) 83, (byte) 25, (byte) 222, (byte) 177, (byte) 150, (byte) 11,
+ (byte) 245, (byte) 199, (byte) 74, (byte) 170, (byte) 154, (byte) 158, (byte) 143, (byte) 41, (byte) 194,
+ (byte) 222, (byte) 70, (byte) 173, (byte) 220, (byte) 59, (byte) 21, (byte) 35, (byte) 240, (byte) 61,
+ (byte) 43, (byte) 86, (byte) 177, (byte) 117, (byte) 63, (byte) 13, (byte) 165, (byte) 235, (byte) 249,
+ (byte) 182, (byte) 183, (byte) 114, (byte) 88, (byte) 200, (byte) 78, (byte) 91, (byte) 98, (byte) 171,
+ (byte) 163, (byte) 127, (byte) 192, (byte) 72, (byte) 224, (byte) 253, (byte) 49, (byte) 78, (byte) 200,
+ (byte) 69, (byte) 216, (byte) 141, (byte) 165, (byte) 193, (byte) 255, (byte) 0, (byte) 71, (byte) 186,
+ (byte) 142, (byte) 67, (byte) 219, (byte) 99, (byte) 131, (byte) 252, (byte) 169, (byte) 205, (byte) 103,
+ (byte) 201, (byte) 109, (byte) 192, (byte) 177, (byte) 234, (byte) 72, (byte) 228, (byte) 215, (byte) 51,
+ (byte) 55, (byte) 133, (byte) 181, (byte) 193, (byte) 247, (byte) 47, (byte) 244, (byte) 251, (byte) 128,
+ (byte) 58, (byte) 9, (byte) 173, (byte) 221, (byte) 79, (byte) 232, (byte) 216, (byte) 253, (byte) 42,
+ (byte) 31, (byte) 236, (byte) 175, (byte) 18, (byte) 218, (byte) 255, (byte) 0, (byte) 171, (byte) 211,
+ (byte) 173, (byte) 155, (byte) 31, (byte) 197, (byte) 109, (byte) 122, (byte) 99, (byte) 63, (byte) 150,
+ (byte) 223, (byte) 235, (byte) 71, (byte) 42, (byte) 29, (byte) 217, (byte) 208, (byte) 79, (byte) 161,
+ (byte) 199, (byte) 60, (byte) 134, (byte) 82, (byte) 89, (byte) 93, (byte) 186, (byte) 178, (byte) 185,
+ (byte) 244, (byte) 199, (byte) 126, (byte) 59, (byte) 85, (byte) 89, (byte) 60, (byte) 58, (byte) 88,
+ (byte) 96, (byte) 79, (byte) 43, (byte) 15, (byte) 250, (byte) 106, (byte) 21, (byte) 135, (byte) 233,
+ (byte) 138, (byte) 199, (byte) 55, (byte) 190, (byte) 35, (byte) 182, (byte) 63, (byte) 61, (byte) 142,
+ (byte) 176, (byte) 152, (byte) 234, (byte) 35, (byte) 242, (byte) 231, (byte) 95, (byte) 204, (byte) 146,
+ (byte) 105, (byte) 195, (byte) 197, (byte) 247, (byte) 86, (byte) 223, (byte) 241, (byte) 242, (byte) 215,
+ (byte) 49, (byte) 30, (byte) 255, (byte) 0, (byte) 104, (byte) 177, (byte) 112, (byte) 63, (byte) 48,
+ (byte) 160, (byte) 126, (byte) 180, (byte) 185, (byte) 16, (byte) 249, (byte) 153, (byte) 106, (byte) 79,
+ (byte) 11, (byte) 47, (byte) 95, (byte) 46, (byte) 217, (byte) 207, (byte) 253, (byte) 123, (byte) 108,
+ (byte) 253, (byte) 121, (byte) 170, (byte) 146, (byte) 120, (byte) 85, (byte) 59, (byte) 219, (byte) 64,
+ (byte) 73, (byte) 254, (byte) 228, (byte) 207, (byte) 159, (byte) 200, (byte) 224, (byte) 85, (byte) 136,
+ (byte) 188, (byte) 117, (byte) 1, (byte) 225, (byte) 174, (byte) 244, (byte) 246, (byte) 99, (byte) 252,
+ (byte) 38, (byte) 79, (byte) 44, (byte) 254, (byte) 68, (byte) 154, (byte) 209, (byte) 139, (byte) 196,
+ (byte) 194, (byte) 84, (byte) 207, (byte) 216, (byte) 252, (byte) 193, (byte) 216, (byte) 67, (byte) 40,
+ (byte) 124, (byte) 254, (byte) 96, (byte) 15, (byte) 214, (byte) 151, (byte) 32, (byte) 115, (byte) 28,
+ (byte) 228, (byte) 190, (byte) 18, (byte) 5, (byte) 24, (byte) 27, (byte) 107, (byte) 133, (byte) 82,
+ (byte) 48, (byte) 64, (byte) 146, (byte) 50, (byte) 63, (byte) 46, (byte) 77, (byte) 55, (byte) 73,
+ (byte) 240, (byte) 230, (byte) 172, (byte) 111, (byte) 110, (byte) 110, (byte) 103, (byte) 185, (byte) 48,
+ (byte) 172, (byte) 108, (byte) 241, (byte) 192, (byte) 38, (byte) 82, (byte) 204, (byte) 232, (byte) 72,
+ (byte) 231, (byte) 253, (byte) 145, (byte) 242, (byte) 143, (byte) 199, (byte) 61, (byte) 59, (byte) 245,
+ (byte) 81, (byte) 248, (byte) 130, (byte) 193, (byte) 254, (byte) 253, (byte) 172, (byte) 209, (byte) 99,
+ (byte) 174, (byte) 228, (byte) 94, (byte) 63, (byte) 34, (byte) 106, (byte) 117, (byte) 213, (byte) 180,
+ (byte) 167, (byte) 255, (byte) 0, (byte) 150, (byte) 165, (byte) 127, (byte) 222, (byte) 71, (byte) 31,
+ (byte) 210, (byte) 151, (byte) 35, (byte) 31, (byte) 49, (byte) 206, (byte) 71, (byte) 225, (byte) 235,
+ (byte) 232, (byte) 99, (byte) 49, (byte) 175, (byte) 216, (byte) 221, (byte) 76, (byte) 143, (byte) 38,
+ (byte) 30, (byte) 70, (byte) 234, (byte) 204, (byte) 91, (byte) 166, (byte) 223, (byte) 124, (byte) 126,
+ (byte) 21, (byte) 47, (byte) 135, (byte) 188, (byte) 48, (byte) 154, (byte) 76, (byte) 179, (byte) 93,
+ (byte) 207, (byte) 181, (byte) 238, (byte) 100, (byte) 118, (byte) 217, (byte) 180, (byte) 252, (byte) 177,
+ (byte) 169, (byte) 61, (byte) 184, (byte) 228, (byte) 145, (byte) 140, (byte) 159, (byte) 192, (byte) 119,
+ (byte) 39, (byte) 163, (byte) 91, (byte) 189, (byte) 57, (byte) 248, (byte) 75, (byte) 216, (byte) 24,
+ (byte) 158, (byte) 194, (byte) 85, (byte) 205, (byte) 76, (byte) 45, (byte) 209, (byte) 134, (byte) 84,
+ (byte) 130, (byte) 15, (byte) 124, (byte) 102, (byte) 151, (byte) 43, (byte) 14, (byte) 100, (byte) 84,
+ (byte) 219, (byte) 207, (byte) 184, (byte) 170, (byte) 151, (byte) 247, (byte) 43, (byte) 12, (byte) 100,
+ (byte) 117, (byte) 61, (byte) 14, (byte) 63, (byte) 149, (byte) 106, (byte) 61, (byte) 190, (byte) 216,
+ (byte) 216, (byte) 134, (byte) 3, (byte) 3, (byte) 60, (byte) 10, (byte) 229, (byte) 238, (byte) 93,
+ (byte) 166, (byte) 148, (byte) 147, (byte) 156, (byte) 3, (byte) 128, (byte) 42, (byte) 90, (byte) 177,
+ (byte) 73, (byte) 220, (byte) 169, (byte) 41, (byte) 105, (byte) 92, (byte) 187, (byte) 117, (byte) 53,
+ (byte) 3, (byte) 165, (byte) 91, (byte) 43, (byte) 219, (byte) 244, (byte) 172, (byte) 248, (byte) 228,
+ (byte) 187, (byte) 214, (byte) 47, (byte) 26, (byte) 195, (byte) 68, (byte) 69, (byte) 145, (byte) 208,
+ (byte) 226, (byte) 107, (byte) 182, (byte) 25, (byte) 138, (byte) 15, (byte) 254, (byte) 41, (byte) 189,
+ (byte) 191, (byte) 62, (byte) 132, (byte) 80, (byte) 149, (byte) 193, (byte) 153, (byte) 186, (byte) 246,
+ (byte) 211, (byte) 164, (byte) 94, (byte) 219, (byte) 161, (byte) 221, (byte) 57, (byte) 133, (byte) 29,
+ (byte) 34, (byte) 31, (byte) 120, (byte) 129, (byte) 52, (byte) 121, (byte) 56, (byte) 244, (byte) 255,
+ (byte) 0, (byte) 3, (byte) 88, (byte) 87, (byte) 54, (byte) 90, (byte) 91, (byte) 70, (byte) 162,
+ (byte) 29, (byte) 118, (byte) 25, (byte) 153, (byte) 3, (byte) 62, (byte) 193, (byte) 98, (byte) 97,
+ (byte) 125, (byte) 193, (byte) 51, (byte) 140, (byte) 224, (byte) 100, (byte) 18, (byte) 161, (byte) 112,
+ (byte) 79, (byte) 4, (byte) 231, (byte) 28, (byte) 147, (byte) 94, (byte) 181, (byte) 166, (byte) 120,
+ (byte) 67, (byte) 75, (byte) 177, (byte) 179, (byte) 120, (byte) 102, (byte) 139, (byte) 237, (byte) 147,
+ (byte) 79, (byte) 131, (byte) 61, (byte) 196, (byte) 220, (byte) 188, (byte) 135, (byte) 235, (byte) 216,
+ (byte) 123, (byte) 10, (byte) 124, (byte) 222, (byte) 19, (byte) 211, (byte) 93, (byte) 54, (byte) 196,
+ (byte) 247, (byte) 80, (byte) 127, (byte) 185, (byte) 59, (byte) 17, (byte) 244, (byte) 195, (byte) 100,
+ (byte) 126, (byte) 149, (byte) 180, (byte) 116, (byte) 86, (byte) 51, (byte) 111, (byte) 83, (byte) 197,
+ (byte) 26, (byte) 12, (byte) 188, (byte) 108, (byte) 73, (byte) 83, (byte) 27, (byte) 110, (byte) 7,
+ (byte) 29, (byte) 240, (byte) 71, (byte) 245, (byte) 171, (byte) 34, (byte) 95, (byte) 246, (byte) 114,
+ (byte) 58, (byte) 115, (byte) 197, (byte) 122, (byte) 140, (byte) 190, (byte) 2, (byte) 183, (byte) 111,
+ (byte) 185, (byte) 120, (byte) 157, (byte) 115, (byte) 137, (byte) 44, (byte) 45, (byte) 219, (byte) 245,
+ (byte) 8, (byte) 15, (byte) 235, (byte) 84, (byte) 102, (byte) 248, (byte) 124, (byte) 255, (byte) 0,
+ (byte) 193, (byte) 253, (byte) 157, (byte) 39, (byte) 185, (byte) 142, (byte) 116, (byte) 63, (byte) 248,
+ (byte) 236, (byte) 184, (byte) 253, (byte) 42, (byte) 249, (byte) 137, (byte) 177, (byte) 196, (byte) 232,
+ (byte) 250, (byte) 116, (byte) 26, (byte) 133, (byte) 196, (byte) 177, (byte) 207, (byte) 36, (byte) 232,
+ (byte) 171, (byte) 30, (byte) 71, (byte) 145, (byte) 24, (byte) 115, (byte) 156, (byte) 129, (byte) 158,
+ (byte) 189, (byte) 6, (byte) 106, (byte) 118, (byte) 183, (byte) 142, (byte) 203, (byte) 197, (byte) 22,
+ (byte) 241, (byte) 195, (byte) 191, (byte) 202, (byte) 23, (byte) 49, (byte) 58, (byte) 110, (byte) 77,
+ (byte) 188, (byte) 22, (byte) 7, (byte) 212, (byte) 156, (byte) 3, (byte) 145, (byte) 215, (byte) 181,
+ (byte) 116, (byte) 167, (byte) 193, (byte) 23, (byte) 246, (byte) 239, (byte) 190, (byte) 11, (byte) 82,
+ (byte) 174, (byte) 58, (byte) 61, (byte) 174, (byte) 163, (byte) 229, (byte) 159, (byte) 195, (byte) 116,
+ (byte) 68, (byte) 255, (byte) 0, (byte) 227, (byte) 213, (byte) 93, (byte) 188, (byte) 35, (byte) 173,
+ (byte) 155, (byte) 184, (byte) 238, (byte) 166, (byte) 183, (byte) 184, (byte) 118, (byte) 71, (byte) 83,
+ (byte) 243, (byte) 92, (byte) 164, (byte) 206, (byte) 66, (byte) 158, (byte) 57, (byte) 37, (byte) 106,
+ (byte) 44, (byte) 249, (byte) 249, (byte) 175, (byte) 167, (byte) 99, (byte) 75, (byte) 195, (byte) 146,
+ (byte) 214, (byte) 215, (byte) 189, (byte) 255, (byte) 0, (byte) 67, (byte) 110, (byte) 238, (byte) 242,
+ (byte) 223, (byte) 79, (byte) 178, (byte) 251, (byte) 69, (byte) 204, (byte) 155, (byte) 16, (byte) 0,
+ (byte) 56, (byte) 25, (byte) 44, (byte) 79, (byte) 64, (byte) 7, (byte) 114, (byte) 125, (byte) 41,
+ (byte) 52, (byte) 127, (byte) 14, (byte) 220, (byte) 106, (byte) 247, (byte) 17, (byte) 234, (byte) 154,
+ (byte) 236, (byte) 94, (byte) 92, (byte) 40, (byte) 119, (byte) 91, (byte) 88, (byte) 30, (byte) 139,
+ (byte) 232, (byte) 242, (byte) 122, (byte) 183, (byte) 183, (byte) 111, (byte) 207, (byte) 55, (byte) 52,
+ (byte) 95, (byte) 13, (byte) 204, (byte) 247, (byte) 73, (byte) 171, (byte) 107, (byte) 155, (byte) 94,
+ (byte) 237, (byte) 127, (byte) 212, (byte) 91, (byte) 41, (byte) 204, (byte) 118, (byte) 163, (byte) 219,
+ (byte) 213, (byte) 189, (byte) 91, (byte) 250, (byte) 99, (byte) 29, (byte) 53, (byte) 76, (byte) 99,
+ (byte) 97, (byte) 54, (byte) 0, (byte) 1, (byte) 192, (byte) 224, (byte) 81, (byte) 75, (byte) 69,
+ (byte) 89, (byte) 33, (byte) 69, (byte) 20, (byte) 80, (byte) 1, (byte) 73, (byte) 69, (byte) 20, (byte) 0,
+ (byte) 180, (byte) 152, (byte) 207, (byte) 90, (byte) 40, (byte) 160, (byte) 10, (byte) 243, (byte) 88,
+ (byte) 89, (byte) 220, (byte) 12, (byte) 77, (byte) 105, (byte) 4, (byte) 128, (byte) 255, (byte) 0,
+ (byte) 122, (byte) 48, (byte) 107, (byte) 54, (byte) 111, (byte) 7, (byte) 120, (byte) 114, (byte) 115,
+ (byte) 185, (byte) 244, (byte) 123, (byte) 96, (byte) 222, (byte) 168, (byte) 155, (byte) 79, (byte) 233,
+ (byte) 69, (byte) 20, (byte) 1, (byte) 89, (byte) 188, (byte) 17, (byte) 165, (byte) 143, (byte) 248,
+ (byte) 247, (byte) 184, (byte) 212, (byte) 45, (byte) 135, (byte) 101, (byte) 138, (byte) 241, (byte) 246,
+ (byte) 143, (byte) 192, (byte) 146, (byte) 42, (byte) 7, (byte) 240, (byte) 93, (byte) 194, (byte) 255,
+ (byte) 0, (byte) 199, (byte) 182, (byte) 191, (byte) 118, (byte) 163, (byte) 178, (byte) 205, (byte) 20,
+ (byte) 114, (byte) 126, (byte) 187, (byte) 115, (byte) 69, (byte) 20, (byte) 92, (byte) 8, (byte) 31,
+ (byte) 194, (byte) 254, (byte) 32, (byte) 143, (byte) 136, (byte) 181, (byte) 27, (byte) 9, (byte) 215,
+ (byte) 210, (byte) 88, (byte) 29, (byte) 79, (byte) 232, (byte) 216, (byte) 253, (byte) 42, (byte) 164,
+ (byte) 154, (byte) 39, (byte) 136, (byte) 225, (byte) 231, (byte) 251, (byte) 54, (byte) 218, (byte) 95,
+ (byte) 246, (byte) 173, (byte) 175, (byte) 154, (byte) 35, (byte) 255, (byte) 0, (byte) 160, (byte) 231,
+ (byte) 245, (byte) 162, (byte) 138, (byte) 119, (byte) 1, (byte) 26, (byte) 125, (byte) 122, (byte) 216,
+ (byte) 98, (byte) 77, (byte) 47, (byte) 88, (byte) 140, (byte) 142, (byte) 134, (byte) 23, (byte) 89,
+ (byte) 64, (byte) 252, (byte) 11, (byte) 16, (byte) 127, (byte) 21, (byte) 52, (byte) 209, (byte) 173,
+ (byte) 100, (byte) 236, (byte) 187, (byte) 211, (byte) 111, (byte) 195, (byte) 147, (byte) 247, (byte) 163,
+ (byte) 178, (byte) 144, (byte) 17, (byte) 245, (byte) 24, (byte) 193, (byte) 247, (byte) 32, (byte) 253,
+ (byte) 5, (byte) 20, (byte) 82, (byte) 105, (byte) 49, (byte) 167, (byte) 97, (byte) 214, (byte) 218,
+ (byte) 62, (byte) 163, (byte) 226, (byte) 89, (byte) 74, (byte) 186, (byte) 207, (byte) 167, (byte) 105,
+ (byte) 32, (byte) 225, (byte) 153, (byte) 148, (byte) 164, (byte) 247, (byte) 62, (byte) 192, (byte) 117,
+ (byte) 69, (byte) 253, (byte) 79, (byte) 183, (byte) 34, (byte) 187, (byte) 75, (byte) 13, (byte) 62,
+ (byte) 211, (byte) 75, (byte) 179, (byte) 142, (byte) 210, (byte) 202, (byte) 4, (byte) 130, (byte) 24,
+ (byte) 198, (byte) 21, (byte) 84, (byte) 81, (byte) 69, (byte) 36, (byte) 172, (byte) 13, (byte) 220,
+ (byte) 181, (byte) 69, (byte) 20, (byte) 83, (byte) 16, (byte) 81, (byte) 69, (byte) 20, (byte) 0,
+ (byte) 148, (byte) 81, (byte) 69, (byte) 0, (byte) 45, (byte) 20, (byte) 81, (byte) 64, (byte) 5,
+ (byte) 20, (byte) 81, (byte) 64, (byte) 31, (byte) 255, (byte) 217
+
+ };
+
+}
diff --git a/src/net/sourceforge/plantuml/eggs/PSystemAppleTwoFactory.java b/src/net/sourceforge/plantuml/eggs/PSystemAppleTwoFactory.java
new file mode 100644
index 0000000..64a13ef
--- /dev/null
+++ b/src/net/sourceforge/plantuml/eggs/PSystemAppleTwoFactory.java
@@ -0,0 +1,60 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.eggs;
+
+import java.io.IOException;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.Log;
+import net.sourceforge.plantuml.command.PSystemSingleLineFactory;
+
+public class PSystemAppleTwoFactory extends PSystemSingleLineFactory {
+
+ @Override
+ protected AbstractPSystem executeLine(String line) {
+ if (line.equalsIgnoreCase("apple //e") || line.equalsIgnoreCase("apple ][")
+ || line.equalsIgnoreCase("apple II") || line.equalsIgnoreCase("Steve Jobs")
+ || line.equalsIgnoreCase("Steve Wozniak")) {
+ try {
+ return new PSystemAppleTwo();
+ } catch (IOException e) {
+ Log.error("Error " + e);
+ e.printStackTrace();
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/eggs/PSystemCharlie.java b/src/net/sourceforge/plantuml/eggs/PSystemCharlie.java
new file mode 100644
index 0000000..e6ef41d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/eggs/PSystemCharlie.java
@@ -0,0 +1,79 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.eggs;
+
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.core.DiagramDescription;
+import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+import net.sourceforge.plantuml.ugraphic.ImageBuilder;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UImage;
+import net.sourceforge.plantuml.version.PSystemVersion;
+
+public class PSystemCharlie extends AbstractPSystem {
+
+ private BufferedImage image;
+
+ PSystemCharlie() {
+ image = PSystemVersion.getCharlieImage();
+ }
+
+ public ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormat) throws IOException {
+ final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, HtmlColorUtils.BLACK,
+ getMetadata(), null, 0, 0, null, false);
+ imageBuilder.addUDrawable(new UDrawable() {
+
+ public void drawU(UGraphic ug) {
+ final UImage im = new UImage(image);
+ ug.draw(im);
+ }
+ });
+ return imageBuilder.writeImageTOBEMOVED(fileFormat.getFileFormat(), os);
+ }
+
+ public DiagramDescription getDescription() {
+ return new DiagramDescriptionImpl("(Version)", getClass());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/eggs/PSystemCharlieFactory.java b/src/net/sourceforge/plantuml/eggs/PSystemCharlieFactory.java
new file mode 100644
index 0000000..44e7998
--- /dev/null
+++ b/src/net/sourceforge/plantuml/eggs/PSystemCharlieFactory.java
@@ -0,0 +1,50 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.eggs;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.command.PSystemSingleLineFactory;
+
+public class PSystemCharlieFactory extends PSystemSingleLineFactory {
+
+ @Override
+ protected AbstractPSystem executeLine(String line) {
+ if (line.equalsIgnoreCase("charlie") || line.equalsIgnoreCase("jesuischarlie")) {
+ return new PSystemCharlie();
+ }
+ return null;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/eggs/PSystemEgg.java b/src/net/sourceforge/plantuml/eggs/PSystemEgg.java
new file mode 100644
index 0000000..58c49fb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/eggs/PSystemEgg.java
@@ -0,0 +1,84 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.eggs;
+
+import java.awt.Font;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.core.DiagramDescription;
+import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.graphic.GraphicStrings;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+import net.sourceforge.plantuml.ugraphic.ImageBuilder;
+import net.sourceforge.plantuml.ugraphic.UAntiAliasing;
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public class PSystemEgg extends AbstractPSystem {
+
+ private final List<String> strings = new ArrayList<String>();
+
+ PSystemEgg(String sentence) {
+ final StringTokenizer st = new StringTokenizer(sentence, "|");
+ while (st.hasMoreTokens()) {
+ strings.add(st.nextToken());
+ }
+ }
+
+ public ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormat) throws IOException {
+ final GraphicStrings result = getGraphicStrings();
+ final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(),
+ getMetadata(), null, 0, 0, null, false);
+ imageBuilder.addUDrawable(result);
+ return imageBuilder.writeImageTOBEMOVED(fileFormat.getFileFormat(), os);
+ }
+
+ private GraphicStrings getGraphicStrings() throws IOException {
+ final UFont font = new UFont("SansSerif", Font.PLAIN, 12);
+ return new GraphicStrings(strings, font, HtmlColorUtils.BLACK, HtmlColorUtils.WHITE, UAntiAliasing.ANTI_ALIASING_ON);
+ }
+
+ public DiagramDescription getDescription() {
+ return new DiagramDescriptionImpl("(Easter Eggs)", getClass());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/eggs/PSystemEggFactory.java b/src/net/sourceforge/plantuml/eggs/PSystemEggFactory.java
new file mode 100644
index 0000000..70dd4fe
--- /dev/null
+++ b/src/net/sourceforge/plantuml/eggs/PSystemEggFactory.java
@@ -0,0 +1,67 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.eggs;
+
+import java.io.UnsupportedEncodingException;
+import java.util.Arrays;
+import java.util.List;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.command.PSystemSingleLineFactory;
+
+public class PSystemEggFactory extends PSystemSingleLineFactory {
+
+ final static private List<byte[]> all = Arrays
+ .asList(EggUtils
+ .toByteArrays("56092d35fce86a0dd88047a766c1d6541a7c5fd5ba212fa02db9a32a463422febd71a75a934eb135dec7d6c6325ddd17fd2fa437eba863462b28e3e92514998306a72790d93501335ed6b1262ea46ab79573142c28f8e92508978255a533d9cf7903394f9ab73a33b230a2b273033633adf16044888243b92f9bd8351f3d4f9aa2302fb264afa37546368424fa6a07919152bd2990d935092e49d9a02038b437aeb528"),
+ EggUtils.toByteArrays("421e5b773c5df733a1194f716f18e8842155196b3b"));
+
+ @Override
+ protected AbstractPSystem executeLine(String line) {
+ try {
+ for (byte[] crypted : all) {
+ final SentenceDecoder decoder = new SentenceDecoder(line, crypted);
+ if (decoder.isOk()) {
+ return new PSystemEgg(decoder.getSecret());
+ }
+ }
+ } catch (UnsupportedEncodingException e) {
+ return null;
+ }
+
+ return null;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/eggs/PSystemLost.java b/src/net/sourceforge/plantuml/eggs/PSystemLost.java
new file mode 100644
index 0000000..0e0442f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/eggs/PSystemLost.java
@@ -0,0 +1,81 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.eggs;
+
+import java.awt.Font;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.core.DiagramDescription;
+import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.graphic.GraphicStrings;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+import net.sourceforge.plantuml.ugraphic.ImageBuilder;
+import net.sourceforge.plantuml.ugraphic.UAntiAliasing;
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public class PSystemLost extends AbstractPSystem {
+
+ private final List<String> strings = new ArrayList<String>();
+
+ public PSystemLost() {
+ strings.add("Thank you for choosing Oceanic Airlines.");
+ }
+
+ public ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormat) throws IOException {
+ final GraphicStrings result = getGraphicStrings();
+ final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(),
+ getMetadata(), null, 0, 0, null, false);
+ imageBuilder.addUDrawable(result);
+ return imageBuilder.writeImageTOBEMOVED(fileFormat.getFileFormat(), os);
+ }
+
+ private GraphicStrings getGraphicStrings() throws IOException {
+ final UFont font = new UFont("SansSerif", Font.PLAIN, 12);
+ return new GraphicStrings(strings, font, HtmlColorUtils.BLACK, HtmlColorUtils.WHITE, UAntiAliasing.ANTI_ALIASING_ON, null,
+ null);
+ }
+
+ public DiagramDescription getDescription() {
+ return new DiagramDescriptionImpl("(Lost)", getClass());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/eggs/PSystemLostFactory.java b/src/net/sourceforge/plantuml/eggs/PSystemLostFactory.java
new file mode 100644
index 0000000..0a403de
--- /dev/null
+++ b/src/net/sourceforge/plantuml/eggs/PSystemLostFactory.java
@@ -0,0 +1,50 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.eggs;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.command.PSystemSingleLineFactory;
+
+public class PSystemLostFactory extends PSystemSingleLineFactory {
+
+ @Override
+ protected AbstractPSystem executeLine(String line) {
+ if (line.matches("^4\\D+8\\D+15\\D+16\\D+23\\D+42")) {
+ return new PSystemLost();
+ }
+ return null;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/eggs/PSystemPath.java b/src/net/sourceforge/plantuml/eggs/PSystemPath.java
new file mode 100644
index 0000000..4ff71a6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/eggs/PSystemPath.java
@@ -0,0 +1,67 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.eggs;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.core.DiagramDescription;
+import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+
+public class PSystemPath extends AbstractPSystem {
+
+ private final GraphicsPath path;
+
+ public PSystemPath(String s) {
+ this.path = new GraphicsPath(new ColorMapperIdentity(), s);
+ }
+
+
+ public ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormat) throws IOException {
+ return path.writeImage(os);
+ }
+
+ public DiagramDescription getDescription() {
+ return new DiagramDescriptionImpl("(Path)", getClass());
+ }
+
+
+
+
+}
diff --git a/src/net/sourceforge/plantuml/eggs/PSystemPathFactory.java b/src/net/sourceforge/plantuml/eggs/PSystemPathFactory.java
new file mode 100644
index 0000000..7988ecd
--- /dev/null
+++ b/src/net/sourceforge/plantuml/eggs/PSystemPathFactory.java
@@ -0,0 +1,57 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.eggs;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.command.PSystemSingleLineFactory;
+import net.sourceforge.plantuml.command.regex.MyPattern;
+
+public class PSystemPathFactory extends PSystemSingleLineFactory {
+
+ final private static Pattern p = MyPattern.cmpile("(?i)^path[%s]+([0-9A-Za-z]+)$");
+
+ @Override
+ protected AbstractPSystem executeLine(String line) {
+ final Matcher m = p.matcher(line);
+ if (m.find() == false) {
+ return null;
+ }
+ return new PSystemPath(m.group(1));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/eggs/PSystemRIP.java b/src/net/sourceforge/plantuml/eggs/PSystemRIP.java
new file mode 100644
index 0000000..e88f56f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/eggs/PSystemRIP.java
@@ -0,0 +1,470 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.eggs;
+
+import java.awt.Font;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.imageio.ImageIO;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.core.DiagramDescription;
+import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.graphic.GraphicPosition;
+import net.sourceforge.plantuml.graphic.GraphicStrings;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+import net.sourceforge.plantuml.ugraphic.ImageBuilder;
+import net.sourceforge.plantuml.ugraphic.UAntiAliasing;
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public class PSystemRIP extends AbstractPSystem {
+
+ private final List<String> strings = new ArrayList<String>();
+ private final BufferedImage image;
+
+ public PSystemRIP() throws IOException {
+ strings.add(" To my Grandfather,");
+ strings.add(" A mon grand-pere,");
+ strings.add(" ");
+ strings.add(" <b>Jean CANOUET");
+ strings.add(" ");
+ strings.add(" 31-OCT-1921 <i>(Neuilly-Sur-Seine, France)");
+ strings.add(" 15-SEP-2009 <i>(Nanterre, France)");
+ strings.add(" ");
+ strings.add(" <b>Requiescat In Pace");
+ strings.add(" ");
+
+ final InputStream is = new ByteArrayInputStream(imm);
+ image = ImageIO.read(is);
+ is.close();
+ }
+
+
+ public ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormat) throws IOException {
+ final GraphicStrings result = getGraphicStrings();
+ final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(),
+ getMetadata(), null, 0, 0, null, false);
+ imageBuilder.addUDrawable(result);
+ return imageBuilder.writeImageTOBEMOVED(fileFormat.getFileFormat(), os);
+ }
+
+
+ private GraphicStrings getGraphicStrings() throws IOException {
+ final UFont font = new UFont("SansSerif", Font.PLAIN, 12);
+ return new GraphicStrings(strings, font, HtmlColorUtils.BLACK, HtmlColorUtils.WHITE, UAntiAliasing.ANTI_ALIASING_ON,
+ image, GraphicPosition.BOTTOM);
+ }
+
+ public DiagramDescription getDescription() {
+ return new DiagramDescriptionImpl("(RIP)", getClass());
+ }
+
+ private static final byte imm[] = new byte[] { (byte) 255, (byte) 216, (byte) 255, (byte) 224, (byte) 0, (byte) 16,
+ (byte) 74, (byte) 70, (byte) 73, (byte) 70, (byte) 0, (byte) 1, (byte) 1, (byte) 1, (byte) 2, (byte) 88,
+ (byte) 2, (byte) 88, (byte) 0, (byte) 0, (byte) 255, (byte) 219, (byte) 0, (byte) 67, (byte) 0, (byte) 13,
+ (byte) 9, (byte) 10, (byte) 11, (byte) 10, (byte) 8, (byte) 13, (byte) 11, (byte) 10, (byte) 11, (byte) 14,
+ (byte) 14, (byte) 13, (byte) 15, (byte) 19, (byte) 32, (byte) 21, (byte) 19, (byte) 18, (byte) 18,
+ (byte) 19, (byte) 39, (byte) 28, (byte) 30, (byte) 23, (byte) 32, (byte) 46, (byte) 41, (byte) 49,
+ (byte) 48, (byte) 46, (byte) 41, (byte) 45, (byte) 44, (byte) 51, (byte) 58, (byte) 74, (byte) 62,
+ (byte) 51, (byte) 54, (byte) 70, (byte) 55, (byte) 44, (byte) 45, (byte) 64, (byte) 87, (byte) 65,
+ (byte) 70, (byte) 76, (byte) 78, (byte) 82, (byte) 83, (byte) 82, (byte) 50, (byte) 62, (byte) 90,
+ (byte) 97, (byte) 90, (byte) 80, (byte) 96, (byte) 74, (byte) 81, (byte) 82, (byte) 79, (byte) 255,
+ (byte) 219, (byte) 0, (byte) 67, (byte) 1, (byte) 14, (byte) 14, (byte) 14, (byte) 19, (byte) 17,
+ (byte) 19, (byte) 38, (byte) 21, (byte) 21, (byte) 38, (byte) 79, (byte) 53, (byte) 45, (byte) 53,
+ (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79,
+ (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79,
+ (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79,
+ (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79,
+ (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79,
+ (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 79, (byte) 255, (byte) 192, (byte) 0, (byte) 17,
+ (byte) 8, (byte) 0, (byte) 135, (byte) 0, (byte) 162, (byte) 3, (byte) 1, (byte) 34, (byte) 0, (byte) 2,
+ (byte) 17, (byte) 1, (byte) 3, (byte) 17, (byte) 1, (byte) 255, (byte) 196, (byte) 0, (byte) 31, (byte) 0,
+ (byte) 0, (byte) 1, (byte) 5, (byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 0,
+ (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 1, (byte) 2, (byte) 3,
+ (byte) 4, (byte) 5, (byte) 6, (byte) 7, (byte) 8, (byte) 9, (byte) 10, (byte) 11, (byte) 255, (byte) 196,
+ (byte) 0, (byte) 181, (byte) 16, (byte) 0, (byte) 2, (byte) 1, (byte) 3, (byte) 3, (byte) 2, (byte) 4,
+ (byte) 3, (byte) 5, (byte) 5, (byte) 4, (byte) 4, (byte) 0, (byte) 0, (byte) 1, (byte) 125, (byte) 1,
+ (byte) 2, (byte) 3, (byte) 0, (byte) 4, (byte) 17, (byte) 5, (byte) 18, (byte) 33, (byte) 49, (byte) 65,
+ (byte) 6, (byte) 19, (byte) 81, (byte) 97, (byte) 7, (byte) 34, (byte) 113, (byte) 20, (byte) 50,
+ (byte) 129, (byte) 145, (byte) 161, (byte) 8, (byte) 35, (byte) 66, (byte) 177, (byte) 193, (byte) 21,
+ (byte) 82, (byte) 209, (byte) 240, (byte) 36, (byte) 51, (byte) 98, (byte) 114, (byte) 130, (byte) 9,
+ (byte) 10, (byte) 22, (byte) 23, (byte) 24, (byte) 25, (byte) 26, (byte) 37, (byte) 38, (byte) 39,
+ (byte) 40, (byte) 41, (byte) 42, (byte) 52, (byte) 53, (byte) 54, (byte) 55, (byte) 56, (byte) 57,
+ (byte) 58, (byte) 67, (byte) 68, (byte) 69, (byte) 70, (byte) 71, (byte) 72, (byte) 73, (byte) 74,
+ (byte) 83, (byte) 84, (byte) 85, (byte) 86, (byte) 87, (byte) 88, (byte) 89, (byte) 90, (byte) 99,
+ (byte) 100, (byte) 101, (byte) 102, (byte) 103, (byte) 104, (byte) 105, (byte) 106, (byte) 115, (byte) 116,
+ (byte) 117, (byte) 118, (byte) 119, (byte) 120, (byte) 121, (byte) 122, (byte) 131, (byte) 132, (byte) 133,
+ (byte) 134, (byte) 135, (byte) 136, (byte) 137, (byte) 138, (byte) 146, (byte) 147, (byte) 148, (byte) 149,
+ (byte) 150, (byte) 151, (byte) 152, (byte) 153, (byte) 154, (byte) 162, (byte) 163, (byte) 164, (byte) 165,
+ (byte) 166, (byte) 167, (byte) 168, (byte) 169, (byte) 170, (byte) 178, (byte) 179, (byte) 180, (byte) 181,
+ (byte) 182, (byte) 183, (byte) 184, (byte) 185, (byte) 186, (byte) 194, (byte) 195, (byte) 196, (byte) 197,
+ (byte) 198, (byte) 199, (byte) 200, (byte) 201, (byte) 202, (byte) 210, (byte) 211, (byte) 212, (byte) 213,
+ (byte) 214, (byte) 215, (byte) 216, (byte) 217, (byte) 218, (byte) 225, (byte) 226, (byte) 227, (byte) 228,
+ (byte) 229, (byte) 230, (byte) 231, (byte) 232, (byte) 233, (byte) 234, (byte) 241, (byte) 242, (byte) 243,
+ (byte) 244, (byte) 245, (byte) 246, (byte) 247, (byte) 248, (byte) 249, (byte) 250, (byte) 255, (byte) 196,
+ (byte) 0, (byte) 31, (byte) 1, (byte) 0, (byte) 3, (byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 1,
+ (byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0,
+ (byte) 1, (byte) 2, (byte) 3, (byte) 4, (byte) 5, (byte) 6, (byte) 7, (byte) 8, (byte) 9, (byte) 10,
+ (byte) 11, (byte) 255, (byte) 196, (byte) 0, (byte) 181, (byte) 17, (byte) 0, (byte) 2, (byte) 1, (byte) 2,
+ (byte) 4, (byte) 4, (byte) 3, (byte) 4, (byte) 7, (byte) 5, (byte) 4, (byte) 4, (byte) 0, (byte) 1,
+ (byte) 2, (byte) 119, (byte) 0, (byte) 1, (byte) 2, (byte) 3, (byte) 17, (byte) 4, (byte) 5, (byte) 33,
+ (byte) 49, (byte) 6, (byte) 18, (byte) 65, (byte) 81, (byte) 7, (byte) 97, (byte) 113, (byte) 19,
+ (byte) 34, (byte) 50, (byte) 129, (byte) 8, (byte) 20, (byte) 66, (byte) 145, (byte) 161, (byte) 177,
+ (byte) 193, (byte) 9, (byte) 35, (byte) 51, (byte) 82, (byte) 240, (byte) 21, (byte) 98, (byte) 114,
+ (byte) 209, (byte) 10, (byte) 22, (byte) 36, (byte) 52, (byte) 225, (byte) 37, (byte) 241, (byte) 23,
+ (byte) 24, (byte) 25, (byte) 26, (byte) 38, (byte) 39, (byte) 40, (byte) 41, (byte) 42, (byte) 53,
+ (byte) 54, (byte) 55, (byte) 56, (byte) 57, (byte) 58, (byte) 67, (byte) 68, (byte) 69, (byte) 70,
+ (byte) 71, (byte) 72, (byte) 73, (byte) 74, (byte) 83, (byte) 84, (byte) 85, (byte) 86, (byte) 87,
+ (byte) 88, (byte) 89, (byte) 90, (byte) 99, (byte) 100, (byte) 101, (byte) 102, (byte) 103, (byte) 104,
+ (byte) 105, (byte) 106, (byte) 115, (byte) 116, (byte) 117, (byte) 118, (byte) 119, (byte) 120, (byte) 121,
+ (byte) 122, (byte) 130, (byte) 131, (byte) 132, (byte) 133, (byte) 134, (byte) 135, (byte) 136, (byte) 137,
+ (byte) 138, (byte) 146, (byte) 147, (byte) 148, (byte) 149, (byte) 150, (byte) 151, (byte) 152, (byte) 153,
+ (byte) 154, (byte) 162, (byte) 163, (byte) 164, (byte) 165, (byte) 166, (byte) 167, (byte) 168, (byte) 169,
+ (byte) 170, (byte) 178, (byte) 179, (byte) 180, (byte) 181, (byte) 182, (byte) 183, (byte) 184, (byte) 185,
+ (byte) 186, (byte) 194, (byte) 195, (byte) 196, (byte) 197, (byte) 198, (byte) 199, (byte) 200, (byte) 201,
+ (byte) 202, (byte) 210, (byte) 211, (byte) 212, (byte) 213, (byte) 214, (byte) 215, (byte) 216, (byte) 217,
+ (byte) 218, (byte) 226, (byte) 227, (byte) 228, (byte) 229, (byte) 230, (byte) 231, (byte) 232, (byte) 233,
+ (byte) 234, (byte) 242, (byte) 243, (byte) 244, (byte) 245, (byte) 246, (byte) 247, (byte) 248, (byte) 249,
+ (byte) 250, (byte) 255, (byte) 218, (byte) 0, (byte) 12, (byte) 3, (byte) 1, (byte) 0, (byte) 2, (byte) 17,
+ (byte) 3, (byte) 17, (byte) 0, (byte) 63, (byte) 0, (byte) 180, (byte) 48, (byte) 6, (byte) 69, (byte) 84,
+ (byte) 212, (byte) 135, (byte) 250, (byte) 49, (byte) 235, (byte) 214, (byte) 174, (byte) 116, (byte) 246,
+ (byte) 170, (byte) 154, (byte) 144, (byte) 205, (byte) 153, (byte) 61, (byte) 121, (byte) 21, (byte) 200,
+ (byte) 246, (byte) 61, (byte) 8, (byte) 124, (byte) 72, (byte) 202, (byte) 94, (byte) 7, (byte) 29,
+ (byte) 233, (byte) 24, (byte) 100, (byte) 127, (byte) 58, (byte) 114, (byte) 99, (byte) 181, (byte) 4,
+ (byte) 113, (byte) 222, (byte) 176, (byte) 59, (byte) 8, (byte) 226, (byte) 228, (byte) 103, (byte) 29,
+ (byte) 41, (byte) 177, (byte) 227, (byte) 127, (byte) 20, (byte) 228, (byte) 198, (byte) 211, (byte) 206,
+ (byte) 41, (byte) 163, (byte) 137, (byte) 61, (byte) 168, (byte) 1, (byte) 95, (byte) 168, (byte) 232,
+ (byte) 42, (byte) 212, (byte) 24, (byte) 242, (byte) 151, (byte) 57, (byte) 224, (byte) 246, (byte) 170,
+ (byte) 210, (byte) 18, (byte) 112, (byte) 42, (byte) 205, (byte) 191, (byte) 250, (byte) 159, (byte) 188,
+ (byte) 122, (byte) 211, (byte) 20, (byte) 182, (byte) 36, (byte) 7, (byte) 23, (byte) 72, (byte) 115,
+ (byte) 220, (byte) 113, (byte) 90, (byte) 135, (byte) 238, (byte) 140, (byte) 117, (byte) 205, (byte) 100,
+ (byte) 183, (byte) 19, (byte) 171, (byte) 99, (byte) 161, (byte) 28, (byte) 85, (byte) 249, (byte) 174,
+ (byte) 226, (byte) 133, (byte) 112, (byte) 207, (byte) 207, (byte) 160, (byte) 173, (byte) 32, (byte) 99,
+ (byte) 81, (byte) 55, (byte) 107, (byte) 22, (byte) 20, (byte) 117, (byte) 233, (byte) 214, (byte) 148,
+ (byte) 116, (byte) 108, (byte) 250, (byte) 214, (byte) 83, (byte) 106, (byte) 172, (byte) 14, (byte) 35,
+ (byte) 143, (byte) 143, (byte) 122, (byte) 106, (byte) 106, (byte) 115, (byte) 110, (byte) 249, (byte) 163,
+ (byte) 4, (byte) 103, (byte) 165, (byte) 105, (byte) 116, (byte) 79, (byte) 179, (byte) 145, (byte) 179,
+ (byte) 143, (byte) 148, (byte) 99, (byte) 138, (byte) 204, (byte) 214, (byte) 135, (byte) 203, (byte) 23,
+ (byte) 63, (byte) 197, (byte) 82, (byte) 195, (byte) 168, (byte) 71, (byte) 39, (byte) 13, (byte) 149,
+ (byte) 57, (byte) 232, (byte) 106, (byte) 13, (byte) 93, (byte) 131, (byte) 197, (byte) 27, (byte) 43,
+ (byte) 103, (byte) 230, (byte) 235, (byte) 69, (byte) 197, (byte) 20, (byte) 212, (byte) 181, (byte) 28,
+ (byte) 169, (byte) 38, (byte) 6, (byte) 8, (byte) 198, (byte) 61, (byte) 41, (byte) 205, (byte) 20,
+ (byte) 196, (byte) 13, (byte) 178, (byte) 1, (byte) 248, (byte) 81, (byte) 24, (byte) 118, (byte) 81,
+ (byte) 243, (byte) 246, (byte) 167, (byte) 180, (byte) 76, (byte) 64, (byte) 196, (byte) 173, (byte) 159,
+ (byte) 76, (byte) 212, (byte) 131, (byte) 96, (byte) 177, (byte) 200, (byte) 62, (byte) 83, (byte) 43,
+ (byte) 123, (byte) 226, (byte) 164, (byte) 17, (byte) 156, (byte) 99, (byte) 123, (byte) 126, (byte) 117,
+ (byte) 24, (byte) 140, (byte) 175, (byte) 222, (byte) 118, (byte) 231, (byte) 190, (byte) 105, (byte) 193,
+ (byte) 71, (byte) 77, (byte) 199, (byte) 241, (byte) 52, (byte) 196, (byte) 72, (byte) 34, (byte) 83,
+ (byte) 213, (byte) 155, (byte) 39, (byte) 142, (byte) 180, (byte) 162, (byte) 36, (byte) 201, (byte) 201,
+ (byte) 63, (byte) 157, (byte) 51, (byte) 9, (byte) 158, (byte) 88, (byte) 115, (byte) 239, (byte) 78,
+ (byte) 81, (byte) 24, (byte) 39, (byte) 230, (byte) 20, (byte) 132, (byte) 39, (byte) 151, (byte) 31,
+ (byte) 181, (byte) 20, (byte) 252, (byte) 197, (byte) 234, (byte) 40, (byte) 160, (byte) 46, (byte) 76,
+ (byte) 7, (byte) 168, (byte) 170, (byte) 218, (byte) 128, (byte) 255, (byte) 0, (byte) 67, (byte) 127,
+ (byte) 194, (byte) 174, (byte) 1, (byte) 199, (byte) 61, (byte) 42, (byte) 190, (byte) 160, (byte) 191,
+ (byte) 232, (byte) 114, (byte) 96, (byte) 83, (byte) 123, (byte) 10, (byte) 59, (byte) 163, (byte) 13,
+ (byte) 6, (byte) 6, (byte) 41, (byte) 89, (byte) 72, (byte) 247, (byte) 52, (byte) 168, (byte) 164,
+ (byte) 119, (byte) 193, (byte) 167, (byte) 50, (byte) 156, (byte) 26, (byte) 231, (byte) 108, (byte) 236,
+ (byte) 34, (byte) 140, (byte) 114, (byte) 221, (byte) 51, (byte) 81, (byte) 168, (byte) 30, (byte) 103,
+ (byte) 34, (byte) 165, (byte) 139, (byte) 134, (byte) 61, (byte) 233, (byte) 164, (byte) 226, (byte) 83,
+ (byte) 199, (byte) 90, (byte) 10, (byte) 65, (byte) 42, (byte) 227, (byte) 233, (byte) 86, (byte) 109,
+ (byte) 128, (byte) 48, (byte) 231, (byte) 112, (byte) 94, (byte) 123, (byte) 213, (byte) 121, (byte) 58,
+ (byte) 116, (byte) 233, (byte) 79, (byte) 50, (byte) 8, (byte) 236, (byte) 152, (byte) 224, (byte) 18,
+ (byte) 125, (byte) 104, (byte) 90, (byte) 147, (byte) 45, (byte) 136, (byte) 238, (byte) 231, (byte) 253,
+ (byte) 246, (byte) 200, (byte) 136, (byte) 220, (byte) 58, (byte) 181, (byte) 49, (byte) 85, (byte) 187,
+ (byte) 245, (byte) 61, (byte) 205, (byte) 71, (byte) 2, (byte) 28, (byte) 100, (byte) 247, (byte) 171,
+ (byte) 208, (byte) 71, (byte) 131, (byte) 156, (byte) 113, (byte) 90, (byte) 109, (byte) 161, (byte) 73,
+ (byte) 13, (byte) 138, (byte) 14, (byte) 121, (byte) 228, (byte) 85, (byte) 143, (byte) 32, (byte) 40,
+ (byte) 199, (byte) 74, (byte) 181, (byte) 111, (byte) 16, (byte) 61, (byte) 112, (byte) 125, (byte) 51,
+ (byte) 83, (byte) 203, (byte) 26, (byte) 4, (byte) 31, (byte) 39, (byte) 228, (byte) 105, (byte) 1,
+ (byte) 143, (byte) 44, (byte) 56, (byte) 233, (byte) 154, (byte) 169, (byte) 59, (byte) 72, (byte) 19,
+ (byte) 110, (byte) 114, (byte) 1, (byte) 200, (byte) 21, (byte) 181, (byte) 34, (byte) 140, (byte) 30,
+ (byte) 0, (byte) 250, (byte) 86, (byte) 124, (byte) 241, (byte) 130, (byte) 50, (byte) 71, (byte) 229,
+ (byte) 66, (byte) 97, (byte) 107, (byte) 133, (byte) 165, (byte) 202, (byte) 200, (byte) 161, (byte) 93,
+ (byte) 176, (byte) 122, (byte) 114, (byte) 106, (byte) 198, (byte) 3, (byte) 30, (byte) 95, (byte) 233,
+ (byte) 205, (byte) 99, (byte) 74, (byte) 165, (byte) 36, (byte) 201, (byte) 30, (byte) 226, (byte) 181,
+ (byte) 45, (byte) 36, (byte) 134, (byte) 120, (byte) 182, (byte) 202, (byte) 16, (byte) 17, (byte) 222,
+ (byte) 180, (byte) 49, (byte) 156, (byte) 109, (byte) 169, (byte) 58, (byte) 136, (byte) 192, (byte) 193,
+ (byte) 97, (byte) 249, (byte) 212, (byte) 170, (byte) 177, (byte) 131, (byte) 156, (byte) 138, (byte) 114,
+ (byte) 8, (byte) 66, (byte) 241, (byte) 183, (byte) 138, (byte) 148, (byte) 24, (byte) 123, (byte) 117,
+ (byte) 250, (byte) 80, (byte) 101, (byte) 113, (byte) 170, (byte) 98, (byte) 235, (byte) 149, (byte) 247,
+ (byte) 226, (byte) 156, (byte) 101, (byte) 128, (byte) 1, (byte) 128, (byte) 51, (byte) 158, (byte) 160,
+ (byte) 82, (byte) 230, (byte) 48, (byte) 49, (byte) 131, (byte) 207, (byte) 160, (byte) 163, (byte) 204,
+ (byte) 78, (byte) 56, (byte) 63, (byte) 247, (byte) 205, (byte) 50, (byte) 70, (byte) 249, (byte) 145,
+ (byte) 255, (byte) 0, (byte) 181, (byte) 255, (byte) 0, (byte) 124, (byte) 209, (byte) 78, (byte) 243,
+ (byte) 71, (byte) 247, (byte) 91, (byte) 242, (byte) 162, (byte) 150, (byte) 131, (byte) 47, (byte) 99,
+ (byte) 143, (byte) 173, (byte) 87, (byte) 191, (byte) 81, (byte) 246, (byte) 73, (byte) 51, (byte) 233,
+ (byte) 87, (byte) 48, (byte) 14, (byte) 122, (byte) 213, (byte) 123, (byte) 209, (byte) 254, (byte) 137,
+ (byte) 39, (byte) 166, (byte) 41, (byte) 189, (byte) 136, (byte) 142, (byte) 232, (byte) 231, (byte) 208,
+ (byte) 102, (byte) 158, (byte) 220, (byte) 28, (byte) 10, (byte) 106, (byte) 227, (byte) 138, (byte) 151,
+ (byte) 4, (byte) 142, (byte) 245, (byte) 204, (byte) 118, (byte) 144, (byte) 32, (byte) 204, (byte) 135,
+ (byte) 53, (byte) 27, (byte) 224, (byte) 75, (byte) 199, (byte) 173, (byte) 74, (byte) 56, (byte) 147,
+ (byte) 6, (byte) 152, (byte) 227, (byte) 247, (byte) 216, (byte) 52, (byte) 13, (byte) 4, (byte) 131,
+ (byte) 229, (byte) 206, (byte) 42, (byte) 180, (byte) 161, (byte) 152, (byte) 172, (byte) 125, (byte) 135,
+ (byte) 38, (byte) 174, (byte) 74, (byte) 0, (byte) 66, (byte) 7, (byte) 165, (byte) 64, (byte) 235,
+ (byte) 209, (byte) 179, (byte) 205, (byte) 84, (byte) 55, (byte) 6, (byte) 75, (byte) 12, (byte) 125,
+ (byte) 1, (byte) 206, (byte) 49, (byte) 82, (byte) 77, (byte) 113, (byte) 228, (byte) 97, (byte) 81,
+ (byte) 55, (byte) 53, (byte) 62, (byte) 220, (byte) 101, (byte) 50, (byte) 8, (byte) 233, (byte) 82,
+ (byte) 89, (byte) 36, (byte) 127, (byte) 104, (byte) 221, (byte) 112, (byte) 192, (byte) 51, (byte) 30,
+ (byte) 51, (byte) 218, (byte) 173, (byte) 110, (byte) 13, (byte) 216, (byte) 91, (byte) 75, (byte) 240,
+ (byte) 236, (byte) 18, (byte) 96, (byte) 87, (byte) 60, (byte) 100, (byte) 138, (byte) 213, (byte) 16,
+ (byte) 130, (byte) 157, (byte) 141, (byte) 23, (byte) 246, (byte) 118, (byte) 182, (byte) 234, (byte) 140,
+ (byte) 204, (byte) 24, (byte) 48, (byte) 4, (byte) 48, (byte) 82, (byte) 42, (byte) 72, (byte) 118,
+ (byte) 199, (byte) 18, (byte) 146, (byte) 202, (byte) 85, (byte) 135, (byte) 20, (byte) 89, (byte) 18,
+ (byte) 165, (byte) 116, (byte) 103, (byte) 94, (byte) 98, (byte) 221, (byte) 119, (byte) 177, (byte) 206,
+ (byte) 122, (byte) 10, (byte) 200, (byte) 123, (byte) 208, (byte) 220, (byte) 52, (byte) 100, (byte) 15,
+ (byte) 90, (byte) 222, (byte) 146, (byte) 15, (byte) 58, (byte) 38, (byte) 157, (byte) 212, (byte) 178,
+ (byte) 47, (byte) 124, (byte) 116, (byte) 172, (byte) 233, (byte) 252, (byte) 150, (byte) 66, (byte) 172,
+ (byte) 128, (byte) 46, (byte) 113, (byte) 144, (byte) 59, (byte) 209, (byte) 161, (byte) 92, (byte) 198,
+ (byte) 93, (byte) 202, (byte) 228, (byte) 43, (byte) 1, (byte) 197, (byte) 45, (byte) 140, (byte) 209,
+ (byte) 37, (byte) 198, (byte) 37, (byte) 25, (byte) 83, (byte) 198, (byte) 49, (byte) 82, (byte) 204,
+ (byte) 134, (byte) 37, (byte) 10, (byte) 72, (byte) 62, (byte) 135, (byte) 218, (byte) 170, (byte) 194,
+ (byte) 234, (byte) 147, (byte) 169, (byte) 35, (byte) 60, (byte) 250, (byte) 85, (byte) 33, (byte) 61,
+ (byte) 81, (byte) 209, (byte) 164, (byte) 208, (byte) 237, (byte) 218, (byte) 128, (byte) 227, (byte) 217,
+ (byte) 77, (byte) 60, (byte) 72, (byte) 167, (byte) 162, (byte) 177, (byte) 255, (byte) 0, (byte) 128,
+ (byte) 154, (byte) 72, (byte) 231, (byte) 27, (byte) 70, (byte) 17, (byte) 200, (byte) 199, (byte) 101,
+ (byte) 169, (byte) 145, (byte) 201, (byte) 255, (byte) 0, (byte) 150, (byte) 111, (byte) 84, (byte) 114,
+ (byte) 49, (byte) 155, (byte) 207, (byte) 64, (byte) 173, (byte) 255, (byte) 0, (byte) 124, (byte) 208,
+ (byte) 95, (byte) 166, (byte) 99, (byte) 111, (byte) 202, (byte) 165, (byte) 220, (byte) 199, (byte) 164,
+ (byte) 109, (byte) 75, (byte) 185, (byte) 207, (byte) 30, (byte) 89, (byte) 252, (byte) 233, (byte) 8,
+ (byte) 103, (byte) 154, (byte) 223, (byte) 243, (byte) 204, (byte) 254, (byte) 84, (byte) 83, (byte) 240,
+ (byte) 255, (byte) 0, (byte) 243, (byte) 207, (byte) 245, (byte) 162, (byte) 139, (byte) 129, (byte) 108,
+ (byte) 142, (byte) 106, (byte) 43, (byte) 197, (byte) 205, (byte) 164, (byte) 131, (byte) 167, (byte) 202,
+ (byte) 106, (byte) 206, (byte) 61, (byte) 122, (byte) 212, (byte) 87, (byte) 35, (byte) 54, (byte) 210,
+ (byte) 103, (byte) 251, (byte) 166, (byte) 155, (byte) 216, (byte) 148, (byte) 245, (byte) 57, (byte) 164,
+ (byte) 83, (byte) 145, (byte) 215, (byte) 138, (byte) 148, (byte) 1, (byte) 154, (byte) 106, (byte) 14,
+ (byte) 112, (byte) 106, (byte) 80, (byte) 56, (byte) 237, (byte) 154, (byte) 229, (byte) 103, (byte) 109,
+ (byte) 202, (byte) 216, (byte) 253, (byte) 233, (byte) 166, (byte) 203, (byte) 254, (byte) 180, (byte) 26,
+ (byte) 148, (byte) 2, (byte) 37, (byte) 250, (byte) 211, (byte) 102, (byte) 95, (byte) 222, (byte) 140,
+ (byte) 154, (byte) 16, (byte) 192, (byte) 168, (byte) 96, (byte) 42, (byte) 213, (byte) 212, (byte) 17,
+ (byte) 164, (byte) 33, (byte) 112, (byte) 8, (byte) 198, (byte) 106, (byte) 187, (byte) 175, (byte) 203,
+ (byte) 212, (byte) 226, (byte) 172, (byte) 135, (byte) 13, (byte) 102, (byte) 197, (byte) 190, (byte) 241,
+ (byte) 92, (byte) 125, (byte) 106, (byte) 224, (byte) 50, (byte) 188, (byte) 16, (byte) 70, (byte) 223,
+ (byte) 42, (byte) 147, (byte) 130, (byte) 123, (byte) 28, (byte) 84, (byte) 255, (byte) 0, (byte) 101,
+ (byte) 119, (byte) 159, (byte) 129, (byte) 140, (byte) 112, (byte) 42, (byte) 27, (byte) 77, (byte) 194,
+ (byte) 69, (byte) 29, (byte) 171, (byte) 106, (byte) 37, (byte) 87, (byte) 56, (byte) 12, (byte) 1,
+ (byte) 199, (byte) 122, (byte) 173, (byte) 68, (byte) 244, (byte) 27, (byte) 112, (byte) 215, (byte) 18,
+ (byte) 90, (byte) 195, (byte) 28, (byte) 164, (byte) 58, (byte) 196, (byte) 48, (byte) 6, (byte) 59,
+ (byte) 85, (byte) 41, (byte) 110, (byte) 30, (byte) 17, (byte) 177, (byte) 85, (byte) 126, (byte) 113,
+ (byte) 223, (byte) 156, (byte) 86, (byte) 156, (byte) 144, (byte) 21, (byte) 66, (byte) 210, (byte) 55,
+ (byte) 3, (byte) 144, (byte) 23, (byte) 189, (byte) 101, (byte) 198, (byte) 130, (byte) 123, (byte) 163,
+ (byte) 185, (byte) 130, (byte) 250, (byte) 3, (byte) 218, (byte) 158, (byte) 251, (byte) 132, (byte) 82,
+ (byte) 38, (byte) 180, (byte) 184, (byte) 157, (byte) 108, (byte) 165, (byte) 137, (byte) 27, (byte) 247,
+ (byte) 114, (byte) 12, (byte) 50, (byte) 213, (byte) 9, (byte) 163, (byte) 85, (byte) 93, (byte) 170,
+ (byte) 8, (byte) 238, (byte) 125, (byte) 234, (byte) 218, (byte) 68, (byte) 233, (byte) 118, (byte) 99,
+ (byte) 71, (byte) 24, (byte) 60, (byte) 143, (byte) 66, (byte) 105, (byte) 243, (byte) 71, (byte) 34,
+ (byte) 130, (byte) 90, (byte) 62, (byte) 71, (byte) 189, (byte) 14, (byte) 227, (byte) 178, (byte) 76,
+ (byte) 206, (byte) 146, (byte) 47, (byte) 58, (byte) 84, (byte) 80, (byte) 6, (byte) 91, (byte) 214,
+ (byte) 179, (byte) 221, (byte) 190, (byte) 207, (byte) 119, (byte) 141, (byte) 155, (byte) 130, (byte) 55,
+ (byte) 74, (byte) 189, (byte) 44, (byte) 158, (byte) 84, (byte) 193, (byte) 240, (byte) 1, (byte) 0,
+ (byte) 145, (byte) 143, (byte) 90, (byte) 207, (byte) 11, (byte) 52, (byte) 243, (byte) 240, (byte) 187,
+ (byte) 153, (byte) 143, (byte) 65, (byte) 84, (byte) 132, (byte) 246, (byte) 58, (byte) 107, (byte) 121,
+ (byte) 76, (byte) 145, (byte) 171, (byte) 136, (byte) 142, (byte) 8, (byte) 233, (byte) 154, (byte) 156,
+ (byte) 23, (byte) 255, (byte) 0, (byte) 158, (byte) 120, (byte) 252, (byte) 106, (byte) 59, (byte) 88,
+ (byte) 231, (byte) 72, (byte) 85, (byte) 10, (byte) 32, (byte) 192, (byte) 171, (byte) 24, (byte) 151,
+ (byte) 31, (byte) 193, (byte) 154, (byte) 163, (byte) 141, (byte) 140, (byte) 5, (byte) 241, (byte) 247,
+ (byte) 7, (byte) 231, (byte) 74, (byte) 60, (byte) 206, (byte) 161, (byte) 71, (byte) 231, (byte) 78,
+ (byte) 219, (byte) 47, (byte) 251, (byte) 20, (byte) 170, (byte) 178, (byte) 231, (byte) 239, (byte) 47,
+ (byte) 229, (byte) 64, (byte) 134, (byte) 252, (byte) 222, (byte) 139, (byte) 249, (byte) 209, (byte) 82,
+ (byte) 121, (byte) 114, (byte) 255, (byte) 0, (byte) 121, (byte) 104, (byte) 164, (byte) 23, (byte) 44,
+ (byte) 149, (byte) 39, (byte) 165, (byte) 71, (byte) 58, (byte) 159, (byte) 33, (byte) 198, (byte) 63,
+ (byte) 132, (byte) 212, (byte) 248, (byte) 7, (byte) 138, (byte) 108, (byte) 171, (byte) 251, (byte) 166,
+ (byte) 250, (byte) 98, (byte) 171, (byte) 161, (byte) 11, (byte) 115, (byte) 150, (byte) 140, (byte) 124,
+ (byte) 220, (byte) 84, (byte) 219, (byte) 121, (byte) 166, (byte) 42, (byte) 146, (byte) 216, (byte) 29,
+ (byte) 141, (byte) 78, (byte) 163, (byte) 154, (byte) 228, (byte) 123, (byte) 157, (byte) 197, (byte) 82,
+ (byte) 15, (byte) 152, (byte) 41, (byte) 179, (byte) 175, (byte) 206, (byte) 9, (byte) 169, (byte) 153,
+ (byte) 79, (byte) 154, (byte) 41, (byte) 147, (byte) 174, (byte) 25, (byte) 73, (byte) 206, (byte) 40,
+ (byte) 24, (byte) 99, (byte) 9, (byte) 142, (byte) 105, (byte) 208, (byte) 32, (byte) 101, (byte) 37,
+ (byte) 219, (byte) 104, (byte) 3, (byte) 34, (byte) 159, (byte) 183, (byte) 40, (byte) 112, (byte) 57,
+ (byte) 237, (byte) 87, (byte) 108, (byte) 236, (byte) 100, (byte) 40, (byte) 124, (byte) 193, (byte) 141,
+ (byte) 195, (byte) 165, (byte) 105, (byte) 74, (byte) 46, (byte) 79, (byte) 66, (byte) 39, (byte) 53,
+ (byte) 21, (byte) 118, (byte) 80, (byte) 183, (byte) 31, (byte) 48, (byte) 30, (byte) 245, (byte) 173,
+ (byte) 110, (byte) 152, (byte) 249, (byte) 143, (byte) 65, (byte) 84, (byte) 163, (byte) 128, (byte) 195,
+ (byte) 115, (byte) 176, (byte) 245, (byte) 7, (byte) 154, (byte) 211, (byte) 141, (byte) 51, (byte) 149,
+ (byte) 238, (byte) 106, (byte) 154, (byte) 177, (byte) 92, (byte) 221, (byte) 72, (byte) 46, (byte) 238,
+ (byte) 55, (byte) 28, (byte) 100, (byte) 243, (byte) 85, (byte) 226, (byte) 183, (byte) 93, (byte) 187,
+ (byte) 152, (byte) 114, (byte) 122, (byte) 123, (byte) 83, (byte) 117, (byte) 8, (byte) 38, (byte) 102,
+ (byte) 45, (byte) 19, (byte) 99, (byte) 29, (byte) 133, (byte) 85, (byte) 84, (byte) 185, (byte) 85,
+ (byte) 206, (byte) 72, (byte) 230, (byte) 132, (byte) 104, (byte) 147, (byte) 104, (byte) 89, (byte) 3,
+ (byte) 67, (byte) 117, (byte) 149, (byte) 99, (byte) 128, (byte) 106, (byte) 244, (byte) 178, (byte) 9,
+ (byte) 34, (byte) 221, (byte) 237, (byte) 89, (byte) 66, (byte) 41, (byte) 158, (byte) 113, (byte) 184,
+ (byte) 182, (byte) 220, (byte) 242, (byte) 107, (byte) 96, (byte) 162, (byte) 139, (byte) 124, (byte) 142,
+ (byte) 167, (byte) 138, (byte) 24, (byte) 164, (byte) 236, (byte) 97, (byte) 94, (byte) 129, (byte) 146,
+ (byte) 9, (byte) 193, (byte) 199, (byte) 21, (byte) 14, (byte) 155, (byte) 230, (byte) 11, (byte) 164,
+ (byte) 219, (byte) 183, (byte) 35, (byte) 212, (byte) 113, (byte) 79, (byte) 212, (byte) 207, (byte) 250,
+ (byte) 70, (byte) 220, (byte) 227, (byte) 2, (byte) 173, (byte) 104, (byte) 214, (byte) 141, (byte) 33,
+ (byte) 105, (byte) 3, (byte) 225, (byte) 151, (byte) 167, (byte) 28, (byte) 85, (byte) 35, (byte) 57,
+ (byte) 187, (byte) 35, (byte) 106, (byte) 53, (byte) 159, (byte) 3, (byte) 123, (byte) 174, (byte) 125,
+ (byte) 133, (byte) 60, (byte) 71, (byte) 38, (byte) 57, (byte) 113, (byte) 159, (byte) 165, (byte) 34,
+ (byte) 197, (byte) 40, (byte) 31, (byte) 52, (byte) 205, (byte) 159, (byte) 165, (byte) 56, (byte) 198,
+ (byte) 248, (byte) 229, (byte) 216, (byte) 211, (byte) 57, (byte) 67, (byte) 99, (byte) 224, (byte) 130,
+ (byte) 252, (byte) 253, (byte) 41, (byte) 66, (byte) 201, (byte) 221, (byte) 248, (byte) 250, (byte) 81,
+ (byte) 229, (byte) 147, (byte) 140, (byte) 187, (byte) 82, (byte) 136, (byte) 207, (byte) 247, (byte) 219,
+ (byte) 31, (byte) 90, (byte) 96, (byte) 46, (byte) 195, (byte) 255, (byte) 0, (byte) 61, (byte) 13,
+ (byte) 20, (byte) 121, (byte) 63, (byte) 237, (byte) 55, (byte) 231, (byte) 69, (byte) 23, (byte) 21,
+ (byte) 139, (byte) 152, (byte) 201, (byte) 247, (byte) 164, (byte) 117, (byte) 249, (byte) 79, (byte) 166,
+ (byte) 41, (byte) 195, (byte) 20, (byte) 132, (byte) 124, (byte) 164, (byte) 85, (byte) 16, (byte) 115,
+ (byte) 32, (byte) 126, (byte) 240, (byte) 129, (byte) 235, (byte) 82, (byte) 117, (byte) 224, (byte) 83,
+ (byte) 74, (byte) 226, (byte) 118, (byte) 235, (byte) 212, (byte) 212, (byte) 161, (byte) 79, (byte) 28,
+ (byte) 243, (byte) 92, (byte) 143, (byte) 115, (byte) 182, (byte) 229, (byte) 121, (byte) 0, (byte) 14,
+ (byte) 50, (byte) 41, (byte) 207, (byte) 3, (byte) 202, (byte) 192, (byte) 39, (byte) 62, (byte) 167,
+ (byte) 210, (byte) 174, (byte) 195, (byte) 100, (byte) 101, (byte) 96, (byte) 207, (byte) 144, (byte) 61,
+ (byte) 43, (byte) 78, (byte) 27, (byte) 116, (byte) 81, (byte) 133, (byte) 0, (byte) 98, (byte) 183,
+ (byte) 167, (byte) 69, (byte) 189, (byte) 89, (byte) 140, (byte) 235, (byte) 168, (byte) 236, (byte) 83,
+ (byte) 176, (byte) 177, (byte) 0, (byte) 130, (byte) 252, (byte) 227, (byte) 214, (byte) 180, (byte) 210,
+ (byte) 60, (byte) 47, (byte) 35, (byte) 156, (byte) 212, (byte) 144, (byte) 198, (byte) 20, (byte) 142,
+ (byte) 42, (byte) 114, (byte) 163, (byte) 56, (byte) 29, (byte) 235, (byte) 174, (byte) 49, (byte) 81,
+ (byte) 86, (byte) 71, (byte) 28, (byte) 230, (byte) 228, (byte) 238, (byte) 204, (byte) 125, (byte) 86,
+ (byte) 216, (byte) 161, (byte) 89, (byte) 194, (byte) 251, (byte) 54, (byte) 59, (byte) 84, (byte) 105,
+ (byte) 40, (byte) 40, (byte) 174, (byte) 189, (byte) 71, (byte) 167, (byte) 90, (byte) 223, (byte) 186,
+ (byte) 183, (byte) 89, (byte) 160, (byte) 42, (byte) 195, (byte) 130, (byte) 48, (byte) 107, (byte) 154,
+ (byte) 8, (byte) 246, (byte) 183, (byte) 13, (byte) 4, (byte) 199, (byte) 31, (byte) 221, (byte) 61,
+ (byte) 136, (byte) 172, (byte) 106, (byte) 199, (byte) 170, (byte) 58, (byte) 104, (byte) 78, (byte) 234,
+ (byte) 204, (byte) 149, (byte) 8, (byte) 147, (byte) 118, (byte) 72, (byte) 235, (byte) 154, (byte) 99,
+ (byte) 40, (byte) 42, (byte) 113, (byte) 131, (byte) 138, (byte) 35, (byte) 27, (byte) 36, (byte) 200,
+ (byte) 28, (byte) 19, (byte) 79, (byte) 102, (byte) 11, (byte) 209, (byte) 125, (byte) 248, (byte) 172,
+ (byte) 108, (byte) 117, (byte) 166, (byte) 85, (byte) 224, (byte) 238, (byte) 35, (byte) 29, (byte) 42,
+ (byte) 1, (byte) 57, (byte) 84, (byte) 62, (byte) 220, (byte) 1, (byte) 235, (byte) 83, (byte) 207,
+ (byte) 242, (byte) 41, (byte) 218, (byte) 58, (byte) 251, (byte) 209, (byte) 97, (byte) 109, (byte) 188,
+ (byte) 153, (byte) 88, (byte) 12, (byte) 3, (byte) 133, (byte) 250, (byte) 250, (byte) 213, (byte) 70,
+ (byte) 23, (byte) 100, (byte) 212, (byte) 154, (byte) 138, (byte) 185, (byte) 3, (byte) 104, (byte) 13,
+ (byte) 112, (byte) 158, (byte) 107, (byte) 204, (byte) 86, (byte) 86, (byte) 228, (byte) 140, (byte) 112,
+ (byte) 42, (byte) 75, (byte) 125, (byte) 60, (byte) 89, (byte) 194, (byte) 82, (byte) 89, (byte) 93,
+ (byte) 73, (byte) 63, (byte) 120, (byte) 30, (byte) 43, (byte) 105, (byte) 27, (byte) 229, (byte) 7,
+ (byte) 20, (byte) 247, (byte) 69, (byte) 117, (byte) 33, (byte) 128, (byte) 32, (byte) 245, (byte) 205,
+ (byte) 110, (byte) 233, (byte) 163, (byte) 139, (byte) 219, (byte) 73, (byte) 238, (byte) 103, (byte) 36,
+ (byte) 42, (byte) 121, (byte) 243, (byte) 73, (byte) 255, (byte) 0, (byte) 129, (byte) 84, (byte) 130,
+ (byte) 20, (byte) 35, (byte) 33, (byte) 219, (byte) 254, (byte) 250, (byte) 172, (byte) 251, (byte) 203,
+ (byte) 83, (byte) 167, (byte) 75, (byte) 231, (byte) 196, (byte) 187, (byte) 161, (byte) 39, (byte) 230,
+ (byte) 83, (byte) 218, (byte) 174, (byte) 91, (byte) 205, (byte) 105, (byte) 60, (byte) 97, (byte) 208,
+ (byte) 168, (byte) 227, (byte) 167, (byte) 165, (byte) 100, (byte) 213, (byte) 141, (byte) 58, (byte) 93,
+ (byte) 18, (byte) 249, (byte) 49, (byte) 255, (byte) 0, (byte) 120, (byte) 243, (byte) 254, (byte) 213,
+ (byte) 30, (byte) 84, (byte) 93, (byte) 50, (byte) 127, (byte) 239, (byte) 170, (byte) 81, (byte) 228,
+ (byte) 15, (byte) 238, (byte) 81, (byte) 254, (byte) 142, (byte) 23, (byte) 248, (byte) 41, (byte) 8,
+ (byte) 60, (byte) 168, (byte) 127, (byte) 188, (byte) 127, (byte) 239, (byte) 170, (byte) 41, (byte) 63,
+ (byte) 209, (byte) 255, (byte) 0, (byte) 216, (byte) 162, (byte) 141, (byte) 7, (byte) 115, (byte) 67,
+ (byte) 29, (byte) 232, (byte) 199, (byte) 81, (byte) 235, (byte) 79, (byte) 160, (byte) 138, (byte) 163,
+ (byte) 51, (byte) 152, (byte) 117, (byte) 38, (byte) 233, (byte) 148, (byte) 15, (byte) 226, (byte) 34,
+ (byte) 180, (byte) 173, (byte) 237, (byte) 48, (byte) 1, (byte) 97, (byte) 255, (byte) 0, (byte) 214,
+ (byte) 169, (byte) 160, (byte) 176, (byte) 219, (byte) 44, (byte) 147, (byte) 75, (byte) 221, (byte) 142,
+ (byte) 209, (byte) 87, (byte) 226, (byte) 139, (byte) 208, (byte) 126, (byte) 116, (byte) 233, (byte) 210,
+ (byte) 183, (byte) 188, (byte) 199, (byte) 86, (byte) 173, (byte) 215, (byte) 42, (byte) 35, (byte) 142,
+ (byte) 53, (byte) 94, (byte) 49, (byte) 83, (byte) 249, (byte) 67, (byte) 32, (byte) 140, (byte) 84,
+ (byte) 137, (byte) 22, (byte) 57, (byte) 53, (byte) 32, (byte) 94, (byte) 245, (byte) 185, (byte) 206,
+ (byte) 49, (byte) 83, (byte) 10, (byte) 24, (byte) 118, (byte) 52, (byte) 253, (byte) 185, (byte) 96,
+ (byte) 77, (byte) 57, (byte) 70, (byte) 65, (byte) 200, (byte) 169, (byte) 54, (byte) 240, (byte) 41,
+ (byte) 12, (byte) 16, (byte) 238, (byte) 5, (byte) 79, (byte) 81, (byte) 84, (byte) 53, (byte) 61,
+ (byte) 60, (byte) 93, (byte) 33, (byte) 3, (byte) 135, (byte) 31, (byte) 116, (byte) 214, (byte) 134,
+ (byte) 222, (byte) 132, (byte) 83, (byte) 156, (byte) 110, (byte) 92, (byte) 142, (byte) 162, (byte) 144,
+ (byte) 211, (byte) 105, (byte) 221, (byte) 28, (byte) 121, (byte) 183, (byte) 185, (byte) 137, (byte) 138,
+ (byte) 156, (byte) 241, (byte) 237, (byte) 71, (byte) 152, (byte) 234, (byte) 62, (byte) 97, (byte) 205,
+ (byte) 116, (byte) 146, (byte) 91, (byte) 164, (byte) 255, (byte) 0, (byte) 49, (byte) 24, (byte) 35,
+ (byte) 140, (byte) 138, (byte) 161, (byte) 45, (byte) 178, (byte) 36, (byte) 152, (byte) 35, (byte) 154,
+ (byte) 194, (byte) 81, (byte) 104, (byte) 236, (byte) 133, (byte) 85, (byte) 35, (byte) 13, (byte) 163,
+ (byte) 121, (byte) 166, (byte) 85, (byte) 60, (byte) 100, (byte) 214, (byte) 196, (byte) 80, (byte) 4,
+ (byte) 9, (byte) 26, (byte) 224, (byte) 119, (byte) 168, (byte) 4, (byte) 5, (byte) 175, (byte) 14,
+ (byte) 209, (byte) 192, (byte) 239, (byte) 90, (byte) 98, (byte) 220, (byte) 44, (byte) 91, (byte) 137,
+ (byte) 201, (byte) 29, (byte) 42, (byte) 233, (byte) 167, (byte) 185, (byte) 157, (byte) 121, (byte) 105,
+ (byte) 98, (byte) 154, (byte) 41, (byte) 85, (byte) 83, (byte) 219, (byte) 161, (byte) 169, (byte) 151,
+ (byte) 142, (byte) 61, (byte) 63, (byte) 149, (byte) 72, (byte) 209, (byte) 0, (byte) 132, (byte) 122,
+ (byte) 115, (byte) 81, (byte) 99, (byte) 24, (byte) 173, (byte) 142, (byte) 113, (byte) 110, (byte) 33,
+ (byte) 73, (byte) 237, (byte) 200, (byte) 97, (byte) 199, (byte) 67, (byte) 244, (byte) 174, (byte) 94,
+ (byte) 214, (byte) 69, (byte) 176, (byte) 212, (byte) 222, (byte) 7, (byte) 251, (byte) 164, (byte) 227,
+ (byte) 165, (byte) 117, (byte) 145, (byte) 99, (byte) 12, (byte) 167, (byte) 21, (byte) 205, (byte) 248,
+ (byte) 146, (byte) 31, (byte) 42, (byte) 120, (byte) 231, (byte) 69, (byte) 231, (byte) 161, (byte) 250,
+ (byte) 138, (byte) 206, (byte) 162, (byte) 208, (byte) 214, (byte) 139, (byte) 215, (byte) 151, (byte) 185,
+ (byte) 171, (byte) 190, (byte) 35, (byte) 252, (byte) 56, (byte) 252, (byte) 40, (byte) 221, (byte) 22,
+ (byte) 51, (byte) 183, (byte) 255, (byte) 0, (byte) 29, (byte) 168, (byte) 236, (byte) 174, (byte) 60,
+ (byte) 251, (byte) 84, (byte) 125, (byte) 135, (byte) 36, (byte) 96, (byte) 212, (byte) 197, (byte) 184,
+ (byte) 255, (byte) 0, (byte) 86, (byte) 213, (byte) 137, (byte) 67, (byte) 124, (byte) 216, (byte) 191,
+ (byte) 186, (byte) 127, (byte) 239, (byte) 154, (byte) 41, (byte) 124, (byte) 207, (byte) 250, (byte) 100,
+ (byte) 223, (byte) 149, (byte) 20, (byte) 12, (byte) 209, (byte) 198, (byte) 120, (byte) 169, (byte) 35,
+ (byte) 143, (byte) 113, (byte) 246, (byte) 20, (byte) 152, (byte) 61, (byte) 106, (byte) 196, (byte) 73,
+ (byte) 182, (byte) 44, (byte) 250, (byte) 214, (byte) 145, (byte) 87, (byte) 102, (byte) 82, (byte) 118,
+ (byte) 34, (byte) 88, (byte) 183, (byte) 201, (byte) 147, (byte) 208, (byte) 118, (byte) 171, (byte) 11,
+ (byte) 31, (byte) 124, (byte) 83, (byte) 97, (byte) 24, (byte) 82, (byte) 125, (byte) 77, (byte) 90,
+ (byte) 3, (byte) 3, (byte) 21, (byte) 165, (byte) 204, (byte) 200, (byte) 74, (byte) 99, (byte) 154,
+ (byte) 66, (byte) 184, (byte) 197, (byte) 78, (byte) 87, (byte) 62, (byte) 244, (byte) 214, (byte) 92,
+ (byte) 227, (byte) 210, (byte) 139, (byte) 136, (byte) 131, (byte) 163, (byte) 98, (byte) 165, (byte) 2,
+ (byte) 145, (byte) 151, (byte) 231, (byte) 252, (byte) 42, (byte) 80, (byte) 56, (byte) 161, (byte) 140,
+ (byte) 140, (byte) 112, (byte) 219, (byte) 79, (byte) 122, (byte) 90, (byte) 71, (byte) 24, (byte) 193,
+ (byte) 29, (byte) 169, (byte) 123, (byte) 231, (byte) 214, (byte) 129, (byte) 145, (byte) 178, (byte) 158,
+ (byte) 171, (byte) 138, (byte) 169, (byte) 120, (byte) 141, (byte) 144, (byte) 248, (byte) 233, (byte) 214,
+ (byte) 175, (byte) 16, (byte) 122, (byte) 83, (byte) 72, (byte) 12, (byte) 118, (byte) 176, (byte) 224,
+ (byte) 138, (byte) 26, (byte) 186, (byte) 176, (byte) 70, (byte) 78, (byte) 46, (byte) 230, (byte) 84,
+ (byte) 17, (byte) 147, (byte) 48, (byte) 53, (byte) 121, (byte) 211, (byte) 10, (byte) 5, (byte) 71,
+ (byte) 111, (byte) 9, (byte) 75, (byte) 135, (byte) 95, (byte) 238, (byte) 244, (byte) 171, (byte) 18,
+ (byte) 142, (byte) 71, (byte) 214, (byte) 148, (byte) 21, (byte) 145, (byte) 85, (byte) 37, (byte) 205,
+ (byte) 34, (byte) 177, (byte) 4, (byte) 231, (byte) 138, (byte) 132, (byte) 175, (byte) 31, (byte) 90,
+ (byte) 182, (byte) 87, (byte) 4, (byte) 212, (byte) 44, (byte) 160, (byte) 49, (byte) 21, (byte) 68,
+ (byte) 21, (byte) 199, (byte) 202, (byte) 224, (byte) 254, (byte) 117, (byte) 71, (byte) 196, (byte) 16,
+ (byte) 249, (byte) 154, (byte) 116, (byte) 140, (byte) 163, (byte) 37, (byte) 112, (byte) 195, (byte) 250,
+ (byte) 214, (byte) 139, (byte) 167, (byte) 28, (byte) 117, (byte) 166, (byte) 74, (byte) 162, (byte) 88,
+ (byte) 25, (byte) 8, (byte) 206, (byte) 84, (byte) 138, (byte) 77, (byte) 93, (byte) 21, (byte) 23,
+ (byte) 102, (byte) 153, (byte) 207, (byte) 104, (byte) 55, (byte) 18, (byte) 24, (byte) 90, (byte) 61,
+ (byte) 160, (byte) 224, (byte) 250, (byte) 214, (byte) 182, (byte) 249, (byte) 127, (byte) 184, (byte) 63,
+ (byte) 58, (byte) 231, (byte) 52, (byte) 150, (byte) 150, (byte) 45, (byte) 65, (byte) 145, (byte) 72,
+ (byte) 29, (byte) 143, (byte) 21, (byte) 209, (byte) 126, (byte) 255, (byte) 0, (byte) 213, (byte) 115,
+ (byte) 88, (byte) 29, (byte) 19, (byte) 90, (byte) 134, (byte) 249, (byte) 255, (byte) 0, (byte) 184,
+ (byte) 159, (byte) 157, (byte) 20, (byte) 126, (byte) 251, (byte) 213, (byte) 127, (byte) 42, (byte) 40,
+ (byte) 185, (byte) 54, (byte) 53, (byte) 209, (byte) 114, (byte) 192, (byte) 26, (byte) 179, (byte) 39,
+ (byte) 220, (byte) 0, (byte) 81, (byte) 69, (byte) 109, (byte) 29, (byte) 140, (byte) 36, (byte) 245,
+ (byte) 31, (byte) 18, (byte) 141, (byte) 192, (byte) 122, (byte) 10, (byte) 177, (byte) 138, (byte) 40,
+ (byte) 160, (byte) 66, (byte) 116, (byte) 56, (byte) 161, (byte) 128, (byte) 234, (byte) 40, (byte) 162,
+ (byte) 129, (byte) 12, (byte) 97, (byte) 215, (byte) 233, (byte) 73, (byte) 25, (byte) 36, (byte) 81,
+ (byte) 69, (byte) 3, (byte) 7, (byte) 25, (byte) 28, (byte) 83, (byte) 87, (byte) 238, (byte) 224,
+ (byte) 209, (byte) 69, (byte) 48, (byte) 23, (byte) 60, (byte) 82, (byte) 48, (byte) 252, (byte) 232,
+ (byte) 162, (byte) 128, (byte) 19, (byte) 0, (byte) 190, (byte) 238, (byte) 132, (byte) 140, (byte) 26,
+ (byte) 107, (byte) 140, (byte) 156, (byte) 122, (byte) 81, (byte) 69, (byte) 2, (byte) 68, (byte) 108,
+ (byte) 188, (byte) 212, (byte) 110, (byte) 189, (byte) 40, (byte) 162, (byte) 129, (byte) 145, (byte) 55,
+ (byte) 99, (byte) 81, (byte) 72, (byte) 187, (byte) 64, (byte) 97, (byte) 235, (byte) 69, (byte) 20,
+ (byte) 193, (byte) 28, (byte) 124, (byte) 136, (byte) 209, (byte) 235, (byte) 178, (byte) 5, (byte) 114,
+ (byte) 191, (byte) 188, (byte) 61, (byte) 43, (byte) 162, (byte) 242, (byte) 164, (byte) 219, (byte) 254,
+ (byte) 185, (byte) 191, (byte) 33, (byte) 69, (byte) 21, (byte) 206, (byte) 247, (byte) 58, (byte) 166,
+ (byte) 244, (byte) 66, (byte) 249, (byte) 18, (byte) 255, (byte) 0, (byte) 207, (byte) 193, (byte) 255,
+ (byte) 0, (byte) 190, (byte) 104, (byte) 162, (byte) 138, (byte) 68, (byte) 159, (byte) 255, (byte) 217
+
+ };
+
+
+}
diff --git a/src/net/sourceforge/plantuml/eggs/PSystemRIPFactory.java b/src/net/sourceforge/plantuml/eggs/PSystemRIPFactory.java
new file mode 100644
index 0000000..189804b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/eggs/PSystemRIPFactory.java
@@ -0,0 +1,58 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.eggs;
+
+import java.io.IOException;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.Log;
+import net.sourceforge.plantuml.command.PSystemSingleLineFactory;
+
+public class PSystemRIPFactory extends PSystemSingleLineFactory {
+
+ @Override
+ protected AbstractPSystem executeLine(String line) {
+ if (line.equalsIgnoreCase("jean canouet")) {
+ try {
+ return new PSystemRIP();
+ } catch (IOException e) {
+ Log.error("Error " + e);
+ e.printStackTrace();
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/eggs/SentenceDecoder.java b/src/net/sourceforge/plantuml/eggs/SentenceDecoder.java
new file mode 100644
index 0000000..e9ab061
--- /dev/null
+++ b/src/net/sourceforge/plantuml/eggs/SentenceDecoder.java
@@ -0,0 +1,68 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.eggs;
+
+import java.io.UnsupportedEncodingException;
+
+public class SentenceDecoder {
+
+ private final String secret;
+
+ public SentenceDecoder(String sentence1, byte[] crypted) throws UnsupportedEncodingException {
+ final byte[] key = EggUtils.fromSecretSentence(sentence1).toByteArray();
+ final byte[] sen2 = EggUtils.xor(crypted, key);
+ this.secret = new String(sen2, "UTF-8");
+ }
+
+ public boolean isOk() {
+ for (char c : secret.toCharArray()) {
+ if ((int) c > 256) {
+ return false;
+ }
+ if (Character.isDefined(c) == false) {
+ return false;
+ }
+ if (Character.isISOControl(c)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public String getSecret() {
+ return secret;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/eggs/SentenceProducer.java b/src/net/sourceforge/plantuml/eggs/SentenceProducer.java
new file mode 100644
index 0000000..cb54f94
--- /dev/null
+++ b/src/net/sourceforge/plantuml/eggs/SentenceProducer.java
@@ -0,0 +1,54 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.eggs;
+
+import java.io.UnsupportedEncodingException;
+
+public class SentenceProducer {
+
+ private final String secret;
+
+ public SentenceProducer(String sentence1, String sentence2) throws UnsupportedEncodingException {
+ final byte[] key = EggUtils.fromSecretSentence(sentence1).toByteArray();
+ final byte[] sen2 = sentence2.getBytes("UTF-8");
+ final byte[] crypted = EggUtils.xor(sen2, key);
+ this.secret = EggUtils.fromByteArrays(crypted);
+ }
+
+ public String getSecret() {
+ return secret;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/eps/EpsGraphics.java b/src/net/sourceforge/plantuml/eps/EpsGraphics.java
new file mode 100644
index 0000000..175548a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/eps/EpsGraphics.java
@@ -0,0 +1,760 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.eps;
+
+import java.awt.Color;
+import java.awt.geom.PathIterator;
+import java.awt.image.BufferedImage;
+import java.util.Locale;
+import java.util.StringTokenizer;
+
+import net.sourceforge.plantuml.Log;
+import net.sourceforge.plantuml.graphic.HtmlColorGradient;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.ShadowManager;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.USegment;
+import net.sourceforge.plantuml.ugraphic.USegmentType;
+import net.sourceforge.plantuml.version.Version;
+
+public class EpsGraphics {
+
+ public static final String END_OF_FILE = "%plantuml done";
+
+ // http://www.linuxfocus.org/Francais/May1998/article43.html
+ // http://www.tailrecursive.org/postscript/text.html
+ private final StringBuilder body = new StringBuilder();
+ private final StringBuilder header = new StringBuilder();
+
+ private Color color = Color.BLACK;
+ private Color fillcolor = Color.BLACK;
+
+ private String strokeWidth = "1";
+ // private String strokeDasharray = null;
+
+ private final PostScriptCommandMacro setcolorgradient = new PostScriptCommandMacro("setcolorgradient");
+ private final PostScriptCommandMacro simplerect = new PostScriptCommandMacro("simplerect");
+ private final PostScriptCommandMacro roundrect = new PostScriptCommandMacro("roundrect");
+ private boolean setcolorgradientUsed = false;
+ private boolean simplerectUsed = false;
+ private boolean roundrectUsed = false;
+
+ public EpsGraphics() {
+ header.append("%!PS-Adobe-3.0 EPSF-3.0\n");
+ header.append("%%Creator: PlantUML v" + Version.versionString(10) + "\n");
+ header.append("%%Title: noTitle\n");
+ // header.append("%%CreationDate: " + new Date() + "\n");
+ setcolorgradient.add(new PostScriptCommandRaw("3 index 7 index sub 1 index mul 7 index add", true));
+ setcolorgradient.add(new PostScriptCommandRaw("3 index 7 index sub 2 index mul 7 index add", true));
+ setcolorgradient.add(new PostScriptCommandRaw("3 index 7 index sub 3 index mul 7 index add", true));
+ setcolorgradient.add(new PostScriptCommandRaw("setrgbcolor", true));
+ // setcolorgradient.add(new PostScriptCommandRaw("0 7 1 {pop} for"));
+ setcolorgradient.add(new PostScriptCommandRaw("pop pop pop pop pop pop pop ", true));
+
+ simplerect.add(new PostScriptCommandRaw("newpath moveto 1 index 0 rlineto", true));
+ simplerect.add(new PostScriptCommandRaw("0 exch rlineto", true));
+ simplerect.add(new PostScriptCommandRaw("neg 0 rlineto", true));
+
+ roundrect.add(new PostScriptCommandRaw("newpath", true));
+ roundrect.add(new PostScriptCommandRaw("dup 3 index add 2 index 2 index add 2 index 180 270 arc", true));
+ roundrect.add(new PostScriptCommandRaw("2 index 5 index add 1 index sub 2 index 2 index add 2 index 270 0 arc",
+ true));
+ roundrect.add(new PostScriptCommandRaw(
+ "2 index 5 index add 1 index sub 2 index 5 index add 2 index sub 2 index 0 90 arc", true));
+ roundrect.add(new PostScriptCommandRaw("dup 3 index add 2 index 5 index add 2 index sub 2 index 90 180 arc",
+ true));
+ roundrect.add(new PostScriptCommandRaw("pop pop pop pop pop ", true));
+ }
+
+ private boolean closeDone = false;
+
+ private int maxX = 10;
+ private int maxY = 10;
+
+ final protected void ensureVisible(double x, double y) {
+ if (x > maxX) {
+ maxX = (int) (x + 1);
+ }
+ if (y > maxY) {
+ maxY = (int) (y + 1);
+ }
+ if (urlArea != null) {
+ urlArea.ensureVisible((int) Math.round(x), (int) Math.round(y));
+ }
+ }
+
+ protected final Color getColor() {
+ return color;
+ }
+
+ public void close() {
+ checkCloseDone();
+
+ header.append("%%BoundingBox: 0 0 " + maxX + " " + maxY + "\n");
+ // header.append("%%DocumentData: Clean7Bit\n");
+ // header.append("%%DocumentProcessColors: Black\n");
+ header.append("%%ColorUsage: Color\n");
+ header.append("%%Origin: 0 0\n");
+ header.append("%%EndComments\n\n");
+ header.append("gsave\n");
+ header.append("0 " + maxY + " translate\n");
+ header.append("1 -1 scale\n");
+
+ if (setcolorgradientUsed) {
+ header.append(setcolorgradient.getPostStringDefinition());
+ }
+ if (simplerectUsed) {
+ header.append(simplerect.getPostStringDefinition());
+ }
+ if (roundrectUsed) {
+ header.append(roundrect.getPostStringDefinition());
+ }
+
+ append("grestore", true);
+
+ // if(isClipSet())
+ // writer.write("grestore\n");
+
+ append("showpage", true);
+ append(END_OF_FILE, true);
+ append("%%EOF", true);
+ closeDone = true;
+ }
+
+ private void checkCloseDone() {
+ if (closeDone) {
+ throw new IllegalStateException();
+ }
+ }
+
+ public String getEPSCode() {
+ if (closeDone == false) {
+ close();
+ }
+ return header.toString() + getBodyString();
+ }
+
+ protected String getBodyString() {
+ return body.toString();
+ }
+
+ public final void setStrokeColor(Color c) {
+ checkCloseDone();
+ this.color = c;
+ }
+
+ public void setFillColor(Color c) {
+ checkCloseDone();
+ this.fillcolor = c;
+ }
+
+ public final void setStrokeWidth(String strokeWidth, double dashVisible, double dashSpace) {
+ checkCloseDone();
+ this.strokeWidth = strokeWidth;
+ this.dashVisible = dashVisible;
+ this.dashSpace = dashSpace;
+ }
+
+ private double dashVisible = 0;
+ private double dashSpace = 0;
+
+ public void newpathDot() {
+ final boolean dashed = dashVisible != 0 || dashSpace != 0;
+ checkCloseDone();
+ append(strokeWidth + " setlinewidth", true);
+ appendColor(color);
+
+ if (dashed) {
+ append("[9 9] 0 setdash", true);
+ }
+ append("newpath", true);
+ }
+
+ public void closepathDot() {
+ final boolean dashed = dashVisible != 0 || dashSpace != 0;
+ append("stroke", true);
+ if (dashed) {
+ append("[] 0 setdash", true);
+ }
+ }
+
+ public void epsLine(double x1, double y1, double x2, double y2) {
+ ensureVisible(x1, y1);
+ ensureVisible(x2, y2);
+ checkCloseDone();
+ append(strokeWidth + " setlinewidth", true);
+ appendColor(color);
+ append("newpath", true);
+ if (dashVisible == 0 || dashSpace == 0) {
+ append(format(x1) + " " + format(y1) + " moveto", true);
+ append(format(x2 - x1) + " " + format(y2 - y1) + " rlineto", true);
+ } else if (x1 == x2) {
+ epsHLine(x1, Math.min(y1, y2), Math.max(y1, y2));
+ } else if (y1 == y2) {
+ epsVLine(y1, Math.min(x1, x2), Math.max(x1, x2));
+ }
+ append("stroke", true);
+ ensureVisible(Math.max(x1, x2), Math.max(y1, y2));
+ }
+
+ protected void epsHLine(double x, double ymin, double ymax) {
+ append(format(x) + " " + format(ymin) + " moveto", true);
+ for (double y = ymin; y < ymax; y += dashVisible + dashSpace) {
+ final double v;
+ if (y + dashVisible > ymax) {
+ v = y - ymax;
+ } else {
+ v = dashSpace;
+ }
+ append("0 " + format(v) + " rlineto", true);
+ append("0 " + format(dashSpace) + " rmoveto", true);
+ }
+ }
+
+ protected void epsVLine(double y, double xmin, double xmax) {
+ append(format(xmin) + " " + format(y) + " moveto", true);
+ for (double x = xmin; x < xmax; x += dashVisible + dashSpace) {
+ final double v;
+ if (x + dashVisible > xmax) {
+ v = x - xmax;
+ } else {
+ v = dashSpace;
+ }
+ append(format(v) + " 0 rlineto", true);
+ append(format(dashSpace) + " 0 rmoveto", true);
+ }
+ }
+
+ public void epsPath(double x, double y, UPath path) {
+ checkCloseDone();
+ if (fillcolor != null) {
+ appendColor(fillcolor);
+ append("newpath", true);
+ for (USegment seg : path) {
+ final USegmentType type = seg.getSegmentType();
+ final double coord[] = seg.getCoord();
+ if (type == USegmentType.SEG_MOVETO) {
+ movetoNoMacro(coord[0] + x, coord[1] + y);
+ } else if (type == USegmentType.SEG_LINETO) {
+ linetoNoMacro(coord[0] + x, coord[1] + y);
+ } else if (type == USegmentType.SEG_QUADTO) {
+ throw new UnsupportedOperationException();
+ } else if (type == USegmentType.SEG_CUBICTO) {
+ curvetoNoMacro(coord[0] + x, coord[1] + y, coord[2] + x, coord[3] + y, coord[4] + x, coord[5] + y);
+ } else if (type == USegmentType.SEG_CLOSE) {
+ // Nothing
+ } else {
+ Log.println("unknown " + seg);
+ }
+ }
+ append("closepath eofill", true);
+ }
+
+ if (color != null) {
+ append(strokeWidth + " setlinewidth", true);
+ appendColor(color);
+ append("newpath", true);
+ for (USegment seg : path) {
+ final USegmentType type = seg.getSegmentType();
+ final double coord[] = seg.getCoord();
+ if (type == USegmentType.SEG_MOVETO) {
+ movetoNoMacro(coord[0] + x, coord[1] + y);
+ } else if (type == USegmentType.SEG_LINETO) {
+ linetoNoMacro(coord[0] + x, coord[1] + y);
+ } else if (type == USegmentType.SEG_QUADTO) {
+ throw new UnsupportedOperationException();
+ } else if (type == USegmentType.SEG_CUBICTO) {
+ curvetoNoMacro(coord[0] + x, coord[1] + y, coord[2] + x, coord[3] + y, coord[4] + x, coord[5] + y);
+ } else if (type == USegmentType.SEG_CLOSE) {
+ // Nothing
+ } else {
+ Log.println("unknown " + seg);
+ }
+ }
+ append("stroke", true);
+ }
+
+ }
+
+ public void epsPolygon(HtmlColorGradient gr, ColorMapper mapper, double... points) {
+ setFillColor(mapper.getMappedColor(gr.getColor1()));
+ epsPolygon(points);
+ }
+
+ public void epsPolygon(double... points) {
+ checkCloseDone();
+ double lastX = 0;
+ double lastY = 0;
+ if (fillcolor != null) {
+ appendColor(fillcolor);
+ append("newpath", true);
+ for (int i = 0; i < points.length; i += 2) {
+ ensureVisible(points[i], points[i + 1]);
+ if (i == 0) {
+ append(format(points[i]) + " " + format(points[i + 1]) + " moveto", true);
+ } else {
+ append(format(points[i] - lastX) + " " + format(points[i + 1] - lastY) + " rlineto", true);
+ }
+ lastX = points[i];
+ lastY = points[i + 1];
+ }
+ append(format(points[0]) + " " + format(points[1]) + " lineto", true);
+ append("closepath eofill", true);
+ }
+
+ if (color != null) {
+ append(strokeWidth + " setlinewidth", true);
+ appendColor(color);
+ append("newpath", true);
+ for (int i = 0; i < points.length; i += 2) {
+ ensureVisible(points[i], points[i + 1]);
+ if (i == 0) {
+ append(format(points[i]) + " " + format(points[i + 1]) + " moveto", true);
+ } else {
+ append(format(points[i] - lastX) + " " + format(points[i + 1] - lastY) + " rlineto", true);
+ }
+ lastX = points[i];
+ lastY = points[i + 1];
+ }
+ append(format(points[0]) + " " + format(points[1]) + " lineto", true);
+ append("closepath stroke", true);
+ }
+
+ }
+
+ public void epsRectangle(double x, double y, double width, double height, double rx, double ry) {
+ checkCloseDone();
+ ensureVisible(x, y);
+ ensureVisible(x + width, y + height);
+ if (fillcolor != null) {
+ appendColor(fillcolor);
+ epsRectangleInternal(x, y, width, height, rx, ry, true);
+ append("closepath eofill", true);
+ }
+
+ if (color != null) {
+ append(strokeWidth + " setlinewidth", true);
+ appendColor(color);
+ epsRectangleInternal(x, y, width, height, rx, ry, false);
+ append("closepath stroke", true);
+ }
+ }
+
+ public void epsRectangle(double x, double y, double width, double height, double rx, double ry,
+ HtmlColorGradient gr, ColorMapper mapper) {
+ checkCloseDone();
+ ensureVisible(x, y);
+ ensureVisible(x + width, y + height);
+ setcolorgradientUsed = true;
+
+ if (rx == 0 && ry == 0) {
+ simplerectUsed = true;
+ appendColorShort(mapper.getMappedColor(gr.getColor1()));
+ appendColorShort(mapper.getMappedColor(gr.getColor2()));
+ append(format(width) + " " + format(height) + " " + format(x) + " " + format(y), true);
+ append("100 -1 1 {", true);
+ append("100 div", true);
+ append("newpath", true);
+ append("2 index 2 index moveto", true);
+ append("dup 5 index mul 2 mul dup 0 rlineto", true);
+ append("neg 4 index 2 index mul 2 mul rlineto", true);
+ append("closepath eoclip", true);
+ append("10 index 10 index 10 index", true);
+ append("10 index 10 index 10 index", true);
+ append("6 index setcolorgradient", true);
+ append("4 index 4 index 4 index 4 index simplerect", true);
+ append("closepath eofill", true);
+ append("pop", true);
+ append("} for", true);
+ append("pop pop pop pop", true);
+ append("pop pop pop", true);
+ append("pop pop pop", true);
+ append("initclip", true);
+ } else {
+ roundrectUsed = true;
+ appendColorShort(mapper.getMappedColor(gr.getColor1()));
+ appendColorShort(mapper.getMappedColor(gr.getColor2()));
+ append(format(width) + " " + format(height) + " " + format(x) + " " + format(y) + " "
+ + format((rx + ry) / 2), true);
+ append("100 -1 1 {", true);
+ append("100 div", true);
+ append("newpath", true);
+ append("3 index 3 index moveto", true);
+ append("dup 6 index mul 2 mul dup 0 rlineto", true);
+ append("neg 5 index 2 index mul 2 mul rlineto", true);
+ append("closepath eoclip", true);
+ append("11 index 11 index 11 index", true);
+ append("11 index 11 index 11 index", true);
+ append("6 index setcolorgradient", true);
+ append("5 index 5 index 5 index 5 index 5 index roundrect", true);
+ append("closepath eofill", true);
+ append("pop", true);
+ append("} for", true);
+ append("pop pop pop pop pop", true);
+ append("pop pop pop", true);
+ append("pop pop pop", true);
+ append("initclip", true);
+ }
+ }
+
+ private void epsRectangleInternal(double x, double y, double width, double height, double rx, double ry,
+ boolean fill) {
+ if (rx == 0 && ry == 0) {
+ simpleRectangle(x, y, width, height, fill);
+ } else {
+ roundRectangle(x, y, width, height, rx, ry);
+ }
+ }
+
+ private void roundRectangle(double x, double y, double width, double height, double rx, double ry) {
+ append(format(width) + " " + format(height) + " " + format(x) + " " + format(y) + " " + format((rx + ry) / 2)
+ + " roundrect", true);
+ roundrectUsed = true;
+ }
+
+ private void simpleRectangle(double x, double y, double width, double height, boolean fill) {
+ if ((dashSpace == 0 && dashVisible == 0) || fill) {
+ append(format(width) + " " + format(height) + " " + format(x) + " " + format(y) + " simplerect", true);
+ simplerectUsed = true;
+ } else {
+ epsVLine(y, x, x + width);
+ epsVLine(y + height, x, x + width);
+ epsHLine(x, y, y + height);
+ epsHLine(x + width, y, y + height);
+ }
+ }
+
+ public void epsEllipse(double x, double y, double xRadius, double yRadius, double start, double extend) {
+ checkCloseDone();
+ ensureVisible(x + xRadius, y + yRadius);
+ double scale = 1;
+ if (xRadius != yRadius) {
+ scale = yRadius / xRadius;
+ append("gsave", true);
+ append("1 " + format(scale) + " scale", true);
+ }
+ // if (fillcolor != null) {
+ // appendColor(fillcolor);
+ // append("newpath", true);
+ // append(format(x) + " " + format(y / scale) + " " + format(xRadius) + " 0 360 arc", true);
+ // append("closepath eofill", true);
+ // }
+
+ if (color != null) {
+ append(strokeWidth + " setlinewidth", true);
+ appendColor(color);
+ append("newpath", true);
+ final double a1 = -start + 180 + 5;
+ final double a2 = -start - extend + 180 - 5;
+ append(format(x) + " " + format(y / scale) + " " + format(xRadius) + " " + format(a1) + " " + format(a2)
+ + " arc", true);
+ append("stroke", true);
+ }
+
+ if (scale != 1) {
+ append("grestore", true);
+ }
+ }
+
+ public void epsEllipse(double x, double y, double xRadius, double yRadius) {
+ checkCloseDone();
+ ensureVisible(x + xRadius, y + yRadius);
+ double scale = 1;
+ if (xRadius != yRadius) {
+ scale = yRadius / xRadius;
+ append("gsave", true);
+ append("1 " + format(scale) + " scale", true);
+ }
+ if (fillcolor != null) {
+ appendColor(fillcolor);
+ append("newpath", true);
+ append(format(x) + " " + format(y / scale) + " " + format(xRadius) + " 0 360 arc", true);
+ append("closepath eofill", true);
+ }
+
+ if (color != null) {
+ append(strokeWidth + " setlinewidth", true);
+ appendColor(color);
+ append("newpath", true);
+ append(format(x) + " " + format(y / scale) + " " + format(xRadius) + " 0 360 arc", true);
+ append("closepath stroke", true);
+ }
+
+ if (scale != 1) {
+ append("grestore", true);
+ }
+ }
+
+ protected void appendColor(Color c) {
+ final double r = c.getRed() / 255.0;
+ final double g = c.getGreen() / 255.0;
+ final double b = c.getBlue() / 255.0;
+ append(format(r) + " " + format(g) + " " + format(b) + " setrgbcolor", true);
+ }
+
+ protected void appendColorShort(Color c) {
+ final double r = c.getRed() / 255.0;
+ final double g = c.getGreen() / 255.0;
+ final double b = c.getBlue() / 255.0;
+ append(format(r) + " " + format(g) + " " + format(b), true);
+ }
+
+ public static String format(double x) {
+ if (x == 0) {
+ return "0";
+ }
+ String s = String.format(Locale.US, "%1.4f", x);
+ s = s.replaceAll("(\\.\\d*?)0+$", "$1");
+ if (s.endsWith(".")) {
+ s = s.substring(0, s.length() - 1);
+ }
+ return s;
+ }
+
+ protected void append(String s, boolean checkConsistence) {
+ if (checkConsistence && s.indexOf(" ") != -1) {
+ throw new IllegalArgumentException(s);
+ }
+ body.append(s + "\n");
+ }
+
+ final public void linetoNoMacro(double x1, double y1) {
+ append(format(x1) + " " + format(y1) + " lineto", true);
+ ensureVisible(x1, y1);
+ }
+
+ final public void movetoNoMacro(double x1, double y1) {
+ append(format(x1) + " " + format(y1) + " moveto", true);
+ ensureVisible(x1, y1);
+ }
+
+ final public void curvetoNoMacro(double x1, double y1, double x2, double y2, double x3, double y3) {
+ append(format(x1) + " " + format(y1) + " " + format(x2) + " " + format(y2) + " " + format(x3) + " "
+ + format(y3) + " curveto", true);
+ ensureVisible(x1, y1);
+ ensureVisible(x2, y2);
+ ensureVisible(x3, y3);
+ }
+
+ // FONT
+ public void moveto(double x1, double y1) {
+ append(format(x1) + " " + format(y1) + " moveto", true);
+ ensureVisible(x1, y1);
+ }
+
+ public void lineto(double x1, double y1) {
+ append(format(x1) + " " + format(y1) + " lineto", true);
+ ensureVisible(x1, y1);
+ }
+
+ public void curveto(double x1, double y1, double x2, double y2, double x3, double y3) {
+ append(format(x1) + " " + format(y1) + " " + format(x2) + " " + format(y2) + " " + format(x3) + " "
+ + format(y3) + " curveto", true);
+ ensureVisible(x1, y1);
+ ensureVisible(x2, y2);
+ ensureVisible(x3, y3);
+ }
+
+ public void quadto(double x1, double y1, double x2, double y2) {
+ append(format(x1) + " " + format(y1) + " " + format(x1) + " " + format(y1) + " " + format(x2) + " "
+ + format(y2) + " curveto", true);
+ ensureVisible(x1, y1);
+ ensureVisible(x2, y2);
+ }
+
+ public void newpath() {
+ append("0 setlinewidth", true);
+ appendColor(color);
+ append("newpath", true);
+ }
+
+ public void closepath() {
+ append("closepath", true);
+ }
+
+ public void fill(int windingRule) {
+ append("%fill", true);
+ if (windingRule == PathIterator.WIND_EVEN_ODD) {
+ append("eofill", true);
+ } else if (windingRule == PathIterator.WIND_NON_ZERO) {
+ append("fill", true);
+ }
+ }
+
+ public void drawImage(BufferedImage image, double x, double y) {
+ final int width = image.getWidth();
+ final int height = image.getHeight();
+ append("gsave", true);
+ append(format(x) + " " + format(y) + " translate", true);
+ append(format(width) + " " + format(height) + " scale", true);
+ append("" + width + " " + height + " 8 [" + width + " 0 0 -" + height + " 0 " + height + "]", true);
+ // append("" + width + " " + height + " 8 [0 0 0 0 0 0]");
+ append("{<", true);
+ final StringBuilder sb = new StringBuilder();
+ for (int j = height - 1; j >= 0; j--) {
+ for (int i = 0; i < width; i++) {
+ final String hexString = getRgb(image.getRGB(i, j));
+ assert hexString.length() == 6;
+ sb.append(hexString);
+ }
+ }
+ append(sb.toString(), true);
+ // append(">} image");
+ append(">} false 3 colorimage", true);
+ ensureVisible(x + width, y + height);
+ append("grestore", true);
+ }
+
+ static String getRgb(int x) {
+ final String s = "000000" + Integer.toHexString(x);
+ return s.substring(s.length() - 6);
+ }
+
+ public void drawEps(String eps, double x, double y) {
+
+ final int idx = eps.indexOf("%%BoundingBox:");
+ if (idx == -1) {
+ throw new IllegalArgumentException();
+ }
+ final StringTokenizer st = new StringTokenizer(eps.substring(idx + "%%BoundingBox:".length()), " \n\t\r");
+ final int x1 = Integer.parseInt(st.nextToken());
+ final int y1 = Integer.parseInt(st.nextToken());
+ final int x2 = Integer.parseInt(st.nextToken());
+ final int y2 = Integer.parseInt(st.nextToken());
+ assert x2 >= x1;
+ assert y2 >= y1;
+
+ append("gsave", true);
+ final double dx = x - x1;
+ final double dy = y + y2;
+ append(format(dx) + " " + format(dy) + " translate", true);
+ append("1 -1 scale", true);
+ append(eps, false);
+ ensureVisible(x + (x2 - x1), y + (y2 - y1));
+ append("grestore", true);
+ }
+
+ protected final double getDashVisible() {
+ return dashVisible;
+ }
+
+ protected final double getDashSpace() {
+ return dashSpace;
+ }
+
+ static class UrlArea {
+ private final String url;
+ private int xmin = Integer.MAX_VALUE;
+ private int xmax = Integer.MIN_VALUE;
+ private int ymin = Integer.MAX_VALUE;
+ private int ymax = Integer.MIN_VALUE;
+
+ UrlArea(String url) {
+ this.url = url;
+ }
+
+ void ensureVisible(int x, int y) {
+ if (x < xmin) {
+ xmin = x;
+ }
+ if (x > xmax) {
+ xmax = x;
+ }
+ if (y < ymin) {
+ ymin = y;
+ }
+ if (y > ymax) {
+ ymax = y;
+ }
+ }
+ }
+
+ private UrlArea urlArea;
+
+ public void closeLink() {
+ if (urlArea != null && urlArea.xmin != Integer.MAX_VALUE) {
+ final int width = urlArea.xmax - urlArea.xmin;
+ final int height = urlArea.ymax - urlArea.ymin;
+ assert width >= 0 && height >= 0;
+ epsUrlLink(urlArea.xmin, urlArea.ymin, width, height, urlArea.url);
+ }
+ this.urlArea = null;
+ }
+
+ public void epsUrlLink(int x, int y, int width, int height, String url) {
+ append("[ /Rect [ " + x + " " + y + " " + (x + width) + " " + (y + height) + " ]", true);
+ append("/Border [ 0 0 0 ]", true);
+ append("/Action << /Subtype /URI /URI (" + url + ") >>", true);
+ append("/Subtype /Link", true);
+ append("/ANN pdfmark", true);
+ }
+
+ public void openLink(String url) {
+ this.urlArea = new UrlArea(url);
+ }
+
+ // Shadow
+ final private ShadowManager shadowManager = new ShadowManager(50, 200);
+
+ public void epsRectangleShadow(double x, double y, double width, double height, double rx, double ry,
+ double deltaShadow) {
+ setStrokeColor(null);
+ for (double i = 0; i <= deltaShadow; i += 0.5) {
+ setFillColor(shadowManager.getColor(i, deltaShadow));
+ final double diff = i;
+ epsRectangle(x + deltaShadow + diff, y + deltaShadow + diff, width - 2 * diff, height - 2 * diff, rx + 1,
+ ry + 1);
+ }
+ }
+
+ public void epsPolygonShadow(double deltaShadow, double... points) {
+ setStrokeColor(null);
+ for (double i = 0; i <= deltaShadow; i += 0.5) {
+ setFillColor(shadowManager.getColor(i, deltaShadow));
+ final double diff = i;
+ epsPolygon(shadowManager.getShadowDeltaPoints(deltaShadow, diff, points));
+ }
+ }
+
+ public void epsEllipseShadow(double x, double y, double xRadius, double yRadius, double deltaShadow) {
+ setStrokeColor(null);
+ for (double i = 0; i <= deltaShadow; i += 0.5) {
+ setFillColor(shadowManager.getColor(i, deltaShadow));
+ final double diff = i;
+ epsEllipse(x + deltaShadow, y + deltaShadow, xRadius - diff, yRadius - diff);
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/eps/EpsGraphicsMacro.java b/src/net/sourceforge/plantuml/eps/EpsGraphicsMacro.java
new file mode 100644
index 0000000..ac67870
--- /dev/null
+++ b/src/net/sourceforge/plantuml/eps/EpsGraphicsMacro.java
@@ -0,0 +1,207 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.eps;
+
+import java.awt.geom.PathIterator;
+import java.util.HashMap;
+import java.util.Map;
+
+public class EpsGraphicsMacro extends EpsGraphics {
+
+ private final PostScriptData data = new PostScriptData();
+ private final PostScriptCommandMacro rquadto = new PostScriptCommandMacro("rquadto");
+
+ public EpsGraphicsMacro() {
+ super();
+ rquadto.add(new PostScriptCommandRaw("3 index 3 index 4 2 roll rcurveto", true));
+ }
+
+ @Override
+ protected void append(String s, boolean checkConsistence) {
+ if (checkConsistence && s.indexOf(" ") != -1) {
+ throw new IllegalArgumentException(s);
+ }
+ data.add(new PostScriptCommandRaw(s, checkConsistence));
+ }
+
+ @Override
+ protected String getBodyString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append(rquadto.getPostStringDefinition());
+ for (PostScriptCommandMacro macro : macros.keySet()) {
+ sb.append(macro.getPostStringDefinition());
+ }
+ sb.append(data.toPostString());
+ return sb.toString();
+ }
+
+ // FONT
+ private double posX;
+ private double posY;
+ private int macroCpt;
+ private final Map<PostScriptCommandMacro, String> macros = new HashMap<PostScriptCommandMacro, String>();
+
+ @Override
+ public void newpath() {
+ append("0 setlinewidth", true);
+ append("[] 0 setdash", true);
+ appendColor(getColor());
+ append("newpath", true);
+ }
+
+ @Override
+ public void closepath() {
+ macroInProgress.add(new PostScriptCommandRaw("closepath", true));
+ closeMacro();
+ }
+
+ @Override
+ public void fill(int windingRule) {
+ if (windingRule == PathIterator.WIND_EVEN_ODD) {
+ append("eofill", true);
+ } else if (windingRule == PathIterator.WIND_NON_ZERO) {
+ append("fill", true);
+ }
+ }
+
+ private PostScriptCommandMacro macroInProgress = null;
+
+ @Override
+ public void moveto(double x1, double y1) {
+ data.add(new PostScriptCommandMoveTo(x1, y1));
+ this.posX = x1;
+ this.posY = y1;
+ openMacro();
+ ensureVisible(x1, y1);
+ }
+
+ @Override
+ public void lineto(double x1, double y1) {
+ final PostScriptCommand cmd = new PostScriptCommandLineTo(x1 - posX, y1 - posY);
+ macroInProgress.add(cmd);
+ this.posX = x1;
+ this.posY = y1;
+ ensureVisible(x1, y1);
+ }
+
+ @Override
+ public void curveto(double x1, double y1, double x2, double y2, double x3, double y3) {
+ final PostScriptCommandCurveTo cmd = new PostScriptCommandCurveTo(x1 - posX, y1 - posY, x2 - posX, y2 - posY,
+ x3 - posX, y3 - posY);
+ macroInProgress.add(cmd);
+ this.posX = x3;
+ this.posY = y3;
+ ensureVisible(x1, y1);
+ ensureVisible(x2, y2);
+ ensureVisible(x3, y3);
+ }
+
+ @Override
+ public void quadto(double x1, double y1, double x2, double y2) {
+ final PostScriptCommandQuadTo cmd = new PostScriptCommandQuadTo(x1 - posX, y1 - posY, x2 - posX, y2 - posY);
+ macroInProgress.add(cmd);
+ this.posX = x2;
+ this.posY = y2;
+ ensureVisible(x1, y1);
+ ensureVisible(x2, y2);
+ }
+
+ private void openMacro() {
+ if (macroInProgress != null) {
+ throw new IllegalStateException();
+ }
+ macroInProgress = new PostScriptCommandMacro(macroName());
+ }
+
+ private String macroName() {
+ return "P$" + Integer.toString(macroCpt, 36);
+ }
+
+ private void closeMacro() {
+ if (macroInProgress == null) {
+ throw new IllegalStateException();
+ }
+ final String existingName = macros.get(macroInProgress);
+ if (existingName == null) {
+ macros.put(macroInProgress, macroInProgress.getName());
+ append(macroName(), true);
+ macroCpt++;
+ } else {
+ append(existingName, true);
+ }
+ macroInProgress = null;
+ }
+
+ @Override
+ protected void epsHLine(double x, double ymin, double ymax) {
+ append(format(x) + " " + format(ymin) + " moveto", true);
+ int nb = (int) ((ymax - ymin) / (getDashVisible() + getDashSpace()));
+ final double lastY = ymin + nb * (getDashVisible() + getDashSpace());
+ double v = ymax - lastY;
+ if (v > getDashVisible()) {
+ v = getDashVisible();
+ nb++;
+ v = 0;
+ }
+ append(nb + "{", true);
+ append("0 " + format(getDashVisible()) + " rlineto", true);
+ append("0 " + format(getDashSpace()) + " rmoveto", true);
+ append("} repeat", true);
+ if (v > 0) {
+ append("0 " + format(v) + " rlineto", true);
+ }
+ }
+
+ @Override
+ protected void epsVLine(double y, double xmin, double xmax) {
+ append(format(xmin) + " " + format(y) + " moveto", true);
+ int nb = (int) ((xmax - xmin) / (getDashVisible() + getDashSpace()));
+ final double lastX = xmin + nb * (getDashVisible() + getDashSpace());
+ double v = xmax - lastX;
+ if (v > getDashVisible()) {
+ v = getDashVisible();
+ nb++;
+ v = 0;
+ }
+ append(nb + "{", true);
+ append(format(getDashVisible()) + " 0 rlineto", true);
+ append(format(getDashSpace()) + " 0 rmoveto", true);
+ append("} repeat", true);
+ if (v > 0) {
+ append(format(v) + " 0 rlineto", true);
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/eps/EpsGraphicsMacroAndText.java b/src/net/sourceforge/plantuml/eps/EpsGraphicsMacroAndText.java
new file mode 100644
index 0000000..6e6a504
--- /dev/null
+++ b/src/net/sourceforge/plantuml/eps/EpsGraphicsMacroAndText.java
@@ -0,0 +1,104 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.eps;
+
+import java.io.UnsupportedEncodingException;
+
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UFontContext;
+
+public class EpsGraphicsMacroAndText extends EpsGraphicsMacro {
+
+ public void drawText(String text, FontConfiguration fontConfiguration, double x, double y) {
+ append(format(x) + " " + format(y) + " moveto", true);
+ appendColor(getColor());
+ final UFont font = fontConfiguration.getFont();
+ final int size = font.getSize();
+ append("/" + getPSName(fontConfiguration) + " findfont " + size + " scalefont setfont", true);
+ append("1 -1 scale", true);
+ append("(" + getTextAsEps(text) + ") show", false);
+ append("1 -1 scale", true);
+ }
+
+ private String getPSName(FontConfiguration fontConfiguration) {
+ final UFont font = fontConfiguration.getFont();
+ final StringBuilder sb = new StringBuilder(font.getFamily(UFontContext.EPS));
+ // final int style = fontConfiguration.getFont().getStyle();
+ // final boolean bold = (style & Font.BOLD) != 0 || fontConfiguration.containsStyle(FontStyle.BOLD);
+ // final boolean italic = (style & Font.ITALIC) != 0 || fontConfiguration.containsStyle(FontStyle.ITALIC);
+ // if (bold && italic) {
+ // sb.append("-BoldItalic");
+ // } else if (bold) {
+ // sb.append("-Bold");
+ // } else if (italic) {
+ // sb.append("-Italic");
+ // }
+ return sb.toString();
+ }
+
+ private String getTextAsEps(String text) {
+ final StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < text.length(); i++) {
+ final char c = text.charAt(i);
+ if (c == '\\') {
+ sb.append("\\\\");
+ } else if (c == '(') {
+ sb.append("\\(");
+ } else if (c == ')') {
+ sb.append("\\)");
+ } else if (c < ' ') {
+ sb.append("?");
+ } else if (c >= ' ' && c <= 127) {
+ sb.append(c);
+ } else {
+ final String s = "" + c;
+ try {
+ final byte b[] = s.getBytes("ISO-8859-1");
+ if (b.length == 1) {
+ final int code = b[0] & 0xFF;
+ sb.append("\\" + Integer.toOctalString(code));
+ } else {
+ sb.append('?');
+ }
+ } catch (UnsupportedEncodingException e) {
+ sb.append('?');
+ }
+ }
+ }
+ return sb.toString();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/eps/EpsStrategy.java b/src/net/sourceforge/plantuml/eps/EpsStrategy.java
new file mode 100644
index 0000000..bf7a851
--- /dev/null
+++ b/src/net/sourceforge/plantuml/eps/EpsStrategy.java
@@ -0,0 +1,58 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.eps;
+
+public enum EpsStrategy {
+
+ VERY_SIMPLE, WITH_MACRO, WITH_MACRO_AND_TEXT;
+
+ public EpsGraphics creatEpsGraphics() {
+ if (this == VERY_SIMPLE) {
+ return new EpsGraphics();
+ }
+ if (this == WITH_MACRO) {
+ return new EpsGraphicsMacro();
+ }
+ if (this == WITH_MACRO_AND_TEXT) {
+ return new EpsGraphicsMacroAndText();
+ }
+ throw new IllegalArgumentException();
+ }
+
+ public static EpsStrategy getDefault2() {
+ return WITH_MACRO;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/eps/PostScriptCommand.java b/src/net/sourceforge/plantuml/eps/PostScriptCommand.java
new file mode 100644
index 0000000..a4b6059
--- /dev/null
+++ b/src/net/sourceforge/plantuml/eps/PostScriptCommand.java
@@ -0,0 +1,41 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.eps;
+
+public interface PostScriptCommand {
+
+ String toPostString();
+
+}
diff --git a/src/net/sourceforge/plantuml/eps/PostScriptCommandCurveTo.java b/src/net/sourceforge/plantuml/eps/PostScriptCommandCurveTo.java
new file mode 100644
index 0000000..6f46ece
--- /dev/null
+++ b/src/net/sourceforge/plantuml/eps/PostScriptCommandCurveTo.java
@@ -0,0 +1,60 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.eps;
+
+public class PostScriptCommandCurveTo implements PostScriptCommand {
+
+ private final double x1;
+ private final double y1;
+ private final double x2;
+ private final double y2;
+ private final double x3;
+ private final double y3;
+
+ public PostScriptCommandCurveTo(double x1, double y1, double x2, double y2, double x3, double y3) {
+ this.x1 = x1;
+ this.y1 = y1;
+ this.x2 = x2;
+ this.y2 = y2;
+ this.x3 = x3;
+ this.y3 = y3;
+ }
+
+ public String toPostString() {
+ return EpsGraphics.format(x1) + " " + EpsGraphics.format(y1) + " " + EpsGraphics.format(x2) + " "
+ + EpsGraphics.format(y2) + " " + EpsGraphics.format(x3) + " " + EpsGraphics.format(y3) + " rcurveto";
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/eps/PostScriptCommandLineTo.java b/src/net/sourceforge/plantuml/eps/PostScriptCommandLineTo.java
new file mode 100644
index 0000000..07ee796
--- /dev/null
+++ b/src/net/sourceforge/plantuml/eps/PostScriptCommandLineTo.java
@@ -0,0 +1,52 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.eps;
+
+
+public class PostScriptCommandLineTo implements PostScriptCommand {
+
+ private final double x;
+ private final double y;
+
+ public PostScriptCommandLineTo(double x, double y) {
+ this.x = x;
+ this.y = y;
+ }
+
+ public String toPostString() {
+ return EpsGraphics.format(x) + " " + EpsGraphics.format(y) + " rlineto";
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/eps/PostScriptCommandMacro.java b/src/net/sourceforge/plantuml/eps/PostScriptCommandMacro.java
new file mode 100644
index 0000000..04c5998
--- /dev/null
+++ b/src/net/sourceforge/plantuml/eps/PostScriptCommandMacro.java
@@ -0,0 +1,77 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.eps;
+
+public class PostScriptCommandMacro implements PostScriptCommand {
+
+ final private String name;
+ final private PostScriptData data = new PostScriptData();
+
+ public PostScriptCommandMacro(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void add(PostScriptCommand cmd) {
+ data.add(cmd);
+ }
+
+ public String toPostString() {
+ return name;
+ }
+
+ public String getPostStringDefinition() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("/" + name + " {\n");
+ sb.append(data.toPostString());
+ sb.append("} def\n");
+ return sb.toString();
+ }
+
+ @Override
+ public int hashCode() {
+ return data.toPostString().hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ final PostScriptCommandMacro other = (PostScriptCommandMacro) obj;
+ return this.data.toPostString().equals(other.data.toPostString());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/eps/PostScriptCommandMoveTo.java b/src/net/sourceforge/plantuml/eps/PostScriptCommandMoveTo.java
new file mode 100644
index 0000000..fccbd4f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/eps/PostScriptCommandMoveTo.java
@@ -0,0 +1,50 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.eps;
+
+public class PostScriptCommandMoveTo implements PostScriptCommand {
+
+ private final double x;
+ private final double y;
+
+ public PostScriptCommandMoveTo(double x, double y) {
+ this.x = x;
+ this.y = y;
+ }
+
+ public String toPostString() {
+ return EpsGraphics.format(x) + " " + EpsGraphics.format(y) + " moveto";
+ }
+}
diff --git a/src/net/sourceforge/plantuml/eps/PostScriptCommandQuadTo.java b/src/net/sourceforge/plantuml/eps/PostScriptCommandQuadTo.java
new file mode 100644
index 0000000..2165d5a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/eps/PostScriptCommandQuadTo.java
@@ -0,0 +1,56 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.eps;
+
+public class PostScriptCommandQuadTo implements PostScriptCommand {
+
+ private final double x1;
+ private final double y1;
+ private final double x2;
+ private final double y2;
+
+ public PostScriptCommandQuadTo(double x1, double y1, double x2, double y2) {
+ this.x1 = x1;
+ this.y1 = y1;
+ this.x2 = x2;
+ this.y2 = y2;
+ }
+
+ public String toPostString() {
+ return EpsGraphics.format(x1) + " " + EpsGraphics.format(y1) + " " + EpsGraphics.format(x2) + " "
+ + EpsGraphics.format(y2) + " rquadto";
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/eps/PostScriptCommandRaw.java b/src/net/sourceforge/plantuml/eps/PostScriptCommandRaw.java
new file mode 100644
index 0000000..bce1aaa
--- /dev/null
+++ b/src/net/sourceforge/plantuml/eps/PostScriptCommandRaw.java
@@ -0,0 +1,52 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.eps;
+
+public class PostScriptCommandRaw implements PostScriptCommand {
+
+ final private String cmd;
+
+ public PostScriptCommandRaw(String cmd, boolean checkConsistence) {
+ if (checkConsistence && cmd.indexOf('\n') != -1) {
+ throw new IllegalArgumentException(cmd);
+ }
+ this.cmd = cmd;
+ }
+
+ public String toPostString() {
+ return cmd;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/eps/PostScriptData.java b/src/net/sourceforge/plantuml/eps/PostScriptData.java
new file mode 100644
index 0000000..7bb2d3e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/eps/PostScriptData.java
@@ -0,0 +1,67 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.eps;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class PostScriptData {
+
+ private final List<PostScriptCommand> data = new ArrayList<PostScriptCommand>();
+
+ private String toString;
+
+ public String toPostString() {
+ if (this.toString == null) {
+ this.toString = toPostStringSlow();
+ }
+ return this.toString;
+ }
+
+ private String toPostStringSlow() {
+ final StringBuilder sb = new StringBuilder();
+ for (PostScriptCommand cmd : data) {
+ sb.append(cmd.toPostString());
+ sb.append('\n');
+ }
+ return sb.toString();
+ }
+
+ public void add(PostScriptCommand cmd) {
+ data.add(cmd);
+ this.toString = null;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/flashcode/FlashCodeFactory.java b/src/net/sourceforge/plantuml/flashcode/FlashCodeFactory.java
new file mode 100644
index 0000000..938a647
--- /dev/null
+++ b/src/net/sourceforge/plantuml/flashcode/FlashCodeFactory.java
@@ -0,0 +1,53 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.flashcode;
+
+public class FlashCodeFactory {
+
+ public static FlashCodeUtils getFlashCodeUtils() {
+ final String name = "net.sourceforge.plantuml.flashcode.FlashCodeUtilsZxing";
+ try {
+ final Class cl = Class.forName(name);
+ return (FlashCodeUtils) cl.newInstance();
+ } catch (ClassNotFoundException e) {
+ return new FlashCodeUtilsNone();
+ } catch (InstantiationException e) {
+ return new FlashCodeUtilsNone();
+ } catch (IllegalAccessException e) {
+ return new FlashCodeUtilsNone();
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/flashcode/FlashCodeUtils.java b/src/net/sourceforge/plantuml/flashcode/FlashCodeUtils.java
new file mode 100644
index 0000000..1455c1d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/flashcode/FlashCodeUtils.java
@@ -0,0 +1,43 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.flashcode;
+
+import java.awt.image.BufferedImage;
+
+public interface FlashCodeUtils {
+
+ public BufferedImage exportFlashcode(String s);
+
+}
diff --git a/src/net/sourceforge/plantuml/flashcode/FlashCodeUtilsNone.java b/src/net/sourceforge/plantuml/flashcode/FlashCodeUtilsNone.java
new file mode 100644
index 0000000..3ec50ee
--- /dev/null
+++ b/src/net/sourceforge/plantuml/flashcode/FlashCodeUtilsNone.java
@@ -0,0 +1,45 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.flashcode;
+
+import java.awt.image.BufferedImage;
+
+public class FlashCodeUtilsNone implements FlashCodeUtils {
+
+ public BufferedImage exportFlashcode(String s) {
+ return null;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/flowdiagram/ActivityBox.java b/src/net/sourceforge/plantuml/flowdiagram/ActivityBox.java
new file mode 100644
index 0000000..12ecc31
--- /dev/null
+++ b/src/net/sourceforge/plantuml/flowdiagram/ActivityBox.java
@@ -0,0 +1,110 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.flowdiagram;
+
+import java.awt.Font;
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.SpriteContainerEmpty;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.golem.Tile;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.ugraphic.Shadowable;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ActivityBox implements TextBlock {
+
+ private static final int CORNER = 25;
+ private static final int MARGIN = 10;
+
+ private final Tile tile;
+ private final String id;
+ private final String label;
+ private final TextBlock tb;
+
+ public ActivityBox(Tile tile, String id, String label) {
+ this.tile = tile;
+ this.id = id;
+ this.label = label;
+ final UFont font = new UFont("Serif", Font.PLAIN, 14);
+ final FontConfiguration fc = new FontConfiguration(font, HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true);
+ tb = TextBlockUtils.create(Display.create(label), fc, HorizontalAlignment.LEFT, new SpriteContainerEmpty());
+ }
+
+ public Tile getTile() {
+ return tile;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dimTotal = calculateDimension(ug.getStringBounder());
+ // final Dimension2D dimDesc = tb.calculateDimension(ug.getStringBounder());
+
+ final double widthTotal = dimTotal.getWidth();
+ final double heightTotal = dimTotal.getHeight();
+ final Shadowable rect = new URectangle(widthTotal, heightTotal, CORNER, CORNER);
+ ug = ug.apply(new UChangeColor(HtmlColorUtils.MY_RED));
+ ug = ug.apply(new UChangeBackColor(HtmlColorUtils.MY_YELLOW));
+ ug.apply(new UStroke(1.5)).draw(rect);
+
+ tb.drawU(ug.apply(new UTranslate(MARGIN, MARGIN)));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dim = tb.calculateDimension(stringBounder);
+
+ return Dimension2DDouble.delta(dim, 2 * MARGIN, 2 * MARGIN);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/flowdiagram/CommandLineSimple.java b/src/net/sourceforge/plantuml/flowdiagram/CommandLineSimple.java
new file mode 100644
index 0000000..629dc3b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/flowdiagram/CommandLineSimple.java
@@ -0,0 +1,72 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.flowdiagram;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.golem.TileGeometry;
+
+public class CommandLineSimple extends SingleLineCommand2<FlowDiagram> {
+
+ public CommandLineSimple() {
+ super(getRegexConcat());
+ }
+
+ private static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("ORIENTATION", "(?:([nsew])[%s]+)?"), //
+ new RegexLeaf("ID_DEST", "(\\w+)"), //
+ new RegexLeaf("[%s]+"), //
+ new RegexLeaf("LABEL", "[%g](.*)[%g]"), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(FlowDiagram diagram, RegexResult arg) {
+ final String idDest = arg.get("ID_DEST", 0);
+ final String label = arg.get("LABEL", 0);
+ final String orientationString = arg.get("ORIENTATION", 0);
+ TileGeometry orientation = TileGeometry.SOUTH;
+ if (orientationString != null) {
+ orientation = TileGeometry.fromString(orientationString);
+ }
+ diagram.lineSimple(orientation, idDest, label);
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/flowdiagram/CommandLink.java b/src/net/sourceforge/plantuml/flowdiagram/CommandLink.java
new file mode 100644
index 0000000..77fa639
--- /dev/null
+++ b/src/net/sourceforge/plantuml/flowdiagram/CommandLink.java
@@ -0,0 +1,69 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.flowdiagram;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.golem.TileGeometry;
+
+public class CommandLink extends SingleLineCommand2<FlowDiagram> {
+
+ public CommandLink() {
+ super(getRegexConcat());
+ }
+
+ private static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("ORIENTATION", "(?:([nsew])[%s]+)?"), //
+ new RegexLeaf("ID_DEST", "(\\w+)"), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(FlowDiagram system, RegexResult arg) {
+ final String idDest = arg.get("ID_DEST", 0);
+ final String orientationString = arg.get("ORIENTATION", 0);
+ TileGeometry orientation = TileGeometry.SOUTH;
+ if (orientationString != null) {
+ orientation = TileGeometry.fromString(orientationString);
+ }
+ system.linkSimple(orientation, idDest);
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/flowdiagram/FlowDiagram.java b/src/net/sourceforge/plantuml/flowdiagram/FlowDiagram.java
new file mode 100644
index 0000000..cb665b0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/flowdiagram/FlowDiagram.java
@@ -0,0 +1,206 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.flowdiagram;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.UmlDiagram;
+import net.sourceforge.plantuml.UmlDiagramType;
+import net.sourceforge.plantuml.api.ImageDataSimple;
+import net.sourceforge.plantuml.core.DiagramDescription;
+import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.golem.MinMaxGolem;
+import net.sourceforge.plantuml.golem.Path;
+import net.sourceforge.plantuml.golem.Position;
+import net.sourceforge.plantuml.golem.Tile;
+import net.sourceforge.plantuml.golem.TileArea;
+import net.sourceforge.plantuml.golem.TileGeometry;
+import net.sourceforge.plantuml.golem.TilesField;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UGraphicUtils;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class FlowDiagram extends UmlDiagram implements TextBlock {
+
+ private static double SINGLE_SIZE_X = 100;
+ private static double SINGLE_SIZE_Y = 35;
+
+ private TilesField field;
+ private final Map<Tile, ActivityBox> tilesBoxes = new HashMap<Tile, ActivityBox>();
+ private Tile lastTile;
+
+ public DiagramDescription getDescription() {
+ return new DiagramDescriptionImpl("Flow Diagram", getClass());
+ }
+
+ @Override
+ public UmlDiagramType getUmlDiagramType() {
+ return UmlDiagramType.FLOW;
+ }
+
+ public void lineSimple(TileGeometry orientation, String idDest, String label) {
+ final Tile newTile;
+ if (field == null) {
+ field = new TilesField();
+ tilesBoxes.clear();
+ newTile = field.getRoot();
+ } else {
+ newTile = field.createTile(lastTile, orientation);
+ }
+ final ActivityBox box = new ActivityBox(newTile, idDest, label);
+ tilesBoxes.put(newTile, box);
+ lastTile = newTile;
+ return;
+ }
+
+ public void linkSimple(TileGeometry orientation, String idDest) {
+ final Tile tile = getTileById(idDest);
+ field.addPath(lastTile, tile, orientation);
+ }
+
+ private Tile getTileById(String id) {
+ for (Map.Entry<Tile, ActivityBox> ent : tilesBoxes.entrySet()) {
+ if (ent.getValue().getId().equals(id)) {
+ return ent.getKey();
+ }
+ }
+ throw new IllegalArgumentException(id);
+ }
+
+ @Override
+ protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption) throws IOException {
+ UGraphicUtils.writeImage(os, null, fileFormatOption, new ColorMapperIdentity(), HtmlColorUtils.WHITE, this);
+ return new ImageDataSimple();
+ }
+
+ public void drawU(UGraphic ug) {
+ double x = 0;
+ double y = 0;
+ final MinMaxGolem minMax = getMinMax();
+ x -= minMax.getMinX() * SINGLE_SIZE_X;
+ y -= minMax.getMinY() * SINGLE_SIZE_Y;
+ final StringBounder stringBounder = ug.getStringBounder();
+ for (Map.Entry<Tile, ActivityBox> ent : tilesBoxes.entrySet()) {
+ final Tile tile = ent.getKey();
+ final Position pos = field.getPosition(tile);
+ final int xmin = pos.getXmin();
+ final int ymin = pos.getYmin();
+ final ActivityBox box = ent.getValue();
+ final Dimension2D dimBox = box.calculateDimension(stringBounder);
+ final double deltaX = SINGLE_SIZE_X * 2 - dimBox.getWidth();
+ final double deltaY = SINGLE_SIZE_Y * 2 - dimBox.getHeight();
+ box.drawU(ug.apply(new UTranslate((x + xmin * SINGLE_SIZE_X + deltaX / 2), (y + ymin
+ * SINGLE_SIZE_Y + deltaY / 2))));
+ }
+ ug = ug.apply(new UChangeColor(HtmlColorUtils.MY_RED));
+ ug = ug.apply(new UChangeBackColor(HtmlColorUtils.MY_RED));
+ final UShape arrow = new UEllipse(7, 7);
+ for (Path p : field.getPaths()) {
+ final TileArea start = p.getStart();
+ final TileArea dest = p.getDest();
+ final Point2D pStart = movePoint(getCenter(start), start.getTile(), start.getGeometry(), stringBounder);
+ final Point2D pDest = movePoint(getCenter(dest), dest.getTile(), dest.getGeometry(), stringBounder);
+ final ULine line = new ULine(pDest.getX() - pStart.getX(), pDest.getY() - pStart.getY());
+ ug.apply(new UTranslate(x + pStart.getX(), y + pStart.getY())).draw(line);
+ ug.apply(new UTranslate(x + pDest.getX() - 3, y + pDest.getY() - 3)).draw(arrow);
+
+ }
+ }
+
+ private Point2D getCenter(TileArea area) {
+ final Tile tile = area.getTile();
+ final Position position = field.getPosition(tile);
+ final double x = position.getCenterX();
+ final double y = position.getCenterY();
+ return new Point2D.Double(x * SINGLE_SIZE_X, y * SINGLE_SIZE_Y);
+ }
+
+ private Point2D movePoint(Point2D pt, Tile tile, TileGeometry tileGeometry, StringBounder stringBounder) {
+ final Dimension2D dim = tilesBoxes.get(tile).calculateDimension(stringBounder);
+ final double width = dim.getWidth();
+ final double height = dim.getHeight();
+ double x = pt.getX();
+ double y = pt.getY();
+ switch (tileGeometry) {
+ case SOUTH:
+ y += height / 2;
+ break;
+ case NORTH:
+ y -= height / 2;
+ break;
+ case EAST:
+ x += width / 2;
+ break;
+ case WEST:
+ x -= width / 2;
+ break;
+ default:
+ throw new IllegalStateException();
+ }
+ return new Point2D.Double(x, y);
+ }
+
+ private MinMaxGolem getMinMax() {
+ final MinMaxGolem minMax = new MinMaxGolem();
+ for (Tile tile : tilesBoxes.keySet()) {
+ minMax.manage(field.getPosition(tile));
+ }
+ return minMax;
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final MinMaxGolem minMax = getMinMax();
+ return new Dimension2DDouble(minMax.getWidth() * SINGLE_SIZE_X, minMax.getHeight() * SINGLE_SIZE_Y);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/flowdiagram/FlowDiagramFactory.java b/src/net/sourceforge/plantuml/flowdiagram/FlowDiagramFactory.java
new file mode 100644
index 0000000..8e1fa27
--- /dev/null
+++ b/src/net/sourceforge/plantuml/flowdiagram/FlowDiagramFactory.java
@@ -0,0 +1,63 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.flowdiagram;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.command.Command;
+import net.sourceforge.plantuml.command.UmlDiagramFactory;
+import net.sourceforge.plantuml.core.DiagramType;
+
+public class FlowDiagramFactory extends UmlDiagramFactory {
+
+ public FlowDiagramFactory() {
+ super(DiagramType.FLOW);
+ }
+
+ @Override
+ public FlowDiagram createEmptyDiagram() {
+ return new FlowDiagram();
+ }
+
+ @Override
+ protected List<Command> createCommands() {
+ final List<Command> cmds = new ArrayList<Command>();
+ cmds.add(new CommandLineSimple());
+ cmds.add(new CommandLink());
+ return cmds;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/font/PSystemListFonts.java b/src/net/sourceforge/plantuml/font/PSystemListFonts.java
new file mode 100644
index 0000000..c9b260e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/font/PSystemListFonts.java
@@ -0,0 +1,94 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.font;
+
+import java.awt.Font;
+import java.awt.GraphicsEnvironment;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.core.DiagramDescription;
+import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.graphic.GraphicStrings;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+import net.sourceforge.plantuml.ugraphic.ImageBuilder;
+import net.sourceforge.plantuml.ugraphic.UAntiAliasing;
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public class PSystemListFonts extends AbstractPSystem {
+
+ private final List<String> strings = new ArrayList<String>();
+
+ public PSystemListFonts(String text) {
+ strings.add(" <b><size:16>Fonts available:");
+ strings.add(" ");
+ // final Font fonts[] = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
+ // for (Font f : fonts) {
+ // strings.add("f=" + f + "/" + f.getPSName() + "/" + f.getName() + "/" + f.getFontName() + "/"
+ // + f.getFamily());
+ // }
+ final String name[] = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
+ for (String n : name) {
+ strings.add(n + " : <font:" + n + ">" + text);
+ }
+
+ }
+
+ public ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormat) throws IOException {
+ final GraphicStrings result = getGraphicStrings();
+ final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(),
+ getMetadata(), null, 0, 0, null, false);
+ imageBuilder.addUDrawable(result);
+ return imageBuilder.writeImageTOBEMOVED(fileFormat.getFileFormat(), os);
+ }
+
+ 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,
+ UAntiAliasing.ANTI_ALIASING_ON);
+ return result;
+ }
+
+ public DiagramDescription getDescription() {
+ return new DiagramDescriptionImpl("(List fonts)", getClass());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/font/PSystemListFontsFactory.java b/src/net/sourceforge/plantuml/font/PSystemListFontsFactory.java
new file mode 100644
index 0000000..311c24b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/font/PSystemListFontsFactory.java
@@ -0,0 +1,54 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.font;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.command.PSystemSingleLineFactory;
+
+public class PSystemListFontsFactory extends PSystemSingleLineFactory {
+
+ @Override
+ protected AbstractPSystem executeLine(String line) {
+ final String lineLower = StringUtils.goLowerCase(line);
+ if (lineLower.equals("listfont") || lineLower.equals("listfonts") || lineLower.startsWith("listfont ")
+ || lineLower.startsWith("listfonts ")) {
+ final int idx = line.indexOf(' ');
+ return new PSystemListFonts(idx == -1 ? "This is a test" : line.substring(idx).trim());
+ }
+ return null;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ftp/FtpConnexion.java b/src/net/sourceforge/plantuml/ftp/FtpConnexion.java
new file mode 100644
index 0000000..547ac04
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ftp/FtpConnexion.java
@@ -0,0 +1,187 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ftp;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import net.sourceforge.plantuml.FileFormat;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.SourceStringReader;
+import net.sourceforge.plantuml.core.DiagramDescription;
+
+public class FtpConnexion {
+
+ private final String user;
+ private final Map<String, String> incoming = new HashMap<String, String>();
+ private final Map<String, byte[]> outgoing = new HashMap<String, byte[]>();
+ private final Set<String> futureOutgoing = new HashSet<String>();
+
+ private FileFormat fileFormat;
+
+ public FtpConnexion(String user, FileFormat defaultfileFormat) {
+ this.user = user;
+ this.fileFormat = defaultfileFormat;
+ }
+
+ public synchronized void addIncoming(String fileName, String data) {
+ if (fileName.startsWith("/")) {
+ throw new IllegalArgumentException();
+ }
+ incoming.put(fileName, data);
+ }
+
+ public synchronized void futureOutgoing(String fileName) {
+ outgoing.remove(fileName);
+ futureOutgoing.add(fileName);
+ }
+
+ public synchronized Collection<String> getFiles() {
+ final List<String> result = new ArrayList<String>(incoming.keySet());
+ result.addAll(outgoing.keySet());
+ return Collections.unmodifiableCollection(result);
+ }
+
+ public synchronized boolean willExist(String fileName) {
+ if (incoming.containsKey(fileName)) {
+ return true;
+ }
+ if (outgoing.containsKey(fileName)) {
+ return true;
+ }
+ if (futureOutgoing.contains(fileName)) {
+ return true;
+ }
+ return false;
+ }
+
+ public synchronized byte[] getData(String fileName) throws InterruptedException {
+ if (fileName.startsWith("/")) {
+ throw new IllegalArgumentException();
+ }
+ final String data = incoming.get(fileName);
+ if (data != null) {
+ return data.getBytes();
+ }
+ do {
+ if (willExist(fileName) == false) {
+ return null;
+ }
+ final byte data2[] = outgoing.get(fileName);
+ if (data2 != null) {
+ return data2;
+ }
+ Thread.sleep(200L);
+ } while (true);
+ }
+
+ public synchronized int getSize(String fileName) {
+ if (fileName.startsWith("/")) {
+ throw new IllegalArgumentException();
+ }
+ final String data = incoming.get(fileName);
+ if (data != null) {
+ return data.length();
+ }
+ final byte data2[] = outgoing.get(fileName);
+ if (data2 != null) {
+ return data2.length;
+ }
+ return 0;
+ }
+
+ public void processImage(String fileName) throws IOException {
+ if (fileName.startsWith("/")) {
+ throw new IllegalArgumentException();
+ }
+ final String pngFileName = getFutureFileName(fileName);
+ boolean done = false;
+ try {
+ final SourceStringReader sourceStringReader = new SourceStringReader(incoming.get(fileName));
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final FileFormat format = getFileFormat();
+ final DiagramDescription desc = sourceStringReader.generateDiagramDescription(baos, new FileFormatOption(
+ format));
+ final String errorFileName = pngFileName.substring(0, pngFileName.length() - 4) + ".err";
+ synchronized (this) {
+ outgoing.remove(pngFileName);
+ futureOutgoing.remove(pngFileName);
+ outgoing.remove(errorFileName);
+ if (desc != null && desc.getDescription() != null) {
+ outgoing.put(pngFileName, baos.toByteArray());
+ done = true;
+ if (desc.getDescription().startsWith("(Error)")) {
+ final ByteArrayOutputStream errBaos = new ByteArrayOutputStream();
+ sourceStringReader.generateImage(errBaos, new FileFormatOption(FileFormat.ATXT));
+ errBaos.close();
+ outgoing.put(errorFileName, errBaos.toByteArray());
+ }
+ }
+ }
+ } finally {
+ if (done == false) {
+ outgoing.put(pngFileName, new byte[0]);
+ }
+ }
+ }
+
+ public String getFutureFileName(String fileName) {
+ return getFileFormat().changeName(fileName, 0);
+ }
+
+ private FileFormat getFileFormat() {
+ return fileFormat;
+ }
+
+ public synchronized void delete(String fileName) {
+ incoming.remove(fileName);
+ outgoing.remove(fileName);
+ futureOutgoing.add(fileName);
+ }
+
+ public void setFileFormat(FileFormat fileFormat) {
+ this.fileFormat = fileFormat;
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ftp/FtpLoop.java b/src/net/sourceforge/plantuml/ftp/FtpLoop.java
new file mode 100644
index 0000000..a934c0b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ftp/FtpLoop.java
@@ -0,0 +1,321 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ftp;
+
+// server
+
+// FtpServer.java
+import java.io.BufferedReader;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.UnknownHostException;
+import java.util.Collection;
+import java.util.StringTokenizer;
+
+import net.sourceforge.plantuml.FileFormat;
+import net.sourceforge.plantuml.FileUtils;
+import net.sourceforge.plantuml.StringUtils;
+
+class FtpLoop implements Runnable {
+ enum Mode {
+ ACTIF, PASSIF
+ };
+
+ final private Socket incoming;
+ final private FtpServer ftpServer;
+ final private BufferedReader br;
+ final private PrintWriter pw;
+
+ private FtpConnexion connexion;
+ private String ipClient = null;
+ private int port = -1;
+ private Mode mode;
+
+ public FtpLoop(Socket socket, FtpServer ftpServer) throws IOException {
+ this.incoming = socket;
+ this.ftpServer = ftpServer;
+ this.br = new BufferedReader(new InputStreamReader(incoming.getInputStream(), ftpServer.getCharset()));
+ this.pw = new PrintWriter(incoming.getOutputStream(), true);
+ }
+
+ // http://www.ncftp.com/libncftp/doc/ftp_overview.html
+ // http://www.nsftools.com/tips/RawFTP.htm
+ // http://www.commentcamarche.net/contents/internet/ftp.php3
+ // http://en.wikipedia.org/wiki/List_of_FTP_server_return_codes
+ // http://www.freefire.org/articles/ftpexample.php
+ // http://forum.hardware.fr/hfr/Programmation/VB-VBA-VBS/transfert-sujet_59989_1.htm
+ // http://www.excel-downloads.com/forum/104130-telechargement-ftp-via-vba.html
+ // http://www.pcreview.co.uk/forums/ftp-vba-macro-t949945.html
+ private void runInternal() throws IOException, InterruptedException {
+ localLog("Starting Loop");
+ myOut("220 PlantUML");
+ while (true) {
+ final String s = br.readLine();
+ localLog("s=" + s);
+ if (s == null) {
+ pw.close();
+ br.close();
+ return;
+ }
+ final boolean finish = manage(s);
+ if (finish) {
+ return;
+ }
+ }
+ }
+
+ private boolean manage(final String cmd) throws UnknownHostException, IOException, InterruptedException {
+ final String upper = StringUtils.goUpperCase(cmd);
+ if (upper.startsWith("USER")) {
+ myOut("331 Password required");
+ final String user = cmd.substring("USER ".length());
+ connexion = ftpServer.getFtpConnexion(user);
+ } else if (upper.startsWith("PASS")) {
+ myOut("230 Logged in.");
+ } else if (upper.startsWith("PWD")) {
+ // myOut("/");
+ // myOut("200 OK /");
+ myOut("257 \"/\" is current directory.");
+ } else if (upper.startsWith("CWD")) {
+ final String dir = cmd.substring("CWD ".length());
+ myOut("250 \"" + dir + "\" is new working directory..");
+ } else if (upper.startsWith("TYPE")) {
+ myOut("200 Command okay.");
+ // localLog("type=" + s);
+ } else if (upper.startsWith("PORT")) {
+ mode = Mode.ACTIF;
+ final StringTokenizer st = new StringTokenizer(cmd, " ,");
+ st.nextToken();
+ ipClient = st.nextToken() + "." + st.nextToken() + "." + st.nextToken() + "." + st.nextToken();
+ port = Integer.parseInt(st.nextToken()) * 256 + Integer.parseInt(st.nextToken());
+ // localLog("ipClient=" + ipClient);
+ // localLog("port=" + port);
+
+ myOut("200 Command okay.");
+ } else if (upper.startsWith("LIST")) {
+ if (mode == Mode.ACTIF) {
+ listActif();
+ } else {
+ listPassif();
+ }
+ } else if (upper.startsWith("STOR")) {
+ if (mode == Mode.ACTIF) {
+ storActif(cmd);
+ } else {
+ storPassif(cmd);
+ }
+ } else if (upper.startsWith("PASV")) {
+ mode = Mode.PASSIF;
+ port = ftpServer.getFreePort();
+ final int p1 = port / 256;
+ final int p2 = port % 256;
+ assert port == p1 * 256 + p2;
+ localLog("adr=" + incoming.getInetAddress().getHostAddress());
+ final String ipServer = ftpServer.getIpServer();
+ localLog("server=" + ipServer);
+ myOut("227 Entering Passive Mode (" + ipServer.replace('.', ',') + "," + p1 + "," + p2 + ").");
+ ipClient = ipServer;
+ } else if (upper.startsWith("RETR")) {
+ if (mode == Mode.ACTIF) {
+ retrActif(cmd);
+ } else {
+ retrPassif(cmd);
+ }
+ } else if (upper.startsWith("DELE")) {
+ final String file = cmd.substring("DELE ".length());
+ connexion.delete(file);
+ myOut("200 Command okay.");
+ } else if (upper.startsWith("QUIT")) {
+ myOut("221 Goodbye.");
+ return true;
+ } else if (upper.startsWith("SYST")) {
+ myOut("215 UNIX Type: L8.");
+ } else {
+ myOut("502 Command not implemented.");
+ }
+ return false;
+ }
+
+ private void localLog(String s) {
+ }
+
+ private void retr(final String fileName, Socket soc) throws UnknownHostException, IOException, InterruptedException {
+ final OutputStream os = soc.getOutputStream();
+ final byte[] data = connexion.getData(fileName);
+
+ if (data != null) {
+ os.write(data);
+ }
+ os.flush();
+ os.close();
+ soc.close();
+ myOut("226 Transfer complete.");
+ }
+
+ private void retrPassif(final String s) throws UnknownHostException, IOException, InterruptedException {
+ String fileName = s.substring("STOR ".length());
+ fileName = removeStartingsSlash(fileName);
+ if (connexion.willExist(fileName) == false) {
+ myOut("550 No such file.");
+ return;
+ }
+ myOut("150 Opening");
+ final ServerSocket ss = new ServerSocket(port);
+ final Socket incoming = ss.accept();
+ retr(fileName, incoming);
+ ss.close();
+ }
+
+ private void retrActif(final String s) throws UnknownHostException, IOException, InterruptedException {
+ String fileName = s.substring("STOR ".length());
+ fileName = removeStartingsSlash(fileName);
+ if (connexion.willExist(fileName) == false) {
+ myOut("550 No such file.");
+ return;
+ }
+ myOut("150 Opening");
+ final Socket soc = new Socket(ipClient, port);
+ retr(fileName, soc);
+ }
+
+ private void storActif(final String s) throws IOException {
+ final String fileName = removeStartingsSlash(s.substring("STOR ".length()));
+ myOut("150 FILE: " + fileName);
+ final Socket soc = new Socket(ipClient, port);
+ stor(fileName, soc);
+ }
+
+ private void storPassif(final String s) throws IOException {
+ final String fileName = removeStartingsSlash(s.substring("STOR ".length()));
+ myOut("150 FILE: " + fileName);
+ final ServerSocket ss = new ServerSocket(port);
+ final Socket incoming = ss.accept();
+ stor(fileName, incoming);
+ ss.close();
+ }
+
+ private String removeStartingsSlash(String fileName) {
+ while (fileName.startsWith("/")) {
+ fileName = fileName.substring(1);
+ }
+ return fileName;
+ }
+
+ private void stor(String fileName, Socket socket) throws UnknownHostException, IOException {
+ final InputStream is = socket.getInputStream();
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ FileUtils.copyToStream(is, baos);
+
+ myOut("226 Transfer complete.");
+
+ if ("png".equalsIgnoreCase(fileName)) {
+ connexion.setFileFormat(FileFormat.PNG);
+ } else if ("svg".equalsIgnoreCase(fileName)) {
+ connexion.setFileFormat(FileFormat.SVG);
+ } else if ("eps".equalsIgnoreCase(fileName)) {
+ connexion.setFileFormat(FileFormat.EPS);
+ }
+
+ if (fileName.length() > 3) {
+ final String data = new String(baos.toByteArray(), ftpServer.getCharset());
+ final String pngFileName = connexion.getFutureFileName(fileName);
+ connexion.futureOutgoing(pngFileName);
+ connexion.addIncoming(fileName, data);
+
+ ftpServer.processImage(connexion, fileName);
+ }
+ }
+
+ private void listActif() throws UnknownHostException, IOException {
+ myOut("150 Opening ASCII mode data");
+ final Socket soc = new Socket(ipClient, port);
+ list(soc);
+ }
+
+ private void listPassif() throws UnknownHostException, IOException {
+ myOut("150 Opening ASCII mode data");
+ final ServerSocket ss = new ServerSocket(port);
+ final Socket incoming = ss.accept();
+ list(incoming);
+ ss.close();
+ }
+
+ private void list(final Socket soc) throws IOException {
+ final PrintWriter listing = new PrintWriter(soc.getOutputStream(), true);
+ final Collection<String> files = connexion.getFiles();
+ if (files.size() > 0) {
+ int total = 0;
+ for (String n : files) {
+ total += (connexion.getSize(n) + 511) / 512;
+ }
+ listing.println("total " + total);
+ // localLog(total);
+ for (String n : files) {
+ final String ls = String.format("%10s %4d %-8s %-8s %8d %3s %2s %5s %s", "-rw-rw-r--", 1, "plantuml",
+ "plantuml", connexion.getSize(n), "Sep", 28, 2006, n);
+ listing.println(ls);
+ // localLog(ls);
+ }
+ }
+ listing.flush();
+ listing.close();
+ soc.close();
+ myOut("226 Listing completed.");
+ }
+
+ private void myOut(String s) {
+ if (s.indexOf('\t') != -1) {
+ throw new IllegalArgumentException();
+ }
+ pw.println(s);
+ pw.flush();
+ }
+
+ public void run() {
+ try {
+ runInternal();
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ftp/FtpServer.java b/src/net/sourceforge/plantuml/ftp/FtpServer.java
new file mode 100644
index 0000000..bbfb07a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ftp/FtpServer.java
@@ -0,0 +1,127 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ftp;
+
+// server
+
+// FtpServer.java
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import net.sourceforge.plantuml.FileFormat;
+
+public class FtpServer {
+
+ private final Map<String, FtpConnexion> datas = new TreeMap<String, FtpConnexion>();
+ private final ExecutorService exeImage = Executors.newFixedThreadPool(2);
+ private final String charset = "UTF-8";
+
+ private final int listenPort;
+
+ private int portFree = 10042;
+ private String ip;
+ private final FileFormat defaultfileFormat;
+
+ public FtpServer(int listenPort, FileFormat defaultfileFormat) {
+ this.listenPort = listenPort;
+ this.defaultfileFormat = defaultfileFormat == null ? FileFormat.PNG : defaultfileFormat;
+ }
+
+ public synchronized int getFreePort() {
+ portFree++;
+ // Log.println("port=" + portFree);
+ return portFree;
+ }
+
+ public void go() throws IOException {
+ final ServerSocket s = new ServerSocket(listenPort);
+ final ExecutorService exe = Executors.newCachedThreadPool();
+ while (true) {
+ final Socket incoming = s.accept();
+ ip = incoming.getLocalAddress().getHostAddress();
+ System.out.println("New Client Connected from " + incoming.getInetAddress().getHostName() + "... ");
+ exe.submit(new FtpLoop(incoming, this));
+ }
+ }
+
+ public String getIpServer() {
+ return ip;
+ }
+
+ public synchronized FtpConnexion getFtpConnexion(String user) {
+ if (user == null) {
+ throw new IllegalArgumentException();
+ }
+ FtpConnexion data = datas.get(user);
+ if (data == null) {
+ data = new FtpConnexion(user, defaultfileFormat);
+ datas.put(user, data);
+ }
+ return data;
+ }
+
+ public static void main(String[] args) throws IOException {
+ System.out.println("****************************** ************************************************** ");
+ System.out.println("****************************** FTP SERVER***********************************");
+
+ System.out.println("****************************** ************************************************** ");
+ System.out.println("Server Started...");
+ System.out.println("Waiting for connections...");
+ System.out.println(" ");
+ new FtpServer(24242, FileFormat.SVG).go();
+ }
+
+ public void processImage(final FtpConnexion connexion, final String name) {
+ exeImage.submit(new Runnable() {
+ public void run() {
+ try {
+ connexion.processImage(name);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ }
+
+ public final String getCharset() {
+ return charset;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/fun/IconLoader.java b/src/net/sourceforge/plantuml/fun/IconLoader.java
new file mode 100644
index 0000000..0780a62
--- /dev/null
+++ b/src/net/sourceforge/plantuml/fun/IconLoader.java
@@ -0,0 +1,105 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.fun;
+
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.imageio.ImageIO;
+
+public class IconLoader {
+
+ private static final int NUMBER_OF_ICONS = 20;
+
+ private final static Map<String, BufferedImage> all = new ConcurrentHashMap<String, BufferedImage>();
+
+ public static BufferedImage getRandom() {
+ // return addTransparent(getIcon("sprite013.png"));
+ return addTransparent(getIcon(getSomeQuote()));
+ }
+
+ private static String getSomeQuote() {
+ final int v = (int) (System.currentTimeMillis() / 1000L);
+ final int n = v % NUMBER_OF_ICONS;
+ return "sprite" + String.format("%03d", n) + ".png";
+ }
+
+ private static BufferedImage getIcon(String name) {
+ BufferedImage result = all.get(name);
+ if (result == null) {
+ result = getIconSlow(name);
+ if (result != null) {
+ all.put(name, result);
+ }
+ }
+ return result;
+ }
+
+ private static BufferedImage getIconSlow(String name) {
+ try {
+ final InputStream is = IconLoader.class.getResourceAsStream(name);
+ if (is == null) {
+ return null;
+ }
+ final BufferedImage image = ImageIO.read(is);
+ is.close();
+ return image;
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ private static BufferedImage addTransparent(BufferedImage ico) {
+ if (ico == null) {
+ return null;
+ }
+ final BufferedImage transparentIcon = new BufferedImage(ico.getWidth(), ico.getHeight(),
+ BufferedImage.TYPE_INT_ARGB_PRE);
+ for (int i = 0; i < ico.getWidth(); i++) {
+ for (int j = 0; j < ico.getHeight(); j++) {
+ final int col = ico.getRGB(i, j);
+ if (col != ico.getRGB(0, 0)) {
+ transparentIcon.setRGB(i, j, col);
+ }
+ }
+ }
+ return transparentIcon;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/fun/sprite000.png b/src/net/sourceforge/plantuml/fun/sprite000.png
new file mode 100644
index 0000000..48ab597
--- /dev/null
+++ b/src/net/sourceforge/plantuml/fun/sprite000.png
Binary files differ
diff --git a/src/net/sourceforge/plantuml/fun/sprite001.png b/src/net/sourceforge/plantuml/fun/sprite001.png
new file mode 100644
index 0000000..32f121d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/fun/sprite001.png
Binary files differ
diff --git a/src/net/sourceforge/plantuml/fun/sprite002.png b/src/net/sourceforge/plantuml/fun/sprite002.png
new file mode 100644
index 0000000..dd18318
--- /dev/null
+++ b/src/net/sourceforge/plantuml/fun/sprite002.png
Binary files differ
diff --git a/src/net/sourceforge/plantuml/fun/sprite003.png b/src/net/sourceforge/plantuml/fun/sprite003.png
new file mode 100644
index 0000000..429dced
--- /dev/null
+++ b/src/net/sourceforge/plantuml/fun/sprite003.png
Binary files differ
diff --git a/src/net/sourceforge/plantuml/fun/sprite004.png b/src/net/sourceforge/plantuml/fun/sprite004.png
new file mode 100644
index 0000000..6d925f7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/fun/sprite004.png
Binary files differ
diff --git a/src/net/sourceforge/plantuml/fun/sprite005.png b/src/net/sourceforge/plantuml/fun/sprite005.png
new file mode 100644
index 0000000..fd5f6e7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/fun/sprite005.png
Binary files differ
diff --git a/src/net/sourceforge/plantuml/fun/sprite006.png b/src/net/sourceforge/plantuml/fun/sprite006.png
new file mode 100644
index 0000000..f9605ad
--- /dev/null
+++ b/src/net/sourceforge/plantuml/fun/sprite006.png
Binary files differ
diff --git a/src/net/sourceforge/plantuml/fun/sprite007.png b/src/net/sourceforge/plantuml/fun/sprite007.png
new file mode 100644
index 0000000..817df6c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/fun/sprite007.png
Binary files differ
diff --git a/src/net/sourceforge/plantuml/fun/sprite008.png b/src/net/sourceforge/plantuml/fun/sprite008.png
new file mode 100644
index 0000000..5b3e95a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/fun/sprite008.png
Binary files differ
diff --git a/src/net/sourceforge/plantuml/fun/sprite009.png b/src/net/sourceforge/plantuml/fun/sprite009.png
new file mode 100644
index 0000000..0a647ba
--- /dev/null
+++ b/src/net/sourceforge/plantuml/fun/sprite009.png
Binary files differ
diff --git a/src/net/sourceforge/plantuml/fun/sprite010.png b/src/net/sourceforge/plantuml/fun/sprite010.png
new file mode 100644
index 0000000..35a355a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/fun/sprite010.png
Binary files differ
diff --git a/src/net/sourceforge/plantuml/fun/sprite011.png b/src/net/sourceforge/plantuml/fun/sprite011.png
new file mode 100644
index 0000000..27e1b63
--- /dev/null
+++ b/src/net/sourceforge/plantuml/fun/sprite011.png
Binary files differ
diff --git a/src/net/sourceforge/plantuml/fun/sprite012.png b/src/net/sourceforge/plantuml/fun/sprite012.png
new file mode 100644
index 0000000..d838292
--- /dev/null
+++ b/src/net/sourceforge/plantuml/fun/sprite012.png
Binary files differ
diff --git a/src/net/sourceforge/plantuml/fun/sprite013.png b/src/net/sourceforge/plantuml/fun/sprite013.png
new file mode 100644
index 0000000..0f65d96
--- /dev/null
+++ b/src/net/sourceforge/plantuml/fun/sprite013.png
Binary files differ
diff --git a/src/net/sourceforge/plantuml/fun/sprite014.png b/src/net/sourceforge/plantuml/fun/sprite014.png
new file mode 100644
index 0000000..82cb170
--- /dev/null
+++ b/src/net/sourceforge/plantuml/fun/sprite014.png
Binary files differ
diff --git a/src/net/sourceforge/plantuml/fun/sprite015.png b/src/net/sourceforge/plantuml/fun/sprite015.png
new file mode 100644
index 0000000..c30e607
--- /dev/null
+++ b/src/net/sourceforge/plantuml/fun/sprite015.png
Binary files differ
diff --git a/src/net/sourceforge/plantuml/fun/sprite016.png b/src/net/sourceforge/plantuml/fun/sprite016.png
new file mode 100644
index 0000000..9f0ceba
--- /dev/null
+++ b/src/net/sourceforge/plantuml/fun/sprite016.png
Binary files differ
diff --git a/src/net/sourceforge/plantuml/fun/sprite017.png b/src/net/sourceforge/plantuml/fun/sprite017.png
new file mode 100644
index 0000000..40e34ac
--- /dev/null
+++ b/src/net/sourceforge/plantuml/fun/sprite017.png
Binary files differ
diff --git a/src/net/sourceforge/plantuml/fun/sprite018.png b/src/net/sourceforge/plantuml/fun/sprite018.png
new file mode 100644
index 0000000..21e9eaa
--- /dev/null
+++ b/src/net/sourceforge/plantuml/fun/sprite018.png
Binary files differ
diff --git a/src/net/sourceforge/plantuml/fun/sprite019.png b/src/net/sourceforge/plantuml/fun/sprite019.png
new file mode 100644
index 0000000..a32ac40
--- /dev/null
+++ b/src/net/sourceforge/plantuml/fun/sprite019.png
Binary files differ
diff --git a/src/net/sourceforge/plantuml/geom/AbstractFigure.java b/src/net/sourceforge/plantuml/geom/AbstractFigure.java
new file mode 100644
index 0000000..b409c71
--- /dev/null
+++ b/src/net/sourceforge/plantuml/geom/AbstractFigure.java
@@ -0,0 +1,314 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.geom;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import net.sourceforge.plantuml.Log;
+
+abstract class AbstractFigure {
+
+ private final Set<LineSegmentInt> segments = new HashSet<LineSegmentInt>();
+
+ @Override
+ public String toString() {
+ return segments.toString();
+ }
+
+ @Override
+ final public boolean equals(Object obj) {
+ final AbstractFigure other = (AbstractFigure) obj;
+ return segments.equals(other.segments);
+ }
+
+ @Override
+ final public int hashCode() {
+ return segments.hashCode();
+ }
+
+ protected boolean knowThisPoint(Point2DInt p) {
+ for (LineSegmentInt seg : segments) {
+ if (seg.getP1().equals(p) || seg.getP2().equals(p)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ LineSegmentInt existingSegment(Point2DInt p1, Point2DInt p2) {
+ for (LineSegmentInt seg : segments) {
+ if (seg.getP1().equals(p1) && seg.getP2().equals(p2)) {
+ return seg;
+ }
+ if (seg.getP1().equals(p2) && seg.getP2().equals(p1)) {
+ return seg;
+ }
+ }
+ return null;
+ }
+
+ Collection<LineSegmentInt> getSegmentsWithExtremity(Point2DInt extremity, Collection<LineSegmentInt> exceptions) {
+ final Collection<LineSegmentInt> result = new HashSet<LineSegmentInt>();
+ for (LineSegmentInt seg : segments) {
+ if (exceptions.contains(seg)) {
+ continue;
+ }
+ if (seg.getP1().equals(extremity) || seg.getP2().equals(extremity)) {
+ result.add(seg);
+ }
+ }
+ return Collections.unmodifiableCollection(result);
+ }
+
+ public void addSegment(LineSegmentInt seg) {
+ segments.add(seg);
+ }
+
+ protected final Set<LineSegmentInt> getSegments() {
+ return Collections.unmodifiableSet(segments);
+ }
+
+ @Deprecated
+ public Polyline addPath(Point2DInt start, Point2DInt end) {
+ if (knowThisPoint(start) && knowThisPoint(end)) {
+ return getPath(start, end);
+ }
+ final LineSegmentInt direct = new LineSegmentInt(start, end);
+ addSegment(direct);
+ return new PolylineImpl(start, end);
+ }
+
+ public Polyline addDirectLink(Point2DInt start, Point2DInt end) {
+ final LineSegmentInt direct = new LineSegmentInt(start, end);
+ addSegment(direct);
+ Log.println("AbstractFigure::addDirectLink " + direct);
+ return new PolylineImpl(start, end);
+ }
+
+ public boolean isSimpleSegmentPossible(Point2DInt start, Point2DInt end) {
+ final LineSegmentInt direct = new LineSegmentInt(start, end);
+ return hasIntersectionStrict(direct) == false;
+ }
+
+ public Polyline getPath(Pointable start, Pointable end) {
+ if (knowThisPoint(start.getPosition()) == false) {
+ throw new IllegalArgumentException();
+ }
+ if (knowThisPoint(end.getPosition()) == false) {
+ throw new IllegalArgumentException("" + end.getPosition());
+ }
+ if (isSimpleSegmentPossible(start.getPosition(), end.getPosition())) {
+ throw new IllegalArgumentException();
+ // return new PolylineImpl(start, end);
+ }
+ if (arePointsConnectable(start.getPosition(), end.getPosition()) == false) {
+ return null;
+ }
+ return findBestPath(start, end);
+ }
+
+ private Polyline findBestPath(Pointable start, Pointable end) {
+ Log.println("start=" + start.getPosition());
+ Log.println("end=" + end.getPosition());
+ final Set<Point2DInt> points = getAllPoints();
+ if (points.contains(start.getPosition()) == false || points.contains(end.getPosition()) == false) {
+ throw new IllegalArgumentException();
+ }
+ points.remove(start.getPosition());
+ points.remove(end.getPosition());
+ final List<Neighborhood> neighborhoods = new ArrayList<Neighborhood>();
+ for (Point2DInt p : points) {
+ neighborhoods.addAll(getSingularity(p).getNeighborhoods());
+ }
+ for (int i = 0; i < neighborhoods.size(); i++) {
+ Log.println("N" + (i + 1) + " " + neighborhoods.get(i));
+ }
+ final Dijkstra dijkstra = new Dijkstra(neighborhoods.size() + 2);
+ Log.println("size=" + dijkstra.getSize());
+ for (int i = 0; i < neighborhoods.size(); i++) {
+ if (isConnectable(start.getPosition(), neighborhoods.get(i))) {
+ dijkstra.addLink(0, i + 1, distance(start.getPosition(), neighborhoods.get(i).getCenter()));
+ }
+ }
+ for (int i = 0; i < neighborhoods.size(); i++) {
+ for (int j = 0; j < neighborhoods.size(); j++) {
+ if (i == j) {
+ continue;
+ }
+ if (isConnectable(neighborhoods.get(i), neighborhoods.get(j))) {
+ dijkstra.addLink(i + 1, j + 1, distance(neighborhoods.get(i).getCenter(), neighborhoods.get(j)
+ .getCenter()));
+ }
+ }
+ }
+ for (int i = 0; i < neighborhoods.size(); i++) {
+ if (isConnectable(end.getPosition(), neighborhoods.get(i))) {
+ dijkstra.addLink(i + 1, neighborhoods.size() + 1, distance(end.getPosition(), neighborhoods.get(i)
+ .getCenter()));
+ }
+ }
+ final List<Integer> path = dijkstra.getBestPath();
+ if (path.get(path.size() - 1) != neighborhoods.size() + 1) {
+ throw new IllegalStateException("No Path");
+ }
+ assert path.size() > 2;
+
+ Log.println("PATH=" + path);
+ final List<Neighborhood> usedNeighborhoods = new ArrayList<Neighborhood>();
+ for (int i = 1; i < path.size() - 1; i++) {
+ final int idx = path.get(i) - 1;
+ usedNeighborhoods.add(neighborhoods.get(idx));
+ }
+ return findApproximatePath(start, end, usedNeighborhoods);
+ }
+
+ private Polyline findApproximatePath(Pointable start, Pointable end, final List<Neighborhood> neighborhoods) {
+ System.err
+ .println("findApproximatePath " + start.getPosition() + " " + end.getPosition() + " " + neighborhoods);
+ final PolylineImpl result = new PolylineImpl(start, end);
+ for (Neighborhood n : neighborhoods) {
+ Log.println("Neighborhood =" + n);
+ final double d = getProximaDistance(n.getCenter()) / 2;
+ final double a = n.getMiddle();
+ Log.println("d=" + d);
+ Log.println("a=" + a * 180 / Math.PI);
+ final double deltaX = d * Math.cos(a);
+ final double deltaY = d * Math.sin(a);
+ assert d > 0;
+ Log.println("Result = " + n.getCenter().translate((int) deltaX, (int) deltaY));
+ result.addIntermediate(n.getCenter().translate((int) deltaX, (int) deltaY));
+ }
+ return result;
+ }
+
+ private double getProximaDistance(Point2DInt center) {
+ double result = Double.MAX_VALUE;
+ for (Point2DInt p : getAllPoints()) {
+ if (center.equals(p)) {
+ continue;
+ }
+ final double cur = new LineSegmentInt(p, center).getLength();
+ result = Math.min(result, cur);
+ }
+ return result;
+ }
+
+ static private double distance(Point2DInt p1, Point2DInt p2) {
+ return new LineSegmentInt(p1, p2).getLength();
+ }
+
+ public boolean isConnectable(Point2DInt p, Neighborhood n) {
+ final LineSegmentInt seg = new LineSegmentInt(n.getCenter(), p);
+ if (hasIntersectionStrict(seg)) {
+ return false;
+ }
+ final double angle = Singularity.convertAngle(seg.getAngle());
+ return n.isInAngleLarge(angle);
+ }
+
+ public boolean isConnectable(Neighborhood n1, Neighborhood n2) {
+ final boolean result = isConnectableInternal(n1, n2);
+ assert result == isConnectableInternal(n2, n1);
+ return result;
+ }
+
+ private boolean isConnectableInternal(Neighborhood n1, Neighborhood n2) {
+ if (n1.getCenter().equals(n2.getCenter())) {
+ return false;
+ }
+ final LineSegmentInt seg1 = new LineSegmentInt(n1.getCenter(), n2.getCenter());
+ if (hasIntersectionStrict(seg1)) {
+ return false;
+ }
+ final double angle1 = Singularity.convertAngle(seg1.getAngle());
+ final double angle2 = Singularity.convertAngle(seg1.getOppositeAngle());
+ assert angle2 == Singularity.convertAngle(new LineSegmentInt(n2.getCenter(), n1.getCenter()).getAngle());
+ if (n1.isInAngleStrict(angle1) && n2.isInAngleStrict(angle2)) {
+ return true;
+ }
+ if (n1.isAngleLimit(angle1) && n2.isAngleLimit(angle2)) {
+ if (n1.is360() || n2.is360()) {
+ return true;
+ }
+ final Orientation o1 = n1.getOrientationFrom(angle1);
+ final Orientation o2 = n2.getOrientationFrom(angle2);
+ return o1 != o2;
+ }
+ return false;
+ }
+
+ private boolean hasIntersectionStrict(LineSegmentInt direct) {
+ for (LineSegmentInt seg : getSegments()) {
+ if (seg.atLeastOneCommonExtremities(direct)) {
+ continue;
+ }
+ if (seg.doesIntersect(direct)) {
+ Log.println("seg=" + seg);
+ Log.println("direct=" + direct);
+ Log.println("AbstractFigure::hasIntersectionStrict true");
+ return true;
+ }
+ }
+ Log.println("AbstractFigure::hasIntersectionStrict false");
+ return false;
+ }
+
+ public Singularity getSingularity(Point2DInt center) {
+ final Singularity singularity = new Singularity(center);
+ for (LineSegmentInt seg : getSegments()) {
+ if (seg.containsPoint(center)) {
+ singularity.addLineSegment(seg);
+ }
+ }
+ return singularity;
+ }
+
+ private Set<Point2DInt> getAllPoints() {
+ final Set<Point2DInt> result = new HashSet<Point2DInt>();
+ for (LineSegmentInt seg : segments) {
+ result.add(seg.getP1());
+ result.add(seg.getP2());
+ }
+ return result;
+ }
+
+ abstract boolean arePointsConnectable(Point2DInt p1, Point2DInt p2);
+
+}
diff --git a/src/net/sourceforge/plantuml/geom/AbstractLineSegment.java b/src/net/sourceforge/plantuml/geom/AbstractLineSegment.java
new file mode 100644
index 0000000..a50f75f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/geom/AbstractLineSegment.java
@@ -0,0 +1,255 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.geom;
+
+import java.awt.geom.Line2D;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+
+public abstract class AbstractLineSegment extends Line2D {
+
+ @Override
+ final public boolean equals(Object obj) {
+ final AbstractLineSegment other = (AbstractLineSegment) obj;
+ return this.getP1().equals(other.getP1()) && getP2().equals(other.getP2());
+ }
+
+ @Override
+ final public int hashCode() {
+ int result = 7;
+ final int multiplier = 17;
+ result = result * multiplier + getP1().hashCode();
+ result = result * multiplier + getP2().hashCode();
+ return result;
+ }
+
+ final public double getLength() {
+ return Math.sqrt((getP2().getX() - getP1().getX()) * (getP2().getX() - getP1().getX())
+ + (getP2().getY() - getP1().getY()) * (getP2().getY() - getP1().getY()));
+ }
+
+ final protected Point2D.Double getPoint2D(double u) {
+ final double x = getP1().getX() + u * (getP2().getX() - getP1().getX());
+ final double y = getP1().getY() + u * (getP2().getY() - getP1().getY());
+ return new Point2D.Double(x, y);
+ }
+
+ final public double getDistance(Point2D f) {
+ return this.ptSegDist(f);
+ }
+
+ public Point2D getSegIntersection(AbstractLineSegment other) {
+ final double u;
+ if (other.isVertical()) {
+ u = getIntersectionVertical(other.getP1().getX());
+ } else if (other.isHorizontal()) {
+ u = getIntersectionHorizontal(other.getP1().getY());
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ if (java.lang.Double.isNaN(u) || u < 0 || u > 1) {
+ return null;
+ }
+ final Point2D.Double result = getPoint2D(u);
+ if (isBetween(result, other.getP1(), other.getP2())) {
+ return result;
+ }
+ return null;
+ }
+
+ private static boolean isBetween(double value, double v1, double v2) {
+ if (v1 < v2) {
+ return value >= v1 && value <= v2;
+ }
+ assert v2 <= v1;
+ return value >= v2 && value <= v1;
+
+ }
+
+ static boolean isBetween(Point2D toTest, Point2D pos1, Point2D pos2) {
+ return isBetween(toTest.getX(), pos1.getX(), pos2.getX()) && isBetween(toTest.getY(), pos1.getY(), pos2.getY());
+ }
+
+ public double getIntersectionVertical(double xOther) {
+ final double coef = getP2().getX() - getP1().getX();
+ if (coef == 0) {
+ return java.lang.Double.NaN;
+ }
+ return (xOther - getP1().getX()) / coef;
+ }
+
+ public double getIntersectionHorizontal(double yOther) {
+ final double coef = getP2().getY() - getP1().getY();
+ if (coef == 0) {
+ return java.lang.Double.NaN;
+ }
+ return (yOther - getP1().getY()) / coef;
+ }
+
+ // Line2D
+
+ @Override
+ final public void setLine(double x1, double y1, double x2, double y2) {
+ throw new UnsupportedOperationException();
+ }
+
+ final public Rectangle2D getBounds2D() {
+ final double x;
+ final double w;
+ if (getX1() < getX2()) {
+ x = getX1();
+ w = getX2() - getX1();
+ } else {
+ x = getX2();
+ w = getX1() - getX2();
+ }
+ final double y;
+ final double h;
+ if (getY1() < getY2()) {
+ y = getY1();
+ h = getY2() - getY1();
+ } else {
+ y = getY2();
+ h = getY1() - getY2();
+ }
+ return new Rectangle2D.Double(x, y, w, h);
+ }
+
+ final public boolean isHorizontal() {
+ return getP1().getY() == getP2().getY();
+ }
+
+ final public boolean isVertical() {
+ return getP1().getX() == getP2().getX();
+ }
+
+ final public double getDistance(AbstractLineSegment other) {
+ final double result = getDistanceInternal(other);
+ assert equals(result, other.getDistanceInternal(this));
+ return result;
+ }
+
+ private boolean equals(double a1, double a2) {
+ return Math.abs(a1 - a2) < 0.0001;
+ }
+
+ private double getDistanceInternal(AbstractLineSegment other) {
+ double result = this.getDistance(other.getP1());
+ result += this.getDistance(other.getP2());
+ result += other.getDistance(this.getP1());
+ result += other.getDistance(this.getP2());
+ return result;
+ }
+
+ final public double getAngle() {
+ return Math.atan2(getP2().getY() - getP1().getY(), getP2().getX() - getP1().getX());
+ }
+
+ final public double getOppositeAngle() {
+ return Math.atan2(getP1().getY() - getP2().getY(), getP1().getX() - getP2().getX());
+ }
+
+ final public Point2D.Double startTranslatedAsVector(double u) {
+ final double pour = 1.0 * u / 100.0;
+ final double x = getP1().getX() + pour * (getP2().getX() - getP1().getX());
+ final double y = getP1().getY() + pour * (getP2().getY() - getP1().getY());
+ return new Point2D.Double(x, y);
+ }
+
+ public boolean doesIntersect(AbstractLineSegment other) {
+ final boolean result = doesIntersectInternal(other);
+ assert result == other.doesIntersectInternal(this);
+ return result;
+ }
+
+ private boolean doesIntersectInternal(AbstractLineSegment other) {
+ final double d1 = direction(other.getP1(), other.getP2(), this.getP1());
+ final double d2 = direction(other.getP1(), other.getP2(), this.getP2());
+ final double d3 = direction(this.getP1(), this.getP2(), other.getP1());
+ final double d4 = direction(this.getP1(), this.getP2(), other.getP2());
+
+ if (d1 == 0 && isBetween(this.getP1(), other.getP1(), other.getP2())) {
+ return true;
+ }
+
+ if (d2 == 0 && isBetween(this.getP2(), other.getP1(), other.getP2())) {
+ return true;
+ }
+
+ if (d3 == 0 && isBetween(other.getP1(), this.getP1(), this.getP2())) {
+ return true;
+ }
+
+ if (d4 == 0 && isBetween(other.getP2(), this.getP1(), this.getP2())) {
+ return true;
+ }
+
+ final boolean result = signDiffers(d1, d2) && signDiffers(d3, d4);
+ assert this.intersectsLine(other) == result;
+ return result;
+ }
+
+ private static double direction(Point2D origin, Point2D point1, Point2D point2) {
+ return determinant(point2.getX() - origin.getX(), point2.getY() - origin.getY(), point1.getX() - origin.getX(),
+ point1.getY() - origin.getY());
+ }
+
+ private static boolean signDiffers(double a, double b) {
+ if (a > 0 && b < 0) {
+ return true;
+ }
+ if (a < 0 && b > 0) {
+ return true;
+ }
+ return false;
+ }
+
+ public double determinant(AbstractLineSegment other) {
+ return determinant(this.getP1().getX() - this.getP2().getX(), this.getP1().getY() - this.getP2().getY(), other
+ .getP1().getX()
+ - other.getP2().getX(), other.getP1().getY() - other.getP2().getY());
+ }
+
+ private static double determinant(double x1, double y1, double x2, double y2) {
+ return x1 * y2 - x2 * y1;
+ }
+
+ public double side(Point2D point) {
+ // assert Math.signum(direction(p1, p2, point)) ==
+ // this.relativeCCW(point);
+ return direction(getP1(), getP2(), point);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/geom/AbstractPolyline.java b/src/net/sourceforge/plantuml/geom/AbstractPolyline.java
new file mode 100644
index 0000000..03a93c2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/geom/AbstractPolyline.java
@@ -0,0 +1,199 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.geom;
+
+import java.awt.geom.GeneralPath;
+
+abstract class AbstractPolyline implements Polyline {
+
+ private final Pointable start;
+ private final Pointable end;
+
+ public AbstractPolyline(Pointable start, Pointable end) {
+ this.start = start;
+ this.end = end;
+ }
+
+ @Override
+ final public String toString() {
+ return segments().toString();
+ }
+
+ final public boolean doesTouch(Polyline other) {
+ final boolean result = doesTouchInternal(other);
+ assert result == ((AbstractPolyline) other).doesTouchInternal(this);
+ return result;
+ }
+
+ private boolean doesTouchInternal(Polyline other) {
+ for (int i = 0; i < nbSegments(); i++) {
+ final LineSegmentInt seg1 = segments().get(i);
+ for (int j = 0; j < other.nbSegments(); j++) {
+ final LineSegmentInt seg2 = other.segments().get(j);
+ final boolean ignoreExtremities = i == 0 || i == nbSegments() - 1 || j == 0
+ || j == other.nbSegments() - 1;
+ if (ignoreExtremities == false && seg1.doesIntersect(seg2)) {
+ return true;
+ }
+ if (ignoreExtremities && seg1.doesIntersectButNotSameExtremity(seg2)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ final public LineSegmentInt getFirst() {
+ return segments().get(0);
+ }
+
+ final public LineSegmentInt getLast() {
+ return segments().get(nbSegments() - 1);
+ }
+
+ final public double getLength() {
+ double result = 0;
+ for (LineSegmentInt seg : segments()) {
+ result += seg.getLength();
+ }
+ return result;
+ }
+
+ final public Point2DInt clipStart(Box box) {
+ assert box.doesIntersect(segments().get(0));
+ final Point2DInt inter[] = box.intersect(segments().get(0));
+ assert inter.length == 1;
+ segments().set(
+ 0,
+ new LineSegmentInt(inter[0].getXint(), inter[0].getYint(), segments().get(0).getP2().getXint(),
+ segments().get(0).getP2().getYint()));
+ return inter[0];
+ }
+
+ final public Point2DInt clipEnd(Box box) {
+ final int last = nbSegments() - 1;
+ if (last == -1) {
+ return null;
+ }
+ assert box.doesIntersect(segments().get(last));
+ final Point2DInt inter[] = box.intersect(segments().get(last));
+ assert inter.length == 1;
+ segments().set(
+ last,
+ new LineSegmentInt(segments().get(last).getP1().getXint(), segments().get(last).getP1().getYint(),
+ inter[0].getXint(), inter[0].getYint()));
+ return inter[0];
+ }
+
+ final public boolean intersectBox(Box b) {
+ for (LineSegmentInt seg : segments()) {
+ if (b.doesIntersect(seg)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ final public double getDistance(Box b) {
+ double result = Double.MAX_VALUE;
+ for (LineSegmentInt seg : segments()) {
+ if (b.doesIntersect(seg)) {
+ result = Math.min(result, seg.getDistance(b.getCenterPoint()));
+ }
+ }
+ return result;
+ }
+
+ final public double getDistance(Polyline other) {
+ double result = 0;
+ for (LineSegmentInt seg1 : segments()) {
+ for (LineSegmentInt seg2 : other.segments()) {
+ result += seg1.getDistance(seg2);
+ }
+ }
+ return result;
+ }
+
+ final public GeneralPath asGeneralPath() {
+ final GeneralPath generalPath = new GeneralPath();
+
+ for (LineSegmentInt seg : segments()) {
+ generalPath.append(seg, false);
+ }
+
+ return generalPath;
+ }
+
+ final public int getMinX() {
+ int result = Integer.MAX_VALUE;
+ for (LineSegmentInt seg : segments()) {
+ result = Math.min(result, seg.getMinX());
+ }
+ return result;
+ }
+
+ final public int getMinY() {
+ int result = Integer.MAX_VALUE;
+ for (LineSegmentInt seg : segments()) {
+ result = Math.min(result, seg.getMinY());
+ }
+ return result;
+ }
+
+ final public int getMaxX() {
+ int result = Integer.MIN_VALUE;
+ for (LineSegmentInt seg : segments()) {
+ result = Math.max(result, seg.getMaxX());
+ }
+ return result;
+ }
+
+ final public int getMaxY() {
+ int result = Integer.MIN_VALUE;
+ for (LineSegmentInt seg : segments()) {
+ result = Math.max(result, seg.getMaxY());
+ }
+ return result;
+ }
+
+ public final Pointable getStart() {
+ return start;
+ }
+
+ public final Pointable getEnd() {
+ return end;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/geom/Box.java b/src/net/sourceforge/plantuml/geom/Box.java
new file mode 100644
index 0000000..f9fe6e8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/geom/Box.java
@@ -0,0 +1,239 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.geom;
+
+public class Box implements XMoveable, Pointable {
+
+ private int x;
+ private int y;
+ final private int width;
+ final private int height;
+
+ public Box(int x, int y, int width, int height) {
+ if (width <= 0 || height <= 0) {
+ throw new IllegalArgumentException();
+ }
+ this.x = x;
+ this.y = y;
+ this.width = width;
+ this.height = height;
+ }
+
+ @Override
+ public String toString() {
+ return "Box [" + x + "," + y + "] " + width + "," + height;
+ }
+
+ public Point2DInt[] getCorners() {
+ final Point2DInt p1 = new Point2DInt(getX(), getY());
+ final Point2DInt p2 = new Point2DInt(getX() + getWidth(), getY());
+ final Point2DInt p3 = new Point2DInt(getX() + getWidth(), getY() + getHeight());
+ final Point2DInt p4 = new Point2DInt(getX(), getY() + getHeight());
+ return new Point2DInt[] { p1, p2, p3, p4 };
+ }
+
+ public Point2DInt[] getCornersOfOneSide(LineSegmentInt seg, int sgn) {
+ final Point2DInt[] corners = getCorners();
+ final double sgn0 = seg.side(corners[0]);
+ final double sgn1 = seg.side(corners[1]);
+ final double sgn2 = seg.side(corners[2]);
+ final double sgn3 = seg.side(corners[3]);
+ int nb = 0;
+ if (Math.signum(sgn0) == sgn) {
+ nb++;
+ }
+ if (Math.signum(sgn1) == sgn) {
+ nb++;
+ }
+ if (Math.signum(sgn2) == sgn) {
+ nb++;
+ }
+ if (Math.signum(sgn3) == sgn) {
+ nb++;
+ }
+ final Point2DInt[] result = new Point2DInt[nb];
+ int i = 0;
+ if (Math.signum(sgn0) == sgn) {
+ result[i++] = corners[0];
+ }
+ if (Math.signum(sgn1) == sgn) {
+ result[i++] = corners[1];
+ }
+ if (Math.signum(sgn2) == sgn) {
+ result[i++] = corners[2];
+ }
+ if (Math.signum(sgn3) == sgn) {
+ result[i++] = corners[3];
+ }
+ assert nb == i;
+ return result;
+ }
+
+ public boolean doesIntersect(LineSegmentInt seg) {
+ return intersect(seg).length > 0;
+ }
+
+ public Point2DInt[] intersect(LineSegmentInt seg) {
+ if (seg.side(this) != 0) {
+ return new Point2DInt[0];
+ }
+ // Log.println("THIS=" + this);
+ // Log.println("LineSegment=" + seg);
+ final Point2DInt corners[] = getCorners();
+ final LineSegmentInt seg1 = new LineSegmentInt(corners[0], corners[1]);
+ final LineSegmentInt seg2 = new LineSegmentInt(corners[1], corners[2]);
+ final LineSegmentInt seg3 = new LineSegmentInt(corners[2], corners[3]);
+ final LineSegmentInt seg4 = new LineSegmentInt(corners[3], corners[0]);
+ final Point2DInt i1 = seg.getSegIntersection(seg1);
+ Point2DInt i2 = seg.getSegIntersection(seg2);
+ Point2DInt i3 = seg.getSegIntersection(seg3);
+ Point2DInt i4 = seg.getSegIntersection(seg4);
+
+ // Log.println("i1="+i1);
+ // Log.println("i2="+i2);
+ // Log.println("i3="+i3);
+ // Log.println("i4="+i4);
+
+ if (i2 != null && i2.equals(i1)) {
+ i2 = null;
+ }
+ if (i3 != null && (i3.equals(i1) || i3.equals(i2))) {
+ i3 = null;
+ }
+ if (i4 != null && (i4.equals(i1) || i4.equals(i2) || i4.equals(i3))) {
+ i4 = null;
+ }
+
+ final int nb = countNotNull(i1, i2, i3, i4);
+ assert nb >= 0 && nb <= 3 : nb;
+ int i = 0;
+ final Point2DInt result[] = new Point2DInt[nb];
+ if (i1 != null) {
+ result[i++] = i1;
+ }
+ if (i2 != null) {
+ result[i++] = i2;
+ }
+ if (i3 != null) {
+ result[i++] = i3;
+ }
+ if (i4 != null) {
+ result[i++] = i4;
+ }
+ assert i == nb;
+ assert getCornersOfOneSide(seg, 0).length + getCornersOfOneSide(seg, 1).length
+ + getCornersOfOneSide(seg, -1).length == 4;
+ return result;
+ }
+
+ private int countNotNull(Point2DInt i1, Point2DInt i2, Point2DInt i3, Point2DInt i4) {
+ int n = 0;
+ if (i1 != null) {
+ n++;
+ }
+ if (i2 != null) {
+ n++;
+ }
+ if (i3 != null) {
+ n++;
+ }
+ if (i4 != null) {
+ n++;
+ }
+ return n;
+ }
+
+ public Box outerBox(int margin) {
+ return new Box(x - margin, y - margin, width + 2 * margin, height + 2 * margin);
+ }
+
+ public Point2DInt getCenterPoint() {
+ return new Point2DInt(x + width / 2, y + height / 2);
+ }
+
+ public void moveX(int delta) {
+ this.x += delta;
+ }
+
+ public boolean intersectBox(Box other) {
+ return other.x + other.width > this.x && other.y + other.height > this.y && other.x < this.x + this.width
+ && other.y < this.y + this.height;
+ }
+
+ public final int getX() {
+ return x;
+ }
+
+ public final int getY() {
+ return y;
+ }
+
+ public final int getWidth() {
+ return width;
+ }
+
+ public final int getHeight() {
+ return height;
+ }
+
+ public int getMinX() {
+ return x;
+ }
+
+ public int getMinY() {
+ return y;
+ }
+
+ public int getMaxX() {
+ return x + width;
+ }
+
+ public int getMaxY() {
+ return y + height;
+ }
+
+ public int getCenterX() {
+ return x + width / 2;
+ }
+
+ public int getCenterY() {
+ return y + height / 2;
+ }
+
+ public Point2DInt getPosition() {
+ return getCenterPoint();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/geom/ClosedArea.java b/src/net/sourceforge/plantuml/geom/ClosedArea.java
new file mode 100644
index 0000000..4fa3b74
--- /dev/null
+++ b/src/net/sourceforge/plantuml/geom/ClosedArea.java
@@ -0,0 +1,296 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.geom;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+
+public class ClosedArea extends AbstractFigure {
+
+ private final List<Point2DInt> points = new ArrayList<Point2DInt>();
+ private final List<LineSegmentInt> segmentsList = new ArrayList<LineSegmentInt>();
+
+ private int minY = Integer.MAX_VALUE;
+ private int minX = Integer.MAX_VALUE;
+ private int maxX = Integer.MIN_VALUE;
+ private int maxY = Integer.MIN_VALUE;
+
+ public ClosedArea() {
+ assert isConsistent();
+ }
+
+ @Override
+ public String toString() {
+ return points.toString();
+ }
+
+ public boolean contains(Point2DInt point) {
+ return contains(point.getXint(), point.getYint());
+ }
+
+ private boolean contains(int x, int y) {
+ if (points.size() <= 2) {
+ return false;
+ }
+ if (x > maxX) {
+ return false;
+ }
+ if (x < minX) {
+ return false;
+ }
+ if (y > maxY) {
+ return false;
+ }
+ if (y < minY) {
+ return false;
+ }
+ if (isOnFrontier(new Point2DInt(x, y))) {
+ return true;
+ }
+ int hits = 0;
+
+ int lastx = getLastPoint().getXint();
+ int lasty = getLastPoint().getYint();
+ int curx;
+ int cury;
+
+ // Walk the edges of the polygon
+ for (int i = 0; i < points.size(); lastx = curx, lasty = cury, i++) {
+ curx = points.get(i).getXint();
+ cury = points.get(i).getYint();
+
+ if (cury == lasty) {
+ continue;
+ }
+
+ final int leftx;
+ if (curx < lastx) {
+ if (x >= lastx) {
+ continue;
+ }
+ leftx = curx;
+ } else {
+ if (x >= curx) {
+ continue;
+ }
+ leftx = lastx;
+ }
+
+ final double test1;
+ final double test2;
+ if (cury < lasty) {
+ if (y < cury || y >= lasty) {
+ continue;
+ }
+ if (x < leftx) {
+ hits++;
+ continue;
+ }
+ test1 = x - curx;
+ test2 = y - cury;
+ } else {
+ if (y < lasty || y >= cury) {
+ continue;
+ }
+ if (x < leftx) {
+ hits++;
+ continue;
+ }
+ test1 = x - lastx;
+ test2 = y - lasty;
+ }
+
+ if (test1 < test2 / (lasty - cury) * (lastx - curx)) {
+ hits++;
+ }
+
+ }
+ return (hits & 1) != 0;
+
+ }
+
+ private boolean isConsistent() {
+ assert getSegments().size() == segmentsList.size();
+ assert getSegments().equals(new HashSet<LineSegmentInt>(segmentsList));
+ if (getSegments().size() > 0) {
+ assert getSegments().size() + 1 == points.size() : "points=" + points + " getSegment()=" + getSegments();
+ }
+ for (int i = 0; i < segmentsList.size(); i++) {
+ final LineSegmentInt seg = segmentsList.get(i);
+ if (seg.sameExtremities(new LineSegmentInt(points.get(i), points.get(i + 1))) == false) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public boolean isOnFrontier(Point2DInt point) {
+ for (LineSegmentInt seg : segmentsList) {
+ if (seg.containsPoint(point)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean isClosed() {
+ if (getSegments().size() < 3) {
+ return false;
+ }
+ if (getFirstSegment().atLeastOneCommonExtremities(getLastSegment())) {
+ return true;
+ }
+ return false;
+ }
+
+ ClosedArea append(LineSegmentInt other) {
+ if (isClosed()) {
+ throw new IllegalStateException();
+ }
+ if (getSegments().contains(other)) {
+ throw new IllegalArgumentException();
+ }
+ final ClosedArea result = new ClosedArea();
+ for (LineSegmentInt seg : segmentsList) {
+ result.addSegment(seg);
+ }
+ if (result.getSegments().size() > 0 && result.getLastSegment().atLeastOneCommonExtremities(other) == false) {
+ throw new IllegalArgumentException();
+ }
+ if (points.contains(other.getP1()) && points.contains(other.getP2())
+ && other.getP1().equals(getFirstPoint()) == false && other.getP2().equals(getFirstPoint()) == false) {
+ return null;
+ }
+ result.addSegment(other);
+ assert result.isConsistent();
+
+ return result;
+ }
+
+ @Override
+ public void addSegment(LineSegmentInt seg) {
+ super.addSegment(seg);
+ minY = Math.min(minY, seg.getMinY());
+ maxY = Math.max(maxY, seg.getMaxY());
+ minX = Math.min(minX, seg.getMinX());
+ maxX = Math.max(maxX, seg.getMaxX());
+ segmentsList.add(seg);
+ if (points.size() == 0) {
+ assert getSegments().size() == 1;
+ points.add(seg.getP1());
+ points.add(seg.getP2());
+ } else if (points.size() == 2) {
+ assert segmentsList.size() == 2;
+ final LineSegmentInt seg0 = segmentsList.get(0);
+ final LineSegmentInt seg1 = segmentsList.get(1);
+ points.clear();
+ final Point2DInt common = seg0.getCommonExtremities(seg1);
+ if (common == null) {
+ throw new IllegalArgumentException();
+ }
+ assert common.equals(seg1.getCommonExtremities(seg0));
+ points.add(seg0.getOtherExtremity(common));
+ points.add(common);
+ points.add(seg1.getOtherExtremity(common));
+
+ } else {
+ final Point2DInt lastPoint = getLastPoint();
+ points.add(seg.getOtherExtremity(lastPoint));
+ }
+ assert isConsistent();
+ }
+
+ private Point2DInt getLastPoint() {
+ return points.get(points.size() - 1);
+ }
+
+ private Point2DInt getFirstPoint() {
+ return points.get(0);
+ }
+
+ public LineSegmentInt getLastSegment() {
+ return segmentsList.get(segmentsList.size() - 1);
+ }
+
+ private LineSegmentInt getFirstSegment() {
+ return segmentsList.get(0);
+ }
+
+ public Point2DInt getFreePoint() {
+ if (isClosed()) {
+ throw new IllegalStateException();
+ }
+ return getLastPoint();
+ }
+
+ public int getMinY() {
+ return minY;
+ }
+
+ public int getMinX() {
+ return minX;
+ }
+
+ public int getMaxY() {
+ return maxY;
+ }
+
+ public int getMaxX() {
+ return maxX;
+ }
+
+ public boolean contains(ClosedArea other) {
+ if (isClosed() == false) {
+ throw new IllegalStateException();
+ }
+ for (Point2DInt point : other.points) {
+ if (this.contains(point) == false) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ boolean arePointsConnectable(Point2DInt p1, Point2DInt p2) {
+ if (isOnFrontier(p1) || isOnFrontier(p2)) {
+ return true;
+ }
+ final boolean pos1 = contains(p1);
+ final boolean pos2 = contains(p2);
+ return pos1 == pos2;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/geom/CollectionUtils.java b/src/net/sourceforge/plantuml/geom/CollectionUtils.java
new file mode 100644
index 0000000..8ab89fc
--- /dev/null
+++ b/src/net/sourceforge/plantuml/geom/CollectionUtils.java
@@ -0,0 +1,85 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.geom;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+public class CollectionUtils {
+
+ public static <E> Collection<List<E>> selectUpTo(List<E> original, int nb) {
+ final List<List<E>> result = new ArrayList<List<E>>();
+ for (int i = 1; i <= nb; i++) {
+ result.addAll(selectExactly(original, i));
+ }
+ return Collections.unmodifiableList(result);
+ }
+
+ public static <E> Collection<List<E>> selectExactly(List<E> original, int nb) {
+ if (nb < 0) {
+ throw new IllegalArgumentException();
+ }
+ if (nb == 0) {
+ return Collections.emptyList();
+ }
+ if (nb == 1) {
+ final List<List<E>> result = new ArrayList<List<E>>();
+ for (E element : original) {
+ result.add(Collections.singletonList(element));
+ }
+ return result;
+
+ }
+ if (nb > original.size()) {
+ return Collections.emptyList();
+ }
+ if (nb == original.size()) {
+ return Collections.singletonList(original);
+ }
+ final List<List<E>> result = new ArrayList<List<E>>();
+
+ for (List<E> subList : selectExactly(original.subList(1, original.size()), nb - 1)) {
+ final List<E> newList = new ArrayList<E>();
+ newList.add(original.get(0));
+ newList.addAll(subList);
+ result.add(Collections.unmodifiableList(newList));
+ }
+ result.addAll(selectExactly(original.subList(1, original.size()), nb));
+
+ return Collections.unmodifiableList(result);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/geom/Dijkstra.java b/src/net/sourceforge/plantuml/geom/Dijkstra.java
new file mode 100644
index 0000000..5fb0d44
--- /dev/null
+++ b/src/net/sourceforge/plantuml/geom/Dijkstra.java
@@ -0,0 +1,129 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.geom;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+public class Dijkstra {
+
+ final private double basic[][];
+ final private double dist[];
+ final private int previous[];
+ final private Set<Integer> q = new HashSet<Integer>();
+ final private int size;
+
+ public Dijkstra(int size) {
+ this.size = size;
+ this.basic = new double[size][size];
+ this.dist = new double[size];
+ this.previous = new int[size];
+ for (int i = 0; i < size; i++) {
+ for (int j = 0; j < size; j++) {
+ this.basic[i][j] = i == j ? 0 : Double.MAX_VALUE;
+ }
+ }
+ }
+
+ public void addLink(int n1, int n2, double d) {
+// Log.println("Adding " + n1 + " " + n2 + " " + d);
+ if (n1 == n2) {
+ throw new IllegalArgumentException();
+ }
+ basic[n1][n2] = d;
+ basic[n2][n1] = d;
+
+ }
+
+ private void init() {
+ for (int i = 0; i < size; i++) {
+ this.dist[i] = Double.MAX_VALUE;
+ this.previous[i] = -1;
+ this.q.add(i);
+ }
+ this.dist[0] = 0;
+ }
+
+ private void computePrevious() {
+ init();
+ while (q.size() > 0) {
+ final int u = smallest();
+ if (dist[u] == Double.MAX_VALUE) {
+ return;
+ }
+ q.remove(u);
+ for (int v = 0; v < size; v++) {
+ if (basic[u][v] == Double.MAX_VALUE) {
+ continue;
+ }
+ final double alt = dist[u] + basic[u][v];
+ if (alt < dist[v]) {
+ dist[v] = alt;
+ previous[v] = u;
+ }
+ }
+ }
+ }
+
+ public List<Integer> getBestPath() {
+ final List<Integer> result = new ArrayList<Integer>();
+ computePrevious();
+ int u = size - 1;
+ while (previous[u] >= 0) {
+ result.add(0, u);
+ u = previous[u];
+ }
+ result.add(0, 0);
+ return Collections.unmodifiableList(result);
+ }
+
+ private int smallest() {
+ int result = -1;
+ for (Integer i : q) {
+ if (result == -1 || dist[i] < dist[result]) {
+ result = i;
+ }
+ }
+ return result;
+ }
+
+ public final int getSize() {
+ return size;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/geom/InflateData.java b/src/net/sourceforge/plantuml/geom/InflateData.java
new file mode 100644
index 0000000..cad3a02
--- /dev/null
+++ b/src/net/sourceforge/plantuml/geom/InflateData.java
@@ -0,0 +1,66 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.geom;
+
+public class InflateData implements Comparable<InflateData> {
+
+ private final int pos;
+ private final int inflation;
+
+ public InflateData(int pos, int inflation) {
+ if (inflation % 2 != 0) {
+ throw new IllegalArgumentException();
+ }
+ this.pos = pos;
+ this.inflation = inflation;
+ }
+
+ public final int getPos() {
+ return pos;
+ }
+
+ public final int getInflation() {
+ return inflation;
+ }
+
+ public int compareTo(InflateData other) {
+ return -(this.pos - other.pos);
+ }
+
+ @Override
+ public String toString() {
+ return "" + pos + " (" + inflation + ")";
+ }
+}
diff --git a/src/net/sourceforge/plantuml/geom/InflationTransform.java b/src/net/sourceforge/plantuml/geom/InflationTransform.java
new file mode 100644
index 0000000..f71c14f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/geom/InflationTransform.java
@@ -0,0 +1,210 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.geom;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+class Point2DIntComparatorDistance implements Comparator<Point2DInt> {
+
+ private final Point2DInt center;
+
+ public Point2DIntComparatorDistance(Point2DInt center) {
+ this.center = center;
+ }
+
+ public int compare(Point2DInt p1, Point2DInt p2) {
+ return (int) Math.signum(p1.distance(center) - p2.distance(center));
+ }
+
+}
+
+public class InflationTransform {
+
+ private final List<InflateData> inflateX = new ArrayList<InflateData>();
+ private final List<InflateData> inflateY = new ArrayList<InflateData>();
+
+ public void addInflationX(int xpos, int inflation) {
+ add(inflateX, xpos, inflation);
+ }
+
+ @Override
+ public String toString() {
+ return "inflateX = " + inflateX + " inflateY = " + inflateY;
+ }
+
+ public void addInflationY(int ypos, int inflation) {
+ add(inflateY, ypos, inflation);
+ }
+
+ static private void add(List<InflateData> list, int ypos, int inflation) {
+ for (final ListIterator<InflateData> it = list.listIterator(); it.hasNext();) {
+ final InflateData cur = it.next();
+ if (cur.getPos() == ypos) {
+ it.set(new InflateData(ypos, Math.max(inflation, cur.getInflation())));
+ return;
+ }
+ }
+ list.add(new InflateData(ypos, inflation));
+ Collections.sort(list);
+ }
+
+ Collection<Point2DInt> cutPoints(LineSegmentInt original) {
+
+ // Log.println("original=" + original);
+ // Log.println("inflateX=" + inflateX);
+ // Log.println("inflateY=" + inflateY);
+
+ final SortedSet<Point2DInt> result = new TreeSet<Point2DInt>(new Point2DIntComparatorDistance(original.getP1()));
+
+ if (original.isHorizontal() == false) {
+ for (InflateData x : inflateX) {
+ final LineSegmentInt vertical = new LineSegmentInt(x.getPos(), original.getMinY(), x.getPos(), original
+ .getMaxY());
+ final Point2DInt inter = original.getSegIntersection(vertical);
+ if (inter != null) {
+ result.add(inter);
+ }
+ }
+ }
+ if (original.isVertical() == false) {
+ for (InflateData y : inflateY) {
+ final LineSegmentInt horizontal = new LineSegmentInt(original.getMinX(), y.getPos(),
+ original.getMaxX(), y.getPos());
+ final Point2DInt inter = original.getSegIntersection(horizontal);
+ if (inter != null) {
+ result.add(inter);
+ }
+ }
+ }
+ return result;
+ }
+
+ Collection<LineSegmentInt> cutSegments(LineSegmentInt original) {
+ final List<LineSegmentInt> result = new ArrayList<LineSegmentInt>();
+ Point2DInt cur = original.getP1();
+ final Collection<Point2DInt> cutPoints = cutPoints(original);
+ for (Point2DInt inter : cutPoints) {
+ if (cur.equals(inter)) {
+ continue;
+ }
+ result.add(new LineSegmentInt(cur, inter));
+ cur = inter;
+ }
+ if (cur.equals(original.getP2()) == false) {
+ result.add(new LineSegmentInt(cur, original.getP2()));
+ }
+ return result;
+ }
+
+ Collection<LineSegmentInt> cutSegments(Collection<LineSegmentInt> segments) {
+ final List<LineSegmentInt> result = new ArrayList<LineSegmentInt>();
+ for (LineSegmentInt seg : segments) {
+ result.addAll(cutSegments(seg));
+ }
+ return result;
+ }
+
+ private LineSegmentInt inflateSegment(LineSegmentInt seg) {
+ if (isOnGrid(seg.getP1()) || isOnGrid(seg.getP2())) {
+ return new LineSegmentInt(inflatePoint2DInt(seg.getP1()), inflatePoint2DInt(seg.getP2()));
+ }
+ for (InflateData x : inflateX) {
+ seg = seg.inflateXAlpha(x);
+ }
+ for (InflateData y : inflateY) {
+ seg = seg.inflateYAlpha(y);
+ }
+ return seg;
+ }
+
+ private boolean isOnGrid(Point2DInt point) {
+ boolean onGrid = false;
+ for (InflateData x : inflateX) {
+ if (point.getX() == x.getPos()) {
+ onGrid = true;
+ }
+ }
+ if (onGrid == false) {
+ return false;
+ }
+ for (InflateData y : inflateY) {
+ if (point.getY() == y.getPos()) {
+ return true;
+ }
+ }
+ return false;
+
+ }
+
+ public Point2DInt inflatePoint2DInt(Point2DInt point) {
+ for (InflateData x : inflateX) {
+ point = point.inflateX(x);
+ }
+ for (InflateData y : inflateY) {
+ point = point.inflateY(y);
+ }
+ return point;
+ }
+
+ List<LineSegmentInt> inflateSegmentCollection(Collection<LineSegmentInt> segments) {
+ final List<LineSegmentInt> result = new ArrayList<LineSegmentInt>();
+ for (LineSegmentInt seg : segments) {
+ result.add(inflateSegment(seg));
+ }
+ return result;
+ }
+
+ public List<LineSegmentInt> inflate(Collection<LineSegmentInt> segments) {
+ final List<LineSegmentInt> result = new ArrayList<LineSegmentInt>();
+ LineSegmentInt last = null;
+ final Collection<LineSegmentInt> cutSegments = cutSegments(segments);
+ for (LineSegmentInt seg : inflateSegmentCollection(cutSegments)) {
+ if (last != null && last.getP2().equals(seg.getP1()) == false) {
+ result.add(new LineSegmentInt(last.getP2(), seg.getP1()));
+ }
+ result.add(seg);
+ last = seg;
+
+ }
+ return result;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/geom/Kingdom.java b/src/net/sourceforge/plantuml/geom/Kingdom.java
new file mode 100644
index 0000000..8bdbf42
--- /dev/null
+++ b/src/net/sourceforge/plantuml/geom/Kingdom.java
@@ -0,0 +1,122 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.geom;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+public class Kingdom extends AbstractFigure {
+
+ private Set<ClosedArea> buildClosedArea(ClosedArea area) {
+ if (area.isClosed()) {
+ throw new IllegalArgumentException();
+ }
+ final Set<ClosedArea> result = new HashSet<ClosedArea>();
+ for (LineSegmentInt seg : getSegmentsWithExtremity(area.getFreePoint(), area.getSegments())) {
+ final ClosedArea newArea = area.append(seg);
+ if (newArea != null) {
+ result.add(newArea);
+ }
+ }
+ return Collections.unmodifiableSet(result);
+ }
+
+ private void grow(Set<ClosedArea> areas) {
+ for (ClosedArea area : new HashSet<ClosedArea>(areas)) {
+ if (area.isClosed() == false) {
+ areas.addAll(buildClosedArea(area));
+ }
+ }
+ }
+
+ public Set<ClosedArea> getAllClosedArea() {
+ final Set<ClosedArea> result = new HashSet<ClosedArea>();
+ for (LineSegmentInt seg : getSegments()) {
+ result.add(new ClosedArea().append(seg));
+ }
+ int lastSize;
+ do {
+ lastSize = result.size();
+ grow(result);
+ } while (result.size() != lastSize);
+ for (final Iterator<ClosedArea> it = result.iterator(); it.hasNext();) {
+ final ClosedArea area = it.next();
+ if (area.isClosed() == false) {
+ it.remove();
+ }
+ }
+ return Collections.unmodifiableSet(result);
+ }
+
+ // public Set<ClosedArea> getAllSmallClosedArea() {
+ // final Set<ClosedArea> all = getAllClosedArea();
+ // final Set<ClosedArea> result = new HashSet<ClosedArea>(all);
+ //
+ // for (final Iterator<ClosedArea> it = result.iterator(); it.hasNext();) {
+ // final ClosedArea area = it.next();
+ // if (containsAnotherArea(area, all)) {
+ // it.remove();
+ // }
+ // }
+ //
+ // return Collections.unmodifiableSet(result);
+ // }
+
+ // static private boolean containsAnotherArea(ClosedArea area,
+ // Set<ClosedArea> all) {
+ // for (ClosedArea another : all) {
+ // if (another == area) {
+ // continue;
+ // }
+ // if (area.contains(another)) {
+ // return true;
+ // }
+ // }
+ // return false;
+ // }
+
+ @Override
+ public boolean arePointsConnectable(Point2DInt p1, Point2DInt p2) {
+ for (ClosedArea area : getAllClosedArea()) {
+ if (area.arePointsConnectable(p1, p2) == false) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/geom/LineSegmentDouble.java b/src/net/sourceforge/plantuml/geom/LineSegmentDouble.java
new file mode 100644
index 0000000..7421684
--- /dev/null
+++ b/src/net/sourceforge/plantuml/geom/LineSegmentDouble.java
@@ -0,0 +1,110 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.geom;
+
+import java.awt.geom.Point2D;
+import java.util.Locale;
+
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class LineSegmentDouble extends AbstractLineSegment {
+
+ private final Point2D p1;
+ private final Point2D p2;
+
+ @Override
+ public String toString() {
+ return String.format(Locale.US, "( %.2f,%.2f - %.2f,%.2f )", getP1().getX(), getP1().getY(), getP2().getX(), getP2()
+ .getY());
+ }
+
+ public LineSegmentDouble(double x1, double y1, double x2, double y2) {
+ this(new Point2D.Double(x1, y1), new Point2D.Double(x2, y2));
+ }
+
+ public LineSegmentDouble(Point2D p1, Point2D p2) {
+ this.p1 = p1;
+ this.p2 = p2;
+ if (p1.equals(p2)) {
+ throw new IllegalArgumentException();
+ }
+ assert p1 != null && p2 != null;
+ assert getLength() > 0;
+ assert this.getDistance(this) == 0;
+ }
+
+ @Override
+ public Point2D getP1() {
+ return p1;
+ }
+
+ @Override
+ public Point2D getP2() {
+ return p2;
+ }
+
+ @Override
+ public double getX1() {
+ return p1.getX();
+ }
+
+ @Override
+ public double getX2() {
+ return p2.getX();
+ }
+
+ @Override
+ public double getY1() {
+ return p1.getY();
+ }
+
+ @Override
+ public double getY2() {
+ return p2.getY();
+ }
+
+ public void draw(UGraphic ug) {
+ final double x1 = p1.getX();
+ final double y1 = p1.getY();
+ final double x2 = p2.getX();
+ final double y2 = p2.getY();
+ ug = ug.apply(new UTranslate(x1, y1));
+ ug.draw(new ULine(x2 - x1, y2 - y1));
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/geom/LineSegmentInt.java b/src/net/sourceforge/plantuml/geom/LineSegmentInt.java
new file mode 100644
index 0000000..c2a418b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/geom/LineSegmentInt.java
@@ -0,0 +1,267 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.geom;
+
+import java.awt.geom.Point2D;
+import java.util.Locale;
+
+public class LineSegmentInt extends AbstractLineSegment {
+
+ private final Point2DInt p1;
+ private final Point2DInt p2;
+
+ @Override
+ public String toString() {
+ return String.format(Locale.US, "( %d,%d - %d,%d )", p1.getXint(), p1.getYint(), p2.getXint(), p2.getYint());
+ }
+
+ public LineSegmentInt(int x1, int y1, int x2, int y2) {
+ this(new Point2DInt(x1, y1), new Point2DInt(x2, y2));
+ }
+
+ public LineSegmentInt(Point2DInt p1, Point2DInt p2) {
+ this.p1 = p1;
+ this.p2 = p2;
+ if (p1.equals(p2)) {
+ throw new IllegalArgumentException();
+ }
+ assert p1 != null && p2 != null;
+ assert getLength() > 0;
+ assert this.getDistance(this) == 0;
+ }
+
+ public boolean containsPoint(Point2D point) {
+ return side(point) == 0 && isBetween(point, p1, p2);
+ }
+
+ public double side(Box box) {
+ final Point2DInt corners[] = box.getCorners();
+ final double s0 = side(corners[0]);
+ final double s1 = side(corners[1]);
+ final double s2 = side(corners[2]);
+ final double s3 = side(corners[3]);
+ if (s0 > 0 && s1 > 0 && s2 > 0 && s3 > 0) {
+ return 1;
+ }
+ if (s0 < 0 && s1 < 0 && s2 < 0 && s3 < 0) {
+ return -1;
+ }
+ return 0;
+ }
+
+ public boolean doesIntersectButNotSameExtremity(LineSegmentInt other) {
+ // assert sameExtremities(other) == false;
+ if (doesIntersect(other) == false) {
+ return false;
+ }
+ if (atLeastOneCommonExtremities(other)) {
+ return false;
+ }
+ return true;
+ }
+
+ public boolean sameExtremities(LineSegmentInt other) {
+ if (p1.equals(other.p1) && p2.equals(other.p2)) {
+ return true;
+ }
+ if (p1.equals(other.p2) && p2.equals(other.p1)) {
+ return true;
+ }
+ return false;
+ }
+
+ public boolean atLeastOneCommonExtremities(LineSegmentInt other) {
+ if (p1.equals(other.p1)) {
+ return true;
+ }
+ if (p1.equals(other.p2)) {
+ return true;
+ }
+ if (p2.equals(other.p1)) {
+ return true;
+ }
+ if (p2.equals(other.p2)) {
+ return true;
+ }
+ return false;
+ }
+
+ public Point2DInt getCommonExtremities(LineSegmentInt other) {
+ if (p1.equals(other.p1)) {
+ return p1;
+ }
+ if (p1.equals(other.p2)) {
+ return p1;
+ }
+ if (p2.equals(other.p1)) {
+ return p2;
+ }
+ if (p2.equals(other.p2)) {
+ return p2;
+ }
+ return null;
+ }
+
+ public Point2DInt getOtherExtremity(Point2DInt extremity1) {
+ if (extremity1 == null) {
+ throw new IllegalArgumentException();
+ }
+ if (extremity1.equals(p1)) {
+ return p2;
+ }
+ if (extremity1.equals(p2)) {
+ return p1;
+ }
+ throw new IllegalArgumentException();
+ }
+
+ // Line2D
+
+ @Override
+ public Point2DInt getP1() {
+ return p1;
+ }
+
+ @Override
+ public Point2DInt getP2() {
+ return p2;
+ }
+
+ @Override
+ public double getX1() {
+ return p1.getXint();
+ }
+
+ @Override
+ public double getX2() {
+ return p2.getXint();
+ }
+
+ @Override
+ public double getY1() {
+ return p1.getYint();
+ }
+
+ @Override
+ public double getY2() {
+ return p2.getYint();
+ }
+
+ public Point2DInt getTranslatedPoint(Point2DInt pointToBeTranslated) {
+ final int x = p2.getXint() - p1.getXint();
+ final int y = p2.getYint() - p1.getYint();
+ return new Point2DInt(pointToBeTranslated.getXint() + x, pointToBeTranslated.getYint() + y);
+ }
+
+ public Point2DInt getCenter() {
+ return new Point2DInt((p1.getXint() + p2.getXint()) / 2, (p1.getYint() + p2.getYint()) / 2);
+ }
+
+ public int getMinX() {
+ return Math.min(p1.getXint(), p2.getXint());
+ }
+
+ public int getMaxX() {
+ return Math.max(p1.getXint(), p2.getXint());
+ }
+
+ public int getMinY() {
+ return Math.min(p1.getYint(), p2.getYint());
+ }
+
+ public int getMaxY() {
+ return Math.max(p1.getYint(), p2.getYint());
+ }
+
+ public Point2DInt ortho(Point2D.Double orig, double d) {
+ final double vectX = p2.getY() - p1.getY();
+ final double vectY = -(p2.getX() - p1.getX());
+ final double pour = 1.0 * d / 100.0;
+ final double x = orig.x + vectX * pour;
+ final double y = orig.y + vectY * pour;
+ return new Point2DInt((int) Math.round(x), (int) Math.round(y));
+ }
+
+ public LineSegmentInt translate(int deltaX, int deltaY) {
+ return new LineSegmentInt(p1.translate(deltaX, deltaY), p2.translate(deltaX, deltaY));
+ }
+
+ public LineSegmentInt inflateXAlpha(InflateData inflateData) {
+
+ final int xpos = inflateData.getPos();
+ final int inflation = inflateData.getInflation();
+ if (isHorizontal()) {
+ return new LineSegmentInt(p1.inflateX(inflateData), p2.inflateX(inflateData));
+ }
+ if (getP1().getXint() == xpos && getP2().getXint() == xpos) {
+ return this.translate(inflation / 2, 0);
+ }
+ if (getP1().getXint() <= xpos && getP2().getXint() <= xpos) {
+ return this;
+ }
+ if (getP1().getXint() >= xpos && getP2().getXint() >= xpos) {
+ return this.translate(inflation, 0);
+ }
+ throw new UnsupportedOperationException(toString() + " " + inflateData);
+ }
+
+ public LineSegmentInt inflateYAlpha(InflateData inflateData) {
+ final int ypos = inflateData.getPos();
+ final int inflation = inflateData.getInflation();
+ if (isVertical()) {
+ return new LineSegmentInt(p1.inflateY(inflateData), p2.inflateY(inflateData));
+ }
+ if (getP1().getYint() == ypos && getP2().getYint() == ypos) {
+ return this.translate(0, inflation / 2);
+ }
+ if (getP1().getYint() <= ypos && getP2().getYint() <= ypos) {
+ return this;
+ }
+ if (getP1().getYint() >= ypos && getP2().getYint() >= ypos) {
+ return this.translate(0, inflation);
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Point2DInt getSegIntersection(AbstractLineSegment other) {
+ final Point2D result = super.getSegIntersection(other);
+ if (result == null) {
+ return null;
+ }
+ return new Point2DInt((int) Math.round(result.getX()), (int) Math.round(result.getY()));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/geom/Neighborhood.java b/src/net/sourceforge/plantuml/geom/Neighborhood.java
new file mode 100644
index 0000000..01d8e37
--- /dev/null
+++ b/src/net/sourceforge/plantuml/geom/Neighborhood.java
@@ -0,0 +1,118 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.geom;
+
+public class Neighborhood {
+
+ final private double angle1;
+ final private double angle2;
+ final private Point2DInt center;
+
+ public Neighborhood(Point2DInt center) {
+ this(center, 0, 0);
+ }
+
+ public boolean is360() {
+ return angle1 == angle2;
+ }
+
+ public Neighborhood(Point2DInt center, double angle1, double angle2) {
+ this.center = center;
+ this.angle1 = angle1;
+ this.angle2 = angle2;
+ }
+
+ @Override
+ public String toString() {
+ final int a1 = (int) (angle1 * 180 / Math.PI);
+ final int a2 = (int) (angle2 * 180 / Math.PI);
+ return center + " " + a1 + " " + a2;
+ }
+
+ public final Point2DInt getCenter() {
+ return center;
+ }
+
+ public final double getMiddle() {
+ if (is360()) {
+ return angle1 + Math.PI;
+ }
+ double result = (angle1 + angle2) / 2;
+ if (angle2 < angle1) {
+ result += Math.PI;
+ }
+ return result;
+ }
+
+ public boolean isInAngleStrict(double angle) {
+ if (angle < 0) {
+ throw new IllegalArgumentException();
+ }
+ if (angle2 > angle1) {
+ return angle > angle1 && angle < angle2;
+ }
+ return angle > angle1 || angle < angle2;
+ }
+
+ public boolean isInAngleLarge(double angle) {
+ if (angle < 0) {
+ throw new IllegalArgumentException();
+ }
+ if (angle2 > angle1) {
+ return angle >= angle1 && angle <= angle2;
+ }
+ return angle >= angle1 || angle <= angle2;
+ }
+
+ public boolean isAngleLimit(double angle) {
+ return angle == angle1 || angle == angle2;
+ }
+
+ public Orientation getOrientationFrom(double angle) {
+ if (angle1 == angle2) {
+ throw new IllegalStateException();
+ }
+ if (angle != angle1 && angle != angle2) {
+ throw new IllegalArgumentException("this=" + this + " angle=" + (int) (angle * 180 / Math.PI));
+ }
+ assert angle == angle1 || angle == angle2;
+
+ if (angle == angle1) {
+ return Orientation.MATH;
+ }
+ return Orientation.CLOCK;
+
+ }
+}
diff --git a/src/net/sourceforge/plantuml/geom/Orientation.java b/src/net/sourceforge/plantuml/geom/Orientation.java
new file mode 100644
index 0000000..c801074
--- /dev/null
+++ b/src/net/sourceforge/plantuml/geom/Orientation.java
@@ -0,0 +1,41 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.geom;
+
+public enum Orientation {
+
+ CLOCK, MATH
+
+}
diff --git a/src/net/sourceforge/plantuml/geom/Point2DInt.java b/src/net/sourceforge/plantuml/geom/Point2DInt.java
new file mode 100644
index 0000000..9834fca
--- /dev/null
+++ b/src/net/sourceforge/plantuml/geom/Point2DInt.java
@@ -0,0 +1,121 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.geom;
+
+import java.awt.geom.Point2D;
+
+public class Point2DInt extends Point2D implements Pointable {
+
+ private final int x;
+ private final int y;
+
+ @Override
+ public String toString() {
+ return "(" + x + "," + y + ")";
+ }
+
+ public Point2DInt(int x, int y) {
+ this.x = x;
+ this.y = y;
+ }
+
+ public int getXint() {
+ return x;
+ }
+
+ public int getYint() {
+ return y;
+ }
+
+ @Override
+ public double getX() {
+ return x;
+ }
+
+ @Override
+ public double getY() {
+ return y;
+ }
+
+ @Override
+ public void setLocation(double x, double y) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Point2DInt getPosition() {
+ return this;
+ }
+
+ public Point2DInt translate(int deltaX, int deltaY) {
+ return new Point2DInt(x + deltaX, y + deltaY);
+ }
+
+ public Point2DInt inflateX(int xpos, int inflation) {
+ if (inflation % 2 != 0) {
+ throw new IllegalArgumentException();
+ }
+ if (x < xpos) {
+ return this;
+ }
+ if (x == xpos) {
+ // throw new IllegalArgumentException();
+ return translate(inflation / 2, 0);
+ }
+ return translate(inflation, 0);
+ }
+
+ public Point2DInt inflateX(InflateData inflateData) {
+ return inflateX(inflateData.getPos(), inflateData.getInflation());
+ }
+
+ public Point2DInt inflateY(InflateData inflateData) {
+ return inflateY(inflateData.getPos(), inflateData.getInflation());
+ }
+
+ public Point2DInt inflateY(int ypos, int inflation) {
+ if (inflation % 2 != 0) {
+ throw new IllegalArgumentException();
+ }
+ if (y < ypos) {
+ return this;
+ }
+ if (y == ypos) {
+ // throw new IllegalArgumentException();
+ return translate(0, inflation / 2);
+ }
+ return translate(0, inflation);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/geom/Pointable.java b/src/net/sourceforge/plantuml/geom/Pointable.java
new file mode 100644
index 0000000..911ddf0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/geom/Pointable.java
@@ -0,0 +1,39 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.geom;
+
+public interface Pointable {
+ Point2DInt getPosition();
+}
diff --git a/src/net/sourceforge/plantuml/geom/Polyline.java b/src/net/sourceforge/plantuml/geom/Polyline.java
new file mode 100644
index 0000000..9c2391d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/geom/Polyline.java
@@ -0,0 +1,49 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.geom;
+
+import java.util.List;
+
+public interface Polyline {
+
+ List<LineSegmentInt> segments();
+
+ int nbSegments();
+
+ boolean doesTouch(Polyline other);
+
+ double getLength();
+
+}
diff --git a/src/net/sourceforge/plantuml/geom/PolylineBreakeable.java b/src/net/sourceforge/plantuml/geom/PolylineBreakeable.java
new file mode 100644
index 0000000..667e355
--- /dev/null
+++ b/src/net/sourceforge/plantuml/geom/PolylineBreakeable.java
@@ -0,0 +1,153 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.geom;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public class PolylineBreakeable extends AbstractPolyline implements Polyline {
+
+ static class Breakure {
+ private int d;
+ private int u;
+
+ public Breakure(int u, int d) {
+ this.u = u;
+ this.d = d;
+ }
+ }
+
+ private final List<Breakure> breakures = new ArrayList<Breakure>();
+
+ public PolylineBreakeable copy(Pointable newStart, Pointable newEnd) {
+ final PolylineBreakeable result = new PolylineBreakeable(newStart, newEnd);
+ result.breakures.addAll(this.breakures);
+ return result;
+ }
+
+ public PolylineBreakeable(Pointable start, Pointable end) {
+ super(start, end);
+ }
+
+ public List<LineSegmentInt> segments() {
+ if (breakures.size() == 0) {
+ return Collections.singletonList(new LineSegmentInt(getStart().getPosition(), getEnd().getPosition()));
+ }
+ final List<LineSegmentInt> result = new ArrayList<LineSegmentInt>();
+ Point2DInt cur = getStart().getPosition();
+ for (Breakure breakure : breakures) {
+ final Point2DInt next = getBreakurePoint(breakure);
+ result.add(new LineSegmentInt(cur, next));
+ cur = next;
+ }
+ result.add(new LineSegmentInt(cur, getEnd().getPosition()));
+ assert nbSegments() == result.size();
+ return Collections.unmodifiableList(result);
+ }
+
+ private Point2DInt getBreakurePoint(Breakure breakure) {
+ final LineSegmentInt seg = new LineSegmentInt(getStart().getPosition(), getEnd().getPosition());
+ return seg.ortho(seg.startTranslatedAsVector(breakure.u), breakure.d);
+ }
+
+ public int nbSegments() {
+ return breakures.size() + 1;
+ }
+
+ public List<XMoveable> getFreedoms() {
+ final List<XMoveable> allFreedom = new ArrayList<XMoveable>();
+
+ for (final Breakure breakure : breakures) {
+ allFreedom.add(new XMoveable() {
+ @Override
+ public String toString() {
+ return super.toString() + " " + PolylineBreakeable.this.toString() + "(d)";
+ }
+
+ public void moveX(int delta) {
+ breakure.d += delta;
+ }
+ });
+ allFreedom.add(new XMoveable() {
+ @Override
+ public String toString() {
+ return super.toString() + " " + PolylineBreakeable.this.toString() + "(u)";
+ }
+
+ public void moveX(int delta) {
+ breakure.u += delta;
+ }
+ });
+ allFreedom.add(new XMoveable() {
+ @Override
+ public String toString() {
+ return super.toString() + " " + PolylineBreakeable.this.toString() + "(ud)";
+ }
+
+ public void moveX(int delta) {
+ breakure.u += delta;
+ breakure.d += delta;
+ }
+ });
+ allFreedom.add(new XMoveable() {
+ @Override
+ public String toString() {
+ return super.toString() + " " + PolylineBreakeable.this.toString() + "(dud)";
+ }
+
+ public void moveX(int delta) {
+ breakure.u += delta;
+ breakure.d -= delta;
+ }
+ });
+ }
+
+ return Collections.unmodifiableList(allFreedom);
+ }
+
+ public void insertBetweenPoint(int u, int d) {
+ breakures.add(new Breakure(u, d));
+ }
+
+ private void breakMore() {
+ if (breakures.size() == 1) {
+ final Breakure b = breakures.get(0);
+ insertBetweenPoint(b.u / 2, 0);
+ }
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/geom/PolylineImpl.java b/src/net/sourceforge/plantuml/geom/PolylineImpl.java
new file mode 100644
index 0000000..b384674
--- /dev/null
+++ b/src/net/sourceforge/plantuml/geom/PolylineImpl.java
@@ -0,0 +1,99 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.geom;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+public class PolylineImpl extends AbstractPolyline implements Polyline {
+
+ final private List<Point2DInt> intermediates = new ArrayList<Point2DInt>();
+
+ public PolylineImpl(Pointable start, Pointable end) {
+ super(start, end);
+ }
+
+ public int nbSegments() {
+ return intermediates.size() + 1;
+ }
+
+ public List<LineSegmentInt> segments() {
+ final List<LineSegmentInt> result = new ArrayList<LineSegmentInt>();
+ Point2DInt cur = getStart().getPosition();
+ for (Point2DInt intermediate : intermediates) {
+ result.add(new LineSegmentInt(cur, intermediate));
+ cur = intermediate;
+ }
+ result.add(new LineSegmentInt(cur, getEnd().getPosition()));
+ return Collections.unmodifiableList(result);
+ }
+
+ public void addIntermediate(Point2DInt intermediate) {
+ assert intermediates.contains(intermediate) == false;
+ intermediates.add(intermediate);
+ }
+
+ public void inflate(InflationTransform transform) {
+ // final List<LineSegment> segments = segments();
+ // if (segments.size() == 1) {
+ // return;
+ // }
+ // intermediates.clear();
+ // if (segments.size() == 2) {
+ // final Point2DInt p = segments.get(0).getP2();
+ // intermediates.add(transform.inflatePoint2DInt(p));
+ // } else {
+ // final List<LineSegment> segmentsT = transform.inflate(segments);
+ // for (int i = 0; i < segmentsT.size() - 2; i++) {
+ // intermediates.add(segmentsT.get(i).getP2());
+ // }
+ //
+ // }
+
+ final List<LineSegmentInt> segments = transform.inflate(this.segments());
+ // Log.println("segments="+segments);
+ intermediates.clear();
+ for (int i = 1; i < segments.size() - 1; i++) {
+ addIntermediate(segments.get(i).getP1());
+ }
+ }
+
+ public final Collection<Point2DInt> getIntermediates() {
+ return Collections.unmodifiableCollection(intermediates);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/geom/Singularity.java b/src/net/sourceforge/plantuml/geom/Singularity.java
new file mode 100644
index 0000000..901224a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/geom/Singularity.java
@@ -0,0 +1,153 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.geom;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.TreeSet;
+
+public class Singularity {
+
+ private final TreeSet<Double> angles = new TreeSet<Double>();
+
+ final private Point2DInt center;
+
+ public Singularity(Point2DInt center) {
+ this.center = center;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder(center.toString());
+ for (Double a : angles) {
+ final int degree = (int) (a * 180 / Math.PI);
+ sb.append(' ');
+ sb.append(degree);
+ }
+ return sb.toString();
+ }
+
+ public void addLineSegment(LineSegmentInt seg) {
+ if (seg.getP1().equals(center)) {
+ angles.add(convertAngle(seg.getAngle()));
+ } else if (seg.getP2().equals(center)) {
+ angles.add(convertAngle(seg.getOppositeAngle()));
+ } else {
+ assert seg.side(center) == 0 : "side=" + seg.side(center) + " center=" + center + " seg=" + seg;
+ assert LineSegmentInt.isBetween(center, seg.getP1(), seg.getP2());
+ addLineSegment(new LineSegmentInt(center, seg.getP1()));
+ addLineSegment(new LineSegmentInt(center, seg.getP2()));
+ }
+ assert betweenZeroAndTwoPi();
+
+ }
+
+ static double convertAngle(double a) {
+ if (a < 0) {
+ return a + 2 * Math.PI;
+ }
+ return a;
+ }
+
+ private boolean betweenZeroAndTwoPi() {
+ for (Double d : angles) {
+ assert d >= 0;
+ assert d < 2 * Math.PI;
+ }
+ return true;
+ }
+
+ List<Double> getAngles() {
+ return new ArrayList<Double>(angles);
+ }
+
+ public boolean crossing(Point2DInt direction1, Point2DInt direction2) {
+ final boolean result = crossingInternal(direction1, direction2);
+ assert result == crossingInternal(direction2, direction1);
+ return result;
+ }
+
+ private boolean crossingInternal(Point2DInt direction1, Point2DInt direction2) {
+ if (angles.size() < 2) {
+ return false;
+ }
+ final double angle1 = convertAngle(new LineSegmentInt(center, direction1).getAngle());
+ final double angle2 = convertAngle(new LineSegmentInt(center, direction2).getAngle());
+
+ Double last = null;
+ for (Double current : angles) {
+ if (last != null) {
+ assert last < current;
+ if (isBetween(angle1, last, current) && isBetween(angle2, last, current)) {
+ return false;
+ }
+ }
+ last = current;
+ }
+ final double first = angles.first();
+ if ((angle1 <= first || angle1 >= last) && (angle2 <= first || angle2 >= last)) {
+ return false;
+ }
+ return true;
+ }
+
+ private boolean isBetween(double test, double v1, double v2) {
+ assert v1 < v2;
+ return test >= v1 && test <= v2;
+ }
+
+ protected final Point2DInt getCenter() {
+ return center;
+ }
+
+ public void merge(Singularity other) {
+ this.angles.addAll(other.angles);
+ }
+
+ public List<Neighborhood> getNeighborhoods() {
+ if (angles.size() == 0) {
+ return Collections.singletonList(new Neighborhood(center));
+ }
+ final List<Neighborhood> result = new ArrayList<Neighborhood>();
+ double last = angles.last();
+ for (Double currentAngle : angles) {
+ result.add(new Neighborhood(center, last, currentAngle));
+ last = currentAngle;
+ }
+ return Collections.unmodifiableList(result);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/geom/SpiderWeb.java b/src/net/sourceforge/plantuml/geom/SpiderWeb.java
new file mode 100644
index 0000000..49db8d2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/geom/SpiderWeb.java
@@ -0,0 +1,182 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.geom;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import net.sourceforge.plantuml.Log;
+
+public class SpiderWeb {
+
+ private final int pointsInCircle = 16;
+ private int nbRow;
+ private int nbCol;
+
+ final private int widthCell;
+ final private int heightCell;
+
+ final private int xMargin = 50;
+ final private int yMargin = 50;
+
+ private final List<PolylineBreakeable> lines = new ArrayList<PolylineBreakeable>();
+
+ public SpiderWeb(int widthCell, int heightCell) {
+ Log.info("widthCell=" + widthCell + " heightCell=" + heightCell);
+ this.widthCell = widthCell;
+ this.heightCell = heightCell;
+ }
+
+ public Point2DInt getMainPoint(int row, int col) {
+ return new Point2DInt(col * (widthCell + xMargin), row * (heightCell + yMargin));
+ }
+
+ public Collection<Point2DInt> getHangPoints(int row, int col) {
+ // final double dist = Math.pow(1.6, -row - 10) + Math.pow(1.5, -col -
+ // 10);
+ assert pointsInCircle % 4 == 0;
+ final List<Point2DInt> result = new ArrayList<Point2DInt>();
+ final int dist = (int) Math.round(Math.sqrt(widthCell * widthCell + heightCell * heightCell) / 10);
+ for (int i = 0; i < pointsInCircle; i++) {
+ final Point2DInt main = getMainPoint(row, col);
+ final int x = main.getXint();
+ final int y = main.getYint();
+ if (i == 0) {
+ result.add(new Point2DInt(x + dist, y));
+ } else if (i == pointsInCircle / 4) {
+ result.add(new Point2DInt(x, y + dist));
+ } else if (i == 2 * pointsInCircle / 4) {
+ result.add(new Point2DInt(x - dist, y));
+ } else if (i == 3 * pointsInCircle / 4) {
+ result.add(new Point2DInt(x, y - dist));
+ } else {
+ final double angle = Math.PI * 2.0 * i / pointsInCircle;
+ final double x1 = x + dist * Math.cos(angle);
+ final double y1 = y + dist * Math.sin(angle);
+ result.add(new Point2DInt((int) Math.round(x1), (int) Math.round(y1)));
+ }
+ }
+ // Log.println("getHangPoints="+result);
+ return result;
+ }
+
+ public PolylineBreakeable addPolyline(int row1, int col1, int row2, int col2) {
+ // Log.println("SpiderWeb : adding " + row1 + "," + col1 + " - "
+ // + row2 + "," + col2);
+ final PolylineBreakeable result = computePolyline(row1, col1, row2, col2);
+ // Log.println("SpiderWeb : adding " + result);
+ if (result != null) {
+ lines.add(result);
+ }
+ return result;
+ }
+
+ private PolylineBreakeable computePolyline(int row1, int col1, int row2, int col2) {
+ if (row1 > nbRow) {
+ nbRow = row1;
+ }
+ if (row2 > nbRow) {
+ nbRow = row2;
+ }
+ if (col1 > nbCol) {
+ nbCol = col1;
+ }
+ if (col2 > nbCol) {
+ nbCol = col2;
+ }
+ if (directLinkPossibleForGeometry(row1, col1, row2, col2)) {
+ // Log.println("Geom OK");
+ final PolylineBreakeable direct = new PolylineBreakeable(getMainPoint(row1, col1), getMainPoint(row2, col2));
+ if (isCompatible(direct)) {
+ // Log.println("Direct OK");
+ return direct;
+ }
+ }
+ return bestLevel1Line(row1, col1, row2, col2);
+ }
+
+ private boolean isCompatible(PolylineBreakeable toTest) {
+ for (PolylineBreakeable p : lines) {
+ if (p.doesTouch(toTest)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private PolylineBreakeable bestLevel1Line(int row1, int col1, int row2, int col2) {
+ PolylineBreakeable result = null;
+ for (int u = 5; u <= 95; u += 5) {
+ for (int d = -200; d <= 200; d += 5) {
+ final PolylineBreakeable cur = new PolylineBreakeable(getMainPoint(row1, col1),
+ getMainPoint(row2, col2));
+ cur.insertBetweenPoint(u, d);
+ if ((result == null || cur.getLength() < result.getLength()) && isCompatible(cur)) {
+ result = cur;
+ }
+
+ }
+ }
+ return result;
+ }
+
+ boolean directLinkPossibleForGeometry(int row1, int col1, int row2, int col2) {
+ final int rowMin = Math.min(row1, row2);
+ final int rowMax = Math.max(row1, row2);
+ final int colMin = Math.min(col1, col2);
+ final int colMax = Math.max(col1, col2);
+ final LineSegmentInt seg = new LineSegmentInt(col1, row1, col2, row2);
+ for (int r = rowMin; r <= rowMax; r++) {
+ for (int c = colMin; c <= colMax; c++) {
+ if (r == row1 && c == col1) {
+ continue;
+ }
+ if (r == row2 && c == col2) {
+ continue;
+ }
+ if (seg.containsPoint(new Point2DInt(c, r))) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ final int getPointsInCircle() {
+ return pointsInCircle;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/geom/XMoveable.java b/src/net/sourceforge/plantuml/geom/XMoveable.java
new file mode 100644
index 0000000..5dbdb2f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/geom/XMoveable.java
@@ -0,0 +1,41 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.geom;
+
+public interface XMoveable {
+
+ void moveX(int delta);
+
+}
diff --git a/src/net/sourceforge/plantuml/geom/kinetic/Frame.java b/src/net/sourceforge/plantuml/geom/kinetic/Frame.java
new file mode 100644
index 0000000..c1ab7cf
--- /dev/null
+++ b/src/net/sourceforge/plantuml/geom/kinetic/Frame.java
@@ -0,0 +1,117 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.geom.kinetic;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.geom.LineSegmentDouble;
+
+public class Frame {
+
+ private double x;
+ private double y;
+
+ private final int width;
+ private final int height;
+
+ public Frame(double x, double y, int width, int height) {
+ this.x = x;
+ this.y = y;
+ this.width = width;
+ this.height = height;
+ }
+
+ LineSegmentDouble getSide1() {
+ return new LineSegmentDouble(x, y, x, y + height);
+ }
+
+ LineSegmentDouble getSide2() {
+ return new LineSegmentDouble(x, y, x + width, y);
+ }
+
+ LineSegmentDouble getSide3() {
+ return new LineSegmentDouble(x + width, y, x + width, y + height);
+ }
+
+ LineSegmentDouble getSide4() {
+ return new LineSegmentDouble(x, y + height, x + width, y + height);
+ }
+
+ public Point2D getFrontierPointViewBy(Point2D point) {
+ final LineSegmentDouble seg = new LineSegmentDouble(point, getCenter());
+ Point2D p = seg.getSegIntersection(getSide1());
+ if (p != null) {
+ return p;
+ }
+ p = seg.getSegIntersection(getSide2());
+ if (p != null) {
+ return p;
+ }
+ p = seg.getSegIntersection(getSide3());
+ if (p != null) {
+ return p;
+ }
+ p = seg.getSegIntersection(getSide4());
+ if (p != null) {
+ return p;
+ }
+ return null;
+ }
+
+ private Point2D getCenter() {
+ return new Point2D.Double(x + width / 2.0, y + height / 2.0);
+ }
+
+ public Point2D getMainCorner() {
+ return new Point2D.Double(x, y);
+ }
+
+ public final double getX() {
+ return x;
+ }
+
+ public final double getY() {
+ return y;
+ }
+
+ public final int getWidth() {
+ return width;
+ }
+
+ public final int getHeight() {
+ return height;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/geom/kinetic/MoveObserver.java b/src/net/sourceforge/plantuml/geom/kinetic/MoveObserver.java
new file mode 100644
index 0000000..c232670
--- /dev/null
+++ b/src/net/sourceforge/plantuml/geom/kinetic/MoveObserver.java
@@ -0,0 +1,41 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.geom.kinetic;
+
+public interface MoveObserver {
+
+ public void pointMoved(Point2DCharge point);
+
+}
diff --git a/src/net/sourceforge/plantuml/geom/kinetic/Path.java b/src/net/sourceforge/plantuml/geom/kinetic/Path.java
new file mode 100644
index 0000000..e6c7be6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/geom/kinetic/Path.java
@@ -0,0 +1,163 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.geom.kinetic;
+
+import java.awt.geom.Line2D;
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class Path {
+
+ private final Frame frame1;
+ private final Frame frame2;
+ private final List<Point2DCharge> points1 = new ArrayList<Point2DCharge>();
+ // private final Map<Point2DCharge, Integer> points2 = new
+ // HashMap<Point2DCharge, Integer>(1000, (float).01);
+ private final Map<Point2DCharge, Integer> points2 = new HashMap<Point2DCharge, Integer>();
+
+ public Path(Frame f1, Frame f2) {
+ if (f1 == null || f2 == null) {
+ throw new IllegalArgumentException();
+ }
+ this.frame1 = f1;
+ this.frame2 = f2;
+ updateCharges();
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append(frame1.getMainCorner());
+ for (Point2DCharge p : points1) {
+ sb.append(' ');
+ sb.append(p);
+ }
+ sb.append(frame2.getMainCorner());
+ return sb.toString();
+ }
+
+ private void updateCharges() {
+ for (Point2DCharge pt : points1) {
+ // pt.setCharge(1.0 / points1.size());
+ pt.setCharge(1.0);
+ }
+ }
+
+ private static final double MINDIST = 30;
+
+ public void renderContinue() {
+ final List<Point2D> newPoints = new ArrayList<Point2D>();
+ Point2D cur = frame1.getMainCorner();
+ for (Point2DCharge pc : points1) {
+ final SegmentCutter segmentCutter = new SegmentCutter(cur, pc, MINDIST);
+ newPoints.addAll(segmentCutter.intermediates());
+ cur = pc;
+ }
+ final SegmentCutter segmentCutter = new SegmentCutter(cur, frame2.getMainCorner(), MINDIST);
+ final List<Point2D> in = segmentCutter.intermediates();
+ newPoints.addAll(in.subList(0, in.size() - 1));
+
+ points1.clear();
+ points2.clear();
+ for (Point2D pt : newPoints) {
+ addIntermediate(new Point2DCharge(pt.getX(), pt.getY()));
+ }
+ }
+
+ public List<Line2D> segments() {
+ final List<Line2D> result = new ArrayList<Line2D>();
+ Point2D cur = frame1.getMainCorner();
+ for (Point2D pt : points1) {
+ result.add(new Line2D.Double(cur, pt));
+ cur = pt;
+ }
+ result.add(new Line2D.Double(cur, frame2.getMainCorner()));
+ return Collections.unmodifiableList(result);
+ }
+
+ public void addIntermediate(Point2DCharge point) {
+ assert points1.size() == points2.size();
+ assert points1.contains(point) == false;
+ assert points2.containsKey(point) == false;
+ assert containsPoint2DCharge(point) == false;
+ points1.add(point);
+ points2.put(point, points2.size());
+ assert points1.size() == points2.size();
+ assert points1.contains(point);
+ assert points2.containsKey(point);
+ assert containsPoint2DCharge(point);
+ updateCharges();
+ }
+
+ public VectorForce getElasticForce(Point2DCharge point) {
+ final int idx = points1.indexOf(point);
+ if (idx == -1) {
+ throw new UnsupportedOperationException();
+ }
+ final Point2D before = getPosition(idx - 1);
+ final Point2D after = getPosition(idx + 1);
+ final VectorForce f1 = new VectorForce(point, before);
+ final VectorForce f2 = new VectorForce(point, after);
+ return f1.plus(f2).multiply(0.2);
+ // return new VectorForce(0, 0);
+ }
+
+ private Point2D getPosition(int idx) {
+ if (idx == -1) {
+ return frame1.getMainCorner();
+ }
+ if (idx == points1.size()) {
+ return frame2.getMainCorner();
+ }
+ return points1.get(idx);
+ }
+
+ public boolean containsPoint2DCharge(Point2DCharge p) {
+ assert points1.contains(p) == points2.containsKey(p) : "p=" + p + "v1=" + points1.contains(p) + "v2="
+ + points2.containsKey(p) + " points1=" + points1 + " points2=" + points2;
+ return points2.containsKey(p);
+ }
+
+ public final Collection<Point2DCharge> getPoints() {
+ assert points1.size() == points2.size();
+ return Collections.unmodifiableCollection(points1);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/geom/kinetic/Point2DCharge.java b/src/net/sourceforge/plantuml/geom/kinetic/Point2DCharge.java
new file mode 100644
index 0000000..8e7b79a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/geom/kinetic/Point2DCharge.java
@@ -0,0 +1,104 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.geom.kinetic;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.Log;
+
+public class Point2DCharge extends Point2D.Double {
+
+ private double charge = 1.0;
+
+ private MoveObserver moveObserver = null;
+
+ public Point2DCharge(double x, double y) {
+ super(x, y);
+ }
+
+ public Point2DCharge(Point2D pt, double ch) {
+ super(pt.getX(), pt.getY());
+ this.charge = ch;
+ }
+
+ public void apply(VectorForce value) {
+ Log.println("Applying " + value);
+ x += value.getX();
+ y += value.getY();
+ if (moveObserver != null) {
+ moveObserver.pointMoved(this);
+ }
+ }
+
+ @Override
+ final public void setLocation(double x, double y) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ final public void setLocation(Point2D p) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String toString() {
+ return System.identityHashCode(this) + " " + String.format("[%8.2f %8.2f]", x, y);
+ }
+
+ public final double getCharge() {
+ return charge;
+ }
+
+ public final void setCharge(double charge) {
+ this.charge = charge;
+ }
+
+ private final int hash = System.identityHashCode(this);
+
+ @Override
+ public int hashCode() {
+ return hash;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return this == obj;
+ }
+
+ public final void setMoveObserver(MoveObserver moveObserver) {
+ this.moveObserver = moveObserver;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/geom/kinetic/Quadrant.java b/src/net/sourceforge/plantuml/geom/kinetic/Quadrant.java
new file mode 100644
index 0000000..cc058ff
--- /dev/null
+++ b/src/net/sourceforge/plantuml/geom/kinetic/Quadrant.java
@@ -0,0 +1,81 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.geom.kinetic;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+
+public class Quadrant {
+
+ static final private int SIZE = 100;
+
+ private final int x;
+ private final int y;
+
+ public Quadrant(int x, int y) {
+ this.x = x;
+ this.y = y;
+ }
+
+ public Quadrant(Point2DCharge pt) {
+ this((int) pt.getX() / SIZE, (int) pt.getY() / SIZE);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ final Quadrant other = (Quadrant) obj;
+ return x == other.x && y == other.y;
+ }
+
+ @Override
+ public int hashCode() {
+ return x * 3571 + y;
+ }
+
+ @Override
+ public String toString() {
+ return "" + x + "-" + y;
+ }
+
+ public Collection<Quadrant> neighbourhood() {
+ final Collection<Quadrant> result = Arrays.asList(new Quadrant(x - 1, y - 1), new Quadrant(x, y - 1),
+ new Quadrant(x + 1, y - 1), new Quadrant(x - 1, y), this, new Quadrant(x + 1, y), new Quadrant(x - 1,
+ y + 1), new Quadrant(x, y + 1), new Quadrant(x + 1, y + 1));
+ assert new HashSet<Quadrant>(result).size() == 9;
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/geom/kinetic/QuadrantMapper.java b/src/net/sourceforge/plantuml/geom/kinetic/QuadrantMapper.java
new file mode 100644
index 0000000..ca897bb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/geom/kinetic/QuadrantMapper.java
@@ -0,0 +1,105 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.geom.kinetic;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+public class QuadrantMapper {
+
+ private final Map<Point2DCharge, Quadrant> quadrants = new HashMap<Point2DCharge, Quadrant>();
+ private final Map<Quadrant, HashSet<Point2DCharge>> setOfPoints = new HashMap<Quadrant, HashSet<Point2DCharge>>();
+
+ public void addPoint(Point2DCharge pt) {
+ if (quadrants.containsKey(pt)) {
+ throw new IllegalArgumentException();
+ }
+ final Quadrant q = new Quadrant(pt);
+ quadrants.put(pt, q);
+ getSetOfPoints(q).add(pt);
+ assert getSetOfPoints(q).contains(pt);
+ assert getSetOfPoints(new Quadrant(pt)).contains(pt);
+ }
+
+ public Set<Point2DCharge> getAllPoints(Quadrant qt) {
+ return Collections.unmodifiableSet(getSetOfPoints(qt));
+ }
+
+ public Set<Point2DCharge> getAllPoints() {
+ assert quadrants.keySet().equals(mergeOfSetOfPoints());
+ return Collections.unmodifiableSet(quadrants.keySet());
+ }
+
+ private Set<Point2DCharge> mergeOfSetOfPoints() {
+ final Set<Point2DCharge> result = new HashSet<Point2DCharge>();
+ for (Set<Point2DCharge> set : setOfPoints.values()) {
+ assert Collections.disjoint(set, result);
+ result.addAll(set);
+ }
+ return result;
+ }
+
+ public void updatePoint(Point2DCharge pt) {
+ final Quadrant newQ = new Quadrant(pt);
+ final Quadrant old = quadrants.get(pt);
+ assert getSetOfPoints(old).contains(pt);
+ if (old.equals(newQ) == false) {
+ assert getSetOfPoints(newQ).contains(pt) == false;
+ assert getSetOfPoints(old).contains(pt);
+ final boolean remove = getSetOfPoints(old).remove(pt);
+ assert remove;
+ final boolean add = getSetOfPoints(newQ).add(pt);
+ assert add;
+ assert getSetOfPoints(newQ).contains(pt);
+ assert getSetOfPoints(old).contains(pt) == false;
+ quadrants.put(pt, newQ);
+ }
+ assert getSetOfPoints(new Quadrant(pt)).contains(pt);
+ }
+
+ private HashSet<Point2DCharge> getSetOfPoints(Quadrant q) {
+ HashSet<Point2DCharge> result = setOfPoints.get(q);
+ if (result == null) {
+ result = new HashSet<Point2DCharge>();
+ setOfPoints.put(q, result);
+ }
+ return result;
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/geom/kinetic/SegmentCutter.java b/src/net/sourceforge/plantuml/geom/kinetic/SegmentCutter.java
new file mode 100644
index 0000000..146bafa
--- /dev/null
+++ b/src/net/sourceforge/plantuml/geom/kinetic/SegmentCutter.java
@@ -0,0 +1,68 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.geom.kinetic;
+
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+class SegmentCutter {
+
+ private final List<Point2D> intermediates = new ArrayList<Point2D>();
+
+ public SegmentCutter(Point2D start, Point2D end, double maxDistance) {
+ final double d = end.distance(start);
+ if (d <= maxDistance) {
+ intermediates.add(end);
+ return;
+ }
+ int nb = 2;
+ while (d / nb > maxDistance) {
+ nb++;
+ }
+ final double deltaX = end.getX() - start.getX();
+ final double deltaY = end.getY() - start.getY();
+ for (int i = 1; i < nb; i++) {
+ intermediates.add(new Point2D.Double(start.getX() + i * deltaX / nb, start.getY() + i * deltaY / nb));
+ }
+ intermediates.add(end);
+ }
+
+ public List<Point2D> intermediates() {
+ return Collections.unmodifiableList(intermediates);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/geom/kinetic/VectorForce.java b/src/net/sourceforge/plantuml/geom/kinetic/VectorForce.java
new file mode 100644
index 0000000..a83ebf1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/geom/kinetic/VectorForce.java
@@ -0,0 +1,101 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.geom.kinetic;
+
+import java.awt.geom.Point2D;
+
+public class VectorForce {
+
+ private final double x;
+ private final double y;
+
+ public VectorForce(double x, double y) {
+ if (Double.isNaN(x) || Double.isNaN(y) || Double.isInfinite(x) || Double.isInfinite(y)) {
+ throw new IllegalArgumentException();
+ }
+ this.x = x;
+ this.y = y;
+ }
+
+ public VectorForce(Point2D src, Point2D dest) {
+ this(dest.getX() - src.getX(), dest.getY() - src.getY());
+ }
+
+ public VectorForce plus(VectorForce other) {
+ return new VectorForce(this.x + other.x, this.y + other.y);
+ }
+
+ public VectorForce multiply(double v) {
+ return new VectorForce(x * v, y * v);
+ }
+
+ @Override
+ public String toString() {
+ return String.format("{%8.2f %8.2f}", x, y);
+ }
+
+ public VectorForce negate() {
+ return new VectorForce(-x, -y);
+ }
+
+ public double length() {
+ return Math.sqrt(x * x + y * y);
+ }
+
+ public VectorForce normaliseTo(double newLength) {
+ if (Double.isInfinite(newLength) || Double.isNaN(newLength)) {
+ throw new IllegalArgumentException();
+ }
+ final double actualLength = length();
+ if (actualLength == 0) {
+ return this;
+ }
+ final double f = newLength / actualLength;
+ return new VectorForce(x * f, y * f);
+
+ }
+
+ public final double getX() {
+ return x;
+ }
+
+ public final double getY() {
+ return y;
+ }
+
+ public double getLength() {
+ return Math.sqrt(x * x + y * y);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/geom/kinetic/World.java b/src/net/sourceforge/plantuml/geom/kinetic/World.java
new file mode 100644
index 0000000..737665f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/geom/kinetic/World.java
@@ -0,0 +1,172 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.geom.kinetic;
+
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+public class World implements MoveObserver {
+
+ private final List<Path> paths = new ArrayList<Path>();
+ private final Map<Point2DCharge, Path> pathOfPoints = new HashMap<Point2DCharge, Path>();
+ private final List<Frame> frames = new ArrayList<Frame>();
+
+ public void addFrame(Frame frame) {
+ this.frames.add(frame);
+ }
+
+ public void addPath(Path path) {
+ this.paths.add(path);
+ }
+
+ public VectorForce getElectricForce(Point2DCharge point) {
+ VectorForce result = new VectorForce(0, 0);
+
+ final Quadrant quadrant = new Quadrant(point);
+
+ for (Quadrant q : quadrant.neighbourhood()) {
+ for (Point2DCharge pc2 : quadrantMapper.getAllPoints(q)) {
+ final Path path = pathOfPoints.get(pc2);
+ if (path.containsPoint2DCharge(point)) {
+ continue;
+ }
+ result = result.plus(getElectricForce(point, pc2));
+ }
+ }
+ return result;
+ }
+
+ private VectorForce getElectricForceSlow(Point2DCharge point) {
+ VectorForce result = new VectorForce(0, 0);
+
+ for (Path path : paths) {
+ if (path.containsPoint2DCharge(point)) {
+ continue;
+ }
+ for (Point2DCharge pc2 : path.getPoints()) {
+ result = result.plus(getElectricForce(point, pc2));
+ }
+ }
+ return result;
+ }
+
+ static private VectorForce getElectricForce(Point2DCharge onThis, Point2DCharge byThis) {
+ final double dist = onThis.distance(byThis);
+ if (dist == 0) {
+ return new VectorForce(0, 0);
+ }
+ final VectorForce result = new VectorForce(byThis.getX() - onThis.getX(), byThis.getY() - onThis.getY());
+ final double v = 100.0 * onThis.getCharge() * byThis.getCharge() / dist / dist;
+ return result.normaliseTo(v);
+ }
+
+ static private VectorForce getAtomicForce(Point2DCharge onThis, Point2DCharge byThis) {
+ final double dist = onThis.distance(byThis);
+ if (dist == 0) {
+ return new VectorForce(0, 0);
+ }
+ final VectorForce result = new VectorForce(byThis.getX() - onThis.getX(), byThis.getY() - onThis.getY());
+ double v = 1000 / dist / dist / dist;
+ if (v > 5) {
+ v = 5;
+ }
+ return result.normaliseTo(v);
+ }
+
+ Map<Point2DCharge, VectorForce> getForces() {
+ final Map<Point2DCharge, VectorForce> result = new LinkedHashMap<Point2DCharge, VectorForce>();
+ for (Path path : paths) {
+ for (Point2DCharge pt : path.getPoints()) {
+ // final VectorForce elastic = new VectorForce(0, 0);
+ // final VectorForce elect = new VectorForce(0, 0);
+ final VectorForce elastic = path.getElasticForce(pt);
+ final VectorForce elect = getElectricForce(pt);
+ VectorForce force = elastic.plus(elect);
+ for (Frame f : frames) {
+ final Point2D inter = f.getFrontierPointViewBy(pt);
+ if (inter != null) {
+ final Point2DCharge pchar = new Point2DCharge(inter, 1);
+ force = force.plus(getAtomicForce(pt, pchar));
+ }
+ }
+ result.put(pt, force);
+ }
+ }
+
+ return result;
+ }
+
+ public double onePass() {
+ double result = 0;
+ final Map<Point2DCharge, VectorForce> forces = getForces();
+ for (Map.Entry<Point2DCharge, VectorForce> ent : forces.entrySet()) {
+ final VectorForce force = ent.getValue();
+ result += force.getLength();
+ ent.getKey().apply(force);
+ }
+ return result;
+ }
+
+ public final Collection<Path> getPaths() {
+ return Collections.unmodifiableCollection(paths);
+ }
+
+ private QuadrantMapper quadrantMapper;
+
+ public void renderContinue() {
+ quadrantMapper = new QuadrantMapper();
+ pathOfPoints.clear();
+ for (Path path : paths) {
+ path.renderContinue();
+ }
+ for (Path path : paths) {
+ for (Point2DCharge pt : path.getPoints()) {
+ pt.setMoveObserver(this);
+ quadrantMapper.addPoint(pt);
+ pathOfPoints.put(pt, path);
+ }
+ }
+ }
+
+ public void pointMoved(Point2DCharge point) {
+ quadrantMapper.updatePoint(point);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/golem/Magnet.java b/src/net/sourceforge/plantuml/golem/Magnet.java
new file mode 100644
index 0000000..341bbbc
--- /dev/null
+++ b/src/net/sourceforge/plantuml/golem/Magnet.java
@@ -0,0 +1,38 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.golem;
+
+public class Magnet {
+}
diff --git a/src/net/sourceforge/plantuml/golem/MinMaxDouble.java b/src/net/sourceforge/plantuml/golem/MinMaxDouble.java
new file mode 100644
index 0000000..3d7a25e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/golem/MinMaxDouble.java
@@ -0,0 +1,83 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.golem;
+
+public class MinMaxDouble {
+
+ private double minX = Double.MAX_VALUE;
+ private double minY = Double.MAX_VALUE;
+ private double maxX = -Double.MAX_VALUE;
+ private double maxY = -Double.MAX_VALUE;
+
+ public void manage(double x, double y) {
+ if (x < minX) {
+ minX = x;
+ }
+ if (y < minY) {
+ minY = y;
+ }
+ if (x > maxX) {
+ maxX = x;
+ }
+ if (y > maxY) {
+ maxY = y;
+ }
+ }
+
+ public double getMinX() {
+ return minX;
+ }
+
+ public double getMinY() {
+ return minY;
+ }
+
+ public double getMaxX() {
+ return maxX;
+ }
+
+ public double getMaxY() {
+ return maxY;
+ }
+
+ public double getWidth() {
+ return maxX - minX + 1;
+ }
+
+ public double getHeight() {
+ return maxY - minY + 1;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/golem/MinMaxGolem.java b/src/net/sourceforge/plantuml/golem/MinMaxGolem.java
new file mode 100644
index 0000000..b15358e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/golem/MinMaxGolem.java
@@ -0,0 +1,80 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.golem;
+
+public class MinMaxGolem {
+
+ private int minX = Integer.MAX_VALUE;
+ private int minY = Integer.MAX_VALUE;
+ private int maxX = Integer.MIN_VALUE;
+ private int maxY = Integer.MIN_VALUE;
+
+ public void manage(int x, int y) {
+ if (x < minX) {
+ minX = x;
+ }
+ if (y < minY) {
+ minY = y;
+ }
+ if (x > maxX) {
+ maxX = x;
+ }
+ if (y > maxY) {
+ maxY = y;
+ }
+ }
+
+ public void manage(Position position) {
+ manage(position.getXmin(), position.getYmin());
+ manage(position.getXmax(), position.getYmax());
+ }
+
+ public int getMinX() {
+ return minX;
+ }
+
+ public int getMinY() {
+ return minY;
+ }
+
+ public int getWidth() {
+ return maxX - minX + 1;
+ }
+
+ public int getHeight() {
+ return maxY - minY + 1;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/golem/Path.java b/src/net/sourceforge/plantuml/golem/Path.java
new file mode 100644
index 0000000..8d0f3f1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/golem/Path.java
@@ -0,0 +1,61 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.golem;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Path {
+
+ private final List<TileArea> all = new ArrayList<TileArea>();
+
+ public static Path build(TileArea start, TileArea dest) {
+ return new Path(start, dest);
+ }
+
+ private Path(TileArea start, TileArea dest) {
+ this.all.add(start);
+ this.all.add(dest);
+ }
+
+ public TileArea getStart() {
+ return all.get(0);
+ }
+
+ public TileArea getDest() {
+ return all.get(all.size() - 1);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/golem/Position.java b/src/net/sourceforge/plantuml/golem/Position.java
new file mode 100644
index 0000000..5992da1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/golem/Position.java
@@ -0,0 +1,114 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.golem;
+
+public class Position {
+
+ private final int xmin;
+ private final int ymin;
+ private final int xmax;
+ private final int ymax;
+
+ public Position(int xmin, int ymin, int xmax, int ymax) {
+ this.xmin = xmin;
+ this.ymin = ymin;
+ this.xmax = xmax;
+ this.ymax = ymax;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ final Position other = (Position) o;
+ return this.xmin == other.xmin && this.xmax == other.xmax && this.ymin == other.ymin && this.ymax == other.ymax;
+ }
+
+ @Override
+ public int hashCode() {
+ return xmin + ymin << 8 + xmax << 16 + ymax << 24;
+ }
+
+ @Override
+ public String toString() {
+ return "(" + xmin + "," + ymin + ")-(" + xmax + "," + ymax + ")";
+ }
+
+ public Position move(TileGeometry position, int sizeMove) {
+ if (position == null || position == TileGeometry.CENTER) {
+ throw new IllegalArgumentException();
+ }
+ switch (position) {
+ case NORTH:
+ return new Position(xmin, ymin - sizeMove, xmax, ymax - sizeMove);
+ case SOUTH:
+ return new Position(xmin, ymin + sizeMove, xmax, ymax + sizeMove);
+ case WEST:
+ return new Position(xmin - sizeMove, ymin, xmax - sizeMove, ymax);
+ case EAST:
+ return new Position(xmin + sizeMove, ymin, xmax + sizeMove, ymax);
+ default:
+ throw new IllegalStateException();
+ }
+ }
+
+ public int getXmin() {
+ return xmin;
+ }
+
+ public int getXmax() {
+ return xmax;
+ }
+
+ public int getYmin() {
+ return ymin;
+ }
+
+ public int getYmax() {
+ return ymax;
+ }
+
+ public int getCenterX() {
+ if ((xmin + xmax + 1) % 2 != 0) {
+ throw new IllegalStateException();
+ }
+ return (xmin + xmax + 1) / 2;
+ }
+
+ public int getCenterY() {
+ if ((ymin + ymax + 1) % 2 != 0) {
+ throw new IllegalStateException();
+ }
+ return (ymin + ymax + 1) / 2;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/golem/Square.java b/src/net/sourceforge/plantuml/golem/Square.java
new file mode 100644
index 0000000..20ed419
--- /dev/null
+++ b/src/net/sourceforge/plantuml/golem/Square.java
@@ -0,0 +1,38 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.golem;
+
+public class Square {
+}
diff --git a/src/net/sourceforge/plantuml/golem/Tile.java b/src/net/sourceforge/plantuml/golem/Tile.java
new file mode 100644
index 0000000..f9d5d6e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/golem/Tile.java
@@ -0,0 +1,100 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.golem;
+
+import java.awt.Font;
+import java.awt.geom.Dimension2D;
+import java.util.Collections;
+import java.util.EnumMap;
+import java.util.Map;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.SpriteContainerEmpty;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class Tile implements TextBlock {
+
+ private static double SIZE = 40;
+ private final int num;
+
+ private final UFont numberFont = new UFont("Monospaced", Font.PLAIN, 11);
+ private final FontConfiguration fc = new FontConfiguration(numberFont, HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true);
+ private final Map<TileGeometry, TileArea> geometries;
+
+ Tile(int num) {
+ this.num = num;
+ final Map<TileGeometry, TileArea> tmp = new EnumMap<TileGeometry, TileArea>(TileGeometry.class);
+ for (TileGeometry g : TileGeometry.values()) {
+ tmp.put(g, new TileArea(this, g));
+ }
+ this.geometries = Collections.unmodifiableMap(tmp);
+ }
+
+ public TileArea getArea(TileGeometry geometry) {
+ return this.geometries.get(geometry);
+ }
+
+ public void drawU(UGraphic ug) {
+ ug = ug.apply(new UChangeColor(HtmlColorUtils.BLACK));
+ final TextBlock n = TextBlockUtils.create(Display.create("" + num), fc, HorizontalAlignment.LEFT,
+ new SpriteContainerEmpty());
+ final Dimension2D dimNum = n.calculateDimension(ug.getStringBounder());
+ final Dimension2D dimTotal = calculateDimension(ug.getStringBounder());
+ final double diffx = dimTotal.getWidth() - dimNum.getWidth();
+ final double diffy = dimTotal.getHeight() - dimNum.getHeight();
+ final double radius = Math.max(dimNum.getWidth(), dimNum.getHeight());
+ final double diffx2 = dimTotal.getWidth() - radius;
+ final double diffy2 = dimTotal.getHeight() - radius;
+ n.drawU(ug.apply(new UTranslate((diffx / 2), (diffy / 2))));
+ ug.draw(new URectangle(SIZE, SIZE));
+ ug.apply(new UTranslate(diffx2 / 2, diffy2 / 2)).draw(new UEllipse(radius, radius));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(SIZE, SIZE);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/golem/TileArea.java b/src/net/sourceforge/plantuml/golem/TileArea.java
new file mode 100644
index 0000000..7a6f74f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/golem/TileArea.java
@@ -0,0 +1,54 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.golem;
+
+public class TileArea {
+
+ private final Tile tile;
+ private final TileGeometry position;
+
+ TileArea(Tile tile, TileGeometry position) {
+ this.tile = tile;
+ this.position = position;
+ }
+
+ public Tile getTile() {
+ return tile;
+ }
+
+ public TileGeometry getGeometry() {
+ return position;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/golem/TileGeometry.java b/src/net/sourceforge/plantuml/golem/TileGeometry.java
new file mode 100644
index 0000000..91740e0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/golem/TileGeometry.java
@@ -0,0 +1,74 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.golem;
+
+import net.sourceforge.plantuml.StringUtils;
+
+public enum TileGeometry {
+ NORTH, SOUTH, EAST, WEST, CENTER;
+
+ public TileGeometry opposite() {
+ switch (this) {
+ case NORTH:
+ return SOUTH;
+ case SOUTH:
+ return NORTH;
+ case EAST:
+ return WEST;
+ case WEST:
+ return EAST;
+ case CENTER:
+ default:
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ public static TileGeometry fromString(String s) {
+ final char c = StringUtils.goUpperCase(s.charAt(0));
+ switch (c) {
+ case 'N':
+ return NORTH;
+ case 'S':
+ return SOUTH;
+ case 'E':
+ return EAST;
+ case 'W':
+ return WEST;
+ default:
+ throw new IllegalArgumentException();
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/golem/TilesField.java b/src/net/sourceforge/plantuml/golem/TilesField.java
new file mode 100644
index 0000000..fdea78e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/golem/TilesField.java
@@ -0,0 +1,302 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.golem;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class TilesField implements TextBlock {
+
+ private int size = 1;
+ private final Tile root = new Tile(0);
+ private final Map<Tile, Position> positions = new HashMap<Tile, Position>();
+ private final List<Path> paths = new ArrayList<Path>();
+
+ public TilesField() {
+ positions.put(root, new Position(0, 0, 1, 1));
+ }
+
+ public Tile getRoot() {
+ return root;
+ }
+
+ public Tile createTile(Tile start, TileGeometry position) {
+ final Tile result = new Tile(size++);
+ final Position p = getFreePosition(start, position);
+ positions.put(result, p);
+ paths.add(buildPath(start.getArea(position), result.getArea(position.opposite())));
+ return result;
+ }
+
+ public void addPath(Tile start, Tile dest, TileGeometry startDirection) {
+ paths.add(buildPath(start.getArea(startDirection), dest.getArea(startDirection.opposite())));
+ }
+
+ private Path buildPath(TileArea tileArea1, TileArea tileArea2) {
+ if (isAdjoining(tileArea1, tileArea2)) {
+ return Path.build(tileArea1, tileArea2);
+ }
+ final Tile tile1 = tileArea1.getTile();
+ final Tile tile2 = tileArea2.getTile();
+ final Position pos1 = getPosition(tile1);
+ final Position pos2 = getPosition(tile2);
+ final TileGeometry geom1 = tileArea1.getGeometry();
+ final TileGeometry geom2 = tileArea2.getGeometry();
+ if (pos1.getYmin() == pos2.getYmin() && pos1.getYmax() == pos2.getYmax() && geom1 == TileGeometry.WEST
+ && geom2 == TileGeometry.EAST) {
+ return Path.build(tileArea1, tileArea2);
+
+ }
+ throw new IllegalArgumentException();
+ }
+
+ private boolean isAdjoining(TileArea tileArea1, TileArea tileArea2) {
+ final Tile tile1 = tileArea1.getTile();
+ final Tile tile2 = tileArea2.getTile();
+ final Position pos1 = getPosition(tile1);
+ final Position pos2 = getPosition(tile2);
+ final TileGeometry geom1 = tileArea1.getGeometry();
+ final TileGeometry geom2 = tileArea2.getGeometry();
+ if (pos1.equals(pos2)) {
+ assert tile1 == tile2;
+ if (geom1 == geom2) {
+ throw new IllegalArgumentException();
+ }
+ return true;
+ }
+ if (geom1.equals(geom2.opposite()) == false) {
+ return false;
+ }
+ switch (geom1) {
+ case EAST:
+ return pos1.getYmin() == pos2.getYmin() && pos1.getYmax() == pos2.getYmax()
+ && pos1.getXmax() + 1 == pos2.getXmin();
+ case WEST:
+ return pos1.getYmin() == pos2.getYmin() && pos1.getYmax() == pos2.getYmax()
+ && pos1.getXmin() == pos2.getXmax() + 1;
+ case SOUTH:
+ return pos1.getXmin() == pos2.getXmin() && pos1.getXmax() == pos2.getXmax()
+ && pos1.getYmax() + 1 == pos2.getYmin();
+ case NORTH:
+ return pos1.getXmin() == pos2.getXmin() && pos1.getXmax() == pos2.getXmax()
+ && pos1.getYmin() == pos2.getYmax() + 1;
+ case CENTER:
+ return false;
+
+ default:
+ throw new IllegalStateException();
+ }
+
+ }
+
+ private Tile getTileAt(Position p) {
+ for (Map.Entry<Tile, Position> ent : positions.entrySet()) {
+ if (p.equals(ent.getValue())) {
+ return ent.getKey();
+ }
+ }
+ return null;
+ }
+
+ private Position getFreePosition(Tile start, TileGeometry position) {
+ final Position p = getPosition(start).move(position, 2);
+ while (isOccuped(p)) {
+ // p = p.move(TileGeometry.EAST, 2);
+ moveAllToEast(p);
+ }
+ return p;
+ }
+
+ private void moveAllToEast(Position startingPosition) {
+ final List<Position> toMove = new ArrayList<Position>();
+ for (Position p : positions.values()) {
+ if (p.getXmax() < startingPosition.getXmin()) {
+ continue;
+ }
+ if (p.getYmax() < startingPosition.getYmin()) {
+ continue;
+ }
+ toMove.add(p);
+ }
+ for (Position p : toMove) {
+ positions.put(getTileAt(p), p.move(TileGeometry.EAST, 2));
+ }
+
+ }
+
+ private boolean isOccuped(Position test) {
+ for (Position p : positions.values()) {
+ if (p.equals(test)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public Position getPosition(Tile tile) {
+ final Position result = positions.get(tile);
+ if (result == null) {
+ throw new IllegalArgumentException();
+ }
+ return result;
+ }
+
+ private int getXmin() {
+ int result = Integer.MAX_VALUE;
+ for (Position p : positions.values()) {
+ final int v = p.getXmin();
+ if (v < result) {
+ result = v;
+ }
+ }
+ return result;
+ }
+
+ private int getYmin() {
+ int result = Integer.MAX_VALUE;
+ for (Position p : positions.values()) {
+ final int v = p.getYmin();
+ if (v < result) {
+ result = v;
+ }
+ }
+ return result;
+ }
+
+ private int getXmax() {
+ int result = Integer.MIN_VALUE;
+ for (Position p : positions.values()) {
+ final int v = p.getXmax();
+ if (v > result) {
+ result = v;
+ }
+ }
+ return result;
+ }
+
+ private int getYmax() {
+ int result = Integer.MIN_VALUE;
+ for (Position p : positions.values()) {
+ final int v = p.getYmax();
+ if (v > result) {
+ result = v;
+ }
+ }
+ return result;
+ }
+
+ public List<Path> getPaths() {
+ return Collections.unmodifiableList(paths);
+ }
+
+ // -----------
+ public void drawU(UGraphic ug) {
+ double x = 0;
+ double y = 0;
+ final int xmin = getXmin();
+ final int ymin = getYmin();
+ final Dimension2D dimSingle = root.calculateDimension(ug.getStringBounder());
+ x -= xmin * dimSingle.getWidth() / 2;
+ y -= ymin * dimSingle.getHeight() / 2;
+ for (Map.Entry<Tile, Position> ent : positions.entrySet()) {
+ final Position p = ent.getValue();
+ final Tile t = ent.getKey();
+ final double xt = p.getXmin() * dimSingle.getWidth() / 2;
+ final double yt = p.getYmin() * dimSingle.getHeight() / 2;
+ t.drawU(ug.apply(new UTranslate((x + xt), (y + yt))));
+ }
+ ug = ug.apply(new UChangeColor(HtmlColorUtils.RED));
+ for (Path p : paths) {
+ final TileArea start = p.getStart();
+ final TileArea dest = p.getDest();
+ final Point2D pstart = getPoint2D(dimSingle, start);
+ final Point2D pdest = getPoint2D(dimSingle, dest);
+ ug.apply(new UTranslate(x + pstart.getX(), y + pstart.getY())).draw(new ULine(pdest.getX() - pstart.getX(), pdest.getY()
+ - pstart.getY()));
+ }
+ }
+
+ private Point2D getPoint2D(Dimension2D dimSingle, TileArea area) {
+ final Position p = getPosition(area.getTile());
+ double xt = p.getXmin() * dimSingle.getWidth() / 2;
+ double yt = p.getYmin() * dimSingle.getHeight() / 2;
+ xt += dimSingle.getWidth() / 2;
+ yt += dimSingle.getHeight() / 2;
+ final double coef = 0.33;
+ switch (area.getGeometry()) {
+ case NORTH:
+ yt -= dimSingle.getHeight() * coef;
+ break;
+ case SOUTH:
+ yt += dimSingle.getHeight() * coef;
+ break;
+ case EAST:
+ xt += dimSingle.getWidth() * coef;
+ break;
+ case WEST:
+ xt -= dimSingle.getWidth() * coef;
+ break;
+ default:
+ throw new IllegalStateException();
+ }
+ return new Point2D.Double(xt, yt);
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final int xmin = getXmin();
+ final int xmax = getXmax();
+ final int ymin = getYmin();
+ final int ymax = getYmax();
+ final int width = (xmax - xmin) / 2 + 1;
+ final int height = (ymax - ymin) / 2 + 1;
+ final Dimension2D dimSingle = root.calculateDimension(stringBounder);
+ return new Dimension2DDouble(width * dimSingle.getWidth(), height * dimSingle.getHeight());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graph/ALink.java b/src/net/sourceforge/plantuml/graph/ALink.java
new file mode 100644
index 0000000..08b6582
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph/ALink.java
@@ -0,0 +1,47 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph;
+
+public interface ALink {
+
+ int getDiffHeight();
+
+ ANode getNode1();
+
+ ANode getNode2();
+
+ public Object getUserData();
+
+}
diff --git a/src/net/sourceforge/plantuml/graph/ALinkImpl.java b/src/net/sourceforge/plantuml/graph/ALinkImpl.java
new file mode 100644
index 0000000..1fd4059
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph/ALinkImpl.java
@@ -0,0 +1,72 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph;
+
+public class ALinkImpl implements ALink {
+
+ private final ANode node1;
+ private final ANode node2;
+ private final Object userData;
+ private final int diffHeight;
+
+ @Override
+ public String toString() {
+ return "" + node1 + " -> " + node2;
+ }
+
+ public ALinkImpl(ANode n1, ANode n2, int diffHeight, Object userData) {
+ this.node1 = n1;
+ this.node2 = n2;
+ this.userData = userData;
+ this.diffHeight = diffHeight;
+ }
+
+ public int getDiffHeight() {
+ return diffHeight;
+ }
+
+ public ANode getNode1() {
+ return node1;
+ }
+
+ public ANode getNode2() {
+ return node2;
+ }
+
+ public final Object getUserData() {
+ return userData;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graph/ANode.java b/src/net/sourceforge/plantuml/graph/ANode.java
new file mode 100644
index 0000000..596f34f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph/ANode.java
@@ -0,0 +1,47 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph;
+
+public interface ANode {
+
+ void setRow(int row);
+
+ int getRow();
+
+ String getCode();
+
+ public Object getUserData();
+
+}
diff --git a/src/net/sourceforge/plantuml/graph/ANodeImpl.java b/src/net/sourceforge/plantuml/graph/ANodeImpl.java
new file mode 100644
index 0000000..27302bb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph/ANodeImpl.java
@@ -0,0 +1,77 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph;
+
+public class ANodeImpl implements ANode {
+
+ private int row = Integer.MIN_VALUE;
+ private final String code;
+ private Object userData;
+
+ public ANodeImpl(String code) {
+ this.code = code;
+ }
+
+ @Override
+ public int hashCode() {
+ return code.hashCode();
+ }
+
+ public int getRow() {
+ return row;
+ }
+
+ public void setRow(int row) {
+ this.row = row;
+ }
+
+ public final String getCode() {
+ return code;
+ }
+
+ @Override
+ public String toString() {
+ return code + " " + getRow();
+ }
+
+ public Object getUserData() {
+ return userData;
+ }
+
+ public void setUserData(Object userData) {
+ this.userData = userData;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graph/AbstractEntityImage.java b/src/net/sourceforge/plantuml/graph/AbstractEntityImage.java
new file mode 100644
index 0000000..26b7b57
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph/AbstractEntityImage.java
@@ -0,0 +1,115 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph;
+
+import java.awt.Font;
+import java.awt.Graphics2D;
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorSet;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+abstract class AbstractEntityImage {
+
+ private final IEntity entity;
+
+ final private HtmlColor red = HtmlColorUtils.MY_RED;
+
+ final private HtmlColor yellow = HtmlColorUtils.MY_YELLOW;
+ private final HtmlColor yellowNote = HtmlColorUtils.COL_FBFB77;
+
+ final private UFont font14 = new UFont("SansSerif", Font.PLAIN, 14);
+ final private UFont font17 = new UFont("Courier", Font.BOLD, 17);
+ final private HtmlColor green = HtmlColorUtils.COL_ADD1B2;
+ final private HtmlColor violet = HtmlColorUtils.COL_B4A7E5;
+ final private HtmlColor blue = HtmlColorUtils.COL_A9DCDF;
+ final private HtmlColor rose = HtmlColorUtils.COL_EB937F;
+
+ public AbstractEntityImage(IEntity entity) {
+ if (entity == null) {
+ throw new IllegalArgumentException("entity null");
+ }
+ this.entity = entity;
+ }
+
+ public abstract Dimension2D getDimension(StringBounder stringBounder);
+
+ public abstract void draw(ColorMapper colorMapper, Graphics2D g2d);
+
+ protected final IEntity getEntity() {
+ return entity;
+ }
+
+ protected final HtmlColor getRed() {
+ return red;
+ }
+
+ protected final HtmlColor getYellow() {
+ return yellow;
+ }
+
+ protected final UFont getFont17() {
+ return font17;
+ }
+
+ protected final UFont getFont14() {
+ return font14;
+ }
+
+ protected final HtmlColor getGreen() {
+ return green;
+ }
+
+ protected final HtmlColor getViolet() {
+ return violet;
+ }
+
+ protected final HtmlColor getBlue() {
+ return blue;
+ }
+
+ protected final HtmlColor getRose() {
+ return rose;
+ }
+
+ protected final HtmlColor getYellowNote() {
+ return yellowNote;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graph/Board.java b/src/net/sourceforge/plantuml/graph/Board.java
new file mode 100644
index 0000000..e6bf7df
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph/Board.java
@@ -0,0 +1,266 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class Board {
+
+ private final List<ALink> links;
+ private final Map<ALink, Integer> initialDirection;
+
+ private final Map<ANode, Integer> nodesCols = new LinkedHashMap<ANode, Integer>();
+
+ private int hashcodeValue;
+ private boolean hashcodeComputed = false;
+
+ private Board(Board old) {
+ this.links = old.links;
+ this.initialDirection = old.initialDirection;
+ this.nodesCols.putAll(old.nodesCols);
+ }
+
+ public Comparator<ALink> getLinkComparator() {
+ return new LenghtLinkComparator(nodesCols);
+ }
+
+ public boolean equals(Object o) {
+ final Board other = (Board) o;
+ if (this.links != other.links) {
+ return false;
+ }
+ final Iterator<Integer> it1 = this.nodesCols.values().iterator();
+ final Iterator<Integer> it2 = other.nodesCols.values().iterator();
+ assert this.nodesCols.size() == other.nodesCols.size();
+ while (it1.hasNext()) {
+ if (it1.next().equals(it2.next()) == false) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ if (this.hashcodeComputed) {
+ return this.hashcodeValue;
+ }
+ this.hashcodeValue = 13;
+ for (Integer i : nodesCols.values()) {
+ this.hashcodeValue = this.hashcodeValue * 17 + i;
+ }
+ this.hashcodeComputed = true;
+ return this.hashcodeValue;
+ }
+
+ public void normalize() {
+ int minRow = Integer.MAX_VALUE;
+ int minCol = Integer.MAX_VALUE;
+ int maxRow = Integer.MIN_VALUE;
+ int maxCol = Integer.MIN_VALUE;
+ for (Map.Entry<ANode, Integer> ent : nodesCols.entrySet()) {
+ minRow = Math.min(minRow, ent.getKey().getRow());
+ maxRow = Math.max(maxRow, ent.getKey().getRow());
+ minCol = Math.min(minCol, ent.getValue());
+ maxCol = Math.max(maxCol, ent.getValue());
+ }
+ for (Map.Entry<ANode, Integer> ent : nodesCols.entrySet()) {
+ if (minRow != 0) {
+ ent.getKey().setRow(ent.getKey().getRow() - minRow);
+ }
+ if (minCol != 0) {
+ ent.setValue(ent.getValue() - minCol);
+ }
+ }
+ }
+
+ private void normalizeCol() {
+ final int minCol = Collections.min(nodesCols.values());
+
+ if (minCol != 0) {
+ for (Map.Entry<ANode, Integer> ent : nodesCols.entrySet()) {
+ ent.setValue(ent.getValue() - minCol);
+ }
+ }
+ }
+
+ void internalMove(String code, int newCol) {
+ hashcodeComputed = false;
+ for (ANode n : nodesCols.keySet()) {
+ if (n.getCode().equals(code)) {
+ nodesCols.put(n, newCol);
+ return;
+ }
+ }
+ }
+
+ public Board copy() {
+ return new Board(this);
+ }
+
+ public Board(List<ANode> nodes, List<ALink> links) {
+ for (ANode n : nodes) {
+ addInRow(n);
+ }
+ this.links = Collections.unmodifiableList(new ArrayList<ALink>(links));
+ this.initialDirection = new HashMap<ALink, Integer>();
+ for (ALink link : links) {
+ this.initialDirection.put(link, getDirection(link));
+ }
+ }
+
+ public int getInitialDirection(ALink link) {
+ return initialDirection.get(link);
+ }
+
+ public int getDirection(ALink link) {
+ return getCol(link.getNode2()) - getCol(link.getNode1());
+ }
+
+ private void addInRow(ANode n) {
+ hashcodeComputed = false;
+ int col = 0;
+ while (true) {
+ if (getNodeAt(n.getRow(), col) == null) {
+ nodesCols.put(n, col);
+ assert getNodeAt(n.getRow(), col) == n;
+ return;
+ }
+ col++;
+ }
+ }
+
+ public Collection<ANode> getNodes() {
+ return Collections.unmodifiableCollection(nodesCols.keySet());
+ }
+
+ public Collection<ANode> getNodesInRow(int row) {
+ final List<ANode> result = new ArrayList<ANode>();
+ for (ANode n : nodesCols.keySet()) {
+ if (n.getRow() == row) {
+ result.add(n);
+ }
+ }
+ return Collections.unmodifiableCollection(result);
+ }
+
+ public final List<? extends ALink> getLinks() {
+ return Collections.unmodifiableList(links);
+ }
+
+ public int getCol(ANode n) {
+ return nodesCols.get(n);
+ }
+
+ public void applyMove(Move move) {
+ final ANode piece = getNodeAt(move.getRow(), move.getCol());
+ if (piece == null) {
+ throw new IllegalArgumentException();
+ }
+ final ANode piece2 = getNodeAt(move.getRow(), move.getNewCol());
+ nodesCols.put(piece, move.getNewCol());
+ if (piece2 != null) {
+ nodesCols.put(piece2, move.getCol());
+ }
+ normalizeCol();
+ hashcodeComputed = false;
+ }
+
+ public Collection<Move> getAllPossibleMoves() {
+ final List<Move> result = new ArrayList<Move>();
+ for (Map.Entry<ANode, Integer> ent : nodesCols.entrySet()) {
+ final int row = ent.getKey().getRow();
+ final int col = ent.getValue();
+ result.add(new Move(row, col, -1));
+ result.add(new Move(row, col, 1));
+ }
+ return result;
+ }
+
+ public ANode getNodeAt(int row, int col) {
+ for (Map.Entry<ANode, Integer> ent : nodesCols.entrySet()) {
+ if (ent.getKey().getRow() == row && ent.getValue().intValue() == col) {
+ return ent.getKey();
+ }
+ }
+ return null;
+ }
+
+ public Set<ANode> getConnectedNodes(ANode root, int level) {
+ if (level < 0) {
+ throw new IllegalArgumentException();
+ }
+ if (level == 0) {
+ return Collections.singleton(root);
+ }
+ final Set<ANode> result = new HashSet<ANode>();
+ if (level == 1) {
+ for (ALink link : links) {
+ if (link.getNode1() == root) {
+ result.add(link.getNode2());
+ } else if (link.getNode2() == root) {
+ result.add(link.getNode1());
+ }
+
+ }
+ } else {
+ for (ANode n : getConnectedNodes(root, level - 1)) {
+ result.addAll(getConnectedNodes(n, 1));
+ }
+ }
+ return Collections.unmodifiableSet(result);
+ }
+
+ public Set<ALink> getAllLinks(Set<ANode> nodes) {
+ final Set<ALink> result = new HashSet<ALink>();
+ for (ALink link : links) {
+ if (nodes.contains(link.getNode1()) || nodes.contains(link.getNode2())) {
+ result.add(link);
+ }
+ }
+ return Collections.unmodifiableSet(result);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graph/BoardCollection.java b/src/net/sourceforge/plantuml/graph/BoardCollection.java
new file mode 100644
index 0000000..def8ebc
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph/BoardCollection.java
@@ -0,0 +1,127 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class BoardCollection {
+
+ static class Entry implements Comparable<Entry> {
+ final private Board board;
+ final private double cost;
+ private boolean explored;
+
+ public Entry(Board b, CostComputer costComputer) {
+ this.board = b;
+ if (costComputer == null) {
+ this.cost = 0;
+ } else {
+ this.cost = costComputer.getCost(b);
+ }
+ }
+
+ public int compareTo(Entry other) {
+ return (int) Math.signum(this.cost - other.cost);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ final Entry other = (Entry) obj;
+ return board.equals(other.board);
+ }
+
+ @Override
+ public int hashCode() {
+ return board.hashCode();
+ }
+
+ }
+
+ private final SortedCollection<Entry> all = new SortedCollectionArrayList<Entry>();
+
+ private final CostComputer costComputer;
+
+ public BoardCollection(CostComputer costComputer) {
+ this.costComputer = costComputer;
+ }
+
+ public int size() {
+ return all.size();
+ }
+
+ public Board getAndSetExploredSmallest() {
+ for (Entry ent : all) {
+ if (ent.explored == false) {
+ ent.explored = true;
+ assert costComputer.getCost(ent.board) == ent.cost;
+ // Log.println("Peeking " + ent.cost);
+ return ent.board;
+ }
+ }
+ return null;
+ }
+
+ public double getBestCost() {
+ for (Entry ent : all) {
+ return ent.cost;
+ }
+ return 0;
+ }
+
+ public Board getBestBoard() {
+ for (Entry ent : all) {
+ return ent.board;
+ }
+ return null;
+ }
+
+ public List<Double> getCosts() {
+ final List<Double> result = new ArrayList<Double>();
+ for (Entry ent : all) {
+ result.add(costComputer.getCost(ent.board));
+ }
+ return result;
+ }
+
+ public void add(Board b) {
+ all.add(new Entry(b, costComputer));
+ }
+
+ public boolean contains(Board b) {
+ return all.contains(new Entry(b, null));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graph/BoardExplorer.java b/src/net/sourceforge/plantuml/graph/BoardExplorer.java
new file mode 100644
index 0000000..17c855d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph/BoardExplorer.java
@@ -0,0 +1,85 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class BoardExplorer {
+
+ private final BoardCollection all = new BoardCollection(new KenavoCostComputer());
+
+ public BoardExplorer(Board init) {
+ all.add(init);
+ }
+
+ public double getBestCost() {
+ return all.getBestCost();
+ }
+
+ public Board getBestBoard() {
+ return all.getBestBoard();
+ }
+
+ public int collectionSize() {
+ return all.size();
+ }
+
+ public boolean onePass() {
+ final Board smallest = all.getAndSetExploredSmallest();
+ if (smallest == null) {
+ return true;
+ }
+ final Set<Board> moves = nextBoards(smallest);
+ for (Board newBoard : moves) {
+ if (all.contains(newBoard)) {
+ continue;
+ }
+ all.add(newBoard);
+ }
+ return false;
+ }
+
+ public Set<Board> nextBoards(Board board) {
+ final Set<Board> result = new HashSet<Board>();
+ for (Move m : board.getAllPossibleMoves()) {
+ final Board copy = board.copy();
+ copy.applyMove(m);
+ result.add(copy);
+ }
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graph/CostComputer.java b/src/net/sourceforge/plantuml/graph/CostComputer.java
new file mode 100644
index 0000000..d5de41b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph/CostComputer.java
@@ -0,0 +1,41 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph;
+
+public interface CostComputer {
+
+ double getCost(Board board);
+
+}
diff --git a/src/net/sourceforge/plantuml/graph/Elastane.java b/src/net/sourceforge/plantuml/graph/Elastane.java
new file mode 100644
index 0000000..95acc2b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph/Elastane.java
@@ -0,0 +1,373 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.Shape;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Dimension2D;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.Log;
+import net.sourceforge.plantuml.SpriteContainerEmpty;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.geom.Box;
+import net.sourceforge.plantuml.geom.CollectionUtils;
+import net.sourceforge.plantuml.geom.Point2DInt;
+import net.sourceforge.plantuml.geom.PolylineBreakeable;
+import net.sourceforge.plantuml.geom.XMoveable;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounderUtils;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public class Elastane {
+
+ private static final int STEP = 4;
+ private static final int OUTER_BOX = 20;
+
+ final private Color red = new Color(Integer.parseInt("A80036", 16));
+
+ private final Galaxy4 galaxy;
+
+ private final double margin = 30;
+
+ private int minX = Integer.MAX_VALUE;
+ private int maxX = Integer.MIN_VALUE;
+ private int minY = Integer.MAX_VALUE;
+ private int maxY = Integer.MIN_VALUE;
+
+ Elastane(Galaxy4 galaxy) {
+ this.galaxy = galaxy;
+ }
+
+ private final Map<ANode, Box> boxes = new LinkedHashMap<ANode, Box>();
+ private final Map<ALink, PolylineBreakeable> lines = new LinkedHashMap<ALink, PolylineBreakeable>();
+
+ public void addBox(ANode node, int w, int h) {
+ final int row = node.getRow();
+ final int col = galaxy.getBoard().getCol(node);
+ final Point2DInt pos = galaxy.getMainPoint(row, col);
+ final Box box = new Box(pos.getXint() - w / 2, pos.getYint() - h / 2, w, h);
+ boxes.put(node, box);
+ assert boxOverlap() == false;
+ }
+
+ private double getCost() {
+ if (boxOverlap()) {
+ return Double.MAX_VALUE;
+ }
+ double result = 0;
+ for (ALink alink : galaxy.getLines().keySet()) {
+ final PolylineBreakeable orig = lines.get(alink);
+ final PolylineBreakeable p = orig;
+ result += getLength(p);
+ final Box b1 = boxes.get(alink.getNode1());
+ final Box b2 = boxes.get(alink.getNode2());
+ result += getCostBoxIntersect(p, b1, b2);
+
+ for (ALink alink2 : galaxy.getLines().keySet()) {
+ if (alink == alink2) {
+ continue;
+ }
+ final PolylineBreakeable other = lines.get(alink2);
+ if (p.doesTouch(other)) {
+ result += getLength(other);
+ // return Double.MAX_VALUE;
+ }
+ // result += p.getDistance(other);
+ }
+ }
+
+ return result;
+ }
+
+ private double getLength(final PolylineBreakeable mutedPolyline) {
+ final double len = mutedPolyline.getLength();
+ assert len > 0;
+ return Math.log(1 + len);
+ }
+
+ private double getCostBoxIntersect(PolylineBreakeable polyline, Box b1, Box b2) {
+ double result = 0;
+ for (Box b : boxes.values()) {
+ if (b == b1 || b == b2) {
+ continue;
+ }
+ if (polyline.intersectBox(b)) {
+ final double dist = polyline.getDistance(b);
+ assert dist >= 0;
+ assert dist != Double.MAX_VALUE;
+ // Log.println("dist=" + dist + " exp=" + (100000 -
+ // dist));
+ result += 100000 - dist;
+ }
+
+ }
+ return result;
+ }
+
+ private void initLines() {
+ for (ALink alink : galaxy.getLines().keySet()) {
+ final PolylineBreakeable p = galaxy.getPolyline(alink);
+ final Box b1 = boxes.get(alink.getNode1());
+ final Box b2 = boxes.get(alink.getNode2());
+ lines.put(alink, p.copy(b1, b2));
+ }
+
+ }
+
+ private boolean boxOverlap() {
+ final List<Box> all = new ArrayList<Box>();
+ for (Box b : boxes.values()) {
+ all.add(b.outerBox(OUTER_BOX));
+ }
+ for (int i = 0; i < all.size() - 1; i++) {
+ for (int j = i + 1; j < all.size(); j++) {
+ if (all.get(i).intersectBox(all.get(j))) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private void moveX(Collection<XMoveable> boxes, int delta, double initCost, boolean trace) {
+ for (XMoveable b : boxes) {
+ b.moveX(delta);
+ }
+ // if (trace) {
+ // final double diff = getCost() - initCost;
+ // Log.println("moving " + boxes + " " + delta + " diff=" +
+ // diff);
+ // }
+ // for (Map.Entry<ALink, Polyline> entry : lines.entrySet()) {
+ // if (isConcerned(entry.getKey(), boxes)) {
+ // entry.getValue().moveX(delta);
+ // }
+ //
+ // }
+ }
+
+ private boolean isConcerned(ALink link, Collection<XMoveable> moved) {
+ final Box b1 = boxes.get(link.getNode1());
+ final Box b2 = boxes.get(link.getNode2());
+ return moved.contains(b1) && moved.contains(b2);
+ }
+
+ private boolean onePass(Collection<? extends Collection<XMoveable>> subLists) {
+ boolean changed = false;
+ for (Collection<XMoveable> toMove : subLists) {
+ final double initCost = getCost();
+
+ assert reversable(initCost, toMove);
+
+ moveX(toMove, STEP, initCost, true);
+ if (getCost() < initCost) {
+ changed = true;
+ } else {
+ moveX(toMove, -STEP, initCost, false);
+ moveX(toMove, -STEP, initCost, true);
+ if (getCost() < initCost) {
+ changed = true;
+ } else {
+ moveX(toMove, STEP, initCost, false);
+ assert getCost() == initCost : "c1=" + getCost() + " init=" + initCost;
+ }
+ }
+ assert getCost() <= initCost;
+
+ }
+ // Log.println("COSTB=" + getCost());
+ return changed;
+ }
+
+ private boolean reversable(double initCost, Collection<XMoveable> toMove) {
+ moveX(toMove, STEP, 0, false);
+ moveX(toMove, -STEP, 0, false);
+ assert getCost() == initCost;
+ moveX(toMove, STEP, 0, false);
+ moveX(toMove, -STEP * 2, 0, false);
+ moveX(toMove, STEP, 0, false);
+ assert getCost() == initCost;
+ return true;
+ }
+
+ private Collection<XMoveable> convertANodeSet(Set<ANode> nodesSet, Map<ALink, Collection<XMoveable>> linkMoveables) {
+ final Collection<XMoveable> result = new HashSet<XMoveable>();
+ for (ANode n : nodesSet) {
+ assert boxes.get(n) != null;
+ result.add(boxes.get(n));
+ }
+ // for (ALink link : galaxy.getBoard().getAllLinks(nodesSet)) {
+ // result.addAll(linkMoveables.get(link));
+ //
+ // }
+ return result;
+ }
+
+ public void draw(final Graphics2D g2d) {
+ final AffineTransform at = g2d.getTransform();
+ g2d.translate(-minX + margin, -minY + margin);
+
+ g2d.setColor(red);
+ for (Map.Entry<ALink, PolylineBreakeable> ent : lines.entrySet()) {
+ final ALink alink = ent.getKey();
+ final Link l = (Link) alink.getUserData();
+ final GeneralPathFactory factory = new GeneralPathFactory(l.getType());
+ final Box b1 = boxes.get(alink.getNode1());
+ final Box b2 = boxes.get(alink.getNode2());
+ final PolylineBreakeable polyline = ent.getValue();
+ final Shape shape = factory.getLink(polyline, b1, b2);
+
+ final String label = l.getLabel().get(0).toString();
+ if (label != null) {
+ // polyline.getFirst().getCenter();
+ final TextBlock textBlock = TextBlockUtils.create(Display.create(label),
+ new FontConfiguration(UFont.getCurrentFont(g2d), HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true),
+ HorizontalAlignment.LEFT, new SpriteContainerEmpty());
+ textBlock.calculateDimension(StringBounderUtils.asStringBounder(g2d));
+ // textBlock.drawTOBEREMOVED(new ColorMapperIdentity(), g2d, center.getXint() - dim.getWidth() / 2,
+ // center.getYint() - dim.getHeight() / 2);
+ }
+
+ g2d.setColor(red);
+ g2d.draw(shape);
+ }
+
+ g2d.setColor(Color.BLACK);
+ for (Map.Entry<ANode, Box> ent : boxes.entrySet()) {
+ final ANode node = ent.getKey();
+ final AbstractEntityImage image = images(node.getRow(), galaxy.getBoard().getCol(node));
+ assert image != null;
+ final Box box = ent.getValue();
+ g2d.translate(box.getX(), box.getY());
+ image.draw(new ColorMapperIdentity(), g2d);
+ g2d.translate(-box.getX(), -box.getY());
+ }
+ g2d.setTransform(at);
+ }
+
+ public void init() {
+ initLines();
+ final Set<Set<ANode>> nodesGroups = new HashSet<Set<ANode>>();
+ final Collection<ANode> nodes = galaxy.getBoard().getNodes();
+ for (ANode root : nodes) {
+ for (int i = 0; i < galaxy.getBoard().getLinks().size(); i++) {
+ final Set<ANode> group = galaxy.getBoard().getConnectedNodes(root, i);
+ if (group.size() < nodes.size()) {
+ nodesGroups.add(group);
+ }
+ }
+ }
+ final Collection<Collection<XMoveable>> xmoveableGroups = new ArrayList<Collection<XMoveable>>();
+ final Map<ALink, Collection<XMoveable>> linkMoveables = new HashMap<ALink, Collection<XMoveable>>();
+
+ for (Map.Entry<ALink, PolylineBreakeable> entry : lines.entrySet()) {
+ final PolylineBreakeable p = entry.getValue();
+ final List<XMoveable> freedoms = p.getFreedoms();
+ // Log.println("freedoms=" + freedoms);
+ if (freedoms.size() > 0) {
+ linkMoveables.put(entry.getKey(), freedoms);
+ // xmoveableGroups.addAll(CollectionUtils.selectUpTo(freedoms,
+ // freedoms.size()));
+ xmoveableGroups.addAll(CollectionUtils.selectUpTo(freedoms, 1));
+ }
+ }
+
+ for (Set<ANode> nodesSet : nodesGroups) {
+ xmoveableGroups.add(convertANodeSet(nodesSet, linkMoveables));
+ }
+
+ assert getCost() != Double.MAX_VALUE;
+ for (int i = 0; i < 3000; i++) {
+ final boolean changed = onePass(xmoveableGroups);
+ if (changed == false) {
+ break;
+ }
+ }
+
+ for (Box box : boxes.values()) {
+ minX = Math.min(minX, box.getMinX());
+ maxX = Math.max(maxX, box.getMaxX());
+ minY = Math.min(minY, box.getMinY());
+ maxY = Math.max(maxY, box.getMaxY());
+ }
+
+ for (PolylineBreakeable polyline : lines.values()) {
+ minX = Math.min(minX, polyline.getMinX());
+ maxX = Math.max(maxX, polyline.getMaxX());
+ minY = Math.min(minY, polyline.getMinY());
+ maxY = Math.max(maxY, polyline.getMaxY());
+ }
+
+ }
+
+ private AbstractEntityImage images(int r, int c) {
+ final ANode n = galaxy.getBoard().getNodeAt(r, c);
+ if (n == null) {
+ return null;
+ }
+ return new EntityImageFactory().createEntityImage((IEntity) n.getUserData());
+ }
+
+ public Dimension2D getDimension() {
+ final Dimension2DDouble dim = new Dimension2DDouble(maxX - minX + 2 * margin, maxY - minY + 2 * margin);
+ Log.info("Dim=" + dim);
+ return dim;
+ }
+
+ // private Point2DInt transform(Point2DInt src) {
+ // return new Point2DInt(xMargin + widthCell / 2 + src.getXint() *
+ // (widthCell + xMargin), yMargin + heightCell / 2
+ // + src.getYint() * (heightCell + yMargin));
+ // }
+
+}
diff --git a/src/net/sourceforge/plantuml/graph/ElectricCharge.java b/src/net/sourceforge/plantuml/graph/ElectricCharge.java
new file mode 100644
index 0000000..2f113ed
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph/ElectricCharge.java
@@ -0,0 +1,69 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph;
+
+import java.awt.geom.Point2D;
+
+public class ElectricCharge {
+
+ private boolean moveable;
+ private final Point2D position;
+ private final double charge;
+
+ public ElectricCharge(double x, double y, double charge) {
+ this.position = new Point2D.Double(x, y);
+ this.charge = charge;
+ }
+
+ public Point2D getPosition() {
+ return position;
+ }
+
+ public double getCharge() {
+ return charge;
+ }
+
+ public final boolean isMoveable() {
+ return moveable;
+ }
+
+ public final void setMoveable(boolean moveable) {
+ this.moveable = moveable;
+ }
+
+ public void move(double deltax, double deltay) {
+ position.setLocation(position.getX() + deltax, position.getY() + deltay);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graph/ElectricWord.java b/src/net/sourceforge/plantuml/graph/ElectricWord.java
new file mode 100644
index 0000000..c94edf5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph/ElectricWord.java
@@ -0,0 +1,67 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph;
+
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+public class ElectricWord {
+
+ private List<ElectricCharge> charges = new ArrayList<ElectricCharge>();
+
+ public ElectricWord(Rectangle2D playingZone) {
+
+ }
+
+ public void addGlueArea(Rectangle2D glue) {
+
+ }
+
+ public void addCharge(ElectricCharge charge) {
+
+ }
+
+ public void addCharges(Collection<ElectricCharge> charges) {
+
+ }
+
+ public Point2D getForceAt(Point2D position, double charge, Collection<ElectricCharge> ignoredCharges) {
+ return null;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graph/EntityImageActivity.java b/src/net/sourceforge/plantuml/graph/EntityImageActivity.java
new file mode 100644
index 0000000..da6419f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph/EntityImageActivity.java
@@ -0,0 +1,104 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.Polygon;
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.SpriteContainerEmpty;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.StringBounderUtils;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+
+class EntityImageActivity extends AbstractEntityImage {
+
+ final private TextBlock text;
+
+ private final int xMargin = 10;
+ private final int yMargin = 6;
+
+ public EntityImageActivity(IEntity entity) {
+ super(entity);
+ this.text = TextBlockUtils.create(entity.getDisplay(), new FontConfiguration(getFont14(),
+ HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true), HorizontalAlignment.CENTER, new SpriteContainerEmpty());
+ }
+
+ @Override
+ public Dimension2D getDimension(StringBounder stringBounder) {
+ final Dimension2D dim = text.calculateDimension(stringBounder);
+ return Dimension2DDouble.delta(dim, 2 * xMargin, 2 * yMargin);
+ }
+
+ @Override
+ public void draw(ColorMapper colorMapper, Graphics2D g2d) {
+ final Dimension2D dimTotal = getDimension(StringBounderUtils.asStringBounder(g2d));
+
+ final int width = (int) dimTotal.getWidth();
+ final int height = (int) dimTotal.getHeight();
+
+ final Polygon p = new Polygon();
+ p.addPoint(0, yMargin * 2);
+ p.addPoint(xMargin * 2, 0);
+
+ p.addPoint(width - 2 * xMargin, 0);
+ p.addPoint(width, 2 * yMargin);
+
+ p.addPoint(width, height - 2 * yMargin);
+ p.addPoint(width - 2 * xMargin, height);
+
+ p.addPoint(xMargin * 2, height);
+ p.addPoint(0, height - 2 * yMargin);
+
+ g2d.setColor(colorMapper.getMappedColor(getYellow()));
+ g2d.fill(p);
+ // g2d.fillRect(0, 0, width, height);
+
+ g2d.setColor(colorMapper.getMappedColor(getRed()));
+ g2d.draw(p);
+ // g2d.drawRect(0, 0, width - 1, height - 1);
+ g2d.setColor(Color.BLACK);
+// text.drawTOBEREMOVED(colorMapper, g2d, xMargin, yMargin);
+
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graph/EntityImageActivityBar.java b/src/net/sourceforge/plantuml/graph/EntityImageActivityBar.java
new file mode 100644
index 0000000..4885478
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph/EntityImageActivityBar.java
@@ -0,0 +1,65 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+
+class EntityImageActivityBar extends AbstractEntityImage {
+
+ private final int width = 100;
+ private final int height = 8;
+
+ public EntityImageActivityBar(IEntity entity) {
+ super(entity);
+ }
+
+ @Override
+ public Dimension2D getDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(width, height);
+ }
+
+ @Override
+ public void draw(ColorMapper colorMapper, Graphics2D g2d) {
+ g2d.setColor(Color.BLACK);
+ g2d.fillRect(0, 0, width, height);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graph/EntityImageActivityBranch.java b/src/net/sourceforge/plantuml/graph/EntityImageActivityBranch.java
new file mode 100644
index 0000000..796441a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph/EntityImageActivityBranch.java
@@ -0,0 +1,72 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph;
+
+import java.awt.Graphics2D;
+import java.awt.Polygon;
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+
+class EntityImageActivityBranch extends AbstractEntityImage {
+
+ private final int size = 10;
+
+ public EntityImageActivityBranch(IEntity entity) {
+ super(entity);
+ }
+
+ @Override
+ public Dimension2D getDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(size * 2, size * 2);
+ }
+
+ @Override
+ public void draw(ColorMapper colorMapper, Graphics2D g2d) {
+ final Polygon p = new Polygon();
+ p.addPoint(size, 0);
+ p.addPoint(size * 2, size);
+ p.addPoint(size, size * 2);
+ p.addPoint(0, size);
+
+ g2d.setColor(colorMapper.getMappedColor(getYellow()));
+ g2d.fill(p);
+ g2d.setColor(colorMapper.getMappedColor(getRed()));
+ g2d.draw(p);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graph/EntityImageActivityCircle.java b/src/net/sourceforge/plantuml/graph/EntityImageActivityCircle.java
new file mode 100644
index 0000000..b1d523d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph/EntityImageActivityCircle.java
@@ -0,0 +1,69 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+
+class EntityImageActivityCircle extends AbstractEntityImage {
+
+ private final int diameterExternal;
+ private final int diameterInternal;
+
+ public EntityImageActivityCircle(IEntity entity, int diameterExternal, int diameterInternal) {
+ super(entity);
+ this.diameterExternal = diameterExternal;
+ this.diameterInternal = diameterInternal;
+ }
+
+ @Override
+ public Dimension2D getDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(diameterExternal, diameterExternal);
+ }
+
+ @Override
+ public void draw(ColorMapper colorMapper, Graphics2D g2d) {
+ g2d.setColor(Color.BLACK);
+ final int delta = diameterExternal - diameterInternal + 1;
+ g2d.drawOval(0, 0, diameterExternal, diameterExternal);
+ g2d.fillOval(delta / 2, delta / 2, diameterInternal, diameterInternal);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graph/EntityImageCircleInterface.java b/src/net/sourceforge/plantuml/graph/EntityImageCircleInterface.java
new file mode 100644
index 0000000..03350a3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph/EntityImageCircleInterface.java
@@ -0,0 +1,93 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph;
+
+import java.awt.Graphics2D;
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.SpriteContainerEmpty;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.skin.CircleInterface;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+
+class EntityImageCircleInterface extends AbstractEntityImage {
+
+ final private TextBlock name;
+ final private CircleInterface circleInterface;
+
+ public EntityImageCircleInterface(IEntity entity) {
+ super(entity);
+ this.name = TextBlockUtils.create(entity.getDisplay(), new FontConfiguration(getFont14(),
+ HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true), HorizontalAlignment.CENTER, new SpriteContainerEmpty());
+ this.circleInterface = new CircleInterface(getYellow(), getRed());
+ }
+
+ @Override
+ public Dimension2D getDimension(StringBounder stringBounder) {
+ final Dimension2D nameDim = name.calculateDimension(stringBounder);
+ final double manWidth = circleInterface.getPreferredWidth(stringBounder);
+ final double manHeight = circleInterface.getPreferredHeight(stringBounder);
+ return new Dimension2DDouble(Math.max(manWidth, nameDim.getWidth()), manHeight + nameDim.getHeight());
+ }
+
+ @Override
+ public void draw(ColorMapper colorMapper, Graphics2D g2d) {
+ throw new UnsupportedOperationException();
+ // final Dimension2D dimTotal = getDimension(StringBounderUtils.asStringBounder(g2d));
+ // final Dimension2D nameDim = name.calculateDimension(StringBounderUtils.asStringBounder(g2d));
+ //
+ // final double manWidth = circleInterface.getPreferredWidth(StringBounderUtils.asStringBounder(g2d));
+ // final double manHeight = circleInterface.getPreferredHeight(StringBounderUtils.asStringBounder(g2d));
+ //
+ // final double manX = (dimTotal.getWidth() - manWidth) / 2;
+ //
+ // g2d.setColor(Color.WHITE);
+ // g2d.fill(new Rectangle2D.Double(0, 0, dimTotal.getWidth(), dimTotal.getHeight()));
+ //
+ // g2d.translate(manX, 0);
+ // circleInterface.draw(g2d);
+ // g2d.translate(-manX, 0);
+ //
+ // g2d.setColor(Color.BLACK);
+ // name.drawTOBEREMOVED(g2d, (dimTotal.getWidth() - nameDim.getWidth()) / 2, manHeight);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graph/EntityImageComponent.java b/src/net/sourceforge/plantuml/graph/EntityImageComponent.java
new file mode 100644
index 0000000..87e3188
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph/EntityImageComponent.java
@@ -0,0 +1,97 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph;
+
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.Shape;
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Rectangle2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.SpriteContainerEmpty;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.StringBounderUtils;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+
+class EntityImageComponent extends AbstractEntityImage {
+
+ final private TextBlock name;
+ private final float thickness = (float) 1.6;
+
+ public EntityImageComponent(IEntity entity) {
+ super(entity);
+ this.name = TextBlockUtils.create(entity.getDisplay(), new FontConfiguration(getFont14(),
+ HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true), HorizontalAlignment.CENTER, new SpriteContainerEmpty());
+ }
+
+ @Override
+ public Dimension2D getDimension(StringBounder stringBounder) {
+ final Dimension2D nameDim = name.calculateDimension(stringBounder);
+ return Dimension2DDouble.delta(nameDim, 20, 14);
+ }
+
+ private void drawRect(ColorMapper colorMapper, Graphics2D g2d, double x, double y, double width, double height) {
+ g2d.setStroke(new BasicStroke(thickness));
+ final Shape head = new Rectangle2D.Double(x, y, width, height);
+ g2d.setColor(colorMapper.getMappedColor(getYellow()));
+ g2d.fill(head);
+ g2d.setColor(colorMapper.getMappedColor(getRed()));
+ g2d.draw(head);
+
+ g2d.setStroke(new BasicStroke());
+ }
+
+ @Override
+ public void draw(ColorMapper colorMapper, Graphics2D g2d) {
+ final Dimension2D dimTotal = getDimension(StringBounderUtils.asStringBounder(g2d));
+ name.calculateDimension(StringBounderUtils.asStringBounder(g2d));
+
+ drawRect(colorMapper, g2d, 6, 0, dimTotal.getWidth(), dimTotal.getHeight());
+ drawRect(colorMapper, g2d, 0, 7, 12, 6);
+ drawRect(colorMapper, g2d, 0, dimTotal.getHeight() - 7 - 6, 12, 6);
+
+ g2d.setColor(Color.BLACK);
+// name.drawTOBEREMOVED(colorMapper, g2d, 6 + (dimTotal.getWidth() - nameDim.getWidth()) / 2,
+// (dimTotal.getHeight() - nameDim.getHeight()) / 2);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graph/EntityImageDefault.java b/src/net/sourceforge/plantuml/graph/EntityImageDefault.java
new file mode 100644
index 0000000..bbc3f91
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph/EntityImageDefault.java
@@ -0,0 +1,78 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.SpriteContainerEmpty;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.StringBounderUtils;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+
+class EntityImageDefault extends AbstractEntityImage {
+
+ final private TextBlock textBlock;
+
+ public EntityImageDefault(IEntity entity) {
+ super(entity);
+ this.textBlock = TextBlockUtils.create(entity.getDisplay(), new FontConfiguration(getFont14(), HtmlColorUtils.BLACK,
+ HtmlColorUtils.BLUE, true), HorizontalAlignment.CENTER, new SpriteContainerEmpty());
+ }
+
+ @Override
+ public Dimension2D getDimension(StringBounder stringBounder) {
+ final Dimension2D dim = textBlock.calculateDimension(stringBounder);
+ return new Dimension2DDouble(dim.getWidth(), dim.getHeight());
+ }
+
+ @Override
+ public void draw(ColorMapper colorMapper, Graphics2D g2d) {
+ final Dimension2D dim = textBlock.calculateDimension(StringBounderUtils.asStringBounder(g2d));
+ final int width = (int) dim.getWidth();
+ final int height = (int) dim.getHeight();
+ g2d.setColor(Color.BLACK);
+ g2d.drawRect(0, 0, width, height);
+// textBlock.drawTOBEREMOVED(colorMapper, g2d, 0, 0);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graph/EntityImageFactory.java b/src/net/sourceforge/plantuml/graph/EntityImageFactory.java
new file mode 100644
index 0000000..cf5910d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph/EntityImageFactory.java
@@ -0,0 +1,84 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph;
+
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+
+public class EntityImageFactory {
+
+ public AbstractEntityImage createEntityImage(IEntity entity) {
+ throw new UnsupportedOperationException();
+// if (entity.getEntityType() == LeafType.CLASS || entity.getEntityType() == LeafType.ANNOTATION
+// || entity.getEntityType() == LeafType.ABSTRACT_CLASS || entity.getEntityType() == LeafType.INTERFACE
+// || entity.getEntityType() == LeafType.ENUM) {
+// return new EntityImageClass(entity);
+// }
+// if (entity.getEntityType() == LeafType.ACTIVITY) {
+// return new EntityImageActivity(entity);
+// }
+// if (entity.getEntityType() == LeafType.NOTE) {
+// return new EntityImageNote(entity);
+// }
+// if (entity.getEntityType() == LeafType.POINT_FOR_ASSOCIATION) {
+// return new EntityImageActivityCircle(entity, 4, 4);
+// }
+// if (entity.getEntityType() == LeafType.CIRCLE_START) {
+// return new EntityImageActivityCircle(entity, 18, 18);
+// }
+// if (entity.getEntityType() == LeafType.CIRCLE_END) {
+// return new EntityImageActivityCircle(entity, 18, 11);
+// }
+// if (entity.getEntityType() == LeafType.BRANCH) {
+// return new EntityImageActivityBranch(entity);
+// }
+// if (entity.getEntityType() == LeafType.SYNCHRO_BAR) {
+// return new EntityImageActivityBar(entity);
+// }
+// if (entity.getEntityType() == LeafType.USECASE) {
+// return new EntityImageUsecase(entity);
+// }
+// if (entity.getEntityType() == LeafType.ACTOR) {
+// return new EntityImageActor(entity);
+// }
+// if (entity.getEntityType() == LeafType.CIRCLE_INTERFACE) {
+// return new EntityImageCircleInterface(entity);
+// }
+// if (entity.getEntityType() == LeafType.COMPONENT) {
+// return new EntityImageComponent(entity);
+// }
+// return new EntityImageDefault(entity);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graph/EntityImageNote.java b/src/net/sourceforge/plantuml/graph/EntityImageNote.java
new file mode 100644
index 0000000..006aa81
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph/EntityImageNote.java
@@ -0,0 +1,99 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.Polygon;
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.SpriteContainerEmpty;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.StringBounderUtils;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+
+class EntityImageNote extends AbstractEntityImage {
+
+ final private TextBlock text;
+
+ private final int xMargin = 10;
+ private final int yMargin = 10;
+
+ public EntityImageNote(IEntity entity) {
+ super(entity);
+ this.text = TextBlockUtils.create(entity.getDisplay(), new FontConfiguration(getFont14(),
+ HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true), HorizontalAlignment.CENTER, new SpriteContainerEmpty());
+ }
+
+ @Override
+ public Dimension2D getDimension(StringBounder stringBounder) {
+ final Dimension2D dim = text.calculateDimension(stringBounder);
+ return Dimension2DDouble.delta(dim, 2 * xMargin, 2 * yMargin);
+ }
+
+ @Override
+ public void draw(ColorMapper colorMapper, Graphics2D g2d) {
+ final Dimension2D dimTotal = getDimension(StringBounderUtils.asStringBounder(g2d));
+
+ final int width = (int) dimTotal.getWidth();
+ final int height = (int) dimTotal.getHeight();
+
+ final Polygon p = new Polygon();
+ p.addPoint(0, 0);
+ p.addPoint(width - xMargin, 0);
+ p.addPoint(width, yMargin);
+ p.addPoint(width, height);
+ p.addPoint(0, height);
+
+ g2d.setColor(colorMapper.getMappedColor(getYellowNote()));
+ g2d.fill(p);
+
+ g2d.setColor(colorMapper.getMappedColor(getRed()));
+ g2d.draw(p);
+ g2d.drawLine(width - xMargin, 0, width - xMargin, yMargin);
+ g2d.drawLine(width - xMargin, yMargin, width, yMargin);
+
+ g2d.setColor(Color.BLACK);
+// text.drawTOBEREMOVED(colorMapper, g2d, xMargin, yMargin);
+
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graph/EntityImageUsecase.java b/src/net/sourceforge/plantuml/graph/EntityImageUsecase.java
new file mode 100644
index 0000000..f311543
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph/EntityImageUsecase.java
@@ -0,0 +1,106 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.geom.Dimension2D;
+import java.awt.geom.GeneralPath;
+import java.awt.geom.QuadCurve2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.SpriteContainerEmpty;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.StringBounderUtils;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+
+class EntityImageUsecase extends AbstractEntityImage {
+
+ final private TextBlock name;
+
+ public EntityImageUsecase(IEntity entity) {
+ super(entity);
+ this.name = TextBlockUtils.create(entity.getDisplay(), new FontConfiguration(getFont14(),
+ HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true), HorizontalAlignment.CENTER, new SpriteContainerEmpty());
+ }
+
+ @Override
+ public Dimension2D getDimension(StringBounder stringBounder) {
+ final Dimension2D nameDim = name.calculateDimension(stringBounder);
+ // final double eps = Math.sqrt(nameDim.getWidth() /
+ // nameDim.getHeight());
+ // final double diag = Math.sqrt(nameDim.getWidth() * nameDim.getWidth()
+ // + nameDim.getHeight()
+ // * nameDim.getHeight());
+ // return new Dimension2DDouble(diag * eps, diag / eps);
+ final double eps = 1.7;
+ return new Dimension2DDouble(nameDim.getWidth() * eps, nameDim.getHeight() * eps);
+ }
+
+ @Override
+ public void draw(ColorMapper colorMapper, Graphics2D g2d) {
+ final Dimension2D dimTotal = getDimension(StringBounderUtils.asStringBounder(g2d));
+
+ // Shape ellipse = new Ellipse2D.Double(0, 0, dimTotal.getWidth(),
+ // dimTotal.getHeight());
+ final GeneralPath ellipse = new GeneralPath();
+ final double h = dimTotal.getHeight();
+ final double w = dimTotal.getWidth();
+ ellipse.append(new QuadCurve2D.Double(0, h / 2, 0, 0, w / 2, 0), true);
+ ellipse.append(new QuadCurve2D.Double(w / 2, 0, w, 0, w, h / 2), true);
+ ellipse.append(new QuadCurve2D.Double(w, h / 2, w, h, w / 2, h), true);
+ ellipse.append(new QuadCurve2D.Double(w / 2, h, 0, h, 0, h / 2), true);
+ g2d.setColor(colorMapper.getMappedColor(getYellow()));
+ g2d.fill(ellipse);
+
+ g2d.setColor(colorMapper.getMappedColor(getRed()));
+ g2d.draw(ellipse);
+
+// final Dimension2D nameDim = name.calculateDimension(StringBounderUtils.asStringBounder(g2d));
+// final double posx = (w - nameDim.getWidth()) / 2;
+// final double posy = (h - nameDim.getHeight()) / 2;
+ // final Shape rect = new Rectangle2D.Double(posx, posy, nameDim.getWidth(), nameDim.getHeight());
+ // g2d.draw(rect);
+
+ g2d.setColor(Color.BLACK);
+ // name.drawTOBEREMOVED(colorMapper, g2d, posx, posy);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graph/Galaxy4.java b/src/net/sourceforge/plantuml/graph/Galaxy4.java
new file mode 100644
index 0000000..6480162
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph/Galaxy4.java
@@ -0,0 +1,93 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph;
+
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import net.sourceforge.plantuml.Log;
+import net.sourceforge.plantuml.geom.Point2DInt;
+import net.sourceforge.plantuml.geom.PolylineBreakeable;
+import net.sourceforge.plantuml.geom.SpiderWeb;
+
+public class Galaxy4 {
+
+ final private Board board;
+
+ final private Map<ALink, PolylineBreakeable> lines = new LinkedHashMap<ALink, PolylineBreakeable>();
+ final private SpiderWeb spiderWeb;
+
+ public Galaxy4(Board board, int widthCell, int heightCell) {
+ this.spiderWeb = new SpiderWeb(widthCell, heightCell);
+ this.board = board;
+ }
+
+ public Point2DInt getMainPoint(int row, int col) {
+ return spiderWeb.getMainPoint(row, col);
+ }
+
+ public PolylineBreakeable getPolyline(ALink link) {
+ return lines.get(link);
+
+ }
+
+ public void addLink(ALink link) {
+ final int rowStart = link.getNode1().getRow();
+ final int rowEnd = link.getNode2().getRow();
+ final int colStart = board.getCol(link.getNode1());
+ final int colEnd = board.getCol(link.getNode2());
+
+ final PolylineBreakeable polyline = spiderWeb.addPolyline(rowStart, colStart, rowEnd, colEnd);
+
+ Log.info("link=" + link + " polyline=" + polyline);
+
+ if (polyline == null) {
+ Log.info("PENDING " + link + " " + polyline);
+ } else {
+ lines.put(link, polyline);
+ }
+
+ }
+
+ public final Board getBoard() {
+ return board;
+ }
+
+ public final Map<ALink, PolylineBreakeable> getLines() {
+ return Collections.unmodifiableMap(lines);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graph/GeneralPathFactory.java b/src/net/sourceforge/plantuml/graph/GeneralPathFactory.java
new file mode 100644
index 0000000..c1384ef
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph/GeneralPathFactory.java
@@ -0,0 +1,157 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph;
+
+import java.awt.Polygon;
+import java.awt.Shape;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.GeneralPath;
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.cucadiagram.LinkType;
+import net.sourceforge.plantuml.geom.Box;
+import net.sourceforge.plantuml.geom.LineSegmentInt;
+import net.sourceforge.plantuml.geom.PolylineBreakeable;
+
+public class GeneralPathFactory {
+
+ private final LinkType linkType;
+
+ public GeneralPathFactory(LinkType linkType) {
+ this.linkType = linkType;
+ }
+
+ public Shape getLink(PolylineBreakeable polyline, Box b1, Box b2) {
+ final LineSegmentInt directSegment = new LineSegmentInt(b1.getCenterX(), b1.getCenterY(), b2.getCenterX(), b2
+ .getCenterY());
+ assert b1.intersect(directSegment).length == 1;
+ assert b2.intersect(directSegment).length == 1;
+
+ // final Point2D.Double start = polyline.clipStart(b1);
+ // final Point2D.Double end = polyline.clipEnd(b2);
+ final GeneralPath generalPath = polyline.asGeneralPath();
+ // addSymbol(generalPath, start, polyline.getFirst(), end,
+ // polyline.getLast());
+ return generalPath;
+
+ }
+
+ private void addSymbol(GeneralPath generalPath, Point2D.Double firstPoint, LineSegmentInt firstSeg,
+ Point2D.Double lastPoint, LineSegmentInt lastSeg) {
+// if (linkType.equals(LinkType.AGREGATION) || linkType.equals(LinkType.COMPOSITION)) {
+// addSymbolDiamond(generalPath, lastPoint, lastSeg);
+// } else if (linkType.equals(LinkType.AGREGATION_INV) || linkType.equals(LinkType.COMPOSITION_INV)) {
+// addSymbolDiamondInv(generalPath, firstPoint, firstSeg);
+// } else if (linkType.equals(LinkType.NAVASSOC) || linkType.equals(LinkType.NAVASSOC_DASHED)) {
+// addSymbolNavasoc(generalPath, lastPoint, lastSeg);
+// } else if (linkType.equals(LinkType.NAVASSOC_INV) || linkType.equals(LinkType.NAVASSOC_DASHED_INV)) {
+// addSymbolNavasocInv(generalPath, firstPoint, firstSeg);
+// } else if (linkType.equals(LinkType.EXTENDS_INV) || linkType.equals(LinkType.IMPLEMENTS_INV)) {
+// addSymbolExtends(generalPath, firstPoint, firstSeg);
+// } else if (linkType.equals(LinkType.EXTENDS) || linkType.equals(LinkType.IMPLEMENTS)) {
+// addSymbolExtendsInv(generalPath, lastPoint, lastSeg);
+// } else {
+// assert linkType.equals(LinkType.ASSOCIED) || linkType.equals(LinkType.ASSOCIED_DASHED);
+// }
+ }
+
+ private void addSymbolDiamond(GeneralPath generalPath, Point2D.Double point, LineSegmentInt seg) {
+ final Polygon arrow = new Polygon();
+ arrow.addPoint(0, 0);
+ arrow.addPoint(-10, 6);
+ arrow.addPoint(-20, 0);
+ arrow.addPoint(-10, -6);
+
+ appendAndRotate(generalPath, point, seg, arrow);
+ }
+
+ private void addSymbolDiamondInv(GeneralPath generalPath, Point2D.Double point, LineSegmentInt seg) {
+ final Polygon arrow = new Polygon();
+ arrow.addPoint(0, 0);
+ arrow.addPoint(10, 6);
+ arrow.addPoint(20, 0);
+ arrow.addPoint(10, -6);
+
+ appendAndRotate(generalPath, point, seg, arrow);
+ }
+
+ private void addSymbolNavasocInv(GeneralPath generalPath, Point2D.Double point, LineSegmentInt seg) {
+ final Polygon arrow = new Polygon();
+ arrow.addPoint(0, 0);
+ arrow.addPoint(13, -8);
+ arrow.addPoint(6, 0);
+ arrow.addPoint(13, 8);
+
+ appendAndRotate(generalPath, point, seg, arrow);
+ }
+
+ private void addSymbolNavasoc(GeneralPath generalPath, Point2D.Double point, LineSegmentInt seg) {
+ final Polygon arrow = new Polygon();
+ arrow.addPoint(0, 0);
+ arrow.addPoint(-13, -8);
+ arrow.addPoint(-6, 0);
+ arrow.addPoint(-13, 8);
+
+ appendAndRotate(generalPath, point, seg, arrow);
+ }
+
+ private void addSymbolExtends(GeneralPath generalPath, Point2D.Double point, LineSegmentInt seg) {
+ final Polygon arrow = new Polygon();
+ arrow.addPoint(0, 0);
+ arrow.addPoint(25, 7);
+ arrow.addPoint(25, -7);
+
+ appendAndRotate(generalPath, point, seg, arrow);
+ }
+
+ private void addSymbolExtendsInv(GeneralPath generalPath, Point2D.Double point, LineSegmentInt seg) {
+ final Polygon arrow = new Polygon();
+ arrow.addPoint(0, 0);
+ arrow.addPoint(-25, 7);
+ arrow.addPoint(-25, -7);
+
+ appendAndRotate(generalPath, point, seg, arrow);
+ }
+
+ private void appendAndRotate(GeneralPath generalPath, Point2D.Double point, LineSegmentInt seg, final Shape shape) {
+ final AffineTransform at = AffineTransform.getTranslateInstance(point.x, point.y);
+ final double theta = seg.getAngle();
+ at.rotate(theta);
+
+ final Shape r = at.createTransformedShape(shape);
+ generalPath.append(r, false);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graph/Graph1.java b/src/net/sourceforge/plantuml/graph/Graph1.java
new file mode 100644
index 0000000..45187f5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph/Graph1.java
@@ -0,0 +1,80 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.image.BufferedImage;
+
+public class Graph1 {
+
+ private final Board board;
+ private final int widthCell = 40;
+ private final int heightCell = 40;
+
+ public Graph1(Board board) {
+ this.board = board;
+ }
+
+ public BufferedImage createBufferedImage() {
+ final BufferedImage im = new BufferedImage(widthCell * 15, heightCell * 15, BufferedImage.TYPE_INT_RGB);
+ final Graphics2D g2d = im.createGraphics();
+ g2d.setColor(Color.WHITE);
+ g2d.fillRect(0, 0, im.getWidth(), im.getHeight());
+
+ g2d.setColor(Color.BLACK);
+ for (ANode n : board.getNodes()) {
+ final int x = board.getCol(n) * widthCell;
+ final int y = n.getRow() * heightCell;
+ g2d.drawString(n.getCode(), x + 5, y + heightCell / 2 - 5);
+ g2d.drawOval(x, y, widthCell / 2, heightCell / 2);
+ }
+
+ for (ALink link : board.getLinks()) {
+ final ANode n1 = link.getNode1();
+ final ANode n2 = link.getNode2();
+ final int x1 = 10 + board.getCol(n1) * widthCell;
+ final int y1 = 10 + n1.getRow() * heightCell;
+ final int x2 = 10 + board.getCol(n2) * widthCell;
+ final int y2 = 10 + n2.getRow() * heightCell;
+ g2d.drawLine(x1, y1, x2, y2);
+
+ }
+
+ return im;
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graph/Graph2.java b/src/net/sourceforge/plantuml/graph/Graph2.java
new file mode 100644
index 0000000..c5be27c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph/Graph2.java
@@ -0,0 +1,100 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.geom.Dimension2D;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import net.sourceforge.plantuml.EmptyImageBuilder;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.graphic.StringBounderUtils;
+
+public class Graph2 {
+
+ final private static Graphics2D dummyGraphics2D;
+
+ private final Elastane elastane;
+ private int widthCell;
+ private int heightCell;
+
+ static {
+ final EmptyImageBuilder builder = new EmptyImageBuilder(10, 10, Color.WHITE);
+ dummyGraphics2D = builder.getGraphics2D();
+ }
+
+ public Graph2(Board board) {
+ board.normalize();
+
+ for (ANode n : board.getNodes()) {
+ final Dimension2D dim = images(n).getDimension(StringBounderUtils.asStringBounder(dummyGraphics2D));
+ widthCell = Math.max(widthCell, (int) dim.getWidth());
+ heightCell = Math.max(heightCell, (int) dim.getHeight());
+ }
+ final Galaxy4 galaxy = new Galaxy4(board, widthCell, heightCell);
+ elastane = new Elastane(galaxy);
+
+ for (ANode n : board.getNodes()) {
+ final Dimension2D dim = images(n).getDimension(StringBounderUtils.asStringBounder(dummyGraphics2D));
+ elastane.addBox(n, (int) dim.getWidth(), (int) dim.getHeight());
+ }
+
+ final List<ALink> links = new ArrayList<ALink>(board.getLinks());
+ Collections.sort(links, board.getLinkComparator());
+ for (ALink link : links) {
+ galaxy.addLink(link);
+ }
+
+ elastane.init();
+
+ }
+
+ private AbstractEntityImage images(ANode n) {
+ return new EntityImageFactory().createEntityImage((IEntity)n.getUserData());
+ }
+
+ public Dimension2D getDimension() {
+ return elastane.getDimension();
+
+ }
+
+ public void draw(final Graphics2D g2d) {
+ elastane.draw(g2d);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graph/Graph3.java b/src/net/sourceforge/plantuml/graph/Graph3.java
new file mode 100644
index 0000000..b6f9779
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph/Graph3.java
@@ -0,0 +1,479 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Line2D;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.EmptyImageBuilder;
+import net.sourceforge.plantuml.Log;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.geom.InflationTransform;
+import net.sourceforge.plantuml.geom.Kingdom;
+import net.sourceforge.plantuml.geom.LineSegmentInt;
+import net.sourceforge.plantuml.geom.Point2DInt;
+import net.sourceforge.plantuml.geom.Pointable;
+import net.sourceforge.plantuml.geom.Polyline;
+import net.sourceforge.plantuml.geom.PolylineImpl;
+import net.sourceforge.plantuml.geom.XMoveable;
+import net.sourceforge.plantuml.geom.kinetic.Frame;
+import net.sourceforge.plantuml.geom.kinetic.Path;
+import net.sourceforge.plantuml.geom.kinetic.Point2DCharge;
+import net.sourceforge.plantuml.geom.kinetic.World;
+import net.sourceforge.plantuml.graphic.StringBounderUtils;
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+
+public class Graph3 {
+
+ final private static Graphics2D dummyGraphics2D;
+
+ private final int spaceWidth = 40;
+ private final int spaceHeight = 40;
+ private final int minDistBetweenPoint = 20;
+
+ // private final int boxWidth = 20;
+ // private final int boxHeight = 20;
+
+ private final double margin = 30;
+ private final Board board;
+ private final List<PolylineImpl> polylines = new ArrayList<PolylineImpl>();
+ private final Map<ANode, ANodePoint> nodePoints = new LinkedHashMap<ANode, ANodePoint>();
+
+ private int maxRow;
+ private int maxCol;
+
+ static {
+ final EmptyImageBuilder builder = new EmptyImageBuilder(10, 10, Color.WHITE);
+ dummyGraphics2D = builder.getGraphics2D();
+ }
+
+ class ANodePoint implements Pointable, XMoveable {
+ final private ANode node;
+ private int deltaX = 0;
+ private int deltaY = 0;
+
+ public ANodePoint(ANode node) {
+ this.node = node;
+ }
+
+ public Point2DInt getPosition() {
+ return new Point2DInt(board.getCol(node) * spaceWidth + deltaX, node.getRow() * spaceHeight + deltaY);
+ }
+
+ public void moveX(int delta) {
+ this.deltaX += delta;
+ }
+
+ public void moveY(int delta) {
+ this.deltaY += delta;
+ }
+
+ public ANode getNode() {
+ return node;
+ }
+
+ }
+
+ private Collection<XMoveable> convertANodeSet(Set<ANode> nodesSet) {
+ final Collection<XMoveable> result = new HashSet<XMoveable>();
+ for (ANode n : nodesSet) {
+ assert nodePoints.get(n) != null;
+ result.add(nodePoints.get(n));
+ }
+ return result;
+ }
+
+ private int addedWidth = 0;
+ private int addedHeight = 0;
+
+ public Graph3(Board board) {
+ board.normalize();
+ this.board = board;
+ for (ANode n : board.getNodes()) {
+ maxRow = Math.max(maxRow, n.getRow());
+ maxCol = Math.max(maxCol, board.getCol(n));
+ }
+ for (ANode n : board.getNodes()) {
+ nodePoints.put(n, new ANodePoint(n));
+ }
+
+ // for (ALink link : board.getLinks()) {
+ // final Pointable pp1 = nodePoints.get(link.getNode1());
+ // final Pointable pp2 = nodePoints.get(link.getNode2());
+ // polylines.add(new PolylineImpl(pp1, pp2));
+ // }
+ // manyPasses(board);
+ // polylines.clear();
+
+ computePolylines(board);
+
+ final InflationTransform inflationTransform = new InflationTransform();
+ for (ANodePoint nodePoint : nodePoints.values()) {
+ final Point2DInt p = nodePoint.getPosition();
+ final AbstractEntityImage image = getImage(nodePoint.getNode());
+
+ int widthCell = (int) image.getDimension(StringBounderUtils.asStringBounder(dummyGraphics2D)).getWidth();
+ int heightCell = (int) image.getDimension(StringBounderUtils.asStringBounder(dummyGraphics2D)).getHeight();
+ if (widthCell % 2 == 1) {
+ widthCell++;
+ }
+ if (heightCell % 2 == 1) {
+ heightCell++;
+ }
+
+ inflationTransform.addInflationX(p.getXint(), widthCell);
+ addedWidth += widthCell;
+ inflationTransform.addInflationY(p.getYint(), heightCell);
+ addedHeight += heightCell;
+ }
+
+ for (PolylineImpl p : polylines) {
+ p.inflate(inflationTransform);
+ }
+
+ for (ANodePoint nodePoint : nodePoints.values()) {
+ final Point2DInt pos = nodePoint.getPosition();
+ final Point2DInt pos2 = inflationTransform.inflatePoint2DInt(pos);
+ nodePoint.moveX(pos2.getXint() - pos.getXint());
+ nodePoint.moveY(pos2.getYint() - pos.getYint());
+ }
+
+ // Kinematic
+ for (ANodePoint point : nodePoints.values()) {
+ final double x = point.getPosition().getX();
+ final double y = point.getPosition().getY();
+ final Dimension2D dim = getImage(point.getNode()).getDimension(
+ StringBounderUtils.asStringBounder(dummyGraphics2D));
+ final Frame frame = new Frame(x, y, (int) dim.getWidth(), (int) dim.getHeight());
+ frames.put(point, frame);
+ world.addFrame(frame);
+ }
+
+ for (PolylineImpl polyline : polylines) {
+ final Frame f1 = frames.get(polyline.getStart());
+ final Frame f2 = frames.get(polyline.getEnd());
+ final Path path = new Path(f1, f2);
+ for (Point2DInt pt : polyline.getIntermediates()) {
+ path.addIntermediate(new Point2DCharge(pt.getX(), pt.getY()));
+ }
+ world.addPath(path);
+ }
+
+ world.renderContinue();
+ Log.info("Starting moving");
+ final long start = System.currentTimeMillis();
+ final int limit = 100;
+ for (int i = 0; i < limit; i++) {
+ Log.info("i=" + i);
+ final double move = world.onePass();
+ if (move < 1) {
+ Log.info("i=" + i + " " + move);
+ // break;
+ }
+ if (i == limit - 1) {
+ Log.info("Aborting");
+ }
+ }
+ final long duration = System.currentTimeMillis() - start;
+ Log.info("Ending moving (" + duration + " ms)");
+
+ }
+
+ private final World world = new World();
+ private final Map<ANodePoint, Frame> frames = new LinkedHashMap<ANodePoint, Frame>();
+
+ private void computePolylines(Board board) {
+ final Collection<ALink> latter = new ArrayList<ALink>();
+ final Kingdom kingdom = new Kingdom();
+ final List<? extends ALink> links = new ArrayList<ALink>(board.getLinks());
+ Collections.sort(links, board.getLinkComparator());
+ for (ALink link : links) {
+ final Pointable pp1 = nodePoints.get(link.getNode1());
+ final Pointable pp2 = nodePoints.get(link.getNode2());
+ if (kingdom.isSimpleSegmentPossible(pp1.getPosition(), pp2.getPosition())) {
+ Log.println("OK for " + link);
+ kingdom.addDirectLink(pp1.getPosition(), pp2.getPosition());
+ polylines.add(new PolylineImpl(pp1, pp2));
+ } else {
+ Log.println("Latter for " + link);
+ latter.add(link);
+ }
+ }
+
+ Log.println("latters=" + latter.size());
+ for (ALink link : latter) {
+ Log.println("Alatter=" + link);
+ }
+ for (ALink link : latter) {
+ Log.println("Blatter=" + link);
+ final Pointable pp1 = nodePoints.get(link.getNode1());
+ final Pointable pp2 = nodePoints.get(link.getNode2());
+ polylines.add((PolylineImpl) kingdom.getPath(pp1, pp2));
+ }
+ }
+
+ private void manyPasses(Board board) {
+ final Collection<Collection<XMoveable>> xmoveableGroups = getXMoveables(board);
+
+ Log.println("COST_INIT=" + getCost());
+ for (int i = 0; i < 300; i++) {
+ final boolean changed = onePass(xmoveableGroups);
+ if (changed == false) {
+ break;
+ }
+ }
+ Log.println("COST_FIN=" + getCost());
+ }
+
+ private Collection<Collection<XMoveable>> getXMoveables(Board board) {
+ final Set<Set<ANode>> nodesGroups = new HashSet<Set<ANode>>();
+ final Collection<ANode> nodes = board.getNodes();
+ for (ANode root : nodes) {
+ for (int i = 0; i < board.getLinks().size(); i++) {
+ final Set<ANode> group = board.getConnectedNodes(root, i);
+ if (group.size() < nodes.size()) {
+ nodesGroups.add(group);
+ }
+ }
+ }
+
+ final Collection<Collection<XMoveable>> xmoveableGroups = new ArrayList<Collection<XMoveable>>();
+ for (Set<ANode> nodesSet : nodesGroups) {
+ xmoveableGroups.add(convertANodeSet(nodesSet));
+ }
+ return xmoveableGroups;
+ }
+
+ private void moveX(Collection<XMoveable> boxes, int delta) {
+ for (XMoveable b : boxes) {
+ b.moveX(delta);
+ }
+ }
+
+ private static final int STEP = 1;
+
+ private boolean onePass(Collection<? extends Collection<XMoveable>> subLists) {
+ boolean changed = false;
+ for (Collection<XMoveable> toMove : subLists) {
+ final double initCost = getCost();
+
+ assert reversable(initCost, toMove);
+
+ moveX(toMove, STEP);
+ if (getCost() < initCost) {
+ changed = true;
+ } else {
+ moveX(toMove, -STEP);
+ moveX(toMove, -STEP);
+ if (getCost() < initCost) {
+ changed = true;
+ } else {
+ moveX(toMove, STEP);
+ assert getCost() == initCost : "c1=" + getCost() + " init=" + initCost;
+ }
+ }
+ assert getCost() <= initCost;
+
+ }
+ // Log.println("COSTB=" + getCost());
+ return changed;
+ }
+
+ private boolean reversable(double initCost, Collection<XMoveable> toMove) {
+ moveX(toMove, STEP);
+ moveX(toMove, -STEP);
+ assert getCost() == initCost;
+ moveX(toMove, STEP);
+ moveX(toMove, -STEP * 2);
+ moveX(toMove, STEP);
+ assert getCost() == initCost;
+ return true;
+ }
+
+ private double getCostOld() {
+ if (mindistRespected() == false) {
+ return Double.MAX_VALUE;
+ }
+ double result = 0;
+ for (PolylineImpl p : polylines) {
+ result += getLength(p);
+
+ for (PolylineImpl other : polylines) {
+ if (other == p) {
+ continue;
+ }
+ if (p.doesTouch(other)) {
+ result += getLength(other);
+ }
+ }
+ }
+
+ return result;
+ }
+
+ private double getCost() {
+ double result = 0;
+ for (PolylineImpl p1 : polylines) {
+ for (PolylineImpl p2 : polylines) {
+ result += getCost(p1, p2);
+ }
+ }
+
+ final List<ANodePoint> all = new ArrayList<ANodePoint>(nodePoints.values());
+ for (int i = 0; i < all.size() - 1; i++) {
+ for (int j = i + 1; j < all.size(); j++) {
+ final double len = new LineSegmentInt(all.get(i).getPosition(), all.get(j).getPosition()).getLength();
+ result += minDistBetweenPoint * minDistBetweenPoint / len / len;
+ }
+ }
+
+ return result;
+ }
+
+ private double getCost(PolylineImpl p1, PolylineImpl p2) {
+ assert p1.nbSegments() == 1;
+ assert p2.nbSegments() == 1;
+
+ final LineSegmentInt seg1 = p1.getFirst();
+ final LineSegmentInt seg2 = p2.getFirst();
+
+ final double len1 = seg1.getLength();
+ if (p1 == p2) {
+ return len1 / minDistBetweenPoint;
+ }
+ final double len2 = seg2.getLength();
+
+ // return len1 * len2 * Math.exp(-seg1.getDistance(seg2));
+ return len1 * len2 / seg1.getDistance(seg2) / minDistBetweenPoint / minDistBetweenPoint;
+ // return len1 * len2 * Math.exp(-seg1.getDistance(seg2)) /
+ // minDistBetweenPoint / minDistBetweenPoint;
+ }
+
+ private boolean mindistRespected() {
+ final List<ANodePoint> all = new ArrayList<ANodePoint>(nodePoints.values());
+ for (int i = 0; i < all.size() - 1; i++) {
+ for (int j = i + 1; j < all.size(); j++) {
+ final double len = new LineSegmentInt(all.get(i).getPosition(), all.get(j).getPosition()).getLength();
+ if (len <= minDistBetweenPoint) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ private double getLength(final Polyline p) {
+ final double len = p.getLength();
+ assert len > 0;
+ return Math.log(1 + len);
+ }
+
+ public Dimension2D getDimension() {
+ final double width = spaceWidth * maxCol;
+ final int height = spaceWidth * maxRow; // + boxHeight * (maxRow + 1);
+ return new Dimension2DDouble(width + 2 * margin + addedWidth, height + 2 * margin + addedHeight);
+
+ }
+
+ public void draw(final Graphics2D g2d) {
+ g2d.translate(margin, margin);
+
+ for (Path p : world.getPaths()) {
+ for (Line2D seg : p.segments()) {
+ g2d.setColor(Color.BLUE);
+ g2d.draw(seg);
+ g2d.setColor(Color.RED);
+ g2d.drawOval((int) seg.getX1(), (int) seg.getY1(), 1, 1);
+ }
+ }
+
+ g2d.setColor(Color.GREEN);
+ for (ANodePoint nodePoint : nodePoints.values()) {
+ final Frame frame = frames.get(nodePoint);
+ final AbstractEntityImage image = getImage(nodePoint.getNode());
+ final double width = image.getDimension(StringBounderUtils.asStringBounder(g2d)).getWidth();
+ final double height = image.getDimension(StringBounderUtils.asStringBounder(g2d)).getHeight();
+ g2d.translate(frame.getX() - width / 2, frame.getY() - height / 2);
+ image.draw(new ColorMapperIdentity(), g2d);
+ g2d.translate(-frame.getX() + width / 2, -frame.getY() + height / 2);
+ }
+
+ }
+
+ public void draw2(final Graphics2D g2d) {
+ g2d.translate(margin, margin);
+
+ g2d.setColor(Color.BLUE);
+ for (Polyline p : polylines) {
+ if (p == null) {
+ Log.println("Polyline NULL!!");
+ continue;
+ }
+ for (LineSegmentInt seg : p.segments()) {
+ g2d.drawLine(seg.getP1().getXint(), seg.getP1().getYint(), seg.getP2().getXint(), seg.getP2().getYint());
+ }
+ }
+
+ g2d.setColor(Color.GREEN);
+ for (ANodePoint nodePoint : nodePoints.values()) {
+ final Point2DInt p = nodePoint.getPosition();
+ // Log.println("p=" + p);
+ final AbstractEntityImage image = getImage(nodePoint.getNode());
+ final int width = (int) (image.getDimension(StringBounderUtils.asStringBounder(g2d)).getWidth());
+ final int height = (int) (image.getDimension(StringBounderUtils.asStringBounder(g2d)).getHeight());
+ g2d.translate(p.getXint() - width / 2, p.getYint() - height / 2);
+ image.draw(new ColorMapperIdentity(), g2d);
+ g2d.translate(-p.getXint() + width / 2, -p.getYint() + height / 2);
+ // g2d.fillOval(p.getXint() - 2, p.getYint() - 2, 5, 5);
+ // g2d.drawRect(p.getXint() - 4, p.getYint() - 4, 8, 8);
+ }
+ }
+
+ private AbstractEntityImage getImage(ANode n) {
+ return new EntityImageFactory().createEntityImage((IEntity) n.getUserData());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graph/Graph4.java b/src/net/sourceforge/plantuml/graph/Graph4.java
new file mode 100644
index 0000000..fbb11bf
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph/Graph4.java
@@ -0,0 +1,266 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.geom.CubicCurve2D;
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Rectangle2D;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.EmptyImageBuilder;
+import net.sourceforge.plantuml.Log;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.geom.InflationTransform;
+import net.sourceforge.plantuml.geom.Point2DInt;
+import net.sourceforge.plantuml.geom.Pointable;
+import net.sourceforge.plantuml.geom.XMoveable;
+import net.sourceforge.plantuml.geom.kinetic.Frame;
+import net.sourceforge.plantuml.graph2.CubicCurveFactory;
+import net.sourceforge.plantuml.graph2.MyCurve;
+import net.sourceforge.plantuml.graph2.RectanglesCollection;
+import net.sourceforge.plantuml.graphic.StringBounderUtils;
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+
+public class Graph4 {
+
+ final private static Graphics2D dummyGraphics2D;
+
+ private final int spaceWidth = 40;
+ private final int spaceHeight = 40;
+
+ private final double margin = 30;
+ private final Board board;
+
+ private final Map<ANode, ANodePoint> nodePoints = new LinkedHashMap<ANode, ANodePoint>();
+ private final Map<ANodePoint, Frame> frames = new LinkedHashMap<ANodePoint, Frame>();
+
+ private int maxRow;
+ private int maxCol;
+
+ private int addedWidth = 0;
+ private int addedHeight = 0;
+
+ static {
+ final EmptyImageBuilder builder = new EmptyImageBuilder(10, 10, Color.WHITE);
+ dummyGraphics2D = builder.getGraphics2D();
+ }
+
+ class ANodePoint implements Pointable, XMoveable {
+ final private ANode node;
+ private int deltaX = 0;
+ private int deltaY = 0;
+
+ public ANodePoint(ANode node) {
+ this.node = node;
+ }
+
+ public Point2DInt getPosition() {
+ return new Point2DInt(board.getCol(node) * spaceWidth + deltaX, node.getRow() * spaceHeight + deltaY);
+ }
+
+ public void moveX(int delta) {
+ this.deltaX += delta;
+ }
+
+ public void moveY(int delta) {
+ this.deltaY += delta;
+ }
+
+ public ANode getNode() {
+ return node;
+ }
+
+ }
+
+ public Graph4(Board board) {
+ board.normalize();
+ this.board = board;
+ for (ANode n : board.getNodes()) {
+ maxRow = Math.max(maxRow, n.getRow());
+ maxCol = Math.max(maxCol, board.getCol(n));
+ }
+ for (ANode n : board.getNodes()) {
+ nodePoints.put(n, new ANodePoint(n));
+ }
+
+ final InflationTransform inflationTransform = new InflationTransform();
+ for (ANodePoint nodePoint : nodePoints.values()) {
+ final Point2DInt p = nodePoint.getPosition();
+ final AbstractEntityImage image = getImage(nodePoint.getNode());
+
+ int widthCell = (int) image.getDimension(StringBounderUtils.asStringBounder(dummyGraphics2D)).getWidth();
+ int heightCell = (int) image.getDimension(StringBounderUtils.asStringBounder(dummyGraphics2D)).getHeight();
+ if (widthCell % 2 == 1) {
+ widthCell++;
+ }
+ if (heightCell % 2 == 1) {
+ heightCell++;
+ }
+
+ inflationTransform.addInflationX(p.getXint(), widthCell);
+ addedWidth += widthCell;
+ inflationTransform.addInflationY(p.getYint(), heightCell);
+ addedHeight += heightCell;
+ }
+
+ for (ANodePoint nodePoint : nodePoints.values()) {
+ final Point2DInt pos = nodePoint.getPosition();
+ final Point2DInt pos2 = inflationTransform.inflatePoint2DInt(pos);
+ nodePoint.moveX(pos2.getXint() - pos.getXint());
+ nodePoint.moveY(pos2.getYint() - pos.getYint());
+ }
+
+ // Kinematic
+ for (ANodePoint point : nodePoints.values()) {
+ final double x = point.getPosition().getX();
+ final double y = point.getPosition().getY();
+ final Dimension2D dim = getImage(point.getNode()).getDimension(
+ StringBounderUtils.asStringBounder(dummyGraphics2D));
+ final int width = (int) dim.getWidth();
+ final int height = (int) dim.getHeight();
+ final Frame frame = new Frame(x - width / 2, y - height / 2, width, height);
+ frames.put(point, frame);
+ }
+
+ }
+
+ public Dimension2D getDimension() {
+ final double width = spaceWidth * maxCol;
+ final int height = spaceWidth * maxRow;
+ return new Dimension2DDouble(width + 2 * margin + addedWidth, height + 2 * margin + addedHeight);
+
+ }
+
+ private final List<MyCurve> alreadyCurve = new ArrayList<MyCurve>();
+
+ public void draw(final Graphics2D g2d) {
+ g2d.translate(margin, margin);
+
+ g2d.setColor(Color.BLUE);
+
+ final long start = System.currentTimeMillis();
+ alreadyCurve.clear();
+ for (ALink link : getSortedLinks()) {
+ final ANodePoint p1 = nodePoints.get(link.getNode1());
+ final ANodePoint p2 = nodePoints.get(link.getNode2());
+ final RectanglesCollection forbidden = getForbidden(link);
+ if (forbidden.size() != nodePoints.size() - 2) {
+ throw new IllegalStateException();
+ }
+ final MyCurve line = getCurveLink(p1, p2, forbidden);
+ alreadyCurve.add(line);
+ line.draw(g2d);
+ }
+ final long tps5 = System.currentTimeMillis() - start;
+ Log.println("TPS5 = " + tps5);
+
+ g2d.setColor(Color.GREEN);
+ for (ANodePoint nodePoint : nodePoints.values()) {
+ final Frame frame = frames.get(nodePoint);
+ final AbstractEntityImage image = getImage(nodePoint.getNode());
+ g2d.translate(frame.getX(), frame.getY());
+ image.draw(new ColorMapperIdentity(), g2d);
+ g2d.translate(-frame.getX(), -frame.getY());
+ }
+
+ }
+
+ private List<ALink> getSortedLinks() {
+ final Map<ALink, Double> lengths = new HashMap<ALink, Double>();
+ for (ALink link : board.getLinks()) {
+ final ANodePoint p1 = nodePoints.get(link.getNode1());
+ final ANodePoint p2 = nodePoints.get(link.getNode2());
+ lengths.put(link, p1.getPosition().distance(p2.getPosition()));
+ }
+ final List<ALink> all = new ArrayList<ALink>(lengths.keySet());
+ Collections.sort(all, new Comparator<ALink>() {
+ public int compare(ALink l1, ALink l2) {
+ final double diff = lengths.get(l1) - lengths.get(l2);
+ return (int) Math.signum(diff);
+ }
+ });
+ return all;
+ }
+
+ private MyCurve getCurveLink(final ANodePoint p1, final ANodePoint p2, RectanglesCollection forbidden) {
+ final int x1 = p1.getPosition().getXint();
+ final int y1 = p1.getPosition().getYint();
+ final int x2 = p2.getPosition().getXint();
+ final int y2 = p2.getPosition().getYint();
+ final CubicCurve2D.Double curve = new CubicCurve2D.Double(x1, y1, x1, y1, x2, y2, x2, y2);
+ final MyCurve result = new MyCurve(curve);
+ if (result.intersects(forbidden) || result.intersects(alreadyCurve)) {
+ final CubicCurveFactory factory = new CubicCurveFactory(p1.getPosition(), p2.getPosition());
+ for (Rectangle2D.Double r : forbidden) {
+ factory.addForbidden(r);
+ }
+ for (MyCurve c : alreadyCurve) {
+ factory.addForbidden(c);
+ }
+ return factory.getCubicCurve2D();
+
+ }
+ return result;
+ }
+
+ private RectanglesCollection getForbidden(ALink link) {
+ final RectanglesCollection result = new RectanglesCollection();
+ for (Map.Entry<ANode, ANodePoint> entry : nodePoints.entrySet()) {
+ final ANode node = entry.getKey();
+ if (link.getNode1().equals(node) || link.getNode2().equals(node)) {
+ continue;
+ }
+ final ANodePoint nodePoints = entry.getValue();
+ final Frame frame = frames.get(nodePoints);
+ result.add(new Rectangle2D.Double(frame.getX(), frame.getY(), frame.getWidth(), frame.getHeight()));
+ }
+
+ return result;
+ }
+
+ private AbstractEntityImage getImage(ANode n) {
+ return new EntityImageFactory().createEntityImage((IEntity) n.getUserData());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graph/Graph5.java b/src/net/sourceforge/plantuml/graph/Graph5.java
new file mode 100644
index 0000000..672a650
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph/Graph5.java
@@ -0,0 +1,191 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Line2D;
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.EmptyImageBuilder;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.graph2.IInflationTransform;
+import net.sourceforge.plantuml.graph2.InflationTransform2;
+import net.sourceforge.plantuml.graph2.Plan;
+import net.sourceforge.plantuml.graph2.Polyline2;
+import net.sourceforge.plantuml.graphic.StringBounderUtils;
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+
+public class Graph5 {
+
+ final private static Graphics2D dummyGraphics2D;
+
+ private final int spaceWidth = 40;
+ private final int spaceHeight = 40;
+
+ private final double margin = 20;
+ private final Board board;
+
+ private int maxRow;
+ private int maxCol;
+
+ private final Plan plan = new Plan();
+ private final IInflationTransform inflationTransform = new InflationTransform2();
+ // private final IInflationTransform inflationTransform = new
+ // IdentityInflationTransform();
+
+ static {
+ final EmptyImageBuilder builder = new EmptyImageBuilder(10, 10, Color.WHITE);
+ dummyGraphics2D = builder.getGraphics2D();
+ }
+
+ private AbstractEntityImage getImage(ANode n) {
+ return new EntityImageFactory().createEntityImage((IEntity) n.getUserData());
+ }
+
+ public Graph5(Board board) {
+ board.normalize();
+ this.board = board;
+ for (ANode n : board.getNodes()) {
+ maxRow = Math.max(maxRow, n.getRow());
+ maxCol = Math.max(maxCol, board.getCol(n));
+ final Point2D.Double pos = getPosition(n);
+ plan.addPoint2D(pos);
+ // Log.println("n=" + n + " pos=" + pos);
+ }
+ for (ANode n : board.getNodes()) {
+ final AbstractEntityImage image = getImage(n);
+ final Point2D.Double pos = getPosition(n);
+ final int widthCell = (int) image.getDimension(StringBounderUtils.asStringBounder(dummyGraphics2D))
+ .getWidth() + 20;
+ final int heightCell = (int) image.getDimension(StringBounderUtils.asStringBounder(dummyGraphics2D))
+ .getHeight() + 20;
+ inflationTransform.addInflationX(pos.getX(), widthCell);
+ inflationTransform.addInflationY(pos.getY(), heightCell);
+ }
+
+ // Log.println("inflationTransform=" + inflationTransform);
+
+ }
+
+ public Point2D.Double getPosition(ANode node) {
+ return new Point2D.Double(board.getCol(node) * spaceWidth, node.getRow() * spaceHeight);
+ }
+
+ public Dimension2D getDimension() {
+ final double width = spaceWidth * maxCol;
+ final int height = spaceWidth * maxRow;
+ return new Dimension2DDouble(width + 2 * margin + inflationTransform.getTotalInflationX(), height + 2 * margin
+ + inflationTransform.getTotalInflationY());
+
+ }
+
+ public void draw(final Graphics2D g2d) {
+ g2d.translate(margin, margin);
+ g2d.setColor(Color.BLUE);
+
+ for (ALink link : getSortedLinks()) {
+ final Point2D start = getPosition(link.getNode1());
+ final Point2D end = getPosition(link.getNode2());
+
+ final List<Line2D.Double> lines = buildPath(start, end);
+ final Polyline2 polyline = buildPolyline(start, end, lines);
+ polyline.draw(g2d);
+ }
+
+ for (ANode n : board.getNodes()) {
+ final AbstractEntityImage image = getImage(n);
+ Point2D pos = getPosition(n);
+ pos = inflationTransform.inflatePoint2D(pos);
+ final double x = pos.getX() - image.getDimension(StringBounderUtils.asStringBounder(g2d)).getWidth() / 2;
+ final double y = pos.getY() - image.getDimension(StringBounderUtils.asStringBounder(g2d)).getHeight() / 2;
+ g2d.translate(x, y);
+ image.draw(new ColorMapperIdentity(), g2d);
+ g2d.translate(-x, -y);
+ }
+
+ }
+
+ private Polyline2 buildPolyline(final Point2D start, final Point2D end, final List<Line2D.Double> lines) {
+ final Polyline2 polyline = new Polyline2(inflationTransform.inflatePoint2D(start), inflationTransform
+ .inflatePoint2D(end));
+ final List<Line2D.Double> list = inflationTransform.inflate(lines);
+ for (Line2D.Double l1 : list) {
+ polyline.addLine(l1);
+ }
+ return polyline;
+ }
+
+ private List<Line2D.Double> buildPath(final Point2D start, final Point2D end) {
+ Point2D current = start;
+ final List<Point2D.Double> interm = plan.getIntermediatePoints(start, end);
+ final List<Line2D.Double> lines = new ArrayList<Line2D.Double>();
+ for (final Point2D.Double inter : interm) {
+ plan.addPoint2D(inter);
+ lines.add(new Line2D.Double(current, inter));
+ plan.createLink(current, inter);
+ current = inter;
+ }
+ lines.add(new Line2D.Double(current, end));
+ plan.createLink(current, end);
+ return lines;
+ }
+
+ private List<ALink> getSortedLinks() {
+ final Map<ALink, Double> lengths = new LinkedHashMap<ALink, Double>();
+ for (ALink link : board.getLinks()) {
+ final Point2D.Double p1 = getPosition(link.getNode1());
+ final Point2D.Double p2 = getPosition(link.getNode2());
+ lengths.put(link, p1.distance(p2));
+ }
+ final List<ALink> all = new ArrayList<ALink>(lengths.keySet());
+ Collections.sort(all, new Comparator<ALink>() {
+ public int compare(ALink l1, ALink l2) {
+ final double diff = lengths.get(l1) - lengths.get(l2);
+ return (int) Math.signum(diff);
+ }
+ });
+ return all;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graph/Heap.java b/src/net/sourceforge/plantuml/graph/Heap.java
new file mode 100644
index 0000000..bbff0f5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph/Heap.java
@@ -0,0 +1,241 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+public class Heap {
+
+ private final Map<String, ANode> nodes = new LinkedHashMap<String, ANode>();
+ private final Map<ANode, LinkedHashMap<ANode, ALink>> directChildren = new LinkedHashMap<ANode, LinkedHashMap<ANode, ALink>>();
+ private final List<ALink> links = new ArrayList<ALink>();
+
+ public boolean isEmpty() {
+ if (links.isEmpty()) {
+ assert nodes.isEmpty();
+ assert directChildren.isEmpty();
+ return true;
+ }
+ return false;
+ }
+
+ public void importing(ANode under, ANode otherRoot, Heap otherHeap, int diffHeight, Object userData) {
+ assert this.directChildren.keySet().contains(under);
+ assert this.nodes.values().contains(under);
+ assert otherHeap.nodes.values().contains(otherRoot);
+ assert otherHeap.directChildren.keySet().contains(otherRoot);
+ assert this.nodes.values().contains(otherRoot) == false;
+ assert this.directChildren.keySet().contains(otherRoot) == false;
+ assert otherHeap.directChildren.keySet().contains(under) == false;
+ final int oldSize = this.nodes.size();
+ assert oldSize == this.directChildren.size();
+ this.nodes.putAll(otherHeap.nodes);
+ this.directChildren.putAll(otherHeap.directChildren);
+ final ALinkImpl link = new ALinkImpl(under, otherRoot, diffHeight, userData);
+ this.links.add(link);
+ this.links.addAll(otherHeap.links);
+ assert oldSize + otherHeap.nodes.size() == this.nodes.size();
+ assert oldSize + otherHeap.directChildren.size() == this.directChildren.size();
+
+ addUnderMe(under, otherRoot, link);
+ }
+
+ public void computeRows() {
+ for (ANode n : nodes.values()) {
+ n.setRow(Integer.MIN_VALUE);
+ }
+ nodes.values().iterator().next().setRow(0);
+ boolean changed;
+ do {
+ onePass();
+ changed = false;
+ for (ANode n : nodes.values()) {
+ if (n.getRow() != Integer.MIN_VALUE) {
+ continue;
+ }
+ final Map.Entry<ANode, ALink> smallestRowOfChildren = getSmallestRowOfChildren(n);
+ if (smallestRowOfChildren != null) {
+ n.setRow(getStartingRow(smallestRowOfChildren));
+ }
+ changed = true;
+ }
+ } while (changed);
+
+ minToZero();
+ }
+
+ private int getStartingRow(Map.Entry<ANode, ALink> ent) {
+ assert ent.getValue().getNode2() == ent.getKey();
+ return ent.getValue().getNode2().getRow() - ent.getValue().getDiffHeight();
+ }
+
+ private void minToZero() {
+ int min = Integer.MAX_VALUE;
+ for (ANode n : nodes.values()) {
+ min = Math.min(min, n.getRow());
+ }
+ if (min == Integer.MIN_VALUE) {
+ throw new IllegalStateException();
+ }
+ if (min != 0) {
+ for (ANode n : nodes.values()) {
+ n.setRow(n.getRow() - min);
+ }
+ }
+
+ }
+
+ private Map.Entry<ANode, ALink> getSmallestRowOfChildren(ANode n) {
+ assert n.getRow() == Integer.MIN_VALUE;
+ Map.Entry<ANode, ALink> result = null;
+ for (Map.Entry<ANode, ALink> ent : directChildren.get(n).entrySet()) {
+ final ANode child = ent.getKey();
+ if (child.getRow() == Integer.MIN_VALUE) {
+ continue;
+ }
+ if (result == null || getStartingRow(ent) < getStartingRow(result)) {
+ result = ent;
+ }
+ }
+ // assert result != null;
+ return result;
+ }
+
+ private void onePass() {
+ boolean changed;
+ do {
+ changed = false;
+ for (ANode n : nodes.values()) {
+ final int row = n.getRow();
+ if (row == Integer.MIN_VALUE) {
+ continue;
+ }
+ for (Map.Entry<ANode, ALink> ent : directChildren.get(n).entrySet()) {
+ final ANode child = ent.getKey();
+ final int diffHeight = ent.getValue().getDiffHeight();
+ if (child.getRow() == Integer.MIN_VALUE || child.getRow() < row + diffHeight) {
+ child.setRow(row + diffHeight);
+ changed = true;
+ }
+ }
+ }
+ } while (changed);
+ }
+
+ private ANode getNode(String code) {
+ ANode result = nodes.get(code);
+ if (result == null) {
+ result = createNewNode(code);
+ }
+ return result;
+ }
+
+ private ANode createNewNode(String code) {
+ final ANode result = new ANodeImpl(code);
+ directChildren.put(result, new LinkedHashMap<ANode, ALink>());
+ nodes.put(code, result);
+ assert directChildren.size() == nodes.size();
+ return result;
+ }
+
+ public ANode getExistingNode(String code) {
+ return nodes.get(code);
+ }
+
+ public List<ALink> getLinks() {
+ return Collections.unmodifiableList(links);
+ }
+
+ public List<ANode> getNodes() {
+ return Collections.unmodifiableList(new ArrayList<ANode>(nodes.values()));
+ }
+
+ HashSet<ANode> getAllChildren(ANode n) {
+ final HashSet<ANode> result = new HashSet<ANode>(directChildren.get(n).keySet());
+ int size = 0;
+ do {
+ size = result.size();
+ for (ANode other : new HashSet<ANode>(result)) {
+ result.addAll(getAllChildren(other));
+ }
+ } while (result.size() != size);
+ return result;
+ }
+
+ public void addLink(String stringLink, int diffHeight, Object userData) {
+ final LinkString l = new LinkString(stringLink);
+ final ANode n1 = getNode(l.getNode1());
+ final ANode n2 = getNode(l.getNode2());
+ if (n1 == n2) {
+ return;
+ }
+ final ALinkImpl link = new ALinkImpl(n1, n2, diffHeight, userData);
+ links.add(link);
+
+ if (getAllChildren(n2).contains(n1)) {
+ addUnderMe(n2, n1, link);
+ } else {
+ addUnderMe(n1, n2, link);
+ }
+ }
+
+ public ANode addNode(String code) {
+ if (nodes.containsKey(code)) {
+ throw new IllegalArgumentException();
+ }
+ return createNewNode(code);
+ }
+
+ private void addUnderMe(final ANode n1, final ANode n2, final ALinkImpl link) {
+ assert getAllChildren(n2).contains(n1) == false;
+ directChildren.get(n1).put(n2, link);
+ assert getAllChildren(n1).contains(n2);
+ assert getAllChildren(n2).contains(n1) == false;
+ }
+
+ public int getRowMax() {
+ int max = Integer.MIN_VALUE;
+ for (ANode n : nodes.values()) {
+ max = Math.max(max, n.getRow());
+ }
+ return max;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graph/KenavoCostComputer.java b/src/net/sourceforge/plantuml/graph/KenavoCostComputer.java
new file mode 100644
index 0000000..1607781
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph/KenavoCostComputer.java
@@ -0,0 +1,77 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph;
+
+import net.sourceforge.plantuml.geom.LineSegmentInt;
+
+public class KenavoCostComputer implements CostComputer {
+
+ public double getCost(Board board) {
+ double result = 0;
+ for (ALink link1 : board.getLinks()) {
+ for (ALink link2 : board.getLinks()) {
+ result += getCost(board, link1, link2);
+ }
+ }
+ return result;
+ }
+
+ LineSegmentInt getLineSegment(Board board, ALink link) {
+ final ANode n1 = link.getNode1();
+ final ANode n2 = link.getNode2();
+ return new LineSegmentInt(board.getCol(n1), n1.getRow(), board.getCol(n2), n2.getRow());
+ }
+
+ private double getCost(Board board, ALink link1, ALink link2) {
+ final LineSegmentInt seg1 = getLineSegment(board, link1);
+ final LineSegmentInt seg2 = getLineSegment(board, link2);
+
+ final double len1 = getLength(link1, seg1, board);
+ final double len2 = getLength(link2, seg2, board);
+
+ return len1 * len2 * Math.exp(-seg1.getDistance(seg2));
+ }
+
+ private double getLength(ALink link, final LineSegmentInt seg, Board board) {
+ double coef = 1;
+ if (link.getNode1().getRow() == link.getNode2().getRow()
+ && board.getDirection(link) != board.getInitialDirection(link)) {
+ coef = 1.1;
+ }
+
+ return seg.getLength() * coef;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graph/LenghtLinkComparator.java b/src/net/sourceforge/plantuml/graph/LenghtLinkComparator.java
new file mode 100644
index 0000000..179571d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph/LenghtLinkComparator.java
@@ -0,0 +1,60 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph;
+
+import java.util.Comparator;
+import java.util.Map;
+
+public class LenghtLinkComparator implements Comparator<ALink> {
+
+ private final Map<ANode, Integer> cols;
+
+ public LenghtLinkComparator(Map<ANode, Integer> cols) {
+ this.cols = cols;
+ }
+
+ public int compare(ALink link1, ALink link2) {
+ return (int) Math.signum(getLenght(link1) - getLenght(link2));
+ }
+
+ private double getLenght(ALink link) {
+ final ANode n1 = link.getNode1();
+ final ANode n2 = link.getNode2();
+ final int deltaRow = n2.getRow() - n1.getRow();
+ final int deltaCol = cols.get(n2) - cols.get(n1);
+ return deltaRow * deltaRow + deltaCol * deltaCol;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graph/LinkString.java b/src/net/sourceforge/plantuml/graph/LinkString.java
new file mode 100644
index 0000000..a75562d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph/LinkString.java
@@ -0,0 +1,66 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+
+public class LinkString {
+
+ final private static Pattern p = MyPattern.cmpile("(.*)->(.*)");
+
+ final private String node1;
+ final private String node2;
+
+ public LinkString(String desc) {
+ final Matcher m = p.matcher(desc);
+ if (m.find() == false) {
+ throw new IllegalArgumentException();
+ }
+ node1 = m.group(1);
+ node2 = m.group(2);
+
+ }
+
+ public final String getNode1() {
+ return node1;
+ }
+
+ public final String getNode2() {
+ return node2;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graph/MethodsOrFieldsArea.java b/src/net/sourceforge/plantuml/graph/MethodsOrFieldsArea.java
new file mode 100644
index 0000000..cb37255
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph/MethodsOrFieldsArea.java
@@ -0,0 +1,97 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph;
+
+import java.awt.geom.Dimension2D;
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.SpriteContainerEmpty;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.Member;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.skin.VisibilityModifier;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class MethodsOrFieldsArea {
+
+ private final UFont font;
+ private final List<String> strings = new ArrayList<String>();
+
+ public MethodsOrFieldsArea(List<Member> attributes, UFont font) {
+ this.font = font;
+ for (Member att : attributes) {
+ this.strings.add(att.getDisplay(false));
+ }
+ }
+
+ public VisibilityModifier getVisibilityModifier() {
+ throw new UnsupportedOperationException();
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ double x = 0;
+ double y = 0;
+ for (String s : strings) {
+ final TextBlock bloc = createTextBlock(s);
+ final Dimension2D dim = bloc.calculateDimension(stringBounder);
+ y += dim.getHeight();
+ x = Math.max(dim.getWidth(), x);
+ }
+ return new Dimension2DDouble(x, y);
+ }
+
+ private TextBlock createTextBlock(String s) {
+ return TextBlockUtils.create(Display.create(s), new FontConfiguration(font, HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true),
+ HorizontalAlignment.LEFT, new SpriteContainerEmpty());
+ }
+
+ public void draw(UGraphic ug, double x, double y) {
+ for (String s : strings) {
+ final TextBlock bloc = createTextBlock(s);
+ bloc.drawU(ug.apply(new UTranslate(x, y)));
+ y += bloc.calculateDimension(ug.getStringBounder()).getHeight();
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graph/Move.java b/src/net/sourceforge/plantuml/graph/Move.java
new file mode 100644
index 0000000..03e0c52
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph/Move.java
@@ -0,0 +1,77 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph;
+
+public class Move {
+
+ private final int row;
+ private final int col;
+ private final int delta;
+
+ @Override
+ public String toString() {
+ return row + "." + col + "->" + row + "." + (col + delta);
+ }
+
+ public Move(int row, int col, int delta) {
+ if (delta != 1 && delta != -1) {
+ throw new IllegalArgumentException();
+ }
+ this.row = row;
+ this.col = col;
+ this.delta = delta;
+ }
+
+ public int getRow() {
+ return row;
+ }
+
+ public int getCol() {
+ return col;
+ }
+
+ public int getNewCol() {
+ return col + delta;
+ }
+
+ public int getDelta() {
+ return delta;
+ }
+
+ public Move getBackMove() {
+ return new Move(row, col + delta, -delta);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graph/Oven.java b/src/net/sourceforge/plantuml/graph/Oven.java
new file mode 100644
index 0000000..f91fc83
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph/Oven.java
@@ -0,0 +1,94 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph;
+
+import java.util.Random;
+
+public class Oven {
+
+ final private double temp;
+ final private CostComputer costComputer;
+
+ public Oven(double temp, CostComputer costComputer) {
+ this.temp = temp;
+ this.costComputer = costComputer;
+ }
+
+ public Board longTic(int nbTic, Board board, Random rnd) {
+ double best = costComputer.getCost(board);
+ Board bestBoard = board.copy();
+ for (int i = 0; i < nbTic; i++) {
+ final double current = tic(board, rnd);
+ // Log.println("current=" + current + " best=" + best);
+ if (current < best) {
+ best = current;
+ bestBoard = board.copy();
+ }
+
+ }
+ return bestBoard;
+ }
+
+ public double tic(Board board, Random rnd) {
+ // Log.println("Oven::tic");
+ final double costBefore = costComputer.getCost(board);
+ final Move move = null; // board.getRandomMove(rnd);
+ board.applyMove(move);
+ final double costAfter = costComputer.getCost(board);
+ final double delta = costAfter - costBefore;
+ // Log.println("delta=" + delta);
+ if (delta <= 0) {
+ return costAfter;
+ }
+ assert delta > 0;
+ assert costAfter > costBefore;
+ // Log.println("temp=" + temp);
+ if (temp > 0) {
+ final double probability = Math.exp(-delta / temp);
+ final double dice = rnd.nextDouble();
+ // Log.println("probability=" + probability + " dice=" +
+ // dice);
+ if (dice < probability) {
+ // Log.println("We keep it");
+ return costAfter;
+ }
+ }
+ // Log.println("Roolback");
+ board.applyMove(move.getBackMove());
+ assert costBefore == costComputer.getCost(board);
+ return costBefore;
+
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graph/SimpleCostComputer.java b/src/net/sourceforge/plantuml/graph/SimpleCostComputer.java
new file mode 100644
index 0000000..1b036d9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph/SimpleCostComputer.java
@@ -0,0 +1,59 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph;
+
+public class SimpleCostComputer implements CostComputer {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sourceforge.plantuml.graph.CostComputer#getCost(net.sourceforge.plantuml.graph.Board)
+ */
+ public double getCost(Board board) {
+ double result = 0;
+ for (ALink link : board.getLinks()) {
+ final ANode n1 = link.getNode1();
+ final ANode n2 = link.getNode2();
+ final int x1 = board.getCol(n1);
+ final int y1 = n1.getRow();
+ final int x2 = board.getCol(n2);
+ final int y2 = n2.getRow();
+ result += Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
+
+ }
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graph/SortedCollection.java b/src/net/sourceforge/plantuml/graph/SortedCollection.java
new file mode 100644
index 0000000..d38196e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph/SortedCollection.java
@@ -0,0 +1,45 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph;
+
+public interface SortedCollection<S extends Comparable<S>> extends Iterable<S> {
+
+ int size();
+
+ void add(S entry);
+
+ boolean contains(S entry);
+
+}
diff --git a/src/net/sourceforge/plantuml/graph/SortedCollectionArrayList.java b/src/net/sourceforge/plantuml/graph/SortedCollectionArrayList.java
new file mode 100644
index 0000000..ff146b0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph/SortedCollectionArrayList.java
@@ -0,0 +1,88 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+public class SortedCollectionArrayList<S extends Comparable<S>> implements SortedCollection<S> {
+
+ private final List<S> allAsList = new ArrayList<S>();
+ private final Set<S> allAsSet = new HashSet<S>();
+
+ public Iterator<S> iterator() {
+ return allAsList.iterator();
+ }
+
+ public void add(S newEntry) {
+ final int r = Collections.binarySearch(allAsList, newEntry);
+ if (r >= 0) {
+ allAsList.add(r, newEntry);
+ } else {
+ allAsList.add(-1 - r, newEntry);
+ }
+ allAsSet.add(newEntry);
+ assert isSorted();
+ }
+
+ public int size() {
+ assert allAsSet.size() == allAsList.size();
+ return allAsList.size();
+ }
+
+ List<S> toList() {
+ return new ArrayList<S>(allAsList);
+ }
+
+ boolean isSorted() {
+ S before = null;
+ for (S ent : allAsList) {
+ if (before != null && ent.compareTo(before) < 0) {
+ return false;
+ }
+ before = ent;
+ }
+ return true;
+ }
+
+ public boolean contains(S entry) {
+ return allAsSet.contains(entry);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graph/SortedCollectionLinked.java b/src/net/sourceforge/plantuml/graph/SortedCollectionLinked.java
new file mode 100644
index 0000000..fe34b93
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph/SortedCollectionLinked.java
@@ -0,0 +1,88 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
+
+public class SortedCollectionLinked<S extends Comparable<S>> implements SortedCollection<S> {
+
+ private final List<S> all = new LinkedList<S>();
+
+ public Iterator<S> iterator() {
+ return all.iterator();
+ }
+
+ public void add(S newEntry) {
+ for (final ListIterator<S> it = all.listIterator(); it.hasNext();) {
+ final S cur = it.next();
+ if (cur.compareTo(newEntry) >= 0) {
+ it.previous();
+ it.add(newEntry);
+ assert isSorted();
+ return;
+ }
+ }
+ all.add(newEntry);
+ assert isSorted();
+ }
+
+ public int size() {
+ return all.size();
+ }
+
+ List<S> toList() {
+ return new ArrayList<S>(all);
+ }
+
+ boolean isSorted() {
+ S before = null;
+ for (S ent : all) {
+ if (before != null && ent.compareTo(before) < 0) {
+ return false;
+ }
+ before = ent;
+ }
+ return true;
+ }
+
+ public boolean contains(S entry) {
+ return all.contains(entry);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graph/Zoda1.java b/src/net/sourceforge/plantuml/graph/Zoda1.java
new file mode 100644
index 0000000..52c866f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph/Zoda1.java
@@ -0,0 +1,167 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @deprecated
+ *
+ */
+public class Zoda1 {
+
+ private final Map<String, ANodeImpl> nodes = new LinkedHashMap<String, ANodeImpl>();
+ private final List<ALink> links = new ArrayList<ALink>();
+
+ public ANodeImpl getNode(String code) {
+ ANodeImpl result = nodes.get(code);
+ if (result == null) {
+ result = new ANodeImpl(code);
+ nodes.put(code, result);
+ }
+ return result;
+ }
+
+ public ANodeImpl getExistingNode(String code) {
+ return nodes.get(code);
+ }
+
+ public List<ALink> getLinks() {
+ return Collections.unmodifiableList(links);
+ }
+
+ public List<ANode> getNodes() {
+ return Collections.unmodifiableList(new ArrayList<ANode>(nodes.values()));
+ }
+
+ public void addLink(String link) {
+ final LinkString l = new LinkString(link);
+ final ANodeImpl n1 = getNode(l.getNode1());
+ final ANodeImpl n2 = getNode(l.getNode2());
+ links.add(new ALinkImpl(n1, n2, 1, null));
+ }
+
+ public void computeRows() {
+ getNodes().get(0).setRow(0);
+
+ for (int i = 0; i < links.size(); i++) {
+ oneStep1();
+ oneStep2();
+ }
+
+ removeUnplacedNodes();
+ }
+
+ private void removeUnplacedNodes() {
+ for (final Iterator<ANodeImpl> it = nodes.values().iterator(); it.hasNext();) {
+ final ANodeImpl n = it.next();
+ if (n.getRow() == Integer.MIN_VALUE) {
+ removeLinksOf(n);
+ it.remove();
+ }
+ }
+
+ }
+
+ private void removeLinksOf(ANodeImpl n) {
+ for (final Iterator<ALink> it = links.iterator(); it.hasNext();) {
+ final ALink link = it.next();
+ if (link.getNode1() == n || link.getNode2() == n) {
+ it.remove();
+ }
+ }
+
+ }
+
+ public int getRowMax() {
+ int max = 0;
+ for (ANode n : getNodes()) {
+ if (n.getRow() == Integer.MIN_VALUE) {
+ return Integer.MIN_VALUE;
+ }
+ if (n.getRow() > max) {
+ max = n.getRow();
+ }
+ }
+ return max;
+ }
+
+ private void oneStep1() {
+ for (ALink link : links) {
+ final ANode n1 = link.getNode1();
+ if (n1.getRow() == Integer.MIN_VALUE) {
+ continue;
+ }
+ final ANode n2 = link.getNode2();
+ if (n2.getRow() == Integer.MIN_VALUE) {
+ n2.setRow(n1.getRow() + 1);
+ } else if (n2.getRow() < n1.getRow() + 1) {
+ n2.setRow(n1.getRow() + 1);
+ }
+ }
+ }
+
+ private void oneStep2() {
+ for (ALink link : links) {
+ final ANode n1 = link.getNode1();
+ final ANode n2 = link.getNode2();
+ if (n1.getRow() == Integer.MIN_VALUE && n2.getRow() != Integer.MIN_VALUE) {
+ if (n2.getRow() == 0) {
+ allDown();
+ }
+ final int row = n2.getRow() - 1;
+ if (row == -1) {
+ throw new UnsupportedOperationException();
+ }
+ n1.setRow(row);
+ }
+ }
+ }
+
+ private void allDown() {
+ for (ANodeImpl n : nodes.values()) {
+ if (n.getRow() != Integer.MIN_VALUE) {
+ n.setRow(n.getRow() + 1);
+ }
+ }
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graph/Zoda2.java b/src/net/sourceforge/plantuml/graph/Zoda2.java
new file mode 100644
index 0000000..4314268
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph/Zoda2.java
@@ -0,0 +1,125 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class Zoda2 {
+
+ private final Map<ANode, Heap> heaps = new LinkedHashMap<ANode, Heap>();
+
+ public ANode getNode(String code) {
+ for (ANode n : heaps.keySet()) {
+ if (n.getCode().equals(code)) {
+ return n;
+ }
+ }
+ return null;
+ }
+
+ public ANode createAloneNode(String code) {
+ if (getNode(code) != null) {
+ throw new IllegalArgumentException();
+ }
+ final Heap h = new Heap();
+ final ANode n = h.addNode(code);
+ heaps.put(n, h);
+ return n;
+ }
+
+ public List<? extends ANode> getNodes() {
+ return Collections.unmodifiableList(new ArrayList<ANode>(heaps.keySet()));
+ }
+
+ public Set<Heap> getHeaps() {
+ return new HashSet<Heap>(heaps.values());
+ }
+
+ public void addLink(String link, int diffHeight, Object userData) {
+ final LinkString l;
+ try {
+ l = new LinkString(link);
+ } catch (IllegalArgumentException e) {
+ e.printStackTrace();
+ return;
+ }
+ final ANode n1 = getNode(l.getNode1());
+ final ANode n2 = getNode(l.getNode2());
+ final Heap h1 = n1 == null ? null : heaps.get(n1);
+ final Heap h2 = n2 == null ? null : heaps.get(n2);
+ assert h1 == null || h1.isEmpty() == false;
+ assert h2 == null || h2.isEmpty() == false;
+ if (h1 == null && h2 == null) {
+ final Heap h = new Heap();
+ h.addLink(link, diffHeight, userData);
+ recordHeap(h);
+ } else if (h1 == h2) {
+ assert h1 != null && h2 != null;
+ h1.addLink(link, diffHeight, userData);
+ } else if (h1 == null) {
+ h2.addLink(link, diffHeight, userData);
+ recordHeap(h2);
+ } else if (h2 == null) {
+ h1.addLink(link, diffHeight, userData);
+ recordHeap(h1);
+ } else {
+ assert h1 != null && h2 != null;
+ assert h1.getNodes().contains(n1);
+ h1.importing(n1, n2, h2, diffHeight, userData);
+ recordHeap(h1);
+ assert heapMerged(h1, h2);
+ }
+ }
+
+ private boolean heapMerged(final Heap destination, final Heap source) {
+ for (ANode n : source.getNodes()) {
+ assert heaps.get(n) == destination;
+ }
+ return true;
+ }
+
+ private void recordHeap(final Heap h) {
+ for (ANode n : h.getNodes()) {
+ heaps.put((ANodeImpl) n, h);
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graph2/CubicCurveFactory.java b/src/net/sourceforge/plantuml/graph2/CubicCurveFactory.java
new file mode 100644
index 0000000..875adfb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph2/CubicCurveFactory.java
@@ -0,0 +1,96 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph2;
+
+import java.awt.geom.CubicCurve2D;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+public class CubicCurveFactory {
+
+ private final Point2D.Double start;
+ private final Point2D.Double end;
+ private final RectanglesCollection forbiddenRect = new RectanglesCollection();
+ private final List<MyCurve> forbiddenCurves = new ArrayList<MyCurve>();
+
+ public CubicCurveFactory(Point2D start, Point2D end) {
+ this.start = new Point2D.Double(start.getX(), start.getY());
+ this.end = new Point2D.Double(end.getX(), end.getY());
+ }
+
+ public void addForbidden(Rectangle2D.Double rect) {
+ forbiddenRect.add(rect);
+ }
+
+ public void addForbidden(MyCurve curve) {
+ forbiddenCurves.add(curve);
+ }
+
+ public MyCurve getCubicCurve2D() {
+ MyCurve result = new MyCurve(new CubicCurve2D.Double(start.getX(), start.getY(), start.getX(), start.getY(),
+ end.getX(), end.getY(), end.getX(), end.getY()));
+ if (result.intersects(forbiddenRect) || result.intersects(forbiddenCurves)) {
+ final Set<Point2D.Double> all = new HashSet<Point2D.Double>();
+ all.addAll(MagicPointsFactory.get(start, end));
+ for (Rectangle2D.Double rect : forbiddenRect) {
+ all.addAll(MagicPointsFactory.get(rect));
+ }
+// Log.println("s1 " + all.size());
+// final long t1 = System.currentTimeMillis();
+ double min = Double.MAX_VALUE;
+ for (Point2D.Double p1 : all) {
+ for (Point2D.Double p2 : all) {
+ final MyCurve me = new MyCurve(new CubicCurve2D.Double(start.getX(), start.getY(), p1.getX(), p1
+ .getY(), p2.getX(), p2.getY(), end.getX(), end.getY()));
+ if (me.getLenght() < min && me.intersects(forbiddenRect) == false
+ && me.intersects(forbiddenCurves) == false) {
+ result = me;
+ min = me.getLenght();
+ }
+ }
+ }
+// final long t2 = System.currentTimeMillis() - t1;
+// Log.println("s2 = " + t2);
+// Log.println("TPS1 = " + RectanglesCollection.TPS1);
+// Log.println("TPS2 = " + RectanglesCollection.TPS2);
+ }
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graph2/Dijkstra.java b/src/net/sourceforge/plantuml/graph2/Dijkstra.java
new file mode 100644
index 0000000..38b9da3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph2/Dijkstra.java
@@ -0,0 +1,155 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph2;
+
+/*
+ * Copyright (c) 2009 the authors listed at the following URL, and/or the
+ * authors of referenced articles or incorporated external code:
+ * http://en.literateprograms.org/Dijkstra's_algorithm_(Java)?action=history&offset=20081113161332
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Retrieved from:
+ * http://en.literateprograms.org/Dijkstra's_algorithm_(Java)?oldid=15444
+ */
+
+// http://www.google.fr/search?hl=fr&source=hp&q=A+star+java&btnG=Recherche+Google&meta=&aq=f&oq=
+// http://www.edenwaith.com/products/pige/tutorials/a-star.php
+import java.util.ArrayList;
+import java.util.List;
+import java.util.PriorityQueue;
+
+public class Dijkstra {
+
+ static class Vertex implements Comparable<Vertex> {
+ private final Object data;
+ private final List<Edge> adjacencies = new ArrayList<Edge>();
+ private double minDistance = Double.POSITIVE_INFINITY;
+ private Vertex previous;
+
+ Vertex(Object data) {
+ this.data = data;
+ }
+
+ public void addAdjacencies(Vertex target, double dist) {
+ if (target == null) {
+ throw new IllegalArgumentException();
+ }
+ adjacencies.add(new Edge(target, dist));
+ }
+
+ public String toString() {
+ return "[ " + data.toString() + " (" + minDistance + ") ] ";
+ }
+
+ public int compareTo(Vertex other) {
+ return Double.compare(minDistance, other.minDistance);
+ }
+
+ public final Object getData() {
+ return data;
+ }
+
+ }
+
+ static class Edge {
+ private final Vertex target;
+ private final double weight;
+
+ Edge(Vertex argTarget, double argWeight) {
+ target = argTarget;
+ weight = argWeight;
+ }
+ }
+
+ private final List<Vertex> vertices = new ArrayList<Vertex>();
+
+ public Vertex addVertex(Object data) {
+ final Vertex v = new Vertex(data);
+ vertices.add(v);
+ return v;
+ }
+
+ private void computePaths(Vertex source) {
+ source.minDistance = 0.;
+ final PriorityQueue<Vertex> vertexQueue = new PriorityQueue<Vertex>();
+ vertexQueue.add(source);
+
+ while (vertexQueue.isEmpty() == false) {
+ final Vertex u = vertexQueue.poll();
+
+ // Visit each edge exiting u
+ for (Edge e : u.adjacencies) {
+ final Vertex v = e.target;
+ final double weight = e.weight;
+ final double distanceThroughU = u.minDistance + weight;
+ if (distanceThroughU < v.minDistance) {
+ vertexQueue.remove(v);
+
+ v.minDistance = distanceThroughU;
+ v.previous = u;
+ vertexQueue.add(v);
+ }
+ }
+ }
+ }
+
+ public List<Vertex> getShortestPathTo(Vertex source, Vertex target) {
+ computePaths(source);
+ final List<Vertex> path = new ArrayList<Vertex>();
+ for (Vertex vertex = target; vertex != null; vertex = vertex.previous) {
+ path.add(0, vertex);
+ }
+
+ return path;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graph2/GeomUtils.java b/src/net/sourceforge/plantuml/graph2/GeomUtils.java
new file mode 100644
index 0000000..676f6d2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph2/GeomUtils.java
@@ -0,0 +1,156 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph2;
+
+import java.awt.Graphics2D;
+import java.awt.geom.Line2D;
+import java.awt.geom.Point2D;
+
+public class GeomUtils {
+
+ public static Point2D translate(Point2D pt, double deltaX, double deltaY) {
+ return new Point2D.Double(pt.getX() + deltaX, pt.getY() + deltaY);
+ }
+
+ static public boolean isHorizontal(Line2D.Double seg) {
+ return seg.getP1().getY() == seg.getP2().getY();
+ }
+
+ static public boolean isVertical(Line2D.Double seg) {
+ return seg.getP1().getX() == seg.getP2().getX();
+ }
+
+ static public double getMinX(Line2D.Double seg) {
+ return Math.min(seg.x1, seg.x2);
+ }
+
+ static public double getMaxX(Line2D.Double seg) {
+ return Math.max(seg.x1, seg.x2);
+ }
+
+ static public double getMinY(Line2D.Double seg) {
+ return Math.min(seg.y1, seg.y2);
+ }
+
+ static public double getMaxY(Line2D.Double seg) {
+ return Math.max(seg.y1, seg.y2);
+ }
+
+ static public Point2D.Double getPoint2D(Line2D.Double line, double u) {
+ final double x = line.x1 + u * (line.x2 - line.x1);
+ final double y = line.y1 + u * (line.y2 - line.y1);
+ return new Point2D.Double(x, y);
+ }
+
+ private static boolean isBetween(double value, double v1, double v2) {
+ if (v1 < v2) {
+ return value >= v1 && value <= v2;
+ }
+ assert v2 <= v1;
+ return value >= v2 && value <= v1;
+
+ }
+
+ static boolean isBetween(Point2D toTest, Point2D pos1, Point2D pos2) {
+ return isBetween(toTest.getX(), pos1.getX(), pos2.getX()) && isBetween(toTest.getY(), pos1.getY(), pos2.getY());
+ }
+
+ static private double getIntersectionVertical(Line2D.Double line, double xOther) {
+ final double coef = line.x2 - line.x1;
+ if (coef == 0) {
+ return java.lang.Double.NaN;
+ }
+ return (xOther - line.x1) / coef;
+ }
+
+ static private double getIntersectionHorizontal(Line2D.Double line, double yOther) {
+ final double coef = line.y2 - line.y1;
+ if (coef == 0) {
+ return java.lang.Double.NaN;
+ }
+ return (yOther - line.y1) / coef;
+ }
+
+ static public Point2D.Double getSegIntersection(Line2D.Double line1, Line2D.Double line2) {
+ final double u;
+ if (isVertical(line2)) {
+ u = getIntersectionVertical(line1, line2.getP1().getX());
+ } else if (isHorizontal(line2)) {
+ u = getIntersectionHorizontal(line1, line2.getP1().getY());
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ if (java.lang.Double.isNaN(u) || u < 0 || u > 1) {
+ return null;
+ }
+ final Point2D.Double result = getPoint2D(line1, u);
+ if (isBetween(result, line2.getP1(), line2.getP2())) {
+ return result;
+ }
+ return null;
+ }
+
+ public static String toString(Line2D line) {
+ // return line.getP1() + "-" + line.getP2();
+ return toString(line.getP1()) + "-" + toString(line.getP2());
+ }
+
+ public static String toString(Point2D pt) {
+ return "[" + pt.getX() + "," + pt.getY() + "]";
+ }
+
+ public static Point2D.Double getCenter(Line2D.Double l) {
+ final double x = (l.getX1() + l.getX2()) / 2;
+ final double y = (l.getY1() + l.getY2()) / 2;
+ return new Point2D.Double(x, y);
+ }
+
+ public static void fillPoint2D(Graphics2D g2d, Point2D pt) {
+ final int x = (int) pt.getX() - 1;
+ final int y = (int) pt.getY() - 1;
+ g2d.fillOval(x, y, 3, 3);
+ }
+
+ public static double getOrthoDistance(Line2D.Double seg, Point2D pt) {
+ if (isHorizontal(seg)) {
+ return Math.abs(seg.getP1().getY() - pt.getY());
+ }
+ if (isVertical(seg)) {
+ return Math.abs(seg.getP1().getX() - pt.getX());
+ }
+ throw new IllegalArgumentException();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graph2/IInflationTransform.java b/src/net/sourceforge/plantuml/graph2/IInflationTransform.java
new file mode 100644
index 0000000..50668c8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph2/IInflationTransform.java
@@ -0,0 +1,56 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph2;
+
+import java.awt.geom.Line2D;
+import java.awt.geom.Point2D;
+import java.util.Collection;
+import java.util.List;
+
+public interface IInflationTransform {
+
+ void addInflationX(double xpos, double inflation);
+
+ void addInflationY(double ypos, double inflation);
+
+ double getTotalInflationX();
+
+ double getTotalInflationY();
+
+ Point2D inflatePoint2D(Point2D point);
+
+ List<Line2D.Double> inflate(Collection<Line2D.Double> segments);
+
+}
diff --git a/src/net/sourceforge/plantuml/graph2/IdentityInflationTransform.java b/src/net/sourceforge/plantuml/graph2/IdentityInflationTransform.java
new file mode 100644
index 0000000..b375f63
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph2/IdentityInflationTransform.java
@@ -0,0 +1,69 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph2;
+
+import java.awt.geom.Line2D;
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+public class IdentityInflationTransform implements IInflationTransform {
+
+ public void addInflationX(double xpos, double inflation) {
+
+ }
+
+ public void addInflationY(double ypos, double inflation) {
+
+ }
+
+ public double getTotalInflationX() {
+ return 0;
+ }
+
+ public double getTotalInflationY() {
+ return 0;
+ }
+
+ public Point2D inflatePoint2D(Point2D point) {
+ return point;
+ }
+
+ public List<Line2D.Double> inflate(Collection<Line2D.Double> segments) {
+ return new ArrayList<Line2D.Double>(segments);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graph2/InflateData2.java b/src/net/sourceforge/plantuml/graph2/InflateData2.java
new file mode 100644
index 0000000..485c618
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph2/InflateData2.java
@@ -0,0 +1,125 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph2;
+
+public class InflateData2 implements Comparable<InflateData2> {
+
+ private final double pos;
+ private final double inflation;
+
+ public InflateData2(double pos, double inflation) {
+ this.pos = pos;
+ this.inflation = inflation;
+ }
+
+ public final double getPos() {
+ return pos;
+ }
+
+ public final double getInflation() {
+ return inflation;
+ }
+
+ public int compareTo(InflateData2 other) {
+ return -Double.compare(this.pos, other.pos);
+ }
+
+ // public Point2D inflateX(Point2D pt) {
+ // if (pt.getX() < pos) {
+ // return pt;
+ // }
+ // if (pt.getX() == pos) {
+ // return GeomUtils.translate(pt, inflation / 2, 0);
+ // }
+ // return GeomUtils.translate(pt, inflation, 0);
+ // }
+ //
+ public double inflateAt(double v) {
+ if (v == pos) {
+ return inflation / 2;
+ }
+
+ if (v < pos) {
+ return 0;
+ }
+ return inflation;
+ }
+
+ // public Line2D.Double inflateXAlpha(Line2D.Double line) {
+ //
+ // if (GeomUtils.isHorizontal(line)) {
+ // return new Line2D.Double(inflateX(line.getP1()), inflateX(line.getP2()));
+ // }
+ // if (line.x1 == pos && line.x2 == pos) {
+ // return new Line2D.Double(GeomUtils.translate(line.getP1(), inflation / 2,
+ // 0), GeomUtils.translate(line
+ // .getP2(), inflation / 2, 0));
+ // }
+ // if (line.x1 <= pos && line.x2 <= pos) {
+ // return line;
+ // }
+ // if (line.x1 >= pos && line.x2 >= pos) {
+ // return new Line2D.Double(GeomUtils.translate(line.getP1(), inflation, 0),
+ // GeomUtils.translate(line.getP2(),
+ // inflation, 0));
+ // }
+ // throw new UnsupportedOperationException();
+ // }
+ //
+ // public Line2D.Double inflateYAlpha(Line2D.Double line) {
+ // if (GeomUtils.isVertical(line)) {
+ // return new Line2D.Double(inflateY(line.getP1()), inflateY(line.getP2()));
+ // }
+ // if (line.y1 == pos && line.y2 == pos) {
+ // return new Line2D.Double(GeomUtils.translate(line.getP1(), 0, inflation /
+ // 2), GeomUtils.translate(line
+ // .getP2(), 0, inflation / 2));
+ // }
+ // if (line.y1 <= pos && line.y2 <= pos) {
+ // return line;
+ // }
+ // if (line.y1 >= pos && line.y2 >= pos) {
+ // return new Line2D.Double(GeomUtils.translate(line.getP1(), 0, inflation),
+ // GeomUtils.translate(line.getP2(),
+ // 0, inflation));
+ // }
+ // throw new UnsupportedOperationException();
+ // }
+
+ @Override
+ public String toString() {
+ return "" + pos + " (" + inflation + ")";
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graph2/InflationTransform2.java b/src/net/sourceforge/plantuml/graph2/InflationTransform2.java
new file mode 100644
index 0000000..5837011
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph2/InflationTransform2.java
@@ -0,0 +1,239 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph2;
+
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Line2D;
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+class Point2DComparatorDistance implements Comparator<Point2D> {
+
+ private final Point2D center;
+
+ public Point2DComparatorDistance(Point2D center) {
+ this.center = center;
+ }
+
+ public int compare(Point2D p1, Point2D p2) {
+ return Double.compare(p1.distance(center), p2.distance(center));
+ }
+
+}
+
+public class InflationTransform2 implements IInflationTransform {
+
+ private final List<InflateData2> inflateX = new ArrayList<InflateData2>();
+ private final List<InflateData2> inflateY = new ArrayList<InflateData2>();
+
+ public void addInflationX(double xpos, double inflation) {
+ add(inflateX, xpos, inflation);
+ }
+
+ @Override
+ public String toString() {
+ return "inflateX = " + inflateX + " inflateY = " + inflateY;
+ }
+
+ public void addInflationY(double ypos, double inflation) {
+ add(inflateY, ypos, inflation);
+ }
+
+ public double getTotalInflationX() {
+ return sumInflation(inflateX);
+ }
+
+ public double getTotalInflationY() {
+ return sumInflation(inflateY);
+ }
+
+ static private double sumInflation(List<InflateData2> list) {
+ double result = 0;
+ for (InflateData2 data : list) {
+ result += data.getInflation();
+ }
+ return result;
+ }
+
+ static private void add(List<InflateData2> list, double ypos, double inflation) {
+ for (final ListIterator<InflateData2> it = list.listIterator(); it.hasNext();) {
+ final InflateData2 cur = it.next();
+ if (cur.getPos() == ypos) {
+ it.set(new InflateData2(ypos, Math.max(inflation, cur.getInflation())));
+ return;
+ }
+ }
+ list.add(new InflateData2(ypos, inflation));
+ Collections.sort(list);
+ }
+
+ Collection<Point2D.Double> cutPoints(Line2D.Double original) {
+
+ final SortedSet<Point2D.Double> result = new TreeSet<Point2D.Double>(new Point2DComparatorDistance(original
+ .getP1()));
+
+ if (GeomUtils.isHorizontal(original) == false) {
+ for (InflateData2 x : inflateX) {
+ final Line2D.Double vertical = new Line2D.Double(x.getPos(), GeomUtils.getMinY(original), x.getPos(),
+ GeomUtils.getMaxY(original));
+ final Point2D.Double inter = GeomUtils.getSegIntersection(original, vertical);
+ if (inter != null) {
+ result.add(inter);
+ }
+ }
+ }
+ if (GeomUtils.isVertical(original) == false) {
+ for (InflateData2 y : inflateY) {
+ final Line2D.Double horizontal = new Line2D.Double(GeomUtils.getMinX(original), y.getPos(), GeomUtils
+ .getMaxX(original), y.getPos());
+ final Point2D.Double inter = GeomUtils.getSegIntersection(original, horizontal);
+ if (inter != null) {
+ result.add(inter);
+ }
+ }
+ }
+ return result;
+ }
+
+ Collection<Line2D.Double> cutSegments(Line2D.Double original) {
+ final List<Line2D.Double> result = new ArrayList<Line2D.Double>();
+ Point2D.Double cur = (Point2D.Double) original.getP1();
+ final Collection<Point2D.Double> cutPoints = cutPoints(original);
+ for (Point2D.Double inter : cutPoints) {
+ if (cur.equals(inter)) {
+ continue;
+ }
+ result.add(new Line2D.Double(cur, inter));
+ cur = inter;
+ }
+ if (cur.equals(original.getP2()) == false) {
+ result.add(new Line2D.Double(cur, original.getP2()));
+ }
+ return result;
+ }
+
+ Collection<Line2D.Double> cutSegments(Collection<Line2D.Double> segments) {
+ final List<Line2D.Double> result = new ArrayList<Line2D.Double>();
+ for (Line2D.Double seg : segments) {
+ result.addAll(cutSegments(seg));
+ }
+ return result;
+ }
+
+ // private Line2D.Double inflateSegment(Line2D.Double seg) {
+ // // if (isOnGrid(seg.getP1()) && isOnGrid(seg.getP2())) {
+ // // return new Line2D.Double(inflatePoint2D(seg.getP1()),
+ // inflatePoint2D(seg.getP2()));
+ // // }
+ // // for (InflateData2 x : inflateX) {
+ // // seg = x.inflateXAlpha(seg);
+ // // }
+ // // for (InflateData2 y : inflateY) {
+ // // seg = y.inflateYAlpha(seg);
+ // // }
+ // // return seg;
+ // return new Line2D.Double(inflatePoint2D(seg.getP1()),
+ // inflatePoint2D(seg.getP2()));
+ // }
+
+ // private boolean isOnGrid(Point2D point) {
+ // boolean onGrid = false;
+ // for (InflateData2 x : inflateX) {
+ // if (point.getX() == x.getPos()) {
+ // onGrid = true;
+ // }
+ // }
+ // if (onGrid == false) {
+ // return false;
+ // }
+ // for (InflateData2 y : inflateY) {
+ // if (point.getY() == y.getPos()) {
+ // return true;
+ // }
+ // }
+ // return false;
+ //
+ // }
+
+ public Point2D inflatePoint2D(Point2D point) {
+ return getAffineTransformAt(point).transform(point, null);
+ }
+
+ AffineTransform getAffineTransformAt(Point2D point) {
+ double deltaX = 0;
+ for (InflateData2 x : inflateX) {
+ deltaX += x.inflateAt(point.getX());
+ }
+ double deltaY = 0;
+ for (InflateData2 y : inflateY) {
+ deltaY += y.inflateAt(point.getY());
+ }
+ return AffineTransform.getTranslateInstance(deltaX, deltaY);
+ }
+
+ List<Line2D.Double> inflateSegmentCollection(Collection<Line2D.Double> segments) {
+ final List<Line2D.Double> result = new ArrayList<Line2D.Double>();
+ for (Line2D.Double seg : segments) {
+ final AffineTransform at = getAffineTransformAt(new Point2D.Double((seg.x1 + seg.x2) / 2,
+ (seg.y1 + seg.y2) / 2));
+ result.add(new Line2D.Double(at.transform(seg.getP1(), null), at.transform(seg.getP2(), null)));
+ }
+ return result;
+ }
+
+ public List<Line2D.Double> inflate(Collection<Line2D.Double> segments) {
+ final Collection<Line2D.Double> cutSegments = cutSegments(segments);
+ Line2D.Double last = null;
+ final List<Line2D.Double> inflated = inflateSegmentCollection(cutSegments);
+ final List<Line2D.Double> result = new ArrayList<Line2D.Double>();
+ for (Line2D.Double seg : inflated) {
+ if (last != null && last.getP2().equals(seg.getP1()) == false) {
+ result.add(new Line2D.Double(last.getP2(), seg.getP1()));
+ }
+ result.add(seg);
+ last = seg;
+
+ }
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graph2/MagicPointsFactory.java b/src/net/sourceforge/plantuml/graph2/MagicPointsFactory.java
new file mode 100644
index 0000000..545ed25
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph2/MagicPointsFactory.java
@@ -0,0 +1,74 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph2;
+
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+import java.util.ArrayList;
+import java.util.List;
+
+public class MagicPointsFactory {
+
+ private MagicPointsFactory() {
+
+ }
+
+ public static List<Point2D.Double> get(Rectangle2D.Double rect) {
+ final List<Point2D.Double> result = new ArrayList<Point2D.Double>();
+ result.add(new Point2D.Double(rect.x - rect.width, rect.y - rect.height));
+ result.add(new Point2D.Double(rect.x, rect.y - rect.height));
+ result.add(new Point2D.Double(rect.x + rect.width, rect.y - rect.height));
+ result.add(new Point2D.Double(rect.x + 2 * rect.width, rect.y - rect.height));
+
+ result.add(new Point2D.Double(rect.x - rect.width, rect.y));
+ result.add(new Point2D.Double(rect.x + 2 * rect.width, rect.y));
+
+ result.add(new Point2D.Double(rect.x - rect.width, rect.y + rect.height));
+ result.add(new Point2D.Double(rect.x + 2 * rect.width, rect.y + rect.height));
+
+ result.add(new Point2D.Double(rect.x - rect.width, rect.y + 2 * rect.height));
+ result.add(new Point2D.Double(rect.x, rect.y + 2 * rect.height));
+ result.add(new Point2D.Double(rect.x + rect.width, rect.y + 2 * rect.height));
+ result.add(new Point2D.Double(rect.x + 2 * rect.width, rect.y + 2 * rect.height));
+ return result;
+ }
+
+ public static List<Point2D.Double> get(Point2D.Double p1, Point2D.Double p2) {
+ final List<Point2D.Double> result = new ArrayList<Point2D.Double>();
+ result.add(new Point2D.Double(p1.x, p2.y));
+ result.add(new Point2D.Double(p2.x, p1.y));
+ return result;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graph2/MagicPointsFactory2.java b/src/net/sourceforge/plantuml/graph2/MagicPointsFactory2.java
new file mode 100644
index 0000000..2a954d0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph2/MagicPointsFactory2.java
@@ -0,0 +1,72 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph2;
+
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+import java.util.List;
+
+public class MagicPointsFactory2 {
+
+ private final Point2D.Double p1;
+ private final Point2D.Double p2;
+
+ private final List<Point2D.Double> result = new ArrayList<Point2D.Double>();
+
+ public MagicPointsFactory2(Point2D.Double p1, Point2D.Double p2) {
+ this.p1 = p1;
+ this.p2 = p2;
+ final double dx = p2.x - p1.x;
+ final double dy = p2.y - p1.y;
+
+ final int interv = 5;
+ final int intervAngle = 10;
+ final double theta = Math.PI * 2 / intervAngle;
+ for (int a = 0; a < 10; a++) {
+ final AffineTransform at = AffineTransform.getRotateInstance(theta * a, p1.x, p1.y);
+ for (int i = 0; i < interv * 2; i++) {
+ final Point2D.Double p = new Point2D.Double(p1.x + dx * i / interv, p1.y + dy * i / interv);
+ result.add((Point2D.Double) at.transform(p, null));
+ }
+ }
+
+ }
+
+ public List<Point2D.Double> get() {
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graph2/Measurer.java b/src/net/sourceforge/plantuml/graph2/Measurer.java
new file mode 100644
index 0000000..45ad6e0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph2/Measurer.java
@@ -0,0 +1,39 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph2;
+
+public interface Measurer<V> {
+ int getMeasure(V data);
+}
diff --git a/src/net/sourceforge/plantuml/graph2/MyCurve.java b/src/net/sourceforge/plantuml/graph2/MyCurve.java
new file mode 100644
index 0000000..5c546d7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph2/MyCurve.java
@@ -0,0 +1,172 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph2;
+
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.geom.CubicCurve2D;
+import java.awt.geom.Line2D;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+import java.util.ArrayList;
+import java.util.List;
+
+public class MyCurve {
+
+ private final CubicCurve2D.Double curve;
+ private final List<Line2D.Double> lines = new ArrayList<Line2D.Double>();
+ private final List<Line2D.Double> linesForInters = new ArrayList<Line2D.Double>();
+ private Color color = Color.GREEN;
+ private double lenght = 0;
+
+ public MyCurve(CubicCurve2D.Double curve) {
+ this.curve = curve;
+ addCurve(curve);
+ if (lenght <= 0) {
+ throw new IllegalStateException();
+ }
+ for (Line2D.Double line : lines) {
+ linesForInters.add(change(line, curve.getP1(), curve.getP2()));
+ }
+ }
+
+ private Line2D.Double change(Line2D.Double line, Point2D p1, Point2D p2) {
+ if (line.getP1().equals(p1) == false && line.getP2().equals(p2) == false) {
+ return line;
+ }
+ final double dx = line.x2 - line.x1;
+ final double dy = line.y2 - line.y1;
+ if (line.getP1().equals(p1)) {
+ p1 = new Point2D.Double(line.x1 + dx / 10, line.y1 + dy / 10);
+ } else {
+ p1 = line.getP1();
+ }
+ if (line.getP2().equals(p2)) {
+ p2 = new Point2D.Double(line.x2 - dx / 10, line.y2 - dy / 10);
+ } else {
+ p2 = line.getP2();
+ }
+ return new Line2D.Double(p1, p2);
+ }
+
+ public final double getLenght() {
+ return lenght;
+ }
+
+ private void addCurve(CubicCurve2D.Double peace) {
+ final Rectangle2D bounds = peace.getBounds2D();
+ final double flat = peace.getFlatness();
+ if (flat < 10) {
+ lines.add(new Line2D.Double(peace.getP1(), peace.getP2()));
+ lenght += Math.sqrt(bounds.getWidth() * bounds.getWidth() + bounds.getHeight() * bounds.getHeight());
+ return;
+ }
+ final CubicCurve2D.Double left = new CubicCurve2D.Double();
+ final CubicCurve2D.Double right = new CubicCurve2D.Double();
+ peace.subdivide(left, right);
+ addCurve(left);
+ addCurve(right);
+ }
+
+ public void drawDebug(Graphics2D g2d) {
+ for (Line2D r : linesForInters) {
+ g2d.setColor(color);
+ g2d.draw(r);
+ }
+ g2d.setColor(Color.BLACK);
+ // g2d.draw(curve);
+ }
+
+ public void draw(Graphics2D g2d) {
+ g2d.setStroke(new BasicStroke((float) 1.5));
+ g2d.draw(curve);
+ g2d.setStroke(new BasicStroke());
+ }
+
+ public final void setColor(Color color) {
+ this.color = color;
+ }
+
+ public boolean intersects(List<MyCurve> others) {
+ for (MyCurve other : others) {
+ if (this.intersects(other)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean intersects(MyCurve other) {
+ for (Line2D.Double l1 : this.linesForInters) {
+ for (Line2D.Double l2 : other.linesForInters) {
+ if (l1.intersectsLine(l2)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ public boolean intersects(RectanglesCollection forbidden) {
+ for (Rectangle2D.Double r : forbidden) {
+ for (Line2D.Double line : lines) {
+ if (r.intersectsLine(line)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+ // public static long TPS6;
+ //
+ // public RectanglesCollection unrecoveredBy(RectanglesCollection allFrames)
+ // {
+ // final long start = System.currentTimeMillis();
+ // try {
+ // final RectanglesCollection result = new RectanglesCollection();
+ // for (Rectangle2D.Double r : areas) {
+ // if (allFrames.intersect(new RectanglesCollection(r)) == false) {
+ // result.add(r);
+ // }
+ // }
+ // return result;
+ // } finally {
+ // TPS6 += System.currentTimeMillis() - start;
+ // }
+ // }
+ //
+
+}
diff --git a/src/net/sourceforge/plantuml/graph2/Neighborhood2.java b/src/net/sourceforge/plantuml/graph2/Neighborhood2.java
new file mode 100644
index 0000000..f9e1926
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph2/Neighborhood2.java
@@ -0,0 +1,189 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph2;
+
+import java.awt.geom.Line2D;
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.geom.Orientation;
+
+public class Neighborhood2 {
+
+ final private double angle1;
+ final private double angle2;
+ final private Point2D.Double center;
+
+ public Neighborhood2(Point2D.Double center) {
+ this(center, 0, 0);
+ }
+
+ public boolean is360() {
+ return angle1 == angle2;
+ }
+
+ public Neighborhood2(Point2D.Double center, double angle1, double angle2) {
+ this.center = center;
+ this.angle1 = angle1;
+ this.angle2 = angle2;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ final Neighborhood2 other = (Neighborhood2) obj;
+ return angle1 == other.angle1 && angle2 == other.angle2 && center.equals(other.center);
+ }
+
+ @Override
+ public int hashCode() {
+ return center.hashCode() * 17 + new Point2D.Double(angle1, angle2).hashCode();
+ }
+
+ @Override
+ public String toString() {
+ final int a1 = (int) (angle1 * 180 / Math.PI);
+ final int a2 = (int) (angle2 * 180 / Math.PI);
+ return center + " " + a1 + " " + a2;
+ }
+
+ public final Point2D.Double getCenter() {
+ return center;
+ }
+
+ // private double getMiddle() {
+ // if (is360()) {
+ // return angle1 + 2 * Math.PI / 3;
+ // }
+ // double result = (angle1 + angle2) / 2;
+ // if (angle2 < angle1) {
+ // result += Math.PI;
+ // }
+ // return result;
+ // }
+ //
+ public Point2D.Double getPointInNeighborhood(double dist, Point2D p1, Point2D p2) {
+ if (p1 == null || p2 == null) {
+ throw new IllegalArgumentException();
+ }
+ if (dist <= 0) {
+ throw new IllegalArgumentException();
+ }
+ final double v1 = Singularity2.convertAngle(Singularity2.getAngle(new Line2D.Double(center, p1)) - angle1);
+ final double v2 = Singularity2.convertAngle(Singularity2.getAngle(new Line2D.Double(center, p2)) - angle1);
+ if (v1 < 0) {
+ throw new IllegalStateException();
+ }
+ if (v2 < 0) {
+ throw new IllegalStateException();
+ }
+ final double middle = (v1 + v2) / 2 + angle1;
+ return new Point2D.Double(center.x + dist * Math.cos(middle), center.y + dist * Math.sin(middle));
+ }
+
+ public boolean isInAngleStrict(double angle) {
+ if (angle < 0) {
+ throw new IllegalArgumentException();
+ }
+ if (angle2 > angle1) {
+ return angle > angle1 && angle < angle2;
+ }
+ return angle > angle1 || angle < angle2;
+ }
+
+ public boolean isInAngleLarge(double angle) {
+ if (angle < 0) {
+ throw new IllegalArgumentException();
+ }
+ if (angle2 > angle1) {
+ return angle >= angle1 && angle <= angle2;
+ }
+ return angle >= angle1 || angle <= angle2;
+ }
+
+ public boolean isAngleLimit(double angle) {
+ return angle == angle1 || angle == angle2;
+ }
+
+ public Orientation getOrientationFrom(double angle) {
+ if (angle1 == angle2) {
+ throw new IllegalStateException();
+ }
+ if (angle != angle1 && angle != angle2) {
+ throw new IllegalArgumentException("this=" + this + " angle=" + (int) (angle * 180 / Math.PI));
+ }
+ assert angle == angle1 || angle == angle2;
+
+ if (angle == angle1) {
+ return Orientation.MATH;
+ }
+ return Orientation.CLOCK;
+ }
+
+ public boolean isConnectable(Neighborhood2 other) {
+ assert isConnectableInternal(other) == other.isConnectableInternal(this);
+ return isConnectableInternal(other);
+
+ }
+
+ private boolean isConnectableInternal(Neighborhood2 other) {
+ if (getCenter().equals(other.getCenter())) {
+ throw new IllegalArgumentException("Same center");
+ }
+ final Line2D.Double seg1 = new Line2D.Double(getCenter(), other.getCenter());
+
+ final double angle1 = Singularity2.convertAngle(Singularity2.getAngle(seg1));
+ final double angle2 = Singularity2.convertAngle(Singularity2.getOppositeAngle(seg1));
+ assert angle2 == Singularity2.convertAngle(Singularity2.getAngle(new Line2D.Double(other.getCenter(),
+ getCenter())));
+ if (isInAngleStrict(angle1) && other.isInAngleStrict(angle2)) {
+ return true;
+ }
+ if (isInAngleStrict(angle1) && other.isInAngleLarge(angle2)) {
+ return true;
+ }
+ if (isInAngleLarge(angle1) && other.isInAngleStrict(angle2)) {
+ return true;
+ }
+ if (isAngleLimit(angle1) && other.isAngleLimit(angle2)) {
+ if (is360() || other.is360()) {
+ return true;
+ }
+ final Orientation o1 = getOrientationFrom(angle1);
+ final Orientation o2 = other.getOrientationFrom(angle2);
+ return o1 != o2;
+ }
+ return false;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graph2/Plan.java b/src/net/sourceforge/plantuml/graph2/Plan.java
new file mode 100644
index 0000000..f3699b6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph2/Plan.java
@@ -0,0 +1,254 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph2;
+
+import java.awt.geom.Line2D;
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import net.sourceforge.plantuml.Log;
+import net.sourceforge.plantuml.graph2.Dijkstra.Vertex;
+
+public class Plan {
+
+ private final Map<Point2D.Double, Singularity2> points = new LinkedHashMap<Point2D.Double, Singularity2>();
+ private final Collection<Line2D.Double> lines = new ArrayList<Line2D.Double>();
+
+ public void addPoint2D(Point2D.Double point) {
+ if (points.containsKey(point)) {
+ throw new IllegalArgumentException();
+ }
+ points.put(point, new Singularity2(point));
+ }
+
+ public void debugPrint() {
+ Log.println("PLAN PRINT");
+ for (Singularity2 s : points.values()) {
+ Log.println("s="+s);
+ }
+ for (Line2D.Double l : lines) {
+ Log.println(GeomUtils.toString(l));
+ }
+ }
+
+ public void createLink(Point2D p1, Point2D p2) {
+ final Singularity2 s1 = points.get(p1);
+ final Singularity2 s2 = points.get(p2);
+ if (s1 == null || s2 == null) {
+ throw new IllegalArgumentException();
+ }
+ final Line2D.Double line = new Line2D.Double(p1, p2);
+
+ s1.addLineSegment(line);
+ s2.addLineSegment(line);
+ lines.add(line);
+ }
+
+ Singularity2 getSingularity(Point2D pt) {
+ final Singularity2 result = points.get(pt);
+ if (result == null) {
+ throw new IllegalArgumentException();
+ }
+ return result;
+ }
+
+ List<Neighborhood2> getShortestPathToInternal(Point2D start, Point2D end) {
+ final Dijkstra dijkstra = new Dijkstra();
+ if (points.containsKey(start) == false || points.containsKey(end) == false) {
+ throw new IllegalArgumentException();
+ }
+ final Vertex vStart = dijkstra.addVertex(start);
+ final Vertex vEnd = dijkstra.addVertex(end);
+ final Map<Neighborhood2, Vertex> vertexes = new LinkedHashMap<Neighborhood2, Vertex>();
+ for (Singularity2 s : points.values()) {
+ for (Neighborhood2 n : s.getNeighborhoods()) {
+ final Vertex v = dijkstra.addVertex(n);
+ vertexes.put(n, v);
+ if (n.getCenter().equals(start)) {
+ vStart.addAdjacencies(v, 0.01);
+ }
+ if (n.getCenter().equals(end)) {
+ v.addAdjacencies(vEnd, 0.01);
+ }
+ }
+ }
+
+ for (Vertex v1 : vertexes.values()) {
+ for (Vertex v2 : vertexes.values()) {
+ final Neighborhood2 n1 = (Neighborhood2) v1.getData();
+ final Neighborhood2 n2 = (Neighborhood2) v2.getData();
+ if (n1.getCenter().equals(n2.getCenter())) {
+ continue;
+ }
+ final Line2D.Double line = new Line2D.Double(n1.getCenter(), n2.getCenter());
+ if (isStrictCrossing(line)) {
+ continue;
+ }
+ if (n1.isConnectable(n2) == false) {
+ continue;
+ }
+ final double dist = n1.getCenter().distance(n2.getCenter());
+ v1.addAdjacencies(v2, dist);
+ v2.addAdjacencies(v1, dist);
+ // Log.println("=(" + n1 + ") (" + n2 + ") " + dist);
+ }
+ }
+
+ final List<Vertex> list = dijkstra.getShortestPathTo(vStart, vEnd);
+ if (list.size() < 2) {
+ throw new IllegalStateException("list=" + list);
+ }
+ final List<Neighborhood2> result = new ArrayList<Neighborhood2>();
+ for (Vertex v : list.subList(1, list.size() - 1)) {
+ result.add((Neighborhood2) v.getData());
+ }
+ return result;
+ }
+
+ public List<Point2D.Double> getIntermediatePoints(Point2D start, Point2D end) {
+ // Log.println("start=" + start + " end=" + end);
+ final List<Point2D.Double> result = new ArrayList<Point2D.Double>();
+ final List<Neighborhood2> list = getShortestPathToInternal(start, end);
+ // Log.println("Neighborhood2 = " + list);
+ for (int i = 1; i < list.size() - 1; i++) {
+ final Neighborhood2 n = list.get(i);
+ final Point2D.Double before = list.get(i - 1).getCenter();
+ final Point2D.Double after = list.get(i + 1).getCenter();
+ // Log.println("before="+before);
+ // Log.println("after="+after);
+ // Log.println("n.getCenter()="+n.getCenter());
+ // Log.println("getMindist(n.getCenter())="+getMindist(n.getCenter()));
+ final Point2D.Double pointInNeighborhood = n.getPointInNeighborhood(getMindist(n.getCenter()) / 2, before,
+ after);
+ // Log.println("pointInNeighborhood="+pointInNeighborhood);
+ result.add(pointInNeighborhood);
+ }
+ return result;
+
+ }
+
+ private boolean isStrictCrossing(Line2D.Double line) {
+ for (Line2D.Double l : lines) {
+ if (intersectsLineStrict(l, line)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static boolean intersectsLineStrict(Line2D.Double l1, Line2D.Double l2) {
+ assert intersectsLineStrictInternal(l1, l2) == intersectsLineStrictInternal(l2, l1);
+ assert intersectsLineStrictInternal(l1, l2) == intersectsLineStrictInternal(inverse(l1), l2);
+ assert intersectsLineStrictInternal(l1, l2) == intersectsLineStrictInternal(l1, inverse(l2));
+ assert intersectsLineStrictInternal(l1, l2) == intersectsLineStrictInternal(inverse(l1), inverse(l2));
+ return intersectsLineStrictInternal(l1, l2);
+ }
+
+ private static Line2D.Double inverse(Line2D.Double line) {
+ return new Line2D.Double(line.getP2(), line.getP1());
+ }
+
+ private static boolean intersectsLineStrictInternal(Line2D.Double l1, Line2D.Double l2) {
+ if (l1.intersectsLine(l2) == false) {
+ return false;
+ }
+ assert l1.intersectsLine(l2);
+
+ Point2D.Double l1a = (Point2D.Double) l1.getP1();
+ Point2D.Double l1b = (Point2D.Double) l1.getP2();
+ Point2D.Double l2a = (Point2D.Double) l2.getP1();
+ Point2D.Double l2b = (Point2D.Double) l2.getP2();
+
+ if (l1a.equals(l2a) == false && l1a.equals(l2b) == false && l1b.equals(l2a) == false
+ && l1b.equals(l2b) == false) {
+ return true;
+ }
+
+ if (l1a.equals(l2b)) {
+ final Point2D.Double tmp = l2a;
+ l2a = l2b;
+ l2b = tmp;
+ } else if (l2a.equals(l1b)) {
+ final Point2D.Double tmp = l1a;
+ l1a = l1b;
+ l1b = tmp;
+ } else if (l1b.equals(l2b)) {
+ Point2D.Double tmp = l2a;
+ l2a = l2b;
+ l2b = tmp;
+ tmp = l1a;
+ l1a = l1b;
+ l1b = tmp;
+ }
+
+ assert l1a.equals(l2a);
+
+ return false;
+
+ }
+
+ final double getMindist(Point2D.Double pt) {
+ double result = Double.MAX_VALUE;
+ for (Point2D p : points.keySet()) {
+ if (pt.equals(p)) {
+ continue;
+ }
+ final double v = p.distance(pt);
+ if (v < 1E-4) {
+ throw new IllegalStateException();
+ }
+ result = Math.min(result, v);
+ }
+ for (Line2D line : lines) {
+ if (line.getP1().equals(pt) || line.getP2().equals(pt)) {
+ continue;
+ }
+ final double v = line.ptSegDist(pt);
+ if (result < 1E-4) {
+ throw new IllegalStateException("pt=" + pt + " line=" + GeomUtils.toString(line));
+ }
+ result = Math.min(result, v);
+ }
+ if (result == 0) {
+ throw new IllegalStateException();
+ }
+ // Log.println("getMindist=" + result);
+ return result;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graph2/Polyline2.java b/src/net/sourceforge/plantuml/graph2/Polyline2.java
new file mode 100644
index 0000000..b510b17
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph2/Polyline2.java
@@ -0,0 +1,110 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph2;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.geom.Line2D;
+import java.awt.geom.Point2D;
+import java.awt.geom.QuadCurve2D;
+import java.util.ArrayList;
+import java.util.List;
+
+public class Polyline2 {
+
+ private final List<Line2D.Double> lines = new ArrayList<Line2D.Double>();
+ private Point2D lastCurrent;
+ private final Point2D end;
+
+ public Polyline2(Point2D start, Point2D end) {
+ lastCurrent = start;
+ this.end = end;
+ }
+
+ public void addLine(Line2D.Double newLine) {
+ // Log.println("# Polyline2::addLine " +
+ // GeomUtils.toString(newLine));
+ if (lastCurrent.equals(newLine.getP1()) == false) {
+ lines.add(new Line2D.Double(lastCurrent, newLine.getP1()));
+ }
+ lines.add(newLine);
+ lastCurrent = newLine.getP2();
+ }
+
+ private boolean debug = false;
+
+ public void draw(Graphics2D g2d) {
+ close();
+ if (debug) {
+ g2d.setColor(Color.GREEN);
+ drawDebug(g2d);
+ }
+ g2d.setColor(Color.BLUE);
+ final List<Point2D.Double> centers = new ArrayList<Point2D.Double>();
+ for (Line2D.Double l : lines) {
+ centers.add(GeomUtils.getCenter(l));
+ }
+ g2d.draw(new Line2D.Double(lines.get(0).getP1(), centers.get(0)));
+ g2d.draw(new Line2D.Double(centers.get(centers.size() - 1), end));
+ for (int i = 0; i < lines.size() - 1; i++) {
+ final Point2D c1 = centers.get(i);
+ final Point2D c2 = centers.get(i + 1);
+ final Point2D ctrl = lines.get(i).getP2();
+ assert ctrl.equals(lines.get(i + 1).getP1());
+ final QuadCurve2D.Double quad = new QuadCurve2D.Double(c1.getX(), c1.getY(), ctrl.getX(), ctrl.getY(), c2
+ .getX(), c2.getY());
+ g2d.draw(quad);
+ }
+ if (debug) {
+ for (Point2D.Double c : centers) {
+ GeomUtils.fillPoint2D(g2d, c);
+ }
+ }
+ }
+
+ private void drawDebug(Graphics2D g2d) {
+ for (Line2D.Double l : lines) {
+ g2d.draw(l);
+ GeomUtils.fillPoint2D(g2d, l.getP1());
+ GeomUtils.fillPoint2D(g2d, l.getP2());
+ }
+ }
+
+ private void close() {
+ if (lastCurrent.equals(end) == false) {
+ lines.add(new Line2D.Double(lastCurrent, end));
+ }
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graph2/RectanglesCollection.java b/src/net/sourceforge/plantuml/graph2/RectanglesCollection.java
new file mode 100644
index 0000000..824e2d4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph2/RectanglesCollection.java
@@ -0,0 +1,199 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph2;
+
+import java.awt.geom.Rectangle2D;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+public class RectanglesCollection implements Iterable<Rectangle2D.Double> {
+
+ private final List<Rectangle2D.Double> areas = new ArrayList<Rectangle2D.Double>();
+ private final SortedListImpl<Rectangle2D.Double> sortedX1;
+ private final SortedListImpl<Rectangle2D.Double> sortedX2;
+ private final SortedListImpl<Rectangle2D.Double> sortedY1;
+ private final SortedListImpl<Rectangle2D.Double> sortedY2;
+
+ private Rectangle2D.Double max = null;
+
+ public RectanglesCollection() {
+ sortedX1 = new SortedListImpl<Rectangle2D.Double>(new Measurer<Rectangle2D.Double>() {
+ public int getMeasure(Rectangle2D.Double data) {
+ return (int) data.x;
+ }
+ });
+ sortedX2 = new SortedListImpl<Rectangle2D.Double>(new Measurer<Rectangle2D.Double>() {
+ public int getMeasure(Rectangle2D.Double data) {
+ return (int) (data.x + data.width);
+ }
+ });
+ sortedY1 = new SortedListImpl<Rectangle2D.Double>(new Measurer<Rectangle2D.Double>() {
+ public int getMeasure(Rectangle2D.Double data) {
+ return (int) data.y;
+ }
+ });
+ sortedY2 = new SortedListImpl<Rectangle2D.Double>(new Measurer<Rectangle2D.Double>() {
+ public int getMeasure(Rectangle2D.Double data) {
+ return (int) (data.y + data.height);
+ }
+ });
+ }
+
+ public RectanglesCollection(Rectangle2D.Double rect) {
+ this();
+ add(rect);
+ }
+
+ public double getSurf() {
+ if (max == null) {
+ return 0;
+ }
+ return max.getWidth() * max.getHeight();
+ }
+
+ public void add(Rectangle2D.Double rect) {
+ areas.add(rect);
+ // sortedX1.add(rect);
+ // sortedX2.add(rect);
+ // sortedY1.add(rect);
+ // sortedY2.add(rect);
+ if (max == null) {
+ max = rect;
+ } else {
+ max = (Rectangle2D.Double) max.createUnion(rect);
+ }
+ }
+
+ public Iterator<Rectangle2D.Double> iterator() {
+ return areas.iterator();
+ }
+
+ public boolean intersect(RectanglesCollection other) {
+ if (this.size() > other.size()) {
+ return intersectSeveral(this, other);
+ }
+ return intersectSeveral(other, this);
+ }
+
+ static private long TPS1;
+ static private long TPS2;
+
+ private static boolean intersectSeveral(RectanglesCollection large, RectanglesCollection compact) {
+ assert large.size() >= compact.size();
+ final long start = System.currentTimeMillis();
+ try {
+ for (Rectangle2D.Double r : compact) {
+ if (large.intersectSimple(r)) {
+ return true;
+ }
+ }
+ return false;
+ } finally {
+ TPS2 += System.currentTimeMillis() - start;
+ }
+ }
+
+ private boolean intersectSimple(Rectangle2D.Double rect) {
+ final long start = System.currentTimeMillis();
+ try {
+ if (max == null || max.intersects(rect) == false) {
+ return false;
+ }
+ for (Rectangle2D.Double r : areas) {
+ if (rect.intersects(r)) {
+ return true;
+ }
+ }
+ return false;
+ } finally {
+ TPS1 += System.currentTimeMillis() - start;
+ }
+ }
+
+ private boolean intersectSimpleOld(Rectangle2D.Double rect) {
+ final long start = System.currentTimeMillis();
+ try {
+ if (max == null || max.intersects(rect) == false) {
+ return false;
+ }
+ final List<Rectangle2D.Double> lX1 = sortedX1.lesserOrEquals((int) (rect.x + rect.width));
+ List<Rectangle2D.Double> lmin = lX1;
+ if (lX1.size() == 0) {
+ return false;
+ }
+ final List<Rectangle2D.Double> lX2 = sortedX2.biggerOrEquals((int) rect.x);
+ if (lX2.size() == 0) {
+ return false;
+ }
+ if (lX2.size() < lmin.size()) {
+ lmin = lX2;
+ }
+ final List<Rectangle2D.Double> lY1 = sortedY1.lesserOrEquals((int) (rect.y + rect.height));
+ if (lY1.size() == 0) {
+ return false;
+ }
+ if (lY1.size() < lmin.size()) {
+ lmin = lY1;
+ }
+ final List<Rectangle2D.Double> lY2 = sortedY2.biggerOrEquals((int) rect.y);
+ if (lY2.size() == 0) {
+ return false;
+ }
+ if (lY2.size() < lmin.size()) {
+ lmin = lY2;
+ }
+ for (Rectangle2D.Double r : lmin) {
+ if (rect.intersects(r)) {
+ return true;
+ }
+ }
+ return false;
+ } finally {
+ TPS1 += System.currentTimeMillis() - start;
+ }
+ }
+
+ public int size() {
+ return areas.size();
+ }
+
+ public void addAll(RectanglesCollection other) {
+ for (Rectangle2D.Double r : other.areas) {
+ this.add(r);
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graph2/Singularity2.java b/src/net/sourceforge/plantuml/graph2/Singularity2.java
new file mode 100644
index 0000000..58459fd
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph2/Singularity2.java
@@ -0,0 +1,163 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph2;
+
+import java.awt.geom.Line2D;
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.TreeSet;
+
+public class Singularity2 {
+
+ private final TreeSet<Double> angles = new TreeSet<Double>();
+
+ final private Point2D.Double center;
+
+ public Singularity2(Point2D.Double center) {
+ this.center = center;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder(center.toString());
+ for (Double a : angles) {
+ final int degree = (int) (a * 180 / Math.PI);
+ sb.append(' ');
+ sb.append(degree);
+ }
+ return sb.toString();
+ }
+
+ public void addLineSegment(Line2D.Double seg) {
+ if (seg.getP1().equals(center)) {
+ angles.add(convertAngle(getAngle(seg)));
+ } else if (seg.getP2().equals(center)) {
+ angles.add(convertAngle(getOppositeAngle(seg)));
+ } else {
+ throw new IllegalArgumentException();
+ }
+ assert betweenZeroAndTwoPi();
+
+ }
+
+ static final double getAngle(Line2D.Double line) {
+ if (line.getP1().equals(line.getP2())) {
+ throw new IllegalArgumentException();
+ }
+ return Math.atan2(line.getP2().getY() - line.getP1().getY(), line.getP2().getX() - line.getP1().getX());
+ }
+
+ static final double getOppositeAngle(Line2D.Double line) {
+ return Math.atan2(line.getP1().getY() - line.getP2().getY(), line.getP1().getX() - line.getP2().getX());
+ }
+
+ static double convertAngle(double a) {
+ while (a < 0) {
+ a += 2 * Math.PI;
+ }
+ return a;
+ }
+
+ private boolean betweenZeroAndTwoPi() {
+ for (Double d : angles) {
+ assert d >= 0;
+ assert d < 2 * Math.PI;
+ }
+ return true;
+ }
+
+ List<Double> getAngles() {
+ return new ArrayList<Double>(angles);
+ }
+
+ public boolean crossing(Point2D.Double direction1, Point2D.Double direction2) {
+ final boolean result = crossingInternal(direction1, direction2);
+ assert result == crossingInternal(direction2, direction1);
+ return result;
+ }
+
+ private boolean crossingInternal(Point2D.Double direction1, Point2D.Double direction2) {
+ if (angles.size() < 2) {
+ return false;
+ }
+ final double angle1 = convertAngle(getAngle(new Line2D.Double(center, direction1)));
+ final double angle2 = convertAngle(getAngle(new Line2D.Double(center, direction2)));
+
+ Double last = null;
+ for (Double current : angles) {
+ if (last != null) {
+ assert last < current;
+ if (isBetween(angle1, last, current) && isBetween(angle2, last, current)) {
+ return false;
+ }
+ }
+ last = current;
+ }
+ final double first = angles.first();
+ if ((angle1 <= first || angle1 >= last) && (angle2 <= first || angle2 >= last)) {
+ return false;
+ }
+ return true;
+ }
+
+ private boolean isBetween(double test, double v1, double v2) {
+ assert v1 < v2;
+ return test >= v1 && test <= v2;
+ }
+
+ protected final Point2D.Double getCenter() {
+ return center;
+ }
+
+ public void merge(Singularity2 other) {
+ this.angles.addAll(other.angles);
+ }
+
+ public List<Neighborhood2> getNeighborhoods() {
+ if (angles.size() == 0) {
+ return Collections.singletonList(new Neighborhood2(center));
+ }
+ final List<Neighborhood2> result = new ArrayList<Neighborhood2>();
+ double last = angles.last();
+ for (Double currentAngle : angles) {
+ result.add(new Neighborhood2(center, last, currentAngle));
+ last = currentAngle;
+ }
+ return Collections.unmodifiableList(result);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graph2/SortedList.java b/src/net/sourceforge/plantuml/graph2/SortedList.java
new file mode 100644
index 0000000..f095062
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph2/SortedList.java
@@ -0,0 +1,45 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph2;
+
+import java.util.List;
+
+public interface SortedList<V> extends Iterable<V> {
+ public void add(V data);
+
+ public List<V> lesserOrEquals(int v);
+
+ public List<V> biggerOrEquals(int v);
+}
diff --git a/src/net/sourceforge/plantuml/graph2/SortedListImpl.java b/src/net/sourceforge/plantuml/graph2/SortedListImpl.java
new file mode 100644
index 0000000..bbef49a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graph2/SortedListImpl.java
@@ -0,0 +1,128 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graph2;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+
+public class SortedListImpl<V> implements SortedList<V> {
+
+ static class NullableAndEvenMeasurer<V> implements Measurer<V> {
+ private final Measurer<V> wrapped;
+ private final int valueForNull;
+
+ NullableAndEvenMeasurer(Measurer<V> wrapped, int valueForNull, boolean plus) {
+ this.wrapped = wrapped;
+ if (plus) {
+ this.valueForNull = valueForNull * 2 + 1;
+ } else {
+ this.valueForNull = valueForNull * 2 - 1;
+ }
+ }
+
+ public int getMeasure(V data) {
+ if (data == null) {
+ return valueForNull;
+ }
+ return wrapped.getMeasure(data) * 2;
+ }
+ }
+
+ private final Measurer<V> measurer;
+ private final List<V> all = new ArrayList<V>();
+ private final Comparator<V> comparator;
+
+ public SortedListImpl(Measurer<V> m) {
+ this.measurer = m;
+ this.comparator = new Comparator<V>() {
+ public int compare(V o1, V o2) {
+ final int v1 = measurer.getMeasure(o1);
+ final int v2 = measurer.getMeasure(o2);
+ return v1 - v2;
+ }
+ };
+ }
+
+ public void add(V data) {
+ final int pos = Collections.binarySearch(all, data, comparator);
+ if (pos >= 0) {
+ all.add(pos, data);
+ } else {
+ all.add(-pos - 1, data);
+ }
+ assert isSorted();
+ }
+
+ private int getPos(int v, boolean plus) {
+ final Measurer<V> m = new NullableAndEvenMeasurer<V>(measurer, v, plus);
+ final Comparator<V> myComp = new Comparator<V>() {
+ public int compare(V o1, V o2) {
+ final int v1 = m.getMeasure(o1);
+ final int v2 = m.getMeasure(o2);
+ return v1 - v2;
+ }
+ };
+ final int pos = Collections.binarySearch(all, null, myComp);
+ assert pos < 0;
+ return -pos - 1;
+ }
+
+ public List<V> lesserOrEquals(int v) {
+ return all.subList(0, getPos(v, true));
+ }
+
+ public List<V> biggerOrEquals(int v) {
+ return all.subList(getPos(v, false), all.size());
+ }
+
+ private boolean isSorted() {
+ for (int i = 0; i < all.size() - 1; i++) {
+ final int v1 = measurer.getMeasure(all.get(i));
+ final int v2 = measurer.getMeasure(all.get(i + 1));
+ if (v1 > v2) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public Iterator<V> iterator() {
+ return all.iterator();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/AddStyle.java b/src/net/sourceforge/plantuml/graphic/AddStyle.java
new file mode 100644
index 0000000..0a7800b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/AddStyle.java
@@ -0,0 +1,60 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+
+public class AddStyle implements FontChange {
+
+ private final FontStyle style;
+ private final HtmlColor extendedColor;
+
+ public AddStyle(FontStyle style, HtmlColor extendedColor) {
+ this.style = style;
+ this.extendedColor = extendedColor;
+ }
+
+ public AddStyle(String s) {
+ this(FontStyle.getStyle(s), FontStyle.getStyle(s).getExtendedColor(s));
+ }
+
+ public FontConfiguration apply(FontConfiguration initial) {
+ initial = initial.add(style);
+ if (extendedColor != null) {
+ initial = initial.changeExtendedColor(extendedColor);
+ }
+ return initial;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/CircledCharacter.java b/src/net/sourceforge/plantuml/graphic/CircledCharacter.java
new file mode 100644
index 0000000..0247c2b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/CircledCharacter.java
@@ -0,0 +1,115 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.UCenteredCharacter;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class CircledCharacter implements TextBlock {
+
+ private final String c;
+ private final UFont font;
+ private final HtmlColor innerCircle;
+ private final HtmlColor circle;
+ private final HtmlColor fontColor;
+ private final double radius;
+
+ public CircledCharacter(char c, double radius, UFont font, HtmlColor innerCircle, HtmlColor circle,
+ HtmlColor fontColor) {
+ this.c = "" + c;
+ this.radius = radius;
+ this.font = font;
+ this.innerCircle = innerCircle;
+ this.circle = circle;
+ this.fontColor = fontColor;
+ }
+
+ // public void draw(ColorMapper colorMapper, Graphics2D g2d, int x, int y, double dpiFactor) {
+ // drawU(new UGraphicG2d(colorMapper, g2d, null, 1.0), x, y);
+ // }
+
+ public void drawU(UGraphic ug) {
+ if (circle != null) {
+ ug = ug.apply(new UChangeColor(circle));
+ }
+ // final HtmlColor back = ug.getParam().getBackcolor();
+ ug = ug.apply(new UChangeBackColor(innerCircle));
+ ug.draw(new UEllipse(radius * 2, radius * 2));
+ ug = ug.apply(new UChangeColor(fontColor));
+ ug = ug.apply(new UTranslate(radius, radius));
+ ug.draw(new UCenteredCharacter(c.charAt(0), font));
+ }
+
+ final public double getPreferredWidth(StringBounder stringBounder) {
+ return 2 * radius;
+ }
+
+ final public double getPreferredHeight(StringBounder stringBounder) {
+ return 2 * radius;
+ }
+
+ // private PathIterator getPathIteratorCharacter(FontRenderContext frc) {
+ // final TextLayout textLayout = new TextLayout(c, font.getFont(), frc);
+ // final Shape s = textLayout.getOutline(null);
+ // return s.getPathIterator(null);
+ // }
+ //
+ // private UPath getUPath(FontRenderContext frc) {
+ // final UPath result = new UPath();
+ //
+ // final PathIterator path = getPathIteratorCharacter(frc);
+ //
+ // final double coord[] = new double[6];
+ // while (path.isDone() == false) {
+ // final int code = path.currentSegment(coord);
+ // result.add(coord, USegmentType.getByCode(code));
+ // path.next();
+ // }
+ //
+ // return result;
+ // }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(getPreferredWidth(stringBounder), getPreferredHeight(stringBounder));
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graphic/ColorAndSizeChange.java b/src/net/sourceforge/plantuml/graphic/ColorAndSizeChange.java
new file mode 100644
index 0000000..c1a0c98
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/ColorAndSizeChange.java
@@ -0,0 +1,85 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+
+class ColorAndSizeChange implements FontChange {
+
+ static final Pattern colorPattern = MyPattern.cmpile("(?i)color\\s*=\\s*[%g]?(#[0-9a-fA-F]{6}|\\w+)[%g]?");
+
+ static final Pattern sizePattern = MyPattern.cmpile("(?i)size\\s*=\\s*[%g]?(\\d+)[%g]?");
+
+ private final HtmlColor color;
+ private final Integer size;
+
+ ColorAndSizeChange(String s) {
+ final Matcher matcherColor = colorPattern.matcher(s);
+ if (matcherColor.find()) {
+ color = HtmlColorSet.getInstance().getColorIfValid(matcherColor.group(1));
+ } else {
+ color = null;
+ }
+ final Matcher matcherSize = sizePattern.matcher(s);
+ if (matcherSize.find()) {
+ size = new Integer(matcherSize.group(1));
+ } else {
+ size = null;
+ }
+ }
+
+ HtmlColor getColor() {
+ return color;
+ }
+
+ Integer getSize() {
+ return size;
+ }
+
+ public FontConfiguration apply(FontConfiguration initial) {
+ FontConfiguration result = initial;
+ if (color != null) {
+ result = result.changeColor(color);
+ }
+ if (size != null) {
+ result = result.changeSize(size);
+ }
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/ColorChange.java b/src/net/sourceforge/plantuml/graphic/ColorChange.java
new file mode 100644
index 0000000..f0e3207
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/ColorChange.java
@@ -0,0 +1,64 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+
+class ColorChange implements FontChange {
+
+ static private final Pattern colorPattern = MyPattern.cmpile("(?i)" + Splitter.fontColorPattern2);
+
+ private final HtmlColor color;
+
+ ColorChange(String s) {
+ final Matcher matcherColor = colorPattern.matcher(s);
+ if (matcherColor.find() == false) {
+ throw new IllegalArgumentException();
+ }
+ this.color = HtmlColorSet.getInstance().getColorIfValid(matcherColor.group(1));
+ }
+
+ HtmlColor getColor() {
+ return color;
+ }
+
+ public FontConfiguration apply(FontConfiguration initial) {
+ return initial.changeColor(color);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/DateEventUtils.java b/src/net/sourceforge/plantuml/graphic/DateEventUtils.java
new file mode 100644
index 0000000..d2d5225
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/DateEventUtils.java
@@ -0,0 +1,107 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.Font;
+import java.awt.geom.Dimension2D;
+import java.awt.image.BufferedImage;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.SpriteContainerEmpty;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UImage;
+import net.sourceforge.plantuml.version.PSystemVersion;
+
+public class DateEventUtils {
+
+ public static TextBlock addEvent(TextBlock textBlock, HtmlColor color) {
+ final DateFormat dateFormat = new SimpleDateFormat("MM-dd");
+ final String today = dateFormat.format(new Date());
+
+ if ("11-05".equals(today)) {
+ final List<String> asList = Arrays.asList("<u>November 5th, 1955",
+ "Doc Brown's discovery of the Flux Capacitor, that makes time-travel possible.");
+ return TextBlockUtils.mergeTB(textBlock, getComment(asList, color), HorizontalAlignment.LEFT);
+ } else if ("08-29".equals(today)) {
+ final List<String> asList = Arrays.asList("<u>August 29th, 1997",
+ "Skynet becomes self-aware at 02:14 AM Eastern Time.");
+ return TextBlockUtils.mergeTB(textBlock, getComment(asList, color), HorizontalAlignment.LEFT);
+ } else if ("06-29".equals(today)) {
+ final List<String> asList = Arrays.asList("<u>June 29th, 1975",
+ "\"It was the first time in history that anyone had typed",
+ "a character on a keyboard and seen it show up on their",
+ "own computer's screen right in front of them.\"", "\t\t\t\t\t\t\t\t\t\t<i>Steve Wozniak");
+ return TextBlockUtils.mergeTB(textBlock, getComment(asList, color), HorizontalAlignment.LEFT);
+ } else if ("01-07".equals(today) || "01-08".equals(today)) {
+ return addCharlie(textBlock);
+
+ }
+
+ return textBlock;
+ }
+
+ private static TextBlock addCharlie(TextBlock textBlock) {
+ final TextBlock charlie = new TextBlock() {
+ private final BufferedImage charlie = PSystemVersion.getCharlieImage();
+
+ public void drawU(UGraphic ug) {
+ ug.draw(new UImage(charlie));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(charlie.getWidth(), charlie.getHeight());
+ }
+ };
+ return TextBlockUtils.mergeTB(charlie, textBlock, HorizontalAlignment.LEFT);
+
+ }
+
+ private static TextBlock getComment(final List<String> asList, HtmlColor color) {
+ final UFont font = new UFont("SansSerif", Font.BOLD, 14);
+ TextBlock comment = TextBlockUtils.create(Display.create(asList), new FontConfiguration(font, color,
+ HtmlColorUtils.BLUE, true), HorizontalAlignment.LEFT, new SpriteContainerEmpty());
+ comment = TextBlockUtils.withMargin(comment, 4, 4);
+ comment = new TextBlockBordered(comment, color);
+ comment = TextBlockUtils.withMargin(comment, 10, 10);
+ return comment;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graphic/DisplayUtils.java b/src/net/sourceforge/plantuml/graphic/DisplayUtils.java
new file mode 100644
index 0000000..32d5708
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/DisplayUtils.java
@@ -0,0 +1,55 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import net.sourceforge.plantuml.SpriteContainer;
+import net.sourceforge.plantuml.cucadiagram.Display;
+
+public class DisplayUtils {
+
+ private static Display breakLines(Display texts, FontConfiguration fontConfiguration,
+ SpriteContainer spriteContainer, double maxWidth) {
+ if (texts.size() != 1) {
+ return texts;
+ }
+ final CharSequence s = texts.get(0);
+ Display result = Display.empty();
+ final int nb = s.length() / 2;
+ result = result.add(s.subSequence(0, nb));
+ result = result.add(s.subSequence(nb + 1, s.length()));
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/EmbededSystemLine.java b/src/net/sourceforge/plantuml/graphic/EmbededSystemLine.java
new file mode 100644
index 0000000..cd7b3f4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/EmbededSystemLine.java
@@ -0,0 +1,109 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.List;
+
+import javax.imageio.ImageIO;
+
+import net.sourceforge.plantuml.BlockUml;
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.EmbededDiagram;
+import net.sourceforge.plantuml.FileFormat;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.core.Diagram;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UImage;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+class EmbededSystemLine implements Line {
+
+ final private List<? extends CharSequence> lines;
+
+ public EmbededSystemLine(EmbededDiagram sys) {
+ this.lines = sys.getLines().as();
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ try {
+ final BufferedImage im = getImage();
+ return new Dimension2DDouble(im.getWidth(), im.getHeight());
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ return new Dimension2DDouble(42, 42);
+ }
+
+ public void drawU(UGraphic ug) {
+ try {
+ final BufferedImage im = getImage();
+ final UShape image = new UImage(im);
+ ug.draw(image);
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ private BufferedImage getImage() throws IOException, InterruptedException {
+ final Diagram system = getSystem();
+ final ByteArrayOutputStream os = new ByteArrayOutputStream();
+ system.exportDiagram(os, 0, new FileFormatOption(FileFormat.PNG));
+ os.close();
+ final ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray());
+ final BufferedImage im = ImageIO.read(is);
+ is.close();
+ return im;
+ }
+
+ public HorizontalAlignment getHorizontalAlignment() {
+ return HorizontalAlignment.LEFT;
+ }
+
+ private Diagram getSystem() throws IOException, InterruptedException {
+ final BlockUml blockUml = new BlockUml(lines, 0);
+ return blockUml.getDiagram();
+
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graphic/ExposantChange.java b/src/net/sourceforge/plantuml/graphic/ExposantChange.java
new file mode 100644
index 0000000..2c7d117
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/ExposantChange.java
@@ -0,0 +1,49 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+class ExposantChange implements FontChange {
+
+ private final FontPosition fontPosition;
+
+ ExposantChange(FontPosition fontPosition) {
+ this.fontPosition = fontPosition;
+ }
+
+ public FontConfiguration apply(FontConfiguration initial) {
+ return initial.changeFontPosition(fontPosition);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/FontChange.java b/src/net/sourceforge/plantuml/graphic/FontChange.java
new file mode 100644
index 0000000..91e3003
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/FontChange.java
@@ -0,0 +1,40 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+public interface FontChange extends HtmlCommand {
+
+ FontConfiguration apply(FontConfiguration initial);
+}
diff --git a/src/net/sourceforge/plantuml/graphic/FontConfiguration.java b/src/net/sourceforge/plantuml/graphic/FontConfiguration.java
new file mode 100644
index 0000000..dcc5a1f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/FontConfiguration.java
@@ -0,0 +1,243 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.util.EnumSet;
+import java.util.Map;
+
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.SkinParamUtils;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public class FontConfiguration {
+
+ private final EnumSet<FontStyle> styles;
+ private final UFont currentFont;
+ private final UFont motherFont;
+ private final HtmlColor motherColor;
+ private final HtmlColor hyperlinkColor;
+ private final HtmlColor currentColor;
+ private final HtmlColor extendedColor;
+ private final FontPosition fontPosition;
+ private final SvgAttributes svgAttributes;
+ private final boolean hyperlink;
+ private final boolean useUnderlineForHyperlink;
+
+ public FontConfiguration(UFont font, HtmlColor color, HtmlColor hyperlinkColor, boolean useUnderlineForHyperlink) {
+ this(getStyles(font), font, color, font, color, null, FontPosition.NORMAL, new SvgAttributes(), false,
+ hyperlinkColor, useUnderlineForHyperlink);
+ }
+
+ public FontConfiguration(ISkinParam skinParam, FontParam fontParam, Stereotype stereo) {
+ this(SkinParamUtils.getFont(skinParam, fontParam, stereo), SkinParamUtils.getFontColor(skinParam, fontParam,
+ stereo), skinParam.getHyperlinkColor(), skinParam.useUnderlineForHyperlink());
+ }
+
+ //---
+
+ public final boolean useUnderlineForHyperlink() {
+ return useUnderlineForHyperlink;
+ }
+
+ public final HtmlColor getHyperlinkColor() {
+ return hyperlinkColor;
+ }
+
+ //---
+
+ private static EnumSet<FontStyle> getStyles(UFont font) {
+ final boolean bold = font.isBold();
+ final boolean italic = font.isItalic();
+ if (bold && italic) {
+ return EnumSet.of(FontStyle.ITALIC, FontStyle.BOLD);
+ }
+ if (bold) {
+ return EnumSet.of(FontStyle.BOLD);
+ }
+ if (italic) {
+ return EnumSet.of(FontStyle.ITALIC);
+ }
+ return EnumSet.noneOf(FontStyle.class);
+ }
+
+ @Override
+ public String toString() {
+ return styles.toString() + " " + currentColor;
+ }
+
+ private FontConfiguration(EnumSet<FontStyle> styles, UFont motherFont, HtmlColor motherColor, UFont currentFont,
+ HtmlColor currentColor, HtmlColor extendedColor, FontPosition fontPosition, SvgAttributes svgAttributes,
+ boolean hyperlink, HtmlColor hyperlinkColor, boolean useUnderlineForHyperlink) {
+ this.styles = styles;
+ this.currentFont = currentFont;
+ this.motherFont = motherFont;
+ this.currentColor = currentColor;
+ this.motherColor = motherColor;
+ this.extendedColor = extendedColor;
+ this.fontPosition = fontPosition;
+ this.svgAttributes = svgAttributes;
+ this.hyperlink = hyperlink;
+ this.hyperlinkColor = hyperlinkColor;
+ this.useUnderlineForHyperlink = useUnderlineForHyperlink;
+ }
+
+ public FontConfiguration forceFont(UFont newFont, HtmlColor htmlColorForStereotype) {
+ if (newFont == null) {
+ return add(FontStyle.ITALIC);
+ }
+ FontConfiguration result = new FontConfiguration(styles, newFont, motherColor, newFont, currentColor,
+ extendedColor, fontPosition, svgAttributes, hyperlink, hyperlinkColor, useUnderlineForHyperlink);
+ if (htmlColorForStereotype != null) {
+ result = result.changeColor(htmlColorForStereotype);
+ }
+ return result;
+ }
+
+ public FontConfiguration changeAttributes(SvgAttributes toBeAdded) {
+ return new FontConfiguration(styles, motherFont, motherColor, currentFont, currentColor, extendedColor,
+ fontPosition, svgAttributes.add(toBeAdded), hyperlink, hyperlinkColor, useUnderlineForHyperlink);
+ }
+
+ private FontConfiguration withHyperlink() {
+ return new FontConfiguration(styles, motherFont, motherColor, currentFont, currentColor, extendedColor,
+ fontPosition, svgAttributes, true, hyperlinkColor, useUnderlineForHyperlink);
+ }
+
+ public FontConfiguration changeColor(HtmlColor htmlColor) {
+ return new FontConfiguration(styles, motherFont, motherColor, currentFont, htmlColor, extendedColor,
+ fontPosition, svgAttributes, hyperlink, hyperlinkColor, useUnderlineForHyperlink);
+ }
+
+ FontConfiguration changeExtendedColor(HtmlColor newExtendedColor) {
+ return new FontConfiguration(styles, motherFont, motherColor, currentFont, currentColor, newExtendedColor,
+ fontPosition, svgAttributes, hyperlink, hyperlinkColor, useUnderlineForHyperlink);
+ }
+
+ public FontConfiguration changeSize(float size) {
+ return new FontConfiguration(styles, motherFont, motherColor, currentFont.deriveSize(size), currentColor,
+ extendedColor, fontPosition, svgAttributes, hyperlink, hyperlinkColor, useUnderlineForHyperlink);
+ }
+
+ public FontConfiguration bigger(double delta) {
+ return changeSize((float) (currentFont.getSize() + delta));
+ }
+
+ public FontConfiguration changeFontPosition(FontPosition fontPosition) {
+ return new FontConfiguration(styles, motherFont, motherColor, currentFont, currentColor, extendedColor,
+ fontPosition, svgAttributes, hyperlink, hyperlinkColor, useUnderlineForHyperlink);
+ }
+
+ public FontConfiguration changeFamily(String family) {
+ return new FontConfiguration(styles, motherFont, motherColor, new UFont(family, currentFont.getStyle(),
+ currentFont.getSize()), currentColor, extendedColor, fontPosition, svgAttributes, hyperlink,
+ hyperlinkColor, useUnderlineForHyperlink);
+ }
+
+ public FontConfiguration resetFont() {
+ return new FontConfiguration(styles, motherFont, motherColor, motherFont, motherColor, null,
+ FontPosition.NORMAL, new SvgAttributes(), hyperlink, hyperlinkColor, useUnderlineForHyperlink);
+ }
+
+ FontConfiguration add(FontStyle style) {
+ final EnumSet<FontStyle> r = styles.clone();
+ r.add(style);
+ return new FontConfiguration(r, motherFont, motherColor, currentFont, currentColor, extendedColor,
+ fontPosition, svgAttributes, hyperlink, hyperlinkColor, useUnderlineForHyperlink);
+ }
+
+ public FontConfiguration italic() {
+ return add(FontStyle.ITALIC);
+ }
+
+ public FontConfiguration bold() {
+ return add(FontStyle.BOLD);
+ }
+
+ public FontConfiguration underline() {
+ return add(FontStyle.UNDERLINE);
+ }
+
+ public FontConfiguration hyperlink() {
+ if (useUnderlineForHyperlink) {
+ return add(FontStyle.UNDERLINE).withHyperlink();
+ }
+ return withHyperlink();
+ }
+
+ FontConfiguration remove(FontStyle style) {
+ final EnumSet<FontStyle> r = styles.clone();
+ r.remove(style);
+ return new FontConfiguration(r, motherFont, motherColor, currentFont, currentColor, extendedColor,
+ fontPosition, svgAttributes, hyperlink, hyperlinkColor, useUnderlineForHyperlink);
+ }
+
+ public UFont getFont() {
+ UFont result = currentFont;
+ for (FontStyle style : styles) {
+ result = style.mutateFont(result);
+ }
+ return fontPosition.mute(result);
+ }
+
+ public HtmlColor getColor() {
+ if (hyperlink) {
+ return hyperlinkColor;
+ }
+ return currentColor;
+ }
+
+ public HtmlColor getExtendedColor() {
+ return extendedColor;
+ }
+
+ public boolean containsStyle(FontStyle style) {
+ return styles.contains(style);
+ }
+
+ public int getSpace() {
+ return fontPosition.getSpace();
+ }
+
+ public Map<String, String> getAttributes() {
+ return svgAttributes.attributes();
+ }
+
+ public double getSize2D() {
+ return currentFont.getSize2D();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/FontFamilyChange.java b/src/net/sourceforge/plantuml/graphic/FontFamilyChange.java
new file mode 100644
index 0000000..476f67c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/FontFamilyChange.java
@@ -0,0 +1,60 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+
+class FontFamilyChange implements FontChange {
+
+ static private final Pattern colorPattern = MyPattern.cmpile("(?i)" + Splitter.fontFamilyPattern);
+
+ private final String family;
+
+ FontFamilyChange(String s) {
+ final Matcher matcherColor = colorPattern.matcher(s);
+ if (matcherColor.find() == false) {
+ throw new IllegalArgumentException();
+ }
+ this.family = matcherColor.group(1).trim();
+ }
+
+ public FontConfiguration apply(FontConfiguration initial) {
+ return initial.changeFamily(family);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/FontPosition.java b/src/net/sourceforge/plantuml/graphic/FontPosition.java
new file mode 100644
index 0000000..e049510
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/FontPosition.java
@@ -0,0 +1,73 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public enum FontPosition {
+ NORMAL, EXPOSANT, INDICE;
+
+ public int getSpace() {
+ if (this == EXPOSANT) {
+ return -6;
+ }
+ if (this == INDICE) {
+ return 3;
+ }
+ return 0;
+ }
+
+ public UFont mute(UFont font) {
+ if (this == NORMAL) {
+ return font;
+ }
+ int size = font.getSize() - 3;
+ if (size < 2) {
+ size = 2;
+ }
+ return font.deriveSize((float) size);
+ }
+
+ public String getHtmlTag() {
+ if (this == EXPOSANT) {
+ return "sup";
+ }
+ if (this == INDICE) {
+ return "sub";
+ }
+ throw new UnsupportedOperationException();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/FontStyle.java b/src/net/sourceforge/plantuml/graphic/FontStyle.java
new file mode 100644
index 0000000..bde9eb9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/FontStyle.java
@@ -0,0 +1,162 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.Font;
+import java.util.EnumSet;
+import java.util.regex.Matcher;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public enum FontStyle {
+ PLAIN, ITALIC, BOLD, UNDERLINE, STRIKE, WAVE, BACKCOLOR;
+
+ public UFont mutateFont(UFont font) {
+ if (this == ITALIC) {
+ return font.deriveStyle(font.getStyle() | Font.ITALIC);
+ }
+ if (this == BOLD) {
+ return font.deriveStyle(font.getStyle() | Font.BOLD);
+ }
+ return font;
+ }
+
+ public String getActivationPattern() {
+ if (this == ITALIC) {
+ return "\\<[iI]\\>";
+ }
+ if (this == BOLD) {
+ return "\\<[bB]\\>";
+ }
+ if (this == UNDERLINE) {
+ return "\\<[uU](?::(#[0-9a-fA-F]{6}|\\w+))?\\>";
+ }
+ if (this == WAVE) {
+ return "\\<[wW](?::(#[0-9a-fA-F]{6}|\\w+))?\\>";
+ }
+ if (this == BACKCOLOR) {
+ return "\\<[bB][aA][cC][kK](?::(#[0-9a-fA-F]{6}|\\w+))?\\>";
+ }
+ if (this == STRIKE) {
+ return "\\<(?:s|S|strike|STRIKE|del|DEL)(?::(#[0-9a-fA-F]{6}|\\w+))?\\>";
+ }
+ return null;
+ }
+
+ public boolean canHaveExtendedColor() {
+ if (this == UNDERLINE) {
+ return true;
+ }
+ if (this == WAVE) {
+ return true;
+ }
+ if (this == BACKCOLOR) {
+ return true;
+ }
+ if (this == STRIKE) {
+ return true;
+ }
+ return false;
+ }
+
+
+ public String getCreoleSyntax() {
+ if (this == ITALIC) {
+ return "//";
+ }
+ if (this == BOLD) {
+ return "\\*\\*";
+ }
+ if (this == UNDERLINE) {
+ return "__";
+ }
+ if (this == WAVE) {
+ return "~~";
+ }
+ if (this == STRIKE) {
+ return "--";
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ public HtmlColor getExtendedColor(String s) {
+ final Matcher m = MyPattern.cmpile(getActivationPattern()).matcher(s);
+ if (m.find() == false || m.groupCount() != 1) {
+ return null;
+ }
+ final String color = m.group(1);
+ if (HtmlColorSet.getInstance().getColorIfValid(color) != null) {
+ return HtmlColorSet.getInstance().getColorIfValid(color);
+ }
+ return null;
+ }
+
+ public String getDeactivationPattern() {
+ if (this == ITALIC) {
+ return "\\</[iI]\\>";
+ }
+ if (this == BOLD) {
+ return "\\</[bB]\\>";
+ }
+ if (this == UNDERLINE) {
+ return "\\</[uU]\\>";
+ }
+ if (this == WAVE) {
+ return "\\</[wW]\\>";
+ }
+ if (this == BACKCOLOR) {
+ return "\\</[bB][aA][cC][kK]\\>";
+ }
+ if (this == STRIKE) {
+ return "\\</(?:s|S|strike|STRIKE|del|DEL)\\>";
+ }
+ return null;
+ }
+
+ public static FontStyle getStyle(String line) {
+ for (FontStyle style : EnumSet.allOf(FontStyle.class)) {
+ if (style == FontStyle.PLAIN) {
+ continue;
+ }
+ if (line.matches(style.getActivationPattern()) || line.matches(style.getDeactivationPattern())) {
+ return style;
+ }
+ }
+ throw new IllegalArgumentException(line);
+ }
+
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/GraphicPosition.java b/src/net/sourceforge/plantuml/graphic/GraphicPosition.java
new file mode 100644
index 0000000..a63ac0a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/GraphicPosition.java
@@ -0,0 +1,41 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+
+public enum GraphicPosition {
+ BOTTOM, BACKGROUND_CORNER_BOTTOM_RIGHT, BACKGROUND_CORNER_TOP_RIGHT
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/GraphicStrings.java b/src/net/sourceforge/plantuml/graphic/GraphicStrings.java
new file mode 100644
index 0000000..382dfc5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/GraphicStrings.java
@@ -0,0 +1,188 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.Font;
+import java.awt.geom.Dimension2D;
+import java.awt.image.BufferedImage;
+import java.util.List;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.SpriteContainerEmpty;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.svek.IEntityImage;
+import net.sourceforge.plantuml.svek.ShapeType;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+import net.sourceforge.plantuml.ugraphic.UAntiAliasing;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UImage;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class GraphicStrings implements IEntityImage {
+
+ private final HtmlColor background;
+
+ private final UFont font;
+
+ private final HtmlColor green;
+
+ private final HtmlColor hyperlinkColor = HtmlColorUtils.BLUE;
+
+ private final boolean useUnderlineForHyperlink = true;
+
+ private final List<String> strings;
+
+ private final BufferedImage image;
+
+ private final GraphicPosition position;
+
+ private final UAntiAliasing antiAliasing;
+
+ private final ColorMapper colorMapper = new ColorMapperIdentity();
+
+ public static GraphicStrings createDefault(List<String> strings, boolean useRed) {
+ if (useRed) {
+ return new GraphicStrings(strings, new UFont("SansSerif", Font.BOLD, 14), HtmlColorUtils.BLACK,
+ HtmlColorUtils.RED_LIGHT, UAntiAliasing.ANTI_ALIASING_ON);
+ }
+ return new GraphicStrings(strings, new UFont("SansSerif", Font.BOLD, 14), HtmlColorSet.getInstance()
+ .getColorIfValid("#33FF02"), HtmlColorUtils.BLACK, UAntiAliasing.ANTI_ALIASING_ON);
+ }
+
+ public GraphicStrings(List<String> strings, UFont font, HtmlColor green, HtmlColor background,
+ UAntiAliasing antiAliasing) {
+ this(strings, font, green, background, antiAliasing, null, null);
+ }
+
+ public GraphicStrings(List<String> strings, UFont font, HtmlColor green, HtmlColor background,
+ UAntiAliasing antiAliasing, BufferedImage image, GraphicPosition position) {
+ this.strings = strings;
+ this.font = font;
+ this.green = green;
+ this.background = background;
+ this.image = image;
+ this.position = position;
+ this.antiAliasing = antiAliasing;
+ }
+
+ private double minWidth;
+
+ public void setMinWidth(double minWidth) {
+ this.minWidth = minWidth;
+ }
+
+ private int maxLine = 0;
+
+ private TextBlock getTextBlock() {
+ TextBlock result = null;
+ if (maxLine == 0) {
+ result = TextBlockUtils.create(Display.create(strings), new FontConfiguration(font, green, hyperlinkColor, useUnderlineForHyperlink),
+ HorizontalAlignment.LEFT, new SpriteContainerEmpty());
+ } else {
+ for (int i = 0; i < strings.size(); i += maxLine) {
+ final int n = Math.min(i + maxLine, strings.size());
+ final TextBlock textBlock1 = TextBlockUtils.create(Display.create(strings.subList(i, n)),
+ new FontConfiguration(font, green, hyperlinkColor, useUnderlineForHyperlink), HorizontalAlignment.LEFT,
+ new SpriteContainerEmpty());
+ if (result == null) {
+ result = textBlock1;
+ } else {
+ result = TextBlockUtils.withMargin(result, 0, 10, 0, 0);
+ result = TextBlockUtils.mergeLR(result, textBlock1, VerticalAlignment.TOP);
+ }
+ }
+ }
+ result = DateEventUtils.addEvent(result, green);
+ return result;
+ }
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D size = calculateDimension(ug.getStringBounder());
+ getTextBlock().drawU(ug.apply(new UChangeColor(green)));
+
+ if (image != null) {
+ if (position == GraphicPosition.BOTTOM) {
+ ug.apply(new UTranslate((size.getWidth() - image.getWidth()) / 2, size.getHeight() - image.getHeight()))
+ .draw(new UImage(image));
+ } else if (position == GraphicPosition.BACKGROUND_CORNER_BOTTOM_RIGHT) {
+ ug.apply(new UTranslate(size.getWidth() - image.getWidth(), size.getHeight() - image.getHeight()))
+ .draw(new UImage(image));
+ } else if (position == GraphicPosition.BACKGROUND_CORNER_TOP_RIGHT) {
+ ug.apply(new UTranslate(size.getWidth() - image.getWidth() - 1, 1)).draw(new UImage(image));
+ }
+ }
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ Dimension2D dim = getTextBlock().calculateDimension(stringBounder);
+ if (dim.getWidth() < minWidth) {
+ dim = new Dimension2DDouble(minWidth, dim.getHeight());
+ }
+ if (image != null) {
+ if (position == GraphicPosition.BOTTOM) {
+ dim = new Dimension2DDouble(dim.getWidth(), dim.getHeight() + image.getHeight());
+ } else if (position == GraphicPosition.BACKGROUND_CORNER_BOTTOM_RIGHT) {
+ dim = new Dimension2DDouble(dim.getWidth() + image.getWidth(), dim.getHeight());
+ } else if (position == GraphicPosition.BACKGROUND_CORNER_TOP_RIGHT) {
+ dim = new Dimension2DDouble(dim.getWidth() + image.getWidth(), dim.getHeight());
+ }
+ }
+ return dim;
+ }
+
+ public ShapeType getShapeType() {
+ return ShapeType.RECTANGLE;
+ }
+
+ public HtmlColor getBackcolor() {
+ return background;
+ }
+
+ public int getShield() {
+ return 0;
+ }
+
+ public boolean isHidden() {
+ return false;
+ }
+
+ public final void setMaxLine(int maxLine) {
+ this.maxLine = maxLine;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/HorizontalAlignment.java b/src/net/sourceforge/plantuml/graphic/HorizontalAlignment.java
new file mode 100644
index 0000000..9ef51ab
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/HorizontalAlignment.java
@@ -0,0 +1,54 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+public enum HorizontalAlignment {
+
+ LEFT, CENTER, RIGHT;
+
+ public static HorizontalAlignment fromString(String s) {
+ if (LEFT.name().equalsIgnoreCase(s)) {
+ return LEFT;
+ }
+ if (CENTER.name().equalsIgnoreCase(s)) {
+ return CENTER;
+ }
+ if (RIGHT.name().equalsIgnoreCase(s)) {
+ return RIGHT;
+ }
+ return null;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/HtmlColor.java b/src/net/sourceforge/plantuml/graphic/HtmlColor.java
new file mode 100644
index 0000000..a65c7a3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/HtmlColor.java
@@ -0,0 +1,41 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+
+public interface HtmlColor {
+
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/HtmlColorGradient.java b/src/net/sourceforge/plantuml/graphic/HtmlColorGradient.java
new file mode 100644
index 0000000..02aeaf1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/HtmlColorGradient.java
@@ -0,0 +1,86 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.Color;
+
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+
+public class HtmlColorGradient implements HtmlColor {
+
+ private final HtmlColor color1;
+ private final HtmlColor color2;
+ private final char policy;
+
+ public HtmlColorGradient(HtmlColor color1, HtmlColor color2, char policy) {
+ if (color1 == null || color2 == null) {
+ throw new IllegalArgumentException();
+ }
+ this.color1 = color1;
+ this.color2 = color2;
+ this.policy = policy;
+ }
+
+ public final HtmlColor getColor1() {
+ return color1;
+ }
+
+ public final HtmlColor getColor2() {
+ return color2;
+ }
+
+ public final Color getColor(ColorMapper mapper, double coeff) {
+ if (coeff > 1 || coeff < 0) {
+ throw new IllegalArgumentException("c=" + coeff);
+ }
+ final Color c1 = mapper.getMappedColor(color1);
+ final Color c2 = mapper.getMappedColor(color2);
+ final int vred = c2.getRed() - c1.getRed();
+ final int vgreen = c2.getGreen() - c1.getGreen();
+ final int vblue = c2.getBlue() - c1.getBlue();
+
+ final int red = c1.getRed() + (int) (coeff * vred);
+ final int green = c1.getGreen() + (int) (coeff * vgreen);
+ final int blue = c1.getBlue() + (int) (coeff * vblue);
+
+ return new Color(red, green, blue);
+
+ }
+
+ public final char getPolicy() {
+ return policy;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/HtmlColorSet.java b/src/net/sourceforge/plantuml/graphic/HtmlColorSet.java
new file mode 100644
index 0000000..ac179df
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/HtmlColorSet.java
@@ -0,0 +1,45 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+public class HtmlColorSet {
+
+ private final static IHtmlColorSet singleton = new HtmlColorSetSimple();
+
+ public static IHtmlColorSet getInstance() {
+ return singleton;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/HtmlColorSetSimple.java b/src/net/sourceforge/plantuml/graphic/HtmlColorSetSimple.java
new file mode 100644
index 0000000..258110b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/HtmlColorSetSimple.java
@@ -0,0 +1,284 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.Color;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.regex.Matcher;
+
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.command.regex.MyPattern;
+
+public class HtmlColorSetSimple implements IHtmlColorSet {
+
+ private final Map<String, String> htmlNames;
+ private final Set<String> names;
+
+ public Collection<String> names() {
+ return Collections.unmodifiableSet(names);
+ }
+
+ public HtmlColor getColorIfValid(String s) {
+ return getColorIfValid(s, false);
+ }
+
+ public HtmlColor getColorIfValid(String s, boolean acceptTransparent) {
+ if (s == null) {
+ return null;
+ }
+ final Matcher m = MyPattern.cmpile("[-\\\\|/]").matcher(s);
+ if (m.find()) {
+ final char sep = m.group(0).charAt(0);
+ final int idx = s.indexOf(sep);
+ final String s1 = s.substring(0, idx);
+ final String s2 = s.substring(idx + 1);
+ if (isValid(s1, false) == false || isValid(s2, false) == false) {
+ return null;
+ }
+ return new HtmlColorGradient(build(s1), build(s2), sep);
+ // return getColorIfValid(s2);
+ }
+ if (isValid(s, acceptTransparent) == false) {
+ return new HtmlColorUserDef();
+ }
+ return build(s);
+ }
+
+ public HtmlColorSetSimple() {
+ // Taken from http://perl.wikipedia.com/wiki/Named_colors ?
+ // http://www.w3schools.com/HTML/html_colornames.asp
+ htmlNames = new HashMap<String, String>();
+ names = new TreeSet<String>();
+ register("AliceBlue", "#F0F8FF");
+ register("AntiqueWhite", "#FAEBD7");
+ register("Aqua", "#00FFFF");
+ register("Aquamarine", "#7FFFD4");
+ register("Azure", "#F0FFFF");
+ register("Beige", "#F5F5DC");
+ register("Bisque", "#FFE4C4");
+ register("Black", "#000000");
+ register("BlanchedAlmond", "#FFEBCD");
+ register("Blue", "#0000FF");
+ register("BlueViolet", "#8A2BE2");
+ register("Brown", "#A52A2A");
+ register("BurlyWood", "#DEB887");
+ register("CadetBlue", "#5F9EA0");
+ register("Chartreuse", "#7FFF00");
+ register("Chocolate", "#D2691E");
+ register("Coral", "#FF7F50");
+ register("CornflowerBlue", "#6495ED");
+ register("Cornsilk", "#FFF8DC");
+ register("Crimson", "#DC143C");
+ register("Cyan", "#00FFFF");
+ register("DarkBlue", "#00008B");
+ register("DarkCyan", "#008B8B");
+ register("DarkGoldenRod", "#B8860B");
+ register("DarkGray", "#A9A9A9");
+ register("DarkGrey", "#A9A9A9");
+ register("DarkGreen", "#006400");
+ register("DarkKhaki", "#BDB76B");
+ register("DarkMagenta", "#8B008B");
+ register("DarkOliveGreen", "#556B2F");
+ register("Darkorange", "#FF8C00");
+ register("DarkOrchid", "#9932CC");
+ register("DarkRed", "#8B0000");
+ register("DarkSalmon", "#E9967A");
+ register("DarkSeaGreen", "#8FBC8F");
+ register("DarkSlateBlue", "#483D8B");
+ register("DarkSlateGray", "#2F4F4F");
+ register("DarkSlateGrey", "#2F4F4F");
+ register("DarkTurquoise", "#00CED1");
+ register("DarkViolet", "#9400D3");
+ register("DeepPink", "#FF1493");
+ register("DeepSkyBlue", "#00BFFF");
+ register("DimGray", "#696969");
+ register("DimGrey", "#696969");
+ register("DodgerBlue", "#1E90FF");
+ register("FireBrick", "#B22222");
+ register("FloralWhite", "#FFFAF0");
+ register("ForestGreen", "#228B22");
+ register("Fuchsia", "#FF00FF");
+ register("Gainsboro", "#DCDCDC");
+ register("GhostWhite", "#F8F8FF");
+ register("Gold", "#FFD700");
+ register("GoldenRod", "#DAA520");
+ register("Gray", "#808080");
+ register("Grey", "#808080");
+ register("Green", "#008000");
+ register("GreenYellow", "#ADFF2F");
+ register("HoneyDew", "#F0FFF0");
+ register("HotPink", "#FF69B4");
+ register("IndianRed", "#CD5C5C");
+ register("Indigo", "#4B0082");
+ register("Ivory", "#FFFFF0");
+ register("Khaki", "#F0E68C");
+ register("Lavender", "#E6E6FA");
+ register("LavenderBlush", "#FFF0F5");
+ register("LawnGreen", "#7CFC00");
+ register("LemonChiffon", "#FFFACD");
+ register("LightBlue", "#ADD8E6");
+ register("LightCoral", "#F08080");
+ register("LightCyan", "#E0FFFF");
+ register("LightGoldenRodYellow", "#FAFAD2");
+ register("LightGray", "#D3D3D3");
+ register("LightGrey", "#D3D3D3");
+ register("LightGreen", "#90EE90");
+ register("LightPink", "#FFB6C1");
+ register("LightSalmon", "#FFA07A");
+ register("LightSeaGreen", "#20B2AA");
+ register("LightSkyBlue", "#87CEFA");
+ register("LightSlateGray", "#778899");
+ register("LightSlateGrey", "#778899");
+ register("LightSteelBlue", "#B0C4DE");
+ register("LightYellow", "#FFFFE0");
+ register("Lime", "#00FF00");
+ register("LimeGreen", "#32CD32");
+ register("Linen", "#FAF0E6");
+ register("Magenta", "#FF00FF");
+ register("Maroon", "#800000");
+ register("MediumAquaMarine", "#66CDAA");
+ register("MediumBlue", "#0000CD");
+ register("MediumOrchid", "#BA55D3");
+ register("MediumPurple", "#9370D8");
+ register("MediumSeaGreen", "#3CB371");
+ register("MediumSlateBlue", "#7B68EE");
+ register("MediumSpringGreen", "#00FA9A");
+ register("MediumTurquoise", "#48D1CC");
+ register("MediumVioletRed", "#C71585");
+ register("MidnightBlue", "#191970");
+ register("MintCream", "#F5FFFA");
+ register("MistyRose", "#FFE4E1");
+ register("Moccasin", "#FFE4B5");
+ register("NavajoWhite", "#FFDEAD");
+ register("Navy", "#000080");
+ register("OldLace", "#FDF5E6");
+ register("Olive", "#808000");
+ register("OliveDrab", "#6B8E23");
+ register("Orange", "#FFA500");
+ register("OrangeRed", "#FF4500");
+ register("Orchid", "#DA70D6");
+ register("PaleGoldenRod", "#EEE8AA");
+ register("PaleGreen", "#98FB98");
+ register("PaleTurquoise", "#AFEEEE");
+ register("PaleVioletRed", "#D87093");
+ register("PapayaWhip", "#FFEFD5");
+ register("PeachPuff", "#FFDAB9");
+ register("Peru", "#CD853F");
+ register("Pink", "#FFC0CB");
+ register("Plum", "#DDA0DD");
+ register("PowderBlue", "#B0E0E6");
+ register("Purple", "#800080");
+ register("Red", "#FF0000");
+ register("RosyBrown", "#BC8F8F");
+ register("RoyalBlue", "#4169E1");
+ register("SaddleBrown", "#8B4513");
+ register("Salmon", "#FA8072");
+ register("SandyBrown", "#F4A460");
+ register("SeaGreen", "#2E8B57");
+ register("SeaShell", "#FFF5EE");
+ register("Sienna", "#A0522D");
+ register("Silver", "#C0C0C0");
+ register("SkyBlue", "#87CEEB");
+ register("SlateBlue", "#6A5ACD");
+ register("SlateGray", "#708090");
+ register("SlateGrey", "#708090");
+ register("Snow", "#FFFAFA");
+ register("SpringGreen", "#00FF7F");
+ register("SteelBlue", "#4682B4");
+ register("Tan", "#D2B48C");
+ register("Teal", "#008080");
+ register("Thistle", "#D8BFD8");
+ register("Tomato", "#FF6347");
+ register("Turquoise", "#40E0D0");
+ register("Violet", "#EE82EE");
+ register("Wheat", "#F5DEB3");
+ register("White", "#FFFFFF");
+ register("WhiteSmoke", "#F5F5F5");
+ register("Yellow", "#FFFF00");
+ register("YellowGreen", "#9ACD32");
+ }
+
+ private void register(String s, String color) {
+ htmlNames.put(StringUtils.goLowerCase(s), color);
+ names.add(s);
+ }
+
+ private HtmlColor build(String s) {
+
+ s = removeFirstDieseAndgoLowerCase(s);
+ final Color color;
+ if (s.equalsIgnoreCase("transparent")) {
+ return new HtmlColorTransparent();
+ } else if (s.matches("[0-9A-Fa-f]{6}")) {
+ color = new Color(Integer.parseInt(s, 16));
+ } else {
+ final String value = htmlNames.get(s);
+ if (value == null) {
+ throw new IllegalArgumentException(s);
+ }
+ color = new Color(Integer.parseInt(value.substring(1), 16));
+ }
+ return new HtmlColorSimple(color, false);
+ }
+
+ private boolean isValid(String s, boolean acceptTransparent) {
+ s = removeFirstDieseAndgoLowerCase(s);
+ if (s.matches("[0-9A-Fa-f]{6}")) {
+ return true;
+ }
+ if (acceptTransparent && s.equalsIgnoreCase("transparent")) {
+ return true;
+ }
+ if (htmlNames.containsKey(s)) {
+ return true;
+ }
+ return false;
+
+ }
+
+ private String removeFirstDieseAndgoLowerCase(String s) {
+ s = StringUtils.goLowerCase(s);
+ if (s.startsWith("#")) {
+ s = s.substring(1);
+ }
+ return s;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/HtmlColorSimple.java b/src/net/sourceforge/plantuml/graphic/HtmlColorSimple.java
new file mode 100644
index 0000000..07f863d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/HtmlColorSimple.java
@@ -0,0 +1,78 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.Color;
+
+import net.sourceforge.plantuml.ugraphic.ColorChangerMonochrome;
+
+public class HtmlColorSimple implements HtmlColor {
+
+
+ private final Color color;
+ private final boolean monochrome;
+
+ @Override
+ public int hashCode() {
+ return color.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (other instanceof HtmlColorSimple == false) {
+ return false;
+ }
+ return this.color.equals(((HtmlColorSimple) other).color);
+ }
+
+
+ HtmlColorSimple(Color c, boolean monochrome) {
+ this.color = c;
+ this.monochrome = monochrome;
+ }
+
+
+ public Color getColor999() {
+ return color;
+ }
+
+ public HtmlColorSimple asMonochrome() {
+ if (monochrome) {
+ throw new IllegalStateException();
+ }
+ return new HtmlColorSimple(new ColorChangerMonochrome().getChangedColor(color), true);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/HtmlColorTransparent.java b/src/net/sourceforge/plantuml/graphic/HtmlColorTransparent.java
new file mode 100644
index 0000000..76bdcd2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/HtmlColorTransparent.java
@@ -0,0 +1,39 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+public class HtmlColorTransparent implements HtmlColor {
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/HtmlColorUserDef.java b/src/net/sourceforge/plantuml/graphic/HtmlColorUserDef.java
new file mode 100644
index 0000000..e1a2dd7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/HtmlColorUserDef.java
@@ -0,0 +1,39 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+public class HtmlColorUserDef implements HtmlColor {
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/HtmlColorUtils.java b/src/net/sourceforge/plantuml/graphic/HtmlColorUtils.java
new file mode 100644
index 0000000..2c0c682
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/HtmlColorUtils.java
@@ -0,0 +1,115 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+
+public class HtmlColorUtils {
+
+ public static final String COLOR_REGEXP = "#\\w+[-\\\\|/]?\\w+";
+
+ public static final HtmlColor BLACK;
+ public static final HtmlColor WHITE;
+ public static final HtmlColor RED_LIGHT;
+ public static final HtmlColor RED_DARK;
+ public static final HtmlColor RED;
+ public static final HtmlColor GREEN;
+ public static final HtmlColor BLUE;
+ public static final HtmlColor GRAY;
+ public static final HtmlColor LIGHT_GRAY;
+ public static final HtmlColor MY_YELLOW;
+ public static final HtmlColor MY_RED;
+
+ public static final HtmlColor COL_C82930;
+ public static final HtmlColor COL_F24D5C;
+ public static final HtmlColor COL_1963A0;
+ public static final HtmlColor COL_4177AF;
+ public static final HtmlColor COL_B38D22;
+ public static final HtmlColor COL_FFFF44;
+ public static final HtmlColor COL_038048;
+ public static final HtmlColor COL_84BE84;
+ public static final HtmlColor COL_DDDDDD;
+ public static final HtmlColor COL_EEEEEE;
+ public static final HtmlColor COL_FBFB77;
+ public static final HtmlColor COL_ADD1B2;
+ public static final HtmlColor COL_A9DCDF;
+ public static final HtmlColor COL_EB937F;
+ public static final HtmlColor COL_B4A7E5;
+ public static final HtmlColor COL_527BC6;
+ public static final HtmlColor COL_D1DBEF;
+ public static final HtmlColor COL_D7E0F2;
+ public static final HtmlColor COL_989898;
+ public static final HtmlColor COL_BBBBBB;
+
+
+ static {
+
+ final IHtmlColorSet set = new HtmlColorSetSimple();
+
+ BLACK = set.getColorIfValid("black");
+ WHITE = set.getColorIfValid("white");
+ RED_LIGHT = set.getColorIfValid("#FEF6F3");
+ RED_DARK = set.getColorIfValid("#CD0A0A");
+ RED = set.getColorIfValid("#FF0000");
+ GREEN = set.getColorIfValid("#00FF00");
+ BLUE = set.getColorIfValid("#0000FF");
+ GRAY = set.getColorIfValid("#808080");
+ LIGHT_GRAY = set.getColorIfValid("#C0C0C0");
+ MY_YELLOW = set.getColorIfValid("#FEFECE");
+ MY_RED = set.getColorIfValid("#A80036");
+
+ COL_C82930 = set.getColorIfValid("#C82930");
+ COL_F24D5C = set.getColorIfValid("#F24D5C");
+ COL_1963A0 = set.getColorIfValid("#1963A0");
+ COL_4177AF = set.getColorIfValid("#4177AF");
+ COL_B38D22 = set.getColorIfValid("#B38D22");
+ COL_FFFF44 = set.getColorIfValid("#FFFF44");
+ COL_038048 = set.getColorIfValid("#038048");
+ COL_84BE84 = set.getColorIfValid("#84BE84");
+ COL_DDDDDD = set.getColorIfValid("#DDDDDD");
+ COL_EEEEEE = set.getColorIfValid("#EEEEEE");
+ COL_FBFB77 = set.getColorIfValid("#FBFB77");
+ COL_ADD1B2 = set.getColorIfValid("#ADD1B2");
+ COL_A9DCDF = set.getColorIfValid("#A9DCDF");
+ COL_EB937F = set.getColorIfValid("#EB937F");
+ COL_B4A7E5 = set.getColorIfValid("#B4A7E5");
+ COL_527BC6 = set.getColorIfValid("#527BC6");
+ COL_D1DBEF = set.getColorIfValid("#D1DBEF");
+ COL_D7E0F2 = set.getColorIfValid("#D7E0F2");
+ COL_989898 = set.getColorIfValid("#989898");
+ COL_BBBBBB = set.getColorIfValid("#BBBBBB");
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/HtmlCommand.java b/src/net/sourceforge/plantuml/graphic/HtmlCommand.java
new file mode 100644
index 0000000..c6bd5b3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/HtmlCommand.java
@@ -0,0 +1,38 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+public interface HtmlCommand {
+}
diff --git a/src/net/sourceforge/plantuml/graphic/HtmlCommandFactory.java b/src/net/sourceforge/plantuml/graphic/HtmlCommandFactory.java
new file mode 100644
index 0000000..03e5dbe
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/HtmlCommandFactory.java
@@ -0,0 +1,141 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.util.EnumSet;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
+import net.sourceforge.plantuml.command.regex.MyPattern;
+
+class HtmlCommandFactory {
+
+ static final Pattern addStyle;
+ static final Pattern removeStyle;
+
+ static {
+ final StringBuilder sbAddStyle = new StringBuilder();
+ final StringBuilder sbRemoveStyle = new StringBuilder();
+
+ for (FontStyle style : EnumSet.allOf(FontStyle.class)) {
+ if (style == FontStyle.PLAIN) {
+ continue;
+ }
+ if (sbAddStyle.length() > 0) {
+ sbAddStyle.append('|');
+ sbRemoveStyle.append('|');
+ }
+ sbAddStyle.append(style.getActivationPattern());
+ sbRemoveStyle.append(style.getDeactivationPattern());
+ }
+
+ addStyle = MyPattern.cmpile(sbAddStyle.toString(), Pattern.CASE_INSENSITIVE);
+ removeStyle = MyPattern.cmpile(sbRemoveStyle.toString(), Pattern.CASE_INSENSITIVE);
+ }
+
+ private Pattern htmlTag = MyPattern.cmpile(Splitter.htmlTag, Pattern.CASE_INSENSITIVE);
+
+ HtmlCommand getHtmlCommand(String s) {
+ if (htmlTag.matcher(s).matches() == false) {
+ return new Text(s);
+ }
+ if (MyPattern.mtches(s, Splitter.imgPattern)) {
+ return Img.getInstance(s, true);
+ }
+
+ if (MyPattern.mtches(s, Splitter.imgPatternNoSrcColon)) {
+ return Img.getInstance(s, false);
+ }
+
+ if (addStyle.matcher(s).matches()) {
+ return new AddStyle(s);
+ }
+ if (removeStyle.matcher(s).matches()) {
+ return new RemoveStyle(FontStyle.getStyle(s));
+ }
+
+ if (MyPattern.mtches(s, Splitter.fontPattern)) {
+ return new ColorAndSizeChange(s);
+ }
+
+ if (MyPattern.mtches(s, Splitter.fontColorPattern2)) {
+ return new ColorChange(s);
+ }
+
+ if (MyPattern.mtches(s, Splitter.fontSizePattern2)) {
+ return new SizeChange(s);
+ }
+
+ if (MyPattern.mtches(s, Splitter.fontSup)) {
+ return new ExposantChange(FontPosition.EXPOSANT);
+ }
+
+ if (MyPattern.mtches(s, Splitter.fontSub)) {
+ return new ExposantChange(FontPosition.INDICE);
+ }
+
+ if (MyPattern.mtches(s, Splitter.endFontPattern)) {
+ return new ResetFont();
+ }
+
+ if (MyPattern.mtches(s, Splitter.endSupSub)) {
+ return new ExposantChange(FontPosition.NORMAL);
+ }
+
+ if (MyPattern.mtches(s, Splitter.fontFamilyPattern)) {
+ return new FontFamilyChange(s);
+ }
+
+ if (MyPattern.mtches(s, Splitter.spritePattern)) {
+ return new SpriteCommand(s);
+ }
+
+ if (MyPattern.mtches(s, Splitter.linkPattern)) {
+ final UrlBuilder urlBuilder = new UrlBuilder(null, ModeUrl.STRICT);
+ final Url url = urlBuilder.getUrl(s);
+ url.setMember(true);
+ return new TextLink(url);
+ }
+
+ if (MyPattern.mtches(s, Splitter.svgAttributePattern)) {
+ return new SvgAttributesChange(s);
+ }
+
+ return null;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/IHtmlColorSet.java b/src/net/sourceforge/plantuml/graphic/IHtmlColorSet.java
new file mode 100644
index 0000000..f5619c2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/IHtmlColorSet.java
@@ -0,0 +1,47 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.util.Collection;
+
+public interface IHtmlColorSet {
+
+ public Collection<String> names();
+
+ public HtmlColor getColorIfValid(String s);
+
+ public HtmlColor getColorIfValid(String s, boolean acceptTransparent);
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/Img.java b/src/net/sourceforge/plantuml/graphic/Img.java
new file mode 100644
index 0000000..d12c86c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/Img.java
@@ -0,0 +1,153 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.imageio.ImageIO;
+
+import net.sourceforge.plantuml.FileSystem;
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.command.regex.MyPattern;
+
+public class Img implements HtmlCommand {
+
+ final static private Pattern srcPattern = MyPattern.cmpile("(?i)src[%s]*=[%s]*[\"%q]?([^%s\">]+)[\"%q]?");
+ final static private Pattern vspacePattern = MyPattern.cmpile("(?i)vspace[%s]*=[%s]*[\"%q]?(\\d+)[\"%q]?");
+ final static private Pattern valignPattern = MyPattern.cmpile("(?i)valign[%s]*=[%s]*[\"%q]?(top|bottom|middle)[\"%q]?");
+ final static private Pattern noSrcColonPattern = MyPattern.cmpile("(?i)" + Splitter.imgPatternNoSrcColon);
+
+ private final TextBlock tileImage;
+
+ private Img(TextBlock image) {
+ this.tileImage = image;
+ }
+
+ static int getVspace(String html) {
+ final Matcher m = vspacePattern.matcher(html);
+ if (m.find() == false) {
+ return 0;
+ }
+ return Integer.parseInt(m.group(1));
+ }
+
+ static ImgValign getValign(String html) {
+ final Matcher m = valignPattern.matcher(html);
+ if (m.find() == false) {
+ return ImgValign.TOP;
+ }
+ return ImgValign.valueOf(StringUtils.goUpperCase(m.group(1)));
+ }
+
+ static HtmlCommand getInstance(String html, boolean withSrc) {
+ if (withSrc) {
+ final Matcher m = srcPattern.matcher(html);
+ final int vspace = getVspace(html);
+ final ImgValign valign = getValign(html);
+ return build(m, valign, vspace);
+ }
+ final Matcher m = noSrcColonPattern.matcher(html);
+ return build(m, ImgValign.TOP, 0);
+ }
+
+ private static HtmlCommand build(final Matcher m, final ImgValign valign, final int vspace) {
+ if (m.find() == false) {
+ return new Text("(SYNTAX ERROR)");
+ }
+ final String src = m.group(1);
+ try {
+ final File f = FileSystem.getInstance().getFile(src);
+ if (f.exists() == false) {
+ // Check if valid URL
+ if (src.startsWith("http:") || src.startsWith("https:")) {
+ final byte image[] = getFile(src);
+ final BufferedImage read = ImageIO.read(new ByteArrayInputStream(image));
+ if (read == null) {
+ return new Text("(Cannot decode: " + src + ")");
+ }
+ return new Img(new TileImage(read, valign, vspace));
+ }
+ return new Text("(File not found: " + f + ")");
+ }
+ if (f.getName().endsWith(".svg")) {
+ return new Img(new TileImageSvg(f));
+ }
+ final BufferedImage read = ImageIO.read(f);
+ if (read == null) {
+ return new Text("(Cannot decode: " + f + ")");
+ }
+ return new Img(new TileImage(ImageIO.read(f), valign, vspace));
+ } catch (IOException e) {
+ return new Text("ERROR " + e.toString());
+ }
+ }
+
+ public TextBlock createMonoImage() {
+ return tileImage;
+ }
+
+ // Added by Alain Corbiere
+ static byte[] getFile(String host) throws IOException {
+ final ByteArrayOutputStream image = new ByteArrayOutputStream();
+ InputStream input = null;
+ try {
+ final URL url = new URL(host);
+ final URLConnection connection = url.openConnection();
+ input = connection.getInputStream();
+ final byte[] buffer = new byte[1024];
+ int read;
+ while ((read = input.read(buffer)) > 0) {
+ image.write(buffer, 0, read);
+ }
+ image.close();
+ return image.toByteArray();
+ } finally {
+ if (input != null) {
+ input.close();
+ }
+ }
+ }
+ // End
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/ImgValign.java b/src/net/sourceforge/plantuml/graphic/ImgValign.java
new file mode 100644
index 0000000..9c9c3d6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/ImgValign.java
@@ -0,0 +1,39 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+public enum ImgValign {
+ TOP, BOTTOM, MIDDLE
+}
diff --git a/src/net/sourceforge/plantuml/graphic/Line.java b/src/net/sourceforge/plantuml/graphic/Line.java
new file mode 100644
index 0000000..21795a1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/Line.java
@@ -0,0 +1,41 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+
+interface Line extends TextBlock {
+
+ HorizontalAlignment getHorizontalAlignment();
+}
diff --git a/src/net/sourceforge/plantuml/graphic/QuoteUtils.java b/src/net/sourceforge/plantuml/graphic/QuoteUtils.java
new file mode 100644
index 0000000..30a7a6a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/QuoteUtils.java
@@ -0,0 +1,160 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class QuoteUtils {
+
+ private static final List<String> quotes = Arrays
+ .asList(//
+ "He's dead, Jim.", //
+ "By Grabthar's hammer, by the sons of Worvan, you shall be avenged.", //
+ "Roads? Where we're going, we don't need roads.", //
+ "The time is out of joint.", //
+ "C'est curieux chez les marins ce besoin de faire des phrases.", //
+ "I'm talking about the other Peter, the one on the other side.", //
+ "May the Force be with you!", //
+ "Never give up, never surrender...", //
+ "Hasta la vista, baby.", //
+ "Hey, Doc, we better back up. We don't have enough road to get up to 88.", //
+ "Greetings, Professor Falken. Shall we play a game?", //
+ "I can't change the law of physics!", //
+ "A strange game. The only winning move is not to play.", //
+ "I'm the Gatekeeper, are you the Keymaster?", //
+ "I am the Master Control Program. No one User wrote me.", //
+ "Life? Don't talk to me about life.", //
+ "I always thought something was fundamentally wrong with the universe.", //
+ "A robot may not injure a human being or, through inaction, allow a human being to come to harm.", //
+ "Surrender may be our only option.", //
+ "Six by nine. Forty two.", //
+ "It's life, Jim, but not as we know it.", //
+ "Don't Panic!", //
+ "What do you mean? An African or European swallow?", //
+ "You forgot to say please...", //
+ "You have died of dysentery.", //
+ "Wouldn't you prefer a nice game of chess?", //
+ "When you have eliminated the impossible, whatever remains, however improbable, must be the truth.", //
+ "I know now why you cry. But it's something I can never do.", //
+ "Resistance is futile. You will be assimilated.", //
+ "Anything different is good.", //
+ "Cracked by Aldo Reset and Laurent Rueil.", //
+ "I'm both. I'm a celebrity in an emergency.", //
+ "Do you know this great great polish actor, Joseph Tura?", //
+ "To infinity and beyond!", //
+ "Space: the final frontier...", //
+ "Sur mon billet, tenez, y a ecrit Saint-Lazare, c'est mes yeux ou quoi ?", //
+ "The boy is important. He has to live.", //
+ "Once upon a time in a galaxy far, far away...", //
+ "And you know there's a long long way ahead of you...", //
+ "An allergy to oxygen? Elm blight?", //
+ "But alors you are French!", //
+ "N'ai-je donc tant vecu que pour cette infamie?", //
+ "Something is rotten in the State of Denmark.", //
+ "Hey, what do you want? Miracles?", //
+ "1.21 gigawatts! 1.21 gigawatts. Great Scott! ", //
+ "What the hell is a gigawatt?", //
+ "I need a vacation.", //
+ "On devrait jamais quitter Montauban.", //
+ "My force is a platform that you can climb on...", //
+ "There's something weird, and it don't look good...", //
+ "Et rien vraiment ne change mais tout est different", //
+ "Beam me up, Scotty.", //
+ "There is no spoon.", //
+ "Follow the white rabbit.", //
+ "Never send a human to do a machine's job.", //
+ "Guru meditation. Press left mouse button to continue.", //
+ "I don't think we're in Kansas anymore.", //
+ "Luke, I am your father.", //
+ "Blood, Sweat and Tears", //
+ "Houston, we have a problem.", //
+ "Boot failure, press any key to continue", //
+ "Big mistake!", //
+ "How many UML designers does it take to change a lightbulb ?", //
+ "Do you like movies about gladiators ?", //
+ "The spirit of learning is a lasting frontier.", //
+ "It is curious for sailors this need for making sentences.", //
+ "Hoping for the best, but expecting the worst", //
+ "The will to go on when I'm hurt deep inside.", //
+ "If it bleeds, we can kill it.", //
+ "Houston, I have a bad feeling about this mission.", //
+ "Mama always said life was like a box of chocolates. You never know what you're gonna get.", //
+ "By the way, is there anyone on board who knows how to fly a plane?", //
+ "Dave, this conversation can serve no purpose anymore. Goodbye.", //
+ "It can only be attributable to human error.", //
+ "Looks like I picked the wrong week to quit smoking.", //
+ "You humans act so strange. Everything you create is used to destroy.", //
+ "Where did you learn how to negotiate like that?", //
+ "Sir, are you classified as human?", //
+ "We're not gonna make it, are we?", //
+ "It's in your nature to destroy yourselves.", //
+ "The more contact I have with humans, the more I learn.", //
+ "Would it save you a lot of time if I just gave up and went mad now?", //
+ "Reality is frequently inaccurate.", //
+ "Don't believe anything you read on the net. Except this. Well, including this, I suppose.", //
+ "A cup of tea would restore my normality.", //
+ "Anything that thinks logically can be fooled by something else that thinks at least as logically as it does.", //
+ "In an infinite Universe anything can happen.", //
+ "Sometimes if you received an answer, the question might be taken away.", //
+ "Please call me Eddie if it will help you to relax.", //
+ "I don't believe it. Prove it to me and I still won't believe it.", //
+ "Totally mad, utter nonsense. But we'll do it because it's brilliant nonsense.", //
+ "This sentence is not true.", //
+ "I would rather die standing than live on my knees.", //
+ "You are being watched.", //
+ "Did you feed them after midnight?", //
+ "How do you explain school to higher intelligence?", //
+ "People sometimes make mistakes.", //
+ "Look, I don't have time for a conversation right now.", //
+ "All problems in computer science can be solved by another level of indirection", //
+ "...except for the problem of too many levels of indirection", //
+ "I know because I built it", //
+ "Even the smallest person can change the course of the future.", //
+ "If you are a friend, you speak the password, and the doors will open.", //
+ "You Shall Not Pass", //
+ "73.6% Of All Statistics Are Made Up", //
+ "We can neither confirm nor deny that this is crashing"
+ // When the beating of your heart echoes the beating of the drums
+ // Never trust a computer you can't throw out a window
+ );
+ private QuoteUtils() {
+ }
+
+ public static String getSomeQuote() {
+ final int v = (int) (System.currentTimeMillis() / 1000L);
+ return quotes.get(v % quotes.size());
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graphic/RemoveStyle.java b/src/net/sourceforge/plantuml/graphic/RemoveStyle.java
new file mode 100644
index 0000000..95cf117
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/RemoveStyle.java
@@ -0,0 +1,49 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+class RemoveStyle implements FontChange {
+
+ private final FontStyle style;
+
+ RemoveStyle(FontStyle style) {
+ this.style = style;
+ }
+
+ public FontConfiguration apply(FontConfiguration initial) {
+ return initial.remove(style);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/ResetFont.java b/src/net/sourceforge/plantuml/graphic/ResetFont.java
new file mode 100644
index 0000000..5c82273
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/ResetFont.java
@@ -0,0 +1,43 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+class ResetFont implements FontChange {
+
+ public FontConfiguration apply(FontConfiguration initial) {
+ return initial.resetFont();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/SingleLine.java b/src/net/sourceforge/plantuml/graphic/SingleLine.java
new file mode 100644
index 0000000..b9b1418
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/SingleLine.java
@@ -0,0 +1,141 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.SpriteContainer;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.ugraphic.Sprite;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class SingleLine implements Line {
+
+ private final List<TextBlock> blocs = new ArrayList<TextBlock>();
+ private final HorizontalAlignment horizontalAlignment;
+
+ public SingleLine(String text, FontConfiguration fontConfiguration, HorizontalAlignment horizontalAlignment,
+ SpriteContainer spriteContainer) {
+ if (text.length() == 0) {
+ text = " ";
+ }
+ this.horizontalAlignment = horizontalAlignment;
+ final Splitter lineSplitter = new Splitter(text);
+
+ for (HtmlCommand cmd : lineSplitter.getHtmlCommands(false)) {
+ if (cmd instanceof Text) {
+ final String s = ((Text) cmd).getText();
+ blocs.add(new TileText(s, fontConfiguration, null));
+ } else if (cmd instanceof TextLink) {
+ final String s = ((TextLink) cmd).getText();
+ final Url url = ((TextLink) cmd).getUrl();
+ // blocs.add(new TileText(s, fontConfiguration.add(FontStyle.UNDERLINE), url));
+ blocs.add(new TileText(s, fontConfiguration, url));
+ } else if (cmd instanceof Img) {
+ blocs.add(((Img) cmd).createMonoImage());
+ } else if (cmd instanceof SpriteCommand) {
+ final Sprite sprite = spriteContainer.getSprite(((SpriteCommand) cmd).getSprite());
+ if (sprite != null) {
+ blocs.add(sprite.asTextBlock(fontConfiguration.getColor()));
+ }
+ } else if (cmd instanceof FontChange) {
+ fontConfiguration = ((FontChange) cmd).apply(fontConfiguration);
+ }
+ }
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ double width = 0;
+ double height = 0;
+ for (TextBlock b : blocs) {
+ final Dimension2D size2D = b.calculateDimension(stringBounder);
+ width += size2D.getWidth();
+ height = Math.max(height, size2D.getHeight());
+ }
+ return new Dimension2DDouble(width, height);
+ }
+
+ // private double maxDeltaY(Graphics2D g2d) {
+ // double result = 0;
+ // final Dimension2D dim = calculateDimension(StringBounderUtils.asStringBounder(g2d));
+ // for (TextBlock b : blocs) {
+ // if (b instanceof TileText == false) {
+ // continue;
+ // }
+ // final Dimension2D dimBloc = b.calculateDimension(StringBounderUtils.asStringBounder(g2d));
+ // final double deltaY = dim.getHeight() - dimBloc.getHeight() + ((TileText) b).getFontSize2D();
+ // result = Math.max(result, deltaY);
+ // }
+ // return result;
+ // }
+
+ private double maxDeltaY(UGraphic ug) {
+ double result = 0;
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ for (TextBlock b : blocs) {
+ if (b instanceof TileText == false) {
+ continue;
+ }
+ final Dimension2D dimBloc = b.calculateDimension(ug.getStringBounder());
+ final double deltaY = dim.getHeight() - dimBloc.getHeight() + ((TileText) b).getFontSize2D();
+ result = Math.max(result, deltaY);
+ }
+ return result;
+ }
+
+ public void drawU(UGraphic ug) {
+ final double deltaY = maxDeltaY(ug);
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D dim = calculateDimension(stringBounder);
+ double x = 0;
+ for (TextBlock b : blocs) {
+ if (b instanceof TileText) {
+ b.drawU(ug.apply(new UTranslate(x, deltaY)));
+ } else {
+ final double dy = dim.getHeight() - b.calculateDimension(stringBounder).getHeight();
+ b.drawU(ug.apply(new UTranslate(x, dy)));
+ }
+ x += b.calculateDimension(stringBounder).getWidth();
+ }
+ }
+
+ public HorizontalAlignment getHorizontalAlignment() {
+ return horizontalAlignment;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graphic/SizeChange.java b/src/net/sourceforge/plantuml/graphic/SizeChange.java
new file mode 100644
index 0000000..22f4445
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/SizeChange.java
@@ -0,0 +1,64 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+
+class SizeChange implements FontChange {
+
+ static private final Pattern sizePattern = MyPattern.cmpile("(?i)" + Splitter.fontSizePattern2);
+
+ private final Integer size;
+
+ SizeChange(String s) {
+ final Matcher matcherSize = sizePattern.matcher(s);
+ if (matcherSize.find() == false) {
+ throw new IllegalArgumentException();
+ }
+ size = new Integer(matcherSize.group(1));
+ }
+
+ Integer getSize() {
+ return size;
+ }
+
+ public FontConfiguration apply(FontConfiguration initial) {
+ return initial.changeSize(size);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/SkinParameter.java b/src/net/sourceforge/plantuml/graphic/SkinParameter.java
new file mode 100644
index 0000000..76c9dda
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/SkinParameter.java
@@ -0,0 +1,131 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.FontParam;
+
+public class SkinParameter {
+
+ public static final SkinParameter DATABASE = new SkinParameter("DATABASE", ColorParam.databaseBackground,
+ ColorParam.databaseBorder, FontParam.DATABASE, FontParam.DATABASE_STEREOTYPE);
+
+ public static final SkinParameter ARTIFACT = new SkinParameter("ARTIFACT", ColorParam.artifactBackground,
+ ColorParam.artifactBorder, FontParam.ARTIFACT, FontParam.ARTIFACT_STEREOTYPE);
+
+ public static final SkinParameter COMPONENT1 = new SkinParameter("COMPONENT1", ColorParam.componentBackground,
+ ColorParam.componentBorder, FontParam.COMPONENT, FontParam.COMPONENT_STEREOTYPE);
+
+ public static final SkinParameter NODE = new SkinParameter("NODE", ColorParam.nodeBackground,
+ ColorParam.nodeBorder, FontParam.NODE, FontParam.NODE_STEREOTYPE);
+
+ public static final SkinParameter STORAGE = new SkinParameter("STORAGE", ColorParam.storageBackground,
+ ColorParam.storageBorder, FontParam.STORAGE, FontParam.STORAGE_STEREOTYPE);
+
+ public static final SkinParameter QUEUE = new SkinParameter("QUEUE", ColorParam.queueBackground,
+ ColorParam.queueBorder, FontParam.QUEUE, FontParam.QUEUE_STEREOTYPE);
+
+ public static final SkinParameter CLOUD = new SkinParameter("CLOUD", ColorParam.cloudBackground,
+ ColorParam.cloudBorder, FontParam.CLOUD, FontParam.CLOUD_STEREOTYPE);
+
+ public static final SkinParameter FRAME = new SkinParameter("FRAME", ColorParam.frameBackground,
+ ColorParam.frameBorder, FontParam.FRAME, FontParam.FRAME_STEREOTYPE);
+
+ public static final SkinParameter COMPONENT2 = new SkinParameter("COMPONENT2", ColorParam.componentBackground,
+ ColorParam.componentBorder, FontParam.COMPONENT, FontParam.COMPONENT_STEREOTYPE);
+
+ public static final SkinParameter AGENT = new SkinParameter("AGENT", ColorParam.agentBackground,
+ ColorParam.agentBorder, FontParam.AGENT, FontParam.AGENT_STEREOTYPE);
+
+ public static final SkinParameter FOLDER = new SkinParameter("FOLDER", ColorParam.folderBackground,
+ ColorParam.folderBorder, FontParam.FOLDER, FontParam.FOLDER_STEREOTYPE);
+
+ public static final SkinParameter PACKAGE = new SkinParameter("PACKAGE", ColorParam.packageBackground,
+ ColorParam.packageBorder, FontParam.FOLDER, FontParam.FOLDER_STEREOTYPE);
+
+ public static final SkinParameter CARD = new SkinParameter("CARD", ColorParam.rectangleBackground,
+ ColorParam.rectangleBorder, FontParam.RECTANGLE, FontParam.RECTANGLE_STEREOTYPE);
+
+ public static final SkinParameter ACTOR = new SkinParameter("ACTOR", ColorParam.actorBackground,
+ ColorParam.actorBorder, FontParam.ACTOR, FontParam.ACTOR_STEREOTYPE);
+
+ public static final SkinParameter BOUNDARY = new SkinParameter("BOUNDARY", ColorParam.boundaryBackground,
+ ColorParam.boundaryBorder, FontParam.BOUNDARY, FontParam.BOUNDARY_STEREOTYPE);
+
+ public static final SkinParameter CONTROL = new SkinParameter("CONTROL", ColorParam.controlBackground,
+ ColorParam.controlBorder, FontParam.CONTROL, FontParam.CONTROL_STEREOTYPE);
+
+ public static final SkinParameter ENTITY_DOMAIN = new SkinParameter("ENTITY_DOMAIN", ColorParam.entityBackground,
+ ColorParam.entityBorder, FontParam.ENTITY, FontParam.ENTITY_STEREOTYPE);
+
+ public static final SkinParameter INTERFACE = new SkinParameter("INTERFACE", ColorParam.interfaceBackground,
+ ColorParam.interfaceBorder, FontParam.INTERFACE, FontParam.INTERFACE_STEREOTYPE);
+
+ private final ColorParam colorParamBorder;
+ private final ColorParam colorParamBack;
+ private final FontParam fontParam;
+ private final FontParam fontParamStereotype;
+ private final String name;
+
+ private SkinParameter(String name, ColorParam colorParamBack, ColorParam colorParamBorder, FontParam fontParam,
+ FontParam fontParamStereotype) {
+ this.name = name;
+ this.colorParamBack = colorParamBack;
+ this.colorParamBorder = colorParamBorder;
+ this.fontParam = fontParam;
+ this.fontParamStereotype = fontParamStereotype;
+ }
+
+ public String getUpperCaseName() {
+ return name;
+ }
+
+ public ColorParam getColorParamBorder() {
+ return colorParamBorder;
+ }
+
+ public ColorParam getColorParamBack() {
+ return colorParamBack;
+ }
+
+ public FontParam getFontParam() {
+ return fontParam;
+ }
+
+ public FontParam getFontParamStereotype() {
+ return fontParamStereotype;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/Splitter.java b/src/net/sourceforge/plantuml/graphic/Splitter.java
new file mode 100644
index 0000000..9bf186d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/Splitter.java
@@ -0,0 +1,157 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.StringUtils;
+
+public class Splitter {
+
+ static final String endFontPattern = "\\</font\\>|\\</color\\>|\\</size\\>|\\</text\\>";
+ static final String endSupSub = "\\</sup\\>|\\</sub\\>";
+ public static final String fontPattern = "\\<font(\\s+size[%s]*=[%s]*[%g]?\\d+[%g]?|[%s]+color[%s]*=\\s*[%g]?(#[0-9a-fA-F]{6}|\\w+)[%g]?)+[%s]*\\>";
+ public static final String fontColorPattern2 = "\\<color[\\s:]+(#[0-9a-fA-F]{6}|#?\\w+)[%s]*\\>";
+ public static final String fontSizePattern2 = "\\<size[\\s:]+(\\d+)[%s]*\\>";
+ static final String fontSup = "\\<sup\\>";
+ static final String fontSub = "\\<sub\\>";
+ static final String imgPattern = "\\<img\\s+(src[%s]*=[%s]*[%q%g]?[^\\s%g>]+[%q%g]?[%s]*|vspace\\s*=\\s*[%q%g]?\\d+[%q%g]?\\s*|valign[%s]*=[%s]*[%q%g]?(top|middle|bottom)[%q%g]?[%s]*)+\\>";
+ public static final String imgPatternNoSrcColon = "\\<img[\\s:]+([^>]+)/?\\>";
+ public static final String fontFamilyPattern = "\\<font[\\s:]+([^>]+)/?\\>";
+ public static final String svgAttributePattern = "\\<text[\\s:]+([^>]+)/?\\>";
+ public static final String openiconPattern = "\\<&([-\\w]+)\\>";
+ public static final String spritePattern = "\\<\\$[\\p{L}0-9_]+\\>";
+ public static final String spritePattern2 = "\\<\\$([\\p{L}0-9_]+)\\>";
+ static final String htmlTag;
+
+ static final String linkPattern = "\\[\\[([^\\[\\]]+)\\]\\]";
+
+ private static final Pattern tagOrText;
+
+ static {
+ final StringBuilder sb = new StringBuilder("(?i)");
+
+ for (FontStyle style : EnumSet.allOf(FontStyle.class)) {
+ if (style == FontStyle.PLAIN) {
+ continue;
+ }
+ sb.append(style.getActivationPattern());
+ sb.append('|');
+ sb.append(style.getDeactivationPattern());
+ sb.append('|');
+ }
+ sb.append(fontPattern);
+ sb.append('|');
+ sb.append(fontColorPattern2);
+ sb.append('|');
+ sb.append(fontSizePattern2);
+ sb.append('|');
+ sb.append(fontSup);
+ sb.append('|');
+ sb.append(fontSub);
+ sb.append('|');
+ sb.append(endFontPattern);
+ sb.append('|');
+ sb.append(endSupSub);
+ sb.append('|');
+ sb.append(imgPattern);
+ sb.append('|');
+ sb.append(imgPatternNoSrcColon);
+ sb.append('|');
+ sb.append(fontFamilyPattern);
+ sb.append('|');
+ sb.append(spritePattern);
+ sb.append('|');
+ sb.append(linkPattern);
+ sb.append('|');
+ sb.append(svgAttributePattern);
+
+ htmlTag = sb.toString();
+ tagOrText = MyPattern.cmpile(htmlTag + "|.+?(?=" + htmlTag + ")|.+$", Pattern.CASE_INSENSITIVE);
+ }
+
+ private final List<String> splitted = new ArrayList<String>();
+
+ public Splitter(String s) {
+ final Matcher matcher = tagOrText.matcher(s);
+ while (matcher.find()) {
+ String part = matcher.group(0);
+ part = StringUtils.showComparatorCharacters(part);
+ splitted.add(part);
+ }
+ }
+
+ List<String> getSplittedInternal() {
+ return splitted;
+ }
+
+ public List<HtmlCommand> getHtmlCommands(boolean newLineAlone) {
+ final HtmlCommandFactory factory = new HtmlCommandFactory();
+ final List<HtmlCommand> result = new ArrayList<HtmlCommand>();
+ for (String s : getSplittedInternal()) {
+ final HtmlCommand cmd = factory.getHtmlCommand(s);
+ if (newLineAlone && cmd instanceof Text) {
+ result.addAll(splitText((Text) cmd));
+ } else {
+ result.add(cmd);
+ }
+ }
+ return Collections.unmodifiableList(result);
+ }
+
+ private Collection<Text> splitText(Text cmd) {
+ String s = cmd.getText();
+ final Collection<Text> result = new ArrayList<Text>();
+ while (true) {
+ final int x = s.indexOf(Text.NEWLINE.getText());
+ if (x == -1) {
+ result.add(new Text(s));
+ return result;
+ }
+ if (x > 0) {
+ result.add(new Text(s.substring(0, x)));
+ }
+ result.add(Text.NEWLINE);
+ s = s.substring(x + 2);
+ }
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graphic/SpriteCommand.java b/src/net/sourceforge/plantuml/graphic/SpriteCommand.java
new file mode 100644
index 0000000..8650fb0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/SpriteCommand.java
@@ -0,0 +1,58 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+public class SpriteCommand implements HtmlCommand {
+
+ private final String sprite;
+
+ SpriteCommand(String sprite) {
+ if (sprite == null) {
+ throw new IllegalArgumentException();
+ }
+ if (sprite.startsWith("<$") == false) {
+ throw new IllegalArgumentException();
+ }
+ if (sprite.endsWith(">") == false) {
+ throw new IllegalArgumentException();
+ }
+ this.sprite = sprite.substring(2, sprite.length() - 1).trim();
+ }
+
+ public String getSprite() {
+ return sprite;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/StringBounder.java b/src/net/sourceforge/plantuml/graphic/StringBounder.java
new file mode 100644
index 0000000..69b02ce
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/StringBounder.java
@@ -0,0 +1,45 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public interface StringBounder {
+
+ public Dimension2D calculateDimension(UFont font, String text);
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/StringBounderUtils.java b/src/net/sourceforge/plantuml/graphic/StringBounderUtils.java
new file mode 100644
index 0000000..a9916a7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/StringBounderUtils.java
@@ -0,0 +1,57 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.FontMetrics;
+import java.awt.Graphics2D;
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Rectangle2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public class StringBounderUtils {
+
+ public static StringBounder asStringBounder(final Graphics2D g2d) {
+
+ return new StringBounder() {
+ public Dimension2D calculateDimension(UFont font, String text) {
+ final FontMetrics fm = g2d.getFontMetrics(font.getFont());
+ final Rectangle2D rect = fm.getStringBounds(text, g2d);
+ return new Dimension2DDouble(rect.getWidth(), rect.getHeight());
+ }
+ };
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graphic/SvgAttributes.java b/src/net/sourceforge/plantuml/graphic/SvgAttributes.java
new file mode 100644
index 0000000..ae15f80
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/SvgAttributes.java
@@ -0,0 +1,81 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.StringUtils;
+
+public class SvgAttributes {
+
+ private final Map<String, String> attributes = new TreeMap<String, String>();
+
+ public SvgAttributes() {
+ }
+
+ private SvgAttributes(SvgAttributes other) {
+ this.attributes.putAll(other.attributes);
+ }
+
+ public SvgAttributes(String args) {
+ final Pattern p = MyPattern.cmpile("(\\w+)\\s*=\\s*([%g][^%g]*[%g]|(?:\\w+))");
+ final Matcher m = p.matcher(args);
+ while (m.find()) {
+ attributes.put(m.group(1), StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(m.group(2)));
+ }
+ }
+
+ public Map<String, String> attributes() {
+ return Collections.unmodifiableMap(attributes);
+ }
+
+ public SvgAttributes add(String key, String value) {
+ final SvgAttributes result = new SvgAttributes(this);
+ result.attributes.put(key, value);
+ return result;
+ }
+
+ public SvgAttributes add(SvgAttributes toBeAdded) {
+ final SvgAttributes result = new SvgAttributes(this);
+ result.attributes.putAll(toBeAdded.attributes);
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/SvgAttributesChange.java b/src/net/sourceforge/plantuml/graphic/SvgAttributesChange.java
new file mode 100644
index 0000000..3ff9b0e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/SvgAttributesChange.java
@@ -0,0 +1,59 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+
+class SvgAttributesChange implements FontChange {
+
+ static final Pattern pattern = MyPattern.cmpile(Splitter.svgAttributePattern);
+ private final SvgAttributes attributes;
+
+ SvgAttributesChange(String s) {
+ final Matcher m = pattern.matcher(s);
+ if (m.find() == false) {
+ throw new IllegalStateException();
+ }
+ attributes = new SvgAttributes(m.group(1));
+ }
+
+ public FontConfiguration apply(FontConfiguration initial) {
+ return initial.changeAttributes(attributes);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/SymbolContext.java b/src/net/sourceforge/plantuml/graphic/SymbolContext.java
new file mode 100644
index 0000000..eb28041
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/SymbolContext.java
@@ -0,0 +1,119 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+
+public class SymbolContext {
+
+ private final HtmlColor backColor;
+ private final HtmlColor foreColor;
+ private final UStroke stroke;
+ private final boolean shadowing;
+ private final double deltaShadow;
+
+ private SymbolContext(HtmlColor backColor, HtmlColor foreColor, UStroke stroke, boolean shadowing,
+ double deltaShadow) {
+ this.backColor = backColor;
+ this.foreColor = foreColor;
+ this.stroke = stroke;
+ this.shadowing = shadowing;
+ this.deltaShadow = deltaShadow;
+ // if (backColor instanceof HtmlColorTransparent) {
+ // throw new UnsupportedOperationException();
+ // }
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + " backColor=" + backColor + " foreColor=" + foreColor;
+ }
+
+ final public UGraphic apply(UGraphic ug) {
+ return applyStroke(applyColors(ug));
+ }
+
+ public UGraphic applyColors(UGraphic ug) {
+ return ug.apply(new UChangeColor(foreColor)).apply(new UChangeBackColor(backColor));
+ }
+
+ public UGraphic applyStroke(UGraphic ug) {
+ return ug.apply(stroke);
+ }
+
+ public SymbolContext(HtmlColor backColor, HtmlColor foreColor) {
+ this(backColor, foreColor, new UStroke(), false, 0);
+ }
+
+ public SymbolContext withShadow(boolean newShadow) {
+ return new SymbolContext(backColor, foreColor, stroke, newShadow, deltaShadow);
+ }
+
+ public SymbolContext withDeltaShadow(double deltaShadow) {
+ return new SymbolContext(backColor, foreColor, stroke, shadowing, deltaShadow);
+ }
+
+ public SymbolContext withStroke(UStroke newStroke) {
+ return new SymbolContext(backColor, foreColor, newStroke, shadowing, deltaShadow);
+ }
+
+ public SymbolContext withBackColor(HtmlColor backColor) {
+ return new SymbolContext(backColor, foreColor, stroke, shadowing, deltaShadow);
+ }
+
+ public HtmlColor getBackColor() {
+ return backColor;
+ }
+
+ public HtmlColor getForeColor() {
+ return foreColor;
+ }
+
+ public UStroke getStroke() {
+ return stroke;
+ }
+
+ public boolean isShadowing() {
+ return shadowing || deltaShadow > 0;
+ }
+
+ public double getDeltaShadow() {
+ return deltaShadow;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/Text.java b/src/net/sourceforge/plantuml/graphic/Text.java
new file mode 100644
index 0000000..5b70d2d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/Text.java
@@ -0,0 +1,61 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+public class Text implements HtmlCommand {
+
+ private final String text;
+
+ public static final Text NEWLINE = new Text("\\n");
+
+ Text(String text) {
+ this.text = text.replaceAll("\\\\\\[", "[").replaceAll("\\\\\\]", "]");
+ if (text.indexOf('\n') != -1) {
+ throw new IllegalArgumentException();
+ }
+ if (text.length() == 0) {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ public String getText() {
+ assert text.length() > 0;
+ return text;
+ }
+
+ public boolean isNewline() {
+ return text.equals("\\n");
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graphic/TextBlock.java b/src/net/sourceforge/plantuml/graphic/TextBlock.java
new file mode 100644
index 0000000..b148ecb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/TextBlock.java
@@ -0,0 +1,45 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public interface TextBlock extends UDrawable, UShape {
+
+ public Dimension2D calculateDimension(StringBounder stringBounder);
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockArrow.java b/src/net/sourceforge/plantuml/graphic/TextBlockArrow.java
new file mode 100644
index 0000000..4a8b111
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/TextBlockArrow.java
@@ -0,0 +1,110 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.Direction;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class TextBlockArrow implements TextBlock {
+
+ private final double size;
+ private final Direction arrow;
+ private final HtmlColor color;
+
+ public TextBlockArrow(Direction arrow, FontConfiguration fontConfiguration) {
+ if (arrow == null) {
+ throw new IllegalArgumentException();
+ }
+ this.arrow = arrow;
+ // this.size = fontConfiguration.getFont().getSize2D() * 0 + 30;
+ this.size = fontConfiguration.getFont().getSize2D();
+ this.color = fontConfiguration.getColor();
+
+ }
+
+ public void drawU(UGraphic ug) {
+ ug = ug.apply(new UChangeBackColor(color));
+ ug = ug.apply(new UChangeColor(color));
+ int triSize = (int) (size * .8 - 3);
+ if (triSize % 2 == 1) {
+ 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);
+ }
+ }
+
+ private UPolygon getTriangle(int triSize) {
+ final UPolygon triangle = new UPolygon();
+ if (arrow == Direction.RIGHT) {
+ triangle.addPoint(0, 0);
+ triangle.addPoint(triSize, triSize / 2);
+ triangle.addPoint(0, triSize);
+ triangle.addPoint(0, 0);
+ } else if (arrow == Direction.LEFT) {
+ triangle.addPoint(triSize, 0);
+ triangle.addPoint(0, triSize / 2);
+ triangle.addPoint(triSize, triSize);
+ triangle.addPoint(triSize, 0);
+ } else if (arrow == Direction.UP) {
+ triangle.addPoint(0, triSize);
+ triangle.addPoint(triSize / 2, 0);
+ triangle.addPoint(triSize, triSize);
+ triangle.addPoint(0, triSize);
+ } else if (arrow == Direction.DOWN) {
+ triangle.addPoint(0, 0);
+ triangle.addPoint(triSize / 2, triSize);
+ triangle.addPoint(triSize, 0);
+ triangle.addPoint(0, 0);
+ } else {
+ throw new IllegalStateException();
+ }
+ return triangle;
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(size, size);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockBordered.java b/src/net/sourceforge/plantuml/graphic/TextBlockBordered.java
new file mode 100644
index 0000000..1e2780a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/TextBlockBordered.java
@@ -0,0 +1,65 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class TextBlockBordered implements TextBlock {
+
+ private final TextBlock textBlock;
+ private final HtmlColor color;
+
+ public TextBlockBordered(TextBlock textBlock, HtmlColor color) {
+ this.textBlock = textBlock;
+ this.color = color;
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dim = textBlock.calculateDimension(stringBounder);
+ return Dimension2DDouble.delta(dim, 1, 1);
+ }
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dim = textBlock.calculateDimension(ug.getStringBounder());
+ textBlock.drawU(ug.apply(new UTranslate(1, 1)));
+ ug.apply(new UChangeColor(color)).draw(new URectangle(dim.getWidth(), dim.getHeight()));
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockCompressed.java b/src/net/sourceforge/plantuml/graphic/TextBlockCompressed.java
new file mode 100644
index 0000000..12f7343
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/TextBlockCompressed.java
@@ -0,0 +1,73 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.CompressionTransform;
+import net.sourceforge.plantuml.ugraphic.SlotFinder;
+import net.sourceforge.plantuml.ugraphic.SlotSet;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UGraphicCompress;
+
+public class TextBlockCompressed implements TextBlock {
+
+ private final TextBlock textBlock;
+
+ public TextBlockCompressed(TextBlock textBlock) {
+ this.textBlock = textBlock;
+ }
+
+ public void drawU(final UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final CompressionTransform compressionTransform = getCompressionTransform(stringBounder);
+ textBlock.drawU(new UGraphicCompress(ug, compressionTransform));
+ }
+
+ private CompressionTransform getCompressionTransform(final StringBounder stringBounder) {
+ final SlotFinder slotFinder = new SlotFinder(stringBounder);
+ textBlock.drawU(slotFinder);
+ final SlotSet ysSlotSet = slotFinder.getYSlotSet().reverse().smaller(5.0);
+ final CompressionTransform compressionTransform = new CompressionTransform(ysSlotSet);
+ return compressionTransform;
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final CompressionTransform compressionTransform = getCompressionTransform(stringBounder);
+ final Dimension2D dim = textBlock.calculateDimension(stringBounder);
+ return new Dimension2DDouble(dim.getWidth(), compressionTransform.transform(dim.getHeight()));
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockCompressed2.java b/src/net/sourceforge/plantuml/graphic/TextBlockCompressed2.java
new file mode 100644
index 0000000..66bba9b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/TextBlockCompressed2.java
@@ -0,0 +1,62 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.CompressionTransform;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UGraphicCompress2;
+
+public class TextBlockCompressed2 implements TextBlock {
+
+ private final TextBlock textBlock;
+ private final CompressionTransform compressionTransform;
+
+ public TextBlockCompressed2(TextBlock textBlock, CompressionTransform compressionTransform) {
+ this.textBlock = textBlock;
+ this.compressionTransform = compressionTransform;
+ }
+
+ public void drawU(final UGraphic ug) {
+ textBlock.drawU(new UGraphicCompress2(ug, compressionTransform));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dim = textBlock.calculateDimension(stringBounder);
+ return new Dimension2DDouble(compressionTransform.transform(dim.getWidth()), dim.getHeight());
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockEmpty.java b/src/net/sourceforge/plantuml/graphic/TextBlockEmpty.java
new file mode 100644
index 0000000..514bd7c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/TextBlockEmpty.java
@@ -0,0 +1,75 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class TextBlockEmpty implements TextBlockWidth, TextBlock {
+
+ private final double width;
+ private final double height;
+
+ public TextBlockEmpty(double width, double height) {
+ this.width = width;
+ this.height = height;
+ }
+
+ public TextBlockEmpty() {
+ this(0, 0);
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(width, height);
+ }
+
+ public void drawU(UGraphic ug) {
+ }
+
+ public TextBlock asTextBlock(final double widthToUse) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return TextBlockEmpty.this.calculateDimension(stringBounder);
+ }
+ };
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockGeneric.java b/src/net/sourceforge/plantuml/graphic/TextBlockGeneric.java
new file mode 100644
index 0000000..ac050d0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/TextBlockGeneric.java
@@ -0,0 +1,71 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+
+public class TextBlockGeneric implements TextBlock {
+
+ private final TextBlock textBlock;
+ private final HtmlColor background;
+ private final HtmlColor border;
+
+ public TextBlockGeneric(TextBlock textBlock, HtmlColor background, HtmlColor border) {
+ this.textBlock = textBlock;
+ this.border = border;
+ this.background = background;
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dim = textBlock.calculateDimension(stringBounder);
+ return dim;
+ }
+
+ public void drawU(UGraphic ug) {
+ ug = ug.apply(new UChangeBackColor(background));
+ ug = ug.apply(new UChangeColor(border));
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ ug.apply(new UStroke(2, 2, 1)).draw(new URectangle(dim.getWidth(), dim.getHeight()));
+
+ textBlock.drawU(ug);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockHorizontal.java b/src/net/sourceforge/plantuml/graphic/TextBlockHorizontal.java
new file mode 100644
index 0000000..eef19f9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/TextBlockHorizontal.java
@@ -0,0 +1,75 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class TextBlockHorizontal implements TextBlock {
+
+ private final TextBlock b1;
+ private final TextBlock b2;
+ private final VerticalAlignment alignment;
+
+ public TextBlockHorizontal(TextBlock b1, TextBlock b2, VerticalAlignment alignment) {
+ this.b1 = b1;
+ this.b2 = b2;
+ this.alignment = alignment;
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dim1 = b1.calculateDimension(stringBounder);
+ final Dimension2D dim2 = b2.calculateDimension(stringBounder);
+ return Dimension2DDouble.mergeLR(dim1, dim2);
+ }
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ final Dimension2D dimb1 = b1.calculateDimension(ug.getStringBounder());
+ final Dimension2D dimb2 = b2.calculateDimension(ug.getStringBounder());
+ final Dimension2D dim1 = b1.calculateDimension(ug.getStringBounder());
+ if (alignment == VerticalAlignment.CENTER) {
+ b1.drawU(ug.apply(new UTranslate(0, ((dim.getHeight() - dimb1.getHeight()) / 2))));
+ b2.drawU(ug.apply(new UTranslate(dim1.getWidth(), ((dim.getHeight() - dimb2.getHeight()) / 2))));
+ } else {
+ b1.drawU(ug);
+ b2.drawU(ug.apply(new UTranslate(dim1.getWidth(), 0)));
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockLineBefore.java b/src/net/sourceforge/plantuml/graphic/TextBlockLineBefore.java
new file mode 100644
index 0000000..3d74311
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/TextBlockLineBefore.java
@@ -0,0 +1,85 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UHorizontalLine;
+
+public class TextBlockLineBefore implements TextBlock {
+
+ private final TextBlock textBlock;
+ private final char separator;
+ private final TextBlock title;
+
+ public TextBlockLineBefore(TextBlock textBlock, char separator, TextBlock title) {
+ this.textBlock = textBlock;
+ this.separator = separator;
+ this.title = title;
+ }
+
+ public TextBlockLineBefore(TextBlock textBlock, char separator) {
+ this(textBlock, separator, null);
+ }
+
+ public TextBlockLineBefore(TextBlock textBlock) {
+ this(textBlock, '\0');
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dim = textBlock.calculateDimension(stringBounder);
+ if (title != null) {
+ final Dimension2D dimTitle = title.calculateDimension(stringBounder);
+ return Dimension2DDouble.atLeast(dim, dimTitle.getWidth() + 8, dimTitle.getHeight());
+ }
+ return dim;
+ }
+
+ public void drawU(UGraphic ug) {
+ final HtmlColor color = ug.getParam().getColor();
+ if (title == null) {
+ UHorizontalLine.infinite(1, 1, separator).drawMe(ug);
+ }
+ textBlock.drawU(ug);
+ ug = ug.apply(new UChangeColor(color));
+ if (title != null) {
+ UHorizontalLine.infinite(1, 1, title, separator).drawMe(ug);
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockMarged.java b/src/net/sourceforge/plantuml/graphic/TextBlockMarged.java
new file mode 100644
index 0000000..d734f9a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/TextBlockMarged.java
@@ -0,0 +1,68 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class TextBlockMarged implements TextBlock {
+
+ private final TextBlock textBlock;
+ private final double x1;
+ private final double x2;
+ private final double y1;
+ private final double y2;
+
+ public TextBlockMarged(TextBlock textBlock, double x1, double x2, double y1, double y2) {
+ this.textBlock = textBlock;
+ this.x1 = x1;
+ this.x2 = x2;
+ this.y1 = y1;
+ this.y2 = y2;
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dim = textBlock.calculateDimension(stringBounder);
+ return Dimension2DDouble.delta(dim, x1 + x2, y1 + y2);
+ }
+
+ public void drawU(UGraphic ug) {
+ textBlock.drawU(ug.apply(new UTranslate(x1, y1)));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockMinWidth.java b/src/net/sourceforge/plantuml/graphic/TextBlockMinWidth.java
new file mode 100644
index 0000000..db62e12
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/TextBlockMinWidth.java
@@ -0,0 +1,71 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class TextBlockMinWidth implements TextBlock {
+
+ private final TextBlock textBlock;
+ private final double minWidth;
+ private final HorizontalAlignment horizontalAlignment;
+
+ public TextBlockMinWidth(TextBlock textBlock, double minWidth, HorizontalAlignment horizontalAlignment) {
+ this.textBlock = textBlock;
+ this.minWidth = minWidth;
+ this.horizontalAlignment = horizontalAlignment;
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dim = textBlock.calculateDimension(stringBounder);
+ return Dimension2DDouble.atLeast(dim, minWidth, 0);
+ }
+
+ public void drawU(UGraphic ug) {
+ if (horizontalAlignment == HorizontalAlignment.LEFT) {
+ textBlock.drawU(ug);
+ } else if (horizontalAlignment == HorizontalAlignment.RIGHT) {
+ final Dimension2D dim = textBlock.calculateDimension(ug.getStringBounder());
+ final double diffx = minWidth - dim.getWidth();
+ textBlock.drawU(ug.apply(new UTranslate(diffx, 0)));
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockRecentred.java b/src/net/sourceforge/plantuml/graphic/TextBlockRecentred.java
new file mode 100644
index 0000000..1cfdbc4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/TextBlockRecentred.java
@@ -0,0 +1,61 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ugraphic.MinMax;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class TextBlockRecentred implements TextBlock {
+
+ private final TextBlock textBlock;
+
+ public TextBlockRecentred(TextBlock textBlock) {
+ this.textBlock = textBlock;
+ }
+
+ public void drawU(final UGraphic ug) {
+ final MinMax minMax = TextBlockUtils.getMinMax(textBlock);
+ textBlock.drawU(ug.apply(new UTranslate(-minMax.getMinX(), -minMax.getMinY())));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final MinMax minMax = TextBlockUtils.getMinMax(textBlock);
+ return minMax.getDimension();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockSimple.java b/src/net/sourceforge/plantuml/graphic/TextBlockSimple.java
new file mode 100644
index 0000000..a9b10c2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/TextBlockSimple.java
@@ -0,0 +1,203 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.EmbededDiagram;
+import net.sourceforge.plantuml.SpriteContainer;
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class TextBlockSimple implements TextBlock {
+
+ private List<Line> lines2;
+
+ private final Display texts;
+ private final FontConfiguration fontConfiguration;
+ private final UFont fontForStereotype;
+ private final HorizontalAlignment horizontalAlignment;
+ private final SpriteContainer spriteContainer;
+ private final double maxMessageSize;
+ private final HtmlColor htmlColorForStereotype;
+
+ protected TextBlockSimple(Display texts, FontConfiguration fontConfiguration,
+ HorizontalAlignment horizontalAlignment, SpriteContainer spriteContainer, double maxMessageSize) {
+ this(texts, fontConfiguration, horizontalAlignment, spriteContainer, maxMessageSize, null, null);
+ }
+
+ protected TextBlockSimple(Display texts, FontConfiguration fontConfiguration,
+ HorizontalAlignment horizontalAlignment, SpriteContainer spriteContainer, double maxMessageSize,
+ UFont fontForStereotype, HtmlColor htmlColorForStereotype) {
+ this.texts = texts;
+ this.fontConfiguration = fontConfiguration;
+ this.horizontalAlignment = horizontalAlignment;
+ this.spriteContainer = spriteContainer;
+ this.maxMessageSize = maxMessageSize;
+ this.fontForStereotype = fontForStereotype;
+ this.htmlColorForStereotype = htmlColorForStereotype;
+ }
+
+ private List<Line> getLines(StringBounder stringBounder) {
+ if (lines2 == null) {
+ if (stringBounder == null) {
+ throw new IllegalStateException();
+ }
+ this.lines2 = new ArrayList<Line>();
+ for (CharSequence s : texts) {
+ if (s instanceof Stereotype) {
+ lines2.addAll(createLinesForStereotype(
+ fontConfiguration.forceFont(fontForStereotype, htmlColorForStereotype), (Stereotype) s,
+ horizontalAlignment, spriteContainer));
+ } else if (s instanceof EmbededDiagram) {
+ lines2.add(new EmbededSystemLine((EmbededDiagram) s));
+ } else {
+ addInLines(stringBounder, s.toString());
+ }
+ }
+ }
+ return lines2;
+ }
+
+ private void addInLines(StringBounder stringBounder, String s) {
+ if (maxMessageSize == 0) {
+ addSingleLine(s);
+ } else if (maxMessageSize > 0) {
+ final StringTokenizer st = new StringTokenizer(s, " ", true);
+ final StringBuilder currentLine = new StringBuilder();
+ while (st.hasMoreTokens()) {
+ final String token = st.nextToken();
+ final double w = getTextWidth(stringBounder, currentLine + token);
+ if (w > maxMessageSize) {
+ addSingleLineNoSpace(currentLine.toString());
+ currentLine.setLength(0);
+ if (token.startsWith(" ") == false) {
+ currentLine.append(token);
+ }
+ } else {
+ currentLine.append(token);
+ }
+ }
+ addSingleLineNoSpace(currentLine.toString());
+ } else if (maxMessageSize < 0) {
+ final StringBuilder currentLine = new StringBuilder();
+ for (int i = 0; i < s.length(); i++) {
+ final char c = s.charAt(i);
+ final double w = getTextWidth(stringBounder, currentLine.toString() + c);
+ if (w > -maxMessageSize) {
+ addSingleLineNoSpace(currentLine.toString());
+ currentLine.setLength(0);
+ if (c != ' ') {
+ currentLine.append(c);
+ }
+ } else {
+ currentLine.append(c);
+ }
+ }
+ addSingleLineNoSpace(currentLine.toString());
+ }
+ }
+
+ private void addSingleLineNoSpace(String s) {
+ if (s.length() == 0 || MyPattern.mtches(s, "^[%s]*$ ")) {
+ return;
+ }
+ lines2.add(new SingleLine(s, fontConfiguration, horizontalAlignment, spriteContainer));
+ }
+
+ private void addSingleLine(String s) {
+ lines2.add(new SingleLine(s, fontConfiguration, horizontalAlignment, spriteContainer));
+ }
+
+ private double getTextWidth(StringBounder stringBounder, String s) {
+ final Line line = new SingleLine(s, fontConfiguration, horizontalAlignment, spriteContainer);
+ return line.calculateDimension(stringBounder).getWidth();
+ }
+
+ private List<SingleLine> createLinesForStereotype(FontConfiguration fontConfiguration, Stereotype s,
+ HorizontalAlignment horizontalAlignment, SpriteContainer spriteContainer) {
+ assert s.getLabel(false) != null;
+ final List<SingleLine> result = new ArrayList<SingleLine>();
+ for (String st : s.getLabels(spriteContainer.useGuillemet())) {
+// st = Stereotype.manageGuillemet(st);
+ result.add(new SingleLine(st, fontConfiguration, horizontalAlignment, spriteContainer));
+ }
+ return Collections.unmodifiableList(result);
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return getTextDimension(stringBounder);
+ }
+
+ protected final Dimension2D getTextDimension(StringBounder stringBounder) {
+ double width = 0;
+ double height = 0;
+ for (Line line : getLines(stringBounder)) {
+ final Dimension2D size2D = line.calculateDimension(stringBounder);
+ height += size2D.getHeight();
+ width = Math.max(width, size2D.getWidth());
+ }
+ return new Dimension2DDouble(width, height);
+ }
+
+ public void drawU(UGraphic ug) {
+ double y = 0;
+ final Dimension2D dimText = getTextDimension(ug.getStringBounder());
+
+ for (Line line : getLines(ug.getStringBounder())) {
+ final HorizontalAlignment lineHorizontalAlignment = line.getHorizontalAlignment();
+ double deltaX = 0;
+ if (lineHorizontalAlignment == HorizontalAlignment.CENTER) {
+ final double diff = dimText.getWidth() - line.calculateDimension(ug.getStringBounder()).getWidth();
+ deltaX = diff / 2.0;
+ } else if (lineHorizontalAlignment == HorizontalAlignment.RIGHT) {
+ final double diff = dimText.getWidth() - line.calculateDimension(ug.getStringBounder()).getWidth();
+ deltaX = diff;
+ }
+ line.drawU(ug.apply(new UTranslate(deltaX, y)));
+ y += line.calculateDimension(ug.getStringBounder()).getHeight();
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockSpotted.java b/src/net/sourceforge/plantuml/graphic/TextBlockSpotted.java
new file mode 100644
index 0000000..8a6089c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/TextBlockSpotted.java
@@ -0,0 +1,81 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.SpriteContainer;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class TextBlockSpotted extends TextBlockSimple {
+
+ private final CircledCharacter circledCharacter;
+
+ public TextBlockSpotted(CircledCharacter circledCharacter, Display texts, FontConfiguration fontConfiguration,
+ HorizontalAlignment horizontalAlignment, SpriteContainer spriteContainer) {
+ super(texts, fontConfiguration, horizontalAlignment, spriteContainer, 0);
+ this.circledCharacter = circledCharacter;
+ }
+
+ @Override
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final double widthCircledCharacter = getCircledCharacterWithAndMargin(stringBounder);
+ final double heightCircledCharacter = circledCharacter.getPreferredHeight(stringBounder);
+
+ final Dimension2D dim = super.calculateDimension(stringBounder);
+ return new Dimension2DDouble(dim.getWidth() + widthCircledCharacter, Math.max(heightCircledCharacter,
+ dim.getHeight()));
+ }
+
+ private double getCircledCharacterWithAndMargin(StringBounder stringBounder) {
+ return circledCharacter.getPreferredWidth(stringBounder) + 6.0;
+ }
+
+ @Override
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+
+ circledCharacter.drawU(ug);
+
+ final double widthCircledCharacter = getCircledCharacterWithAndMargin(stringBounder);
+
+ super.drawU(ug.apply(new UTranslate(widthCircledCharacter, 0)));
+ }
+
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockUtils.java b/src/net/sourceforge/plantuml/graphic/TextBlockUtils.java
new file mode 100644
index 0000000..a39fc07
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/TextBlockUtils.java
@@ -0,0 +1,217 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics2D;
+import java.awt.font.FontRenderContext;
+import java.awt.font.LineMetrics;
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.awt.image.BufferedImage;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.SpriteContainer;
+import net.sourceforge.plantuml.creole.CreoleParser;
+import net.sourceforge.plantuml.creole.Sheet;
+import net.sourceforge.plantuml.creole.SheetBlock1;
+import net.sourceforge.plantuml.creole.SheetBlock2;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.posimo.Positionable;
+import net.sourceforge.plantuml.posimo.PositionableImpl;
+import net.sourceforge.plantuml.sequencediagram.MessageNumber;
+import net.sourceforge.plantuml.ugraphic.LimitFinder;
+import net.sourceforge.plantuml.ugraphic.MinMax;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+
+public class TextBlockUtils {
+
+ public static TextBlock create(Display texts, FontConfiguration fontConfiguration,
+ HorizontalAlignment horizontalAlignment, ISkinSimple spriteContainer) {
+ return create(texts, fontConfiguration, horizontalAlignment, spriteContainer, false);
+ }
+
+ public static TextBlock create(Display texts, FontConfiguration fontConfiguration,
+ HorizontalAlignment horizontalAlignment, ISkinSimple spriteContainer, boolean modeSimpleLine) {
+ if (texts == null) {
+ return empty(0, 0);
+ }
+ return create(texts, fontConfiguration, horizontalAlignment, spriteContainer, 0, modeSimpleLine, null, null);
+ }
+
+ public static TextBlock create(Display texts, FontConfiguration fontConfiguration,
+ HorizontalAlignment horizontalAlignment, ISkinSimple spriteContainer, double maxMessageSize,
+ boolean modeSimpleLine, UFont fontForStereotype, HtmlColor htmlColorForStereotype) {
+ if (texts.getNaturalHorizontalAlignment() != null) {
+ horizontalAlignment = texts.getNaturalHorizontalAlignment();
+ }
+ if (texts.size() > 0) {
+ if (texts.get(0) instanceof Stereotype) {
+ return createStereotype(texts, fontConfiguration, horizontalAlignment, spriteContainer, 0,
+ fontForStereotype, htmlColorForStereotype);
+ }
+ if (texts.get(texts.size() - 1) instanceof Stereotype) {
+ return createStereotype(texts, fontConfiguration, horizontalAlignment, spriteContainer,
+ texts.size() - 1, fontForStereotype, htmlColorForStereotype);
+ }
+ if (texts.get(0) instanceof MessageNumber) {
+ return createMessageNumber(texts, fontConfiguration, horizontalAlignment, spriteContainer,
+ maxMessageSize);
+ }
+ }
+
+ return getCreole(texts, fontConfiguration, horizontalAlignment, spriteContainer, maxMessageSize, modeSimpleLine);
+ }
+
+ private static TextBlock getCreole(Display texts, FontConfiguration fontConfiguration,
+ HorizontalAlignment horizontalAlignment, ISkinSimple spriteContainer, double maxMessageSize,
+ boolean modeSimpleLine) {
+ final Sheet sheet = new CreoleParser(fontConfiguration, horizontalAlignment, spriteContainer, modeSimpleLine)
+ .createSheet(texts);
+ final SheetBlock1 sheetBlock1 = new SheetBlock1(sheet, maxMessageSize, spriteContainer == null ? 0
+ : spriteContainer.getPadding());
+ return new SheetBlock2(sheetBlock1, sheetBlock1, new UStroke(1.5));
+ }
+
+ private static TextBlock createMessageNumber(Display texts, FontConfiguration fontConfiguration,
+ HorizontalAlignment horizontalAlignment, ISkinSimple spriteContainer, double maxMessageSize) {
+ TextBlock tb1 = getCreole(texts.subList(0, 1), fontConfiguration, horizontalAlignment, spriteContainer,
+ maxMessageSize, false);
+ tb1 = TextBlockUtils.withMargin(tb1, 0, 4, 0, 0);
+ final TextBlock tb2 = getCreole(texts.subList(1, texts.size()), fontConfiguration, horizontalAlignment,
+ spriteContainer, maxMessageSize, false);
+ return TextBlockUtils.mergeLR(tb1, tb2, VerticalAlignment.CENTER);
+
+ }
+
+ private static TextBlock createStereotype(Display texts, FontConfiguration fontConfiguration,
+ HorizontalAlignment horizontalAlignment, SpriteContainer spriteContainer, int position,
+ UFont fontForStereotype, HtmlColor htmlColorForStereotype) {
+ final Stereotype stereotype = (Stereotype) texts.get(position);
+ if (stereotype.isSpotted()) {
+ final CircledCharacter circledCharacter = new CircledCharacter(stereotype.getCharacter(),
+ stereotype.getRadius(), stereotype.getCircledFont(), stereotype.getHtmlColor(), null,
+ fontConfiguration.getColor());
+ if (stereotype.getLabel(false) == null) {
+ return new TextBlockSpotted(circledCharacter, texts.subList(1, texts.size()), fontConfiguration,
+ horizontalAlignment, spriteContainer);
+ }
+ return new TextBlockSpotted(circledCharacter, texts, fontConfiguration, horizontalAlignment,
+ spriteContainer);
+ }
+ return new TextBlockSimple(texts, fontConfiguration, horizontalAlignment, spriteContainer, 0, fontForStereotype, htmlColorForStereotype);
+ }
+
+ public static TextBlock withMargin(TextBlock textBlock, double marginX, double marginY) {
+ return new TextBlockMarged(textBlock, marginX, marginX, marginY, marginY);
+ }
+
+ public static TextBlock withMinWidth(TextBlock textBlock, double minWidth, HorizontalAlignment horizontalAlignment) {
+ return new TextBlockMinWidth(textBlock, minWidth, horizontalAlignment);
+ }
+
+ public static TextBlock withMargin(TextBlock textBlock, double marginX1, double marginX2, double marginY1,
+ double marginY2) {
+ return new TextBlockMarged(textBlock, marginX1, marginX2, marginY1, marginY2);
+ }
+
+ public static TextBlock empty(final double width, final double height) {
+ return new TextBlock() {
+ public void drawU(UGraphic ug) {
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(width, height);
+ }
+ };
+ }
+
+ public static Positionable asPositionable(TextBlock textBlock, StringBounder stringBounder, Point2D pt) {
+ return new PositionableImpl(pt, textBlock.calculateDimension(stringBounder));
+ }
+
+ public static TextBlock mergeLR(TextBlock b1, TextBlock b2, VerticalAlignment verticallAlignment) {
+ return new TextBlockHorizontal(b1, b2, verticallAlignment);
+ }
+
+ public static TextBlock mergeTB(TextBlock b1, TextBlock b2, HorizontalAlignment horizontalAlignment) {
+ return new TextBlockVertical2(b1, b2, horizontalAlignment);
+ }
+
+ public static MinMax getMinMax(TextBlock tb, StringBounder stringBounder) {
+ final LimitFinder limitFinder = new LimitFinder(stringBounder, false);
+ tb.drawU(limitFinder);
+ return limitFinder.getMinMax();
+ }
+
+ private static final Graphics2D gg;
+ private static final StringBounder dummyStringBounder;
+
+ static {
+ final BufferedImage imDummy = new BufferedImage(10, 10, BufferedImage.TYPE_INT_RGB);
+ gg = imDummy.createGraphics();
+ dummyStringBounder = StringBounderUtils.asStringBounder(gg);
+ }
+
+ public static StringBounder getDummyStringBounder() {
+ return dummyStringBounder;
+ }
+
+ public static FontRenderContext getFontRenderContext() {
+ return gg.getFontRenderContext();
+ }
+
+ public static MinMax getMinMax(TextBlock tb) {
+ return getMinMax(tb, dummyStringBounder);
+ }
+
+ public static Dimension2D getDimension(TextBlock tb) {
+ return tb.calculateDimension(dummyStringBounder);
+ }
+
+ public static LineMetrics getLineMetrics(UFont font, String text) {
+ return font.getLineMetrics(gg, text);
+ }
+
+ public static FontMetrics getFontMetrics(Font font) {
+ return gg.getFontMetrics(font);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockVertical2.java b/src/net/sourceforge/plantuml/graphic/TextBlockVertical2.java
new file mode 100644
index 0000000..fbf3cb8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/TextBlockVertical2.java
@@ -0,0 +1,89 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class TextBlockVertical2 implements TextBlock {
+
+ private final List<TextBlock> blocks = new ArrayList<TextBlock>();
+ private final HorizontalAlignment horizontalAlignment;
+
+ public TextBlockVertical2(TextBlock b1, TextBlock b2, HorizontalAlignment horizontalAlignment) {
+ this.blocks.add(b1);
+ this.blocks.add(b2);
+ this.horizontalAlignment = horizontalAlignment;
+ }
+
+ public TextBlockVertical2(List<TextBlock> all, HorizontalAlignment horizontalAlignment) {
+ if (all.size() < 2) {
+ throw new IllegalArgumentException();
+ }
+ this.blocks.addAll(all);
+ this.horizontalAlignment = horizontalAlignment;
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ Dimension2D dim = blocks.get(0).calculateDimension(stringBounder);
+ for (int i = 1; i < blocks.size(); i++) {
+ dim = Dimension2DDouble.mergeTB(dim, blocks.get(i).calculateDimension(stringBounder));
+ }
+ return dim;
+ }
+
+ public void drawU(UGraphic ug) {
+ double y = 0;
+ final Dimension2D dimtotal = calculateDimension(ug.getStringBounder());
+ for (TextBlock b : blocks) {
+ final Dimension2D dimb = b.calculateDimension(ug.getStringBounder());
+ if (horizontalAlignment == HorizontalAlignment.LEFT) {
+ b.drawU(ug.apply(new UTranslate(0, y)));
+ } else if (horizontalAlignment == HorizontalAlignment.CENTER) {
+ final double dx = (dimtotal.getWidth() - dimb.getWidth()) / 2;
+ b.drawU(ug.apply(new UTranslate(dx, y)));
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ y += dimb.getHeight();
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockWidth.java b/src/net/sourceforge/plantuml/graphic/TextBlockWidth.java
new file mode 100644
index 0000000..4da6229
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/TextBlockWidth.java
@@ -0,0 +1,44 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+public interface TextBlockWidth {
+
+ Dimension2D calculateDimension(StringBounder stringBounder);
+
+ TextBlock asTextBlock(double widthToUse);
+}
diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockWidthAdapter.java b/src/net/sourceforge/plantuml/graphic/TextBlockWidthAdapter.java
new file mode 100644
index 0000000..fbf3c63
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/TextBlockWidthAdapter.java
@@ -0,0 +1,63 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class TextBlockWidthAdapter implements TextBlock {
+
+ private final TextBlockWidth textBlockWidth;
+ private final double width;
+
+ // public final void setWidth(double width) {
+ // this.width = width;
+ // }
+
+ public TextBlockWidthAdapter(TextBlockWidth textBlockWidth, double widthToUse) {
+ this.textBlockWidth = textBlockWidth;
+ this.width = widthToUse;
+ }
+
+ public void drawU(UGraphic ug) {
+ textBlockWidth.asTextBlock(width).drawU(ug);
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return textBlockWidth.calculateDimension(stringBounder);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/TextLink.java b/src/net/sourceforge/plantuml/graphic/TextLink.java
new file mode 100644
index 0000000..f5c2e82
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/TextLink.java
@@ -0,0 +1,58 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import net.sourceforge.plantuml.Url;
+
+public class TextLink implements HtmlCommand {
+
+ private final Url url;
+
+ TextLink(Url url) {
+ if (url == null) {
+ throw new IllegalArgumentException();
+ }
+ this.url = url;
+ }
+
+ public String getText() {
+ return url.getLabel();
+ }
+
+ public Url getUrl() {
+ return url;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/TileImage.java b/src/net/sourceforge/plantuml/graphic/TileImage.java
new file mode 100644
index 0000000..8d254f2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/TileImage.java
@@ -0,0 +1,66 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+import java.awt.image.BufferedImage;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UImage;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class TileImage implements TextBlock {
+
+ private final BufferedImage image;
+ private final int vspace;
+
+ public TileImage(BufferedImage image, ImgValign valign, int vspace) {
+ if (image == null) {
+ throw new IllegalArgumentException();
+ }
+ this.image = image;
+ this.vspace = vspace;
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(image.getWidth(), image.getHeight() + 2 * vspace);
+ }
+
+ public void drawU(UGraphic ug) {
+ ug.apply(new UTranslate(0, vspace)).draw(new UImage(image));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/TileImageSvg.java b/src/net/sourceforge/plantuml/graphic/TileImageSvg.java
new file mode 100644
index 0000000..623dd14
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/TileImageSvg.java
@@ -0,0 +1,74 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UImageSvg;
+
+public class TileImageSvg implements TextBlock {
+
+ private final UImageSvg svg;
+
+ public TileImageSvg(File svgFile) throws IOException {
+ this.svg = createSvg(svgFile);
+ }
+
+ private UImageSvg createSvg(File svgFile) throws IOException {
+ final BufferedReader br = new BufferedReader(new FileReader(svgFile));
+ final StringBuilder sb = new StringBuilder();
+ String s;
+ while ((s = br.readLine()) != null) {
+ sb.append(s);
+ }
+ br.close();
+ return new UImageSvg(sb.toString());
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(svg.getWidth(), svg.getHeight());
+ }
+
+ public void drawU(UGraphic ug) {
+ ug.draw(svg);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/TileText.java b/src/net/sourceforge/plantuml/graphic/TileText.java
new file mode 100644
index 0000000..f9511c4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/TileText.java
@@ -0,0 +1,134 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+import java.util.StringTokenizer;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.Log;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UText;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class TileText implements TextBlock {
+
+ private final String text;
+ private final FontConfiguration fontConfiguration;
+ private final Url url;
+
+ public TileText(String text, FontConfiguration fontConfiguration, Url url) {
+ this.fontConfiguration = fontConfiguration;
+ this.text = text;
+ this.url = url;
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D rect = stringBounder.calculateDimension(fontConfiguration.getFont(), text);
+ final int spaceBottom = Math.abs(fontConfiguration.getSpace());
+ Log.debug("g2d=" + rect);
+ Log.debug("Size for " + text + " is " + rect);
+ double h = rect.getHeight();
+ if (h < 10) {
+ h = 10;
+ }
+ final double width = text.indexOf('\t') == -1 ? rect.getWidth() : getWidth(stringBounder);
+ return new Dimension2DDouble(width, h + spaceBottom);
+ }
+
+ public double getFontSize2D() {
+ return fontConfiguration.getFont().getSize2D();
+ }
+
+ double getTabSize(StringBounder stringBounder) {
+ return stringBounder.calculateDimension(fontConfiguration.getFont(), " ").getWidth();
+ }
+
+ public void drawU(UGraphic ug) {
+ double x = 0;
+ if (url != null) {
+ ug.startUrl(url);
+ }
+ ug = ug.apply(new UChangeColor(fontConfiguration.getColor()));
+
+ final StringTokenizer tokenizer = new StringTokenizer(text, "\t", true);
+
+ if (tokenizer.hasMoreTokens()) {
+ final double tabSize = getTabSize(ug.getStringBounder());
+ while (tokenizer.hasMoreTokens()) {
+ final String s = tokenizer.nextToken();
+ if (s.equals("\t")) {
+ final double remainder = x % tabSize;
+ x += tabSize - remainder;
+ } else {
+ final UText utext = new UText(s, fontConfiguration);
+ final Dimension2D dim = ug.getStringBounder().calculateDimension(fontConfiguration.getFont(), s);
+ final int space = fontConfiguration.getSpace();
+ final double ypos;
+ if (space < 0) {
+ ypos = space /*- getFontSize2D() - space*/;
+ } else {
+ ypos = space;
+ }
+ ug.apply(new UTranslate(x, ypos)).draw(utext);
+ x += dim.getWidth();
+ }
+ }
+ }
+ if (url != null) {
+ ug.closeAction();
+ }
+ }
+
+ double getWidth(StringBounder stringBounder) {
+ final StringTokenizer tokenizer = new StringTokenizer(text, "\t", true);
+ final double tabSize = getTabSize(stringBounder);
+ double x = 0;
+ while (tokenizer.hasMoreTokens()) {
+ final String s = tokenizer.nextToken();
+ if (s.equals("\t")) {
+ final double remainder = x % tabSize;
+ x += tabSize - remainder;
+ } else {
+ final Dimension2D dim = stringBounder.calculateDimension(fontConfiguration.getFont(), s);
+ x += dim.getWidth();
+ }
+ }
+ return x;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/UDrawable.java b/src/net/sourceforge/plantuml/graphic/UDrawable.java
new file mode 100644
index 0000000..9bbbd02
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/UDrawable.java
@@ -0,0 +1,43 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public interface UDrawable {
+
+ public void drawU(UGraphic ug);
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/UDrawableUtils.java b/src/net/sourceforge/plantuml/graphic/UDrawableUtils.java
new file mode 100644
index 0000000..b5b00c7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/UDrawableUtils.java
@@ -0,0 +1,50 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class UDrawableUtils {
+
+ public static UDrawable move(final UDrawable orig, final double dx, final double dy) {
+ return new UDrawable() {
+ public void drawU(UGraphic ug) {
+ orig.drawU(ug.apply(new UTranslate(dx, dy)));
+ }
+ };
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/UGraphicDelegator.java b/src/net/sourceforge/plantuml/graphic/UGraphicDelegator.java
new file mode 100644
index 0000000..8e475eb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/UGraphicDelegator.java
@@ -0,0 +1,91 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public abstract class UGraphicDelegator implements UGraphic {
+
+ final private UGraphic ug;
+
+ public final boolean isSpecialTxt() {
+ return ug.isSpecialTxt();
+ }
+
+
+ public UGraphicDelegator(UGraphic ug) {
+ this.ug = ug;
+ }
+
+ public StringBounder getStringBounder() {
+ return ug.getStringBounder();
+ }
+
+ public UParam getParam() {
+ return ug.getParam();
+ }
+
+ public void draw(UShape shape) {
+ ug.draw(shape);
+ }
+
+ public ColorMapper getColorMapper() {
+ return ug.getColorMapper();
+ }
+
+ public void startUrl(Url url) {
+ ug.startUrl(url);
+ }
+
+ public void closeAction() {
+ ug.closeAction();
+ }
+
+ protected UGraphic getUg() {
+ return ug;
+ }
+
+ public void flushUg() {
+ ug.flushUg();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/UGraphicInterceptorUDrawable.java b/src/net/sourceforge/plantuml/graphic/UGraphicInterceptorUDrawable.java
new file mode 100644
index 0000000..6e13067
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/UGraphicInterceptorUDrawable.java
@@ -0,0 +1,61 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import net.sourceforge.plantuml.ugraphic.UChange;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class UGraphicInterceptorUDrawable extends UGraphicDelegator {
+
+ public UGraphicInterceptorUDrawable(UGraphic ug) {
+ super(ug);
+ }
+
+ public void draw(UShape shape) {
+ if (shape instanceof UDrawable) {
+ final UDrawable drawable = (UDrawable) shape;
+ drawable.drawU(this);
+ } else {
+ getUg().draw(shape);
+ }
+
+ }
+
+ public UGraphic apply(UChange change) {
+ return new UGraphicInterceptorUDrawable(getUg().apply(change));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/USymbol.java b/src/net/sourceforge/plantuml/graphic/USymbol.java
new file mode 100644
index 0000000..d159f96
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/USymbol.java
@@ -0,0 +1,159 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+import java.util.HashMap;
+import java.util.Map;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.StringUtils;
+
+public abstract class USymbol {
+
+ private static final Map<String, USymbol> all = new HashMap<String, USymbol>();
+
+ public final static USymbol STORAGE = record("STORAGE", SkinParameter.STORAGE, new USymbolStorage());
+ public final static USymbol DATABASE = record("DATABASE", SkinParameter.DATABASE, new USymbolDatabase());
+ public final static USymbol CLOUD = record("CLOUD", SkinParameter.CLOUD, new USymbolCloud());
+ public final static USymbol CARD = record("CARD", SkinParameter.CARD, new USymbolCard(SkinParameter.CARD));
+ public final static USymbol FRAME = record("FRAME", SkinParameter.FRAME, new USymbolFrame());
+ public final static USymbol NODE = record("NODE", SkinParameter.NODE, new USymbolNode());
+ public final static USymbol ARTIFACT = record("ARTIFACT", SkinParameter.ARTIFACT, new USymbolArtifact());
+ public final static USymbol PACKAGE = record("PACKAGE", SkinParameter.PACKAGE, new USymbolFolder(
+ SkinParameter.PACKAGE));
+ public final static USymbol FOLDER = record("FOLDER", SkinParameter.FOLDER, new USymbolFolder(SkinParameter.FOLDER));
+ public final static USymbol RECTANGLE = record("RECTANGLE", SkinParameter.CARD, new USymbolRect(SkinParameter.CARD));
+ public final static USymbol AGENT = record("AGENT", SkinParameter.AGENT, new USymbolRect(SkinParameter.AGENT));
+ public final static USymbol ACTOR = record("ACTOR", SkinParameter.ACTOR, new USymbolActor());
+ public final static USymbol USECASE = null;
+ public final static USymbol COMPONENT1 = record("COMPONENT1", SkinParameter.COMPONENT1, new USymbolComponent1());
+ 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_DOMAIN,
+ new USymbolEntityDomain(2));
+ public final static USymbol CONTROL = record("CONTROL", SkinParameter.CONTROL, new USymbolControl(2));
+ public final static USymbol INTERFACE = record("INTERFACE", SkinParameter.INTERFACE, new USymbolInterface());
+ public final static USymbol QUEUE = record("QUEUE", SkinParameter.QUEUE, new USymbolQueue());
+
+ abstract public SkinParameter getSkinParameter();
+
+ public FontParam getFontParam() {
+ return getSkinParameter().getFontParam();
+ }
+
+ public FontParam getFontParamStereotype() {
+ return getSkinParameter().getFontParamStereotype();
+
+ }
+
+ public ColorParam getColorParamBack() {
+ return getSkinParameter().getColorParamBack();
+ }
+
+ public ColorParam getColorParamBorder() {
+ return getSkinParameter().getColorParamBorder();
+ }
+
+ public static USymbol getFromString(String s) {
+ final USymbol result = all.get(StringUtils.goUpperCase(s));
+ if (result == null) {
+ if (s.equalsIgnoreCase("component")) {
+ return COMPONENT2;
+ }
+ throw new IllegalArgumentException("s=" + s);
+ }
+ return result;
+ }
+
+ private static USymbol record(String code, SkinParameter skinParameter, USymbol symbol) {
+ all.put(StringUtils.goUpperCase(code), symbol);
+ return symbol;
+ }
+
+ public abstract TextBlock asSmall(TextBlock label, TextBlock stereotype, SymbolContext symbolContext);
+
+ public abstract TextBlock asBig(TextBlock label, TextBlock stereotype, double width, double height,
+ SymbolContext symbolContext);
+
+ static class Margin {
+ private final double x1;
+ private final double x2;
+ private final double y1;
+ private final double y2;
+
+ Margin(double x1, double x2, double y1, double y2) {
+ this.x1 = x1;
+ this.x2 = x2;
+ this.y1 = y1;
+ this.y2 = y2;
+ }
+
+ double getWidth() {
+ return x1 + x2;
+ }
+
+ double getHeight() {
+ return y1 + y2;
+ }
+
+ public Dimension2D addDimension(Dimension2D dim) {
+ return new Dimension2DDouble(dim.getWidth() + x1 + x2, dim.getHeight() + y1 + y2);
+ }
+
+ public double getX1() {
+ return x1;
+ }
+
+ public double getY1() {
+ return y1;
+ }
+ }
+
+ public boolean manageHorizontalLine() {
+ return false;
+ }
+
+ public int suppHeightBecauseOfShape() {
+ return 0;
+ }
+
+ public int suppWidthBecauseOfShape() {
+ return 0;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/USymbolActor.java b/src/net/sourceforge/plantuml/graphic/USymbolActor.java
new file mode 100644
index 0000000..ac209d1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/USymbolActor.java
@@ -0,0 +1,54 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import net.sourceforge.plantuml.skin.StickMan;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+
+class USymbolActor extends USymbolSimpleAbstract {
+
+ @Override
+ public SkinParameter getSkinParameter() {
+ return SkinParameter.ACTOR;
+ }
+
+
+ @Override
+ protected TextBlock getDrawing(SymbolContext symbolContext) {
+ final double deltaShadow = symbolContext.isShadowing() ? 4.0 : 0.0;
+ return new StickMan(symbolContext.withDeltaShadow(deltaShadow).withStroke(new UStroke(2)));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/USymbolArtifact.java b/src/net/sourceforge/plantuml/graphic/USymbolArtifact.java
new file mode 100644
index 0000000..79cd066
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/USymbolArtifact.java
@@ -0,0 +1,132 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class USymbolArtifact extends USymbol {
+
+ @Override
+ public SkinParameter getSkinParameter() {
+ return SkinParameter.ARTIFACT;
+ }
+
+
+ private void drawArtifact(UGraphic ug, double widthTotal, double heightTotal, boolean shadowing) {
+
+ final URectangle form = new URectangle(widthTotal, heightTotal);
+ if (shadowing) {
+ form.setDeltaShadow(4);
+ }
+
+ ug.draw(form);
+
+ final UPolygon polygon = new UPolygon();
+ polygon.addPoint(0, 0);
+ final double heightSymbol = 14;
+ polygon.addPoint(0, heightSymbol);
+ final double widthSymbol = 12;
+ polygon.addPoint(widthSymbol, heightSymbol);
+ final int cornersize = 6;
+ polygon.addPoint(widthSymbol, cornersize);
+ polygon.addPoint(widthSymbol - cornersize, 0);
+ polygon.addPoint(0, 0);
+ // if (shadowing) {
+ // polygon.setDeltaShadow(3.0);
+ // }
+
+ final double xSymbol = widthTotal - widthSymbol - 5;
+ final double ySymbol = 5;
+
+ ug.apply(new UTranslate(xSymbol, ySymbol)).draw(polygon);
+ ug.apply(new UTranslate(xSymbol + widthSymbol - cornersize, ySymbol)).draw(new ULine(0, cornersize));
+ ug.apply(new UTranslate(xSymbol + widthSymbol, ySymbol + cornersize)).draw(new ULine(-cornersize, 0));
+
+ }
+
+ private Margin getMargin() {
+ return new Margin(10, 10 + 10, 10 + 3, 10);
+ }
+
+ public TextBlock asSmall(final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ ug = symbolContext.apply(ug);
+ drawArtifact(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing());
+ final Margin margin = getMargin();
+ final TextBlock tb = TextBlockUtils.mergeTB(stereotype, label, HorizontalAlignment.CENTER);
+ tb.drawU(ug.apply(new UTranslate(margin.getX1(), margin.getY1())));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dimLabel = label.calculateDimension(stringBounder);
+ final Dimension2D dimStereo = stereotype.calculateDimension(stringBounder);
+ return getMargin().addDimension(Dimension2DDouble.mergeTB(dimStereo, dimLabel));
+ }
+ };
+ }
+
+ public TextBlock asBig(final TextBlock title, final TextBlock stereotype, final double width, final double height,
+ final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ ug = symbolContext.apply(ug);
+ drawArtifact(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing());
+ final Dimension2D dimStereo = stereotype.calculateDimension(ug.getStringBounder());
+ final double posStereo = (width - dimStereo.getWidth()) / 2;
+ stereotype.drawU(ug.apply(new UTranslate(posStereo, 2)));
+ final Dimension2D dimTitle = title.calculateDimension(ug.getStringBounder());
+ final double posTitle = (width - dimTitle.getWidth()) / 2;
+ title.drawU(ug.apply(new UTranslate(posTitle, 2 + dimStereo.getHeight())));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(width, height);
+ }
+ };
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/USymbolBoundary.java b/src/net/sourceforge/plantuml/graphic/USymbolBoundary.java
new file mode 100644
index 0000000..dbf67f9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/USymbolBoundary.java
@@ -0,0 +1,53 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import net.sourceforge.plantuml.svek.Boundary;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+
+class USymbolBoundary extends USymbolSimpleAbstract {
+
+ @Override
+ public SkinParameter getSkinParameter() {
+ 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)));
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graphic/USymbolCard.java b/src/net/sourceforge/plantuml/graphic/USymbolCard.java
new file mode 100644
index 0000000..7b44855
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/USymbolCard.java
@@ -0,0 +1,117 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class USymbolCard extends USymbol {
+
+ private final SkinParameter skinParameter;
+
+ public USymbolCard(SkinParameter skinParameter) {
+ this.skinParameter = skinParameter;
+ }
+
+ @Override
+ public SkinParameter getSkinParameter() {
+ return skinParameter;
+ }
+
+
+ private void drawRect(UGraphic ug, double width, double height, boolean shadowing, double top) {
+ final URectangle shape = new URectangle(width, height);
+ if (shadowing) {
+ shape.setDeltaShadow(3.0);
+ }
+ ug.draw(shape);
+ if (top != 0) {
+ ug.apply(new UTranslate(0, top)).draw(new ULine(width, 0));
+ }
+ }
+
+ private Margin getMargin() {
+ return new Margin(10, 10, 3, 3);
+ }
+
+ public TextBlock asSmall(final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ ug = symbolContext.apply(ug);
+ drawRect(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing(), 0);
+ final Margin margin = getMargin();
+ final TextBlock tb = TextBlockUtils.mergeTB(stereotype, label, HorizontalAlignment.CENTER);
+ tb.drawU(ug.apply(new UTranslate(margin.getX1(), margin.getY1())));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dimLabel = label.calculateDimension(stringBounder);
+ final Dimension2D dimStereo = stereotype.calculateDimension(stringBounder);
+ return getMargin().addDimension(Dimension2DDouble.mergeTB(dimStereo, dimLabel));
+ }
+ };
+ }
+
+ public TextBlock asBig(final TextBlock title, final TextBlock stereotype, final double width, final double height,
+ final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ ug = symbolContext.apply(ug);
+ final Dimension2D dimStereo = stereotype.calculateDimension(ug.getStringBounder());
+ final Dimension2D dimTitle = title.calculateDimension(ug.getStringBounder());
+ drawRect(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing(), dimTitle.getHeight()
+ + dimStereo.getHeight() + 4);
+ final double posStereo = (width - dimStereo.getWidth()) / 2;
+ stereotype.drawU(ug.apply(new UTranslate(posStereo, 2)));
+ final double posTitle = (width - dimTitle.getWidth()) / 2;
+ title.drawU(ug.apply(new UTranslate(posTitle, 2 + dimStereo.getHeight())));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(width, height);
+ }
+ };
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/USymbolCloud.java b/src/net/sourceforge/plantuml/graphic/USymbolCloud.java
new file mode 100644
index 0000000..a867749
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/USymbolCloud.java
@@ -0,0 +1,132 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class USymbolCloud extends USymbol {
+
+ @Override
+ public SkinParameter getSkinParameter() {
+ return SkinParameter.CLOUD;
+ }
+
+
+ private void drawCloud(UGraphic ug, double width, double height, boolean shadowing) {
+ final UPath shape = getSpecificFrontierForCloud(width, height);
+ if (shadowing) {
+ shape.setDeltaShadow(3.0);
+ }
+ ug.apply(new UTranslate(3, -3)).draw(shape);
+ }
+
+ private UPath getSpecificFrontierForCloud(double width, double height) {
+ final UPath path = new UPath();
+ path.moveTo(0, 10);
+ double x = 0;
+ for (int i = 0; i < width - 9; i += 10) {
+ path.cubicTo(i, -3 + 10, 2 + i, -5 + 10, 5 + i, -5 + 10);
+ path.cubicTo(8 + i, -5 + 10, 10 + i, -3 + 10, 10 + i, 10);
+ x = i + 10;
+ }
+ double y = 0;
+ for (int j = 10; j < height - 9; j += 10) {
+ path.cubicTo(x + 3, j, x + 5, 2 + j, x + 5, 5 + j);
+ path.cubicTo(x + 5, 8 + j, x + 3, 10 + j, x, 10 + j);
+ y = j + 10;
+ }
+ for (int i = 0; i < width - 9; i += 10) {
+ path.cubicTo(x - i, y + 3, x - 3 - i, y + 5, x - 5 - i, y + 5);
+ path.cubicTo(x - 8 - i, y + 5, x - 10 - i, y + 3, x - 10 - i, y);
+ }
+ for (int j = 0; j < height - 9 - 10; j += 10) {
+ path.cubicTo(-3, y - j, -5, y - 2 - j, -5, y - 5 - j);
+ path.cubicTo(-5, y - 8 - j, -3, y - 10 - j, 0, y - 10 - j);
+ }
+ return path;
+ }
+
+ private Margin getMargin() {
+ return new Margin(10, 10, 10, 10);
+ }
+
+ public TextBlock asSmall(final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ ug = symbolContext.apply(ug);
+ drawCloud(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing());
+ final Margin margin = getMargin();
+ final TextBlock tb = TextBlockUtils.mergeTB(stereotype, label, HorizontalAlignment.CENTER);
+ tb.drawU(ug.apply(new UTranslate(margin.getX1(), margin.getY1())));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dimLabel = label.calculateDimension(stringBounder);
+ final Dimension2D dimStereo = stereotype.calculateDimension(stringBounder);
+ return getMargin().addDimension(Dimension2DDouble.mergeTB(dimStereo, dimLabel));
+ }
+ };
+ }
+
+ public TextBlock asBig(final TextBlock title, final TextBlock stereotype, final double width, final double height,
+ final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ ug = symbolContext.apply(ug);
+ drawCloud(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing());
+ final Dimension2D dimStereo = stereotype.calculateDimension(ug.getStringBounder());
+ final double posStereo = (width - dimStereo.getWidth()) / 2;
+ stereotype.drawU(ug.apply(new UTranslate(posStereo, 13)));
+ final Dimension2D dimTitle = title.calculateDimension(ug.getStringBounder());
+ final double posTitle = (width - dimTitle.getWidth()) / 2;
+ title.drawU(ug.apply(new UTranslate(posTitle, 13 + dimStereo.getHeight())));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(width, height);
+ }
+ };
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/USymbolComponent1.java b/src/net/sourceforge/plantuml/graphic/USymbolComponent1.java
new file mode 100644
index 0000000..2445c8b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/USymbolComponent1.java
@@ -0,0 +1,99 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class USymbolComponent1 extends USymbol {
+
+ @Override
+ public SkinParameter getSkinParameter() {
+ return SkinParameter.COMPONENT1;
+ }
+
+
+ private void drawNode(UGraphic ug, double widthTotal, double heightTotal, boolean shadowing) {
+
+ final URectangle form = new URectangle(widthTotal, heightTotal);
+ if (shadowing) {
+ form.setDeltaShadow(4);
+ }
+
+ ug.draw(form);
+ final UShape small = new URectangle(10, 5);
+
+ // UML 1 Component Notation
+ ug.apply(new UTranslate(-5, 5)).draw(small);
+ ug.apply(new UTranslate(-5, heightTotal - 10)).draw(small);
+
+ }
+
+ private Margin getMargin() {
+ return new Margin(10, 10, 10, 10);
+ }
+
+ public TextBlock asSmall(final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D dimTotal = calculateDimension(stringBounder);
+ ug = symbolContext.apply(ug);
+ drawNode(ug, dimTotal.getWidth(), dimTotal.getHeight(), symbolContext.isShadowing());
+ final Margin margin = getMargin();
+ final TextBlock tb = TextBlockUtils.mergeTB(stereotype, label, HorizontalAlignment.CENTER);
+ tb.drawU(ug.apply(new UTranslate(margin.getX1(), margin.getY1())));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dimLabel = label.calculateDimension(stringBounder);
+ final Dimension2D dimStereo = stereotype.calculateDimension(stringBounder);
+ return getMargin().addDimension(Dimension2DDouble.mergeTB(dimStereo, dimLabel));
+ }
+ };
+ }
+
+ public TextBlock asBig(final TextBlock title, TextBlock stereotype, final double width, final double height,
+ final SymbolContext symbolContext) {
+ throw new UnsupportedOperationException();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/USymbolComponent2.java b/src/net/sourceforge/plantuml/graphic/USymbolComponent2.java
new file mode 100644
index 0000000..6a74bc6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/USymbolComponent2.java
@@ -0,0 +1,114 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class USymbolComponent2 extends USymbol {
+
+ @Override
+ public SkinParameter getSkinParameter() {
+ return SkinParameter.COMPONENT2;
+ }
+
+
+ private void drawNode(UGraphic ug, double widthTotal, double heightTotal, boolean shadowing) {
+
+ final URectangle form = new URectangle(widthTotal, heightTotal);
+ if (shadowing) {
+ form.setDeltaShadow(4);
+ }
+
+ final UShape small = new URectangle(15, 10);
+ final UShape tiny = new URectangle(4, 2);
+
+ ug.draw(form);
+
+ // UML 2 Component Notation
+ ug.apply(new UTranslate(widthTotal - 20, 5)).draw(small);
+ ug.apply(new UTranslate(widthTotal - 22, 7)).draw(tiny);
+ ug.apply(new UTranslate(widthTotal - 22, 11)).draw(tiny);
+
+ }
+
+ private Margin getMargin() {
+ return new Margin(10 + 5, 20 + 5, 15 + 5, 5 + 5);
+ }
+
+ public TextBlock asSmall(final TextBlock label, TextBlock stereotype, final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ ug = symbolContext.apply(ug);
+ drawNode(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing());
+ final Margin margin = getMargin();
+ label.drawU(ug.apply(new UTranslate(margin.getX1(), margin.getY1())));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dim = label.calculateDimension(stringBounder);
+ return getMargin().addDimension(dim);
+ }
+ };
+ }
+
+ public TextBlock asBig(final TextBlock title, TextBlock stereotype, final double width, final double height,
+ final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ ug = symbolContext.apply(ug);
+ drawNode(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing());
+ title.drawU(ug.apply(new UTranslate(3, 13)));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(width, height);
+ }
+
+ };
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/USymbolControl.java b/src/net/sourceforge/plantuml/graphic/USymbolControl.java
new file mode 100644
index 0000000..7f9dfbd
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/USymbolControl.java
@@ -0,0 +1,60 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+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)));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/USymbolDatabase.java b/src/net/sourceforge/plantuml/graphic/USymbolDatabase.java
new file mode 100644
index 0000000..4eda644
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/USymbolDatabase.java
@@ -0,0 +1,169 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.AbstractUGraphicHorizontalLine;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UHorizontalLine;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class USymbolDatabase extends USymbol {
+
+ @Override
+ public SkinParameter getSkinParameter() {
+ return SkinParameter.DATABASE;
+ }
+
+
+
+ private void drawDatabase(UGraphic ug, double width, double height, boolean shadowing) {
+ final UPath shape = new UPath();
+ if (shadowing) {
+ shape.setDeltaShadow(3.0);
+ }
+ shape.moveTo(0, 10);
+ shape.cubicTo(0, 0, width / 2, 0, width / 2, 0);
+ shape.cubicTo(width / 2, 0, width, 0, width, 10);
+ shape.lineTo(width, height - 10);
+ shape.cubicTo(width, height, width / 2, height, width / 2, height);
+ shape.cubicTo(width / 2, height, 0, height, 0, height - 10);
+ shape.lineTo(0, 10);
+
+ ug.draw(shape);
+
+ final UPath closing = getClosingPath(width);
+ ug.apply(new UChangeBackColor(null)).draw(closing);
+
+ }
+
+ private UPath getClosingPath(double width) {
+ final UPath closing = new UPath();
+ closing.moveTo(0, 10);
+ closing.cubicTo(0, 20, width / 2, 20, width / 2, 20);
+ closing.cubicTo(width / 2, 20, width, 20, width, 10);
+ return closing;
+ }
+
+ class MyUGraphicDatabase extends AbstractUGraphicHorizontalLine {
+
+ private final double endingX;
+
+ @Override
+ protected AbstractUGraphicHorizontalLine copy(UGraphic ug) {
+ return new MyUGraphicDatabase(ug, endingX);
+ }
+
+ public MyUGraphicDatabase(UGraphic ug, double endingX) {
+ super(ug);
+ this.endingX = endingX;
+ }
+
+ @Override
+ protected void drawHline(UGraphic ug, UHorizontalLine line, UTranslate translate) {
+ final UPath closing = getClosingPath(endingX);
+ ug = ug.apply(translate);
+ ug.apply(line.getStroke()).apply(new UChangeBackColor(null)).apply(new UTranslate(0, -15)).draw(closing);
+ if (line.isDouble()) {
+ ug.apply(line.getStroke()).apply(new UChangeBackColor(null)).apply(new UTranslate(0, -15 + 2))
+ .draw(closing);
+ }
+ line.drawTitleInternal(ug, 0, endingX, 0, true);
+ }
+
+ }
+
+ private Margin getMargin() {
+ return new Margin(10, 10, 20, 5);
+ }
+
+ public TextBlock asSmall(final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ ug = symbolContext.apply(ug);
+ drawDatabase(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing());
+ final Margin margin = getMargin();
+ final TextBlock tb = TextBlockUtils.mergeTB(stereotype, label, HorizontalAlignment.CENTER);
+ final UGraphic ug2 = new MyUGraphicDatabase(ug, dim.getWidth());
+ tb.drawU(ug2.apply(new UTranslate(margin.getX1(), margin.getY1())));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dimLabel = label.calculateDimension(stringBounder);
+ final Dimension2D dimStereo = stereotype.calculateDimension(stringBounder);
+ return getMargin().addDimension(Dimension2DDouble.mergeTB(dimStereo, dimLabel));
+ }
+ };
+ }
+
+ public TextBlock asBig(final TextBlock title, final TextBlock stereotype, final double width, final double height,
+ final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ ug = symbolContext.apply(ug);
+ drawDatabase(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing());
+ final Dimension2D dimStereo = stereotype.calculateDimension(ug.getStringBounder());
+ final double posStereo = (width - dimStereo.getWidth()) / 2;
+ stereotype.drawU(ug.apply(new UTranslate(posStereo, 0)));
+
+ final Dimension2D dimTitle = title.calculateDimension(ug.getStringBounder());
+ final double posTitle = (width - dimTitle.getWidth()) / 2;
+ title.drawU(ug.apply(new UTranslate(posTitle, 21)));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(width, height);
+ }
+ };
+ }
+
+ public boolean manageHorizontalLine() {
+ return true;
+ }
+
+ @Override
+ public int suppHeightBecauseOfShape() {
+ return 15;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/USymbolEntityDomain.java b/src/net/sourceforge/plantuml/graphic/USymbolEntityDomain.java
new file mode 100644
index 0000000..bfc6ed6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/USymbolEntityDomain.java
@@ -0,0 +1,59 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+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_DOMAIN;
+ }
+
+
+ @Override
+ protected TextBlock getDrawing(final SymbolContext symbolContext) {
+ return new EntityDomain(symbolContext.withDeltaShadow(symbolContext.isShadowing() ? 4.0 : 0.0).withStroke(
+ new UStroke(thickness)));
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graphic/USymbolFolder.java b/src/net/sourceforge/plantuml/graphic/USymbolFolder.java
new file mode 100644
index 0000000..2c924fa
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/USymbolFolder.java
@@ -0,0 +1,150 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class USymbolFolder extends USymbol {
+
+ private final static int marginTitleX1 = 3;
+ private final static int marginTitleX2 = 3;
+ private final static int marginTitleX3 = 7;
+ private final static int marginTitleY0 = 0;
+ private final static int marginTitleY1 = 3;
+ private final static int marginTitleY2 = 3;
+
+ private final SkinParameter skinParameter;
+
+ public USymbolFolder(SkinParameter skinParameter) {
+ this.skinParameter = skinParameter;
+ }
+
+ @Override
+ public SkinParameter getSkinParameter() {
+ return skinParameter;
+ }
+
+ private void drawFolder(UGraphic ug, double width, double height, Dimension2D dimTitle, boolean shadowing) {
+
+ final double wtitle;
+ if (dimTitle.getWidth() == 0) {
+ wtitle = Math.max(30, width / 4);
+ } else {
+ wtitle = dimTitle.getWidth() + marginTitleX1 + marginTitleX2;
+ }
+ final double htitle = getHTitle(dimTitle);
+
+ final UPolygon shape = new UPolygon();
+ shape.addPoint(0, 0);
+ shape.addPoint(wtitle, 0);
+
+ shape.addPoint(wtitle + marginTitleX3, htitle);
+ shape.addPoint(width, htitle);
+ shape.addPoint(width, height);
+ shape.addPoint(0, height);
+ shape.addPoint(0, 0);
+ if (shadowing) {
+ shape.setDeltaShadow(3.0);
+ }
+ ug.draw(shape);
+ ug.apply(new UTranslate(0, htitle)).draw(new ULine(wtitle + marginTitleX3, 0));
+ }
+
+ private double getHTitle(Dimension2D dimTitle) {
+ final double htitle;
+ if (dimTitle.getWidth() == 0) {
+ htitle = 10;
+ } else {
+ htitle = dimTitle.getHeight() + marginTitleY1 + marginTitleY2;
+ }
+ return htitle;
+ }
+
+ private Margin getMargin() {
+ return new Margin(10, 10 + 10, 10 + 3, 10);
+ }
+
+ public TextBlock asSmall(final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ ug = symbolContext.apply(ug);
+ drawFolder(ug, dim.getWidth(), dim.getHeight(), new Dimension2DDouble(0, 0),
+ symbolContext.isShadowing());
+ final Margin margin = getMargin();
+ final TextBlock tb = TextBlockUtils.mergeTB(stereotype, label, HorizontalAlignment.CENTER);
+ tb.drawU(ug.apply(new UTranslate(margin.getX1(), margin.getY1())));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dimLabel = label.calculateDimension(stringBounder);
+ final Dimension2D dimStereo = stereotype.calculateDimension(stringBounder);
+ return getMargin().addDimension(Dimension2DDouble.mergeTB(dimStereo, dimLabel));
+ }
+ };
+ }
+
+ public TextBlock asBig(final TextBlock title, final TextBlock stereotype, final double width, final double height,
+ final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D dim = calculateDimension(stringBounder);
+ ug = symbolContext.apply(ug);
+ final Dimension2D dimTitle = title.calculateDimension(stringBounder);
+ drawFolder(ug, dim.getWidth(), dim.getHeight(), dimTitle, symbolContext.isShadowing());
+ title.drawU(ug.apply(new UTranslate(4, 2)));
+ final Dimension2D dimStereo = stereotype.calculateDimension(stringBounder);
+ final double posStereo = (width - dimStereo.getWidth()) / 2;
+
+ stereotype.drawU(ug.apply(new UTranslate(4 + posStereo, 2 + getHTitle(dimTitle))));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(width, height);
+ }
+
+ };
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/USymbolFrame.java b/src/net/sourceforge/plantuml/graphic/USymbolFrame.java
new file mode 100644
index 0000000..f9c146d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/USymbolFrame.java
@@ -0,0 +1,138 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class USymbolFrame extends USymbol {
+
+ @Override
+ public SkinParameter getSkinParameter() {
+ return SkinParameter.FRAME;
+ }
+
+
+ private void drawFrame(UGraphic ug, double width, double height, Dimension2D dimTitle, boolean shadowing) {
+ final URectangle shape = new URectangle(width, height);
+ if (shadowing) {
+ shape.setDeltaShadow(3.0);
+ }
+
+ ug.draw(shape);
+
+ final double textWidth;
+ final int cornersize;
+ if (dimTitle.getWidth() == 0) {
+ textWidth = width / 3;
+ cornersize = 7;
+ } else {
+ textWidth = dimTitle.getWidth() + 10;
+ cornersize = 10;
+ }
+ final double textHeight = getYpos(dimTitle);
+
+ final UPath polygon = new UPath();
+ polygon.moveTo(textWidth, 1);
+
+ polygon.lineTo(textWidth, textHeight - cornersize);
+ polygon.lineTo(textWidth - cornersize, textHeight);
+
+ polygon.lineTo(0, textHeight);
+ ug.draw(polygon);
+
+ }
+
+ private double getYpos(Dimension2D dimTitle) {
+ if (dimTitle.getWidth() == 0) {
+ return 12;
+ }
+ return dimTitle.getHeight() + 3;
+ }
+
+ private Margin getMargin() {
+ return new Margin(10 + 5, 20 + 5, 15 + 5, 5 + 5);
+ }
+
+ public TextBlock asSmall(final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ ug = symbolContext.apply(ug);
+ drawFrame(ug, dim.getWidth(), dim.getHeight(), new Dimension2DDouble(0, 0), symbolContext.isShadowing());
+ final Margin margin = getMargin();
+ final TextBlock tb = TextBlockUtils.mergeTB(stereotype, label, HorizontalAlignment.CENTER);
+ tb.drawU(ug.apply(new UTranslate(margin.getX1(), margin.getY1())));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dimLabel = label.calculateDimension(stringBounder);
+ final Dimension2D dimStereo = stereotype.calculateDimension(stringBounder);
+ return getMargin().addDimension(Dimension2DDouble.mergeTB(dimStereo, dimLabel));
+ }
+ };
+ }
+
+ public TextBlock asBig(final TextBlock title, final TextBlock stereotype, final double width, final double height,
+ final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D dim = calculateDimension(stringBounder);
+ ug = symbolContext.apply(ug);
+ final Dimension2D dimTitle = title.calculateDimension(stringBounder);
+ drawFrame(ug, dim.getWidth(), dim.getHeight(), dimTitle, symbolContext.isShadowing());
+ title.drawU(ug.apply(new UTranslate(3, 1)));
+
+ final Dimension2D dimStereo = stereotype.calculateDimension(stringBounder);
+ final double posStereo = (width - dimStereo.getWidth()) / 2;
+
+ stereotype.drawU(ug.apply(new UTranslate(4 + posStereo, 2 + getYpos(dimTitle))));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(width, height);
+ }
+ };
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/USymbolInterface.java b/src/net/sourceforge/plantuml/graphic/USymbolInterface.java
new file mode 100644
index 0000000..33bcec8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/USymbolInterface.java
@@ -0,0 +1,52 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import net.sourceforge.plantuml.svek.CircleInterface2;
+
+public class USymbolInterface extends USymbolSimpleAbstract {
+
+ @Override
+ public SkinParameter getSkinParameter() {
+ return SkinParameter.INTERFACE;
+ }
+
+ @Override
+ protected TextBlock getDrawing(SymbolContext symbolContext) {
+ return new CircleInterface2(symbolContext.getBackColor(), symbolContext.getForeColor(),
+ symbolContext.isShadowing() ? 4.0 : 0.0);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/USymbolNode.java b/src/net/sourceforge/plantuml/graphic/USymbolNode.java
new file mode 100644
index 0000000..3c4305c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/USymbolNode.java
@@ -0,0 +1,132 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class USymbolNode extends USymbol {
+
+ @Override
+ public SkinParameter getSkinParameter() {
+ return SkinParameter.NODE;
+ }
+
+
+ private void drawNode(UGraphic ug, double width, double height, boolean shadowing) {
+ final UPolygon shape = new UPolygon();
+ shape.addPoint(0, 10);
+ shape.addPoint(10, 0);
+ shape.addPoint(width, 0);
+ shape.addPoint(width, height - 10);
+ shape.addPoint(width - 10, height);
+ shape.addPoint(0, height);
+ shape.addPoint(0, 10);
+ if (shadowing) {
+ shape.setDeltaShadow(2);
+ }
+ ug.draw(shape);
+
+ ug.apply(new UTranslate(width - 10, 10)).draw(new ULine(9, -9));
+ ug.apply(new UTranslate(0, 10)).draw(new ULine(width - 10, 0));
+ ug.apply(new UTranslate(width - 10, 10)).draw(new ULine(0, height - 10));
+
+ }
+
+ private Margin getMargin() {
+ return new Margin(10 + 5, 20 + 5, 15 + 5, 5 + 5);
+ }
+
+ public TextBlock asSmall(final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ ug = symbolContext.apply(ug);
+ drawNode(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing());
+ final Margin margin = getMargin();
+ final TextBlock tb = TextBlockUtils.mergeTB(stereotype, label, HorizontalAlignment.CENTER);
+ tb.drawU(ug.apply(new UTranslate(margin.getX1(), margin.getY1())));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dimLabel = label.calculateDimension(stringBounder);
+ final Dimension2D dimStereo = stereotype.calculateDimension(stringBounder);
+ return getMargin().addDimension(Dimension2DDouble.mergeTB(dimStereo, dimLabel));
+ }
+ };
+ }
+
+ public TextBlock asBig(final TextBlock title, final TextBlock stereotype, final double width, final double height,
+ final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ ug = symbolContext.apply(ug);
+ drawNode(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing());
+ ug = ug.apply(new UTranslate(-4, 11));
+
+ final Dimension2D dimStereo = stereotype.calculateDimension(ug.getStringBounder());
+ final double posStereo = (width - dimStereo.getWidth()) / 2;
+ stereotype.drawU(ug.apply(new UTranslate(posStereo, 2)));
+ final Dimension2D dimTitle = title.calculateDimension(ug.getStringBounder());
+ final double posTitle = (width - dimTitle.getWidth()) / 2;
+ title.drawU(ug.apply(new UTranslate(posTitle, 2 + dimStereo.getHeight())));
+
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(width, height);
+ }
+ };
+ }
+
+ @Override
+ public int suppHeightBecauseOfShape() {
+ return 5;
+ }
+
+ @Override
+ public int suppWidthBecauseOfShape() {
+ return 60;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/USymbolQueue.java b/src/net/sourceforge/plantuml/graphic/USymbolQueue.java
new file mode 100644
index 0000000..01aefa9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/USymbolQueue.java
@@ -0,0 +1,172 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.AbstractUGraphicHorizontalLine;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UHorizontalLine;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class USymbolQueue extends USymbol {
+
+ @Override
+ public SkinParameter getSkinParameter() {
+ return SkinParameter.QUEUE;
+ }
+
+
+ private final double dx = 5;
+
+ private void drawDatabase(UGraphic ug, double width, double height, boolean shadowing) {
+ final UPath shape = new UPath();
+ if (shadowing) {
+ shape.setDeltaShadow(3.0);
+ }
+ shape.moveTo(dx, 0);
+ shape.lineTo(width - dx, 0);
+ shape.cubicTo(width, 0, width, height / 2, width, height / 2);
+ shape.cubicTo(width, height / 2, width, height, width - dx, height);
+ shape.lineTo(dx, height);
+
+ shape.cubicTo(0, height, 0, height / 2, 0, height / 2);
+ shape.cubicTo(0, height / 2, 0, 0, dx, 0);
+
+ ug.draw(shape);
+
+ final UPath closing = getClosingPath(width, height);
+ ug.apply(new UChangeBackColor(null)).draw(closing);
+
+ }
+
+ private UPath getClosingPath(double width, double height) {
+ final UPath closing = new UPath();
+ closing.moveTo(width - dx, 0);
+ closing.cubicTo(width - dx * 2, 0, width - dx * 2, height / 2, width - dx * 2, height / 2);
+ closing.cubicTo(width - dx * 2, height, width - dx, height, width - dx, height);
+ return closing;
+ }
+
+ class MyUGraphicDatabase extends AbstractUGraphicHorizontalLine {
+
+ private final double endingX;
+
+ @Override
+ protected AbstractUGraphicHorizontalLine copy(UGraphic ug) {
+ return new MyUGraphicDatabase(ug, endingX);
+ }
+
+ public MyUGraphicDatabase(UGraphic ug, double endingX) {
+ super(ug);
+ this.endingX = endingX;
+ }
+
+ @Override
+ protected void drawHline(UGraphic ug, UHorizontalLine line, UTranslate translate) {
+ // final UPath closing = getClosingPath(endingX);
+ // ug = ug.apply(translate);
+ // ug.apply(line.getStroke()).apply(new UChangeBackColor(null)).apply(new UTranslate(0, -15)).draw(closing);
+ // if (line.isDouble()) {
+ // ug.apply(line.getStroke()).apply(new UChangeBackColor(null)).apply(new UTranslate(0, -15 + 2))
+ // .draw(closing);
+ // }
+ line.drawTitleInternal(ug, 0, endingX, 0, true);
+ }
+
+ }
+
+ private Margin getMargin() {
+ return new Margin(5, 15, 5, 5);
+ }
+
+ public TextBlock asSmall(final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ ug = symbolContext.apply(ug);
+ drawDatabase(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing());
+ final Margin margin = getMargin();
+ final TextBlock tb = TextBlockUtils.mergeTB(stereotype, label, HorizontalAlignment.CENTER);
+ final UGraphic ug2 = new MyUGraphicDatabase(ug, dim.getWidth());
+ tb.drawU(ug2.apply(new UTranslate(margin.getX1(), margin.getY1())));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dimLabel = label.calculateDimension(stringBounder);
+ final Dimension2D dimStereo = stereotype.calculateDimension(stringBounder);
+ return getMargin().addDimension(Dimension2DDouble.mergeTB(dimStereo, dimLabel));
+ }
+ };
+ }
+
+ public TextBlock asBig(final TextBlock title, final TextBlock stereotype, final double width, final double height,
+ final SymbolContext symbolContext) {
+ throw new UnsupportedOperationException();
+ // return new TextBlock() {
+ //
+ // public void drawU(UGraphic ug) {
+ // final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ // ug = symbolContext.apply(ug);
+ // drawDatabase(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing());
+ // final Dimension2D dimStereo = stereotype.calculateDimension(ug.getStringBounder());
+ // final double posStereo = (width - dimStereo.getWidth()) / 2;
+ // stereotype.drawU(ug.apply(new UTranslate(posStereo, 0)));
+ //
+ // final Dimension2D dimTitle = title.calculateDimension(ug.getStringBounder());
+ // final double posTitle = (width - dimTitle.getWidth()) / 2;
+ // title.drawU(ug.apply(new UTranslate(posTitle, 21)));
+ // }
+ //
+ // public Dimension2D calculateDimension(StringBounder stringBounder) {
+ // return new Dimension2DDouble(width, height);
+ // }
+ // };
+ }
+
+ public boolean manageHorizontalLine() {
+ return true;
+ }
+
+ // @Override
+ // public int suppHeightBecauseOfShape() {
+ // return 15;
+ // }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/USymbolRect.java b/src/net/sourceforge/plantuml/graphic/USymbolRect.java
new file mode 100644
index 0000000..ac154db
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/USymbolRect.java
@@ -0,0 +1,113 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class USymbolRect extends USymbol {
+
+ private final SkinParameter skinParameter;
+
+
+ public USymbolRect(SkinParameter skinParameter) {
+ this.skinParameter = skinParameter;
+ }
+
+ @Override
+ public SkinParameter getSkinParameter() {
+ return skinParameter;
+ }
+
+
+ private void drawRect(UGraphic ug, double width, double height, boolean shadowing) {
+ final URectangle shape = new URectangle(width, height);
+ if (shadowing) {
+ shape.setDeltaShadow(3.0);
+ }
+ ug.draw(shape);
+ }
+
+ private Margin getMargin() {
+ return new Margin(10, 10, 10, 10);
+ }
+
+ public TextBlock asSmall(final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ ug = symbolContext.apply(ug);
+ drawRect(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing());
+ final Margin margin = getMargin();
+ final TextBlock tb = TextBlockUtils.mergeTB(stereotype, label, HorizontalAlignment.CENTER);
+ tb.drawU(ug.apply(new UTranslate(margin.getX1(), margin.getY1())));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dimLabel = label.calculateDimension(stringBounder);
+ final Dimension2D dimStereo = stereotype.calculateDimension(stringBounder);
+ return getMargin().addDimension(Dimension2DDouble.mergeTB(dimStereo, dimLabel));
+ }
+ };
+ }
+
+ public TextBlock asBig(final TextBlock title, final TextBlock stereotype, final double width, final double height,
+ final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ ug = symbolContext.apply(ug);
+ drawRect(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing());
+ final Dimension2D dimStereo = stereotype.calculateDimension(ug.getStringBounder());
+ final double posStereo = (width - dimStereo.getWidth()) / 2;
+ stereotype.drawU(ug.apply(new UTranslate(posStereo, 2)));
+ final Dimension2D dimTitle = title.calculateDimension(ug.getStringBounder());
+ final double posTitle = (width - dimTitle.getWidth()) / 2;
+ title.drawU(ug.apply(new UTranslate(posTitle, 2 + dimStereo.getHeight())));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(width, height);
+ }
+ };
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/USymbolSimpleAbstract.java b/src/net/sourceforge/plantuml/graphic/USymbolSimpleAbstract.java
new file mode 100644
index 0000000..f98aa63
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/USymbolSimpleAbstract.java
@@ -0,0 +1,86 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+abstract class USymbolSimpleAbstract extends USymbol {
+
+ public TextBlock asSmall(final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) {
+ if (stereotype == null) {
+ throw new IllegalArgumentException();
+ }
+ final TextBlock stickman = getDrawing(symbolContext);
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D dimName = label.calculateDimension(stringBounder);
+ final Dimension2D dimStereo = stereotype.calculateDimension(stringBounder);
+ final Dimension2D dimStickMan = stickman.calculateDimension(stringBounder);
+ final Dimension2D dimTotal = calculateDimension(stringBounder);
+ final double stickmanX = (dimTotal.getWidth() - dimStickMan.getWidth()) / 2;
+ final double stickmanY = dimStereo.getHeight();
+ ug = symbolContext.apply(ug);
+ stickman.drawU(ug.apply(new UTranslate(stickmanX, stickmanY)));
+ final double labelX = (dimTotal.getWidth() - dimName.getWidth()) / 2;
+ final double labelY = dimStickMan.getHeight() + dimStereo.getHeight();
+ label.drawU(ug.apply(new UTranslate(labelX, labelY)));
+
+ final double stereoX = (dimTotal.getWidth() - dimStereo.getWidth()) / 2;
+ stereotype.drawU(ug.apply(new UTranslate(stereoX, 0)));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dimName = label.calculateDimension(stringBounder);
+ final Dimension2D dimStereo = stereotype.calculateDimension(stringBounder);
+ final Dimension2D dimActor = stickman.calculateDimension(stringBounder);
+ return Dimension2DDouble.mergeLayoutT12B3(dimStereo, dimActor, dimName);
+ }
+ };
+ }
+
+ abstract protected TextBlock getDrawing(final SymbolContext symbolContext);
+
+ public TextBlock asBig(final TextBlock title, TextBlock stereotype, final double width, final double height,
+ final SymbolContext symbolContext) {
+ throw new UnsupportedOperationException();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/USymbolStorage.java b/src/net/sourceforge/plantuml/graphic/USymbolStorage.java
new file mode 100644
index 0000000..0ef378b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/USymbolStorage.java
@@ -0,0 +1,106 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class USymbolStorage extends USymbol {
+
+ @Override
+ public SkinParameter getSkinParameter() {
+ return SkinParameter.STORAGE;
+ }
+
+ private void drawStorage(UGraphic ug, double width, double height, boolean shadowing) {
+ final URectangle shape = new URectangle(width, height, 70, 70);
+ if (shadowing) {
+ shape.setDeltaShadow(3.0);
+ }
+ ug.draw(shape);
+ }
+
+ private Margin getMargin() {
+ return new Margin(10, 10, 10, 10);
+ }
+
+ public TextBlock asSmall(final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ ug = symbolContext.apply(ug);
+ drawStorage(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing());
+ final Margin margin = getMargin();
+ final TextBlock tb = TextBlockUtils.mergeTB(stereotype, label, HorizontalAlignment.CENTER);
+ tb.drawU(ug.apply(new UTranslate(margin.getX1(), margin.getY1())));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dimLabel = label.calculateDimension(stringBounder);
+ final Dimension2D dimStereo = stereotype.calculateDimension(stringBounder);
+ return getMargin().addDimension(Dimension2DDouble.mergeTB(dimStereo, dimLabel));
+ }
+ };
+ }
+
+ public TextBlock asBig(final TextBlock title, final TextBlock stereotype, final double width, final double height,
+ final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ ug = symbolContext.apply(ug);
+ drawStorage(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing());
+
+ final Dimension2D dimStereo = stereotype.calculateDimension(ug.getStringBounder());
+ final double posStereo = (width - dimStereo.getWidth()) / 2;
+ stereotype.drawU(ug.apply(new UTranslate(posStereo, 5)));
+ final Dimension2D dimTitle = title.calculateDimension(ug.getStringBounder());
+ final double posTitle = (width - dimTitle.getWidth()) / 2;
+ title.drawU(ug.apply(new UTranslate(posTitle, 7 + dimStereo.getHeight())));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(width, height);
+ }
+ };
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/UnusedSpace.java b/src/net/sourceforge/plantuml/graphic/UnusedSpace.java
new file mode 100644
index 0000000..2c820e9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/UnusedSpace.java
@@ -0,0 +1,173 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.Graphics2D;
+import java.awt.image.BufferedImage;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public class UnusedSpace {
+
+ static class Point {
+ final private double x;
+ final private double y;
+
+ Point(double x, double y) {
+ this.x = x;
+ this.y = y;
+ }
+
+ public double getDistSq(Point other) {
+ final double dx = this.x - other.x;
+ final double dy = this.y - other.y;
+ return dx * dx + dy * dy;
+ }
+ }
+
+ private static final int HALF_SIZE = 20;
+
+ private double meanX2;
+ private double meanY2;
+
+ private final List<Point> points = new ArrayList<Point>();
+
+ final private static Map<Object, UnusedSpace> cache = new HashMap<Object, UnusedSpace>();
+
+ public static UnusedSpace getUnusedSpace(UFont font, char c) {
+ final Object key = Arrays.asList(font, c);
+ UnusedSpace result = cache.get(key);
+ if (result == null) {
+ result = new UnusedSpace(font, c);
+ cache.put(key, result);
+ }
+ return result;
+ }
+
+ private UnusedSpace(UFont font, char c) {
+ final BufferedImage im = new BufferedImage(2 * HALF_SIZE, 2 * HALF_SIZE, BufferedImage.TYPE_INT_RGB);
+ final Graphics2D g2d = im.createGraphics();
+ g2d.setFont(font.getFont());
+ g2d.drawString("" + c, HALF_SIZE, HALF_SIZE);
+
+ int minI = Integer.MAX_VALUE;
+ int minJ = Integer.MAX_VALUE;
+ int maxI = Integer.MIN_VALUE;
+ int maxJ = Integer.MIN_VALUE;
+
+ for (int i = 0; i < im.getWidth(); i++) {
+ for (int j = 0; j < im.getHeight(); j++) {
+ if (isPoint(im, i, j)) {
+ if (i < minI) {
+ minI = i;
+ }
+ if (j < minJ) {
+ minJ = j;
+ }
+ if (i > maxI) {
+ maxI = i;
+ }
+ if (j > maxJ) {
+ maxJ = j;
+ }
+ points.add(new Point(i, j));
+ }
+ }
+ }
+
+ double min = Double.MAX_VALUE;
+ for (int i = minI * 4; i <= maxI * 4; i++) {
+ for (int j = minJ * 4; j < maxJ * 4; j++) {
+ final Point p = new Point(i / 4.0, j / 4.0);
+ final double d = biggestDistSqFromPoint(p);
+ if (d < min) {
+ min = d;
+ this.meanX2 = i / 4.0 - HALF_SIZE;
+ this.meanY2 = j / 4.0 - HALF_SIZE;
+ }
+ }
+ }
+
+ // g2d.setColor(Color.RED);
+ // g2d.draw(new Line2D.Double(meanX2 + HALF_SIZE - 1, meanY2 + HALF_SIZE
+ // - 1, meanX2 + HALF_SIZE + 1, meanY2
+ // + HALF_SIZE + 1));
+ // g2d.draw(new Line2D.Double(meanX2 + HALF_SIZE + 1, meanY2 + HALF_SIZE
+ // - 1, meanX2 + HALF_SIZE - 1, meanY2
+ // + HALF_SIZE + 1));
+
+ // int cpt = 1;
+ // try {
+ // ImageIO.write(im, "png", new File("c:/img" + cpt + ".png"));
+ // cpt++;
+ // } catch (IOException e) {
+ // e.printStackTrace();
+ // }
+
+ }
+
+ private double biggestDistSqFromPoint(Point p) {
+ double result = 0;
+ for (Point other : points) {
+ final double d = p.getDistSq(other);
+ if (d > result) {
+ result = d;
+ }
+ }
+ return result;
+ }
+
+ private static boolean isPoint(BufferedImage im, int x, int y) {
+ final int color = im.getRGB(x, y) & 0x00FFFFFF;
+ if (color == 0) {
+ return false;
+ }
+ return true;
+ }
+
+ public double getCenterX() {
+ return meanX2;
+ }
+
+ public double getCenterY() {
+ return meanY2;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/VerticalAlignment.java b/src/net/sourceforge/plantuml/graphic/VerticalAlignment.java
new file mode 100644
index 0000000..a5427a1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/VerticalAlignment.java
@@ -0,0 +1,52 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+public enum VerticalAlignment {
+ TOP, CENTER, BOTTOM;
+
+ public static VerticalAlignment fromString(String s) {
+ if (TOP.name().equalsIgnoreCase(s)) {
+ return TOP;
+ }
+ // if (CENTER.name().equalsIgnoreCase(s)) {
+ // return CENTER;
+ // }
+ if (BOTTOM.name().equalsIgnoreCase(s)) {
+ return BOTTOM;
+ }
+ return BOTTOM;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graphic/VerticalPosition.java b/src/net/sourceforge/plantuml/graphic/VerticalPosition.java
new file mode 100644
index 0000000..74f9fd3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/VerticalPosition.java
@@ -0,0 +1,41 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+public enum VerticalPosition {
+
+ TOP, BOTTOM
+
+}
diff --git a/src/net/sourceforge/plantuml/hector/Box2D.java b/src/net/sourceforge/plantuml/hector/Box2D.java
new file mode 100644
index 0000000..722f38f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector/Box2D.java
@@ -0,0 +1,80 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.hector;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.geom.LineSegmentDouble;
+
+public class Box2D {
+
+ final private double x1;
+ final private double y1;
+ final private double x2;
+ final private double y2;
+
+ private Box2D(double x1, double y1, double x2, double y2) {
+ this.x1 = x1;
+ this.y1 = y1;
+ this.x2 = x2;
+ this.y2 = y2;
+ }
+
+ public static Box2D create(double x, double y, Dimension2D dim) {
+ return new Box2D(x, y, x + dim.getWidth(), y + dim.getHeight());
+ }
+
+ @Override
+ public String toString() {
+ return "Box [" + x1 + "," + y1 + "] [" + x2 + "," + y2 + "]";
+ }
+
+ public boolean doesIntersect(LineSegmentDouble seg) {
+ if (seg.doesIntersect(new LineSegmentDouble(x1, y1, x2, y1))) {
+ return true;
+ }
+ if (seg.doesIntersect(new LineSegmentDouble(x2, y1, x2, y2))) {
+ return true;
+ }
+ if (seg.doesIntersect(new LineSegmentDouble(x2, y2, x1, y2))) {
+ return true;
+ }
+ if (seg.doesIntersect(new LineSegmentDouble(x1, y2, x1, y1))) {
+ return true;
+ }
+ return false;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/hector/CucaDiagramFileMakerHector.java b/src/net/sourceforge/plantuml/hector/CucaDiagramFileMakerHector.java
new file mode 100644
index 0000000..290fe13
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector/CucaDiagramFileMakerHector.java
@@ -0,0 +1,106 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.hector;
+
+import java.awt.geom.Dimension2D;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.api.ImageDataSimple;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.svek.CucaDiagramFileMaker;
+import net.sourceforge.plantuml.svek.CucaDiagramFileMakerSvek2;
+import net.sourceforge.plantuml.svek.IEntityImage;
+import net.sourceforge.plantuml.ugraphic.UGraphic2;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class CucaDiagramFileMakerHector implements CucaDiagramFileMaker {
+
+ private final CucaDiagram diagram;
+
+ public CucaDiagramFileMakerHector(CucaDiagram diagram) {
+ this.diagram = diagram;
+ }
+
+ final private Map<ILeaf, IEntityImage> images = new LinkedHashMap<ILeaf, IEntityImage>();
+
+ public ImageData createFile(OutputStream os, List<String> dotStrings, FileFormatOption fileFormatOption)
+ throws IOException {
+ double singleWidth = 0;
+ double singleHeight = 0;
+ int nb = 0;
+ for (ILeaf leaf : diagram.getLeafsvalues()) {
+ final IEntityImage image = computeImage(leaf);
+ final Dimension2D dim = TextBlockUtils.getDimension(image);
+ if (dim.getWidth() > singleWidth) {
+ singleWidth = dim.getWidth();
+ }
+ if (dim.getHeight() > singleHeight) {
+ singleHeight = dim.getHeight();
+ }
+ images.put(leaf, image);
+ nb++;
+ }
+ final double margin = 10;
+ final Dimension2D dim = new Dimension2DDouble(2 * margin + nb * singleWidth, singleHeight + 2 * margin);
+ UGraphic2 ug = null;// fileFormatOption.createUGraphic(diagram.getColorMapper(), diagram.getDpiFactor(fileFormatOption),
+ // dim, null, false);
+ ug = (UGraphic2) ug.apply(new UTranslate(margin, margin));
+
+ double pos = 0;
+ for (IEntityImage im : images.values()) {
+ im.drawU(ug.apply(new UTranslate(pos, 0)));
+ pos += singleWidth;
+ }
+
+// ug.writeImageTOBEMOVED(os, null, diagram.getDpi(fileFormatOption));
+// return new ImageDataSimple(dim);
+ throw new UnsupportedOperationException();
+ }
+
+ private IEntityImage computeImage(final ILeaf leaf) {
+ final IEntityImage image = CucaDiagramFileMakerSvek2.createEntityImageBlock(leaf, diagram.getSkinParam(),
+ false, diagram, null, null, null);
+ return image;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/hector/CucaDiagramFileMakerHector2.java b/src/net/sourceforge/plantuml/hector/CucaDiagramFileMakerHector2.java
new file mode 100644
index 0000000..103d6c9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector/CucaDiagramFileMakerHector2.java
@@ -0,0 +1,181 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.hector;
+
+import java.awt.geom.Dimension2D;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.api.ImageDataSimple;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.skin.rose.Rose;
+import net.sourceforge.plantuml.svek.CucaDiagramFileMaker;
+import net.sourceforge.plantuml.svek.CucaDiagramFileMakerSvek2;
+import net.sourceforge.plantuml.svek.IEntityImage;
+import net.sourceforge.plantuml.ugraphic.MinMax;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UGraphic2;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class CucaDiagramFileMakerHector2 implements CucaDiagramFileMaker {
+
+ private final CucaDiagram diagram;
+ private SkeletonConfiguration configuration;
+
+ private double singleWidth;
+ private double singleHeight;
+ private double nodeMargin = 40;
+
+ public CucaDiagramFileMakerHector2(CucaDiagram diagram) {
+ this.diagram = diagram;
+ }
+
+ final private Map<Pin, IEntityImage> images = new LinkedHashMap<Pin, IEntityImage>();
+
+ final private Map<Link, PinLink> links = new LinkedHashMap<Link, PinLink>();
+
+ private double getX(Pin pin) {
+ return singleWidth * configuration.getCol(pin);
+ }
+
+ private double getY(Pin pin) {
+ return singleHeight * pin.getRow();
+ }
+
+ private double getCenterX(Pin pin) {
+ return singleWidth * configuration.getCol(pin) + singleWidth / 2.0;
+ }
+
+ private double getCenterY(Pin pin) {
+ return singleHeight * pin.getRow() + singleHeight / 2.0;
+ }
+
+ public ImageData createFile(OutputStream os, List<String> dotStrings, FileFormatOption fileFormatOption)
+ throws IOException {
+ final PinFactory pinFactory = new PinFactory();
+ final SkeletonBuilder skeletonBuilder = new SkeletonBuilder();
+ for (Link link : diagram.getLinks()) {
+ final PinLink pinLink = pinFactory.createPinLink(link);
+ links.put(link, pinLink);
+ skeletonBuilder.add(pinLink);
+ }
+
+ final Skeleton skeleton = skeletonBuilder.createSkeletons().get(0);
+ this.configuration = SkeletonConfiguration.getDefault(skeleton);
+
+ this.singleWidth = 0;
+ this.singleHeight = 0;
+
+ for (Pin pin : skeleton.getPins()) {
+ final ILeaf leaf = (ILeaf) pin.getUserData();
+ final IEntityImage image = computeImage(leaf);
+ final Dimension2D dim = TextBlockUtils.getDimension(image);
+ if (dim.getWidth() > singleWidth) {
+ singleWidth = dim.getWidth();
+ }
+ if (dim.getHeight() > singleHeight) {
+ singleHeight = dim.getHeight();
+ }
+ images.put(pin, image);
+ }
+ singleHeight += nodeMargin;
+ singleWidth += nodeMargin;
+
+ MinMax minMax = MinMax.getEmpty(false);
+ for (Pin pin : skeleton.getPins()) {
+ minMax = minMax.addPoint(getX(pin), getY(pin));
+ minMax = minMax.addPoint(getX(pin) + singleWidth, getY(pin) + singleHeight);
+ }
+
+ final double borderMargin = 10;
+
+ final Dimension2D dimTotal = new Dimension2DDouble(2 * borderMargin + minMax.getMaxX(), 2 * borderMargin
+ + minMax.getMaxY());
+ UGraphic2 ug = null;//fileFormatOption.createUGraphic(diagram.getColorMapper(), diagram.getDpiFactor(fileFormatOption),
+ // dimTotal, null, false);
+ ug = (UGraphic2) ug.apply(new UTranslate(borderMargin, borderMargin));
+
+ for (PinLink pinLink : skeleton.getPinLinks()) {
+ drawPinLink(ug, pinLink);
+ }
+
+ for (Map.Entry<Pin, IEntityImage> ent : images.entrySet()) {
+ final Pin pin = ent.getKey();
+ final IEntityImage im = ent.getValue();
+ final double x = getX(pin);
+ final double y = getY(pin);
+ final Dimension2D dimImage = im.calculateDimension(ug.getStringBounder());
+ im.drawU(ug.apply(new UTranslate(x + (singleWidth - dimImage.getWidth()) / 2, y
+ + (singleHeight - dimImage.getHeight()) / 2)));
+ }
+
+// ug.writeImageTOBEMOVED(os, null, diagram.getDpi(fileFormatOption));
+// return new ImageDataSimple(dimTotal);
+ throw new UnsupportedOperationException();
+ }
+
+ private void drawPinLink(UGraphic ug, PinLink pinLink) {
+ final Rose rose = new Rose();
+ final HtmlColor color = rose.getHtmlColor(diagram.getSkinParam(), ColorParam.classArrow);
+ ug = ug.apply(new UChangeColor(color)).apply(new UStroke(1.5));
+ final double x1 = getCenterX(pinLink.getPin1());
+ final double y1 = getCenterY(pinLink.getPin1());
+ final double x2 = getCenterX(pinLink.getPin2());
+ final double y2 = getCenterY(pinLink.getPin2());
+ ug = ug.apply(new UTranslate(x1, y1));
+ ug.draw(new ULine(x2 - x1, y2 - y1));
+
+ }
+
+ private IEntityImage computeImage(final ILeaf leaf) {
+ final IEntityImage image = CucaDiagramFileMakerSvek2.createEntityImageBlock(leaf, diagram.getSkinParam(),
+ false, diagram, null, null, null);
+ return image;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/hector/CucaDiagramFileMakerHector3.java b/src/net/sourceforge/plantuml/hector/CucaDiagramFileMakerHector3.java
new file mode 100644
index 0000000..ffad07a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector/CucaDiagramFileMakerHector3.java
@@ -0,0 +1,182 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.hector;
+
+import java.awt.geom.Dimension2D;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.api.ImageDataSimple;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.skin.rose.Rose;
+import net.sourceforge.plantuml.svek.CucaDiagramFileMaker;
+import net.sourceforge.plantuml.svek.CucaDiagramFileMakerSvek2;
+import net.sourceforge.plantuml.svek.IEntityImage;
+import net.sourceforge.plantuml.ugraphic.MinMax;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UGraphic2;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class CucaDiagramFileMakerHector3 implements CucaDiagramFileMaker {
+
+ private final CucaDiagram diagram;
+ private SkeletonConfiguration configuration;
+
+ private double singleWidth;
+ private double singleHeight;
+ private double nodeMargin = 40;
+
+ public CucaDiagramFileMakerHector3(CucaDiagram diagram) {
+ this.diagram = diagram;
+ }
+
+ final private Map<Pin, IEntityImage> images = new LinkedHashMap<Pin, IEntityImage>();
+
+ final private Map<Link, PinLink> links = new LinkedHashMap<Link, PinLink>();
+
+ private double getX(Pin pin) {
+ return singleWidth * configuration.getCol(pin);
+ }
+
+ private double getY(Pin pin) {
+ return singleHeight * pin.getRow();
+ }
+
+ private double getCenterX(Pin pin) {
+ return singleWidth * configuration.getCol(pin) + singleWidth / 2.0;
+ }
+
+ private double getCenterY(Pin pin) {
+ return singleHeight * pin.getRow() + singleHeight / 2.0;
+ }
+
+ public ImageData createFile(OutputStream os, List<String> dotStrings, FileFormatOption fileFormatOption)
+ throws IOException {
+ final PinFactory pinFactory = new PinFactory();
+ final SkeletonBuilder skeletonBuilder = new SkeletonBuilder();
+ for (Link link : diagram.getLinks()) {
+ final PinLink pinLink = pinFactory.createPinLink(link);
+ links.put(link, pinLink);
+ skeletonBuilder.add(pinLink);
+ }
+
+ final Skeleton skeleton = skeletonBuilder.createSkeletons().get(0);
+ this.configuration = SkeletonConfiguration.getDefault(skeleton);
+
+ this.singleWidth = 0;
+ this.singleHeight = 0;
+
+ for (Pin pin : skeleton.getPins()) {
+ final ILeaf leaf = (ILeaf) pin.getUserData();
+ final IEntityImage image = computeImage(leaf);
+ final Dimension2D dim = TextBlockUtils.getDimension(image);
+ if (dim.getWidth() > singleWidth) {
+ singleWidth = dim.getWidth();
+ }
+ if (dim.getHeight() > singleHeight) {
+ singleHeight = dim.getHeight();
+ }
+ images.put(pin, image);
+ }
+ singleHeight += nodeMargin;
+ singleWidth += nodeMargin;
+
+ MinMax minMax = MinMax.getEmpty(false);
+ for (Pin pin : skeleton.getPins()) {
+ minMax = minMax.addPoint(getX(pin), getY(pin));
+ minMax = minMax.addPoint(getX(pin) + singleWidth, getY(pin) + singleHeight);
+ }
+
+ final double borderMargin = 10;
+
+ final Dimension2D dimTotal = new Dimension2DDouble(2 * borderMargin + minMax.getMaxX(), 2 * borderMargin
+ + minMax.getMaxY());
+ UGraphic2 ug = null;// fileFormatOption.createUGraphic(diagram.getColorMapper(),
+ // diagram.getDpiFactor(fileFormatOption),
+ // dimTotal, null, false);
+ ug = (UGraphic2) ug.apply(new UTranslate(borderMargin, borderMargin));
+
+ for (PinLink pinLink : skeleton.getPinLinks()) {
+ drawPinLink(ug, pinLink);
+ }
+
+ for (Map.Entry<Pin, IEntityImage> ent : images.entrySet()) {
+ final Pin pin = ent.getKey();
+ final IEntityImage im = ent.getValue();
+ final double x = getX(pin);
+ final double y = getY(pin);
+ final Dimension2D dimImage = im.calculateDimension(ug.getStringBounder());
+ im.drawU(ug.apply(new UTranslate(x + (singleWidth - dimImage.getWidth()) / 2, y
+ + (singleHeight - dimImage.getHeight()) / 2)));
+ }
+
+ // ug.writeImageTOBEMOVED(os, null, diagram.getDpi(fileFormatOption));
+ // return new ImageDataSimple(dimTotal);
+ throw new UnsupportedOperationException();
+ }
+
+ private void drawPinLink(UGraphic ug, PinLink pinLink) {
+ final Rose rose = new Rose();
+ final HtmlColor color = rose.getHtmlColor(diagram.getSkinParam(), ColorParam.classArrow);
+ ug = ug.apply(new UChangeColor(color)).apply(new UStroke(1.5));
+ final double x1 = getCenterX(pinLink.getPin1());
+ final double y1 = getCenterY(pinLink.getPin1());
+ final double x2 = getCenterX(pinLink.getPin2());
+ final double y2 = getCenterY(pinLink.getPin2());
+ ug = ug.apply(new UTranslate(x1, y1));
+ ug.draw(new ULine(x2 - x1, y2 - y1));
+
+ }
+
+ private IEntityImage computeImage(final ILeaf leaf) {
+ final IEntityImage image = CucaDiagramFileMakerSvek2.createEntityImageBlock(leaf, diagram.getSkinParam(),
+ false, diagram, null, null, null);
+ return image;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/hector/CucaDiagramFileMakerHector4.java b/src/net/sourceforge/plantuml/hector/CucaDiagramFileMakerHector4.java
new file mode 100644
index 0000000..dce7dde
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector/CucaDiagramFileMakerHector4.java
@@ -0,0 +1,197 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.hector;
+
+import java.awt.geom.Dimension2D;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.api.ImageDataSimple;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.skin.rose.Rose;
+import net.sourceforge.plantuml.svek.CucaDiagramFileMaker;
+import net.sourceforge.plantuml.svek.CucaDiagramFileMakerSvek2;
+import net.sourceforge.plantuml.svek.IEntityImage;
+import net.sourceforge.plantuml.ugraphic.MinMax;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UGraphic2;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class CucaDiagramFileMakerHector4 implements CucaDiagramFileMaker {
+
+ private final CucaDiagram diagram;
+ private SkeletonConfiguration configuration;
+
+ private double singleWidth;
+ private double singleHeight;
+ private double nodeMargin = 40;
+
+ public CucaDiagramFileMakerHector4(CucaDiagram diagram) {
+ this.diagram = diagram;
+ }
+
+ final private Map<Pin, IEntityImage> images = new LinkedHashMap<Pin, IEntityImage>();
+ final private Map<Pin, Box2D> boxes = new LinkedHashMap<Pin, Box2D>();
+
+ final private Map<Link, PinLink> links = new LinkedHashMap<Link, PinLink>();
+
+ final private List<Box2D> forbidden = new ArrayList<Box2D>();
+
+ private double getX(Pin pin) {
+ return singleWidth * configuration.getCol(pin);
+ }
+
+ private double getY(Pin pin) {
+ return singleHeight * pin.getRow();
+ }
+
+ private double getCenterX(Pin pin) {
+ return singleWidth * configuration.getCol(pin) + singleWidth / 2.0;
+ }
+
+ private double getCenterY(Pin pin) {
+ return singleHeight * pin.getRow() + singleHeight / 2.0;
+ }
+
+ public ImageData createFile(OutputStream os, List<String> dotStrings, FileFormatOption fileFormatOption)
+ throws IOException {
+ final PinFactory pinFactory = new PinFactory();
+ final SkeletonBuilder skeletonBuilder = new SkeletonBuilder();
+ links.clear();
+ for (Link link : diagram.getLinks()) {
+ final PinLink pinLink = pinFactory.createPinLink(link);
+ links.put(link, pinLink);
+ skeletonBuilder.add(pinLink);
+ }
+
+ final Skeleton skeleton = skeletonBuilder.createSkeletons().get(0);
+ this.configuration = SkeletonConfigurationUtils.getBest(skeleton);
+
+ this.singleWidth = 0;
+ this.singleHeight = 0;
+
+ images.clear();
+ for (Pin pin : skeleton.getPins()) {
+ final ILeaf leaf = (ILeaf) pin.getUserData();
+ final IEntityImage image = computeImage(leaf);
+ final Dimension2D dim = TextBlockUtils.getDimension(image);
+ if (dim.getWidth() > singleWidth) {
+ singleWidth = dim.getWidth();
+ }
+ if (dim.getHeight() > singleHeight) {
+ singleHeight = dim.getHeight();
+ }
+ images.put(pin, image);
+ }
+ singleHeight += nodeMargin;
+ singleWidth += nodeMargin;
+
+ MinMax minMax = MinMax.getEmpty(false);
+ for (Pin pin : skeleton.getPins()) {
+ minMax = minMax.addPoint(getX(pin), getY(pin));
+ minMax = minMax.addPoint(getX(pin) + singleWidth, getY(pin) + singleHeight);
+ }
+
+ final double borderMargin = 10;
+
+ final Dimension2D dimTotal = new Dimension2DDouble(2 * borderMargin + minMax.getMaxX(), 2 * borderMargin
+ + minMax.getMaxY());
+ UGraphic2 ug = null; //fileFormatOption.createUGraphic(diagram.getColorMapper(), diagram.getDpiFactor(fileFormatOption),
+ // dimTotal, null, false);
+ ug = (UGraphic2) ug.apply(new UTranslate(borderMargin, borderMargin));
+
+ forbidden.clear();
+ for (Map.Entry<Pin, IEntityImage> ent : images.entrySet()) {
+ final Pin pin = ent.getKey();
+ final IEntityImage im = ent.getValue();
+ final Dimension2D dimImage = im.calculateDimension(ug.getStringBounder());
+ final double x = getX(pin) + (singleWidth - dimImage.getWidth()) / 2;
+ final double y = getY(pin) + (singleHeight - dimImage.getHeight()) / 2;
+ final Box2D box = Box2D.create(x, y, dimImage);
+ boxes.put(pin, box);
+ forbidden.add(box);
+ }
+
+ for (PinLink pinLink : skeleton.getPinLinks()) {
+ drawPinLink(ug, pinLink);
+ }
+
+ for (Map.Entry<Pin, IEntityImage> ent : images.entrySet()) {
+ final Pin pin = ent.getKey();
+ final IEntityImage im = ent.getValue();
+ final Dimension2D dimImage = im.calculateDimension(ug.getStringBounder());
+ final double x = getX(pin) + (singleWidth - dimImage.getWidth()) / 2;
+ final double y = getY(pin) + (singleHeight - dimImage.getHeight()) / 2;
+ im.drawU(ug.apply(new UTranslate(x, y)));
+ }
+
+// ug.writeImageTOBEMOVED(os, null, diagram.getDpi(fileFormatOption));
+// return new ImageDataSimple(dimTotal);
+ throw new UnsupportedOperationException();
+ }
+
+ private void drawPinLink(UGraphic ug, PinLink pinLink) {
+ final double x1 = getCenterX(pinLink.getPin1());
+ final double y1 = getCenterY(pinLink.getPin1());
+ final double x2 = getCenterX(pinLink.getPin2());
+ final double y2 = getCenterY(pinLink.getPin2());
+
+ final Rose rose = new Rose();
+ final HtmlColor color = rose.getHtmlColor(diagram.getSkinParam(), ColorParam.classArrow);
+ final List<Box2D> b = new ArrayList<Box2D>(forbidden);
+ b.remove(boxes.get(pinLink.getPin1()));
+ b.remove(boxes.get(pinLink.getPin2()));
+ final SmartConnection connection = new SmartConnection(x1, y1, x2, y2, b);
+ connection.draw(ug, color);
+ }
+
+ private IEntityImage computeImage(final ILeaf leaf) {
+ final IEntityImage image = CucaDiagramFileMakerSvek2.createEntityImageBlock(leaf, diagram.getSkinParam(),
+ false, diagram, null, null, null);
+ return image;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/hector/CucaDiagramFileMakerHectorB1.java b/src/net/sourceforge/plantuml/hector/CucaDiagramFileMakerHectorB1.java
new file mode 100644
index 0000000..403fec7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector/CucaDiagramFileMakerHectorB1.java
@@ -0,0 +1,169 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.hector;
+
+import java.awt.geom.Dimension2D;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.api.ImageDataSimple;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.skin.rose.Rose;
+import net.sourceforge.plantuml.svek.CucaDiagramFileMaker;
+import net.sourceforge.plantuml.svek.CucaDiagramFileMakerSvek2;
+import net.sourceforge.plantuml.svek.IEntityImage;
+import net.sourceforge.plantuml.ugraphic.MinMax;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UGraphic2;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class CucaDiagramFileMakerHectorB1 implements CucaDiagramFileMaker {
+
+ private final CucaDiagram diagram;
+ private SkeletonConfiguration configuration;
+
+ // private double singleWidth;
+ // private double singleHeight;
+ private double nodeMargin = 40;
+
+ public CucaDiagramFileMakerHectorB1(CucaDiagram diagram) {
+ this.diagram = diagram;
+ }
+
+ // final private Map<Pin, IEntityImage> images = new LinkedHashMap<Pin, IEntityImage>();
+ // final private Map<Pin, Box2D> boxes = new LinkedHashMap<Pin, Box2D>();
+
+ final private Map<Link, PinLink> links = new LinkedHashMap<Link, PinLink>();
+
+ // final private List<Box2D> forbidden = new ArrayList<Box2D>();
+
+ private double getX(Pin pin) {
+ return nodeMargin * configuration.getCol(pin);
+ }
+
+ private double getY(Pin pin) {
+ return nodeMargin * pin.getRow();
+ }
+
+ // private double getCenterX(Pin pin) {
+ // return singleWidth * configuration.getCol(pin) + singleWidth / 2.0;
+ // }
+ //
+ // private double getCenterY(Pin pin) {
+ // return singleHeight * pin.getRow() + singleHeight / 2.0;
+ // }
+
+ public ImageData createFile(OutputStream os, List<String> dotStrings, FileFormatOption fileFormatOption)
+ throws IOException {
+ final PinFactory pinFactory = new PinFactory();
+ final SkeletonBuilder skeletonBuilder = new SkeletonBuilder();
+ links.clear();
+ for (Link link : diagram.getLinks()) {
+ final PinLink pinLink = pinFactory.createPinLink(link);
+ links.put(link, pinLink);
+ skeletonBuilder.add(pinLink);
+ }
+
+ final Skeleton skeleton = skeletonBuilder.createSkeletons().get(0);
+ this.configuration = SkeletonConfigurationUtils.getBest(skeleton);
+
+ MinMax minMax = MinMax.getEmpty(false);
+ for (Pin pin : skeleton.getPins()) {
+ minMax = minMax.addPoint(getX(pin), getY(pin));
+ }
+
+ final double borderMargin = 10;
+
+ final Dimension2D dimTotal = new Dimension2DDouble(2 * borderMargin + minMax.getMaxX(), 2 * borderMargin
+ + minMax.getMaxY());
+ UGraphic2 ug = null;// fileFormatOption.createUGraphic(diagram.getColorMapper(), diagram.getDpiFactor(fileFormatOption),
+ // dimTotal, null, false);
+ ug = (UGraphic2) ug.apply(new UTranslate(borderMargin, borderMargin));
+
+ for (PinLink pinLink : skeleton.getPinLinks()) {
+ drawPinLink(ug, pinLink);
+ }
+
+ for (Pin pin : skeleton.getPins()) {
+ drawPin(ug, pin);
+ }
+
+// ug.writeImageTOBEMOVED(os, null, diagram.getDpi(fileFormatOption));
+// return new ImageDataSimple(dimTotal);
+ throw new UnsupportedOperationException();
+ }
+
+ private void drawPin(UGraphic ug, Pin pin) {
+ final double x = getX(pin);
+ final double y = getY(pin);
+ final UEllipse circle = new UEllipse(6, 6);
+ ug.apply(new UChangeColor(HtmlColorUtils.BLACK)).apply(new UChangeBackColor(HtmlColorUtils.BLACK))
+ .apply(new UTranslate(x - 3, y - 3)).draw(circle);
+ }
+
+ private void drawPinLink(UGraphic ug, PinLink pinLink) {
+ final double x1 = getX(pinLink.getPin1());
+ final double y1 = getY(pinLink.getPin1());
+ final double x2 = getX(pinLink.getPin2());
+ final double y2 = getY(pinLink.getPin2());
+
+ final Rose rose = new Rose();
+ final HtmlColor color = rose.getHtmlColor(diagram.getSkinParam(), ColorParam.classArrow);
+ final List<Box2D> b = new ArrayList<Box2D>();
+ final SmartConnection connection = new SmartConnection(x1, y1, x2, y2, b);
+ connection.draw(ug, color);
+ }
+
+ private IEntityImage computeImage(final ILeaf leaf) {
+ final IEntityImage image = CucaDiagramFileMakerSvek2.createEntityImageBlock(leaf, diagram.getSkinParam(),
+ false, diagram, null, null, null);
+ return image;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/hector/CucaDiagramFileMakerHectorB2.java b/src/net/sourceforge/plantuml/hector/CucaDiagramFileMakerHectorB2.java
new file mode 100644
index 0000000..e5a699b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector/CucaDiagramFileMakerHectorB2.java
@@ -0,0 +1,203 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.hector;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.api.ImageDataSimple;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.skin.rose.Rose;
+import net.sourceforge.plantuml.svek.CucaDiagramFileMaker;
+import net.sourceforge.plantuml.svek.CucaDiagramFileMakerSvek2;
+import net.sourceforge.plantuml.svek.IEntityImage;
+import net.sourceforge.plantuml.ugraphic.MinMax;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UGraphic2;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class CucaDiagramFileMakerHectorB2 implements CucaDiagramFileMaker {
+
+ private final CucaDiagram diagram;
+ private SkeletonConfiguration configuration;
+
+ private double singleWidth;
+ private double singleHeight;
+ private double nodeDistanceX = 30;
+ private double nodeDistanceY = 50;
+
+ private UnlinarCompressedPlan unlinarCompressedPlan;
+
+ public CucaDiagramFileMakerHectorB2(CucaDiagram diagram) {
+ this.diagram = diagram;
+ }
+
+ final private Map<Pin, IEntityImage> images = new LinkedHashMap<Pin, IEntityImage>();
+ // final private Map<Pin, Box2D> boxes = new LinkedHashMap<Pin, Box2D>();
+
+ final private Map<Link, PinLink> links = new LinkedHashMap<Link, PinLink>();
+
+ // final private List<Box2D> forbidden = new ArrayList<Box2D>();
+
+ private double getX(Pin pin) {
+ return nodeDistanceX * configuration.getCol(pin);
+ }
+
+ private double getY(Pin pin) {
+ return nodeDistanceY * pin.getRow();
+ }
+
+ private Point2D getPoint(Pin pin) {
+ return new Point2D.Double(getX(pin), getY(pin));
+ }
+
+ // private double getCenterX(Pin pin) {
+ // return singleWidth * configuration.getCol(pin) + singleWidth / 2.0;
+ // }
+ //
+ // private double getCenterY(Pin pin) {
+ // return singleHeight * pin.getRow() + singleHeight / 2.0;
+ // }
+
+ public ImageData createFile(OutputStream os, List<String> dotStrings, FileFormatOption fileFormatOption)
+ throws IOException {
+ final PinFactory pinFactory = new PinFactory();
+ final SkeletonBuilder skeletonBuilder = new SkeletonBuilder();
+ links.clear();
+ for (Link link : diagram.getLinks()) {
+ final PinLink pinLink = pinFactory.createPinLink(link);
+ links.put(link, pinLink);
+ skeletonBuilder.add(pinLink);
+ }
+
+ final Skeleton skeleton = skeletonBuilder.createSkeletons().get(0);
+ this.configuration = SkeletonConfigurationUtils.getBest(skeleton);
+
+ this.singleWidth = 0;
+ this.singleHeight = 0;
+
+ images.clear();
+ for (Pin pin : skeleton.getPins()) {
+ final ILeaf leaf = (ILeaf) pin.getUserData();
+ final IEntityImage image = computeImage(leaf);
+ final Dimension2D dim = TextBlockUtils.getDimension(image);
+ if (dim.getWidth() > singleWidth) {
+ singleWidth = dim.getWidth();
+ }
+ if (dim.getHeight() > singleHeight) {
+ singleHeight = dim.getHeight();
+ }
+ images.put(pin, image);
+ }
+
+ unlinarCompressedPlan = new UnlinarCompressedPlan(singleWidth, nodeDistanceX, singleHeight, nodeDistanceY);
+
+ MinMax minMax = MinMax.getEmpty(false);
+ for (Pin pin : skeleton.getPins()) {
+ minMax = minMax.addPoint(unlinarCompressedPlan.uncompress(getX(pin), getY(pin),
+ UnlinearCompression.Rounding.BORDER_2));
+ }
+
+ final double borderMargin = 10;
+
+ final Dimension2D dimTotal = new Dimension2DDouble(2 * borderMargin + minMax.getMaxX(), 2 * borderMargin
+ + minMax.getMaxY());
+ UGraphic2 ug = null; // fileFormatOption.createUGraphic(diagram.getColorMapper(), diagram.getDpiFactor(fileFormatOption),
+ // dimTotal, null, false);
+ ug = (UGraphic2) ug.apply(new UTranslate(borderMargin, borderMargin));
+
+ for (PinLink pinLink : skeleton.getPinLinks()) {
+ drawPinLink(ug, pinLink);
+ }
+
+ for (Pin pin : skeleton.getPins()) {
+ drawPin(ug, pin);
+ }
+
+// ug.writeImageTOBEMOVED(os, null, diagram.getDpi(fileFormatOption));
+// return new ImageDataSimple(dimTotal);
+ throw new UnsupportedOperationException();
+ }
+
+ private void drawPin(UGraphic ug, Pin pin) {
+ final Point2D pt = unlinarCompressedPlan.uncompress(getPoint(pin), UnlinearCompression.Rounding.BORDER_1);
+
+ final double x = pt.getX();
+ final double y = pt.getY();
+ final UShape rect = new URectangle(unlinarCompressedPlan.getInnerX(), unlinarCompressedPlan.getInnerY());
+ ug.apply(new UChangeColor(HtmlColorUtils.BLACK)).apply(new UChangeBackColor(HtmlColorUtils.BLACK)).apply(
+ new UTranslate(x, y)).draw(rect);
+ }
+
+ private void drawPinLink(UGraphic ug, PinLink pinLink) {
+ final Point2D pp1 = getPoint(pinLink.getPin1());
+ final Point2D pp2 = getPoint(pinLink.getPin2());
+
+ final Rose rose = new Rose();
+ final HtmlColor color = rose.getHtmlColor(diagram.getSkinParam(), ColorParam.classArrow);
+
+ final HectorPath path = unlinarCompressedPlan.uncompressSegment(pp1, pp2);
+ path.draw(ug, color);
+
+// final Point2D p1 = unlinarCompressedPlan.uncompress(pp1, UnlinearCompression.Rounding.CENTRAL);
+// final Point2D p2 = unlinarCompressedPlan.uncompress(pp2, UnlinearCompression.Rounding.CENTRAL);
+// final SmartConnection connection = new SmartConnection(p1, p2, new ArrayList<Box2D>());
+// connection.draw(ug, color);
+ }
+
+ private IEntityImage computeImage(final ILeaf leaf) {
+ final IEntityImage image = CucaDiagramFileMakerSvek2.createEntityImageBlock(leaf, diagram.getSkinParam(),
+ false, diagram, null, null, null);
+ return image;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/hector/GrowingTree.java b/src/net/sourceforge/plantuml/hector/GrowingTree.java
new file mode 100644
index 0000000..c4aedc0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector/GrowingTree.java
@@ -0,0 +1,174 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.hector;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class GrowingTree {
+
+ private final List<PinLink> all = new ArrayList<PinLink>();
+ private final Map<Pin, ArrayList<Pin>> directlyAfter = new HashMap<Pin, ArrayList<Pin>>();
+
+ public Skeleton createSkeleton() {
+ final Set<Pin> pins = new LinkedHashSet<Pin>();
+ for (PinLink link : all) {
+ pins.add(link.getPin1());
+ pins.add(link.getPin2());
+ }
+ normalizeRowToZero(pins);
+ return new Skeleton(new ArrayList<Pin>(pins), new ArrayList<PinLink>(all));
+ }
+
+ private void normalizeRowToZero(Collection<Pin> pins) {
+ int minRow = Integer.MAX_VALUE;
+ for (Pin p : pins) {
+ final int r = p.getRow();
+ if (r == Integer.MAX_VALUE) {
+ throw new IllegalStateException();
+ }
+ if (r < minRow) {
+ minRow = r;
+ }
+ }
+ for (Pin p : pins) {
+ p.push(-minRow);
+ }
+ }
+
+ public boolean canBeAdded(PinLink candidat) {
+ if (all.size() == 0) {
+ return true;
+ }
+ final Pin p1 = candidat.getPin1();
+ final Pin p2 = candidat.getPin2();
+ if (p1.getRow() == Integer.MAX_VALUE && p2.getRow() == Integer.MAX_VALUE) {
+ return false;
+ }
+ return true;
+ }
+
+ public void add(PinLink newPinLink) {
+ final Pin p1 = newPinLink.getPin1();
+ final Pin p2 = newPinLink.getPin2();
+ if (all.size() == 0) {
+ newPinLink.getPin1().setRow(0);
+ simpleRowComputation(newPinLink);
+ } else if (isPartiallyNew(newPinLink)) {
+ simpleRowComputation(newPinLink);
+ } else if (p1.getRow() != Integer.MAX_VALUE && p2.getRow() != Integer.MAX_VALUE) {
+ final int actualRowDiff = p2.getRow() - p1.getRow();
+ final int neededPushForP2 = newPinLink.getLengthStandard() - actualRowDiff;
+ push(p2, neededPushForP2);
+ } else {
+ throw new IllegalArgumentException();
+ }
+ all.add(newPinLink);
+ getDirectlyAfter(p1).add(p2);
+ }
+
+ private List<Pin> getDirectlyAfter(Pin p) {
+ ArrayList<Pin> result = directlyAfter.get(p);
+ if (result == null) {
+ result = new ArrayList<Pin>();
+ directlyAfter.put(p, result);
+ }
+ return result;
+ }
+
+ private Collection<Pin> getIndirectlyAfter(Pin pin) {
+ final Set<Pin> result = new HashSet<Pin>(getDirectlyAfter(pin));
+ int lastSize = result.size();
+ while (true) {
+ for (Pin p : new ArrayList<Pin>(result)) {
+ result.addAll(getDirectlyAfter(p));
+ }
+ if (result.size() == lastSize) {
+ return result;
+ }
+ lastSize = result.size();
+ }
+ }
+
+ private void push(Pin p, int push) {
+ if (push <= 0) {
+ return;
+ }
+ final Collection<Pin> after = getIndirectlyAfter(p);
+ if (after.contains(p)) {
+ throw new IllegalStateException();
+ }
+ p.push(push);
+ for (Pin pp : after) {
+ pp.push(push);
+ }
+ }
+
+ private void simpleRowComputation(PinLink link) {
+ final Pin p1 = link.getPin1();
+ final Pin p2 = link.getPin2();
+ if (p1.getRow() == Integer.MAX_VALUE && p2.getRow() != Integer.MAX_VALUE) {
+ p1.setRow(p2.getRow() - link.getLengthStandard());
+ } else if (p1.getRow() != Integer.MAX_VALUE && p2.getRow() == Integer.MAX_VALUE) {
+ p2.setRow(p1.getRow() + link.getLengthStandard());
+ } else {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ private boolean isPartiallyNew(PinLink link) {
+ final Pin p1 = link.getPin1();
+ final Pin p2 = link.getPin2();
+ if (p1.getRow() == Integer.MAX_VALUE && p2.getRow() != Integer.MAX_VALUE) {
+ return true;
+ } else if (p1.getRow() != Integer.MAX_VALUE && p2.getRow() == Integer.MAX_VALUE) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public void normalizeRowToZero() {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/hector/HectorPath.java b/src/net/sourceforge/plantuml/hector/HectorPath.java
new file mode 100644
index 0000000..3b2778d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector/HectorPath.java
@@ -0,0 +1,71 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.hector;
+
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.geom.LineSegmentDouble;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+
+public class HectorPath {
+
+ private final List<LineSegmentDouble> segments = new ArrayList<LineSegmentDouble>();
+
+ public void add(LineSegmentDouble seg) {
+ this.segments.add(seg);
+ }
+
+ public void add(Point2D p1, Point2D p2) {
+ add(new LineSegmentDouble(p1, p2));
+ }
+
+ @Override
+ public String toString() {
+ return segments.toString();
+ }
+
+ public void draw(UGraphic ug, HtmlColor color) {
+ ug = ug.apply(new UChangeColor(color)).apply(new UStroke(1.5));
+ for (LineSegmentDouble seg : segments) {
+ seg.draw(ug);
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/hector/Pin.java b/src/net/sourceforge/plantuml/hector/Pin.java
new file mode 100644
index 0000000..08e8ed7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector/Pin.java
@@ -0,0 +1,77 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.hector;
+
+
+public class Pin {
+
+ private int row;
+ private int uid = -1;
+
+ private final Object userData;
+
+ public Pin(int row, Object userData) {
+ this.row = row;
+ this.userData = userData;
+ }
+
+ public void setUid(int uid) {
+ if (this.uid != -1) {
+ throw new IllegalStateException();
+ }
+ this.uid = uid;
+ }
+
+ public int getRow() {
+ return row;
+ }
+
+ public int getUid() {
+ return uid;
+ }
+
+ public Object getUserData() {
+ return userData;
+ }
+
+ public void setRow(int row) {
+ this.row = row;
+ }
+
+ public void push(int push) {
+ setRow(getRow() + push);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/hector/PinFactory.java b/src/net/sourceforge/plantuml/hector/PinFactory.java
new file mode 100644
index 0000000..79ed583
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector/PinFactory.java
@@ -0,0 +1,67 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.hector;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import net.sourceforge.plantuml.cucadiagram.Link;
+
+public class PinFactory {
+
+ private final Map<Object, Pin> pins = new HashMap<Object, Pin>();
+
+ Pin create(Object userData) {
+ return create(Integer.MAX_VALUE, userData);
+ }
+
+ public Pin create(int row, Object userData) {
+ if (userData == null) {
+ return new Pin(row, userData);
+ }
+ Pin result = pins.get(userData);
+ if (result == null) {
+ result = new Pin(row, userData);
+ pins.put(userData, result);
+ }
+ return result;
+ }
+
+ public PinLink createPinLink(Link link) {
+ final PinLink result = new PinLink(create(link.getEntity1()), create(link.getEntity2()), link.getLength(), link);
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/hector/PinLink.java b/src/net/sourceforge/plantuml/hector/PinLink.java
new file mode 100644
index 0000000..cb0ce64
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector/PinLink.java
@@ -0,0 +1,77 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.hector;
+
+public class PinLink {
+
+ private final Pin pin1;
+ private final Pin pin2;
+ private final Object userData;
+ private final int length;
+
+ public PinLink(Pin pin1, Pin pin2, int length, Object userData) {
+ if (length < 1) {
+ throw new IllegalArgumentException();
+ }
+ this.pin1 = pin1;
+ this.pin2 = pin2;
+ this.userData = userData;
+ this.length = length;
+ }
+
+ public boolean contains(Pin pin) {
+ return pin == pin1 || pin == pin2;
+ }
+
+ public boolean doesTouch(PinLink other) {
+ return other.contains(pin1) || other.contains(pin2);
+ }
+
+ public Pin getPin1() {
+ return pin1;
+ }
+
+ public Pin getPin2() {
+ return pin2;
+ }
+
+ public int getLengthDot() {
+ return length;
+ }
+
+ public int getLengthStandard() {
+ return length - 1;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/hector/PinLinksContinuousSet.java b/src/net/sourceforge/plantuml/hector/PinLinksContinuousSet.java
new file mode 100644
index 0000000..5a4e2bf
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector/PinLinksContinuousSet.java
@@ -0,0 +1,103 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.hector;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+public class PinLinksContinuousSet {
+
+ private final Collection<PinLink> all = new ArrayList<PinLink>();
+
+ public Skeleton createSkeleton() {
+ final GrowingTree tree = new GrowingTree();
+ final Collection<PinLink> pendings = new ArrayList<PinLink>(all);
+ while (pendings.size() > 0) {
+ for (Iterator<PinLink> it = pendings.iterator(); it.hasNext();) {
+ final PinLink candidat = it.next();
+ if (tree.canBeAdded(candidat)) {
+ tree.add(candidat);
+ it.remove();
+ }
+ }
+ }
+ return tree.createSkeleton();
+
+ }
+
+ public void add(PinLink newPinLink) {
+ if (all.size() == 0) {
+ all.add(newPinLink);
+ return;
+ }
+ if (all.contains(newPinLink)) {
+ throw new IllegalArgumentException("already");
+ }
+ for (PinLink aLink : all) {
+ if (newPinLink.doesTouch(aLink)) {
+ all.add(newPinLink);
+ return;
+ }
+ }
+ throw new IllegalArgumentException("not connex");
+ }
+
+ public void addAll(PinLinksContinuousSet other) {
+ if (doesTouch(other) == false) {
+ throw new IllegalArgumentException();
+ }
+ this.all.addAll(other.all);
+ }
+
+ public boolean doesTouch(PinLink other) {
+ for (PinLink aLink : all) {
+ if (other.doesTouch(aLink)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean doesTouch(PinLinksContinuousSet otherSet) {
+ for (PinLink otherLink : otherSet.all) {
+ if (doesTouch(otherLink)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/hector/Skeleton.java b/src/net/sourceforge/plantuml/hector/Skeleton.java
new file mode 100644
index 0000000..62767e7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector/Skeleton.java
@@ -0,0 +1,84 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.hector;
+
+import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+public class Skeleton {
+
+ private final List<Pin> pins;
+ private final List<PinLink> pinLinks;
+ private final SortedSet<Integer> rows = new TreeSet<Integer>();
+
+ public Skeleton(List<Pin> pins, List<PinLink> pinLinks) {
+ this.pins = pins;
+ this.pinLinks = pinLinks;
+ int uid = 0;
+ for (Pin pin : pins) {
+ pin.setUid(uid++);
+ rows.add(pin.getRow());
+ }
+ }
+
+ public SortedSet<Integer> getRows() {
+ return rows;
+ }
+
+ public List<Pin> getPins() {
+ return pins;
+ }
+
+ public Collection<Pin> getPinsOfRow(int row) {
+ final Set<Pin> result = new LinkedHashSet<Pin>();
+ for (Pin pin : pins) {
+ if (pin.getRow() == row) {
+ result.add(pin);
+ }
+ }
+ return result;
+ }
+
+ public List<PinLink> getPinLinks() {
+ return pinLinks;
+ }
+
+
+
+}
diff --git a/src/net/sourceforge/plantuml/hector/SkeletonBuilder.java b/src/net/sourceforge/plantuml/hector/SkeletonBuilder.java
new file mode 100644
index 0000000..e682eb5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector/SkeletonBuilder.java
@@ -0,0 +1,84 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.hector;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public class SkeletonBuilder {
+
+ private List<PinLinksContinuousSet> sets = new ArrayList<PinLinksContinuousSet>();
+
+ public void add(PinLink pinLink) {
+ addInternal(pinLink);
+ merge();
+
+ }
+
+ private void merge() {
+ for (int i = 0; i < sets.size() - 1; i++) {
+ for (int j = i + 1; j < sets.size(); j++) {
+ if (sets.get(i).doesTouch(sets.get(j))) {
+ sets.get(i).addAll(sets.get(j));
+ sets.remove(j);
+ return;
+ }
+ }
+ }
+ }
+
+ private void addInternal(PinLink pinLink) {
+ for (PinLinksContinuousSet set : sets) {
+ if (set.doesTouch(pinLink)) {
+ set.add(pinLink);
+ return;
+ }
+ }
+ final PinLinksContinuousSet newSet = new PinLinksContinuousSet();
+ newSet.add(pinLink);
+ sets.add(newSet);
+ }
+
+ public List<Skeleton> createSkeletons() {
+ final List<Skeleton> result = new ArrayList<Skeleton>();
+
+ for (PinLinksContinuousSet set : sets) {
+ result.add(set.createSkeleton());
+ }
+
+ return Collections.unmodifiableList(result);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/hector/SkeletonConfiguration.java b/src/net/sourceforge/plantuml/hector/SkeletonConfiguration.java
new file mode 100644
index 0000000..8cada11
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector/SkeletonConfiguration.java
@@ -0,0 +1,255 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.hector;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class SkeletonConfiguration {
+
+ private final int position[];
+ private final Skeleton skeleton;
+
+ public static SkeletonConfiguration getDefault(Skeleton skeleton) {
+ final Collection<Integer> rows = skeleton.getRows();
+ final Map<Integer, Integer> free = new HashMap<Integer, Integer>();
+ for (Integer i : rows) {
+ free.put(i, 0);
+ }
+ final Collection<Pin> pins = skeleton.getPins();
+ final int position[] = new int[pins.size()];
+ for (Pin pin : pins) {
+ final int f = free.get(pin.getRow());
+ position[pin.getUid()] = f;
+ free.put(pin.getRow(), f + 1);
+ }
+ return new SkeletonConfiguration(skeleton, position);
+ }
+
+ @Override
+ public int hashCode() {
+ int result = 0;
+ for (int v : position) {
+ result = result * 37 + v;
+ }
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ final SkeletonConfiguration this2 = (SkeletonConfiguration) other;
+ if (this.skeleton != this2.skeleton) {
+ throw new IllegalArgumentException();
+ }
+ if (this.position.length != this2.position.length) {
+ throw new IllegalArgumentException();
+ }
+ for (int i = 0; i < position.length; i++) {
+ if (this.position[i] != this2.position[i]) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ final int minRow = skeleton.getRows().first();
+ final int maxRow = skeleton.getRows().last();
+ int minCol = Integer.MAX_VALUE;
+ int maxCol = Integer.MIN_VALUE;
+ for (int c : position) {
+ if (c > maxCol) {
+ maxCol = c;
+ }
+ if (c < minCol) {
+ minCol = c;
+ }
+ }
+ final StringBuilder result = new StringBuilder();
+ for (int r = minRow; r <= maxRow; r++) {
+ appendRow(result, r, minCol, maxCol);
+ if (r < maxRow) {
+ result.append(" ");
+ }
+ }
+ return result.toString();
+ }
+
+ private void appendRow(StringBuilder result, int row, int minCol, int maxCol) {
+ result.append("(");
+ boolean first = true;
+ for (int c = minCol; c <= maxCol; c++) {
+ if (first == false) {
+ result.append("-");
+ }
+ final Pin pin = getPin(row, c);
+ if (pin == null) {
+ result.append(".");
+ } else {
+ result.append(pin.getUid());
+ }
+ first = false;
+ }
+ result.append(")");
+
+ }
+
+ private Pin getPin(int row, int col) {
+ for (Pin p : skeleton.getPinsOfRow(row)) {
+ if (getCol(p) == col) {
+ return p;
+ }
+ }
+ return null;
+ }
+
+ public int getCol(Pin pin) {
+ return position[pin.getUid()];
+ }
+
+ private SkeletonConfiguration(Skeleton skeleton, int position[]) {
+ this.position = position;
+ this.skeleton = skeleton;
+ }
+
+ class Switch implements SkeletonMutation {
+ private final SkeletonConfiguration newConfiguration;
+
+ public Switch(Pin pin1, Pin pin2) {
+ if (pin1 == pin2) {
+ throw new IllegalArgumentException();
+ }
+ final int copy[] = new int[position.length];
+ for (int i = 0; i < position.length; i++) {
+ if (i == pin1.getUid()) {
+ copy[i] = position[pin2.getUid()];
+ } else if (i == pin2.getUid()) {
+ copy[i] = position[pin1.getUid()];
+ } else {
+ copy[i] = position[i];
+ }
+ }
+ this.newConfiguration = new SkeletonConfiguration(skeleton, copy);
+ }
+
+ public SkeletonConfiguration mutate() {
+ return newConfiguration;
+ }
+ }
+
+ class Move implements SkeletonMutation {
+ private final SkeletonConfiguration newConfiguration;
+
+ public Move(Pin pin, int deltaX) {
+ final int copy[] = new int[position.length];
+ for (int i = 0; i < position.length; i++) {
+ if (i == pin.getUid()) {
+ copy[i] = position[i] + deltaX;
+ } else {
+ copy[i] = position[i];
+ }
+ }
+ this.newConfiguration = new SkeletonConfiguration(skeleton, copy);
+ }
+
+ public SkeletonConfiguration mutate() {
+ return newConfiguration;
+ }
+ }
+
+ private Collection<SkeletonMutation> getMutationForRow(int row) {
+ final Collection<Pin> pins = skeleton.getPinsOfRow(row);
+ final Collection<Integer> usedCols = new HashSet<Integer>();
+ for (Pin pin : pins) {
+ usedCols.add(getCol(pin));
+ }
+ final Collection<SkeletonMutation> result = new ArrayList<SkeletonMutation>();
+ for (Pin pin1 : pins) {
+ final int c = getCol(pin1);
+ if (usedCols.contains(c + 1) == false) {
+ result.add(new Move(pin1, 1));
+ }
+ if (usedCols.contains(c - 1) == false) {
+ result.add(new Move(pin1, -1));
+ }
+ for (Pin pin2 : pins) {
+ if (pin1 == pin2) {
+ continue;
+ }
+ if (getCol(pin1) > getCol(pin2)) {
+ continue;
+ }
+ if (getCol(pin1) == getCol(pin2)) {
+ throw new IllegalStateException();
+ }
+ result.add(new Switch(pin1, pin2));
+ }
+ }
+ return result;
+ }
+
+ public Set<SkeletonConfiguration> getSomeMuteds() {
+ final Set<SkeletonConfiguration> result = new HashSet<SkeletonConfiguration>();
+ for (Integer row : skeleton.getRows()) {
+ for (SkeletonMutation mutation : getMutationForRow(row)) {
+ result.add(mutation.mutate());
+ }
+
+ }
+ return result;
+ }
+
+ public List<PinLink> getPinLinks() {
+ return skeleton.getPinLinks();
+ }
+
+ public double getLength(PinLink link) {
+ final double x1 = getCol(link.getPin1());
+ final double y1 = link.getPin1().getRow();
+ final double x2 = getCol(link.getPin2());
+ final double y2 = link.getPin2().getRow();
+ final double dx = x2 - x1;
+ final double dy = y2 - y1;
+ return Math.sqrt(dx * dx + dy * dy);
+ }
+
+
+}
diff --git a/src/net/sourceforge/plantuml/hector/SkeletonConfigurationComparator.java b/src/net/sourceforge/plantuml/hector/SkeletonConfigurationComparator.java
new file mode 100644
index 0000000..c8a233e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector/SkeletonConfigurationComparator.java
@@ -0,0 +1,59 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.hector;
+
+import java.util.Comparator;
+
+public class SkeletonConfigurationComparator implements Comparator<SkeletonConfiguration> {
+
+ private final SkeletonConfigurationEvaluator evaluator;
+
+ public SkeletonConfigurationComparator(SkeletonConfigurationEvaluator evaluator) {
+ this.evaluator = evaluator;
+ }
+
+ public int compare(SkeletonConfiguration sc1, SkeletonConfiguration sc2) {
+ final double price1 = evaluator.getPrice(sc1);
+ final double price2 = evaluator.getPrice(sc2);
+ if (price1 > price2) {
+ return 1;
+ }
+ if (price1 < price2) {
+ return -1;
+ }
+ return 0;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/hector/SkeletonConfigurationEvaluator.java b/src/net/sourceforge/plantuml/hector/SkeletonConfigurationEvaluator.java
new file mode 100644
index 0000000..ea5d1cf
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector/SkeletonConfigurationEvaluator.java
@@ -0,0 +1,41 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.hector;
+
+public interface SkeletonConfigurationEvaluator {
+
+ public double getPrice(SkeletonConfiguration configuration);
+
+}
diff --git a/src/net/sourceforge/plantuml/hector/SkeletonConfigurationEvaluatorLineLenght.java b/src/net/sourceforge/plantuml/hector/SkeletonConfigurationEvaluatorLineLenght.java
new file mode 100644
index 0000000..9ffd158
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector/SkeletonConfigurationEvaluatorLineLenght.java
@@ -0,0 +1,47 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.hector;
+
+public class SkeletonConfigurationEvaluatorLineLenght implements SkeletonConfigurationEvaluator {
+
+ public double getPrice(SkeletonConfiguration configuration) {
+ double result = 0;
+ for (PinLink link : configuration.getPinLinks()) {
+ result += configuration.getLength(link);
+ }
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/hector/SkeletonConfigurationSet.java b/src/net/sourceforge/plantuml/hector/SkeletonConfigurationSet.java
new file mode 100644
index 0000000..77ea314
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector/SkeletonConfigurationSet.java
@@ -0,0 +1,89 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.hector;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+public class SkeletonConfigurationSet implements Iterable<SkeletonConfiguration> {
+
+ private final List<SkeletonConfiguration> all;
+ private final SkeletonConfigurationComparator comparator;
+ private final int limitSize;
+
+ public SkeletonConfigurationSet(int limitSize, SkeletonConfigurationEvaluator evaluator) {
+ this.comparator = new SkeletonConfigurationComparator(evaluator);
+ this.all = new ArrayList<SkeletonConfiguration>();
+ this.limitSize = limitSize;
+ }
+
+ public void add(SkeletonConfiguration skeletonConfiguration) {
+ this.all.add(skeletonConfiguration);
+ sortAndTruncate();
+ }
+
+ public void addAll(Collection<SkeletonConfiguration> others) {
+ all.addAll(others);
+ sortAndTruncate();
+ }
+
+ private void sortAndTruncate() {
+ Collections.sort(all, comparator);
+ while (all.size() > limitSize) {
+ all.remove(all.size() - 1);
+ }
+ }
+
+ @Override
+ public String toString() {
+ return all.toString();
+ }
+
+ public int size() {
+ return all.size();
+ }
+
+ public Iterator<SkeletonConfiguration> iterator() {
+ return new ArrayList<SkeletonConfiguration>(all).iterator();
+ }
+
+ public SkeletonConfiguration first() {
+ return all.get(0);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/hector/SkeletonConfigurationUtils.java b/src/net/sourceforge/plantuml/hector/SkeletonConfigurationUtils.java
new file mode 100644
index 0000000..25354c0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector/SkeletonConfigurationUtils.java
@@ -0,0 +1,56 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.hector;
+
+public class SkeletonConfigurationUtils {
+
+ public static SkeletonConfiguration getBest(Skeleton skeleton) {
+ SkeletonConfiguration config = SkeletonConfiguration.getDefault(skeleton);
+
+ final SkeletonConfigurationSet set = new SkeletonConfigurationSet(200,
+ new SkeletonConfigurationEvaluatorLineLenght());
+ set.add(config);
+
+ for (int i = 0; i < 10; i++) {
+ System.err.println("before size=" + set.size());
+ for (SkeletonConfiguration sk : set) {
+ set.addAll(sk.getSomeMuteds());
+ }
+ System.err.println("after size=" + set.size());
+ }
+ return set.first();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/hector/SkeletonConfigurations.java b/src/net/sourceforge/plantuml/hector/SkeletonConfigurations.java
new file mode 100644
index 0000000..c9a8cbf
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector/SkeletonConfigurations.java
@@ -0,0 +1,39 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.hector;
+
+public class SkeletonConfigurations {
+
+}
diff --git a/src/net/sourceforge/plantuml/hector/SkeletonMutation.java b/src/net/sourceforge/plantuml/hector/SkeletonMutation.java
new file mode 100644
index 0000000..6b53db4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector/SkeletonMutation.java
@@ -0,0 +1,41 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.hector;
+
+interface SkeletonMutation {
+
+ public SkeletonConfiguration mutate();
+
+}
diff --git a/src/net/sourceforge/plantuml/hector/SmartConnection.java b/src/net/sourceforge/plantuml/hector/SmartConnection.java
new file mode 100644
index 0000000..a18f5bb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector/SmartConnection.java
@@ -0,0 +1,110 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.hector;
+
+import java.awt.geom.Point2D;
+import java.util.List;
+
+import net.sourceforge.plantuml.geom.LineSegmentDouble;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+
+class SmartConnection {
+
+ private final double x1;
+ private final double y1;
+ private final double x2;
+ private final double y2;
+ private final List<Box2D> forbidden;
+
+ public SmartConnection(double x1, double y1, double x2, double y2, List<Box2D> forbidden) {
+ this.x1 = x1;
+ this.y1 = y1;
+ this.x2 = x2;
+ this.y2 = y2;
+ this.forbidden = forbidden;
+ }
+
+ public SmartConnection(Point2D p1, Point2D p2, List<Box2D> b) {
+ this(p1.getX(), p1.getY(), p2.getX(), p2.getY(), b);
+ }
+
+ public void draw(UGraphic ug, HtmlColor color) {
+ final LineSegmentDouble seg = new LineSegmentDouble(x1, y1, x2, y2);
+ boolean clash = intersect(seg);
+ if (clash) {
+ ug = ug.apply(new UChangeColor(HtmlColorUtils.BLACK)).apply(new UStroke(1.0));
+ } else {
+ ug = ug.apply(new UChangeColor(color)).apply(new UStroke(1.5));
+ }
+ seg.draw(ug);
+ }
+
+ private boolean intersect(LineSegmentDouble seg) {
+ for (Box2D box : forbidden) {
+ if (box.doesIntersect(seg)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void drawEx1(UGraphic ug, HtmlColor color) {
+ ug = ug.apply(new UChangeColor(color)).apply(new UStroke(1.5));
+ final double orthoX = -(y2 - y1);
+ final double orthoY = x2 - x1;
+ for (int i = -10; i <= 10; i++) {
+ for (int j = -10; j <= 10; j++) {
+ final double d1x = orthoX * i / 10.0;
+ final double d1y = orthoY * i / 10.0;
+ final double c1x = (x1 + x2) / 2 + d1x;
+ final double c1y = (y1 + y2) / 2 + d1y;
+ final double d2x = orthoX * j / 10.0;
+ final double d2y = orthoY * j / 10.0;
+ final double c2x = (x1 + x2) / 2 + d2x;
+ final double c2y = (y1 + y2) / 2 + d2y;
+ final UPath path = new UPath();
+ path.moveTo(x1, y1);
+ path.cubicTo(c1x, c1y, c2x, c2y, x2, y2);
+ ug.draw(path);
+ }
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/hector/UnlinarCompressedPlan.java b/src/net/sourceforge/plantuml/hector/UnlinarCompressedPlan.java
new file mode 100644
index 0000000..8d27d33
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector/UnlinarCompressedPlan.java
@@ -0,0 +1,143 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.hector;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.geom.LineSegmentDouble;
+import net.sourceforge.plantuml.hector.UnlinearCompression.Rounding;
+
+class UnlinarCompressedPlan {
+
+ private final UnlinearCompression compX;
+ private final UnlinearCompression compY;
+
+ public UnlinarCompressedPlan(double inner, double outer) {
+ this(inner, outer, inner, outer);
+ }
+
+ public UnlinarCompressedPlan(double innerx, double outerx, double innery, double outery) {
+ this.compX = new UnlinearCompression(innerx, outerx);
+ this.compY = new UnlinearCompression(innery, outery);
+ }
+
+ public double getInnerX() {
+ return compX.innerSize();
+ }
+
+ public double getInnerY() {
+ return compY.innerSize();
+ }
+
+ public HectorPath uncompressSegmentSimple(Point2D pp1, Point2D pp2) {
+ final HectorPath result = new HectorPath();
+ result.add(new LineSegmentDouble(uncompress(pp1, UnlinearCompression.Rounding.CENTRAL), uncompress(pp2,
+ UnlinearCompression.Rounding.CENTRAL)));
+ return result;
+ }
+
+ public HectorPath uncompressSegment(Point2D pp1, Point2D pp2) {
+ double x1 = pp1.getX();
+ double y1 = pp1.getY();
+ final double x2 = pp2.getX();
+ final double y2 = pp2.getY();
+ final HectorPath result = new HectorPath();
+ final double y[] = compY.encounteredSingularities(y1, y2);
+ if (y.length == 0 || x1 == x2) {
+ result.add(new LineSegmentDouble(uncompress(pp1, UnlinearCompression.Rounding.CENTRAL), uncompress(pp2,
+ UnlinearCompression.Rounding.CENTRAL)));
+ return result;
+ }
+ System.err.println("len=" + y.length);
+ final LineSegmentDouble segment = new LineSegmentDouble(pp1, pp2);
+ for (int i = 0; i < y.length; i++) {
+ final double x = segment.getIntersectionHorizontal(y[i]);
+ final Rounding r = i == 0 ? UnlinearCompression.Rounding.CENTRAL : UnlinearCompression.Rounding.BORDER_2;
+ result.add(uncompress(x1, y1, r), uncompress(x, y[i], UnlinearCompression.Rounding.BORDER_1));
+ x1 = x;
+ y1 = y[i];
+ }
+ result.add(uncompress(x1, y1, UnlinearCompression.Rounding.BORDER_2), uncompress(x2, y2,
+ UnlinearCompression.Rounding.CENTRAL));
+ return result;
+
+ }
+
+ public HectorPath uncompress(LineSegmentDouble segment) {
+ double x1 = segment.getX1();
+ double y1 = segment.getY1();
+ final double x2 = segment.getX2();
+ final double y2 = segment.getY2();
+ final HectorPath result = new HectorPath();
+ final double x[] = compX.encounteredSingularities(x1, x2);
+ if (x.length == 0) {
+ result.add(getUncompressedSegment(x1, y1, x2, y2, UnlinearCompression.Rounding.BORDER_2));
+ return result;
+ }
+ for (int i = 0; i < x.length; i++) {
+ final double y = segment.getIntersectionVertical(x[i]);
+ result.add(getUncompressedSegment(x1, y1, x[i], y, UnlinearCompression.Rounding.BORDER_2));
+ x1 = x[i];
+ y1 = y;
+ }
+ result.add(getUncompressedSegment(x1, y1, x2, y2, UnlinearCompression.Rounding.BORDER_2));
+ return result;
+ }
+
+ public Point2D uncompress(Point2D pt, UnlinearCompression.Rounding rounding) {
+ return uncompress(pt.getX(), pt.getY(), rounding);
+ }
+
+ public Point2D uncompress(double x, double y, UnlinearCompression.Rounding rounding) {
+ return new Point2D.Double(compX.uncompress(x, rounding), compY.uncompress(y, rounding));
+ }
+
+ private LineSegmentDouble getUncompressedSegment(final double x1, final double y1, final double x2,
+ final double y2, UnlinearCompression.Rounding rounding) {
+ final LineSegmentDouble un1 = new LineSegmentDouble(compX.uncompress(x1, rounding), compY.uncompress(y1,
+ rounding), compX.uncompress(x2, rounding), compY.uncompress(y2, rounding));
+ return un1;
+ }
+
+ // private LineSegmentDouble getUncompressedSegmentRoundBefore(final double
+ // x1, final double y1, final double x2,
+ // final double y2) {
+ // final LineSegmentDouble un1 = new LineSegmentDouble(compX.uncompress(x1),
+ // compY.uncompress(y1),
+ // compX.uncompress(x2) - compX.innerSize(), compY.uncompress(y2));
+ // return un1;
+ // }
+
+}
diff --git a/src/net/sourceforge/plantuml/hector/UnlinearCompression.java b/src/net/sourceforge/plantuml/hector/UnlinearCompression.java
new file mode 100644
index 0000000..babe6b4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector/UnlinearCompression.java
@@ -0,0 +1,111 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.hector;
+
+class UnlinearCompression {
+
+ static enum Rounding {
+ BORDER_1, CENTRAL, BORDER_2;
+ }
+
+ private final double inner;
+ private final double outer;
+
+ public UnlinearCompression(double inner, double outer) {
+ this.inner = inner;
+ this.outer = outer;
+ }
+
+ public double compress(double x) {
+ final double pour = x / (inner + outer);
+ final double pourInter = Math.floor(pour);
+ x -= pourInter * (inner + outer);
+ if (x < inner) {
+ return pourInter * outer;
+ }
+ return x - inner + pourInter * outer;
+ }
+
+ public double uncompress(double x, Rounding rounding) {
+ final int pourInter = nbOuterBefore(x);
+ final boolean onBorder = equals(x, pourInter * outer);
+ if (onBorder && rounding == Rounding.BORDER_1) {
+ // Nothing
+ } else if (onBorder && rounding == Rounding.CENTRAL) {
+ x += inner / 2.0;
+ } else {
+ x += inner;
+ }
+ x += pourInter * inner;
+ return x;
+ }
+
+ private static boolean equals(double d1, double d2) {
+ return Math.abs(d1 - d2) < .001;
+ }
+
+ private int nbOuterBefore(double x) {
+ final double pour = x / outer;
+ final int pourInter = (int) Math.floor(pour);
+ return pourInter;
+ }
+
+ public double[] encounteredSingularities(double from, double to) {
+ final int outer1 = nbOuterBefore(from) + 1;
+ int outer2 = nbOuterBefore(to) + 1;
+ if (equals(to, (outer2 - 1) * outer)) {
+ outer2--;
+ }
+ final double result[];
+ if (from <= to) {
+ result = new double[outer2 - outer1];
+ for (int i = 0; i < result.length; i++) {
+ result[i] = (outer1 + i) * outer;
+ }
+ } else {
+ result = new double[outer1 - outer2];
+ for (int i = 0; i < result.length; i++) {
+ result[i] = (outer1 - 1 - i) * outer;
+ }
+
+ }
+ return result;
+ }
+
+ public double innerSize() {
+ return inner;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/hector2/CucaDiagramFileMakerHectorC1.java b/src/net/sourceforge/plantuml/hector2/CucaDiagramFileMakerHectorC1.java
new file mode 100644
index 0000000..b05095a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector2/CucaDiagramFileMakerHectorC1.java
@@ -0,0 +1,104 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.hector2;
+
+import java.awt.geom.Dimension2D;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.List;
+
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.api.ImageDataSimple;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.hector2.continuity.Skeleton;
+import net.sourceforge.plantuml.hector2.continuity.SkeletonBuilder;
+import net.sourceforge.plantuml.hector2.graphic.Foo2;
+import net.sourceforge.plantuml.hector2.layering.Layer;
+import net.sourceforge.plantuml.hector2.layering.LayerFactory;
+import net.sourceforge.plantuml.hector2.mpos.Distribution;
+import net.sourceforge.plantuml.hector2.mpos.MutationLayer;
+import net.sourceforge.plantuml.svek.CucaDiagramFileMaker;
+import net.sourceforge.plantuml.ugraphic.UGraphic2;
+
+public class CucaDiagramFileMakerHectorC1 implements CucaDiagramFileMaker {
+
+ private final CucaDiagram diagram;
+
+ public CucaDiagramFileMakerHectorC1(CucaDiagram diagram) {
+ this.diagram = diagram;
+ }
+
+ public ImageData createFile(OutputStream os, List<String> dotStrings, FileFormatOption fileFormatOption)
+ throws IOException {
+ final SkeletonBuilder skeletonBuilder = new SkeletonBuilder();
+ for (Link link : diagram.getLinks()) {
+ skeletonBuilder.add(link);
+ }
+ final List<Skeleton> skeletons = skeletonBuilder.getSkeletons();
+ if (skeletons.size() != 1) {
+ throw new UnsupportedOperationException("size=" + skeletons.size());
+ }
+ final List<Layer> layers = new LayerFactory().getLayers(skeletons.get(0));
+ // System.err.println("layers=" + layers);
+
+ final Distribution distribution = new Distribution(layers);
+ final double cost1 = distribution.cost(diagram.getLinks());
+ System.err.println("cost1=" + cost1);
+
+ final List<MutationLayer> mutations = distribution.getPossibleMutations();
+ for (MutationLayer m : mutations) {
+ System.err.println(m.toString());
+ final Distribution muted = distribution.mute(m);
+ final double cost2 = muted.cost(diagram.getLinks());
+ System.err.println("cost2=" + cost2);
+ }
+
+ final Foo2 foo2 = new Foo2(distribution, diagram);
+
+ final Dimension2D dimTotal = foo2.calculateDimension(TextBlockUtils.getDummyStringBounder());
+
+ UGraphic2 ug = null; //fileFormatOption.createUGraphic(diagram.getColorMapper(), diagram.getDpiFactor(fileFormatOption),
+ //dimTotal, null, false);
+ foo2.drawU(ug);
+
+// ug.writeImageTOBEMOVED(os, null, diagram.getDpi(fileFormatOption));
+// return new ImageDataSimple(dimTotal);
+ throw new UnsupportedOperationException();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/hector2/MinMax.java b/src/net/sourceforge/plantuml/hector2/MinMax.java
new file mode 100644
index 0000000..cd77143
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector2/MinMax.java
@@ -0,0 +1,98 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.hector2;
+
+import java.util.Collection;
+
+public class MinMax {
+
+ private final int min;
+ private final int max;
+
+ private MinMax(int min, int max) {
+ if (max < min) {
+ throw new IllegalArgumentException();
+ }
+ this.min = min;
+ this.max = max;
+ }
+
+ private MinMax(int value) {
+ this(value, value);
+ }
+
+ public MinMax add(int value) {
+ final int newMin = Math.min(min, value);
+ final int newMax = Math.max(max, value);
+ if (min == newMin && max == newMax) {
+ return this;
+ }
+ return new MinMax(newMin, newMax);
+ }
+
+ public MinMax add(MinMax other) {
+ final int newMin = Math.min(min, other.min);
+ final int newMax = Math.max(max, other.max);
+ if (min == newMin && max == newMax) {
+ return this;
+ }
+ return new MinMax(newMin, newMax);
+ }
+
+ public final int getMin() {
+ return min;
+ }
+
+ public final int getMax() {
+ return max;
+ }
+
+ public static MinMax from(Collection<Integer> values) {
+ MinMax result = null;
+ for (Integer i : values) {
+ if (result == null) {
+ result = new MinMax(i);
+ } else {
+ result = result.add(i);
+ }
+ }
+ return result;
+ }
+
+ public int getDiff() {
+ return max - min;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/hector2/continuity/Skeleton.java b/src/net/sourceforge/plantuml/hector2/continuity/Skeleton.java
new file mode 100644
index 0000000..383e473
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector2/continuity/Skeleton.java
@@ -0,0 +1,188 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.hector2.continuity;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.Link;
+
+public class Skeleton {
+
+ private final Set<IEntity> entities = new HashSet<IEntity>();
+ private final List<Link> links = new ArrayList<Link>();
+
+ private Set<IEntity> getDirectChildren(IEntity parent) {
+ final Set<IEntity> result = new HashSet<IEntity>();
+ for (Link link : links) {
+ if (link.isAutolink()) {
+ continue;
+ }
+ if (link.getEntity1() == parent) {
+ result.add(link.getEntity2());
+ }
+ }
+ return Collections.unmodifiableSet(result);
+ }
+
+ @Override
+ public String toString() {
+ return "skeleton " + links;
+ }
+
+ private Set<IEntity> getIndirectChildren(IEntity parent) {
+ final Set<IEntity> result = new HashSet<IEntity>(getDirectChildren(parent));
+ int currentSize = result.size();
+ while (true) {
+ for (IEntity ent : new HashSet<IEntity>(result)) {
+ result.addAll(getDirectChildren(ent));
+ }
+ if (result.contains(parent) || result.size() == currentSize) {
+ return Collections.unmodifiableSet(result);
+ }
+ currentSize = result.size();
+ }
+ }
+
+ private boolean hasCycle() {
+ for (IEntity ent : entities) {
+ if (getIndirectChildren(ent).contains(ent)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public Skeleton removeCycle() {
+ final Skeleton result = new Skeleton();
+ for (Link link : links) {
+ result.add(link);
+ if (result.hasCycle()) {
+ result.links.remove(link);
+ }
+ }
+ return result;
+ }
+
+ public void add(Link link) {
+ if (links.contains(link)) {
+ throw new IllegalArgumentException();
+ }
+ if (link.getEntity1().isGroup()) {
+ throw new IllegalArgumentException();
+ }
+ if (link.getEntity2().isGroup()) {
+ throw new IllegalArgumentException();
+ }
+ links.add(link);
+ entities.add(link.getEntity1());
+ entities.add(link.getEntity2());
+ }
+
+ public void addAll(Skeleton other) {
+ for (Link otherLink : other.links) {
+ this.add(otherLink);
+ }
+
+ }
+
+ public boolean doesTouch(Link other) {
+ for (Link link : links) {
+ if (link.doesTouch(other)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean doesTouch(Skeleton other) {
+ for (Link link : links) {
+ if (other.doesTouch(link)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void computeLayers() {
+ if (hasCycle()) {
+ throw new UnsupportedOperationException();
+ }
+ for (IEntity ent : entities) {
+ ent.setHectorLayer(0);
+ }
+ boolean changed;
+ do {
+ changed = false;
+ for (Link link : links) {
+ if (ensureLayer(link)) {
+ changed = true;
+ }
+ }
+ } while (changed);
+ }
+
+ private boolean ensureLayer(Link link) {
+ final int lenght = link.getLength();
+ final int l1 = link.getEntity1().getHectorLayer();
+ final int l2 = link.getEntity2().getHectorLayer();
+ if (lenght == 1) {
+ if (l1 < l2) {
+ link.getEntity1().setHectorLayer(l2);
+ return true;
+ } else if (l2 < l1) {
+ link.getEntity2().setHectorLayer(l1);
+ return true;
+ }
+ } else {
+ final int l2theoric = l1 + lenght - 1;
+ if (l2 < l2theoric) {
+ link.getEntity2().setHectorLayer(l2theoric);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public Collection<IEntity> entities() {
+ return Collections.unmodifiableCollection(entities);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/hector2/continuity/SkeletonBuilder.java b/src/net/sourceforge/plantuml/hector2/continuity/SkeletonBuilder.java
new file mode 100644
index 0000000..83da747
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector2/continuity/SkeletonBuilder.java
@@ -0,0 +1,86 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.hector2.continuity;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import net.sourceforge.plantuml.cucadiagram.Link;
+
+public class SkeletonBuilder {
+
+ private List<Skeleton> all = new ArrayList<Skeleton>();
+
+ public void add(Link link) {
+ addInternal(link);
+ do {
+ final boolean changed = merge();
+ if (changed == false) {
+ return;
+ }
+ } while (true);
+
+ }
+
+ private boolean merge() {
+ for (int i = 0; i < all.size() - 1; i++) {
+ for (int j = i + 1; j < all.size(); j++) {
+ if (all.get(i).doesTouch(all.get(j))) {
+ all.get(i).addAll(all.get(j));
+ all.remove(j);
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private void addInternal(Link link) {
+ for (Skeleton skeleton : all) {
+ if (skeleton.doesTouch(link)) {
+ skeleton.add(link);
+ return;
+ }
+ }
+ final Skeleton newSkeleton = new Skeleton();
+ newSkeleton.add(link);
+ all.add(newSkeleton);
+ }
+
+ public List<Skeleton> getSkeletons() {
+ return Collections.unmodifiableList(all);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/hector2/graphic/Foo1.java b/src/net/sourceforge/plantuml/hector2/graphic/Foo1.java
new file mode 100644
index 0000000..bd60416
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector2/graphic/Foo1.java
@@ -0,0 +1,66 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.hector2.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.hector2.layering.Layer;
+import net.sourceforge.plantuml.svek.CucaDiagramFileMakerSvek2;
+import net.sourceforge.plantuml.svek.IEntityImage;
+
+public class Foo1 {
+
+ public static Dimension2D getMaxCellDimension(StringBounder stringBounder, Layer layer, CucaDiagram diagram) {
+ Dimension2D result = new Dimension2DDouble(0, 0);
+ for (IEntity ent : layer.entities()) {
+ final IEntityImage image = computeImage((ILeaf) ent, diagram);
+ final Dimension2D dim = image.calculateDimension(stringBounder);
+ result = Dimension2DDouble.max(result, dim);
+ }
+ return result;
+ }
+
+ private static IEntityImage computeImage(final ILeaf leaf, CucaDiagram diagram) {
+ final IEntityImage image = CucaDiagramFileMakerSvek2.createEntityImageBlock(leaf, diagram.getSkinParam(),
+ false, diagram, null, null, null);
+ return image;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/hector2/graphic/Foo2.java b/src/net/sourceforge/plantuml/hector2/graphic/Foo2.java
new file mode 100644
index 0000000..4e586d5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector2/graphic/Foo2.java
@@ -0,0 +1,106 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.hector2.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.hector2.MinMax;
+import net.sourceforge.plantuml.hector2.layering.Layer;
+import net.sourceforge.plantuml.hector2.mpos.Distribution;
+import net.sourceforge.plantuml.svek.CucaDiagramFileMakerSvek2;
+import net.sourceforge.plantuml.svek.IEntityImage;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class Foo2 implements TextBlock {
+
+ private final Distribution distribution;
+ private final CucaDiagram diagram;
+
+ public Foo2(Distribution distribution, CucaDiagram diagram) {
+ this.distribution = distribution;
+ this.diagram = diagram;
+ }
+
+ public Dimension2D getMaxCellDimension(StringBounder stringBounder) {
+ Dimension2D result = new Dimension2DDouble(0, 0);
+ for (Layer layer : distribution.getLayers()) {
+ final Dimension2D dim = Foo1.getMaxCellDimension(stringBounder, layer, diagram);
+ result = Dimension2DDouble.max(result, dim);
+ }
+ return result;
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D cell = getMaxCellDimension(stringBounder);
+ final MinMax longitudes = distribution.getMinMaxLongitudes();
+ final double width = (longitudes.getDiff() + 2) * cell.getWidth() / 2;
+ final double height = cell.getHeight() * distribution.getNbLayers();
+ return new Dimension2DDouble(width, height);
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D cell = getMaxCellDimension(stringBounder);
+ for (Layer layer : distribution.getLayers()) {
+ drawLayer(ug, layer, cell.getWidth(), cell.getHeight());
+ ug = ug.apply(new UTranslate(0, cell.getHeight()));
+ }
+ }
+
+ private void drawLayer(UGraphic ug, Layer layer, double w, double h) {
+ for (IEntity ent : layer.entities()) {
+ final IEntityImage image = computeImage((ILeaf) ent);
+ final int longitude = layer.getLongitude(ent);
+ final Dimension2D dimImage = image.calculateDimension(ug.getStringBounder());
+ final double diffx = w - dimImage.getWidth();
+ final double diffy = h - dimImage.getHeight();
+ image.drawU(ug.apply(new UTranslate(w * longitude / 2 + diffx / 2, diffy / 2)));
+ }
+ }
+
+ private IEntityImage computeImage(final ILeaf leaf) {
+ final IEntityImage image = CucaDiagramFileMakerSvek2.createEntityImageBlock(leaf, diagram.getSkinParam(),
+ false, diagram, null, null, null);
+ return image;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/hector2/layering/Layer.java b/src/net/sourceforge/plantuml/hector2/layering/Layer.java
new file mode 100644
index 0000000..b4cef4d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector2/layering/Layer.java
@@ -0,0 +1,116 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.hector2.layering;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.hector2.MinMax;
+import net.sourceforge.plantuml.hector2.mpos.MutationLayer;
+import net.sourceforge.plantuml.hector2.mpos.MutationLayerMove;
+
+public class Layer {
+
+ private final int id;
+ private final Map<IEntity, Integer> entities = new HashMap<IEntity, Integer>();
+
+ public Layer(int id) {
+ this.id = id;
+ }
+
+ public Layer duplicate() {
+ final Layer result = new Layer(id);
+ result.entities.putAll(this.entities);
+ return result;
+ }
+
+ public List<MutationLayer> getPossibleMutations() {
+ final List<MutationLayer> result = new ArrayList<MutationLayer>();
+ for (Map.Entry<IEntity, Integer> ent : entities.entrySet()) {
+ final IEntity entity = ent.getKey();
+ final int longitude = ent.getValue();
+ if (isLongitudeFree(longitude + 2)) {
+ result.add(new MutationLayerMove(this, entity, longitude + 2));
+ }
+ if (isLongitudeFree(longitude - 2)) {
+ result.add(new MutationLayerMove(this, entity, longitude - 2));
+ }
+ }
+ return Collections.unmodifiableList(result);
+ }
+
+ private boolean isLongitudeFree(int longitude) {
+ return entities.values().contains(longitude) == false;
+ }
+
+ public void put(IEntity ent, int longitude) {
+ if (entities.containsKey(ent) == false) {
+ throw new IllegalArgumentException();
+ }
+ this.entities.put(ent, longitude);
+ }
+
+ public void add(IEntity ent) {
+ final int pos = entities.size() * 2;
+ this.entities.put(ent, pos);
+ }
+
+ public Collection<IEntity> entities() {
+ return Collections.unmodifiableCollection(entities.keySet());
+ }
+
+ public int getLongitude(IEntity ent) {
+ return entities.get(ent);
+ }
+
+ public MinMax getMinMaxLongitudes() {
+ return MinMax.from(entities.values());
+ }
+
+ @Override
+ public String toString() {
+ return "layer " + id + " " + entities;
+ }
+
+ public final int getId() {
+ return id;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/hector2/layering/LayerFactory.java b/src/net/sourceforge/plantuml/hector2/layering/LayerFactory.java
new file mode 100644
index 0000000..8a1efb4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector2/layering/LayerFactory.java
@@ -0,0 +1,66 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.hector2.layering;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.hector2.continuity.Skeleton;
+
+public class LayerFactory {
+
+ public List<Layer> getLayers(Skeleton skeleton) {
+ skeleton = skeleton.removeCycle();
+ skeleton.computeLayers();
+ final List<Layer> result = new ArrayList<Layer>();
+ for (IEntity ent : skeleton.entities()) {
+ ensureLayer(result, ent.getHectorLayer());
+ }
+ for (IEntity ent : skeleton.entities()) {
+ final int layer = ent.getHectorLayer();
+ result.get(layer).add(ent);
+ }
+ return Collections.unmodifiableList(result);
+ }
+
+ private void ensureLayer(List<Layer> result, int layerToAdd) {
+ while (result.size() <= layerToAdd) {
+ result.add(new Layer(result.size()));
+ }
+
+ }
+}
diff --git a/src/net/sourceforge/plantuml/hector2/mpos/Distribution.java b/src/net/sourceforge/plantuml/hector2/mpos/Distribution.java
new file mode 100644
index 0000000..0dda414
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector2/mpos/Distribution.java
@@ -0,0 +1,113 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.hector2.mpos;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.hector2.MinMax;
+import net.sourceforge.plantuml.hector2.layering.Layer;
+
+public class Distribution {
+
+ private final List<Layer> layers;
+
+ public Distribution(List<Layer> layers) {
+ this.layers = new ArrayList<Layer>(layers);
+ }
+
+ public Distribution mute(MutationLayer mutation) {
+ final Distribution result = new Distribution(this.layers);
+ final int idx = result.layers.indexOf(mutation.getOriginal());
+ if (idx == -1) {
+ throw new IllegalArgumentException();
+ }
+ result.layers.set(idx, mutation.mute());
+ return result;
+ }
+
+ public double cost(Collection<Link> links) {
+ double result = 0;
+ for (Link link : links) {
+ result += getLength(link);
+ }
+ return result;
+ }
+
+ private double getLength(Link link) {
+ final IEntity ent1 = link.getEntity1();
+ final IEntity ent2 = link.getEntity2();
+ final int y1 = ent1.getHectorLayer();
+ final int x1 = layers.get(y1).getLongitude(ent1);
+ final int y2 = ent2.getHectorLayer();
+ final int x2 = layers.get(y2).getLongitude(ent2);
+ final int dx = x2 - x1;
+ final int dy = y2 - y1;
+ return Math.sqrt(dx * dx + dy * dy);
+ }
+
+ public List<MutationLayer> getPossibleMutations() {
+ final List<MutationLayer> result = new ArrayList<MutationLayer>();
+ for (Layer layer : layers) {
+ result.addAll(layer.getPossibleMutations());
+ }
+ return Collections.unmodifiableList(result);
+ }
+
+ public final List<Layer> getLayers() {
+ return Collections.unmodifiableList(layers);
+ }
+
+ public MinMax getMinMaxLongitudes() {
+ MinMax result = null;
+ for (Layer layer : layers) {
+ if (result == null) {
+ result = layer.getMinMaxLongitudes();
+ } else {
+ result = result.add(layer.getMinMaxLongitudes());
+ }
+ }
+ return result;
+ }
+
+ public double getNbLayers() {
+ return layers.size();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/hector2/mpos/MutationLayer.java b/src/net/sourceforge/plantuml/hector2/mpos/MutationLayer.java
new file mode 100644
index 0000000..880edd6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector2/mpos/MutationLayer.java
@@ -0,0 +1,45 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.hector2.mpos;
+
+import net.sourceforge.plantuml.hector2.layering.Layer;
+
+public interface MutationLayer {
+
+ public Layer getOriginal();
+
+ public Layer mute();
+
+}
diff --git a/src/net/sourceforge/plantuml/hector2/mpos/MutationLayerMove.java b/src/net/sourceforge/plantuml/hector2/mpos/MutationLayerMove.java
new file mode 100644
index 0000000..89abc6b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/hector2/mpos/MutationLayerMove.java
@@ -0,0 +1,66 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.hector2.mpos;
+
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.hector2.layering.Layer;
+
+public class MutationLayerMove implements MutationLayer {
+
+ private final Layer layer;
+ private final IEntity entity;
+ private final int newLongitude;
+
+ public MutationLayerMove(Layer layer, IEntity entity, int newLongitude) {
+ this.layer = layer;
+ this.entity = entity;
+ this.newLongitude = newLongitude;
+ }
+
+ public Layer mute() {
+ final Layer result = layer.duplicate();
+ result.put(entity, newLongitude);
+ return result;
+ }
+
+ public Layer getOriginal() {
+ return layer;
+ }
+
+ @Override
+ public String toString() {
+ return "{" + layer.getId() + "} " + entity + " moveto " + newLongitude;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/html/CucaDiagramHtmlMaker.java b/src/net/sourceforge/plantuml/html/CucaDiagramHtmlMaker.java
new file mode 100644
index 0000000..af823a6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/html/CucaDiagramHtmlMaker.java
@@ -0,0 +1,235 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.html;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.cucadiagram.Member;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.StringUtils;
+
+public final class CucaDiagramHtmlMaker {
+
+ private final CucaDiagram diagram;
+ private final File dir;
+
+ public CucaDiagramHtmlMaker(CucaDiagram diagram, File dir) {
+ this.diagram = diagram;
+ this.dir = dir;
+ }
+
+ public List<File> create() throws IOException {
+ dir.mkdirs();
+ if (dir.exists() == false) {
+ throw new IOException("Cannot create " + dir);
+ }
+ final File f = new File(dir, "index.html");
+ final PrintWriter pw = new PrintWriter(f);
+ pw.println("<html>");
+ printAllType(pw, LeafType.ENUM);
+ printAllType(pw, LeafType.INTERFACE);
+ printAllType(pw, LeafType.ANNOTATION);
+ printAllType(pw, LeafType.ABSTRACT_CLASS);
+ printAllType(pw, LeafType.CLASS);
+ htmlClose(pw);
+ return Arrays.asList(dir);
+ }
+
+ private void printAllType(final PrintWriter pw, LeafType type) throws IOException {
+ if (hasSome(type)) {
+ pw.println("<h2>" + type.toHtml() + "</h2>");
+ for (final IEntity ent : diagram.getLeafsvalues()) {
+ if (ent.getEntityType() != type) {
+ continue;
+ }
+ export(ent);
+ pw.println("<li>");
+ pw.println(LinkHtmlPrinter.htmlLink(ent));
+ pw.println("</li>");
+ }
+ // for (Map.Entry<Code, IEntity> ent : new TreeMap<Code, IEntity>(diagram.getLeafs()).entrySet()) {
+ // if (ent.getValue().getEntityType() != type) {
+ // continue;
+ // }
+ // export(ent.getValue());
+ // pw.println("<li>");
+ // pw.println(LinkHtmlPrinter.htmlLink(ent.getValue()));
+ // pw.println("</li>");
+ // }
+ }
+ }
+
+ private boolean hasSome(final LeafType type) {
+ for (IEntity ent : diagram.getLeafsvalues()) {
+ if (ent.getEntityType() == type) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private void export(IEntity entity) throws IOException {
+ final File f = new File(dir, LinkHtmlPrinter.urlOf(entity));
+ final PrintWriter pw = new PrintWriter(f);
+ pw.println("<html>");
+ pw.println("<title>" + StringUtils.unicodeForHtml(entity.getCode().getFullName()) + "</title>");
+ pw.println("<h2>" + entity.getEntityType().toHtml() + "</h2>");
+ for (CharSequence s : entity.getDisplay()) {
+ pw.println(StringUtils.unicodeForHtml(s.toString()));
+ pw.println("<br>");
+ }
+ final Stereotype stereotype = entity.getStereotype();
+ if (stereotype != null) {
+ pw.println("<hr>");
+ pw.println("<h3>Stereotype</h3>");
+ for (String s : stereotype.getLabels(diagram.getSkinParam().useGuillemet())) {
+ pw.println(s);
+ pw.println("<br>");
+ }
+ }
+
+ pw.println("<hr>");
+ if (entity.getFieldsToDisplay().size() == 0) {
+ pw.println("<h2>No fields</h2>");
+ } else {
+ pw.println("<h2>Fields:</h2>");
+ pw.println("<ul>");
+ for (Member m : entity.getFieldsToDisplay()) {
+ pw.println("<li>");
+ pw.println(StringUtils.unicodeForHtml(m.getDisplay(true)));
+ pw.println("</li>");
+ }
+ pw.println("</ul>");
+ }
+
+ pw.println("<hr>");
+ if (entity.getMethodsToDisplay().size() == 0) {
+ pw.println("<h2>No methods</h2>");
+ } else {
+ pw.println("<h2>Methods:</h2>");
+ pw.println("<ul>");
+ for (Member m : entity.getMethodsToDisplay()) {
+ pw.println("<li>");
+ pw.println(StringUtils.unicodeForHtml(m.getDisplay(true)));
+ pw.println("</li>");
+ }
+ pw.println("</ul>");
+ }
+
+ pw.println("<hr>");
+ final Collection<Link> links = getLinksButNotes(entity);
+ if (links.size() == 0) {
+ pw.println("<h2>No links</h2>");
+ } else {
+ pw.println("<h2>Links:</h2>");
+ pw.println("<ul>");
+ for (Link l : links) {
+ pw.println("<li>");
+ new LinkHtmlPrinter(l, entity).printLink(pw);
+ pw.println("</li>");
+ }
+ pw.println("</ul>");
+ }
+
+ final Collection<IEntity> notes = getNotes(entity);
+ if (notes.size() > 0) {
+ pw.println("<hr>");
+ pw.println("<h2>Notes:</h2>");
+ pw.println("<ul>");
+ for (IEntity note : notes) {
+ pw.println("<li>");
+ for (CharSequence s : note.getDisplay()) {
+ pw.println(StringUtils.unicodeForHtml(s.toString()));
+ pw.println("<br>");
+ }
+ pw.println("</li>");
+ }
+ pw.println("</ul>");
+
+ }
+
+ htmlClose(pw);
+ }
+
+ private void htmlClose(final PrintWriter pw) {
+ pw.println("<hr>");
+ pw.println("<a href=index.html>Back to index</a>");
+ pw.println("</html>");
+ pw.close();
+ }
+
+ private Collection<IEntity> getNotes(IEntity ent) {
+ final List<IEntity> result = new ArrayList<IEntity>();
+ for (Link link : diagram.getLinks()) {
+ if (link.contains(ent) == false) {
+ continue;
+ }
+ if (link.getEntity1().getEntityType() == LeafType.NOTE
+ || link.getEntity2().getEntityType() == LeafType.NOTE) {
+ result.add(link.getOther(ent));
+ }
+ }
+ return Collections.unmodifiableList(result);
+ }
+
+ private Collection<Link> getLinksButNotes(IEntity ent) {
+ final List<Link> result = new ArrayList<Link>();
+ for (Link link : diagram.getLinks()) {
+ if (link.contains(ent) == false) {
+ continue;
+ }
+ if (link.getEntity1().getEntityType() == LeafType.NOTE
+ || link.getEntity2().getEntityType() == LeafType.NOTE) {
+ continue;
+ }
+ result.add(link);
+ }
+ return Collections.unmodifiableList(result);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/html/LinkHtmlPrinter.java b/src/net/sourceforge/plantuml/html/LinkHtmlPrinter.java
new file mode 100644
index 0000000..53b3810
--- /dev/null
+++ b/src/net/sourceforge/plantuml/html/LinkHtmlPrinter.java
@@ -0,0 +1,187 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.html;
+
+import java.io.PrintWriter;
+
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.cucadiagram.LinkDecor;
+import net.sourceforge.plantuml.StringUtils;
+
+public final class LinkHtmlPrinter {
+
+ private final Link link;
+ // private final Entity entity;
+ private final boolean chiral;
+
+ public LinkHtmlPrinter(Link link, IEntity entity) {
+ this.link = link;
+ if (link.getEntity1() == entity) {
+ this.chiral = false;
+ } else if (link.getEntity2() == entity) {
+ this.chiral = true;
+ } else {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ void printLink(PrintWriter pw) {
+ final String ent1h;
+ final String ent2h;
+ if (chiral) {
+ ent1h = htmlLink(link.getEntity1());
+ ent2h = "<i>" + StringUtils.unicodeForHtml(link.getEntity2().getCode().getFullName()) + "</i>";
+ } else {
+ ent1h = "<i>" + StringUtils.unicodeForHtml(link.getEntity1().getCode().getFullName()) + "</i>";
+ ent2h = htmlLink(link.getEntity2());
+ }
+ String label = link.getLabel() == null ? null : StringUtils.unicodeForHtml(link.getLabel());
+ String ent1 = ent1h;
+ String ent2 = ent2h;
+ if (link.getQualifier1() != null) {
+ ent1 = ent1 + " (" + link.getQualifier1() + ")";
+ if (label != null) {
+ label = "(" + link.getQualifier1() + " " + ent1h + ") " + label;
+ }
+ }
+ if (link.getQualifier2() != null) {
+ ent2 = ent2 + " (" + link.getQualifier2() + ")";
+ if (label != null) {
+ label = label + " (" + link.getQualifier2() + " " + ent2h + ")";
+ }
+ }
+ if (chiral) {
+ pw.println(getHtmlChiral(ent1, ent2));
+ } else {
+ pw.println(getHtml(ent1, ent2));
+ }
+ if (label != null) {
+ pw.println("&nbsp;:&nbsp;");
+ pw.println(label);
+ }
+ }
+
+ private String getHtml(String ent1, String ent2) {
+ final LinkDecor decor1 = link.getType().getDecor1();
+ final LinkDecor decor2 = link.getType().getDecor2();
+
+ if (decor1 == LinkDecor.NONE && decor2 == LinkDecor.NONE) {
+ return ent1 + " is linked to " + ent2;
+ }
+ if (decor1 == LinkDecor.NONE && decor2 == LinkDecor.EXTENDS) {
+ return ent1 + " is extended by " + ent2;
+ }
+ if (decor1 == LinkDecor.EXTENDS && decor2 == LinkDecor.NONE) {
+ return ent1 + " extends " + ent2;
+ }
+ if (decor2 == LinkDecor.AGREGATION) {
+ return ent1 + " is aggregated by " + ent2;
+ }
+ if (decor1 == LinkDecor.AGREGATION) {
+ return ent1 + " aggregates " + ent2;
+ }
+ if (decor2 == LinkDecor.COMPOSITION) {
+ return ent1 + " is composed by " + ent2;
+ }
+ if (decor1 == LinkDecor.COMPOSITION) {
+ return ent1 + " composes " + ent2;
+ }
+ if (decor1 == LinkDecor.NONE && decor2 == LinkDecor.ARROW) {
+ return ent1 + " is navigable from " + ent2;
+ }
+ if (decor1 == LinkDecor.ARROW && decor2 == LinkDecor.NONE) {
+ return ent1 + " navigates to " + ent2;
+ }
+ return ent1 + " " + decor1 + "-" + decor2 + " " + ent2;
+
+ }
+
+ private String getHtmlChiral(String ent1, String ent2) {
+ final LinkDecor decor1 = link.getType().getDecor1();
+ final LinkDecor decor2 = link.getType().getDecor2();
+
+ if (decor1 == LinkDecor.NONE && decor2 == LinkDecor.NONE) {
+ return ent2 + " is linked to " + ent1;
+ }
+ if (decor1 == LinkDecor.NONE && decor2 == LinkDecor.EXTENDS) {
+ return ent2 + " extends " + ent1;
+ }
+ if (decor1 == LinkDecor.EXTENDS && decor2 == LinkDecor.NONE) {
+ return ent2 + " is extended by " + ent1;
+ }
+ if (decor2 == LinkDecor.AGREGATION) {
+ return ent2 + " aggregates " + ent1;
+ }
+ if (decor1 == LinkDecor.AGREGATION) {
+ return ent2 + " is aggregated by " + ent1;
+ }
+ if (decor2 == LinkDecor.COMPOSITION) {
+ return ent2 + " composes " + ent1;
+ }
+ if (decor1 == LinkDecor.COMPOSITION) {
+ return ent2 + " is composed by " + ent1;
+ }
+ if (decor1 == LinkDecor.NONE && decor2 == LinkDecor.ARROW) {
+ return ent2 + " navigates to " + ent1;
+ }
+ if (decor1 == LinkDecor.ARROW && decor2 == LinkDecor.NONE) {
+ return ent2 + " is navigable from " + ent1;
+ }
+ return ent1 + " " + decor1 + "-" + decor2 + " " + ent2;
+ }
+
+ static String htmlLink(IEntity ent) {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("<a href=\"");
+ sb.append(urlOf(ent));
+ sb.append("\">");
+ sb.append(StringUtils.unicodeForHtml(ent.getCode().getFullName()));
+ sb.append("</a>");
+ return sb.toString();
+ }
+
+ static String urlOf(IEntity ent) {
+ if (ent.getEntityType() == LeafType.NOTE) {
+ throw new IllegalArgumentException();
+ }
+ if (ent.getCode().getFullName().matches("[-\\w_ .]+")) {
+ return StringUtils.unicodeForHtml(ent.getCode().getFullName()) + ".html";
+ }
+ return StringUtils.unicodeForHtml(ent.getUid()) + ".html";
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/jungle/CommandAddLevel.java b/src/net/sourceforge/plantuml/jungle/CommandAddLevel.java
new file mode 100644
index 0000000..abdcbec
--- /dev/null
+++ b/src/net/sourceforge/plantuml/jungle/CommandAddLevel.java
@@ -0,0 +1,64 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.jungle;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+
+public class CommandAddLevel extends SingleLineCommand2<PSystemTree> {
+
+ public CommandAddLevel() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("LEVEL", "(=+)"), //
+ new RegexLeaf("[%s]+"), //
+ new RegexLeaf("LABEL", "(.+)"), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(PSystemTree diagram, RegexResult arg) {
+ final String level = arg.get("LEVEL", 0);
+ final String label = arg.get("LABEL", 0);
+ return diagram.addParagraph(level.length(), label);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/jungle/CommandEmpty.java b/src/net/sourceforge/plantuml/jungle/CommandEmpty.java
new file mode 100644
index 0000000..de32b96
--- /dev/null
+++ b/src/net/sourceforge/plantuml/jungle/CommandEmpty.java
@@ -0,0 +1,60 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.jungle;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+
+public class CommandEmpty extends SingleLineCommand2<PSystemTree> {
+
+ public CommandEmpty() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(PSystemTree diagram, RegexResult arg) {
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/jungle/GNode.java b/src/net/sourceforge/plantuml/jungle/GNode.java
new file mode 100644
index 0000000..766a2f6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/jungle/GNode.java
@@ -0,0 +1,66 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.jungle;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import net.sourceforge.plantuml.cucadiagram.Display;
+
+public class GNode {
+
+ private final Display display;
+ private final List<GNode> children = new ArrayList<GNode>();
+
+ public GNode(Display display) {
+ this.display = display;
+ }
+
+ public Display getDisplay() {
+ return display;
+ }
+
+ public List<GNode> getChildren() {
+ return Collections.unmodifiableList(children);
+ }
+
+ public GNode addChild(Display display) {
+ final GNode child = new GNode(display);
+ children.add(child);
+ return child;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/jungle/GNodeUtils.java b/src/net/sourceforge/plantuml/jungle/GNodeUtils.java
new file mode 100644
index 0000000..f908c95
--- /dev/null
+++ b/src/net/sourceforge/plantuml/jungle/GNodeUtils.java
@@ -0,0 +1,55 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.jungle;
+
+public class GNodeUtils {
+
+// public static GNode getIndirectChild(GNode root, String id) {
+// if (root.getId().equals(id)) {
+// return root;
+// }
+// for (GNode n : root.getChildren()) {
+// if (n.getId().equals(id)) {
+// return n;
+// }
+// final GNode result = getIndirectChild(n, id);
+// if (result != null) {
+// return result;
+// }
+// }
+// return null;
+// }
+
+}
diff --git a/src/net/sourceforge/plantuml/jungle/GTile.java b/src/net/sourceforge/plantuml/jungle/GTile.java
new file mode 100644
index 0000000..e446eae
--- /dev/null
+++ b/src/net/sourceforge/plantuml/jungle/GTile.java
@@ -0,0 +1,43 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.jungle;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+
+public interface GTile extends TextBlock {
+
+ public GTileGeometry calculateDimension(StringBounder stringBounder);
+}
diff --git a/src/net/sourceforge/plantuml/jungle/GTileGeometry.java b/src/net/sourceforge/plantuml/jungle/GTileGeometry.java
new file mode 100644
index 0000000..094c957
--- /dev/null
+++ b/src/net/sourceforge/plantuml/jungle/GTileGeometry.java
@@ -0,0 +1,75 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.jungle;
+
+import java.awt.geom.Dimension2D;
+import java.util.Collections;
+import java.util.List;
+
+public class GTileGeometry extends Dimension2D {
+
+ private final double width;
+ private final double height;
+ private final List<Double> westPositions;
+
+ public GTileGeometry(Dimension2D dim, List<Double> westPositions) {
+ this(dim.getWidth(), dim.getHeight(), westPositions);
+ }
+
+ @Override
+ public void setSize(double width, double height) {
+ throw new UnsupportedOperationException();
+ }
+
+ public GTileGeometry(double width, double height, List<Double> westPositions) {
+ this.width = width;
+ this.height = height;
+ this.westPositions = westPositions;
+ }
+
+ @Override
+ public final double getWidth() {
+ return width;
+ }
+
+ @Override
+ public final double getHeight() {
+ return height;
+ }
+
+ public List<Double> getWestPositions() {
+ return Collections.unmodifiableList(westPositions);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/jungle/GTileLeftRight.java b/src/net/sourceforge/plantuml/jungle/GTileLeftRight.java
new file mode 100644
index 0000000..fbfff1c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/jungle/GTileLeftRight.java
@@ -0,0 +1,102 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.jungle;
+
+import java.awt.geom.Dimension2D;
+import java.util.Arrays;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class GTileLeftRight implements GTile {
+
+ private final GTile left;
+ private final GTile right;
+ private final double space;
+ private final double step = 5;
+
+ public GTileLeftRight(GTile left, GTile right, double space) {
+ this.left = left;
+ this.right = right;
+ this.space = space;
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final GTileGeometry dimLeft = left.calculateDimension(stringBounder);
+ final GTileGeometry dimRight = right.calculateDimension(stringBounder);
+ final Dimension2D dimTotal = calculateDimension(stringBounder);
+ final double deltaH1 = dimTotal.getHeight() - dimLeft.getHeight();
+ final double deltaH2 = dimTotal.getHeight() - dimRight.getHeight();
+ left.drawU(ug.apply(new UTranslate(0, deltaH1 / 2)));
+ final double dx2 = dimLeft.getWidth() + space;
+ right.drawU(ug.apply(new UTranslate(dx2, deltaH2 / 2)));
+
+ ug = ug.apply(new UChangeColor(HtmlColorUtils.BLACK));
+ final double step = dimLeft.getHeight() / (dimRight.getWestPositions().size() + 1);
+ double ystart = step + deltaH1 / 2;
+ for (Double w2 : dimRight.getWestPositions()) {
+ line(ug, dimLeft.getWidth(), ystart, dx2, w2 + deltaH2 / 2);
+ ystart += step;
+ }
+
+ }
+
+ private void line(UGraphic ug, double x1, double y1, double x2, double y2) {
+ // final ULine line = new ULine(x2 - x1, y2 - y1);
+ // ug.apply(new UTranslate(x1, y1)).draw(line);
+ final UPath path = new UPath();
+ path.moveTo(x1, y1);
+ path.lineTo(x1 + step, y1);
+ path.lineTo(x2 - step, y2);
+ path.lineTo(x2, y2);
+ ug.apply(new UTranslate(0, 0)).draw(path);
+ }
+
+ public GTileGeometry calculateDimension(StringBounder stringBounder) {
+ final GTileGeometry dimLeft = left.calculateDimension(stringBounder);
+ final Dimension2D dimRight = right.calculateDimension(stringBounder);
+ final Dimension2D dimTotal = new Dimension2DDouble(dimLeft.getWidth() + space + dimRight.getHeight(), Math.max(
+ dimLeft.getHeight(), dimRight.getHeight()));
+ final double deltaH1 = dimTotal.getHeight() - dimLeft.getHeight();
+ final double west = dimLeft.getWestPositions().get(0) + deltaH1 / 2;
+ return new GTileGeometry(dimTotal, Arrays.asList(west));
+ }
+}
diff --git a/src/net/sourceforge/plantuml/jungle/GTileNode.java b/src/net/sourceforge/plantuml/jungle/GTileNode.java
new file mode 100644
index 0000000..0a01b9b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/jungle/GTileNode.java
@@ -0,0 +1,94 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.jungle;
+
+import java.awt.geom.Dimension2D;
+import java.util.Arrays;
+
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.SkinParam;
+import net.sourceforge.plantuml.UmlDiagramType;
+import net.sourceforge.plantuml.creole.CreoleParser;
+import net.sourceforge.plantuml.creole.Sheet;
+import net.sourceforge.plantuml.creole.SheetBlock1;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.SymbolContext;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.graphic.USymbol;
+import net.sourceforge.plantuml.skin.rose.Rose;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class GTileNode implements GTile {
+
+ private final TextBlock tb;
+
+ public GTileNode(GNode node) {
+ final Display display = node.getDisplay();
+ final SheetBlock1 sheetBlock1 = getTextBlock(display);
+
+ final SymbolContext symbolContext = new SymbolContext(HtmlColorUtils.MY_YELLOW, HtmlColorUtils.BLACK);
+ tb = USymbol.RECTANGLE.asSmall(sheetBlock1, TextBlockUtils.empty(0, 0), symbolContext);
+ }
+
+ public static SheetBlock1 getTextBlock(final Display display) {
+ final Rose rose = new Rose();
+ final SkinParam skinParam = new SkinParam();
+ final HtmlColor fontColor = rose.getFontColor(skinParam, FontParam.NOTE);
+ final UFont fontNote = skinParam.getFont(FontParam.NOTE, null, false);
+
+ final FontConfiguration fc = new FontConfiguration(fontNote, fontColor, skinParam.getHyperlinkColor(), skinParam.useUnderlineForHyperlink());
+
+ final Sheet sheet9 = new CreoleParser(fc, HorizontalAlignment.LEFT, skinParam, false).createSheet(display);
+ final SheetBlock1 sheetBlock1 = new SheetBlock1(sheet9, 0, 0);
+ return sheetBlock1;
+ }
+
+ public void drawU(UGraphic ug) {
+ tb.drawU(ug);
+ }
+
+ public GTileGeometry calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dim = tb.calculateDimension(stringBounder);
+ return new GTileGeometry(dim, Arrays.asList(dim.getHeight() / 2));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/jungle/GTileOneLevelFactory.java b/src/net/sourceforge/plantuml/jungle/GTileOneLevelFactory.java
new file mode 100644
index 0000000..a1bb40d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/jungle/GTileOneLevelFactory.java
@@ -0,0 +1,56 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.jungle;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class GTileOneLevelFactory {
+
+ public GTile createGTile(GNode root) {
+ final GTileNode left = new GTileNode(root);
+ if (root.getChildren().size() == 0) {
+ return left;
+ }
+ final List<GTile> all = new ArrayList<GTile>();
+ for (GNode n : root.getChildren()) {
+ all.add(createGTile(n));
+ }
+ final GTileStack right = new GTileStack(all, 20);
+ return new GTileLeftRight(left, right, 30);
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/jungle/GTileStack.java b/src/net/sourceforge/plantuml/jungle/GTileStack.java
new file mode 100644
index 0000000..4286a49
--- /dev/null
+++ b/src/net/sourceforge/plantuml/jungle/GTileStack.java
@@ -0,0 +1,82 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.jungle;
+
+import java.awt.geom.Dimension2D;
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class GTileStack implements GTile {
+
+ private final List<GTile> tiles;
+ private final double space;
+
+ public GTileStack(List<GTile> tiles, double space) {
+ this.tiles = tiles;
+ this.space = space;
+ if (tiles.size() == 0) {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ public void drawU(UGraphic ug) {
+ for (GTile tile : tiles) {
+ tile.drawU(ug);
+ final Dimension2D dim = tile.calculateDimension(ug.getStringBounder());
+ ug = ug.apply(new UTranslate(0, dim.getHeight() + space));
+ }
+ }
+
+ public GTileGeometry calculateDimension(StringBounder stringBounder) {
+ double width = 0;
+ double height = 0;
+ double delta = 0;
+ final List<Double> wests = new ArrayList<Double>();
+ for (GTile tile : tiles) {
+ final GTileGeometry dim = tile.calculateDimension(stringBounder);
+ wests.add(delta + dim.getWestPositions().get(0));
+ height += dim.getHeight();
+ delta += dim.getHeight() + space;
+ width = Math.max(width, dim.getWidth());
+ }
+ height += (tiles.size() - 1) * space;
+ return new GTileGeometry(width, height, wests);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/jungle/Needle.java b/src/net/sourceforge/plantuml/jungle/Needle.java
new file mode 100644
index 0000000..be16c36
--- /dev/null
+++ b/src/net/sourceforge/plantuml/jungle/Needle.java
@@ -0,0 +1,114 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.jungle;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class Needle implements UDrawable {
+
+ private final double length;
+ private final Display display;
+ private final double degreePosition;
+ private final double degreeOperture;
+
+ private Needle(Display display, double length, double degreePosition, double degreeOperture) {
+ this.display = display;
+ this.degreePosition = degreePosition;
+ this.degreeOperture = degreeOperture;
+ this.length = length;
+ }
+
+ public void drawU(UGraphic ug) {
+ GTileNode.getTextBlock(display);
+ ug.draw(getLine());
+
+ ug = ug.apply(getTranslate(length));
+ GTileNode.getTextBlock(display).drawU(ug);
+ }
+
+ private ULine getLine() {
+ final UTranslate translate = getTranslate(length);
+ return new ULine(translate.getDx(), translate.getDy());
+ }
+
+ public UTranslate getTranslate(double dist) {
+ final double angle = degreePosition * Math.PI / 180.0;
+ final double dx = dist * Math.cos(angle);
+ final double dy = dist * Math.sin(angle);
+ return new UTranslate(dx, dy);
+ }
+
+ public UDrawable addChildren(final List<GNode> children) {
+ return new UDrawable() {
+ public void drawU(UGraphic ug) {
+ Needle.this.drawU(ug);
+ if (children.size() == 0) {
+ return;
+ }
+ ug = ug.apply(getTranslate(length / 2));
+ final UDrawable child1 = getNeedle(children.get(0), length / 2, degreePosition + degreeOperture,
+ degreeOperture / 2);
+ child1.drawU(ug);
+ if (children.size() == 1) {
+ return;
+ }
+ final UDrawable child2 = getNeedle(children.get(1), length / 2, degreePosition - degreeOperture,
+ degreeOperture / 2);
+ child2.drawU(ug);
+
+ }
+ };
+ }
+
+ public static UDrawable getNeedle(GNode root, double length, double degree, double degreeOperture) {
+ final Needle needle0 = new Needle(root.getDisplay(), length, degree, degreeOperture);
+ final UDrawable n1 = needle0.addChildren(root.getChildren());
+ return new UDrawable() {
+ public void drawU(UGraphic ug) {
+ ug = ug.apply(new UChangeColor(HtmlColorUtils.BLACK));
+ n1.drawU(ug);
+ }
+ };
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/jungle/PSystemTree.java b/src/net/sourceforge/plantuml/jungle/PSystemTree.java
new file mode 100644
index 0000000..f02574a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/jungle/PSystemTree.java
@@ -0,0 +1,106 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.jungle;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.core.DiagramDescription;
+import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.graphic.UDrawableUtils;
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+import net.sourceforge.plantuml.ugraphic.ImageBuilder;
+import net.sourceforge.plantuml.ugraphic.LimitFinder;
+
+public class PSystemTree extends AbstractPSystem {
+
+ private GNode root;
+ private List<GNode> stack = new ArrayList<GNode>();
+ private final Rendering rendering = Rendering.NEEDLE;
+
+ public DiagramDescription getDescription() {
+ return new DiagramDescriptionImpl("(Tree)", getClass());
+ }
+
+ public ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormat) throws IOException {
+ final ImageBuilder builder = new ImageBuilder(new ColorMapperIdentity(), 1.0, HtmlColorUtils.WHITE, null, null,
+ 5, 5, null, false);
+ if (rendering == Rendering.NEEDLE) {
+ final UDrawable tmp = Needle.getNeedle(root, 200, 0, 60);
+ final LimitFinder limitFinder = new LimitFinder(TextBlockUtils.getDummyStringBounder(), true);
+ tmp.drawU(limitFinder);
+ final double minY = limitFinder.getMinY();
+ builder.addUDrawable(UDrawableUtils.move(tmp, 0, -minY));
+ } else {
+ builder.addUDrawable(new GTileOneLevelFactory().createGTile(root));
+ }
+ return builder.writeImageTOBEMOVED(fileFormat.getFileFormat(), os);
+ }
+
+ public CommandExecutionResult addParagraph(int level, String label) {
+
+ if (level == 1 && root == null) {
+ root = new GNode(Display.create(label));
+ stack.add(root);
+ return CommandExecutionResult.ok();
+ } else if (level == 1 && root != null) {
+ return CommandExecutionResult.error("Not allowed 1");
+ }
+
+ final GNode parent = stack.get(level - 2);
+ final GNode newNode = parent.addChild(Display.create(label));
+
+ if (level > stack.size() + 1) {
+ return CommandExecutionResult.error("Not allowed 2");
+ } else if (level - 1 == stack.size()) {
+ stack.add(newNode);
+ } else {
+ stack.set(level - 1, newNode);
+ }
+
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/jungle/PSystemTreeFactory.java b/src/net/sourceforge/plantuml/jungle/PSystemTreeFactory.java
new file mode 100644
index 0000000..efcdeb9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/jungle/PSystemTreeFactory.java
@@ -0,0 +1,63 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.jungle;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.command.Command;
+import net.sourceforge.plantuml.command.UmlDiagramFactory;
+import net.sourceforge.plantuml.core.DiagramType;
+
+public class PSystemTreeFactory extends UmlDiagramFactory {
+
+ public PSystemTreeFactory(DiagramType type) {
+ super(type);
+ }
+
+ @Override
+ protected List<Command> createCommands() {
+ final List<Command> cmds = new ArrayList<Command>();
+ cmds.add(new CommandEmpty());
+ cmds.add(new CommandAddLevel());
+ return cmds;
+ }
+
+ @Override
+ public PSystemTree createEmptyDiagram() {
+ return new PSystemTree();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/jungle/Rendering.java b/src/net/sourceforge/plantuml/jungle/Rendering.java
new file mode 100644
index 0000000..3158829
--- /dev/null
+++ b/src/net/sourceforge/plantuml/jungle/Rendering.java
@@ -0,0 +1,41 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.jungle;
+
+public enum Rendering {
+
+ BASIC, NEEDLE
+
+}
diff --git a/src/net/sourceforge/plantuml/mda/MDADiagramImpl.java b/src/net/sourceforge/plantuml/mda/MDADiagramImpl.java
new file mode 100644
index 0000000..51f3ed1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/mda/MDADiagramImpl.java
@@ -0,0 +1,84 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.mda;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import net.sourceforge.plantuml.BlockUml;
+import net.sourceforge.plantuml.SourceStringReader;
+import net.sourceforge.plantuml.api.mda.option2.MDADiagram;
+import net.sourceforge.plantuml.api.mda.option2.MDAPackage;
+import net.sourceforge.plantuml.classdiagram.ClassDiagram;
+import net.sourceforge.plantuml.core.Diagram;
+import net.sourceforge.plantuml.cucadiagram.IGroup;
+import net.sourceforge.plantuml.cucadiagram.entity.EntityFactory;
+
+public class MDADiagramImpl implements MDADiagram {
+
+ public static MDADiagram create(String uml) {
+ List<BlockUml> blocks = new SourceStringReader(uml).getBlocks();
+ if (blocks.size() == 0) {
+ uml = "@startuml\n" + uml + "\n@enduml";
+ blocks = new SourceStringReader(uml).getBlocks();
+ if (blocks.size() == 0) {
+ return null;
+ }
+ }
+ final BlockUml block = blocks.get(0);
+ final Diagram diagram = block.getDiagram();
+ if (diagram instanceof ClassDiagram) {
+ return new MDADiagramImpl((ClassDiagram) diagram);
+ }
+ return null;
+ }
+
+ private final Collection<MDAPackage> packages = new ArrayList<MDAPackage>();
+
+ private MDADiagramImpl(ClassDiagram classDiagram) {
+ final EntityFactory entityFactory = classDiagram.getEntityFactory();
+ packages.add(new MDAPackageImpl(entityFactory.getRootGroup()));
+ for (IGroup group : entityFactory.getGroups().values()) {
+ packages.add(new MDAPackageImpl(group));
+ }
+ }
+
+ public Collection<MDAPackage> getPackages() {
+ return Collections.unmodifiableCollection(packages);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/mda/MDAEntityImpl.java b/src/net/sourceforge/plantuml/mda/MDAEntityImpl.java
new file mode 100644
index 0000000..07c7324
--- /dev/null
+++ b/src/net/sourceforge/plantuml/mda/MDAEntityImpl.java
@@ -0,0 +1,52 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.mda;
+
+import net.sourceforge.plantuml.api.mda.option2.MDAEntity;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+
+public class MDAEntityImpl implements MDAEntity {
+
+ private final ILeaf leaf;
+
+ public MDAEntityImpl(ILeaf leaf) {
+ this.leaf = leaf;
+ }
+
+ public String getName() {
+ return leaf.getCode().getFullName();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/mda/MDAPackageImpl.java b/src/net/sourceforge/plantuml/mda/MDAPackageImpl.java
new file mode 100644
index 0000000..2aa11fa
--- /dev/null
+++ b/src/net/sourceforge/plantuml/mda/MDAPackageImpl.java
@@ -0,0 +1,70 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.mda;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+
+import net.sourceforge.plantuml.api.mda.option2.MDAEntity;
+import net.sourceforge.plantuml.api.mda.option2.MDAPackage;
+import net.sourceforge.plantuml.cucadiagram.GroupRoot;
+import net.sourceforge.plantuml.cucadiagram.IGroup;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+
+public class MDAPackageImpl implements MDAPackage {
+
+ private final Collection<MDAEntity> entities = new ArrayList<MDAEntity>();
+ private final IGroup group;
+
+ public MDAPackageImpl(IGroup group) {
+ this.group = group;
+ for (ILeaf leaf : group.getLeafsDirect()) {
+ entities.add(new MDAEntityImpl(leaf));
+ }
+ }
+
+ public Collection<MDAEntity> getEntities() {
+ return Collections.unmodifiableCollection(entities);
+ }
+
+ public String getName() {
+ if (group instanceof GroupRoot) {
+ return "";
+ }
+ return group.getCode().getFullName();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/mjpeg/MJPEGGenerator.java b/src/net/sourceforge/plantuml/mjpeg/MJPEGGenerator.java
new file mode 100644
index 0000000..e61ecf2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/mjpeg/MJPEGGenerator.java
@@ -0,0 +1,609 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+/*
+ * MJPEGGenerator.java
+ *
+ * Created on April 17, 2006, 11:48 PM
+ *
+ * To change this template, choose Tools | Options and locate the template under
+ * the Source Creation and Management node. Right-click the template and choose
+ * Open. You can then make changes to the template in the Source Editor.
+ */
+
+package net.sourceforge.plantuml.mjpeg;
+
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.nio.channels.FileChannel;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import javax.imageio.ImageIO;
+import javax.swing.ImageIcon;
+
+import net.sourceforge.plantuml.StringUtils;
+
+/**
+ *
+ * @author monceaux
+ */
+public class MJPEGGenerator
+{
+ /*
+ * Info needed for MJPEG AVI
+ *
+ * - size of file minus "RIFF & 4 byte file size"
+ *
+ */
+
+ int width = 0;
+ int height = 0;
+ double framerate = 0;
+ int numFrames = 0;
+ File aviFile = null;
+ FileOutputStream aviOutput = null;
+ FileChannel aviChannel = null;
+
+ long riffOffset = 0;
+ long aviMovieOffset = 0;
+
+ AVIIndexList indexlist = null;
+
+ /** Creates a new instance of MJPEGGenerator */
+ public MJPEGGenerator(File aviFile, int width, int height, double framerate, int numFrames) throws IOException
+ {
+ this.aviFile = aviFile;
+ this.width = width;
+ this.height = height;
+ this.framerate = framerate;
+ this.numFrames = numFrames;
+ aviOutput = new FileOutputStream(aviFile);
+ aviChannel = aviOutput.getChannel();
+
+ RIFFHeader rh = new RIFFHeader();
+ aviOutput.write(rh.toBytes());
+ aviOutput.write(new AVIMainHeader().toBytes());
+ aviOutput.write(new AVIStreamList().toBytes());
+ aviOutput.write(new AVIStreamHeader().toBytes());
+ aviOutput.write(new AVIStreamFormat().toBytes());
+ aviOutput.write(new AVIJunk().toBytes());
+ aviMovieOffset = aviChannel.position();
+ aviOutput.write(new AVIMovieList().toBytes());
+ indexlist = new AVIIndexList();
+ }
+
+ public void addImage(Image image) throws IOException
+ {
+ byte[] fcc = new byte[]{'0','0','d','b'};
+ byte[] imagedata = writeImageToBytes(image);
+ int useLength = imagedata.length;
+ long position = aviChannel.position();
+ int extra = (useLength+(int)position) % 4;
+ if(extra > 0)
+ useLength = useLength + extra;
+
+ indexlist.addAVIIndex((int)position,useLength);
+
+ aviOutput.write(fcc);
+ aviOutput.write(intBytes(swapInt(useLength)));
+ aviOutput.write(imagedata);
+ if(extra > 0)
+ {
+ for(int i = 0; i < extra; i++)
+ aviOutput.write(0);
+ }
+ imagedata = null;
+ }
+
+ public void finishAVI() throws IOException
+ {
+ byte[] indexlistBytes = indexlist.toBytes();
+ aviOutput.write(indexlistBytes);
+ aviOutput.close();
+ long size = aviFile.length();
+ RandomAccessFile raf = new RandomAccessFile(aviFile, "rw");
+ raf.seek(4);
+ raf.write(intBytes(swapInt((int)size - 8)));
+ raf.seek(aviMovieOffset+4);
+ raf.write(intBytes(swapInt((int)(size - 8 - aviMovieOffset - indexlistBytes.length))));
+ raf.close();
+ }
+
+// public void writeAVI(File file) throws Exception
+// {
+// OutputStream os = new FileOutputStream(file);
+//
+// // RIFFHeader
+// // AVIMainHeader
+// // AVIStreamList
+// // AVIStreamHeader
+// // AVIStreamFormat
+// // write 00db and image bytes...
+// }
+
+ public static int swapInt(int v)
+ {
+ return (v >>> 24) | (v << 24) |
+ ((v << 8) & 0x00FF0000) | ((v >> 8) & 0x0000FF00);
+ }
+
+ public static short swapShort(short v)
+ {
+ return (short)((v >>> 8) | (v << 8));
+ }
+
+ public static byte[] intBytes(int i)
+ {
+ byte[] b = new byte[4];
+ b[0] = (byte)(i >>> 24);
+ b[1] = (byte)((i >>> 16) & 0x000000FF);
+ b[2] = (byte)((i >>> 8) & 0x000000FF);
+ b[3] = (byte)(i & 0x000000FF);
+
+ return b;
+ }
+
+ public static byte[] shortBytes(short i)
+ {
+ byte[] b = new byte[2];
+ b[0] = (byte)(i >>> 8);
+ b[1] = (byte)(i & 0x000000FF);
+
+ return b;
+ }
+
+ private class RIFFHeader
+ {
+ public byte[] fcc = new byte[]{'R','I','F','F'};
+ public int fileSize = 0;
+ public byte[] fcc2 = new byte[]{'A','V','I',' '};
+ public byte[] fcc3 = new byte[]{'L','I','S','T'};
+ public int listSize = 200;
+ public byte[] fcc4 = new byte[]{'h','d','r','l'};
+
+ public RIFFHeader()
+ {
+
+ }
+
+ public byte[] toBytes() throws IOException
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ baos.write(fcc);
+ baos.write(intBytes(swapInt(fileSize)));
+ baos.write(fcc2);
+ baos.write(fcc3);
+ baos.write(intBytes(swapInt(listSize)));
+ baos.write(fcc4);
+ baos.close();
+
+ return baos.toByteArray();
+ }
+ }
+
+ private class AVIMainHeader
+ {
+ /*
+ *
+ FOURCC fcc;
+ DWORD cb;
+ DWORD dwMicroSecPerFrame;
+ DWORD dwMaxBytesPerSec;
+ DWORD dwPaddingGranularity;
+ DWORD dwFlags;
+ DWORD dwTotalFrames;
+ DWORD dwInitialFrames;
+ DWORD dwStreams;
+ DWORD dwSuggestedBufferSize;
+ DWORD dwWidth;
+ DWORD dwHeight;
+ DWORD dwReserved[4];
+ */
+
+ public byte[] fcc = new byte[]{'a','v','i','h'};
+ public int cb = 56;
+ public int dwMicroSecPerFrame = 0; // (1 / frames per sec) * 1,000,000
+ public int dwMaxBytesPerSec = 10000000;
+ public int dwPaddingGranularity = 0;
+ public int dwFlags = 65552;
+ public int dwTotalFrames = 0; // replace with correct value
+ public int dwInitialFrames = 0;
+ public int dwStreams = 1;
+ public int dwSuggestedBufferSize = 0;
+ public int dwWidth = 0; // replace with correct value
+ public int dwHeight = 0; // replace with correct value
+ public int[] dwReserved = new int[4];
+
+ public AVIMainHeader()
+ {
+ dwMicroSecPerFrame = (int)((1.0/framerate)*1000000.0);
+ dwWidth = width;
+ dwHeight = height;
+ dwTotalFrames = numFrames;
+ }
+
+ public byte[] toBytes() throws IOException
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ baos.write(fcc);
+ baos.write(intBytes(swapInt(cb)));
+ baos.write(intBytes(swapInt(dwMicroSecPerFrame)));
+ baos.write(intBytes(swapInt(dwMaxBytesPerSec)));
+ baos.write(intBytes(swapInt(dwPaddingGranularity)));
+ baos.write(intBytes(swapInt(dwFlags)));
+ baos.write(intBytes(swapInt(dwTotalFrames)));
+ baos.write(intBytes(swapInt(dwInitialFrames)));
+ baos.write(intBytes(swapInt(dwStreams)));
+ baos.write(intBytes(swapInt(dwSuggestedBufferSize)));
+ baos.write(intBytes(swapInt(dwWidth)));
+ baos.write(intBytes(swapInt(dwHeight)));
+ baos.write(intBytes(swapInt(dwReserved[0])));
+ baos.write(intBytes(swapInt(dwReserved[1])));
+ baos.write(intBytes(swapInt(dwReserved[2])));
+ baos.write(intBytes(swapInt(dwReserved[3])));
+ baos.close();
+
+ return baos.toByteArray();
+ }
+ }
+
+ private class AVIStreamList
+ {
+ public byte[] fcc = new byte[]{'L','I','S','T'};
+ public int size = 124;
+ public byte[] fcc2 = new byte[]{'s','t','r','l'};
+
+ public AVIStreamList()
+ {
+
+ }
+
+ public byte[] toBytes() throws IOException
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ baos.write(fcc);
+ baos.write(intBytes(swapInt(size)));
+ baos.write(fcc2);
+ baos.close();
+
+ return baos.toByteArray();
+ }
+ }
+
+ private class AVIStreamHeader
+ {
+ /*
+ FOURCC fcc;
+ DWORD cb;
+ FOURCC fccType;
+ FOURCC fccHandler;
+ DWORD dwFlags;
+ WORD wPriority;
+ WORD wLanguage;
+ DWORD dwInitialFrames;
+ DWORD dwScale;
+ DWORD dwRate;
+ DWORD dwStart;
+ DWORD dwLength;
+ DWORD dwSuggestedBufferSize;
+ DWORD dwQuality;
+ DWORD dwSampleSize;
+ struct {
+ short int left;
+ short int top;
+ short int right;
+ short int bottom;
+ } rcFrame;
+ */
+
+ public byte[] fcc = new byte[]{'s','t','r','h'};
+ public int cb = 64;
+ public byte[] fccType = new byte[]{'v','i','d','s'};
+ public byte[] fccHandler = new byte[]{'M','J','P','G'};
+ public int dwFlags = 0;
+ public short wPriority = 0;
+ public short wLanguage = 0;
+ public int dwInitialFrames = 0;
+ public int dwScale = 0; // microseconds per frame
+ public int dwRate = 1000000; // dwRate / dwScale = frame rate
+ public int dwStart = 0;
+ public int dwLength = 0; // num frames
+ public int dwSuggestedBufferSize = 0;
+ public int dwQuality = -1;
+ public int dwSampleSize = 0;
+ public int left = 0;
+ public int top = 0;
+ public int right = 0;
+ public int bottom = 0;
+
+ public AVIStreamHeader()
+ {
+ dwScale = (int)((1.0/framerate)*1000000.0);
+ dwLength = numFrames;
+ }
+
+ public byte[] toBytes() throws IOException
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ baos.write(fcc);
+ baos.write(intBytes(swapInt(cb)));
+ baos.write(fccType);
+ baos.write(fccHandler);
+ baos.write(intBytes(swapInt(dwFlags)));
+ baos.write(shortBytes(swapShort(wPriority)));
+ baos.write(shortBytes(swapShort(wLanguage)));
+ baos.write(intBytes(swapInt(dwInitialFrames)));
+ baos.write(intBytes(swapInt(dwScale)));
+ baos.write(intBytes(swapInt(dwRate)));
+ baos.write(intBytes(swapInt(dwStart)));
+ baos.write(intBytes(swapInt(dwLength)));
+ baos.write(intBytes(swapInt(dwSuggestedBufferSize)));
+ baos.write(intBytes(swapInt(dwQuality)));
+ baos.write(intBytes(swapInt(dwSampleSize)));
+ baos.write(intBytes(swapInt(left)));
+ baos.write(intBytes(swapInt(top)));
+ baos.write(intBytes(swapInt(right)));
+ baos.write(intBytes(swapInt(bottom)));
+ baos.close();
+
+ return baos.toByteArray();
+ }
+ }
+
+ private class AVIStreamFormat
+ {
+ /*
+ FOURCC fcc;
+ DWORD cb;
+ DWORD biSize;
+ LONG biWidth;
+ LONG biHeight;
+ WORD biPlanes;
+ WORD biBitCount;
+ DWORD biCompression;
+ DWORD biSizeImage;
+ LONG biXPelsPerMeter;
+ LONG biYPelsPerMeter;
+ DWORD biClrUsed;
+ DWORD biClrImportant;
+ */
+
+ public byte[] fcc = new byte[]{'s','t','r','f'};
+ public int cb = 40;
+ public int biSize = 40; // same as cb
+ public int biWidth = 0;
+ public int biHeight = 0;
+ public short biPlanes = 1;
+ public short biBitCount = 24;
+ public byte[] biCompression = new byte[]{'M','J','P','G'};
+ public int biSizeImage = 0; // width x height in pixels
+ public int biXPelsPerMeter = 0;
+ public int biYPelsPerMeter = 0;
+ public int biClrUsed = 0;
+ public int biClrImportant = 0;
+
+
+ public AVIStreamFormat()
+ {
+ biWidth = width;
+ biHeight = height;
+ biSizeImage = width * height;
+ }
+
+ public byte[] toBytes() throws IOException
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ baos.write(fcc);
+ baos.write(intBytes(swapInt(cb)));
+ baos.write(intBytes(swapInt(biSize)));
+ baos.write(intBytes(swapInt(biWidth)));
+ baos.write(intBytes(swapInt(biHeight)));
+ baos.write(shortBytes(swapShort(biPlanes)));
+ baos.write(shortBytes(swapShort(biBitCount)));
+ baos.write(biCompression);
+ baos.write(intBytes(swapInt(biSizeImage)));
+ baos.write(intBytes(swapInt(biXPelsPerMeter)));
+ baos.write(intBytes(swapInt(biYPelsPerMeter)));
+ baos.write(intBytes(swapInt(biClrUsed)));
+ baos.write(intBytes(swapInt(biClrImportant)));
+ baos.close();
+
+ return baos.toByteArray();
+ }
+ }
+
+ private class AVIMovieList
+ {
+ public byte[] fcc = new byte[]{'L','I','S','T'};
+ public int listSize = 0;
+ public byte[] fcc2 = new byte[]{'m','o','v','i'};
+ // 00db size jpg image data ...
+
+ public AVIMovieList()
+ {
+
+ }
+
+ public byte[] toBytes() throws IOException
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ baos.write(fcc);
+ baos.write(intBytes(swapInt(listSize)));
+ baos.write(fcc2);
+ baos.close();
+
+ return baos.toByteArray();
+ }
+ }
+
+ private class AVIIndexList
+ {
+ public byte[] fcc = new byte[]{'i','d','x','1'};
+ public int cb = 0;
+ public ArrayList ind = new ArrayList();
+
+ public AVIIndexList()
+ {
+
+ }
+
+ public void addAVIIndex(AVIIndex ai)
+ {
+ ind.add(ai);
+ }
+
+ public void addAVIIndex(int dwOffset, int dwSize)
+ {
+ ind.add(new AVIIndex(dwOffset, dwSize));
+ }
+
+ public byte[] toBytes() throws IOException
+ {
+ cb = 16 * ind.size();
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ baos.write(fcc);
+ baos.write(intBytes(swapInt(cb)));
+ for(int i = 0; i < ind.size(); i++)
+ {
+ AVIIndex in = (AVIIndex)ind.get(i);
+ baos.write(in.toBytes());
+ }
+
+ baos.close();
+
+ return baos.toByteArray();
+ }
+ }
+
+ private class AVIIndex
+ {
+ public byte[] fcc = new byte[]{'0','0','d','b'};
+ public int dwFlags = 16;
+ public int dwOffset = 0;
+ public int dwSize = 0;
+
+ public AVIIndex(int dwOffset, int dwSize)
+ {
+ this.dwOffset = dwOffset;
+ this.dwSize = dwSize;
+ }
+
+ public byte[] toBytes() throws IOException
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ baos.write(fcc);
+ baos.write(intBytes(swapInt(dwFlags)));
+ baos.write(intBytes(swapInt(dwOffset)));
+ baos.write(intBytes(swapInt(dwSize)));
+ baos.close();
+
+ return baos.toByteArray();
+ }
+ }
+
+ private class AVIJunk
+ {
+ public byte[] fcc = new byte[]{'J','U','N','K'};
+ public int size = 1808;
+ public byte[] data = new byte[size];
+
+ public AVIJunk()
+ {
+ Arrays.fill(data,(byte)0);
+ }
+
+ public byte[] toBytes() throws IOException
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ baos.write(fcc);
+ baos.write(intBytes(swapInt(size)));
+ baos.write(data);
+ baos.close();
+
+ return baos.toByteArray();
+ }
+ }
+
+ private byte[] writeImageToBytes(Image image) throws IOException
+ {
+ BufferedImage bi = new BufferedImage(width, height,BufferedImage.TYPE_INT_RGB);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ Graphics2D g = bi.createGraphics();
+ g.drawImage(image,0,0,width,height,null);
+ ImageIO.write(bi,"jpg",baos);
+ baos.close();
+ bi = null;
+ g = null;
+
+ return baos.toByteArray();
+ }
+
+ public static void main(String[] args) throws Exception
+ {
+ double framerate = 12.0;
+ double transitionDuration = 1; // seconds
+ double slideDuration = 3; // seconds
+
+ File photoDir = new File(args[0]);
+ File[] files = photoDir.listFiles(new FilenameFilter(){
+ public boolean accept(File dir, String name)
+ {
+ if(StringUtils.goLowerCase(name).endsWith("jpg"))
+ return true;
+ return false;
+ }
+ });
+
+
+ int numFrames = (int)(files.length * framerate * (slideDuration + transitionDuration) + (transitionDuration * framerate));
+ MJPEGGenerator m = new MJPEGGenerator(new File(args[1]), 640, 480, framerate, numFrames);
+ for(int i = 0; i < files.length; i++)
+ {
+ System.out.println("processing file "+i);
+ ImageIcon ii = new ImageIcon(files[i].getCanonicalPath());
+ m.addImage(ii.getImage());
+ }
+ m.finishAVI();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/objectdiagram/AbstractClassOrObjectDiagram.java b/src/net/sourceforge/plantuml/objectdiagram/AbstractClassOrObjectDiagram.java
new file mode 100644
index 0000000..2d72917
--- /dev/null
+++ b/src/net/sourceforge/plantuml/objectdiagram/AbstractClassOrObjectDiagram.java
@@ -0,0 +1,235 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.objectdiagram;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.cucadiagram.LinkDecor;
+import net.sourceforge.plantuml.cucadiagram.LinkType;
+import net.sourceforge.plantuml.utils.UniqueSequence;
+
+public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram {
+
+ final public boolean insertBetween(IEntity entity1, IEntity entity2, IEntity node) {
+ final Link link = foundLink(entity1, entity2);
+ if (link == null) {
+ return false;
+ }
+ final Link l1 = new Link(entity1, node, link.getType(), link.getLabel(), link.getLength(),
+ link.getQualifier1(), null, link.getLabeldistance(), link.getLabelangle());
+ final Link l2 = new Link(node, entity2, link.getType(), link.getLabel(), link.getLength(), null,
+ link.getQualifier2(), link.getLabeldistance(), link.getLabelangle());
+ addLink(l1);
+ addLink(l2);
+ removeLink(link);
+ return true;
+ }
+
+ private Link foundLink(IEntity entity1, IEntity entity2) {
+ final List<Link> links = getLinks();
+ for (int i = links.size() - 1; i >= 0; i--) {
+ final Link l = links.get(i);
+ if (l.isBetween(entity1, entity2)) {
+ return l;
+ }
+ }
+ return null;
+ }
+
+ public int getNbOfHozizontalLollipop(IEntity entity) {
+ if (entity.getEntityType() == LeafType.LOLLIPOP) {
+ throw new IllegalArgumentException();
+ }
+ int result = 0;
+ for (Link link : getLinks()) {
+ if (link.getLength() == 1 && link.contains(entity) && link.containsType(LeafType.LOLLIPOP)) {
+ result++;
+ }
+
+ }
+ return result;
+ }
+
+ private final List<Association> assocations = new ArrayList<Association>();
+
+ public boolean associationClass(int mode, Code clName1, Code clName2, IEntity associed, LinkType linkType,
+ Display label) {
+ final IEntity entity1 = getOrCreateLeaf(clName1, null, null);
+ final IEntity entity2 = getOrCreateLeaf(clName2, null, null);
+ final List<Association> same = new ArrayList<Association>();
+ for (Association existing : assocations) {
+ if (existing.sameCouple(entity1, entity2)) {
+ same.add(existing);
+ }
+ }
+ if (same.size() > 1) {
+ return false;
+ } else if (same.size() == 0) {
+ final Association association = new Association(mode, entity1, entity2, associed);
+ association.createNew(mode, linkType, label);
+
+ this.assocations.add(association);
+ return true;
+ }
+ assert same.size() == 1;
+ final Association association = same.get(0).createSecondAssociation(mode, associed, label);
+ association.createInSecond(linkType, label);
+
+ this.assocations.add(association);
+ return true;
+ }
+
+ class Association {
+ private IEntity entity1;
+ private IEntity entity2;
+ private IEntity associed;
+ private IEntity point;
+
+ private Link existingLink;
+
+ private Link entity1ToPoint;
+ private Link pointToEntity2;
+ private Link pointToAssocied;
+
+ private Association other;
+
+ public Association(int mode, IEntity entity1, IEntity entity2, IEntity associed) {
+ this.entity1 = entity1;
+ this.entity2 = entity2;
+ this.associed = associed;
+ point = getOrCreateLeaf(UniqueSequence.getCode("apoint"), LeafType.POINT_FOR_ASSOCIATION, null);
+
+ }
+
+ public Association createSecondAssociation(int mode2, IEntity associed2, Display label) {
+ final Association result = new Association(mode2, entity1, entity2, associed2);
+ result.existingLink = this.existingLink;
+ result.other = this;
+
+ if (this.existingLink.getLength() == 1) {
+ this.entity1ToPoint.setLength(2);
+ this.pointToEntity2.setLength(2);
+ this.pointToAssocied.setLength(1);
+ }
+ return result;
+ }
+
+ void createNew(int mode, LinkType linkType, Display label) {
+ existingLink = foundLink(entity1, entity2);
+ if (existingLink == null) {
+ existingLink = new Link(entity1, entity2, new LinkType(LinkDecor.NONE, LinkDecor.NONE), null,
+ 2);
+ } else {
+ removeLink(existingLink);
+ }
+
+ entity1ToPoint = new Link(entity1, point, existingLink.getType().getPart2(), existingLink.getLabel(),
+ existingLink.getLength(), existingLink.getQualifier1(), null, existingLink.getLabeldistance(),
+ existingLink.getLabelangle());
+ entity1ToPoint.setLinkArrow(existingLink.getLinkArrow());
+ pointToEntity2 = new Link(point, entity2, existingLink.getType().getPart1(), null,
+ existingLink.getLength(), null, existingLink.getQualifier2(), existingLink.getLabeldistance(),
+ existingLink.getLabelangle());
+ addLink(entity1ToPoint);
+ addLink(pointToEntity2);
+
+ int length = 1;
+ if (existingLink.getLength() == 1 && entity1 != entity2) {
+ length = 2;
+ }
+ if (existingLink.getLength() == 2 && entity1 == entity2) {
+ length = 2;
+ }
+
+ if (mode == 1) {
+ pointToAssocied = new Link(point, associed, linkType, label, length);
+ } else {
+ pointToAssocied = new Link(associed, point, linkType, label, length);
+ }
+ addLink(pointToAssocied);
+ }
+
+ void createInSecond(LinkType linkType, Display label) {
+ existingLink = foundLink(entity1, entity2);
+ if (existingLink == null) {
+ existingLink = new Link(entity1, entity2, new LinkType(LinkDecor.NONE, LinkDecor.NONE), null,
+ 2);
+ } else {
+ removeLink(existingLink);
+ }
+
+ entity1ToPoint = new Link(entity1, point, existingLink.getType().getPart2(), existingLink.getLabel(), 2,
+ existingLink.getQualifier1(), null, existingLink.getLabeldistance(), existingLink.getLabelangle());
+ pointToEntity2 = new Link(point, entity2, existingLink.getType().getPart1(), null, 2, null,
+ existingLink.getQualifier2(), existingLink.getLabeldistance(), existingLink.getLabelangle());
+ // entity1ToPoint = new Link(entity1, point, existingLink.getType(),
+ // null, 2);
+ // pointToEntity2 = new Link(point, entity2, existingLink.getType(),
+ // null, 2);
+ addLink(entity1ToPoint);
+ addLink(pointToEntity2);
+ if (other.pointToAssocied.getEntity1().getEntityType() == LeafType.POINT_FOR_ASSOCIATION) {
+ removeLink(other.pointToAssocied);
+ other.pointToAssocied = other.pointToAssocied.getInv();
+ addLink(other.pointToAssocied);
+ }
+ pointToAssocied = new Link(point, associed, linkType, label, 1);
+ addLink(pointToAssocied);
+
+ final Link lnode = new Link(other.point, this.point, new LinkType(LinkDecor.NONE, LinkDecor.NONE), null, 1);
+ lnode.setInvis(true);
+ addLink(lnode);
+
+ }
+
+ boolean sameCouple(IEntity entity1, IEntity entity2) {
+ if (this.entity1 == entity1 && this.entity2 == entity2) {
+ return true;
+ }
+ if (this.entity1 == entity2 && this.entity2 == entity1) {
+ return true;
+ }
+ return false;
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/objectdiagram/ObjectDiagram.java b/src/net/sourceforge/plantuml/objectdiagram/ObjectDiagram.java
new file mode 100644
index 0000000..eb85c76
--- /dev/null
+++ b/src/net/sourceforge/plantuml/objectdiagram/ObjectDiagram.java
@@ -0,0 +1,59 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.objectdiagram;
+
+import net.sourceforge.plantuml.UmlDiagramType;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+import net.sourceforge.plantuml.graphic.USymbol;
+
+public class ObjectDiagram extends AbstractClassOrObjectDiagram {
+
+ @Override
+ public ILeaf getOrCreateLeaf(Code code, LeafType type, USymbol symbol) {
+ if (type == null) {
+ type = LeafType.OBJECT;
+ }
+ return getOrCreateLeafDefault(code, type, symbol);
+ }
+
+ @Override
+ public UmlDiagramType getUmlDiagramType() {
+ return UmlDiagramType.OBJECT;
+ }
+
+
+}
diff --git a/src/net/sourceforge/plantuml/objectdiagram/ObjectDiagramFactory.java b/src/net/sourceforge/plantuml/objectdiagram/ObjectDiagramFactory.java
new file mode 100644
index 0000000..58b6e48
--- /dev/null
+++ b/src/net/sourceforge/plantuml/objectdiagram/ObjectDiagramFactory.java
@@ -0,0 +1,106 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.objectdiagram;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.UmlDiagramType;
+import net.sourceforge.plantuml.classdiagram.command.CommandLinkClass;
+import net.sourceforge.plantuml.classdiagram.command.CommandUrl;
+import net.sourceforge.plantuml.command.Command;
+import net.sourceforge.plantuml.command.CommandEndPackage;
+import net.sourceforge.plantuml.command.CommandFootboxIgnored;
+import net.sourceforge.plantuml.command.CommandPackage;
+import net.sourceforge.plantuml.command.CommandPage;
+import net.sourceforge.plantuml.command.CommandRankDir;
+import net.sourceforge.plantuml.command.UmlDiagramFactory;
+import net.sourceforge.plantuml.command.note.FactoryNoteCommand;
+import net.sourceforge.plantuml.command.note.FactoryNoteOnEntityCommand;
+import net.sourceforge.plantuml.command.note.FactoryNoteOnLinkCommand;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.objectdiagram.command.CommandAddData;
+import net.sourceforge.plantuml.objectdiagram.command.CommandCreateEntityObject;
+import net.sourceforge.plantuml.objectdiagram.command.CommandCreateEntityObjectMultilines;
+
+public class ObjectDiagramFactory extends UmlDiagramFactory {
+
+ @Override
+ protected List<Command> createCommands() {
+
+ final List<Command> cmds = new ArrayList<Command>();
+ cmds.add(new CommandFootboxIgnored());
+
+ addCommonCommands(cmds);
+ cmds.add(new CommandRankDir());
+ cmds.add(new CommandPage());
+ cmds.add(new CommandAddData());
+ cmds.add(new CommandLinkClass(UmlDiagramType.OBJECT));
+ //
+ cmds.add(new CommandCreateEntityObject());
+ final FactoryNoteCommand factoryNoteCommand = new FactoryNoteCommand();
+
+ cmds.add(factoryNoteCommand.createSingleLine());
+ cmds.add(new CommandPackage());
+ cmds.add(new CommandEndPackage());
+ // addCommand(new CommandNamespace());
+ // addCommand(new CommandEndNamespace());
+ // addCommand(new CommandStereotype());
+ //
+ // addCommand(new CommandImport());
+ final FactoryNoteOnEntityCommand factoryNoteOnEntityCommand = new FactoryNoteOnEntityCommand(new RegexLeaf(
+ "ENTITY", "([\\p{L}0-9_.]+|[%g][^%g]+[%g])"));
+ cmds.add(factoryNoteOnEntityCommand.createSingleLine());
+
+ cmds.add(new CommandUrl());
+
+ cmds.add(factoryNoteCommand.createMultiLine());
+ cmds.add(factoryNoteOnEntityCommand.createMultiLine());
+ cmds.add(new CommandCreateEntityObjectMultilines());
+
+ final FactoryNoteOnLinkCommand factoryNoteOnLinkCommand = new FactoryNoteOnLinkCommand();
+ cmds.add(factoryNoteOnLinkCommand.createSingleLine());
+ cmds.add(factoryNoteOnLinkCommand.createMultiLine());
+
+ // addCommand(new CommandNoopClass());
+ return cmds;
+
+ }
+
+ @Override
+ public ObjectDiagram createEmptyDiagram() {
+ return new ObjectDiagram();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/objectdiagram/command/CommandAddData.java b/src/net/sourceforge/plantuml/objectdiagram/command/CommandAddData.java
new file mode 100644
index 0000000..70f9fce
--- /dev/null
+++ b/src/net/sourceforge/plantuml/objectdiagram/command/CommandAddData.java
@@ -0,0 +1,63 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.objectdiagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.objectdiagram.ObjectDiagram;
+import net.sourceforge.plantuml.skin.VisibilityModifier;
+
+public class CommandAddData extends SingleLineCommand<ObjectDiagram> {
+
+ public CommandAddData() {
+ super("(?i)^([\\p{L}0-9_.]+)[%s]*:[%s]*(.*)$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ObjectDiagram diagram, List<String> arg) {
+ final IEntity entity = diagram.getOrCreateLeaf(Code.of(arg.get(0)), null, null);
+
+ final String field = arg.get(1);
+ if (field.length() > 0 && VisibilityModifier.isVisibilityCharacter(field.charAt(0))) {
+ diagram.setVisibilityModifierPresent(true);
+ }
+ entity.addFieldOrMethod(field);
+ return CommandExecutionResult.ok();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateEntityObject.java b/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateEntityObject.java
new file mode 100644
index 0000000..a3f284c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateEntityObject.java
@@ -0,0 +1,97 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.objectdiagram.command;
+
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.objectdiagram.ObjectDiagram;
+
+public class CommandCreateEntityObject extends SingleLineCommand2<ObjectDiagram> {
+
+ public CommandCreateEntityObject() {
+ super(getRegexConcat());
+ }
+
+ private static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("TYPE", "(object)[%s]+"), //
+ new RegexLeaf("NAME", "(?:[%g]([^%g]+)[%g][%s]+as[%s]+)?([\\p{L}0-9_.]+)"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("STEREO", "(\\<\\<.+\\>\\>)?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("COLOR", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(ObjectDiagram diagram, RegexResult arg) {
+ final Code code = Code.of(arg.get("NAME", 1));
+ final String display = arg.get("NAME", 0);
+ final String stereotype = arg.get("STEREO", 0);
+ if (diagram.leafExist(code)) {
+ return CommandExecutionResult.error("Object already exists : " + code);
+ }
+ final IEntity entity = diagram.createLeaf(code, Display.getWithNewlines(display), LeafType.OBJECT, null);
+ if (stereotype != null) {
+ entity.setStereotype(new Stereotype(stereotype, diagram.getSkinParam().getCircledCharacterRadius(), diagram
+ .getSkinParam().getFont(FontParam.CIRCLED_CHARACTER, null, false), diagram.getSkinParam()
+ .getIHtmlColorSet()));
+ }
+ final String urlString = arg.get("URL", 0);
+ if (urlString != null) {
+ final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
+ final Url url = urlBuilder.getUrl(urlString);
+ entity.addUrl(url);
+ }
+ entity.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0)));
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateEntityObjectMultilines.java b/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateEntityObjectMultilines.java
new file mode 100644
index 0000000..f727e2d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/objectdiagram/command/CommandCreateEntityObjectMultilines.java
@@ -0,0 +1,115 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.objectdiagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.CommandMultilines2;
+import net.sourceforge.plantuml.command.MultilinesStrategy;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.objectdiagram.ObjectDiagram;
+import net.sourceforge.plantuml.skin.VisibilityModifier;
+import net.sourceforge.plantuml.StringUtils;
+
+public class CommandCreateEntityObjectMultilines extends CommandMultilines2<ObjectDiagram> {
+
+ public CommandCreateEntityObjectMultilines() {
+ super(getRegexConcat(), MultilinesStrategy.REMOVE_STARTING_QUOTE);
+ }
+
+ private static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("TYPE", "(object)[%s]+"), //
+ new RegexLeaf("NAME", "(?:[%g]([^%g]+)[%g][%s]+as[%s]+)?([\\p{L}0-9_.]+)"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("STEREO", "(\\<\\<.+\\>\\>)?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("COLOR", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), //
+ new RegexLeaf("[%s]*\\{[%s]*$"));
+ }
+
+ @Override
+ public String getPatternEnd() {
+ return "(?i)^[%s]*\\}[%s]*$";
+ }
+
+ public CommandExecutionResult executeNow(ObjectDiagram diagram, List<String> lines) {
+ StringUtils.trim(lines, true);
+ final RegexResult line0 = getStartingPattern().matcher(lines.get(0).trim());
+ final IEntity entity = executeArg0(diagram, line0);
+ if (entity == null) {
+ return CommandExecutionResult.error("No such entity");
+ }
+ for (String s : lines.subList(1, lines.size() - 1)) {
+ assert s.length() > 0;
+ if (VisibilityModifier.isVisibilityCharacter(s.charAt(0))) {
+ diagram.setVisibilityModifierPresent(true);
+ }
+ entity.addFieldOrMethod(s);
+ }
+ return CommandExecutionResult.ok();
+ }
+
+ private IEntity executeArg0(ObjectDiagram diagram, RegexResult line0) {
+ final Code code = Code.of(line0.get("NAME", 1));
+ final String display = line0.get("NAME", 0);
+ final String stereotype = line0.get("STEREO", 0);
+ if (diagram.leafExist(code)) {
+ return diagram.getOrCreateLeaf(code, null, null);
+ }
+ final IEntity entity = diagram.createLeaf(code, Display.getWithNewlines(display), LeafType.OBJECT, null);
+ if (stereotype != null) {
+ entity.setStereotype(new Stereotype(stereotype, diagram.getSkinParam().getCircledCharacterRadius(), diagram
+ .getSkinParam().getFont(FontParam.CIRCLED_CHARACTER, null, false), diagram.getSkinParam()
+ .getIHtmlColorSet()));
+ }
+ entity.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(line0.get("COLOR", 0)));
+ return entity;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/openiconic/Movement.java b/src/net/sourceforge/plantuml/openiconic/Movement.java
new file mode 100644
index 0000000..8c4d11b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/Movement.java
@@ -0,0 +1,188 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.openiconic;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+public class Movement {
+
+ private final SvgCommandLetter letter;
+ private final List<SvgCommandNumber> arguments;
+
+ public Movement(Iterator<SvgCommand> it) {
+ this.letter = (SvgCommandLetter) it.next();
+ final int nb = letter.argumentNumber();
+ final SvgCommandNumber args[] = new SvgCommandNumber[nb];
+ for (int i = 0; i < nb; i++) {
+ args[i] = (SvgCommandNumber) it.next();
+ }
+ this.arguments = Arrays.asList(args);
+ }
+
+ private Movement(SvgCommandLetter letter, SvgCommandNumber... args) {
+ this.letter = letter;
+ this.arguments = Arrays.asList(args);
+ }
+
+ private Movement(SvgCommandLetter letter) {
+ this.letter = letter;
+ this.arguments = Collections.emptyList();
+ }
+
+ public char getLetter() {
+ return letter.getLetter();
+ }
+
+ private Movement(SvgCommandLetter letter, SvgPosition... pos) {
+ this.letter = letter;
+ final SvgCommandNumber args[] = new SvgCommandNumber[pos.length * 2];
+ for (int i = 0; i < pos.length; i++) {
+ args[2 * i] = pos[i].getX();
+ args[2 * i + 1] = pos[i].getY();
+ }
+ this.arguments = Arrays.asList(args);
+ }
+
+ public Movement mutoToC(SvgPosition mirrorControlPoint) {
+ if (is('S') == false) {
+ throw new UnsupportedOperationException();
+ }
+ if (mirrorControlPoint == null) {
+ // return this;
+ // throw new IllegalArgumentException();
+ return new Movement(new SvgCommandLetter("C"), this.getSvgPosition(0), this.getSvgPosition(0),
+ lastPosition());
+ }
+ return new Movement(new SvgCommandLetter("C"), mirrorControlPoint, this.getSvgPosition(0), lastPosition());
+ }
+
+ public String toSvg() {
+ final StringBuilder result = new StringBuilder();
+ result.append(letter.toSvg());
+ result.append(' ');
+ for (SvgCommandNumber arg : arguments) {
+ result.append(arg.toSvg());
+ result.append(' ');
+ }
+ return result.toString();
+ }
+
+ public SvgPosition getSvgPosition(int index) {
+ return new SvgPosition(arguments.get(index), arguments.get(index + 1));
+ }
+
+ public double getArgument(int index) {
+ return arguments.get(index).getDouble();
+ }
+
+ public SvgPosition lastPosition() {
+ if (letter.argumentNumber() == 0) {
+ return null;
+ }
+ return getSvgPosition(arguments.size() - 2);
+ // final SvgCommandNumber lastX = arguments.get(arguments.size() - 2);
+ // final SvgCommandNumber lastY = arguments.get(arguments.size() - 1);
+ // return new SvgPosition(lastX, lastY);
+ }
+
+ // public SvgPosition firstPosition() {
+ // return getSvgPosition(0);
+ // // final SvgCommandNumber firstX = arguments.get(0);
+ // // final SvgCommandNumber firstY = arguments.get(1);
+ // // return new SvgPosition(firstX, firstY);
+ // }
+
+ public Movement toAbsoluteUpperCase(SvgPosition delta) {
+ if (delta == null) {
+ throw new IllegalArgumentException();
+ }
+ if (letter.isUpperCase()) {
+ return this;
+ }
+ if (letter.is('m')) {
+ return new Movement(new SvgCommandLetter("M"), delta.add(getSvgPosition(0)));
+ }
+ if (letter.is('l')) {
+ return new Movement(new SvgCommandLetter("L"), delta.add(getSvgPosition(0)));
+ }
+ if (letter.is('z')) {
+ return new Movement(new SvgCommandLetter("Z"));
+ }
+ if (letter.is('c')) {
+ return new Movement(new SvgCommandLetter("C"), delta.add(getSvgPosition(0)), delta.add(getSvgPosition(2)),
+ delta.add(getSvgPosition(4)));
+ }
+ if (letter.is('s')) {
+ return new Movement(new SvgCommandLetter("S"), delta.add(getSvgPosition(0)), delta.add(getSvgPosition(2)));
+ }
+ if (letter.is('a')) {
+ final SvgPosition last = delta.add(lastPosition());
+ // System.err.println("LAST=" + last);
+ return new Movement(new SvgCommandLetter("A"), arguments.get(0), arguments.get(1), arguments.get(2),
+ arguments.get(3), arguments.get(4), last.getX(), last.getY());
+ }
+ // A still to be done
+ // System.err.println("Movement::goUpperCase " + letter);
+ throw new UnsupportedOperationException("Movement::goUpperCase " + letter);
+ }
+
+ public SvgPosition getMirrorControlPoint() {
+ if (letter.is('c')) {
+ throw new IllegalStateException();
+ }
+ if (letter.is('s')) {
+ throw new IllegalStateException();
+ }
+ if (letter.is('C')) {
+ final SvgPosition center = lastPosition();
+ final SvgPosition controlPoint = getSvgPosition(2);
+ return center.getMirror(controlPoint);
+ }
+ if (letter.is('S')) {
+ final SvgPosition center = lastPosition();
+ final SvgPosition controlPoint = getSvgPosition(0);
+ return center.getMirror(controlPoint);
+ }
+ return null;
+ }
+
+ public boolean is(char c) {
+ return letter.is(c);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/openiconic/OpenIcon.java b/src/net/sourceforge/plantuml/openiconic/OpenIcon.java
new file mode 100644
index 0000000..a2fdf85
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/OpenIcon.java
@@ -0,0 +1,145 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.openiconic;
+
+import java.awt.geom.Dimension2D;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.openiconic.data.DummyIcon;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class OpenIcon {
+
+ private SvgPath svgPath;
+ private List<String> rawData = new ArrayList<String>();
+ private final String id;
+
+ public static OpenIcon retrieve(String name) {
+ final InputStream is = getRessource(name);
+ if (is == null) {
+ return null;
+ }
+ try {
+ return new OpenIcon(is, name);
+ } catch (IOException e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ OpenIcon(String name) throws IOException {
+ this(getRessource(name), name);
+ }
+
+ private static InputStream getRessource(String name) {
+ // System.err.println("OPENING " + name);
+ return DummyIcon.class.getResourceAsStream(name + ".svg");
+ }
+
+ private OpenIcon(InputStream is, String id) throws IOException {
+ this.id = id;
+ BufferedReader br = new BufferedReader(new InputStreamReader(is));
+ String s = null;
+ while ((s = br.readLine()) != null) {
+ rawData.add(s);
+ if (s.contains("<path")) {
+ final int x1 = s.indexOf('"');
+ final int x2 = s.indexOf('"', x1 + 1);
+ svgPath = new SvgPath(s.substring(x1 + 1, x2));
+ }
+ }
+ br.close();
+ is.close();
+ if (rawData.size() != 3 && rawData.size() != 4) {
+ throw new IllegalStateException();
+ }
+ }
+
+ void saveCopy(File fnew) throws IOException {
+ final PrintWriter pw = new PrintWriter(fnew);
+ pw.println(rawData.get(0));
+ pw.println(svgPath.toSvg());
+ pw.println(rawData.get(rawData.size() - 1));
+ pw.close();
+
+ }
+
+ private Dimension2D getDimension(double factor) {
+ final String width = getNumber(rawData.get(0), "width");
+ final String height = getNumber(rawData.get(0), "height");
+ return new Dimension2DDouble(Integer.parseInt(width) * factor, Integer.parseInt(height) * factor);
+ }
+
+ private String getNumber(String s, String arg) {
+ int x1 = s.indexOf(arg);
+ if (x1 == -1) {
+ throw new IllegalArgumentException();
+ }
+ x1 = s.indexOf("\"", x1);
+ if (x1 == -1) {
+ throw new IllegalArgumentException();
+ }
+ final int x2 = s.indexOf("\"", x1 + 1);
+ if (x2 == -1) {
+ throw new IllegalArgumentException();
+ }
+ return s.substring(x1 + 1, x2);
+ }
+
+ public TextBlock asTextBlock(final HtmlColor color, final double factor) {
+ return new TextBlock() {
+ public void drawU(UGraphic ug) {
+ svgPath.drawMe(ug.apply(new UChangeColor(color)), factor);
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return getDimension(factor);
+ }
+ };
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/openiconic/PSystemListOpenIconic.java b/src/net/sourceforge/plantuml/openiconic/PSystemListOpenIconic.java
new file mode 100644
index 0000000..4130a7f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/PSystemListOpenIconic.java
@@ -0,0 +1,99 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.openiconic;
+
+import java.awt.Font;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.core.DiagramDescription;
+import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.graphic.GraphicStrings;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.openiconic.data.DummyIcon;
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+import net.sourceforge.plantuml.ugraphic.ImageBuilder;
+import net.sourceforge.plantuml.ugraphic.UAntiAliasing;
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public class PSystemListOpenIconic extends AbstractPSystem {
+
+ public ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormat) throws IOException {
+ final GraphicStrings result = getGraphicStrings();
+ final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(),
+ getMetadata(), null, 0, 0, null, false);
+ imageBuilder.addUDrawable(result);
+ return imageBuilder.writeImageTOBEMOVED(fileFormat.getFileFormat(), os);
+ }
+
+ private GraphicStrings getGraphicStrings() throws IOException {
+ final List<String> lines = new ArrayList<String>();
+ lines.add("<b>List Open Iconic");
+ lines.add("<i>Credit to");
+ lines.add("https://useiconic.com/open");
+ lines.add(" ");
+ final BufferedReader br = new BufferedReader(new InputStreamReader(getRessourceAllTxt()));
+ String s = null;
+ while ((s = br.readLine()) != null) {
+ // lines.add("<&yen> " + s);
+ // System.err.println("s=" + s);
+ lines.add("<&" + s + "> " + s);
+ }
+ br.close();
+
+ final UFont font = new UFont("SansSerif", Font.PLAIN, 12);
+ final GraphicStrings graphicStrings = new GraphicStrings(lines, font, HtmlColorUtils.BLACK,
+ HtmlColorUtils.WHITE, UAntiAliasing.ANTI_ALIASING_ON);
+ graphicStrings.setMaxLine(35);
+ return graphicStrings;
+ }
+
+ private InputStream getRessourceAllTxt() {
+ return DummyIcon.class.getResourceAsStream("all.txt");
+ }
+
+ public DiagramDescription getDescription() {
+ return new DiagramDescriptionImpl("(Open iconic)", getClass());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/openiconic/PSystemListOpenIconicFactory.java b/src/net/sourceforge/plantuml/openiconic/PSystemListOpenIconicFactory.java
new file mode 100644
index 0000000..0446212
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/PSystemListOpenIconicFactory.java
@@ -0,0 +1,52 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.openiconic;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.command.PSystemSingleLineFactory;
+
+public class PSystemListOpenIconicFactory extends PSystemSingleLineFactory {
+
+ @Override
+ protected AbstractPSystem executeLine(String line) {
+ final String lineLower = StringUtils.goLowerCase(line);
+ if (lineLower.startsWith("listopeniconic")) {
+ return new PSystemListOpenIconic();
+ }
+ return null;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/openiconic/PSystemOpenIconic.java b/src/net/sourceforge/plantuml/openiconic/PSystemOpenIconic.java
new file mode 100644
index 0000000..027e9e3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/PSystemOpenIconic.java
@@ -0,0 +1,88 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.openiconic;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.core.DiagramDescription;
+import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+import net.sourceforge.plantuml.ugraphic.ImageBuilder;
+
+public class PSystemOpenIconic extends AbstractPSystem {
+
+ private final String iconName;
+ private final double factor;
+
+ public PSystemOpenIconic(String iconName, double factor) {
+ this.iconName = iconName;
+ this.factor = factor;
+ }
+
+ public ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormat) throws IOException {
+ final OpenIcon icon = OpenIcon.retrieve(iconName);
+ // final Dimension2D dim = new Dimension2DDouble(100, 100);
+
+ final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0,
+ null, null, null, 5, 5, null, false);
+ imageBuilder.addUDrawable(icon.asTextBlock(HtmlColorUtils.BLACK, factor));
+ return imageBuilder.writeImageTOBEMOVED(fileFormat.getFileFormat(), os);
+
+// UGraphic2 ug = fileFormat.createUGraphic(dim);
+// ug = (UGraphic2) ug.apply(new UTranslate(10, 10));
+// // ug = ug.apply(new UChangeColor(HtmlColorUtils.BLACK));
+// // ug.draw(new URectangle(7, 6));
+// icon.asTextBlock(HtmlColorUtils.BLACK, factor).drawU(ug);
+// ug.writeImageTOBEMOVED(os, null, 96);
+// return new ImageDataSimple(dim);
+ }
+
+ // 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,
+ // UAntiAliasing.ANTI_ALIASING_ON);
+ // return result;
+ // }
+
+ public DiagramDescription getDescription() {
+ return new DiagramDescriptionImpl("(Open iconic)", getClass());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/openiconic/PSystemOpenIconicFactory.java b/src/net/sourceforge/plantuml/openiconic/PSystemOpenIconicFactory.java
new file mode 100644
index 0000000..83e7f54
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/PSystemOpenIconicFactory.java
@@ -0,0 +1,53 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.openiconic;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.command.PSystemSingleLineFactory;
+
+public class PSystemOpenIconicFactory extends PSystemSingleLineFactory {
+
+ @Override
+ protected AbstractPSystem executeLine(String line) {
+ final String lineLower = StringUtils.goLowerCase(line);
+ if (lineLower.startsWith("openiconic ")) {
+ final int idx = line.indexOf(' ');
+ return new PSystemOpenIconic(lineLower.substring(idx + 1), 1.0);
+ }
+ return null;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/openiconic/StringDecipher.java b/src/net/sourceforge/plantuml/openiconic/StringDecipher.java
new file mode 100644
index 0000000..0373cfc
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/StringDecipher.java
@@ -0,0 +1,50 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.openiconic;
+
+public class StringDecipher {
+
+ public static String decipher(String path) {
+ path = path.replaceAll("(\\S)-", "$1 -");
+ path = path.replaceAll("([a-zA-Z])(\\S)", "$1 $2");
+ path = path.replaceAll("(\\S)([a-zA-Z])", "$1 $2");
+ path = path.replaceAll("([a-zA-Z])(\\S)", "$1 $2");
+ while (path.matches(".*\\.\\d+\\..*")) {
+ path = path.replaceAll("(\\.\\d+)\\.", "$1 .");
+ }
+ return path;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/openiconic/SvgCommand.java b/src/net/sourceforge/plantuml/openiconic/SvgCommand.java
new file mode 100644
index 0000000..2423ff8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/SvgCommand.java
@@ -0,0 +1,41 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.openiconic;
+
+public interface SvgCommand {
+
+ public String toSvg();
+
+}
diff --git a/src/net/sourceforge/plantuml/openiconic/SvgCommandLetter.java b/src/net/sourceforge/plantuml/openiconic/SvgCommandLetter.java
new file mode 100644
index 0000000..980ecb5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/SvgCommandLetter.java
@@ -0,0 +1,114 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.openiconic;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class SvgCommandLetter implements SvgCommand {
+
+ final private char letter;
+
+ public SvgCommandLetter(String letter) {
+ if (letter.matches("[a-zA-Z]") == false) {
+ throw new IllegalArgumentException();
+ }
+ this.letter = letter.charAt(0);
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + " " + letter;
+ }
+
+ public String toSvg() {
+ return "" + letter;
+ }
+
+ public int argumentNumber() {
+ switch (StringUtils.goLowerCase(letter)) {
+ case 'm':
+ case 'M':
+ case 'l':
+ return 2;
+ case 'z':
+ return 0;
+ case 'c':
+ return 6;
+ case 's':
+ return 4;
+ case 'a':
+ return 7;
+ }
+ throw new UnsupportedOperationException("" + letter);
+ }
+
+// public UGraphic drawMe(UGraphic ug, Iterator<SvgCommand> it) {
+// System.err.println("drawMe " + letter);
+// final List<SvgCommandNumber> numbers = new ArrayList<SvgCommandNumber>();
+// for (int i = 0; i < argumentNumber(); i++) {
+// numbers.add((SvgCommandNumber) it.next());
+// }
+// return drawMe(ug, numbers);
+// }
+//
+// private UGraphic drawMe(UGraphic ug, List<SvgCommandNumber> numbers) {
+// switch (letter) {
+// case 'M':
+// final double x = numbers.get(0).getDouble();
+// final double y = numbers.get(1).getDouble();
+// return ug.apply(new UTranslate(x, y));
+// }
+// return ug;
+//
+// }
+
+ public boolean isUpperCase() {
+ return Character.isUpperCase(letter);
+ }
+
+ public boolean is(char c) {
+ return this.letter == c;
+ }
+
+ public char getLetter() {
+ return letter;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/openiconic/SvgCommandNumber.java b/src/net/sourceforge/plantuml/openiconic/SvgCommandNumber.java
new file mode 100644
index 0000000..01119f6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/SvgCommandNumber.java
@@ -0,0 +1,71 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.openiconic;
+
+import java.util.Locale;
+
+public class SvgCommandNumber implements SvgCommand {
+
+ final private String number;
+
+ public SvgCommandNumber(String number) {
+ if (number.matches("[-.0-9]+") == false) {
+ throw new IllegalArgumentException();
+ }
+ this.number = number;
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + " " + number;
+ }
+
+ public SvgCommandNumber(double number) {
+ this.number = String.format(Locale.US, "%1.4f", number);
+ }
+
+ public SvgCommandNumber add(SvgCommandNumber other) {
+ return new SvgCommandNumber(getDouble() + other.getDouble());
+ }
+
+ public String toSvg() {
+ return number;
+ }
+
+ public double getDouble() {
+ return Double.parseDouble(number);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/openiconic/SvgPath.java b/src/net/sourceforge/plantuml/openiconic/SvgPath.java
new file mode 100644
index 0000000..679a6ed
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/SvgPath.java
@@ -0,0 +1,215 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.openiconic;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UPath;
+
+public class SvgPath {
+
+ // http://www.w3.org/TR/SVG11/paths.html#PathDataEllipticalArcCommands
+ // https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths
+ // http://tutorials.jenkov.com/svg/path-element.html
+
+ private List<Movement> movements = new ArrayList<Movement>();
+ private List<SvgCommand> commands = new ArrayList<SvgCommand>();
+
+ public SvgPath(String path) {
+ path = StringDecipher.decipher(path);
+ // List<SvgCommand> commands = new ArrayList<SvgCommand>();
+ for (final StringTokenizer st = new StringTokenizer(path); st.hasMoreTokens();) {
+ final String token = st.nextToken();
+ // System.err.println("token=" + token);
+ if (token.matches("[a-zA-Z]")) {
+ commands.add(new SvgCommandLetter(token));
+ } else {
+ commands.add(new SvgCommandNumber(token));
+ }
+ }
+ commands = manageHV(commands);
+ commands = insertMissingLetter(commands);
+ checkArguments(commands);
+ SvgPosition last = new SvgPosition();
+ SvgPosition mirrorControlPoint = null;
+ final Iterator<SvgCommand> iterator = commands.iterator();
+ while (iterator.hasNext()) {
+ Movement movement = new Movement(iterator);
+ // System.err.println("before=" + movement.toSvg());
+ movement = movement.toAbsoluteUpperCase(last);
+ // System.err.println("after=" + movement.toSvg());
+ if (movement.is('S')) {
+ // System.err.println(" before " + movement.toSvg());
+ movement = movement.mutoToC(mirrorControlPoint);
+ // System.err.println(" after " + movement.toSvg());
+ }
+ movements.add(movement);
+ if (movement.lastPosition() != null) {
+ last = movement.lastPosition();
+ }
+ mirrorControlPoint = movement.getMirrorControlPoint();
+ }
+ }
+
+ private List<SvgCommand> insertMissingLetter(List<SvgCommand> commands) {
+ final List<SvgCommand> result = new ArrayList<SvgCommand>();
+ final Iterator<SvgCommand> it = commands.iterator();
+ SvgCommandLetter lastLetter = null;
+ while (it.hasNext()) {
+ final SvgCommand cmd = it.next();
+ // System.err.println("cmd=" + cmd);
+ final int nb;
+ if (cmd instanceof SvgCommandNumber) {
+ // System.err.println("INSERTING " + lastLetter);
+ result.add(lastLetter);
+ result.add(cmd);
+ nb = lastLetter.argumentNumber() - 1;
+ } else {
+ result.add(cmd);
+ lastLetter = (SvgCommandLetter) cmd;
+ nb = lastLetter.argumentNumber();
+ }
+ for (int i = 0; i < nb; i++) {
+ final SvgCommandNumber number = (SvgCommandNumber) it.next();
+ result.add(number);
+ }
+ }
+ return result;
+ }
+
+ private void checkArguments(List<SvgCommand> commands) {
+ final Iterator<SvgCommand> it = commands.iterator();
+ while (it.hasNext()) {
+ final SvgCommandLetter cmd = (SvgCommandLetter) it.next();
+ final int nb = cmd.argumentNumber();
+ for (int i = 0; i < nb; i++) {
+ final SvgCommandNumber number = (SvgCommandNumber) it.next();
+ }
+ }
+ }
+
+ private List<SvgCommand> manageHV(List<SvgCommand> commands) {
+ final List<SvgCommand> result = new ArrayList<SvgCommand>();
+ SvgCommandNumber lastX = null;
+ SvgCommandNumber lastY = null;
+ final Iterator<SvgCommand> it = commands.iterator();
+ while (it.hasNext()) {
+ final SvgCommand cmd = it.next();
+ if (cmd instanceof SvgCommandNumber) {
+ lastX = lastY;
+ lastY = (SvgCommandNumber) cmd;
+ result.add(cmd);
+ continue;
+ }
+ final String letter = cmd.toSvg();
+ if (letter.equals("h")) {
+ result.add(new SvgCommandLetter("l"));
+ result.add(it.next());
+ result.add(new SvgCommandNumber("0"));
+ } else if (letter.equals("v")) {
+ result.add(new SvgCommandLetter("l"));
+ result.add(new SvgCommandNumber("0"));
+ result.add(it.next());
+ } else {
+ result.add(cmd);
+ }
+ }
+ return result;
+ }
+
+ public String toSvg() {
+ final StringBuilder result = new StringBuilder("<path d=\"");
+ for (Movement move : movements) {
+ result.append(move.toSvg());
+ result.append(' ');
+ }
+ result.append("\"/>");
+ return result.toString();
+ }
+
+ private String toSvgNew() {
+ final StringBuilder result = new StringBuilder("<path d=\"");
+ for (SvgCommand cmd : commands) {
+ result.append(cmd.toSvg());
+ result.append(' ');
+ }
+ result.append("\"/>");
+ return result.toString();
+ }
+
+ private UPath toUPath(double factor) {
+ final UPath result = new UPath();
+ for (Movement move : movements) {
+ final char letter = move.getLetter();
+ final SvgPosition lastPosition = move.lastPosition();
+ if (letter == 'M') {
+ result.moveTo(lastPosition.getXDouble() * factor, lastPosition.getYDouble() * factor);
+ } else if (letter == 'C') {
+ final SvgPosition ctl1 = move.getSvgPosition(0);
+ final SvgPosition ctl2 = move.getSvgPosition(2);
+ result.cubicTo(ctl1.getXDouble() * factor, ctl1.getYDouble() * factor, ctl2.getXDouble() * factor,
+ ctl2.getYDouble() * factor, lastPosition.getXDouble() * factor, lastPosition.getYDouble()
+ * factor);
+ } else if (letter == 'L') {
+ result.lineTo(lastPosition.getXDouble() * factor, lastPosition.getYDouble() * factor);
+ } else if (letter == 'A') {
+
+ final double rx = move.getArgument(0);
+ final double ry = move.getArgument(1);
+ final double x_axis_rotation = move.getArgument(2);
+ final double large_arc_flag = move.getArgument(3);
+ final double sweep_flag = move.getArgument(4);
+ result.arcTo(rx * factor, ry * factor, x_axis_rotation, large_arc_flag, sweep_flag,
+ lastPosition.getXDouble() * factor, lastPosition.getYDouble() * factor);
+ } else if (letter == 'Z') {
+ result.closePath();
+ } else {
+ throw new UnsupportedOperationException("letter " + letter);
+ }
+
+ }
+ result.setOpenIconic(true);
+ return result;
+ }
+
+ public void drawMe(UGraphic ug, double factor) {
+ final UPath path = toUPath(factor);
+ ug.draw(path);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/openiconic/SvgPosition.java b/src/net/sourceforge/plantuml/openiconic/SvgPosition.java
new file mode 100644
index 0000000..938769a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/SvgPosition.java
@@ -0,0 +1,89 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.openiconic;
+
+public class SvgPosition {
+
+ final private SvgCommandNumber x;
+ final private SvgCommandNumber y;
+
+ public SvgPosition() {
+ this(new SvgCommandNumber("0"), new SvgCommandNumber("0"));
+ }
+
+ public SvgPosition(SvgCommandNumber x, SvgCommandNumber y) {
+ this.x = x;
+ this.y = y;
+ }
+
+ @Override
+ public String toString() {
+ return x.toSvg() + "," + y.toSvg();
+ }
+
+ public SvgPosition(double x, double y) {
+ this.x = new SvgCommandNumber(x);
+ this.y = new SvgCommandNumber(y);
+ }
+
+ public SvgCommandNumber getX() {
+ return x;
+ }
+
+ public SvgCommandNumber getY() {
+ return y;
+ }
+
+ public double getXDouble() {
+ return x.getDouble();
+ }
+
+ public double getYDouble() {
+ return y.getDouble();
+ }
+
+ public SvgPosition add(SvgPosition other) {
+ return new SvgPosition(x.add(other.x), y.add(other.y));
+ }
+
+ public SvgPosition getMirror(SvgPosition tobeMirrored) {
+ final double centerX = getXDouble();
+ final double centerY = getYDouble();
+ // x1+x2 = 2*xc
+ final double x = 2 * centerX - tobeMirrored.getXDouble();
+ final double y = 2 * centerY - tobeMirrored.getYDouble();
+ return new SvgPosition(x, y);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/openiconic/data/DummyIcon.java b/src/net/sourceforge/plantuml/openiconic/data/DummyIcon.java
new file mode 100644
index 0000000..b486fff
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/DummyIcon.java
@@ -0,0 +1,39 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.openiconic.data;
+
+public class DummyIcon {
+
+}
diff --git a/src/net/sourceforge/plantuml/openiconic/data/account-login.svg b/src/net/sourceforge/plantuml/openiconic/data/account-login.svg
new file mode 100644
index 0000000..225d912
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/account-login.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M3 0v1h4v5h-4v1h5v-7h-5zm1 2v1h-4v1h4v1l2-1.5-2-1.5z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/account-logout.svg b/src/net/sourceforge/plantuml/openiconic/data/account-logout.svg
new file mode 100644
index 0000000..123cece
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/account-logout.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M3 0v1h4v5h-4v1h5v-7h-5zm-1 2l-2 1.5 2 1.5v-1h4v-1h-4v-1z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/action-redo.svg b/src/net/sourceforge/plantuml/openiconic/data/action-redo.svg
new file mode 100644
index 0000000..ce2da3c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/action-redo.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M3.5 1c-1.93 0-3.5 1.57-3.5 3.5 0-1.38 1.12-2.5 2.5-2.5s2.5 1.12 2.5 2.5v.5h-1l2 2 2-2h-1v-.5c0-1.93-1.57-3.5-3.5-3.5z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/action-undo.svg b/src/net/sourceforge/plantuml/openiconic/data/action-undo.svg
new file mode 100644
index 0000000..216bec1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/action-undo.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4.5 1c-1.93 0-3.5 1.57-3.5 3.5v.5h-1l2 2 2-2h-1v-.5c0-1.38 1.12-2.5 2.5-2.5s2.5 1.12 2.5 2.5c0-1.93-1.57-3.5-3.5-3.5z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/align-center.svg b/src/net/sourceforge/plantuml/openiconic/data/align-center.svg
new file mode 100644
index 0000000..bbac8ec
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/align-center.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 0v1h8v-1h-8zm1 2v1h6v-1h-6zm-1 2v1h8v-1h-8zm1 2v1h6v-1h-6z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/align-left.svg b/src/net/sourceforge/plantuml/openiconic/data/align-left.svg
new file mode 100644
index 0000000..2e92e0d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/align-left.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 0v1h8v-1h-8zm0 2v1h6v-1h-6zm0 2v1h8v-1h-8zm0 2v1h6v-1h-6z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/align-right.svg b/src/net/sourceforge/plantuml/openiconic/data/align-right.svg
new file mode 100644
index 0000000..22d127a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/align-right.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 0v1h8v-1h-8zm2 2v1h6v-1h-6zm-2 2v1h8v-1h-8zm2 2v1h6v-1h-6z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/all.txt b/src/net/sourceforge/plantuml/openiconic/data/all.txt
new file mode 100644
index 0000000..07d84ed
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/all.txt
@@ -0,0 +1,223 @@
+account-login
+account-logout
+action-redo
+action-undo
+align-center
+align-left
+align-right
+aperture
+arrow-bottom
+arrow-circle-bottom
+arrow-circle-left
+arrow-circle-right
+arrow-circle-top
+arrow-left
+arrow-right
+arrow-thick-bottom
+arrow-thick-left
+arrow-thick-right
+arrow-thick-top
+arrow-top
+audio-spectrum
+audio
+badge
+ban
+bar-chart
+basket
+battery-empty
+battery-full
+beaker
+bell
+bluetooth
+bold
+bolt
+book
+bookmark
+box
+briefcase
+british-pound
+browser
+brush
+bug
+bullhorn
+calculator
+calendar
+camera-slr
+caret-bottom
+caret-left
+caret-right
+caret-top
+cart
+chat
+check
+chevron-bottom
+chevron-left
+chevron-right
+chevron-top
+circle-check
+circle-x
+clipboard
+clock
+cloud-download
+cloud-upload
+cloud
+cloudy
+code
+cog
+collapse-down
+collapse-left
+collapse-right
+collapse-up
+command
+comment-square
+compass
+contrast
+copywriting
+credit-card
+crop
+dashboard
+data-transfer-download
+data-transfer-upload
+delete
+dial
+document
+dollar
+double-quote-sans-left
+double-quote-sans-right
+double-quote-serif-left
+double-quote-serif-right
+droplet
+eject
+elevator
+ellipses
+envelope-closed
+envelope-open
+euro
+excerpt
+expand-down
+expand-left
+expand-right
+expand-up
+external-link
+eye
+eyedropper
+file
+fire
+flag
+flash
+folder
+fork
+fullscreen-enter
+fullscreen-exit
+globe
+graph
+grid-four-up
+grid-three-up
+grid-two-up
+hard-drive
+header
+headphones
+heart
+home
+image
+inbox
+infinity
+info
+italic
+justify-center
+justify-left
+justify-right
+key
+laptop
+layers
+lightbulb
+link-broken
+link-intact
+list-rich
+list
+location
+lock-locked
+lock-unlocked
+loop-circular
+loop-square
+loop
+magnifying-glass
+map-marker
+map
+media-pause
+media-play
+media-record
+media-skip-backward
+media-skip-forward
+media-step-backward
+media-step-forward
+media-stop
+medical-cross
+menu
+microphone
+minus
+monitor
+moon
+move
+musical-note
+paperclip
+pencil
+people
+person
+phone
+pie-chart
+pin
+play-circle
+plus
+power-standby
+print
+project
+pulse
+puzzle-piece
+question-mark
+rain
+random
+reload
+resize-both
+resize-height
+resize-width
+rss-alt
+rss
+script
+share-boxed
+share
+shield
+signal
+signpost
+sort-ascending
+sort-descending
+spreadsheet
+star
+sun
+tablet
+tag
+tags
+target
+task
+terminal
+text
+thumb-down
+thumb-up
+timer
+transfer
+trash
+underline
+vertical-align-bottom
+vertical-align-center
+vertical-align-top
+video
+volume-high
+volume-low
+volume-off
+warning
+wifi
+wrench
+x
+yen
+zoom-in
+zoom-out
diff --git a/src/net/sourceforge/plantuml/openiconic/data/aperture.svg b/src/net/sourceforge/plantuml/openiconic/data/aperture.svg
new file mode 100644
index 0000000..84935dc
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/aperture.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4 0c-.69 0-1.336.19-1.906.5l3.219 2.344.719-2.25c-.59-.36-1.281-.594-2.031-.594zm-2.75 1.125c-.76.73-1.25 1.735-1.25 2.875 0 .25.022.489.063.719l3.094-2.219-1.906-1.375zm5.625.125l-1.219 3.75h2.219c.08-.32.125-.65.125-1 0-1.07-.435-2.03-1.125-2.75zm-4.719 3.188l-1.75 1.281c.55 1.13 1.595 1.989 2.875 2.219l-1.125-3.5zm1.563 1.563l.625 1.969c1.33-.11 2.454-.879 3.094-1.969h-3.719z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/arrow-bottom.svg b/src/net/sourceforge/plantuml/openiconic/data/arrow-bottom.svg
new file mode 100644
index 0000000..b41aa32
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/arrow-bottom.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M3 0v5h-2l2.531 3 2.469-3h-2v-5h-1z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/arrow-circle-bottom.svg b/src/net/sourceforge/plantuml/openiconic/data/arrow-circle-bottom.svg
new file mode 100644
index 0000000..fffa96b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/arrow-circle-bottom.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4 0c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm-1 1h2v3h2l-3 3-3-3h2v-3z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/arrow-circle-left.svg b/src/net/sourceforge/plantuml/openiconic/data/arrow-circle-left.svg
new file mode 100644
index 0000000..b4d7600
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/arrow-circle-left.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4 0c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm0 1v2h3v2h-3v2l-3-3 3-3z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/arrow-circle-right.svg b/src/net/sourceforge/plantuml/openiconic/data/arrow-circle-right.svg
new file mode 100644
index 0000000..a62bc17
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/arrow-circle-right.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4 0c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm0 1l3 3-3 3v-2h-3v-2h3v-2z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/arrow-circle-top.svg b/src/net/sourceforge/plantuml/openiconic/data/arrow-circle-top.svg
new file mode 100644
index 0000000..2ac6e7f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/arrow-circle-top.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4 0c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm0 1l3 3h-2v3h-2v-3h-2l3-3z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/arrow-left.svg b/src/net/sourceforge/plantuml/openiconic/data/arrow-left.svg
new file mode 100644
index 0000000..7221cae
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/arrow-left.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M3 1l-3 2.531 3 2.469v-2h5v-1h-5v-2z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/arrow-right.svg b/src/net/sourceforge/plantuml/openiconic/data/arrow-right.svg
new file mode 100644
index 0000000..fa49384
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/arrow-right.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M5 1v2h-5v1h5v2l3-2.531-3-2.469z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/arrow-thick-bottom.svg b/src/net/sourceforge/plantuml/openiconic/data/arrow-thick-bottom.svg
new file mode 100644
index 0000000..754e841
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/arrow-thick-bottom.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M3 0v5h-2l3.031 3 2.969-3h-2v-5h-2z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/arrow-thick-left.svg b/src/net/sourceforge/plantuml/openiconic/data/arrow-thick-left.svg
new file mode 100644
index 0000000..94a93e1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/arrow-thick-left.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M3 1l-3 3.031 3 2.969v-2h5v-2h-5v-2z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/arrow-thick-right.svg b/src/net/sourceforge/plantuml/openiconic/data/arrow-thick-right.svg
new file mode 100644
index 0000000..5aa125c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/arrow-thick-right.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M5 1v2h-5v2h5v2l3-3.031-3-2.969z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/arrow-thick-top.svg b/src/net/sourceforge/plantuml/openiconic/data/arrow-thick-top.svg
new file mode 100644
index 0000000..92f6f9f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/arrow-thick-top.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M3.969 0l-2.969 3h2v5h2v-5h2l-3.031-3z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/arrow-top.svg b/src/net/sourceforge/plantuml/openiconic/data/arrow-top.svg
new file mode 100644
index 0000000..305e05c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/arrow-top.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M3.469 0l-2.469 3h2v5h1v-5h2l-2.531-3z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/audio-spectrum.svg b/src/net/sourceforge/plantuml/openiconic/data/audio-spectrum.svg
new file mode 100644
index 0000000..7077ec7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/audio-spectrum.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4 0v8h1v-8h-1zm-2 1v6h1v-6h-1zm4 1v4h1v-4h-1zm-6 1v2h1v-2h-1z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/audio.svg b/src/net/sourceforge/plantuml/openiconic/data/audio.svg
new file mode 100644
index 0000000..5914b3a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/audio.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M1.188 1c-.734.722-1.188 1.748-1.188 2.844 0 1.095.454 2.09 1.188 2.813l.688-.719c-.546-.538-.875-1.269-.875-2.094s.329-1.587.875-2.125l-.688-.719zm5.625 0l-.688.719c.552.552.875 1.289.875 2.125 0 .836-.327 1.554-.875 2.094l.688.719c.732-.72 1.188-1.708 1.188-2.813 0-1.104-.459-2.115-1.188-2.844zm-4.219 1.406c-.362.362-.594.889-.594 1.438 0 .548.232 1.045.594 1.406l.688-.719c-.178-.178-.281-.416-.281-.688 0-.272.103-.54.281-.719l-.688-.719zm2.813 0l-.688.719c.183.183.281.434.281.719s-.099.505-.281.688l.688.719c.357-.357.594-.851.594-1.406 0-.555-.236-1.08-.594-1.438z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/badge.svg b/src/net/sourceforge/plantuml/openiconic/data/badge.svg
new file mode 100644
index 0000000..34f43cf
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/badge.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4 0c-1.105 0-2 .895-2 2s.895 2 2 2 2-.895 2-2-.895-2-2-2zm-1 4.813v3.188l1-1 1 1v-3.188c-.31.11-.65.188-1 .188s-.69-.077-1-.188z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/ban.svg b/src/net/sourceforge/plantuml/openiconic/data/ban.svg
new file mode 100644
index 0000000..3b701c3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/ban.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4 0c-2.203 0-4 1.797-4 4 0 2.203 1.797 4 4 4 2.203 0 4-1.797 4-4 0-2.203-1.797-4-4-4zm0 1c.655 0 1.258.209 1.75.563l-4.188 4.188c-.353-.492-.563-1.095-.563-1.75 0-1.663 1.337-3 3-3zm2.438 1.25c.353.492.563 1.095.563 1.75 0 1.663-1.337 3-3 3-.655 0-1.258-.209-1.75-.563l4.188-4.188z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/bar-chart.svg b/src/net/sourceforge/plantuml/openiconic/data/bar-chart.svg
new file mode 100644
index 0000000..a1cde5a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/bar-chart.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 0v7h8v-1h-7v-6h-1zm5 0v5h2v-5h-2zm-3 2v3h2v-3h-2z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/basket.svg b/src/net/sourceforge/plantuml/openiconic/data/basket.svg
new file mode 100644
index 0000000..39f16f2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/basket.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M3.969 0c-.127.011-.259.083-.344.188l-2.344 2.813h-1.281v1h1v3.656c0 .18.164.344.344.344h5.313c.18 0 .344-.164.344-.344v-3.656h1v-1h-1.281c-.274-.329-2.387-2.866-2.406-2.875-.105-.09-.216-.136-.344-.125zm.031 1.281l1.438 1.719h-2.875l1.438-1.719zm-1.5 3.719c.28 0 .5.22.5.5v1c0 .28-.22.5-.5.5s-.5-.22-.5-.5v-1c0-.28.22-.5.5-.5zm3 0c.28 0 .5.22.5.5v1c0 .28-.22.5-.5.5s-.5-.22-.5-.5v-1c0-.28.22-.5.5-.5z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/battery-empty.svg b/src/net/sourceforge/plantuml/openiconic/data/battery-empty.svg
new file mode 100644
index 0000000..844a415
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/battery-empty.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M.094 1c-.06 0-.094.034-.094.094v5.813c0 .06.034.094.094.094h6.813c.06 0 .094-.034.094-.094v-1.906h1v-2h-1v-1.906c0-.06-.034-.094-.094-.094h-6.813zm.906 1h5v4h-5v-4z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/battery-full.svg b/src/net/sourceforge/plantuml/openiconic/data/battery-full.svg
new file mode 100644
index 0000000..ea757ee
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/battery-full.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M.094 1c-.06 0-.094.034-.094.094v5.813c0 .06.034.094.094.094h6.813c.06 0 .094-.034.094-.094v-1.906h1v-2h-1v-1.906c0-.06-.034-.094-.094-.094h-6.813z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/beaker.svg b/src/net/sourceforge/plantuml/openiconic/data/beaker.svg
new file mode 100644
index 0000000..7083b1c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/beaker.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M1.344 0a.502.502 0 0 0 .156 1h.5v1.406c-.088.172-1.194 2.313-1.656 3.094-.153.268-.344.612-.344 1.063 0 .383.139.764.406 1.031.26.26.643.406 1.031.406h5.125c.383 0 .764-.139 1.031-.406.26-.26.406-.643.406-1.031 0-.452-.194-.801-.344-1.063-.463-.78-1.568-2.922-1.656-3.094v-1.406h.5a.5.5 0 1 0 0-1h-5a.5.5 0 0 0-.094 0 .502.502 0 0 0-.063 0zm1.656 1h2v1.625l.063.094s.652 1.233 1.219 2.281h-4.563c.567-1.049 1.219-2.281 1.219-2.281l.063-.094v-1.625z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/bell.svg b/src/net/sourceforge/plantuml/openiconic/data/bell.svg
new file mode 100644
index 0000000..68b17ca
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/bell.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4 0c-1.1 0-2 .9-2 2 0 1.04-.524 1.976-1.344 2.656-.42.34-.656.824-.656 1.344h8c0-.52-.236-1.004-.656-1.344-.82-.68-1.344-1.616-1.344-2.656 0-1.1-.9-2-2-2zm-1 7c0 .55.45 1 1 1s1-.45 1-1h-2z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/bluetooth.svg b/src/net/sourceforge/plantuml/openiconic/data/bluetooth.svg
new file mode 100644
index 0000000..6c80231
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/bluetooth.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M2.5 0v2.5l-.75-.75-.75.75 1.5 1.5-1.5 1.5.75.75.75-.75v2.5h.5l3.5-2.5-2.25-1.531 2.25-1.469-3.5-2.5h-.5zm1 1.5l1.5 1-1.5 1v-2zm0 3l1.5 1-1.5 1v-2z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/bold.svg b/src/net/sourceforge/plantuml/openiconic/data/bold.svg
new file mode 100644
index 0000000..60afa80
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/bold.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 0v1c.55 0 1 .45 1 1v4c0 .55-.45 1-1 1v1h5.5c1.38 0 2.5-1.12 2.5-2.5 0-1-.588-1.85-1.438-2.25.27-.34.438-.78.438-1.25 0-1.1-.9-2-2-2h-5zm3 1h1c.55 0 1 .45 1 1s-.45 1-1 1h-1v-2zm0 3h1.5c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5h-1.5v-3z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/bolt.svg b/src/net/sourceforge/plantuml/openiconic/data/bolt.svg
new file mode 100644
index 0000000..1bfe8de
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/bolt.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4 0l-3 5h2v3l3-5h-2v-3z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/book.svg b/src/net/sourceforge/plantuml/openiconic/data/book.svg
new file mode 100644
index 0000000..d69afa4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/book.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M1 0l-.188.031c-.39.08-.701.391-.781.781l-.031.188v5.5c0 .83.67 1.5 1.5 1.5h5.5v-1h-5.5c-.28 0-.5-.22-.5-.5s.22-.5.5-.5h5.5v-5.5c0-.28-.22-.5-.5-.5h-.5v3l-1-1-1 1v-3h-3z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/bookmark.svg b/src/net/sourceforge/plantuml/openiconic/data/bookmark.svg
new file mode 100644
index 0000000..586cf4d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/bookmark.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M2 0v8l2-2 2 2v-8h-4z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/box.svg b/src/net/sourceforge/plantuml/openiconic/data/box.svg
new file mode 100644
index 0000000..771adc4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/box.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 0v1h8v-1h-8zm0 2v5.906c0 .06.034.094.094.094h7.813c.06 0 .094-.034.094-.094v-5.906h-2.969v1.031h-2.031v-1.031h-3z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/briefcase.svg b/src/net/sourceforge/plantuml/openiconic/data/briefcase.svg
new file mode 100644
index 0000000..43a6d64
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/briefcase.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M3 0c-.554 0-1 .458-1 1v1h-1.906c-.06 0-.094.034-.094.094v2.406c0 .28.22.5.5.5h7c.28 0 .5-.22.5-.5v-2.406c0-.06-.034-.094-.094-.094h-1.906v-1c0-.542-.446-1-1-1h-2zm0 1h2v1h-2v-1zm-3 4.906v2c0 .06.034.094.094.094h7.813c.06 0 .094-.034.094-.094v-2c-.16.05-.32.094-.5.094h-7c-.18 0-.34-.044-.5-.094z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/british-pound.svg b/src/net/sourceforge/plantuml/openiconic/data/british-pound.svg
new file mode 100644
index 0000000..af29a2e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/british-pound.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4 0c-.619 0-1.159.262-1.5.688-.341.426-.5.986-.5 1.563 0 .692.165 1.245.25 1.75h-1.25v1h1.219c-.112.448-.37.964-1.063 1.656l-.156.125v1.219h6v-1h-4.906c.641-.729.982-1.397 1.125-2h1.781v-1h-1.719c-.078-.683-.281-1.242-.281-1.75 0-.394.115-.731.281-.938.166-.207.368-.313.719-.313.394 0 .609.109.75.25.141.141.25.356.25.75h1c0-.576-.165-1.102-.531-1.469-.366-.366-.893-.531-1.469-.531z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/browser.svg b/src/net/sourceforge/plantuml/openiconic/data/browser.svg
new file mode 100644
index 0000000..8a23116
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/browser.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M.344 0a.5.5 0 0 0-.344.5v7a.5.5 0 0 0 .5.5h7a.5.5 0 0 0 .5-.5v-7a.5.5 0 0 0-.5-.5h-7a.5.5 0 0 0-.094 0 .5.5 0 0 0-.063 0zm1.156 1c.28 0 .5.22.5.5s-.22.5-.5.5-.5-.22-.5-.5.22-.5.5-.5zm2 0h3c.28 0 .5.22.5.5s-.22.5-.5.5h-3c-.28 0-.5-.22-.5-.5s.22-.5.5-.5zm-2.5 2h6v4h-6v-4z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/brush.svg b/src/net/sourceforge/plantuml/openiconic/data/brush.svg
new file mode 100644
index 0000000..2fd9f8d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/brush.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M7.438.031l-.063.031-3.75 2.656-.125.156-.125.25c.719.229 1.271.781 1.5 1.5l.25-.125c.05-.02.126-.075.156-.125l2.656-3.75c.03-.04.04-.116 0-.156l-.406-.406-.094-.031zm-4.781 3.969c-.73 0-1.313.614-1.313 1.344 0 .99-.544 1.821-1.344 2.281.4.23.864.375 1.344.375 1.48 0 2.656-1.176 2.656-2.656 0-.73-.604-1.344-1.344-1.344z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/bug.svg b/src/net/sourceforge/plantuml/openiconic/data/bug.svg
new file mode 100644
index 0000000..e1f6ca4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/bug.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M3.5 0c-1.19 0-1.978 1.69-1.188 2.5l-.281.219-1.313-.656a.5.5 0 0 0-.344-.063.5.5 0 0 0-.094.938l1.156.563c-.09.156-.186.328-.25.5h-.688a.5.5 0 0 0-.094 0 .502.502 0 1 0 .094 1h.5c0 .227.023.445.063.656l-.781.406a.5.5 0 1 0 .438.875l.656-.344c.245.46.59.844 1 1.094.35-.19.625-.439.625-.719v-1.438a.5.5 0 0 0 0-.094v-.813a.5.5 0 0 0 0-.219c.045-.231.254-.406.5-.406.28 0 .5.22.5.5v.875a.5.5 0 0 0 0 .094v.063a.5.5 0 0 0 0 .094v1.344c0 .27.275.497.625.688.41-.245.755-.604 1-1.063l.656.344a.5.5 0 1 0 .438-.875l-.781-.406c.04-.211.063-.429.063-.656h.5a.5.5 0 1 0 0-1h-.688c-.064-.172-.16-.344-.25-.5l1.156-.563a.5.5 0 0 0-.313-.938.5.5 0 0 0-.125.063l-1.313.656-.281-.219c.78-.83.003-2.5-1.188-2.5z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/bullhorn.svg b/src/net/sourceforge/plantuml/openiconic/data/bullhorn.svg
new file mode 100644
index 0000000..288f25f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/bullhorn.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M6.094 0l-.094.031v5.969h.907c.06 0 .094-.034.094-.094v-5.813c0-.06-.034-.094-.094-.094h-.813zm-1.094.5l-2.906 1.469-.188.031h-1.813c-.06 0-.094.034-.094.094v1.813c0 .06.034.094.094.094h.906l1.031 2.719c.11.25.406.36.656.25.25-.11.36-.406.25-.656l-.719-1.781c.033-.136.136-.25.281-.25v-.031l2.5 1.25v-5z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/calculator.svg b/src/net/sourceforge/plantuml/openiconic/data/calculator.svg
new file mode 100644
index 0000000..8b7b3c4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/calculator.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M.094 0c-.06 0-.094.034-.094.094v7.813c0 .06.034.094.094.094h6.813c.06 0 .094-.034.094-.094v-7.813c0-.06-.034-.094-.094-.094h-6.813zm.906 1h5v2h-5v-2zm0 3h1v1h-1v-1zm2 0h1v1h-1v-1zm2 0h1v3h-1v-3zm-4 2h1v1h-1v-1zm2 0h1v1h-1v-1z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/calendar.svg b/src/net/sourceforge/plantuml/openiconic/data/calendar.svg
new file mode 100644
index 0000000..48b394a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/calendar.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 0v2h7v-2h-7zm0 3v4.906c0 .06.034.094.094.094h6.813c.06 0 .094-.034.094-.094v-4.906h-7zm1 1h1v1h-1v-1zm2 0h1v1h-1v-1zm2 0h1v1h-1v-1zm-4 2h1v1h-1v-1zm2 0h1v1h-1v-1z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/camera-slr.svg b/src/net/sourceforge/plantuml/openiconic/data/camera-slr.svg
new file mode 100644
index 0000000..704f920
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/camera-slr.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4.094 0c-.06 0-.105.044-.125.094l-.938 1.813c-.02.05-.065.094-.125.094h-1.406c-.83 0-1.5.67-1.5 1.5v4.406c0 .06.034.094.094.094h7.813c.06 0 .094-.034.094-.094v-5.813c0-.06-.034-.094-.094-.094h-.813c-.06 0-.105-.044-.125-.094l-.938-1.813c-.02-.05-.065-.094-.125-.094h-1.813zm-2.594 3c.28 0 .5.22.5.5s-.22.5-.5.5-.5-.22-.5-.5.22-.5.5-.5zm3.5 0c1.1 0 2 .9 2 2s-.9 2-2 2-2-.9-2-2 .9-2 2-2zm0 1c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/caret-bottom.svg b/src/net/sourceforge/plantuml/openiconic/data/caret-bottom.svg
new file mode 100644
index 0000000..ac894c7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/caret-bottom.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 2l4 4 4-4h-8z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/caret-left.svg b/src/net/sourceforge/plantuml/openiconic/data/caret-left.svg
new file mode 100644
index 0000000..5912663
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/caret-left.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M6 0l-4 4 4 4v-8z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/caret-right.svg b/src/net/sourceforge/plantuml/openiconic/data/caret-right.svg
new file mode 100644
index 0000000..b69354e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/caret-right.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M2 0v8l4-4-4-4z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/caret-top.svg b/src/net/sourceforge/plantuml/openiconic/data/caret-top.svg
new file mode 100644
index 0000000..2a12b0b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/caret-top.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4 2l-4 4h8l-4-4z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/cart.svg b/src/net/sourceforge/plantuml/openiconic/data/cart.svg
new file mode 100644
index 0000000..a8dd9b5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/cart.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M.344 0a.502.502 0 0 0 .156 1h1.5l.094.25.406 1.25.406 1.25c.04.13.204.25.344.25h3.5c.14 0 .304-.12.344-.25l.813-2.531c.04-.12-.016-.219-.156-.219h-4.438l-.375-.719a.5.5 0 0 0-.438-.281h-2a.5.5 0 0 0-.094 0 .502.502 0 0 0-.063 0zm3.156 5c-.276 0-.5.224-.5.5s.224.5.5.5.5-.224.5-.5-.224-.5-.5-.5zm3 0c-.276 0-.5.224-.5.5s.224.5.5.5.5-.224.5-.5-.224-.5-.5-.5z"
+ transform="translate(0 1)" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/chat.svg b/src/net/sourceforge/plantuml/openiconic/data/chat.svg
new file mode 100644
index 0000000..e1a1da0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/chat.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 0v5l1-1h1v-3h3v-1h-5zm3 2v4h4l1 1v-5h-5z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/check.svg b/src/net/sourceforge/plantuml/openiconic/data/check.svg
new file mode 100644
index 0000000..61368e4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/check.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M6.406 1l-.719.688-2.781 2.781-.781-.781-.719-.688-1.406 1.406.688.719 1.5 1.5.719.688.719-.688 3.5-3.5.688-.719-1.406-1.406z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/chevron-bottom.svg b/src/net/sourceforge/plantuml/openiconic/data/chevron-bottom.svg
new file mode 100644
index 0000000..6b66869
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/chevron-bottom.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M1.5 1l-1.5 1.5 4 4 4-4-1.5-1.5-2.5 2.5-2.5-2.5z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/chevron-left.svg b/src/net/sourceforge/plantuml/openiconic/data/chevron-left.svg
new file mode 100644
index 0000000..0210e22
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/chevron-left.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M5 0l-4 4 4 4 1.5-1.5-2.5-2.5 2.5-2.5-1.5-1.5z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/chevron-right.svg b/src/net/sourceforge/plantuml/openiconic/data/chevron-right.svg
new file mode 100644
index 0000000..1310503
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/chevron-right.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M2.5 0l-1.5 1.5 2.5 2.5-2.5 2.5 1.5 1.5 4-4-4-4z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/chevron-top.svg b/src/net/sourceforge/plantuml/openiconic/data/chevron-top.svg
new file mode 100644
index 0000000..e3f2f14
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/chevron-top.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4 1l-4 4 1.5 1.5 2.5-2.5 2.5 2.5 1.5-1.5-4-4z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/circle-check.svg b/src/net/sourceforge/plantuml/openiconic/data/circle-check.svg
new file mode 100644
index 0000000..a995328
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/circle-check.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4 0c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm2 1.781l.719.719-3.219 3.219-1.719-1.719.719-.719 1 1 2.5-2.5z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/circle-x.svg b/src/net/sourceforge/plantuml/openiconic/data/circle-x.svg
new file mode 100644
index 0000000..e5cf16a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/circle-x.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4 0c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm-1.5 1.781l1.5 1.5 1.5-1.5.719.719-1.5 1.5 1.5 1.5-.719.719-1.5-1.5-1.5 1.5-.719-.719 1.5-1.5-1.5-1.5.719-.719z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/clipboard.svg b/src/net/sourceforge/plantuml/openiconic/data/clipboard.svg
new file mode 100644
index 0000000..6b0be4d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/clipboard.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M3.5 0c-.28 0-.5.22-.5.5v.5h-.75c-.14 0-.25.11-.25.25v.75h3v-.75c0-.14-.11-.25-.25-.25h-.75v-.5c0-.28-.22-.5-.5-.5zm-3.25 1c-.14 0-.25.11-.25.25v6.5c0 .14.11.25.25.25h6.5c.14 0 .25-.11.25-.25v-6.5c0-.14-.11-.25-.25-.25h-.75v2h-5v-2h-.75z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/clock.svg b/src/net/sourceforge/plantuml/openiconic/data/clock.svg
new file mode 100644
index 0000000..4d198bc
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/clock.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4 0c-2.203 0-4 1.797-4 4 0 2.203 1.797 4 4 4 2.203 0 4-1.797 4-4 0-2.203-1.797-4-4-4zm0 1c1.663 0 3 1.337 3 3s-1.337 3-3 3-3-1.337-3-3 1.337-3 3-3zm-.5 1v2.219l.156.125.5.5.344.375.719-.719-.375-.344-.344-.344v-1.813h-1z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/cloud-download.svg b/src/net/sourceforge/plantuml/openiconic/data/cloud-download.svg
new file mode 100644
index 0000000..d6158cb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/cloud-download.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4.5 0c-1.21 0-2.27.86-2.5 2-1.1 0-2 .9-2 2 0 .37.111.7.281 1h2.719v-.5c0-.83.67-1.5 1.5-1.5s1.5.67 1.5 1.5v.5h1.906c.05-.16.094-.32.094-.5 0-.65-.42-1.29-1-1.5v-.5c0-1.38-1.12-2.5-2.5-2.5zm-.156 4a.5.5 0 0 0-.344.5v1.5h-1.5l2 2 2-2h-1.5v-1.5a.5.5 0 0 0-.594-.5.5.5 0 0 0-.063 0z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/cloud-upload.svg b/src/net/sourceforge/plantuml/openiconic/data/cloud-upload.svg
new file mode 100644
index 0000000..6d3697f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/cloud-upload.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4.5 0c-1.21 0-2.27.86-2.5 2-1.1 0-2 .9-2 2 0 .37.111.7.281 1h2.219l2-2 2 2h1.406c.05-.16.094-.32.094-.5 0-.65-.42-1.29-1-1.5v-.5c0-1.38-1.12-2.5-2.5-2.5zm0 4.5l-2.5 2.5h2v.5a.5.5 0 1 0 1 0v-.5h2l-2.5-2.5z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/cloud.svg b/src/net/sourceforge/plantuml/openiconic/data/cloud.svg
new file mode 100644
index 0000000..01c3d54
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/cloud.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4.5 1c-1.21 0-2.27.86-2.5 2-1.1 0-2 .9-2 2s.9 2 2 2h4.5c.83 0 1.5-.67 1.5-1.5 0-.65-.42-1.29-1-1.5v-.5c0-1.38-1.12-2.5-2.5-2.5z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/cloudy.svg b/src/net/sourceforge/plantuml/openiconic/data/cloudy.svg
new file mode 100644
index 0000000..1595b28
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/cloudy.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M2.5 0c-1.38 0-2.5 1.12-2.5 2.5 0 .39.09.743.25 1.063.3-.21.63-.379 1-.469.55-1.25 1.82-2.084 3.25-2.094-.46-.6-1.18-1-2-1zm2 2c-1.21 0-2.27.86-2.5 2-1.1 0-2 .9-2 2s.9 2 2 2h4.5c.83 0 1.5-.67 1.5-1.5 0-.65-.42-1.29-1-1.5v-.5c0-1.38-1.12-2.5-2.5-2.5z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/code.svg b/src/net/sourceforge/plantuml/openiconic/data/code.svg
new file mode 100644
index 0000000..96d9bf4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/code.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M5 1l-3 6h1l3-6h-1zm-4 1l-1 2 1 2h1l-1-2 1-2h-1zm5 0l1 2-1 2h1l1-2-1-2h-1z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/cog.svg b/src/net/sourceforge/plantuml/openiconic/data/cog.svg
new file mode 100644
index 0000000..6f49741
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/cog.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M3.5 0l-.5 1.188-.281.125-1.188-.5-.719.719.5 1.188-.125.281-1.188.5v1l1.188.5.125.313-.5 1.156.719.719 1.188-.5.281.125.5 1.188h1l.5-1.188.281-.125 1.188.5.719-.719-.5-1.188.125-.281 1.188-.5v-1l-1.188-.5-.125-.281.469-1.188-.688-.719-1.188.5-.281-.125-.5-1.188h-1zm.5 2.5c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5-1.5-.67-1.5-1.5.67-1.5 1.5-1.5z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/collapse-down.svg b/src/net/sourceforge/plantuml/openiconic/data/collapse-down.svg
new file mode 100644
index 0000000..47a37c5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/collapse-down.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 0v2h8v-2h-8zm2 3l2 2 2-2h-4zm-2 4v1h8v-1h-8z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/collapse-left.svg b/src/net/sourceforge/plantuml/openiconic/data/collapse-left.svg
new file mode 100644
index 0000000..31ef1d6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/collapse-left.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 0v8h1v-8h-1zm6 0v8h2v-8h-2zm-1 2l-2 2 2 2v-4z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/collapse-right.svg b/src/net/sourceforge/plantuml/openiconic/data/collapse-right.svg
new file mode 100644
index 0000000..6f104f6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/collapse-right.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 0v8h2v-8h-2zm7 0v8h1v-8h-1zm-4 2v4l2-2-2-2z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/collapse-up.svg b/src/net/sourceforge/plantuml/openiconic/data/collapse-up.svg
new file mode 100644
index 0000000..6693e1e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/collapse-up.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 0v1h8v-1h-8zm4 3l-2 2h4l-2-2zm-4 3v2h8v-2h-8z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/command.svg b/src/net/sourceforge/plantuml/openiconic/data/command.svg
new file mode 100644
index 0000000..ae05df6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/command.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M1.5 0c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5h.5v1h-.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5v-.5h1v.5c0 .83.67 1.5 1.5 1.5s1.5-.67 1.5-1.5-.67-1.5-1.5-1.5h-.5v-1h.5c.83 0 1.5-.67 1.5-1.5s-.67-1.5-1.5-1.5-1.5.67-1.5 1.5v.5h-1v-.5c0-.83-.67-1.5-1.5-1.5zm0 1c.28 0 .5.22.5.5v.5h-.5c-.28 0-.5-.22-.5-.5s.22-.5.5-.5zm4 0c.28 0 .5.22.5.5s-.22.5-.5.5h-.5v-.5c0-.28.22-.5.5-.5zm-2.5 2h1v1h-1v-1zm-1.5 2h.5v.5c0 .28-.22.5-.5.5s-.5-.22-.5-.5.22-.5.5-.5zm3.5 0h.5c.28 0 .5.22.5.5s-.22.5-.5.5-.5-.22-.5-.5v-.5z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/comment-square.svg b/src/net/sourceforge/plantuml/openiconic/data/comment-square.svg
new file mode 100644
index 0000000..f04e55d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/comment-square.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M.094 0c-.06 0-.094.034-.094.094v5.813c0 .06.034.094.094.094h5.906l2 2v-7.906c0-.06-.034-.094-.094-.094h-7.813z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/compass.svg b/src/net/sourceforge/plantuml/openiconic/data/compass.svg
new file mode 100644
index 0000000..488b375
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/compass.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4 0c-2.203 0-4 1.797-4 4 0 2.203 1.797 4 4 4 2.203 0 4-1.797 4-4 0-2.203-1.797-4-4-4zm0 1c1.663 0 3 1.337 3 3s-1.337 3-3 3-3-1.337-3-3 1.337-3 3-3zm2 1l-3 1-1 3 3-1 1-3zm-2 1.5c.28 0 .5.22.5.5s-.22.5-.5.5-.5-.22-.5-.5.22-.5.5-.5z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/contrast.svg b/src/net/sourceforge/plantuml/openiconic/data/contrast.svg
new file mode 100644
index 0000000..126505d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/contrast.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4 0c-2.203 0-4 1.797-4 4 0 2.203 1.797 4 4 4 2.203 0 4-1.797 4-4 0-2.203-1.797-4-4-4zm0 1c1.663 0 3 1.337 3 3s-1.337 3-3 3v-6z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/copywriting.svg b/src/net/sourceforge/plantuml/openiconic/data/copywriting.svg
new file mode 100644
index 0000000..f1e7ddd
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/copywriting.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 0v1h8v-1h-8zm0 2v1h5v-1h-5zm0 3v1h8v-1h-8zm0 2v1h6v-1h-6zm7.5 0c-.276 0-.5.224-.5.5s.224.5.5.5.5-.224.5-.5-.224-.5-.5-.5z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/credit-card.svg b/src/net/sourceforge/plantuml/openiconic/data/credit-card.svg
new file mode 100644
index 0000000..aa9889b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/credit-card.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M.25 1c-.14 0-.25.11-.25.25v.75h8v-.75c0-.14-.11-.25-.25-.25h-7.5zm-.25 2v3.75c0 .14.11.25.25.25h7.5c.14 0 .25-.11.25-.25v-3.75h-8zm1 2h1v1h-1v-1zm2 0h1v1h-1v-1z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/crop.svg b/src/net/sourceforge/plantuml/openiconic/data/crop.svg
new file mode 100644
index 0000000..8a7f1eb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/crop.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M1 0v1h-1v1h1v5h5v1h1v-1h1v-1h-1v-4.5l1-1-.5-.5-1 1h-4.5v-1h-1zm1 2h3.5l-3.5 3.5v-3.5zm4 .5v3.5h-3.5l3.5-3.5z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/dashboard.svg b/src/net/sourceforge/plantuml/openiconic/data/dashboard.svg
new file mode 100644
index 0000000..484c41a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/dashboard.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4 0c-2.203 0-4 1.797-4 4 0 2.203 1.797 4 4 4 2.203 0 4-1.797 4-4 0-2.203-1.797-4-4-4zm0 1c1.663 0 3 1.337 3 3s-1.337 3-3 3-3-1.337-3-3 1.337-3 3-3zm0 1c-.276 0-.5.224-.5.5s.224.5.5.5.5-.224.5-.5-.224-.5-.5-.5zm-1.656 1a.5.5 0 0 0-.188.844l.906.906-.063.25c0 .552.448 1 1 1s1-.448 1-1-.448-1-1-1l-.25.063-.906-.906a.5.5 0 0 0-.438-.156.5.5 0 0 0-.063 0zm3.156 0c-.276 0-.5.224-.5.5s.224.5.5.5.5-.224.5-.5-.224-.5-.5-.5z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/data-transfer-download.svg b/src/net/sourceforge/plantuml/openiconic/data/data-transfer-download.svg
new file mode 100644
index 0000000..9f14f33
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/data-transfer-download.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M3 0v3h-2l3 3 3-3h-2v-3h-2zm-3 7v1h8v-1h-8z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/data-transfer-upload.svg b/src/net/sourceforge/plantuml/openiconic/data/data-transfer-upload.svg
new file mode 100644
index 0000000..5fb17fa
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/data-transfer-upload.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 0v1h8v-1h-8zm4 2l-3 3h2v3h2v-3h2l-3-3z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/delete.svg b/src/net/sourceforge/plantuml/openiconic/data/delete.svg
new file mode 100644
index 0000000..f11bdce
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/delete.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M2 1l-2 3 2 3h6v-6h-6zm1.5.781l1.5 1.5 1.5-1.5.719.719-1.5 1.5 1.5 1.5-.719.719-1.5-1.5-1.5 1.5-.719-.719 1.5-1.5-1.5-1.5.719-.719z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/dial.svg b/src/net/sourceforge/plantuml/openiconic/data/dial.svg
new file mode 100644
index 0000000..29930da
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/dial.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4 1c-2.201 0-4 1.799-4 4h1c0-1.659 1.341-3 3-3s3 1.341 3 3h1c0-2.201-1.799-4-4-4zm-.594 2.094c-.82.25-1.406 1.006-1.406 1.906 0 1.1.9 2 2 2s2-.9 2-2c0-.9-.586-1.656-1.406-1.906l-.594.875-.594-.875z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/document.svg b/src/net/sourceforge/plantuml/openiconic/data/document.svg
new file mode 100644
index 0000000..8e2ba05
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/document.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 0v8h7v-4h-4v-4h-3zm4 0v3h3l-3-3zm-3 2h1v1h-1v-1zm0 2h1v1h-1v-1zm0 2h4v1h-4v-1z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/dollar.svg b/src/net/sourceforge/plantuml/openiconic/data/dollar.svg
new file mode 100644
index 0000000..b0218ad
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/dollar.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M3 0v1h-.75c-.686 0-1.25.564-1.25 1.25v.5c0 .678.437 1.242 1.094 1.406l2.563.656c.143.036.344.296.344.438v.5c0 .134-.116.25-.25.25h-2.5c-.116 0-.212-.037-.25-.063v-.938h-1v1c0 .342.203.627.438.781.234.155.518.219.813.219h.75v1h1v-1h.75c.686 0 1.25-.564 1.25-1.25v-.5c0-.678-.437-1.242-1.094-1.406l-2.563-.656c-.143-.036-.344-.296-.344-.438v-.5c0-.134.116-.25.25-.25h2.5c.116 0 .212.037.25.063v.938h1v-1c0-.342-.203-.627-.438-.781-.234-.155-.518-.219-.813-.219h-.75v-1h-1z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/double-quote-sans-left.svg b/src/net/sourceforge/plantuml/openiconic/data/double-quote-sans-left.svg
new file mode 100644
index 0000000..0a7a626
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/double-quote-sans-left.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 1v6l3-3v-3h-3zm5 0v6l3-3v-3h-3z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/double-quote-sans-right.svg b/src/net/sourceforge/plantuml/openiconic/data/double-quote-sans-right.svg
new file mode 100644
index 0000000..49a8f39
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/double-quote-sans-right.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M3 1l-3 3v3h3v-6zm5 0l-3 3v3h3v-6z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/double-quote-serif-left.svg b/src/net/sourceforge/plantuml/openiconic/data/double-quote-serif-left.svg
new file mode 100644
index 0000000..92181bf
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/double-quote-serif-left.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M3 1c-1.651 0-3 1.349-3 3v3h3v-3h-2c0-1.109.891-2 2-2v-1zm5 0c-1.651 0-3 1.349-3 3v3h3v-3h-2c0-1.109.891-2 2-2v-1z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/double-quote-serif-right.svg b/src/net/sourceforge/plantuml/openiconic/data/double-quote-serif-right.svg
new file mode 100644
index 0000000..c704431
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/double-quote-serif-right.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 1v3h2c0 1.109-.891 2-2 2v1c1.651 0 3-1.349 3-3v-3h-3zm5 0v3h2c0 1.109-.891 2-2 2v1c1.651 0 3-1.349 3-3v-3h-3z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/droplet.svg b/src/net/sourceforge/plantuml/openiconic/data/droplet.svg
new file mode 100644
index 0000000..80e7baf
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/droplet.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4 0l-.344.344c-.11.11-2.656 2.685-2.656 4.875 0 1.65 1.35 3 3 3s3-1.35 3-3c0-2.19-2.546-4.765-2.656-4.875l-.344-.344zm-1.5 4.719c.28 0 .5.22.5.5 0 .55.45 1 1 1 .28 0 .5.22.5.5s-.22.5-.5.5c-1.1 0-2-.9-2-2 0-.28.22-.5.5-.5z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/eject.svg b/src/net/sourceforge/plantuml/openiconic/data/eject.svg
new file mode 100644
index 0000000..f7ff102
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/eject.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4 0l-4 5h8l-4-5zm-4 6v2h8v-2h-8z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/elevator.svg b/src/net/sourceforge/plantuml/openiconic/data/elevator.svg
new file mode 100644
index 0000000..639e1ff
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/elevator.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4 0l-3 3h6l-3-3zm-3 5l3 3 3-3h-6z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/ellipses.svg b/src/net/sourceforge/plantuml/openiconic/data/ellipses.svg
new file mode 100644
index 0000000..22f75f7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/ellipses.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 3v2h2v-2h-2zm3 0v2h2v-2h-2zm3 0v2h2v-2h-2z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/envelope-closed.svg b/src/net/sourceforge/plantuml/openiconic/data/envelope-closed.svg
new file mode 100644
index 0000000..c0cf265
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/envelope-closed.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 1v1l4 2 4-2v-1h-8zm0 2v4h8v-4l-4 2-4-2z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/envelope-open.svg b/src/net/sourceforge/plantuml/openiconic/data/envelope-open.svg
new file mode 100644
index 0000000..659390e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/envelope-open.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4 0l-4 2v6h8v-6l-4-2zm0 1.125l3 1.5v1.875l-3 1.5-3-1.5v-1.875l3-1.5zm-2 1.875v1l2 1 2-1v-1h-4z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/euro.svg b/src/net/sourceforge/plantuml/openiconic/data/euro.svg
new file mode 100644
index 0000000..854aa4d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/euro.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M5 0c-1.858 0-3.398 1.278-3.844 3h-1.906l-.25 1h2c0 .345.073.68.156 1h-1.969l-.188 1h2.563c.696 1.185 1.969 2 3.438 2 .734 0 1.407-.215 2-.563v-1.219c-.531.479-1.225.781-2 .781-.888 0-1.671-.392-2.219-1h2.219l.156-1h-2.969c-.113-.317-.188-.643-.188-1h3.344l.156-1h-3.313c.414-1.16 1.507-2 2.813-2 .655 0 1.258.209 1.75.563l.156-1.063c-.57-.313-1.213-.5-1.906-.5z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/excerpt.svg b/src/net/sourceforge/plantuml/openiconic/data/excerpt.svg
new file mode 100644
index 0000000..e83a3ee
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/excerpt.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 0v1h7v-1h-7zm0 2v1h5v-1h-5zm0 2v1h8v-1h-8zm0 2v1h1v-1h-1zm2 0v1h1v-1h-1zm2 0v1h1v-1h-1z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/expand-down.svg b/src/net/sourceforge/plantuml/openiconic/data/expand-down.svg
new file mode 100644
index 0000000..b1d8ed0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/expand-down.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 0v1h8v-1h-8zm2 2l2 2 2-2h-4zm-2 4v2h8v-2h-8z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/expand-left.svg b/src/net/sourceforge/plantuml/openiconic/data/expand-left.svg
new file mode 100644
index 0000000..380eae2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/expand-left.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 0v8h1v-8h-1zm6 0v8h2v-8h-2zm-4 2v4l2-2-2-2z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/expand-right.svg b/src/net/sourceforge/plantuml/openiconic/data/expand-right.svg
new file mode 100644
index 0000000..a75dadb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/expand-right.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 0v8h2v-8h-2zm7 0v8h1v-8h-1zm-1 2l-2 2 2 2v-4z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/expand-up.svg b/src/net/sourceforge/plantuml/openiconic/data/expand-up.svg
new file mode 100644
index 0000000..36c3973
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/expand-up.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 0v2h8v-2h-8zm4 4l-2 2h4l-2-2zm-4 3v1h8v-1h-8z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/external-link.svg b/src/net/sourceforge/plantuml/openiconic/data/external-link.svg
new file mode 100644
index 0000000..6fdc00c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/external-link.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 0v8h8v-2h-1v1h-6v-6h1v-1h-2zm4 0l1.5 1.5-2.5 2.5 1 1 2.5-2.5 1.5 1.5v-4h-4z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/eye.svg b/src/net/sourceforge/plantuml/openiconic/data/eye.svg
new file mode 100644
index 0000000..c68604c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/eye.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4.031 1c-2.53 0-4.031 3-4.031 3s1.501 3 4.031 3c2.47 0 3.969-3 3.969-3s-1.499-3-3.969-3zm-.031 1c1.1 0 2 .9 2 2s-.9 2-2 2-2-.9-2-2 .9-2 2-2zm0 1c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1c0-.1-.032-.191-.063-.281-.08.16-.237.281-.438.281-.28 0-.5-.22-.5-.5 0-.2.121-.357.281-.438-.09-.03-.181-.063-.281-.063z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/eyedropper.svg b/src/net/sourceforge/plantuml/openiconic/data/eyedropper.svg
new file mode 100644
index 0000000..600fdbc
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/eyedropper.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M3.313 0a.5.5 0 0 0-.188.844l.625.625-3.594 3.656-.156.156v2.719h2.719l.125-.156 3.656-3.656.625.656a.5.5 0 1 0 .719-.688l-.938-.938.656-.656c.59-.58.59-1.545 0-2.125-.56-.57-1.555-.57-2.125 0l-.656.656-.938-.938a.5.5 0 0 0-.469-.156.5.5 0 0 0-.063 0zm1.156 2.188l1.313 1.313-3.156 3.156-1.281-1.313 3.125-3.156z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/file.svg b/src/net/sourceforge/plantuml/openiconic/data/file.svg
new file mode 100644
index 0000000..145853d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/file.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 0v8h7v-4h-4v-4h-3zm4 0v3h3l-3-3z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/fire.svg b/src/net/sourceforge/plantuml/openiconic/data/fire.svg
new file mode 100644
index 0000000..9d33359
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/fire.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M2 0c1 2-2 3-2 5l2 3c-.98-1.98 2-3 2-5l-2-3zm3 3c1 2-2 3-2 5h3c.4 0 1-.5 1-2 0-2-2-3-2-3z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/flag.svg b/src/net/sourceforge/plantuml/openiconic/data/flag.svg
new file mode 100644
index 0000000..f2fde23
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/flag.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 0v8h1v-8h-1zm2 0v4h2v1h4l-2-1.969 2-2.031h-3v-1h-3z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/flash.svg b/src/net/sourceforge/plantuml/openiconic/data/flash.svg
new file mode 100644
index 0000000..18f7fc3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/flash.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M3.5 0l-1.5 3h2l-.656 2h-1.344l1 3 3-3h-1.5l1.5-3h-2l1-2h-1.5z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/folder.svg b/src/net/sourceforge/plantuml/openiconic/data/folder.svg
new file mode 100644
index 0000000..ef47dd6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/folder.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 0v2h8v-1h-5v-1h-3zm0 3v4.5c0 .28.22.5.5.5h7c.28 0 .5-.22.5-.5v-4.5h-8z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/fork.svg b/src/net/sourceforge/plantuml/openiconic/data/fork.svg
new file mode 100644
index 0000000..f494192
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/fork.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M1.5 0c-.828 0-1.5.672-1.5 1.5 0 .656.414 1.202 1 1.406v2.188c-.586.204-1 .75-1 1.406 0 .828.672 1.5 1.5 1.5s1.5-.672 1.5-1.5c0-.595-.341-1.101-.844-1.344.09-.09.205-.156.344-.156h2c.823 0 1.5-.677 1.5-1.5v-.594c.586-.204 1-.75 1-1.406 0-.828-.672-1.5-1.5-1.5s-1.5.672-1.5 1.5c0 .656.414 1.202 1 1.406v.594c0 .277-.223.5-.5.5h-2c-.171 0-.346.04-.5.094v-1.188c.586-.204 1-.75 1-1.406 0-.828-.672-1.5-1.5-1.5z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/fullscreen-enter.svg b/src/net/sourceforge/plantuml/openiconic/data/fullscreen-enter.svg
new file mode 100644
index 0000000..4efb890
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/fullscreen-enter.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 0v4l1.5-1.5 1.5 1.5 1-1-1.5-1.5 1.5-1.5h-4zm5 4l-1 1 1.5 1.5-1.5 1.5h4v-4l-1.5 1.5-1.5-1.5z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/fullscreen-exit.svg b/src/net/sourceforge/plantuml/openiconic/data/fullscreen-exit.svg
new file mode 100644
index 0000000..c57d8ad
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/fullscreen-exit.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M1 0l-1 1 1.5 1.5-1.5 1.5h4v-4l-1.5 1.5-1.5-1.5zm3 4v4l1.5-1.5 1.5 1.5 1-1-1.5-1.5 1.5-1.5h-4z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/globe.svg b/src/net/sourceforge/plantuml/openiconic/data/globe.svg
new file mode 100644
index 0000000..296c649
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/globe.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4 0c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm0 1c.333 0 .637.086.938.188-.214.197-.45.383-.406.563.04.18.688.13.688.5 0 .27-.425.346-.125.656.35.35-.636.978-.656 1.438-.03.83.841.969 1.531.969.424 0 .503.195.469.438-.546.758-1.438 1.25-2.438 1.25-.378 0-.729-.09-1.063-.219.224-.442-.313-1.344-.781-1.625-.226-.226-.689-.114-.969-.219-.092-.271-.178-.545-.188-.844.031-.05.081-.094.156-.094.19 0 .454.374.594.344.18-.04-.742-1.313-.313-1.563.2-.12.609.394.469-.156-.12-.51.366-.276.656-.406.26-.11.455-.414.125-.594l-.219-.188c.45-.27.972-.438 1.531-.438zm2.313 1.094c.184.222.323.481.438.75l-.188.219c-.29.27-.327-.212-.438-.313-.13-.11-.638.025-.688-.125-.077-.181.499-.418.875-.531z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/graph.svg b/src/net/sourceforge/plantuml/openiconic/data/graph.svg
new file mode 100644
index 0000000..8db4da0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/graph.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M7.031 0l-3.031 3-1-1-3 3.031 1 1 2-2.031 1 1 4-4-.969-1zm-7.031 7v1h8v-1h-8z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/grid-four-up.svg b/src/net/sourceforge/plantuml/openiconic/data/grid-four-up.svg
new file mode 100644
index 0000000..bdcc178
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/grid-four-up.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 0v1h1v-1h-1zm2 0v1h1v-1h-1zm2 0v1h1v-1h-1zm2 0v1h1v-1h-1zm-6 2v1h1v-1h-1zm2 0v1h1v-1h-1zm2 0v1h1v-1h-1zm2 0v1h1v-1h-1zm-6 2v1h1v-1h-1zm2 0v1h1v-1h-1zm2 0v1h1v-1h-1zm2 0v1h1v-1h-1zm-6 2v1h1v-1h-1zm2 0v1h1v-1h-1zm2 0v1h1v-1h-1zm2 0v1h1v-1h-1z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/grid-three-up.svg b/src/net/sourceforge/plantuml/openiconic/data/grid-three-up.svg
new file mode 100644
index 0000000..2a929a0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/grid-three-up.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 0v2h2v-2h-2zm3 0v2h2v-2h-2zm3 0v2h2v-2h-2zm-6 3v2h2v-2h-2zm3 0v2h2v-2h-2zm3 0v2h2v-2h-2zm-6 3v2h2v-2h-2zm3 0v2h2v-2h-2zm3 0v2h2v-2h-2z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/grid-two-up.svg b/src/net/sourceforge/plantuml/openiconic/data/grid-two-up.svg
new file mode 100644
index 0000000..71503ba
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/grid-two-up.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 0v3h3v-3h-3zm5 0v3h3v-3h-3zm-5 5v3h3v-3h-3zm5 0v3h3v-3h-3z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/hard-drive.svg b/src/net/sourceforge/plantuml/openiconic/data/hard-drive.svg
new file mode 100644
index 0000000..af63461
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/hard-drive.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M.188 0c-.11 0-.188.077-.188.188v3.313c0 .28.22.5.5.5h6c.28 0 .5-.22.5-.5v-3.313c0-.11-.077-.188-.188-.188h-6.625zm-.188 4.906v2.906c0 .11.077.188.188.188h6.625c.11 0 .188-.077.188-.188v-2.906c-.16.05-.32.094-.5.094h-6c-.18 0-.34-.044-.5-.094zm5.5 1.094c.28 0 .5.22.5.5s-.22.5-.5.5-.5-.22-.5-.5.22-.5.5-.5z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/header.svg b/src/net/sourceforge/plantuml/openiconic/data/header.svg
new file mode 100644
index 0000000..e794cc4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/header.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 0v1h.5c.28 0 .5.22.5.5v4c0 .28-.22.5-.5.5h-.5v1h3v-1h-.5c-.28 0-.5-.22-.5-.5v-1.5h3v1.5c0 .28-.22.5-.5.5h-.5v1h3v-1h-.5c-.28 0-.5-.22-.5-.5v-4c0-.28.22-.5.5-.5h.5v-1h-3v1h.5c.28 0 .5.22.5.5v1.5h-3v-1.5c0-.28.22-.5.5-.5h.5v-1h-3z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/headphones.svg b/src/net/sourceforge/plantuml/openiconic/data/headphones.svg
new file mode 100644
index 0000000..fc44be9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/headphones.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4 0c-1.651 0-3 1.349-3 3v1h-.5a.5.5 0 0 0-.5.5v2a.5.5 0 0 0 .5.5h1a.5.5 0 0 0 .5-.5v-3.5c0-1.109.891-2 2-2s2 .891 2 2v3.5a.5.5 0 0 0 .5.5h1a.5.5 0 0 0 .5-.5v-2a.5.5 0 0 0-.5-.5h-.5v-1c0-1.651-1.349-3-3-3z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/heart.svg b/src/net/sourceforge/plantuml/openiconic/data/heart.svg
new file mode 100644
index 0000000..7c060cf
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/heart.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M2 1c-.55 0-1.046.224-1.406.594-.37.36-.594.856-.594 1.406 0 .55.224 1.046.594 1.406l3.406 3.438 3.406-3.438c.37-.37.594-.856.594-1.406 0-.55-.224-1.046-.594-1.406-.36-.37-.856-.594-1.406-.594-.55 0-1.046.224-1.406.594-.37.36-.594.856-.594 1.406 0-.55-.224-1.046-.594-1.406-.36-.37-.856-.594-1.406-.594z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/home.svg b/src/net/sourceforge/plantuml/openiconic/data/home.svg
new file mode 100644
index 0000000..e6cc83a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/home.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4 0l-4 3h1v4h2v-2h2v2h2v-4.031l1 .031-4-3z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/image.svg b/src/net/sourceforge/plantuml/openiconic/data/image.svg
new file mode 100644
index 0000000..fa9a105
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/image.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 0v8h8v-8h-8zm1 1h6v3l-1-1-1 1 2 2v1h-1l-4-4-1 1v-3z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/inbox.svg b/src/net/sourceforge/plantuml/openiconic/data/inbox.svg
new file mode 100644
index 0000000..72797fd
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/inbox.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M.188 0c-.11 0-.188.077-.188.188v7.625c0 .11.077.188.188.188h7.625c.11 0 .188-.077.188-.188v-7.625c0-.11-.077-.188-.188-.188h-7.625zm.813 2h6v3h-1l-1 1h-2l-1-1h-1v-3z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/infinity.svg b/src/net/sourceforge/plantuml/openiconic/data/infinity.svg
new file mode 100644
index 0000000..5820ca5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/infinity.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M2 2c-1.31 0-2 1.01-2 2s.69 2 2 2c.79 0 1.42-.559 2-1.219.58.66 1.19 1.219 2 1.219 1.31 0 2-1.01 2-2s-.69-2-2-2c-.81 0-1.42.559-2 1.219-.57-.66-1.21-1.219-2-1.219zm0 1c.42 0 .884.47 1.344 1-.46.53-.924 1-1.344 1-.74 0-1-.54-1-1 0-.46.26-1 1-1zm4 0c.74 0 1 .54 1 1 0 .46-.26 1-1 1-.43 0-.894-.47-1.344-1 .45-.53.914-1 1.344-1z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/info.svg b/src/net/sourceforge/plantuml/openiconic/data/info.svg
new file mode 100644
index 0000000..6927b24
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/info.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M5 0c-.552 0-1 .448-1 1s.448 1 1 1 1-.448 1-1-.448-1-1-1zm-1.5 2.5c-.83 0-1.5.67-1.5 1.5h1c0-.28.22-.5.5-.5s.5.22.5.5-1 1.64-1 2.5c0 .86.67 1.5 1.5 1.5s1.5-.67 1.5-1.5h-1c0 .28-.22.5-.5.5s-.5-.22-.5-.5c0-.36 1-1.84 1-2.5 0-.81-.67-1.5-1.5-1.5z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/italic.svg b/src/net/sourceforge/plantuml/openiconic/data/italic.svg
new file mode 100644
index 0000000..381c08f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/italic.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M2 0v1h1.625l-.063.125-2 5-.344.875h-1.219v1h5v-1h-1.625l.063-.125 2-5 .344-.875h1.219v-1h-5z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/justify-center.svg b/src/net/sourceforge/plantuml/openiconic/data/justify-center.svg
new file mode 100644
index 0000000..544162c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/justify-center.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 0v1h8v-1h-8zm0 2v1h8v-1h-8zm0 2v1h8v-1h-8zm1 2v1h6v-1h-6z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/justify-left.svg b/src/net/sourceforge/plantuml/openiconic/data/justify-left.svg
new file mode 100644
index 0000000..e5787c3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/justify-left.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 0v1h8v-1h-8zm0 2v1h8v-1h-8zm0 2v1h8v-1h-8zm0 2v1h6v-1h-6z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/justify-right.svg b/src/net/sourceforge/plantuml/openiconic/data/justify-right.svg
new file mode 100644
index 0000000..2e8c6fd
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/justify-right.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 0v1h8v-1h-8zm0 2v1h8v-1h-8zm0 2v1h8v-1h-8zm2 2v1h6v-1h-6z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/key.svg b/src/net/sourceforge/plantuml/openiconic/data/key.svg
new file mode 100644
index 0000000..d870d61
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/key.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M5.5 0c-1.38 0-2.5 1.12-2.5 2.5 0 .16.033.297.063.438l-3.063 3.063v2h3v-2h2v-1l.063-.063c.14.03.277.063.438.063 1.38 0 2.5-1.12 2.5-2.5s-1.12-2.5-2.5-2.5zm.5 1c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/laptop.svg b/src/net/sourceforge/plantuml/openiconic/data/laptop.svg
new file mode 100644
index 0000000..1de7a54
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/laptop.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M1.344 0a.5.5 0 0 0-.344.5v3.5h-1v1.5c0 .28.22.5.5.5h7c.28 0 .5-.22.5-.5v-1.5h-1v-3.5a.5.5 0 0 0-.5-.5h-5a.5.5 0 0 0-.094 0 .5.5 0 0 0-.063 0zm.656 1h4v3h-1v1h-2v-1h-1v-3z" transform="translate(0 1)" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/layers.svg b/src/net/sourceforge/plantuml/openiconic/data/layers.svg
new file mode 100644
index 0000000..564c4ae
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/layers.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 0v4h4v-4h-4zm5 2v3h-3v1h4v-4h-1zm2 2v3h-3v1h4v-4h-1z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/lightbulb.svg b/src/net/sourceforge/plantuml/openiconic/data/lightbulb.svg
new file mode 100644
index 0000000..9ae5b0b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/lightbulb.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M3.406 0a.5.5 0 0 0-.125.063l-3 1.5a.5.5 0 1 0 .438.875l3-1.5a.5.5 0 0 0-.313-.938zm1 1.5a.5.5 0 0 0-.125.063l-4 2a.5.5 0 1 0 .438.875l4-2a.5.5 0 0 0-.313-.938zm0 2a.5.5 0 0 0-.125.063l-3 1.5a.5.5 0 0 0 .219.938h2a.502.502 0 0 0 .156-1l1.063-.563a.5.5 0 0 0-.313-.938zm-2.563 3.5a.502.502 0 0 0 .156 1h1a.5.5 0 1 0 0-1h-1a.5.5 0 0 0-.094 0 .502.502 0 0 0-.063 0z"
+ transform="translate(1)" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/link-broken.svg b/src/net/sourceforge/plantuml/openiconic/data/link-broken.svg
new file mode 100644
index 0000000..e1a933a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/link-broken.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M2 0v1h-1v1h2v-2h-1zm3.875.031c-.184.01-.354.03-.531.094-.27.095-.531.25-.75.469l-.438.438a.5.5 0 1 0 .688.688l.438-.438c.101-.101.245-.173.375-.219.352-.126.78-.064 1.063.219.395.389.4 1.037 0 1.438l-1.5 1.5a.5.5 0 1 0 .688.688l1.5-1.5c.78-.78.785-2.041 0-2.813-.279-.279-.606-.452-.969-.531-.181-.039-.379-.041-.563-.031zm-3.594 2.906a.5.5 0 0 0-.188.156l-1.5 1.5c-.78.78-.785 2.041 0 2.813.557.557 1.355.722 2.063.469.27-.095.531-.25.75-.469l.438-.438a.5.5 0 1 0-.688-.688l-.438.438c-.101.101-.245.173-.375.219-.352.126-.78.064-1.063-.219-.395-.389-.4-1.037 0-1.438l1.5-1.5a.5.5 0 0 0-.438-.844.5.5 0 0 0-.063 0zm2.719 3.063v2h1v-1h1v-1h-2z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/link-intact.svg b/src/net/sourceforge/plantuml/openiconic/data/link-intact.svg
new file mode 100644
index 0000000..1076eec
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/link-intact.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M5.875.031c-.184.01-.354.03-.531.094-.27.095-.531.25-.75.469a.5.5 0 1 0 .688.688c.101-.101.245-.173.375-.219.352-.126.78-.064 1.063.219.395.389.4 1.037 0 1.438l-1.5 1.5c-.434.434-.799.483-1.063.469-.264-.015-.406-.125-.406-.125a.504.504 0 1 0-.5.875s.34.222.844.25c.504.028 1.197-.165 1.813-.781l1.5-1.5c.78-.78.785-2.041 0-2.813-.279-.279-.606-.452-.969-.531-.181-.039-.379-.041-.563-.031zm-2 2.313c-.501-.019-1.186.155-1.781.75l-1.5 1.5c-.78.78-.785 2.041 0 2.813.557.557 1.355.722 2.063.469.27-.095.531-.25.75-.469a.5.5 0 1 0-.688-.688c-.101.101-.245.173-.375.219-.352.126-.78.064-1.063-.219-.395-.389-.4-1.037 0-1.438l1.5-1.5c.405-.405.752-.448 1.031-.438.279.011.469.094.469.094a.5.5 0 1 0 .438-.875s-.343-.199-.844-.219z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/list-rich.svg b/src/net/sourceforge/plantuml/openiconic/data/list-rich.svg
new file mode 100644
index 0000000..cf816d1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/list-rich.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 0v3h3v-3h-3zm4 0v1h4v-1h-4zm0 2v1h3v-1h-3zm-4 2v3h3v-3h-3zm4 0v1h4v-1h-4zm0 2v1h3v-1h-3z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/list.svg b/src/net/sourceforge/plantuml/openiconic/data/list.svg
new file mode 100644
index 0000000..241e5e0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/list.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M.5 0c-.276 0-.5.224-.5.5s.224.5.5.5.5-.224.5-.5-.224-.5-.5-.5zm1.5 0v1h6v-1h-6zm-1.5 2c-.276 0-.5.224-.5.5s.224.5.5.5.5-.224.5-.5-.224-.5-.5-.5zm1.5 0v1h6v-1h-6zm-1.5 2c-.276 0-.5.224-.5.5s.224.5.5.5.5-.224.5-.5-.224-.5-.5-.5zm1.5 0v1h6v-1h-6zm-1.5 2c-.276 0-.5.224-.5.5s.224.5.5.5.5-.224.5-.5-.224-.5-.5-.5zm1.5 0v1h6v-1h-6z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/location.svg b/src/net/sourceforge/plantuml/openiconic/data/location.svg
new file mode 100644
index 0000000..9fa01f2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/location.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M8 0l-8 4 3 1 1 3 4-8z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/lock-locked.svg b/src/net/sourceforge/plantuml/openiconic/data/lock-locked.svg
new file mode 100644
index 0000000..5306dc9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/lock-locked.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4 0c-1.099 0-2 .901-2 2v1h-1v4h6v-4h-1v-1c0-1.099-.901-2-2-2zm0 1c.561 0 1 .439 1 1v1h-2v-1c0-.561.439-1 1-1z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/lock-unlocked.svg b/src/net/sourceforge/plantuml/openiconic/data/lock-unlocked.svg
new file mode 100644
index 0000000..5ee3b20
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/lock-unlocked.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4 0c-1.099 0-2 .901-2 2h1c0-.561.439-1 1-1 .561 0 1 .439 1 1v2h-4v4h6v-4h-1v-2c0-1.099-.901-2-2-2z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/loop-circular.svg b/src/net/sourceforge/plantuml/openiconic/data/loop-circular.svg
new file mode 100644
index 0000000..fd720b9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/loop-circular.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4 1c-1.651 0-3 1.349-3 3h-1l1.5 2 1.5-2h-1c0-1.109.891-2 2-2v-1zm2.5 1l-1.5 2h1c0 1.109-.891 2-2 2v1c1.651 0 3-1.349 3-3h1l-1.5-2z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/loop-square.svg b/src/net/sourceforge/plantuml/openiconic/data/loop-square.svg
new file mode 100644
index 0000000..e052f40
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/loop-square.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M1 0v2h1v-1h4v2h-1l1.5 2.5 1.5-2.5h-1v-3h-6zm.5 2.5l-1.5 2.5h1v3h6v-2h-1v1h-4v-2h1l-1.5-2.5z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/loop.svg b/src/net/sourceforge/plantuml/openiconic/data/loop.svg
new file mode 100644
index 0000000..48f8975
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/loop.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M6 0v1h-5c-.554 0-1 .446-1 1v1h1v-1h5v1l2-1.5-2-1.5zm-4 4l-2 1.5 2 1.5v-1h5c.542 0 1-.458 1-1v-1h-1v1h-5v-1z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/magnifying-glass.svg b/src/net/sourceforge/plantuml/openiconic/data/magnifying-glass.svg
new file mode 100644
index 0000000..387f477
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/magnifying-glass.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M3.5 0c-1.927 0-3.5 1.573-3.5 3.5s1.573 3.5 3.5 3.5c.592 0 1.166-.145 1.656-.406a1 1 0 0 0 .125.125l1 1a1.016 1.016 0 1 0 1.438-1.438l-1-1a1 1 0 0 0-.156-.125c.266-.493.438-1.059.438-1.656 0-1.927-1.573-3.5-3.5-3.5zm0 1c1.387 0 2.5 1.113 2.5 2.5 0 .661-.241 1.273-.656 1.719l-.031.031a1 1 0 0 0-.125.125c-.442.397-1.043.625-1.688.625-1.387 0-2.5-1.113-2.5-2.5s1.113-2.5 2.5-2.5z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/map-marker.svg b/src/net/sourceforge/plantuml/openiconic/data/map-marker.svg
new file mode 100644
index 0000000..36841a3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/map-marker.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4 0c-1.66 0-3 1.34-3 3 0 2 3 5 3 5s3-3 3-5c0-1.66-1.34-3-3-3zm0 1c1.1 0 2 .9 2 2s-.9 2-2 2-2-.9-2-2 .9-2 2-2z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/map.svg b/src/net/sourceforge/plantuml/openiconic/data/map.svg
new file mode 100644
index 0000000..8c868c1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/map.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 0v8h8v-2.375a.5.5 0 0 0 0-.219v-5.406h-8zm1 1h6v4h-1.5a.5.5 0 0 0-.094 0 .502.502 0 1 0 .094 1h1.5v1h-6v-6zm2.5 1c-.83 0-1.5.67-1.5 1.5 0 1 1.5 2.5 1.5 2.5s1.5-1.5 1.5-2.5c0-.83-.67-1.5-1.5-1.5zm0 1c.28 0 .5.22.5.5s-.22.5-.5.5-.5-.22-.5-.5.22-.5.5-.5z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/media-pause.svg b/src/net/sourceforge/plantuml/openiconic/data/media-pause.svg
new file mode 100644
index 0000000..3b1bad8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/media-pause.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M1 1v6h2v-6h-2zm4 0v6h2v-6h-2z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/media-play.svg b/src/net/sourceforge/plantuml/openiconic/data/media-play.svg
new file mode 100644
index 0000000..7c4516d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/media-play.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M1 1v6l6-3-6-3z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/media-record.svg b/src/net/sourceforge/plantuml/openiconic/data/media-record.svg
new file mode 100644
index 0000000..a52bee3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/media-record.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4 1c-1.657 0-3 1.343-3 3s1.343 3 3 3 3-1.343 3-3-1.343-3-3-3z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/media-skip-backward.svg b/src/net/sourceforge/plantuml/openiconic/data/media-skip-backward.svg
new file mode 100644
index 0000000..e4feb43
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/media-skip-backward.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4 1l-4 3 4 3v-6zm0 3l4 3v-6l-4 3z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/media-skip-forward.svg b/src/net/sourceforge/plantuml/openiconic/data/media-skip-forward.svg
new file mode 100644
index 0000000..a7e7c10
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/media-skip-forward.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 1v6l4-3-4-3zm4 3v3l4-3-4-3v3z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/media-step-backward.svg b/src/net/sourceforge/plantuml/openiconic/data/media-step-backward.svg
new file mode 100644
index 0000000..2fc461b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/media-step-backward.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 1v6h2v-6h-2zm2 3l5 3v-6l-5 3z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/media-step-forward.svg b/src/net/sourceforge/plantuml/openiconic/data/media-step-forward.svg
new file mode 100644
index 0000000..ade1440
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/media-step-forward.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 1v6l5-3-5-3zm5 3v3h2v-6h-2v3z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/media-stop.svg b/src/net/sourceforge/plantuml/openiconic/data/media-stop.svg
new file mode 100644
index 0000000..e9df2f0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/media-stop.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M1 1v6h6v-6h-6z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/medical-cross.svg b/src/net/sourceforge/plantuml/openiconic/data/medical-cross.svg
new file mode 100644
index 0000000..71028f9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/medical-cross.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M2 0v2h-2v4h2v2h4v-2h2v-4h-2v-2h-4z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/menu.svg b/src/net/sourceforge/plantuml/openiconic/data/menu.svg
new file mode 100644
index 0000000..a96555d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/menu.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 1v1h8v-1h-8zm0 2.969v1h8v-1h-8zm0 3v1h8v-1h-8z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/microphone.svg b/src/net/sourceforge/plantuml/openiconic/data/microphone.svg
new file mode 100644
index 0000000..711e546
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/microphone.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M2.906-.031a1 1 0 0 0-.125.031 1 1 0 0 0-.781 1v2a1 1 0 1 0 2 0v-2a1 1 0 0 0-1.094-1.031zm-2.563 2.031a.5.5 0 0 0-.344.5v.5c0 1.476 1.091 2.693 2.5 2.938v1.063h-.5c-.55 0-1 .45-1 1h4c0-.55-.45-1-1-1h-.5v-1.063c1.409-.244 2.5-1.461 2.5-2.938v-.5a.5.5 0 1 0-1 0v.5c0 1.109-.891 2-2 2s-2-.891-2-2v-.5a.5.5 0 0 0-.594-.5.5.5 0 0 0-.063 0z"
+ transform="translate(1)" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/minus.svg b/src/net/sourceforge/plantuml/openiconic/data/minus.svg
new file mode 100644
index 0000000..83aa208
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/minus.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 3v2h8v-2h-8z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/monitor.svg b/src/net/sourceforge/plantuml/openiconic/data/monitor.svg
new file mode 100644
index 0000000..e4460cd
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/monitor.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M.344 0a.5.5 0 0 0-.344.5v5a.5.5 0 0 0 .5.5h2.5v1h-1c-.55 0-1 .45-1 1h6c0-.55-.45-1-1-1h-1v-1h2.5a.5.5 0 0 0 .5-.5v-5a.5.5 0 0 0-.5-.5h-7a.5.5 0 0 0-.094 0 .5.5 0 0 0-.063 0zm.656 1h6v4h-6v-4z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/moon.svg b/src/net/sourceforge/plantuml/openiconic/data/moon.svg
new file mode 100644
index 0000000..37408d1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/moon.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M2.719 0c-1.58.53-2.719 2.021-2.719 3.781 0 2.21 1.79 4 4 4 1.76 0 3.251-1.17 3.781-2.75-.4.14-.831.25-1.281.25-2.21 0-4-1.79-4-4 0-.44.079-.881.219-1.281z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/move.svg b/src/net/sourceforge/plantuml/openiconic/data/move.svg
new file mode 100644
index 0000000..4674db8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/move.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M3.5 0l-1.5 1.5h1v1.5h-1.5v-1l-1.5 1.5 1.5 1.5v-1h1.5v1.5h-1l1.5 1.5 1.5-1.5h-1v-1.5h1.5v1l1.5-1.5-1.5-1.5v1h-1.5v-1.5h1l-1.5-1.5z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/musical-note.svg b/src/net/sourceforge/plantuml/openiconic/data/musical-note.svg
new file mode 100644
index 0000000..9bbd65a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/musical-note.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M8 0c-5 0-6 1-6 1v4.094c-.154-.054-.327-.094-.5-.094-.828 0-1.5.672-1.5 1.5s.672 1.5 1.5 1.5 1.5-.672 1.5-1.5v-3.969c.732-.226 1.99-.438 4-.5v2.063c-.154-.054-.327-.094-.5-.094-.828 0-1.5.672-1.5 1.5s.672 1.5 1.5 1.5 1.5-.672 1.5-1.5v-5.5z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/paperclip.svg b/src/net/sourceforge/plantuml/openiconic/data/paperclip.svg
new file mode 100644
index 0000000..528f14f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/paperclip.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M5 0c-.514 0-1.021.201-1.406.594l-2.781 2.719c-1.07 1.07-1.07 2.805 0 3.875 1.07 1.07 2.805 1.07 3.875 0l1.25-1.25-.688-.688-.906.875-.344.375c-.69.69-1.81.69-2.5 0-.682-.682-.668-1.778 0-2.469l2.781-2.719v-.031c.389-.395 1.037-.4 1.438 0 .388.381.378 1.006 0 1.406l-2.5 2.469c-.095.095-.28.095-.375 0-.095-.095-.095-.28 0-.375l.375-.344.594-.625-.688-.688-.875.875-.094.094c-.485.485-.485 1.265 0 1.75.485.485 1.265.485 1.75 0l2.5-2.438c.78-.78.785-2.041 0-2.813-.39-.39-.893-.594-1.406-.594z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/pencil.svg b/src/net/sourceforge/plantuml/openiconic/data/pencil.svg
new file mode 100644
index 0000000..8109530
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/pencil.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M6 0l-1 1 2 2 1-1-2-2zm-2 2l-4 4v2h2l4-4-2-2z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/people.svg b/src/net/sourceforge/plantuml/openiconic/data/people.svg
new file mode 100644
index 0000000..2befc6b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/people.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M5.5 0c-.51 0-.949.355-1.219.875.45.54.719 1.275.719 2.125 0 .29-.034.574-.094.844.18.11.374.156.594.156.83 0 1.5-.9 1.5-2s-.67-2-1.5-2zm-3 1c-.828 0-1.5.895-1.5 2s.672 2 1.5 2 1.5-.895 1.5-2-.672-2-1.5-2zm4.75 3.156c-.43.51-1.018.824-1.688.844.27.38.438.844.438 1.344v.656h2v-1.656c0-.52-.31-.968-.75-1.188zm-6.5 1c-.44.22-.75.668-.75 1.188v1.656h5v-1.656c0-.52-.31-.968-.75-1.188-.44.53-1.06.844-1.75.844s-1.31-.314-1.75-.844z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/person.svg b/src/net/sourceforge/plantuml/openiconic/data/person.svg
new file mode 100644
index 0000000..0ce80f5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/person.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4 0c-1.105 0-2 1.119-2 2.5s.895 2.5 2 2.5 2-1.119 2-2.5-.895-2.5-2-2.5zm-2.094 5c-1.07.04-1.906.92-1.906 2v1h8v-1c0-1.08-.836-1.96-1.906-2-.54.61-1.284 1-2.094 1-.81 0-1.554-.39-2.094-1z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/phone.svg b/src/net/sourceforge/plantuml/openiconic/data/phone.svg
new file mode 100644
index 0000000..9c8cc06
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/phone.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M1.188 0c-.11 0-.188.077-.188.188v7.625c0 .11.077.188.188.188h4.625c.11 0 .188-.077.188-.188v-7.625c0-.11-.077-.188-.188-.188h-4.625zm.813 1h3v5h-3v-5zm1.5 5.5c.28 0 .5.22.5.5s-.22.5-.5.5-.5-.22-.5-.5.22-.5.5-.5z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/pie-chart.svg b/src/net/sourceforge/plantuml/openiconic/data/pie-chart.svg
new file mode 100644
index 0000000..7ac7577
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/pie-chart.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M3.5 0c-.97 0-1.839.391-2.469 1.031l2.969 2.969v-3.969c-.16-.03-.33-.031-.5-.031zm1.5 1.063v3.406l-2.719 2.719c.6.5 1.369.813 2.219.813 1.93 0 3.5-1.57 3.5-3.5 0-1.76-1.31-3.197-3-3.438zm-4.094 1.313c-.55.54-.906 1.285-.906 2.125 0 .95.435 1.804 1.125 2.344l2.156-2.125-2.375-2.344z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/pin.svg b/src/net/sourceforge/plantuml/openiconic/data/pin.svg
new file mode 100644
index 0000000..2810c46
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/pin.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M1.344 0a.502.502 0 0 0 .156 1h.5v2h-1c-.55 0-1 .45-1 1h3v3l.438 1 .563-1v-3h3c0-.55-.45-1-1-1h-1v-2h.5a.5.5 0 1 0 0-1h-4a.5.5 0 0 0-.094 0 .502.502 0 0 0-.063 0z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/play-circle.svg b/src/net/sourceforge/plantuml/openiconic/data/play-circle.svg
new file mode 100644
index 0000000..d668d52
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/play-circle.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4 0c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm-1 2l3 2-3 2v-4z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/plus.svg b/src/net/sourceforge/plantuml/openiconic/data/plus.svg
new file mode 100644
index 0000000..74aea49
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/plus.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M3 0v3h-3v2h3v3h2v-3h3v-2h-3v-3h-2z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/power-standby.svg b/src/net/sourceforge/plantuml/openiconic/data/power-standby.svg
new file mode 100644
index 0000000..bbbd6c9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/power-standby.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M3 0v4h1v-4h-1zm-1.281 1.438l-.375.313c-.803.64-1.344 1.634-1.344 2.75 0 1.929 1.571 3.5 3.5 3.5s3.5-1.571 3.5-3.5c0-1.116-.529-2.11-1.344-2.75l-.375-.313-.625.781.375.313c.585.46.969 1.165.969 1.969 0 1.391-1.109 2.5-2.5 2.5s-2.5-1.109-2.5-2.5c0-.804.361-1.509.938-1.969l.406-.313-.625-.781z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/print.svg b/src/net/sourceforge/plantuml/openiconic/data/print.svg
new file mode 100644
index 0000000..f48d866
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/print.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M2 0v2h4v-2h-4zm-1.906 3c-.06 0-.094.034-.094.094v2.813c0 .06.034.094.094.094h.906v-2h6v2h.906c.06 0 .094-.034.094-.094v-2.813c0-.06-.034-.094-.094-.094h-7.813zm1.906 2v3h4v-3h-4z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/project.svg b/src/net/sourceforge/plantuml/openiconic/data/project.svg
new file mode 100644
index 0000000..e8e9154
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/project.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 0v7h1v-7h-1zm7 0v7h1v-7h-1zm-5 1v1h2v-1h-2zm1 2v1h2v-1h-2zm1 2v1h2v-1h-2z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/pulse.svg b/src/net/sourceforge/plantuml/openiconic/data/pulse.svg
new file mode 100644
index 0000000..eb521c4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/pulse.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M3.25 0l-.469 1.531-.781 2.563-.031-.063-.094-.344h-1.875v1h1.156l.375 1.156.469 1.469.469-1.469.781-2.5.781 2.5.406 1.313.531-1.281.594-1.469.125.281h2.313v-1h-1.688l-.375-.719-.5-1-.406 1.031-.469 1.188-.844-2.656-.469-1.531z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/puzzle-piece.svg b/src/net/sourceforge/plantuml/openiconic/data/puzzle-piece.svg
new file mode 100644
index 0000000..f752fbb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/puzzle-piece.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M3 0c-.28 0-.539.101-.719.281-.18.18-.281.439-.281.719 0 .28.181.479.281.719.03.06.063.161.063.281h-2.344v6h2.344c0-.12-.011-.221-.031-.281-.11-.24-.313-.439-.313-.719 0-.28.101-.539.281-.719.18-.18.439-.281.719-.281.28 0 .539.101.719.281.18.18.281.439.281.719 0 .28-.181.479-.281.719-.03.06-.063.161-.063.281h2.344v-2.344c.12 0 .221.011.281.031.24.11.439.313.719.313.28 0 .539-.101.719-.281.18-.18.281-.439.281-.719 0-.28-.101-.539-.281-.719-.18-.18-.439-.281-.719-.281-.28 0-.479.181-.719.281-.06.03-.161.063-.281.063v-2.344h-2.344c0-.12.011-.221.031-.281.11-.24.313-.439.313-.719 0-.28-.101-.539-.281-.719-.18-.18-.439-.281-.719-.281z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/question-mark.svg b/src/net/sourceforge/plantuml/openiconic/data/question-mark.svg
new file mode 100644
index 0000000..7e1c76a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/question-mark.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4.469 0c-.854 0-1.48.256-1.875.656s-.54.901-.594 1.281l1 .125c.036-.26.125-.497.313-.688.188-.19.491-.375 1.156-.375.664 0 1.019.163 1.219.344.199.181.281.405.281.656 0 .833-.313 1.063-.813 1.5-.5.438-1.188 1.083-1.188 2.25v.25h1v-.25c0-.833.344-1.063.844-1.5.5-.438 1.156-1.083 1.156-2.25 0-.479-.168-1.02-.594-1.406-.426-.387-1.071-.594-1.906-.594zm-.5 7v1h1v-1h-1z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/rain.svg b/src/net/sourceforge/plantuml/openiconic/data/rain.svg
new file mode 100644
index 0000000..d9ff4ea
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/rain.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4.5 0c-1.21 0-2.27.86-2.5 2-1.1 0-2 .9-2 2 0 .52.201 1.015.531 1.375.26-.22.599-.375.969-.375.2 0 .393.055.563.125.17-.64.748-1.125 1.438-1.125s1.268.485 1.438 1.125c.17-.07.362-.125.563-.125.63 0 1.155.388 1.375.938.64-.17 1.125-.747 1.125-1.438 0-.65-.42-1.29-1-1.5v-.5c0-1.38-1.12-2.5-2.5-2.5zm-1.156 5a.5.5 0 0 0-.344.5v2a.5.5 0 1 0 1 0v-2a.5.5 0 0 0-.594-.5.5.5 0 0 0-.063 0zm-2 1a.5.5 0 0 0-.344.5v1a.5.5 0 1 0 1 0v-1a.5.5 0 0 0-.594-.5.5.5 0 0 0-.063 0zm4 0a.5.5 0 0 0-.344.5v1a.5.5 0 1 0 1 0v-1a.5.5 0 0 0-.594-.5.5.5 0 0 0-.063 0z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/random.svg b/src/net/sourceforge/plantuml/openiconic/data/random.svg
new file mode 100644
index 0000000..6cafaae
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/random.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M6 0v1h-.5c-.354 0-.6.116-.813.375l-1.406 1.75-1.5-1.75v-.031c-.212-.236-.427-.344-.781-.344h-1v1h1.031v.031l1.625 1.906-1.625 2.031v.031h-1.031v1h1c.354 0 .6-.116.813-.375l1.531-1.906 1.625 1.906v.031c.212.236.427.344.781.344h.25v1l2-1.5-2-1.5v1h-.281v-.031l-1.75-2.063 1.5-1.875v-.031h.531v1l2-1.5-2-1.5z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/reload.svg b/src/net/sourceforge/plantuml/openiconic/data/reload.svg
new file mode 100644
index 0000000..8cb8492
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/reload.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4 0c-2.201 0-4 1.799-4 4s1.799 4 4 4c1.104 0 2.092-.456 2.813-1.188l-.688-.688c-.54.548-1.289.875-2.125.875-1.659 0-3-1.341-3-3s1.341-3 3-3c.834 0 1.545.354 2.094.906l-1.094 1.094h3v-3l-1.188 1.188c-.731-.72-1.719-1.188-2.813-1.188z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/resize-both.svg b/src/net/sourceforge/plantuml/openiconic/data/resize-both.svg
new file mode 100644
index 0000000..26f564a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/resize-both.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4 0l1.656 1.656-4 4-1.656-1.656v4h4l-1.656-1.656 4-4 1.656 1.656v-4h-4z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/resize-height.svg b/src/net/sourceforge/plantuml/openiconic/data/resize-height.svg
new file mode 100644
index 0000000..1b104fb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/resize-height.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M3.5 0l-2.5 3h2v2h-2l2.5 3 2.5-3h-2v-2h2l-2.5-3z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/resize-width.svg b/src/net/sourceforge/plantuml/openiconic/data/resize-width.svg
new file mode 100644
index 0000000..cf7e7b1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/resize-width.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M3 1l-3 2.5 3 2.5v-2h2v2l3-2.5-3-2.5v2h-2v-2z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/rss-alt.svg b/src/net/sourceforge/plantuml/openiconic/data/rss-alt.svg
new file mode 100644
index 0000000..67d4f85
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/rss-alt.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 0v2c3.331 0 6 2.669 6 6h2c0-4.409-3.591-8-8-8zm0 3v2c1.67 0 3 1.33 3 3h2c0-2.75-2.25-5-5-5zm0 3v2h2c0-1.11-.89-2-2-2z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/rss.svg b/src/net/sourceforge/plantuml/openiconic/data/rss.svg
new file mode 100644
index 0000000..a25f939
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/rss.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M1 0v1c3.32 0 6 2.68 6 6h1c0-3.86-3.14-7-7-7zm0 2v1c2.221 0 4 1.779 4 4h1c0-2.759-2.241-5-5-5zm0 2v1c1.109 0 2 .891 2 2h1c0-1.651-1.349-3-3-3zm0 2c-.552 0-1 .448-1 1s.448 1 1 1 1-.448 1-1-.448-1-1-1z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/script.svg b/src/net/sourceforge/plantuml/openiconic/data/script.svg
new file mode 100644
index 0000000..14b7ff8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/script.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M3 0c-.55 0-1 .45-1 1v5.5c0 .28-.22.5-.5.5s-.5-.22-.5-.5v-1.5h-1v2c0 .55.45 1 1 1h5c.55 0 1-.45 1-1v-3h-4v-2.5c0-.28.22-.5.5-.5s.5.22.5.5v1.5h4v-2c0-.55-.45-1-1-1h-4z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/share-boxed.svg b/src/net/sourceforge/plantuml/openiconic/data/share-boxed.svg
new file mode 100644
index 0000000..dd8524f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/share-boxed.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M.75 0c-.402 0-.75.348-.75.75v5.5c0 .402.348.75.75.75h4.5c.402 0 .75-.348.75-.75v-1.25h-1v1h-4v-5h2v-1h-2.25zm5.25 0v1c-2.05 0-3.704 1.544-3.938 3.531.213-.875.999-1.531 1.938-1.531h2v1l2-2-2-2z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/share.svg b/src/net/sourceforge/plantuml/openiconic/data/share.svg
new file mode 100644
index 0000000..6dbf37c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/share.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M5 0v2c-4 0-5 2.05-5 5 .52-1.98 2-3 4-3h1v2l3-3.156-3-2.844z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/shield.svg b/src/net/sourceforge/plantuml/openiconic/data/shield.svg
new file mode 100644
index 0000000..4adddf7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/shield.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4 0l-.188.094-3.5 1.469-.313.125v.313c0 1.657.666 3.122 1.469 4.188.401.533.828.969 1.25 1.281.422.313.826.531 1.281.531.455 0 .86-.219 1.281-.531.422-.313.849-.749 1.25-1.281.803-1.065 1.469-2.53 1.469-4.188v-.313l-.313-.125-3.5-1.469-.188-.094zm0 1.094v5.906c-.045 0-.328-.069-.656-.313s-.714-.631-1.063-1.094c-.642-.851-1.137-2.025-1.219-3.281l2.938-1.219z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/signal.svg b/src/net/sourceforge/plantuml/openiconic/data/signal.svg
new file mode 100644
index 0000000..14137f4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/signal.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M6 0v8h1v-8h-1zm-2 1v7h1v-7h-1zm-2 2v5h1v-5h-1zm-2 2v3h1v-3h-1z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/signpost.svg b/src/net/sourceforge/plantuml/openiconic/data/signpost.svg
new file mode 100644
index 0000000..965e95a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/signpost.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M3 0v1h-2l-1 1 1 1h2v5h1v-4h2l1-1-1-1h-2v-2h-1z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/sort-ascending.svg b/src/net/sourceforge/plantuml/openiconic/data/sort-ascending.svg
new file mode 100644
index 0000000..bb8d497
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/sort-ascending.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M2 0v6h-2l2.5 2 2.5-2h-2v-6h-1zm2 0v1h2v-1h-2zm0 2v1h3v-1h-3zm0 2v1h4v-1h-4z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/sort-descending.svg b/src/net/sourceforge/plantuml/openiconic/data/sort-descending.svg
new file mode 100644
index 0000000..6af7349
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/sort-descending.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M2 0v6h-2l2.5 2 2.5-2h-2v-6h-1zm2 0v1h4v-1h-4zm0 2v1h3v-1h-3zm0 2v1h2v-1h-2z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/spreadsheet.svg b/src/net/sourceforge/plantuml/openiconic/data/spreadsheet.svg
new file mode 100644
index 0000000..bd52d5f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/spreadsheet.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M.75 0c-.402 0-.75.348-.75.75v5.5c0 .402.348.75.75.75h6.5c.402 0 .75-.348.75-.75v-5.5c0-.402-.348-.75-.75-.75h-6.5zm.25 1h1v1h-1v-1zm2 0h4v1h-4v-1zm-2 2h1v1h-1v-1zm2 0h4v1h-4v-1zm-2 2h1v1h-1v-1zm2 0h4v1h-4v-1z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/star.svg b/src/net/sourceforge/plantuml/openiconic/data/star.svg
new file mode 100644
index 0000000..ab716a0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/star.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4 0l-1 3h-3l2.5 2-1 3 2.5-2 2.5 2-1-3 2.5-2h-3l-1-3z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/sun.svg b/src/net/sourceforge/plantuml/openiconic/data/sun.svg
new file mode 100644
index 0000000..cc90820
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/sun.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4 0c-.276 0-.5.224-.5.5s.224.5.5.5.5-.224.5-.5-.224-.5-.5-.5zm-2.5 1c-.276 0-.5.224-.5.5s.224.5.5.5.5-.224.5-.5-.224-.5-.5-.5zm5 0c-.276 0-.5.224-.5.5s.224.5.5.5.5-.224.5-.5-.224-.5-.5-.5zm-2.5 1c-1.105 0-2 .895-2 2s.895 2 2 2 2-.895 2-2-.895-2-2-2zm-3.5 1.5c-.276 0-.5.224-.5.5s.224.5.5.5.5-.224.5-.5-.224-.5-.5-.5zm7 0c-.276 0-.5.224-.5.5s.224.5.5.5.5-.224.5-.5-.224-.5-.5-.5zm-6 2.5c-.276 0-.5.224-.5.5s.224.5.5.5.5-.224.5-.5-.224-.5-.5-.5zm5 0c-.276 0-.5.224-.5.5s.224.5.5.5.5-.224.5-.5-.224-.5-.5-.5zm-2.5 1c-.276 0-.5.224-.5.5s.224.5.5.5.5-.224.5-.5-.224-.5-.5-.5z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/tablet.svg b/src/net/sourceforge/plantuml/openiconic/data/tablet.svg
new file mode 100644
index 0000000..14cca49
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/tablet.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M.344 0c-.18 0-.344.164-.344.344v7.313c0 .18.164.344.344.344h6.313c.18 0 .344-.164.344-.344v-7.313c0-.18-.164-.344-.344-.344h-6.313zm.656 1h5v5h-5v-5zm2.5 5.5c.28 0 .5.22.5.5s-.22.5-.5.5-.5-.22-.5-.5.22-.5.5-.5z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/tag.svg b/src/net/sourceforge/plantuml/openiconic/data/tag.svg
new file mode 100644
index 0000000..b9efc2b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/tag.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 0v3l5 5 3-3-5-5h-3zm2 1c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/tags.svg b/src/net/sourceforge/plantuml/openiconic/data/tags.svg
new file mode 100644
index 0000000..2f57925
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/tags.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 1v2l3 3 1.5-1.5.5-.5-2-2-1-1h-2zm3.406 0l3 3-1.188 1.219.781.781 2-2-3-3h-1.594zm-1.906 1c.28 0 .5.22.5.5s-.22.5-.5.5-.5-.22-.5-.5.22-.5.5-.5z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/target.svg b/src/net/sourceforge/plantuml/openiconic/data/target.svg
new file mode 100644
index 0000000..180fee9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/target.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4 0c-2.203 0-4 1.797-4 4 0 2.203 1.797 4 4 4 2.203 0 4-1.797 4-4 0-2.203-1.797-4-4-4zm0 1c1.663 0 3 1.337 3 3s-1.337 3-3 3-3-1.337-3-3 1.337-3 3-3zm0 1c-1.099 0-2 .901-2 2s.901 2 2 2 2-.901 2-2-.901-2-2-2zm0 1c.558 0 1 .442 1 1s-.442 1-1 1-1-.442-1-1 .442-1 1-1z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/task.svg b/src/net/sourceforge/plantuml/openiconic/data/task.svg
new file mode 100644
index 0000000..4dbb20e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/task.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 0v7h7v-3.594l-1 1v1.594h-5v-5h3.594l1-1h-5.594zm7 0l-3 3-1-1-1 1 2 2 4-4-1-1z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/terminal.svg b/src/net/sourceforge/plantuml/openiconic/data/terminal.svg
new file mode 100644
index 0000000..9d67ed3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/terminal.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M.094 0c-.06 0-.094.034-.094.094v7.813c0 .06.034.094.094.094h7.813c.06 0 .094-.034.094-.094v-7.813c0-.06-.034-.094-.094-.094h-7.813zm1.406.781l1.719 1.719-1.719 1.719-.719-.719 1-1-1-1 .719-.719zm2.5 2.219h3v1h-3v-1z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/text.svg b/src/net/sourceforge/plantuml/openiconic/data/text.svg
new file mode 100644
index 0000000..7a4ffb4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/text.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 0v2h.5c0-.55.45-1 1-1h1.5v5.5c0 .28-.22.5-.5.5h-.5v1h4v-1h-.5c-.28 0-.5-.22-.5-.5v-5.5h1.5c.55 0 1 .45 1 1h.5v-2h-8z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/thumb-down.svg b/src/net/sourceforge/plantuml/openiconic/data/thumb-down.svg
new file mode 100644
index 0000000..17d6526
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/thumb-down.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 0v4h1v-4h-1zm2 0v4.001c.28 0 .529.101.719.281.18.19 1.151 2.115 1.281 2.375.13.26.386.393.656.313.26-.08.393-.355.313-.625-.08-.26-.469-1.594-.469-1.844s.22-.5.5-.5h1.5c.28 0 .5-.22.5-.5l-1.031-3.188c-.08-.18-.259-.313-.469-.313h-3.5z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/thumb-up.svg b/src/net/sourceforge/plantuml/openiconic/data/thumb-up.svg
new file mode 100644
index 0000000..a274e21
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/thumb-up.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4.438 0c-.19.021-.34.149-.438.344-.13.26-1.101 2.185-1.281 2.375-.19.18-.439.281-.719.281v4.001h3.5c.21 0 .389-.133.469-.313 0 0 1.031-2.908 1.031-3.188 0-.28-.22-.5-.5-.5h-1.5c-.28 0-.5-.25-.5-.5s.389-1.574.469-1.844c.08-.27-.053-.545-.313-.625l-.219-.031zm-4.438 3v4h1v-4h-1z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/timer.svg b/src/net/sourceforge/plantuml/openiconic/data/timer.svg
new file mode 100644
index 0000000..0ced8ea
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/timer.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M2 0v1h1v.031c-1.697.241-3 1.707-3 3.469 0 1.929 1.571 3.5 3.5 3.5s3.5-1.571 3.5-3.5c0-.45-.086-.874-.219-1.25l-.938.344c.107.304.156.596.156.906 0 1.391-1.109 2.5-2.5 2.5s-2.5-1.109-2.5-2.5 1.109-2.5 2.5-2.5c.298 0 .585.051.875.156l.344-.938c-.221-.081-.471-.119-.719-.156v-.063h1v-1h-3zm5 1.125s-3.675 2.8-3.875 3c-.2.2-.2.519 0 .719.2.2.519.2.719 0 .2-.19 3.156-3.719 3.156-3.719z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/transfer.svg b/src/net/sourceforge/plantuml/openiconic/data/transfer.svg
new file mode 100644
index 0000000..39ace35
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/transfer.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M6 0v1h-6v1h6v1l2-1.5-2-1.5zm-4 4l-2 1.5 2 1.5v-1h6v-1h-6v-1z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/trash.svg b/src/net/sourceforge/plantuml/openiconic/data/trash.svg
new file mode 100644
index 0000000..f157254
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/trash.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M3 0c-.55 0-1 .45-1 1h-1c-.55 0-1 .45-1 1h7c0-.55-.45-1-1-1h-1c0-.55-.45-1-1-1h-1zm-2 3v4.813c0 .11.077.188.188.188h4.625c.11 0 .188-.077.188-.188v-4.813h-1v3.5c0 .28-.22.5-.5.5s-.5-.22-.5-.5v-3.5h-1v3.5c0 .28-.22.5-.5.5s-.5-.22-.5-.5v-3.5h-1z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/underline.svg b/src/net/sourceforge/plantuml/openiconic/data/underline.svg
new file mode 100644
index 0000000..a6f8073
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/underline.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M1 0v4c0 1.1 1.12 2 2.5 2h.5c1.1 0 2-.9 2-2v-4h-1v4c0 .55-.45 1-1 1s-1-.45-1-1v-4h-2zm-1 7v1h7v-1h-7z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/vertical-align-bottom.svg b/src/net/sourceforge/plantuml/openiconic/data/vertical-align-bottom.svg
new file mode 100644
index 0000000..9c21f67
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/vertical-align-bottom.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M.094 0c-.06 0-.094.034-.094.094v4.813c0 .06.034.094.094.094h1.813c.06 0 .094-.034.094-.094v-4.813c0-.06-.034-.094-.094-.094h-1.813zm6 0c-.06 0-.094.034-.094.094v4.813c0 .06.034.094.094.094h1.813c.06 0 .094-.034.094-.094v-4.813c0-.06-.034-.094-.094-.094h-1.813zm-3 2c-.06 0-.094.034-.094.094v2.813c0 .06.034.094.094.094h1.813c.06 0 .094-.034.094-.094v-2.813c0-.06-.034-.094-.094-.094h-1.813zm-3.094 4v1h8v-1h-8z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/vertical-align-center.svg b/src/net/sourceforge/plantuml/openiconic/data/vertical-align-center.svg
new file mode 100644
index 0000000..1827b90
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/vertical-align-center.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M.094 0c-.06 0-.094.034-.094.094v1.906h2v-1.906c0-.06-.034-.094-.094-.094h-1.813zm6 0c-.06 0-.094.034-.094.094v1.906h2v-1.906c0-.06-.034-.094-.094-.094h-1.813zm-3 1c-.06 0-.094.034-.094.094v.906h2v-.906c0-.06-.034-.094-.094-.094h-1.813zm-3.094 2v1h8v-1h-8zm0 2v1.906c0 .06.034.094.094.094h1.813c.06 0 .094-.034.094-.094v-1.906h-2zm3 0v.906c0 .06.034.094.094.094h1.813c.06 0 .094-.034.094-.094v-.906h-2zm3 0v1.906c0 .06.034.094.094.094h1.813c.06 0 .094-.034.094-.094v-1.906h-2z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/vertical-align-top.svg b/src/net/sourceforge/plantuml/openiconic/data/vertical-align-top.svg
new file mode 100644
index 0000000..4bac913
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/vertical-align-top.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 0v1h8v-1h-8zm.094 2c-.06 0-.094.034-.094.094v4.813c0 .06.034.094.094.094h1.813c.06 0 .094-.034.094-.094v-4.813c0-.06-.034-.094-.094-.094h-1.813zm3 0c-.06 0-.094.034-.094.094v2.813c0 .06.034.094.094.094h1.813c.06 0 .094-.034.094-.094v-2.813c0-.06-.034-.094-.094-.094h-1.813zm3 0c-.06 0-.094.034-.094.094v4.813c0 .06.034.094.094.094h1.813c.06 0 .094-.034.094-.094v-4.813c0-.06-.034-.094-.094-.094h-1.813z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/video.svg b/src/net/sourceforge/plantuml/openiconic/data/video.svg
new file mode 100644
index 0000000..8e516dd
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/video.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M.5 1c-.28 0-.5.22-.5.5v4c0 .28.22.5.5.5h5c.28 0 .5-.22.5-.5v-1.5l1 1h1v-3h-1l-1 1v-1.5c0-.28-.22-.5-.5-.5h-5z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/volume-high.svg b/src/net/sourceforge/plantuml/openiconic/data/volume-high.svg
new file mode 100644
index 0000000..4786581
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/volume-high.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M3.344 0l-1.344 2h-2v4h2l1.344 2h.656v-8h-.656zm1.656 1v1c.152 0 .313.026.469.063h.031c.86.215 1.5.995 1.5 1.938 0 .942-.64 1.722-1.5 1.938-.166.041-.338.063-.5.063v1c.258 0 .516-.035.75-.094 1.3-.325 2.25-1.508 2.25-2.906 0-1.398-.95-2.581-2.25-2.906-.234-.059-.492-.094-.75-.094zm0 2v2l.25-.031c.433-.118.75-.507.75-.969 0-.446-.325-.819-.75-.938v-.031h-.031l-.219-.031z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/volume-low.svg b/src/net/sourceforge/plantuml/openiconic/data/volume-low.svg
new file mode 100644
index 0000000..a08992b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/volume-low.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M4.344 0l-1.344 2h-2v4h2l1.344 2h.656v-8h-.656zm1.656 3v2l.25-.031c.433-.118.75-.507.75-.969 0-.446-.325-.819-.75-.938v-.031h-.031l-.219-.031z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/volume-off.svg b/src/net/sourceforge/plantuml/openiconic/data/volume-off.svg
new file mode 100644
index 0000000..5b2d172
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/volume-off.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M5.344 0l-1.344 2h-2v4h2l1.344 2h.656v-8h-.656z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/warning.svg b/src/net/sourceforge/plantuml/openiconic/data/warning.svg
new file mode 100644
index 0000000..9eca3d9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/warning.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M3.094 0c-.06 0-.105.044-.125.094l-2.938 6.813-.031.188v.813c0 .06.034.094.094.094h6.813c.06 0 .094-.034.094-.094v-.813l-.031-.188-2.938-6.813c-.02-.05-.065-.094-.125-.094h-.813zm-.094 3h1v2h-1v-2zm0 3h1v1h-1v-1z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/wifi.svg b/src/net/sourceforge/plantuml/openiconic/data/wifi.svg
new file mode 100644
index 0000000..cee1ea6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/wifi.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M3.75 0c-1.374 0-2.66.372-3.75 1.063l.531.875c.93-.59 2.033-.938 3.219-.938 1.2 0 2.323.31 3.25.906l.531-.813c-1.093-.703-2.401-1.094-3.781-1.094zm.031 3c-.795 0-1.531.227-2.156.625l.531.844c.475-.302 1.02-.469 1.625-.469.593 0 1.13.177 1.594.469l.531-.844c-.616-.388-1.338-.625-2.125-.625zm-.031 3c-.552 0-1 .448-1 1s.448 1 1 1 1-.448 1-1-.448-1-1-1z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/wrench.svg b/src/net/sourceforge/plantuml/openiconic/data/wrench.svg
new file mode 100644
index 0000000..3d91c70
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/wrench.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M5.5 0c-1.38 0-2.5 1.12-2.5 2.5 0 .32.078.626.188.906l-2.906 2.875c-.39.39-.39 1.016 0 1.406.2.2.459.313.719.313.26 0 .519-.091.719-.281l2.875-2.875c.28.1.586.156.906.156 1.38 0 2.5-1.12 2.5-2.5 0-.16-.032-.297-.063-.438l-.938.938h-2v-2l.938-.938c-.14-.03-.277-.062-.438-.063zm-4.5 6.5c.28 0 .5.22.5.5s-.22.5-.5.5-.5-.22-.5-.5.22-.5.5-.5z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/x.svg b/src/net/sourceforge/plantuml/openiconic/data/x.svg
new file mode 100644
index 0000000..4c1b505
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/x.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M1.406 0l-1.406 1.406.688.719 1.781 1.781-1.781 1.781-.688.719 1.406 1.406.719-.688 1.781-1.781 1.781 1.781.719.688 1.406-1.406-.688-.719-1.781-1.781 1.781-1.781.688-.719-1.406-1.406-.719.688-1.781 1.781-1.781-1.781-.719-.688z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/yen.svg b/src/net/sourceforge/plantuml/openiconic/data/yen.svg
new file mode 100644
index 0000000..a79cd6c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/yen.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M0 0l2.25 3h-2.25v1h3v1h-3v1h3v2h1v-2h3v-1h-3v-1h3v-1h-2.25l2.25-3h-1l-2.313 3h-.375l-2.313-3h-1z" />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/zoom-in.svg b/src/net/sourceforge/plantuml/openiconic/data/zoom-in.svg
new file mode 100644
index 0000000..61b7648
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/zoom-in.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M3.5 0c-1.927 0-3.5 1.573-3.5 3.5s1.573 3.5 3.5 3.5c.592 0 1.166-.145 1.656-.406a1 1 0 0 0 .094.094l1.031 1.031a1.016 1.016 0 1 0 1.438-1.438l-1.031-1.031a1 1 0 0 0-.125-.094c.266-.493.438-1.059.438-1.656 0-1.927-1.573-3.5-3.5-3.5zm0 1c1.387 0 2.5 1.113 2.5 2.5 0 .587-.196 1.137-.531 1.563l-.031.031a1 1 0 0 0-.063.031 1 1 0 0 0-.281.281 1 1 0 0 0-.063.063c-.422.326-.953.531-1.531.531-1.387 0-2.5-1.113-2.5-2.5s1.113-2.5 2.5-2.5zm-.5 1v1h-1v1h1v1h1v-1h1v-1h-1v-1h-1z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/openiconic/data/zoom-out.svg b/src/net/sourceforge/plantuml/openiconic/data/zoom-out.svg
new file mode 100644
index 0000000..89d6c4c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/openiconic/data/zoom-out.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
+ <path d="M3.5 0c-1.927 0-3.5 1.573-3.5 3.5s1.573 3.5 3.5 3.5c.592 0 1.166-.145 1.656-.406a1 1 0 0 0 .094.094l1.031 1.031a1.016 1.016 0 1 0 1.438-1.438l-1.031-1.031a1 1 0 0 0-.125-.094c.266-.493.438-1.059.438-1.656 0-1.927-1.573-3.5-3.5-3.5zm0 1c1.387 0 2.5 1.113 2.5 2.5 0 .587-.196 1.137-.531 1.563l-.031.031a1 1 0 0 0-.063.031 1 1 0 0 0-.281.281 1 1 0 0 0-.063.063c-.422.326-.953.531-1.531.531-1.387 0-2.5-1.113-2.5-2.5s1.113-2.5 2.5-2.5zm-1.5 2v1h3v-1h-3z"
+ />
+</svg> \ No newline at end of file
diff --git a/src/net/sourceforge/plantuml/oregon/BasicGame.java b/src/net/sourceforge/plantuml/oregon/BasicGame.java
new file mode 100644
index 0000000..c51f4fa
--- /dev/null
+++ b/src/net/sourceforge/plantuml/oregon/BasicGame.java
@@ -0,0 +1,42 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.oregon;
+
+public interface BasicGame {
+
+ void run(Keyboard keyboard) throws NoInputException;
+
+ Screen getScreen();
+}
diff --git a/src/net/sourceforge/plantuml/oregon/Keyboard.java b/src/net/sourceforge/plantuml/oregon/Keyboard.java
new file mode 100644
index 0000000..324978b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/oregon/Keyboard.java
@@ -0,0 +1,41 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.oregon;
+
+public interface Keyboard {
+ String input() throws NoInputException;
+ boolean hasMore();
+
+}
diff --git a/src/net/sourceforge/plantuml/oregon/KeyboardList.java b/src/net/sourceforge/plantuml/oregon/KeyboardList.java
new file mode 100644
index 0000000..d26cfc9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/oregon/KeyboardList.java
@@ -0,0 +1,65 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.oregon;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+
+public class KeyboardList implements Keyboard {
+
+ private final Iterator<String> data;
+
+ public KeyboardList(String... inputs) {
+ this(Arrays.asList(inputs));
+ }
+
+ public KeyboardList(Collection<String> inputs) {
+ data = inputs.iterator();
+ }
+
+
+ public String input() throws NoInputException {
+ if (data.hasNext()) {
+ return data.next();
+ }
+ throw new NoInputException();
+ }
+
+ public boolean hasMore() {
+ return data.hasNext();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/oregon/MagicTable.java b/src/net/sourceforge/plantuml/oregon/MagicTable.java
new file mode 100644
index 0000000..8cfddd5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/oregon/MagicTable.java
@@ -0,0 +1,232 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.oregon;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Random;
+
+import net.sourceforge.plantuml.Log;
+
+public class MagicTable {
+
+ static enum Oc {
+ USED, NEAR
+ }
+
+ private final Oc number[] = new Oc[10000];
+
+ private static ArrayList<int[]> neighboors;
+
+ static {
+ neighboors = new ArrayList<int[]>();
+ for (int i = 0; i < 10000; i++) {
+ neighboors.add(null);
+ }
+ }
+
+ public static int[] getNeighboors(final int nb) {
+ if (neighboors.get(nb) == null) {
+ neighboors.set(nb, getNeighboorsSlow(nb));
+ }
+ return neighboors.get(nb);
+ }
+
+ public static int[] getNeighboorsSlow(final int nb) {
+ final int result[] = new int[36];
+
+ final int v1 = nb % 10;
+ int root = nb - v1;
+ int cpt = 0;
+ for (int i = 0; i < 10; i++) {
+ final int candidat = root + i;
+ if (candidat == nb) {
+ continue;
+ }
+ result[cpt++] = candidat;
+ }
+ final int v2 = (nb / 10) % 10;
+ root = nb - v2 * 10;
+ for (int i = 0; i < 10; i++) {
+ final int candidat = root + i * 10;
+ if (candidat == nb) {
+ continue;
+ }
+ result[cpt++] = candidat;
+ }
+ final int v3 = (nb / 100) % 10;
+ root = nb - v3 * 100;
+ for (int i = 0; i < 10; i++) {
+ final int candidat = root + i * 100;
+ if (candidat == nb) {
+ continue;
+ }
+ result[cpt++] = candidat;
+ }
+ final int v4 = nb / 1000;
+ root = nb - v4 * 1000;
+ for (int i = 0; i < 10; i++) {
+ final int candidat = root + i * 1000;
+ if (candidat == nb) {
+ continue;
+ }
+ result[cpt++] = candidat;
+ }
+ return result;
+ }
+
+ public List<Integer> getAllFree() {
+ final List<Integer> result = new ArrayList<Integer>(10000);
+ for (int i = 0; i < number.length; i++) {
+ if (number[i] == null) {
+ result.add(i);
+ }
+ }
+ return result;
+ }
+
+ public List<Integer> getAllUsed() {
+ final List<Integer> result = new ArrayList<Integer>(10000);
+ for (int i = 0; i < number.length; i++) {
+ if (number[i] == Oc.USED) {
+ result.add(i);
+ }
+ }
+ return result;
+ }
+
+ public boolean isUsuable(int nb) {
+ if (number[nb] != null) {
+ return false;
+ }
+ for (int near : getNeighboors(nb)) {
+ if (number[near] != null) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public void burnNumber(int nb) {
+ if (number[nb] != null) {
+ throw new IllegalArgumentException();
+ }
+ number[nb] = Oc.USED;
+ for (int near : getNeighboors(nb)) {
+ number[near] = Oc.NEAR;
+ }
+ }
+
+ public int getRandomFree(Random rnd) {
+ final List<Integer> frees = getAllFree();
+ // final int size = frees.size();
+ // for (int i = 0; i < size; i++) {
+ // final int pos = rnd.nextInt(frees.size());
+ // final int nb = frees.get(pos);
+ // frees.remove(pos);
+ // if (isUsuable(nb)) {
+ // return nb;
+ // }
+ // }
+ Collections.shuffle(frees, rnd);
+ for (int nb : frees) {
+ if (isUsuable(nb)) {
+ return nb;
+ }
+ }
+ return -1;
+
+ }
+
+ public static int size(Random rnd, MagicTable mt) {
+ int i = 0;
+ while (true) {
+ final int candidat = mt.getRandomFree(rnd);
+ if (candidat == -1) {
+ break;
+ }
+ mt.burnNumber(candidat);
+ i++;
+ }
+ return i;
+ }
+
+ public static void main(String[] args) {
+ int max = 0;
+ final long start = System.currentTimeMillis();
+ final Random rnd = new Random(49);
+ final int nb = 200000;
+ for (int i = 0; i < nb; i++) {
+ if (i == 100) {
+ long dur = (System.currentTimeMillis() - start) / 1000L;
+ dur = dur * nb / 100;
+ dur = dur / 3600;
+ Log.println("Estimated duration = " + dur + " h");
+ }
+ final MagicTable mt = new MagicTable();
+ final int v = MagicTable.size(rnd, mt);
+ if (v > max) {
+ Log.println("v="+v);
+ Log.println("mt="+mt.getAllUsed());
+ max = v;
+ }
+ }
+ final long duration = System.currentTimeMillis() - start;
+ Log.println("Duration = " + duration / 1000L / 60);
+
+ }
+
+ public static void main2(String[] args) {
+ int max = 0;
+ final long start = System.currentTimeMillis();
+ for (int j = 1; j < 100; j++) {
+ final Random rnd = new Random(j);
+ for (int i = 0; i < 1000; i++) {
+ final MagicTable mt = new MagicTable();
+ final int v = MagicTable.size(rnd, mt);
+ if (v > max) {
+ Log.println("v="+v);
+ Log.println("mt="+mt.getAllUsed());
+ max = v;
+ }
+ }
+ }
+ final long duration = System.currentTimeMillis() - start;
+ Log.println("Duration = " + duration / 1000L / 60);
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/oregon/NoInputException.java b/src/net/sourceforge/plantuml/oregon/NoInputException.java
new file mode 100644
index 0000000..353aae7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/oregon/NoInputException.java
@@ -0,0 +1,38 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.oregon;
+
+public class NoInputException extends Exception {
+}
diff --git a/src/net/sourceforge/plantuml/oregon/OregonBasicGame.java b/src/net/sourceforge/plantuml/oregon/OregonBasicGame.java
new file mode 100644
index 0000000..1663509
--- /dev/null
+++ b/src/net/sourceforge/plantuml/oregon/OregonBasicGame.java
@@ -0,0 +1,939 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.oregon;
+
+import java.util.Random;
+
+import net.sourceforge.plantuml.StringUtils;
+
+public class OregonBasicGame implements BasicGame {
+
+ private Screen screen;
+ private SmartKeyboard skb;
+ private Random rnd;
+
+ private int ks;
+ private int kh;
+ private int kp;
+ private int kb;
+ private int km;
+ private int kq;
+
+ private double ma;
+
+ private final String da[] = new String[] { "March 29", "April 12", "April 26", "May 10", "May 24", "June 7",
+ "June 21", "July 5", "July 19", "August 2", "August 16", "August 31", "September 13", "September 27",
+ "October 11", "October 25", "November 8", "November 22", "December 6", "December 20" };
+
+ private final int ep[] = new int[] { 6, 11, 13, 15, 17, 22, 32, 35, 37, 42, 44, 54, 64, 69, 95 };
+
+ public Screen getScreen() {
+ return screen;
+ }
+
+ private void print(String s) {
+ screen.print(s);
+ }
+
+ private void printb(String s) {
+ screen.print("<b>** " + s + " **</b>");
+ }
+
+ private void print() {
+ screen.print();
+ }
+
+ public void run(Keyboard keyboard) throws NoInputException {
+ if (screen != null) {
+ throw new IllegalStateException();
+ }
+ screen = new Screen();
+ skb = new SmartKeyboard(keyboard);
+ init();
+ }
+
+ private double rnd() {
+ if (this.rnd == null) {
+ this.rnd = new Random(skb.getHistory().hashCode());
+ }
+ return rnd.nextDouble();
+ }
+
+ private void init() throws NoInputException {
+ printInitialScenario490();
+ initialPurchasesOfPlayer690();
+ initialShootingRanking920();
+ screen.clear();
+ print("<i>** Your trip is about to begin... **</i>");
+ print();
+ for (int j = 0; j < 20; j++) {
+ if (m > 2039) {
+ madeIt3190(j);
+ break;
+ }
+ print("<b>Monday, " + da[j] + ", 1847</b>. You are " + whereAreWe());
+ print();
+ if (f < 6) {
+ print("<b>** You're low on food. Better buy some or go hunting soon. **");
+ print();
+ }
+ if (ks == 1 || kh == 1) {
+ t = t - 10;
+ if (t < 0) {
+ needDoctorBadly3010(j);
+ }
+ print("Doctor charged <b>$10</b> for his services");
+ print("to treat your " + (ks == 1 ? "illness." : "injuries."));
+ }
+ // MP flag to be done?
+
+ m = (int) (m + .5);
+ print("Total mileage to date is: <b>" + ((int) m) + "</b>");
+ m += 200 + (a - 110) / 2.5 + 10 * rnd();
+ print();
+ // Calculate how far we travel in 2 weeks
+ print("Here's what you now have (no. of bullets, $ worth of other items) :");
+ printInventory3350();
+ question1000(j);
+ eating1310(j);
+ screen.clear();
+ riders1390(j);
+ // print();
+ events1800(j);
+ // print();
+ montains2640(j);
+ if (skb.hasMore()) {
+ screen.clear();
+ }
+ }
+ }
+
+ private void events1800(int j) throws NoInputException {
+ final int rn = (int) (100.0 * rnd());
+ for (int i = 0; i < ep.length; i++) {
+ if (rn <= ep[i]) {
+ execEvent(i, j);
+ return;
+ }
+ }
+ execEvent(ep.length, j);
+ }
+
+ private void execEvent(int i, int j) throws NoInputException {
+ switch (i) {
+ case 0:
+ printb("Your wagon breaks down. It costs you time and supplies to fix it.");
+ m = m - 15 - 5 * rnd();
+ r = r - 4;
+ break;
+ case 1:
+ printb("An ox gores your leg. That slows you down for the rest of the trip.");
+ m = m - 25;
+ a = a - 10;
+ break;
+ case 2:
+ printb("Bad luck... your daughter breaks her arm. You must stop and");
+ printb("make a splint and sling with some of your medical supplies.");
+ m = m - 5 - 4 * rnd();
+ r = r - 1 - 2 * rnd();
+ break;
+ case 3:
+ printb("An ox wanders off and you have to spend time looking for it.");
+ m = m - 17;
+ break;
+ case 4:
+ printb("Your son gets lost and you spend half a day searching for him.");
+ m = m - 10;
+ break;
+ case 5:
+ printb("Nothing but contaminated and stagnant water near the trail.");
+ printb("You lose time looking for a clean spring or creek.");
+ m = m - 2 - 10 * rnd();
+ break;
+
+ case 6:
+ if (m > 950) {
+ int c1 = 0;
+ if (c < 11 + 2 * rnd()) {
+ c1 = 1;
+ }
+ printb("Cold weather... Brrrrrrr! ... You " + (c1 == 1 ? "dont't " : "")
+ + "have enough clothing to keep warm.");
+ if (c1 == 1) {
+ dealWithIllness2880(j);
+ }
+ } else {
+ printb("Heavy rains. Traveling is slow in the mud and you break your spare");
+ printb("ox yoke using it to pry your wagon out of the mud. Worse yet, some");
+ printb("of your ammo is damaged by the water.");
+ m = m - 5 - 10 * rnd();
+ r = r - 7;
+ b = b - 400;
+ f = f - 5;
+ }
+ break;
+
+ case 7:
+ printb("Bandits attacking!");
+ final int br1 = shoot3870();
+ b = b - 20 * br1;
+ if (b > 0) {
+ if (br1 <= 1) {
+ print("That was the quickest draw outside of Dodge City.");
+ print("You got at least one and drove 'em off.");
+ return;
+ }
+ } else {
+ t = t / 3;
+ print("You try to drive them off but you run out of bullets.");
+ print("They grab as much cash as they can find.");
+
+ }
+ print("You get shot in the leg -");
+ kh = 1;
+ print("and they grab one of your oxen.");
+ a = a - 10;
+ r = r - 2;
+ print("Better have a doc look at your leg... and soon!");
+ break;
+
+ case 8:
+ printb("You have a fire in your wagon. Food and supplies are damaged.");
+ m = m - 15;
+ f = f - 20;
+ b = b - 400;
+ r = r - 2 * 6 * rnd();
+ break;
+
+ case 9:
+ printb("You lose your way in heavy fog. Time lost regaining the trail.");
+ m = m - 10 - 5 * rnd();
+ break;
+
+ case 10:
+ printb("You come upon a rattlesnake and before you are able to get your gun");
+ printb("out, it bites you.");
+ b = b - 10;
+ r = r - 2;
+ if (r < 0) {
+ printb("You have no medical supplies left, and you die of poison.");
+ die3060(j);
+
+ }
+ print("Fortunately, you acted quickly, sucked out the poison, and");
+ print("treated the wound. It is painful, but you'll survive.");
+ break;
+
+ case 11:
+ print("Your wagon gets swamped fording a river; you lose food and clothes.");
+ m = m - 20 - 20 * rnd();
+ f = f - 15;
+ c = c - 10;
+ break;
+
+ case 12:
+ printb("You're sound asleep and you hear a noise... get up to investigate.");
+ printb("It's wild animals! They attack you!");
+ final int br2 = shoot3870();
+ if (b <= 39) {
+ print("You're almost out of ammo; can't reach more.");
+ print("The wolves come at you biting and clawing.");
+ kh = 1;
+ die3030(j);
+ }
+ if (br2 <= 2) {
+ print("Nice shooting, pardner... They didn't get much.");
+ } else {
+ print("Kind of slow on the draw. The wolves got at your food and clothes.");
+ b = b - 20 * br2;
+ c = c - 2 * br2;
+ f = f - 4 * br2;
+ }
+ break;
+
+ case 13:
+ printb("You're caught in a fierce hailstorm; ammo and supplies are damaged.");
+ m = m - 5 - 10 * rnd();
+ b = b - 150;
+ r = r - 2 - 2 * rnd();
+ break;
+
+ case 14:
+ if (e == 1) {
+ dealWithIllness2880(j);
+ } else if (e == 2 && rnd() > .25) {
+ dealWithIllness2880(j);
+ } else if (e == 3 && rnd() > .5) {
+ dealWithIllness2880(j);
+ }
+ break;
+
+ case 15:
+ printb("Helpful Indians show you where to find more food.");
+ f = f + 7;
+ break;
+
+ default:
+ printb("EVENT " + i);
+ }
+ print();
+
+ }
+
+ private void madeIt3190(int j) throws NoInputException {
+ final double ml = (2040 - ma) / (m - ma);
+ f = f + (1 - ml) * (8 + 5 * e);
+ print("You finally arrived at Oregon City after 2040 long miles.");
+ print("You're exhausted and haggard, but you made it! A real pioneer!");
+ final int d = (int) (14 * (j + ml));
+ final int dm = (int) (d / 30.5);
+ final int dd = (int) (d - 30.5 * dm);
+ print("You've been on the trail for " + dm + " months and " + dd + " days.");
+ print("You have few supplies remaining :");
+ printInventory3350();
+ print();
+ print("President James A. Polk sends you his heartiest");
+
+ print("congratulations and wishes you a prosperous life in your new home.");
+ throw new NoInputException();
+ }
+
+ private boolean riders1390(int j) throws NoInputException {
+ final double value = (Math.pow(m / 100 - 4, 2) + 72) / (Math.pow(m / 100 - 4, 2) + 12) - 1;
+ final double random = 10.0 * rnd();
+ if (random > value) {
+ return false;
+ }
+ int gh = 0;
+ if (rnd() > .2) {
+ gh = 1;
+ }
+ print();
+ print("Riders ahead! They " + (gh == 1 ? "don't " : "") + "look hostile.");
+ int gt;
+ do {
+ print("You can <b>(1)</b> run, <b>(2)</b> attack, <b>(3)</b> ignore them, or <b>(4)</b> circle wagons.");
+ gt = skb.inputInt(screen);
+ } while (gt < 0 || gt > 4);
+ if (rnd() < .2) {
+ gh = 1 - gh;
+ }
+ if (gh == 1) {
+ if (gt == 1) {
+ m = m + 15;
+ a = a - 5;
+ } else if (gt == 2) {
+ m = m - 5;
+ b = b - 100;
+ } else if (gt == 4) {
+ m = m - 20;
+ }
+ print("Riders were friendly, but check for possible losses.");
+ return true;
+ }
+ if (gt == 1) {
+ m = m + 20;
+ r = r - 7;
+ b = b - 150;
+ a = a - 20;
+ } else if (gt == 2) {
+ final int br = shoot3870();
+ b = b - br * 40 - 80;
+ riderShoot(br);
+ } else if (gt == 3) {
+ if (rnd() > .8) {
+ print("They did not attack. Whew!");
+ return true;
+ }
+ b = b - 150;
+ r = r - 7;
+ } else {
+ assert gt == 4;
+ final int br = shoot3870();
+ b = b - br * 30 - 80;
+ m = m - 25;
+ riderShoot(br);
+ }
+ print("Riders were hostile. Better check for losses!");
+ if (b >= 0) {
+ return true;
+ }
+ print();
+ print("<b>Oh, my gosh!</b>");
+ print("They're coming back and you're out of ammo! Your dreams turn to");
+ print("dust as you and your family are massacred on the prairie.");
+ print3110(j);
+ return true;
+
+ }
+
+ private void riderShoot(final int br) {
+ if (br <= 1) {
+ print("Nice shooting - you drove them off.");
+ } else if (br <= 4) {
+ print("Kind of slow with your Colt .45.");
+ } else {
+ print("Pretty slow on the draw, partner. You got a nasty flesh wound.");
+ kh = 1;
+ print("You'll have to see the doc soon as you can.");
+ }
+ }
+
+ private void montains2640(int j) throws NoInputException {
+ if (m <= 975) {
+ return;
+ }
+ final double mm = m / 100.0 - 15;
+ if (10 * rnd() > 9 - (mm * mm + 72) / (mm * mm + 12)) {
+ southPass2750(j);
+ return;
+ }
+ print("You're in rugged mountain country.");
+ if (rnd() <= .1) {
+ print("You get lost and lose valuable time trying to find the trail.");
+ m = m - 60;
+ southPass2750(j);
+ return;
+ }
+ if (rnd() > .11) {
+ print("The going is really slow; oxen are very tired.");
+ m = m - 45 - 50 * rnd();
+ } else {
+ print("Trail cave in damages your wagon. You lose time and supplies.");
+ m = m - 20 - 30 * rnd();
+ b = b - 200;
+ r = r - 3;
+ }
+ southPass2750(j);
+
+ }
+
+ private void southPass2750(int j) throws NoInputException {
+ if (kp == 0) {
+ kp = 1;
+ if (rnd() < .8) {
+ blizzard2840(j);
+ return;
+ }
+ print("You made it safely through the South Pass....no snow!");
+ }
+ if (m < 1700) {
+ return;
+ }
+ if (km == 0) {
+ km = 1;
+ if (rnd() < .7) {
+ blizzard2840(j);
+ }
+ }
+
+ }
+
+ private void blizzard2840(int j) throws NoInputException {
+ print("Blizzard in the mountain pass. Going is slow; supplies are lost.");
+ kb = 1;
+ m = m - 30 - 40 * rnd();
+ f = f - 12;
+ b = b - 200;
+ r = r - 5;
+ if (c < 18 + 2 * rnd()) {
+ dealWithIllness2880(j);
+ }
+ }
+
+ private void dealWithIllness2880(int j) throws NoInputException {
+ if (100 * rnd() < 10 + 35 * (e - 1)) {
+ print("Mild illness. Your own medicine will cure it.");
+ m -= 5;
+ r -= 1;
+ } else if (100 * rnd() < 100.0 - 40.0 / Math.pow(4.0, e - 1)) {
+ print("The whole family is sick. Your medicine will probably work okay.");
+ m -= 5;
+ r -= 2.5;
+ } else {
+ print("Serious illness in the family. You'll have to stop and see a doctor");
+ print("soon. For now, your medicine will work.");
+ r -= 5;
+ ks = 1;
+ }
+ if (r <= 0) {
+ print("...if only you had enough.");
+ outOfMedicalSupplies3020(j);
+ }
+
+ }
+
+ private void eating1310(int j) throws NoInputException {
+ if (f < 5) {
+ die3000(j);
+ return;
+ }
+ do {
+ print("Do you want to eat <b>(1)</b> poorly, <b>(2)</b> moderately or <b>(3)</b> well ?");
+ e = skb.inputInt(screen);
+ if (e < 1 || e > 3) {
+ print("Enter 1, 2, or 3, please.");
+ break;
+ }
+ final int ee = (int) (4 + 2.5 * e);
+ if (e == 1 && ee > f) {
+ f = 0;
+ return;
+ }
+ if (ee > f) {
+ print("You don't have enough to eat that well.");
+ break;
+ }
+ f -= ee;
+ return;
+ } while (true);
+
+ }
+
+ private void needDoctorBadly3010(int j) throws NoInputException {
+ print("<b>You need a doctor badly but can't afford one.</b>");
+ die3030(j);
+ }
+
+ private void outOfMedicalSupplies3020(int j) throws NoInputException {
+ print("<b>You have run out of all medical supplies.</b>");
+ print();
+ die3030(j);
+ }
+
+ private void die3000(int j) throws NoInputException {
+ screen.clear();
+ print("<b>You run out of food and starve to death.</b>");
+ print();
+ print3110(j);
+ }
+
+ private void die3030(int j) throws NoInputException {
+ print("The wilderness is unforgiving and you die of " + (kh == 1 ? "your injuries" : "pneumonia"));
+ die3060(j);
+ }
+
+ private void die3060(int j) throws NoInputException {
+ print("Your family tries to push on, but finds the going too rough");
+ print(" without you.");
+ print3110(j);
+ }
+
+ private void print3110(int j) throws NoInputException {
+ print("Some travelers find the bodies of you and your");
+ print("family the following spring. They give you a decent");
+ print("burial and notify your next of kin.");
+ print();
+ print("At the time of your unfortunate demise, you had been on the trail");
+ final int d = 14 * j;
+ final int dm = (int) (d / 30.5);
+ final int dd = (int) (d - 30.5 * dm);
+ print("for " + dm + " months and " + dd + " days and had covered " + (int) ((m + 70)) + " miles.");
+ print();
+ print("You had a few supplies left :");
+ printInventory3350();
+ throw new NoInputException();
+ }
+
+ private void question1000(int j) throws NoInputException {
+ int x;
+ if (j % 2 == 1) {
+ do {
+ print("Want to <b>(1)</b> stop at the next fort, <b>(2)</b> hunt, or <b>(3)</b> push on ?");
+ x = skb.inputInt(screen);
+ if (x == 3) {
+ return;
+ }
+ if (x == 1) {
+ stopAtFort1100(j);
+ return;
+ }
+ if (x == 2) {
+ hunt1200(j);
+ if (kq == 0) {
+ return;
+ }
+ }
+ } while (true);
+ } else {
+ do {
+ print("Would you like to <b>(1)</b> hunt or <b>(2)</b> continue on ?");
+ x = skb.inputInt(screen);
+ if (x == 2) {
+ return;
+ }
+ } while (x < 1 || x > 2);
+ if (x == 1) {
+ hunt1200(j);
+ }
+ }
+
+ }
+
+ private void hunt1200(int j) throws NoInputException {
+ kq = 0;
+ if (b <= 39) {
+ print("Tough luck. You don't have enough ammo to hunt.");
+ kq = 1;
+ return;
+ }
+ m = m - 45;
+ final int br = shoot3870();
+ if (br <= 1) {
+ print("Right between the eyes... you got a big one!");
+ print("Full bellies tonight!");
+ b = b - 10 - 4 * rnd();
+ f = f + 26 + 3 * rnd();
+ return;
+ }
+ if (100.0 * rnd() < 13 * br) {
+ print("You missed completely... and your dinner got away.");
+ return;
+ }
+ print("Nice shot... right on target... good eatin' tonight!");
+ f = f + 24 - 2 * br;
+ b = b - 10 - 3 * br;
+ return;
+ }
+
+ private void stopAtFort1100(int j) throws NoInputException {
+ if (t <= 0) {
+ print("You sing with the folks there and get a good");
+ print("night's sleep, but you have no money to buy anything.");
+ return;
+ }
+
+ while (true) {
+ print("What would you like to spend on each of the following");
+ print("Food?");
+ final double p1 = skb.inputInt(screen);
+ print("Ammunition?");
+ final double p2 = skb.inputInt(screen);
+ print("Clothing?");
+ final double p3 = skb.inputInt(screen);
+ print("Medicine and supplies?");
+ final double p4 = skb.inputInt(screen);
+ final double p = p1 + p2 + p3 + p4;
+ print("The storekeeper tallies up your bill. It comes to $" + ((int) p));
+ if (t >= p) {
+ t = t - p;
+ f = f + .67 * p1;
+ b = b + 33 * p2;
+ c = c + .67 * p3;
+ r = r + .67 * p4;
+ return;
+ }
+ print("Uh, oh. That's more than you have. Better start over.");
+ }
+ }
+
+ private void printInventory3350() {
+ // print("+------+------+------+---------+--------------------+");
+ print();
+ print("| <u>Cash</u> | <u>Food</u> | <u>Ammo</u> | <u>Clothes</u> | <u>Medicine/parts/...</u> |");
+ print("+------+------+------+---------+--------------------+");
+ if (t < 0) {
+ t = 0;
+ }
+ if (f < 0) {
+ f = 0;
+ }
+ if (b < 0) {
+ b = 0;
+ }
+ if (c < 0) {
+ c = 0;
+ }
+ if (r < 0) {
+ r = 0;
+ }
+ print(String.format("|%5d |%5d |%5d | %5d | %5d |", (int) t, (int) f, (int) b, (int) c, (int) r));
+ print("+------+------+------+---------+--------------------+");
+ print();
+ }
+
+ private String whereAreWe() {
+ if (m < 5) {
+ return "on the high prairie.";
+ }
+ if (m < 200) {
+ return "near Independence Crossing on the Big Blue River.";
+ }
+ if (m < 350) {
+ return "following the Platte River.";
+ }
+ if (m < 450) {
+ return "near Fort Kearney.";
+ }
+ if (m < 600) {
+ return "following the North Platte River.";
+ }
+ if (m < 750) {
+ return "within sight of Chimney Rock.";
+ }
+ if (m < 850) {
+ return "near Fort Laramie.";
+ }
+ if (m < 1000) {
+ return "close upon Independence Rock.";
+ }
+ if (m < 1050) {
+ return "in the Big Horn Mountains.";
+ }
+ if (m < 1150) {
+ return "following the Green River.";
+ }
+ if (m < 1250) {
+ return "not too far from Fort Hall.";
+ }
+ if (m < 1400) {
+ return "following the Snake River.";
+ }
+ if (m < 1550) {
+ return "not far from Fort Boise.";
+ }
+ if (m < 1850) {
+ return "in the Blue Mountains.";
+ }
+ return "following the Columbia River";
+
+ }
+
+ private void printInitialScenario490() {
+ print(" Your journey over the Oregon Trail takes place in 1847.");
+ print();
+ print("Starting in Independence, Missouri, you plan to take your family of");
+ print("five over 2040 tough miles to Oregon City.");
+ print();
+ print(" Having saved <b>$420</b> for the trip, you bought a wagon for <b>$70</b> and");
+ print("now have to purchase the following items :");
+ print();
+ print(" * <b>Oxen</b> (spending more will buy you a larger and better team which");
+ print(" will be faster so you'll be on the trail for less time)");
+ print(" * <b>Food</b> (you'll need ample food to keep up your strength and health)");
+ print(" * <b>Ammunition</b> ($1 buys a belt of 50 bullets. You'll need ammo for");
+ print(" hunting and for fighting off attacks by bandits and animals)");
+ print(" * <b>Clothing</b> (you'll need warm clothes, especially when you hit the");
+ print(" snow and freezing weather in the mountains)");
+ print(" * <b>Other supplies</b> (includes medicine, first-aid supplies, tools, and");
+ print(" wagon parts for unexpected emergencies)");
+ print();
+ print(" You can spend all your money at the start or save some to spend");
+ print("at forts along the way. However, items cost more at the forts. You");
+ print("can also hunt for food if you run low.");
+ print();
+
+ }
+
+ private void initialPurchasesOfPlayer690() throws NoInputException {
+ if (skb.hasMore()) {
+ screen.clear();
+ }
+ do {
+ print("How much do you want to pay for a team of oxen ?");
+ a = skb.inputInt(screen);
+ if (a < 100) {
+ print("No one in town has a team that cheap");
+ continue;
+ }
+ break;
+ } while (true);
+ if (a >= 151) {
+ print("You choose an honest dealer who tells you that $" + a + " is too much for");
+ print("a team of oxen. He charges you $150 and gives you $" + (a - 150) + " change.");
+ a = 150;
+ }
+ do {
+ print();
+ print("How much do you want to spend on food ?");
+ f = skb.inputInt(screen);
+ if (f <= 13) {
+ print("That won't even get you to the Kansas River");
+ print(" - better spend a bit more.");
+ continue;
+ }
+ if (a + f > 300) {
+ print("You wont't have any for ammo and clothes.");
+ continue;
+ }
+ break;
+ } while (true);
+ do {
+ print();
+ print("How much do you want to spend on ammunition ?");
+ b = skb.inputInt(screen);
+ if (b < 2) {
+ print("Better take a bit just for protection.");
+ continue;
+ }
+ if (a + f + b > 320) {
+ print("That won't leave any money for clothes.");
+ continue;
+ }
+ break;
+ } while (true);
+ do {
+ print();
+ print("How much do you want to spend on clothes ?");
+ c = skb.inputInt(screen);
+ if (c <= 24) {
+ print("Your family is going to be mighty cold in.");
+ print("the montains.");
+ print("Better spend a bit more.");
+ continue;
+ }
+ if (a + f + b + c > 345) {
+ print("That leaves nothing for medecine.");
+ continue;
+ }
+ break;
+ } while (true);
+ do {
+ print();
+ screen.print("How much for medecine, bandage, repair parts, etc. ?");
+ r = skb.inputInt(screen);
+ if (r <= 5) {
+ print("That's not at all wise.");
+ continue;
+ }
+ if (a + f + b + c + r > 350) {
+ print("You don't have that much money.");
+ continue;
+ }
+ break;
+ } while (true);
+ t = 350 - a - f - b - c - r;
+ print();
+ print("You now have <b>$" + ((int) t) + " left.</b>");
+ b = 50 * b;
+ }
+
+ private void initialShootingRanking920() throws NoInputException {
+ print();
+ print("Please rank your shooting (typing) ability as follows :");
+ print(" (1) Ace marksman (2) Good shot (3) Fair to middlin'");
+ print(" (4) Need more practice (5) Shaky knees");
+ do {
+ print();
+ print("How do you rank yourself ?");
+ dr = skb.inputInt(screen);
+ if (dr >= 1 && dr <= 6) {
+ return;
+ }
+ print("Please enter 1, 2, 3, 4 or 5.");
+ } while (true);
+ }
+
+ private int e;
+ private int a;
+ private double b;
+ private double f;
+ private double c;
+ private double r;
+ private double t;
+ private int dr;
+ private double m;
+
+ enum ShootingWord {
+ POW, BANG, BLAM, WHOP, WHAM, ZING, ZACK, ZANG, WOOSH, BAM, ZAP, BOOM, WOW, CLANG, BOING, ZOW, PANG, ZOSH, KAZ, KOOG, ZOOP, PONG, PING, BAZ, ZONG, PAM, POOM, DOING;
+
+ public static ShootingWord safeValueOf(String s) {
+ try {
+ return valueOf(StringUtils.goUpperCase(s));
+ } catch (IllegalArgumentException e) {
+ return null;
+ }
+ }
+
+ public int decode(ShootingWord key) {
+ return (ordinal() + key.ordinal()) % NB_WORDS;
+ }
+
+ public ShootingWord encode(int v) {
+ v = v - this.ordinal();
+ if (v < 0) {
+ v += NB_WORDS;
+ }
+ return ShootingWord.values()[v];
+ }
+ }
+
+ private static int NB_WORDS = ShootingWord.values().length;
+
+ private int getTime() {
+ return (int) ((System.currentTimeMillis() / 1000L) % NB_WORDS);
+ }
+
+ private int shoot3870() throws NoInputException {
+ final int time1 = getTime();
+ final ShootingWord word1Printed = ShootingWord.values()[time1];
+ if (skb.hasMore() == false) {
+ print("Type: " + word1Printed);
+ }
+ final String typed1 = skb.input(screen);
+ ShootingWord wordType1 = ShootingWord.safeValueOf(typed1);
+ final int delta;
+ if (wordType1 == null) {
+ delta = NB_WORDS - 1;
+ wordType1 = ShootingWord.values()[NB_WORDS - 1];
+ } else {
+ delta = protect(getTime() - wordType1.ordinal());
+ }
+ // print("delta="+delta);
+ final ShootingWord word2 = wordType1.encode(delta);
+ if (skb.hasMore() == false) {
+ print("Type: " + word2);
+ }
+ final String typed2 = skb.input(screen);
+ final ShootingWord wordType2 = ShootingWord.safeValueOf(typed2);
+ final int duration = wordType2 == null ? NB_WORDS : wordType1.decode(wordType2) - dr;
+ // print("duration=" + duration);
+ if (duration < 0) {
+ return 0;
+ }
+ return duration;
+ }
+
+ private int protect(int v) {
+ while (v >= NB_WORDS) {
+ v -= NB_WORDS;
+ }
+ while (v < 0) {
+ v += NB_WORDS;
+ }
+ return v;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/oregon/PSystemOregon.java b/src/net/sourceforge/plantuml/oregon/PSystemOregon.java
new file mode 100644
index 0000000..fa4442c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/oregon/PSystemOregon.java
@@ -0,0 +1,118 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.oregon;
+
+import java.awt.Font;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.core.DiagramDescription;
+import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.graphic.GraphicStrings;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+import net.sourceforge.plantuml.ugraphic.ImageBuilder;
+import net.sourceforge.plantuml.ugraphic.UAntiAliasing;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.StringUtils;
+
+public class PSystemOregon extends AbstractPSystem {
+
+ private Screen screen;
+ private List<String> inputs;
+
+ @Deprecated
+ public PSystemOregon(Keyboard keyboard) {
+ final BasicGame game = new OregonBasicGame();
+ try {
+ game.run(keyboard);
+ this.screen = game.getScreen();
+ // this.screen = new Screen();
+ // screen.print("Game ended??");
+ } catch (NoInputException e) {
+ this.screen = game.getScreen();
+ }
+ }
+
+ public PSystemOregon() {
+ this.inputs = new ArrayList<String>();
+ }
+
+ public void add(String line) {
+ if (StringUtils.isNotEmpty(line)) {
+ inputs.add(line);
+ }
+ }
+
+ private Screen getScreen() {
+ if (screen == null) {
+ final Keyboard keyboard = new KeyboardList(inputs);
+ final BasicGame game = new OregonBasicGame();
+ try {
+ game.run(keyboard);
+ this.screen = game.getScreen();
+ // this.screen = new Screen();
+ // screen.print("Game ended??");
+ } catch (NoInputException e) {
+ this.screen = game.getScreen();
+ }
+ }
+ return screen;
+ }
+
+ public ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormat) throws IOException {
+ final GraphicStrings result = getGraphicStrings();
+ final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(),
+ getMetadata(), null, 0, 0, null, false);
+ imageBuilder.addUDrawable(result);
+ return imageBuilder.writeImageTOBEMOVED(fileFormat.getFileFormat(), os);
+ }
+
+ private GraphicStrings getGraphicStrings() throws IOException {
+ final UFont font = new UFont("Monospaced", Font.PLAIN, 14);
+ return new GraphicStrings(getScreen().getLines(), font, HtmlColorUtils.GREEN, HtmlColorUtils.BLACK,
+ UAntiAliasing.ANTI_ALIASING_OFF);
+ }
+
+ public DiagramDescription getDescription() {
+ return new DiagramDescriptionImpl("(The Oregon Trail)", getClass());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/oregon/PSystemOregonFactory.java b/src/net/sourceforge/plantuml/oregon/PSystemOregonFactory.java
new file mode 100644
index 0000000..1bf8cc0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/oregon/PSystemOregonFactory.java
@@ -0,0 +1,64 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.oregon;
+
+import net.sourceforge.plantuml.command.PSystemBasicFactory;
+
+public class PSystemOregonFactory extends PSystemBasicFactory<PSystemOregon> {
+
+ // public PSystemOregon getSystem() {
+ // final Keyboard keyboard;
+ // if (inputs == null) {
+ // keyboard = new KeyboardList("");
+ // } else {
+ // keyboard = new KeyboardList(inputs);
+ // }
+ // system = new PSystemOregon(keyboard);
+ // return system;
+ // }
+
+ @Override
+ public PSystemOregon executeLine(PSystemOregon system, String line) {
+ if (system == null && line.equalsIgnoreCase("run oregon trail")) {
+ return new PSystemOregon();
+ }
+ if (system == null) {
+ return null;
+ }
+ system.add(line);
+ return system;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/oregon/Screen.java b/src/net/sourceforge/plantuml/oregon/Screen.java
new file mode 100644
index 0000000..b5225c4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/oregon/Screen.java
@@ -0,0 +1,64 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.oregon;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public class Screen {
+ private final List<String> lines = new ArrayList<String>();
+
+ public void clear() {
+ lines.clear();
+ }
+
+ public void print(String s) {
+ lines.add(s);
+ }
+
+ public void print() {
+ lines.add(" ");
+ }
+
+ public List<String> getLines() {
+ return Collections.unmodifiableList(lines);
+ }
+
+ public String getLastLine() {
+ return lines.get(lines.size()-1);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/oregon/SecureCoder.java b/src/net/sourceforge/plantuml/oregon/SecureCoder.java
new file mode 100644
index 0000000..5d252a6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/oregon/SecureCoder.java
@@ -0,0 +1,71 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.oregon;
+
+public class SecureCoder {
+
+ private static final int m[] = { 38, 152, 264, 491, 573, 616, 727, 880, 905, 1090, 1188, 1315, 1544, 1603, 1756,
+ 1831, 1962, 2025, 2100, 2257, 2381, 2469, 2536, 2714, 2948, 3077, 3166, 3219, 3340, 3455, 3701, 3892, 3934,
+ 4193, 4372, 4404, 4521, 4650, 4739, 4865, 4987, 5053, 5135, 5282, 5309, 5446, 5628, 5817, 5970, 6002, 6174,
+ 6295, 6367, 6420, 6558, 6689, 6913, 7061, 7129, 7206, 7333, 7510, 7697, 7742, 7854, 8084, 8147, 8230, 8326,
+ 8412, 8599, 8675, 8763, 8808, 8951, 9049, 9111, 9223, 9394, 9478, 9507, 9632, 9785 };
+
+ private static final int dec[] = new int[10000];
+
+ static {
+ for (int i = 0; i < dec.length; i++) {
+ dec[i] = -1;
+ }
+ for (int i = 0; i < m.length; i++) {
+ final int enc = m[i];
+ dec[enc] = i;
+ for (int n : MagicTable.getNeighboors(enc)) {
+ if (dec[n] != -1) {
+ throw new IllegalStateException();
+ }
+ dec[n] = i + 1000;
+ }
+ }
+ }
+
+ public int encode(int i) {
+ return m[i];
+ }
+
+ public int decode(int v) {
+ return dec[v];
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/oregon/SmartKeyboard.java b/src/net/sourceforge/plantuml/oregon/SmartKeyboard.java
new file mode 100644
index 0000000..07e85d1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/oregon/SmartKeyboard.java
@@ -0,0 +1,74 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.oregon;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public class SmartKeyboard {
+
+ private final Keyboard keyboard;
+ private final List<String> history = new ArrayList<String>();
+
+ public SmartKeyboard(Keyboard keyboard) {
+ this.keyboard = keyboard;
+ }
+
+ public String input(Screen screen) throws NoInputException {
+ final String s = keyboard.input();
+ history.add(s);
+ screen.print("<i>? " + s);
+ return s;
+ }
+
+ public int inputInt(Screen screen) throws NoInputException {
+ final String s = input(screen);
+ if (s.matches("\\d+") == false) {
+ screen.print("Please enter a valid number instead of " + s);
+ throw new NoInputException();
+ }
+ return Integer.parseInt(s);
+ }
+
+ public boolean hasMore() {
+ return keyboard.hasMore();
+ }
+
+ public List<String> getHistory() {
+ return Collections.unmodifiableList(history);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/pdf/PdfConverter.java b/src/net/sourceforge/plantuml/pdf/PdfConverter.java
new file mode 100644
index 0000000..188f3d3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/pdf/PdfConverter.java
@@ -0,0 +1,77 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.pdf;
+import java.io.File;
+import java.lang.reflect.Method;
+
+public class PdfConverter {
+
+ public static void convert(File svgFile, File pdfFile) {
+
+ if (svgFile.exists() == false) {
+ throw new IllegalArgumentException();
+ }
+ pdfFile.delete();
+ if (pdfFile.exists()) {
+ throw new IllegalStateException();
+ }
+
+ try {
+ final Class<?> clSVGConverter = Class.forName("org.apache.batik.apps.rasterizer.SVGConverter");
+
+ final Object converter = clSVGConverter.newInstance();
+
+ final Class<?> clDestinationType = Class.forName("org.apache.batik.apps.rasterizer.DestinationType");
+ final Object pdf = clDestinationType.getField("PDF").get(null);
+ final Method setDestinationType = clSVGConverter.getMethod("setDestinationType", clDestinationType);
+
+ setDestinationType.invoke(converter, pdf);
+
+ final String[] path = new String[] { svgFile.getAbsolutePath() };
+ final Method setSources = clSVGConverter.getMethod("setSources", path.getClass());
+ setSources.invoke(converter, new Object[] { path });
+ final Method setDst = clSVGConverter.getMethod("setDst", pdfFile.getClass());
+ setDst.invoke(converter, new Object[] { pdfFile });
+ final Method execute = clSVGConverter.getMethod("execute");
+ execute.invoke(converter);
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new UnsupportedOperationException();
+ }
+ if (pdfFile.exists() == false) {
+ throw new IllegalStateException();
+ }
+ }
+}
diff --git a/src/net/sourceforge/plantuml/png/Metadata.java b/src/net/sourceforge/plantuml/png/Metadata.java
new file mode 100644
index 0000000..d3e0d91
--- /dev/null
+++ b/src/net/sourceforge/plantuml/png/Metadata.java
@@ -0,0 +1,126 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.png;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Iterator;
+
+import javax.imageio.ImageIO;
+import javax.imageio.ImageReader;
+import javax.imageio.metadata.IIOMetadata;
+import javax.imageio.stream.ImageInputStream;
+
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+
+public class Metadata {
+
+ public static void main(String[] args) throws IOException {
+ final Metadata meta = new Metadata();
+ final int length = args.length;
+ for (int i = 0; i < length; i++) {
+ meta.readAndDisplayMetadata(new File(args[i]));
+ }
+ }
+
+ public void readAndDisplayMetadata(File file) throws IOException {
+ final ImageInputStream iis = ImageIO.createImageInputStream(file);
+ final Iterator<ImageReader> readers = ImageIO.getImageReaders(iis);
+
+ if (readers.hasNext()) {
+ // pick the first available ImageReader
+ final ImageReader reader = readers.next();
+
+ // attach source to the reader
+ reader.setInput(iis, true);
+
+ // read metadata of first image
+ final IIOMetadata metadata = reader.getImageMetadata(0);
+
+ final String[] names = metadata.getMetadataFormatNames();
+ final int length = names.length;
+ for (int i = 0; i < length; i++) {
+ displayMetadata(metadata.getAsTree(names[i]));
+ }
+ }
+ }
+
+ private void displayMetadata(Node root) {
+ displayMetadata(root, 0);
+ }
+
+ private void indent(int level) {
+ for (int i = 0; i < level; i++) {
+ System.out.print(" ");
+ }
+ }
+
+ private void displayMetadata(Node node, int level) {
+ // print open tag of element
+ indent(level);
+ System.out.print("<" + node.getNodeName());
+ final NamedNodeMap map = node.getAttributes();
+ if (map != null) {
+
+ // print attribute values
+ final int length = map.getLength();
+ for (int i = 0; i < length; i++) {
+ final Node attr = map.item(i);
+ System.out.print(" " + attr.getNodeName() + "=\"" + attr.getNodeValue() + "\"");
+ }
+ }
+
+ Node child = node.getFirstChild();
+ if (child == null) {
+ // no children, so close element and return
+ System.out.println("/>");
+ return;
+ }
+
+ // children, so close current tag
+ System.out.println(">");
+ while (child != null) {
+ // print children recursively
+ displayMetadata(child, level + 1);
+ child = child.getNextSibling();
+ }
+
+ // print close tag of element
+ indent(level);
+ System.out.println("</" + node.getNodeName() + ">");
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/png/MetadataTag.java b/src/net/sourceforge/plantuml/png/MetadataTag.java
new file mode 100644
index 0000000..bd16df7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/png/MetadataTag.java
@@ -0,0 +1,118 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.png;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Iterator;
+
+import javax.imageio.ImageIO;
+import javax.imageio.ImageReader;
+import javax.imageio.metadata.IIOMetadata;
+import javax.imageio.stream.ImageInputStream;
+
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+
+public class MetadataTag {
+
+ private final File f;
+ private final String tag;
+
+ public MetadataTag(File f, String tag) {
+ this.f = f;
+ this.tag = tag;
+ }
+
+ public String getData() throws IOException {
+ final ImageInputStream iis = ImageIO.createImageInputStream(f);
+ final Iterator<ImageReader> readers = ImageIO.getImageReaders(iis);
+
+ if (readers.hasNext()) {
+ // pick the first available ImageReader
+ final ImageReader reader = readers.next();
+
+ // attach source to the reader
+ reader.setInput(iis, true);
+
+ // read metadata of first image
+ final IIOMetadata metadata = reader.getImageMetadata(0);
+
+ final String[] names = metadata.getMetadataFormatNames();
+ final int length = names.length;
+ for (int i = 0; i < length; i++) {
+ final String result = displayMetadata(metadata.getAsTree(names[i]));
+ if (result != null) {
+ return result;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ private String displayMetadata(Node root) {
+ return displayMetadata(root, 0);
+ }
+
+ private String displayMetadata(Node node, int level) {
+ final NamedNodeMap map = node.getAttributes();
+ if (map != null) {
+ final Node keyword = map.getNamedItem("keyword");
+ if (keyword != null && tag.equals(keyword.getNodeValue())) {
+ final Node text = map.getNamedItem("value");
+ if (text != null) {
+ return text.getNodeValue();
+ }
+ }
+ }
+
+ Node child = node.getFirstChild();
+
+ // children, so close current tag
+ while (child != null) {
+ // print children recursively
+ final String result = displayMetadata(child, level + 1);
+ if (result != null) {
+ return result;
+ }
+ child = child.getNextSibling();
+ }
+
+ return null;
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/png/PngFlashcoder.java b/src/net/sourceforge/plantuml/png/PngFlashcoder.java
new file mode 100644
index 0000000..39a6ae5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/png/PngFlashcoder.java
@@ -0,0 +1,97 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.png;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.image.BufferedImage;
+import java.util.List;
+
+import net.sourceforge.plantuml.ugraphic.UAntiAliasing;
+
+public class PngFlashcoder {
+
+ private final List<BufferedImage> flashcodes;
+
+ public PngFlashcoder(List<BufferedImage> flashcodes) {
+ this.flashcodes = flashcodes;
+ }
+
+ public BufferedImage processImage(BufferedImage im, Color background) {
+ if (flashcodes != null) {
+ im = addImage(im, background);
+ }
+ return im;
+
+ }
+
+ private BufferedImage addImage(BufferedImage im, Color background) {
+
+ final double width = Math.max(im.getWidth(), getWidth(flashcodes));
+ final double height = im.getHeight() + getHeight(flashcodes);
+
+ final BufferedImage newIm = new BufferedImage((int) width, (int) height, BufferedImage.TYPE_INT_RGB);
+ final Graphics2D g2d = newIm.createGraphics();
+
+ UAntiAliasing.ANTI_ALIASING_OFF.apply(g2d);
+ g2d.setColor(background);
+ g2d.fillRect(0, 0, newIm.getWidth(), newIm.getHeight());
+ g2d.drawImage(im, null, 0, 0);
+ int x = 0;
+ for (BufferedImage f : flashcodes) {
+ g2d.drawImage(f, null, x, (int) im.getHeight());
+ x += f.getWidth();
+ }
+ g2d.dispose();
+ return newIm;
+
+ }
+
+ public static int getHeight(List<BufferedImage> flashcodes) {
+ int result = 0;
+ for (BufferedImage im : flashcodes) {
+ result = Math.max(result, im.getWidth());
+ }
+ return result;
+ }
+
+ public static int getWidth(List<BufferedImage> flashcodes) {
+ int result = 0;
+ for (BufferedImage im : flashcodes) {
+ result += im.getWidth();
+ }
+ return result;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/png/PngIO.java b/src/net/sourceforge/plantuml/png/PngIO.java
new file mode 100644
index 0000000..03effcc
--- /dev/null
+++ b/src/net/sourceforge/plantuml/png/PngIO.java
@@ -0,0 +1,107 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.png;
+
+import java.awt.image.RenderedImage;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import javax.imageio.ImageIO;
+
+import net.sourceforge.plantuml.Log;
+
+public class PngIO {
+
+ private static final String copyleft = "Generated by http://plantuml.sourceforge.net";
+
+ public static void write(RenderedImage image, File file, int dpi) throws IOException {
+ write(image, file, null, dpi);
+ }
+
+ public static void write(RenderedImage image, OutputStream os, int dpi) throws IOException {
+ write(image, os, null, dpi);
+ }
+
+ public static void write(RenderedImage image, File file, String metadata, int dpi) throws IOException {
+ OutputStream os = null;
+ try {
+ os = new BufferedOutputStream(new FileOutputStream(file));
+ write(image, os, metadata, dpi);
+ } finally {
+ if (os != null) {
+ os.close();
+ }
+ }
+ Log.debug("File is " + file);
+ Log.debug("File size " + file.length());
+ if (file.length() == 0) {
+ Log.error("File size is zero: " + file);
+ ImageIO.write(image, "png", file);
+ }
+ }
+
+ public static void write(RenderedImage image, OutputStream os, String metadata, int dpi) throws IOException {
+ write(image, os, metadata, dpi, null);
+ }
+
+ public static void write(RenderedImage image, OutputStream os, String metadata, int dpi, String debugData)
+ throws IOException {
+ if (metadata != null && checkPNGMetadata()) {
+ PngIOMetadata.writeWithMetadata(image, os, metadata, dpi, debugData);
+ } else {
+ ImageIO.write(image, "png", os);
+ }
+
+ }
+
+ static boolean checkPNGMetadata() {
+ try {
+ final Class cl = Class.forName("com.sun.imageio.plugins.png.PNGMetadata");
+ if (cl == null) {
+ Log.info("Cannot load com.sun.imageio.plugins.png.PNGMetadata");
+ return false;
+ }
+ Log.info("Ok for com.sun.imageio.plugins.png.PNGMetadata");
+ return true;
+ } catch (Exception e) {
+ Log.info("Error loading com.sun.imageio.plugins.png.PNGMetadata " + e);
+ return false;
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/png/PngIOMetadata.java b/src/net/sourceforge/plantuml/png/PngIOMetadata.java
new file mode 100644
index 0000000..0a3a92a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/png/PngIOMetadata.java
@@ -0,0 +1,122 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.png;
+
+import java.awt.image.RenderedImage;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Iterator;
+
+import javax.imageio.IIOImage;
+import javax.imageio.ImageIO;
+import javax.imageio.ImageWriter;
+
+import net.sourceforge.plantuml.Log;
+
+import com.sun.imageio.plugins.png.PNGMetadata;
+
+public class PngIOMetadata {
+
+ private static final String copyleft = "Generated by http://plantuml.sourceforge.net";
+
+ public static void writeWithMetadata(RenderedImage image, OutputStream os, String metadata, int dpi, String debugData) throws IOException {
+
+ // Create & populate metadata
+ final PNGMetadata pngMetadata = new PNGMetadata();
+
+ if (dpi != 96) {
+ pngMetadata.pHYs_present = true;
+ pngMetadata.pHYs_unitSpecifier = PNGMetadata.PHYS_UNIT_METER;
+ pngMetadata.pHYs_pixelsPerUnitXAxis = (int) Math.round(dpi / .0254 + 0.5);
+ pngMetadata.pHYs_pixelsPerUnitYAxis = pngMetadata.pHYs_pixelsPerUnitXAxis;
+ }
+
+ if (metadata != null) {
+ pngMetadata.zTXt_keyword.add("plantuml");
+ pngMetadata.zTXt_compressionMethod.add(new Integer(0));
+ pngMetadata.zTXt_text.add(metadata);
+ // Log.println("metadata=" + metadata);
+ // if (metadata.equals("Generated by
+ // http://plantuml.sourceforge.net")) {
+ // throw new IllegalArgumentException();
+ // }
+ }
+
+ if (debugData != null) {
+ pngMetadata.tEXt_keyword.add("debug");
+ pngMetadata.tEXt_text.add(debugData);
+ }
+
+
+ pngMetadata.tEXt_keyword.add("copyleft");
+ pngMetadata.tEXt_text.add(copyleft);
+
+ Log.debug("PngIOMetadata pngMetadata=" + pngMetadata);
+
+ // Render the PNG to file
+ final IIOImage iioImage = new IIOImage(image, null, pngMetadata);
+ Log.debug("PngIOMetadata iioImage=" + iioImage);
+ // Attach the metadata
+ final ImageWriter imagewriter = getImageWriter();
+ Log.debug("PngIOMetadata imagewriter=" + imagewriter);
+
+ synchronized (imagewriter) {
+ imagewriter.setOutput(ImageIO.createImageOutputStream(os));
+ imagewriter.write(null, iioImage, null);
+ os.flush();
+ imagewriter.reset();
+ imagewriter.dispose();
+ }
+// Log.debug("PngIOMetadata before flush");
+// os.flush();
+// Log.debug("PngIOMetadata after flush");
+ }
+
+ private static ImageWriter getImageWriter() {
+ final Iterator<ImageWriter> iterator = ImageIO.getImageWritersBySuffix("png");
+ for (final Iterator<ImageWriter> it = ImageIO.getImageWritersBySuffix("png"); it.hasNext();) {
+ final ImageWriter imagewriter = iterator.next();
+ Log.debug("PngIOMetadata countImageWriter = " + it.next());
+ if (imagewriter.getClass().getName().equals("com.sun.imageio.plugins.png.PNGImageWriter")) {
+ Log.debug("PngIOMetadata Found sun PNGImageWriter");
+ return imagewriter;
+ }
+
+ }
+ Log.debug("Using first one");
+ return ImageIO.getImageWritersBySuffix("png").next();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/png/PngRotation.java b/src/net/sourceforge/plantuml/png/PngRotation.java
new file mode 100644
index 0000000..2b746a3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/png/PngRotation.java
@@ -0,0 +1,62 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.png;
+
+import java.awt.Graphics2D;
+import java.awt.geom.AffineTransform;
+import java.awt.image.BufferedImage;
+
+import net.sourceforge.plantuml.Log;
+
+public class PngRotation {
+
+ public static BufferedImage process(BufferedImage im) {
+
+ Log.info("Rotation");
+
+ final BufferedImage newIm = new BufferedImage(im.getHeight(), im.getWidth(), BufferedImage.TYPE_INT_RGB);
+ final Graphics2D g2d = newIm.createGraphics();
+
+ final AffineTransform at = new AffineTransform(0, 1, 1, 0, 0, 0);
+ at.concatenate(new AffineTransform(-1, 0, 0, 1, im.getWidth(), 0));
+ g2d.setTransform(at);
+
+ g2d.drawImage(im, 0, 0, null);
+ g2d.dispose();
+
+ return newIm;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/png/PngSegment.java b/src/net/sourceforge/plantuml/png/PngSegment.java
new file mode 100644
index 0000000..a95fadb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/png/PngSegment.java
@@ -0,0 +1,61 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.png;
+
+class PngSegment {
+
+ private final int totalSize;
+ private final int nbPiece;
+
+ public PngSegment(int totalSize, int nbPiece) {
+ this.nbPiece = nbPiece;
+ this.totalSize = totalSize;
+ }
+
+ public int getStart(int idx) {
+ if (idx < 0 || idx > nbPiece - 1) {
+ throw new IllegalArgumentException();
+ }
+ return (int) (1.0 * totalSize / nbPiece * idx);
+ }
+
+ public int getLen(int idx) {
+ if (idx < 0 || idx > nbPiece - 1) {
+ throw new IllegalArgumentException();
+ }
+ return (int) (1.0 * totalSize / nbPiece);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/png/PngSizer.java b/src/net/sourceforge/plantuml/png/PngSizer.java
new file mode 100644
index 0000000..db43fdc
--- /dev/null
+++ b/src/net/sourceforge/plantuml/png/PngSizer.java
@@ -0,0 +1,74 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.png;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.image.BufferedImage;
+
+import net.sourceforge.plantuml.Log;
+
+public class PngSizer {
+
+ static public BufferedImage process(BufferedImage im, int minsize) {
+
+ if (minsize != Integer.MAX_VALUE) {
+ return resize(im, minsize);
+ }
+ return im;
+
+ }
+
+ static private BufferedImage resize(BufferedImage im, int minsize) {
+ Log.info("Resizing file to " + minsize);
+
+ if (im.getWidth() >= minsize) {
+ return im;
+ }
+
+ final BufferedImage newIm = new BufferedImage(minsize, im.getHeight(), BufferedImage.TYPE_INT_RGB);
+ final Graphics2D g2d = newIm.createGraphics();
+ g2d.setColor(Color.WHITE);
+ g2d.fillRect(0, 0, newIm.getWidth(), newIm.getHeight());
+ final int delta = (minsize - im.getWidth()) / 2;
+ g2d.drawImage(im, delta, 0, null);
+
+ g2d.dispose();
+
+ return newIm;
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/png/PngSplitter.java b/src/net/sourceforge/plantuml/png/PngSplitter.java
new file mode 100644
index 0000000..2f0eee4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/png/PngSplitter.java
@@ -0,0 +1,109 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.png;
+
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.imageio.ImageIO;
+
+import net.sourceforge.plantuml.FileFormat;
+import net.sourceforge.plantuml.FileUtils;
+import net.sourceforge.plantuml.Log;
+
+public class PngSplitter {
+
+ private final List<File> files = new ArrayList<File>();
+
+ public static void main(String[] args) throws IOException {
+ final File f = new File(args[0]);
+ final int x = Integer.parseInt(args[1]);
+ final int y = Integer.parseInt(args[2]);
+ final File cp = new File(f.getParent(), f.getName().replaceAll("\\.png$", "_000.png"));
+ FileUtils.copyToFile(f, cp);
+ new PngSplitter(cp, x, y, "", 96, false);
+
+ }
+
+ public PngSplitter(File pngFile, int horizontalPages, int verticalPages, String source, int dpi,
+ boolean isWithMetadata) throws IOException {
+ if (horizontalPages == 1 && verticalPages == 1) {
+ this.files.add(pngFile);
+ return;
+ }
+
+ Log.info("Splitting " + horizontalPages + " x " + verticalPages);
+ final File full = new File(pngFile.getParentFile(), pngFile.getName() + ".tmp");
+ Thread.yield();
+ full.delete();
+ Thread.yield();
+ final boolean ok = pngFile.renameTo(full);
+ Thread.yield();
+ if (ok == false) {
+ throw new IOException("Cannot rename");
+ }
+
+ Thread.yield();
+ final BufferedImage im = ImageIO.read(full);
+ Thread.yield();
+ final PngSegment horizontalSegment = new PngSegment(im.getWidth(), horizontalPages);
+ final PngSegment verticalSegment = new PngSegment(im.getHeight(), verticalPages);
+
+ int x = 0;
+ for (int i = 0; i < horizontalPages; i++) {
+ for (int j = 0; j < verticalPages; j++) {
+ final File f = FileFormat.PNG.computeFilename(pngFile, x++);
+ this.files.add(f);
+ final BufferedImage imPiece = im.getSubimage(horizontalSegment.getStart(i),
+ verticalSegment.getStart(j), horizontalSegment.getLen(i), verticalSegment.getLen(j));
+ Thread.yield();
+ PngIO.write(imPiece, f, isWithMetadata ? source : null, dpi);
+ Thread.yield();
+ }
+ }
+
+ full.delete();
+ Log.info("End of splitting");
+ }
+
+ public List<File> getFiles() {
+ return Collections.unmodifiableList(files);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/png/PngTitler.java b/src/net/sourceforge/plantuml/png/PngTitler.java
new file mode 100644
index 0000000..b9c7f91
--- /dev/null
+++ b/src/net/sourceforge/plantuml/png/PngTitler.java
@@ -0,0 +1,111 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.png;
+
+import java.awt.Font;
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.SpriteContainerEmpty;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public class PngTitler {
+
+ private final HtmlColor textColor;
+ private final HtmlColor hyperlinkColor;
+ private final Display text;
+ private final int fontSize;
+ private final String fontFamily;
+ private final HorizontalAlignment horizontalAlignment;
+ private final boolean useUnderlineForHyperlink;
+
+ public PngTitler(HtmlColor textColor, Display text, int fontSize, String fontFamily,
+ HorizontalAlignment horizontalAlignment, HtmlColor hyperlinkColor, boolean useUnderlineForHyperlink) {
+ this.textColor = textColor;
+ this.text = text;
+ this.fontSize = fontSize;
+ this.fontFamily = fontFamily;
+ this.horizontalAlignment = horizontalAlignment;
+ this.hyperlinkColor = hyperlinkColor;
+ this.useUnderlineForHyperlink = useUnderlineForHyperlink;
+
+ }
+
+ public Dimension2D getTextDimension(StringBounder stringBounder) {
+ final TextBlock textBloc = getTextBlock();
+ if (textBloc == null) {
+ return null;
+ }
+ return textBloc.calculateDimension(stringBounder);
+ }
+
+ public TextBlock getTextBlock() {
+ if (text == null || text.size() == 0) {
+ return null;
+ }
+ final UFont normalFont = new UFont(fontFamily, Font.PLAIN, fontSize);
+ return TextBlockUtils.create(text, new FontConfiguration(normalFont, textColor, hyperlinkColor, useUnderlineForHyperlink), horizontalAlignment,
+ new SpriteContainerEmpty());
+ }
+
+ private double getOffsetX(double imWidth, StringBounder stringBounder) {
+ final TextBlock textBloc = getTextBlock();
+ if (textBloc == null) {
+ return 0;
+ }
+ final Dimension2D dimText = textBloc.calculateDimension(stringBounder);
+
+ if (imWidth >= dimText.getWidth()) {
+ return 0;
+ }
+ return (dimText.getWidth() - imWidth) / 2;
+ }
+
+ private double getOffsetY(StringBounder stringBounder) {
+ final TextBlock textBloc = getTextBlock();
+ if (textBloc == null) {
+ return 0;
+ }
+ final Dimension2D dimText = textBloc.calculateDimension(stringBounder);
+ final double height = dimText.getHeight();
+ return height;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/posimo/AbstractEntityImage2.java b/src/net/sourceforge/plantuml/posimo/AbstractEntityImage2.java
new file mode 100644
index 0000000..8b15000
--- /dev/null
+++ b/src/net/sourceforge/plantuml/posimo/AbstractEntityImage2.java
@@ -0,0 +1,84 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.posimo;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.rose.Rose;
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+abstract class AbstractEntityImage2 implements IEntityImageBlock {
+
+ private final IEntity entity;
+ private final ISkinParam skinParam;
+
+ private final Rose rose = new Rose();
+
+ public AbstractEntityImage2(IEntity entity, ISkinParam skinParam) {
+ if (entity == null) {
+ throw new IllegalArgumentException("entity null");
+ }
+ this.entity = entity;
+ this.skinParam = skinParam;
+ }
+
+ public abstract Dimension2D getDimension(StringBounder stringBounder);
+
+ protected final IEntity getEntity() {
+ return entity;
+ }
+
+ protected UFont getFont(FontParam fontParam) {
+ return skinParam.getFont(fontParam, null, false);
+ }
+
+ protected HtmlColor getFontColor(FontParam fontParam) {
+ return skinParam.getFontHtmlColor(fontParam, null);
+ }
+
+ protected final HtmlColor getColor(ColorParam colorParam) {
+ return rose.getHtmlColor(skinParam, colorParam);
+ }
+
+ protected final ISkinParam getSkinParam() {
+ return skinParam;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/posimo/BezierUtils.java b/src/net/sourceforge/plantuml/posimo/BezierUtils.java
new file mode 100644
index 0000000..985654a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/posimo/BezierUtils.java
@@ -0,0 +1,181 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.posimo;
+
+import java.awt.Shape;
+import java.awt.geom.CubicCurve2D;
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Line2D;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+
+public class BezierUtils {
+
+ static public double getEndingAngle(final CubicCurve2D.Double left) {
+ if (left.getCtrlP2().equals(left.getP2())) {
+ return getAngle(left.getP1(), left.getP2());
+ }
+ return getAngle(left.getCtrlP2(), left.getP2());
+ }
+
+ static public double getStartingAngle(final CubicCurve2D.Double left) {
+ if (left.getP1().equals(left.getCtrlP1())) {
+ return getAngle(left.getP1(), left.getP2());
+ }
+ return getAngle(left.getP1(), left.getCtrlP1());
+ }
+
+ static double getAngle(Point2D p1, Point2D p2) {
+ if (p1.equals(p2)) {
+ throw new IllegalArgumentException();
+ }
+ return Math.atan2(p2.getY() - p1.getY(), p2.getX() - p1.getX());
+ }
+
+ static boolean isCutting(CubicCurve2D.Double bez, Shape shape) {
+ final boolean contains1 = shape.contains(bez.x1, bez.y1);
+ final boolean contains2 = shape.contains(bez.x2, bez.y2);
+ return contains1 ^ contains2;
+ }
+
+ static void shorten(CubicCurve2D.Double bez, Shape shape) {
+ final boolean contains1 = shape.contains(bez.x1, bez.y1);
+ final boolean contains2 = shape.contains(bez.x2, bez.y2);
+ if (contains1 ^ contains2 == false) {
+ throw new IllegalArgumentException();
+ }
+ if (contains1 == false) {
+ bez.setCurve(bez.x2, bez.y2, bez.ctrlx2, bez.ctrly2, bez.ctrlx1, bez.ctrly1, bez.x1, bez.y1);
+ }
+ assert shape.contains(bez.x1, bez.y1) && shape.contains(bez.x2, bez.y2) == false;
+ final CubicCurve2D.Double left = new CubicCurve2D.Double();
+ final CubicCurve2D.Double right = new CubicCurve2D.Double();
+ subdivide(bez, left, right, 0.5);
+
+ if (isCutting(left, shape) ^ isCutting(right, shape) == false) {
+ throw new IllegalArgumentException();
+ }
+
+ if (isCutting(left, shape)) {
+ bez.setCurve(left);
+ } else {
+ bez.setCurve(right);
+ }
+
+ }
+
+ public static void subdivide(CubicCurve2D src, CubicCurve2D left, CubicCurve2D right, final double coef) {
+ final double coef1 = coef;
+ final double coef2 = 1 - coef;
+ final double centerxA = src.getCtrlX1() * coef1 + src.getCtrlX2() * coef2;
+ final double centeryA = src.getCtrlY1() * coef1 + src.getCtrlY2() * coef2;
+
+ final double ctrlx1 = src.getX1() * coef1 + src.getCtrlX1() * coef1;
+ final double ctrly1 = src.getY1() * coef1 + src.getCtrlY1() * coef1;
+ final double ctrlx2 = src.getX2() * coef1 + src.getCtrlX2() * coef1;
+ final double ctrly2 = src.getY2() * coef1 + src.getCtrlY2() * coef1;
+
+ final double ctrlx12 = ctrlx1 * coef1 + centerxA * coef1;
+ final double ctrly12 = ctrly1 * coef1 + centeryA * coef1;
+ final double ctrlx21 = ctrlx2 * coef1 + centerxA * coef1;
+ final double ctrly21 = ctrly2 * coef1 + centeryA * coef1;
+ final double centerxB = ctrlx12 * coef1 + ctrlx21 * coef1;
+ final double centeryB = ctrly12 * coef1 + ctrly21 * coef1;
+ left.setCurve(src.getX1(), src.getY1(), ctrlx1, ctrly1, ctrlx12, ctrly12, centerxB, centeryB);
+ right.setCurve(centerxB, centeryB, ctrlx21, ctrly21, ctrlx2, ctrly2, src.getX2(), src.getY2());
+ }
+
+ static double dist(CubicCurve2D.Double seg) {
+ return Point2D.distance(seg.x1, seg.y1, seg.x2, seg.y2);
+ }
+
+ static double dist(Line2D.Double seg) {
+ return Point2D.distance(seg.x1, seg.y1, seg.x2, seg.y2);
+ }
+
+ static public Point2D middle(Line2D.Double seg) {
+ return new Point2D.Double((seg.x1 + seg.x2) / 2, (seg.y1 + seg.y2) / 2);
+ }
+
+ static public Point2D middle(Point2D p1, Point2D p2) {
+ return new Point2D.Double((p1.getX() + p2.getX()) / 2, (p1.getY() + p2.getY()) / 2);
+ }
+
+ public static Point2D intersect(Line2D.Double orig, Shape shape) {
+ final Line2D.Double copy = new Line2D.Double(orig.x1, orig.y1, orig.x2, orig.y2);
+ final boolean contains1 = shape.contains(copy.x1, copy.y1);
+ final boolean contains2 = shape.contains(copy.x2, copy.y2);
+ if (contains1 ^ contains2 == false) {
+ // return new Point2D.Double(orig.x2, orig.y2);
+ throw new IllegalArgumentException();
+ }
+ while (true) {
+ final double mx = (copy.x1 + copy.x2) / 2;
+ final double my = (copy.y1 + copy.y2) / 2;
+ final boolean containsMiddle = shape.contains(mx, my);
+ if (contains1 == containsMiddle) {
+ copy.x1 = mx;
+ copy.y1 = my;
+ } else {
+ copy.x2 = mx;
+ copy.y2 = my;
+ }
+ if (dist(copy) < 0.1) {
+ if (contains1) {
+ return new Point2D.Double(copy.x2, copy.y2);
+ }
+ if (contains2) {
+ return new Point2D.Double(copy.x1, copy.y1);
+ }
+ throw new IllegalStateException();
+ }
+ }
+ }
+
+ static public Rectangle2D toRectangle(Positionable p) {
+ final Point2D point = p.getPosition();
+ final Dimension2D dim = p.getSize();
+ return new Rectangle2D.Double(point.getX(), point.getY(), dim.getWidth(), dim.getHeight());
+ }
+
+ static public boolean intersect(Positionable p1, Positionable p2) {
+ return toRectangle(p1).intersects(toRectangle(p2));
+ }
+
+ static public Point2D.Double getCenter(Positionable p) {
+ return new Point2D.Double(toRectangle(p).getCenterX(), toRectangle(p).getCenterY());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/posimo/Block.java b/src/net/sourceforge/plantuml/posimo/Block.java
new file mode 100644
index 0000000..9627360
--- /dev/null
+++ b/src/net/sourceforge/plantuml/posimo/Block.java
@@ -0,0 +1,105 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.posimo;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.util.Locale;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+
+public class Block implements Clusterable {
+
+ private final int uid;
+ private final double width;
+ private final double height;
+ private double x;
+ private double y;
+ private final Cluster parent;
+
+ public Block(int uid, double width, double height, Cluster parent) {
+ this.uid = uid;
+ this.width = width;
+ this.height = height;
+ this.parent = parent;
+ }
+
+ @Override
+ public String toString() {
+ return "BLOCK " + uid;
+ }
+
+ public String toStringPosition() {
+ return String.format(Locale.US, "x=%9.2f y=%9.2f w=%9.2f h=%9.2f", x, y, width, height);
+ }
+
+ public int getUid() {
+ return uid;
+ }
+
+ public Cluster getParent() {
+ return parent;
+ }
+
+ public Point2D getPosition() {
+ return new Point2D.Double(x, y);
+ }
+
+ public Dimension2D getSize() {
+ return new Dimension2DDouble(width, height);
+ }
+
+ public void setCenterX(double center) {
+ this.x = center - width / 2;
+ }
+
+ public void setCenterY(double center) {
+ this.y = center - height / 2;
+ }
+
+ public final void setX(double x) {
+ this.x = x;
+ }
+
+ public final void setY(double y) {
+ this.y = y;
+ }
+
+ public void moveSvek(double deltaX, double deltaY) {
+ throw new UnsupportedOperationException();
+ }
+
+
+}
diff --git a/src/net/sourceforge/plantuml/posimo/Cluster.java b/src/net/sourceforge/plantuml/posimo/Cluster.java
new file mode 100644
index 0000000..9315970
--- /dev/null
+++ b/src/net/sourceforge/plantuml/posimo/Cluster.java
@@ -0,0 +1,160 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.posimo;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+
+public class Cluster implements Clusterable {
+
+ private static int CPT = 1;
+
+ private final Cluster parent;
+ private final Collection<Block> blocs = new ArrayList<Block>();
+ private final Collection<Cluster> children = new ArrayList<Cluster>();
+ private final int uid = CPT++;
+ private double x;
+ private double y;
+ private double width;
+ private double height;
+
+ private final double titleWidth;
+ private final double titleHeight;
+
+// public Cluster(Cluster parent) {
+// this(parent, 100, 20);
+// }
+//
+ public Cluster(Cluster parent, double titleWidth, double titleHeight) {
+ this.parent = parent;
+ this.titleWidth = titleWidth;
+ this.titleHeight = titleHeight;
+ if (parent != null) {
+ parent.children.add(this);
+ }
+ }
+
+ public Collection<Cluster> getSubClusters() {
+ return Collections.unmodifiableCollection(children);
+ }
+
+ public Collection<Block> getRecursiveContents() {
+ final Collection<Block> result = new ArrayList<Block>();
+ addContentRecurse(result);
+ return Collections.unmodifiableCollection(result);
+ }
+
+ private void addContentRecurse(Collection<Block> result) {
+ result.addAll(blocs);
+ for (Cluster c : children) {
+ c.addContentRecurse(result);
+ }
+
+ }
+
+ public int getUid() {
+ return uid;
+ }
+
+ public void addBloc(Block b) {
+ this.blocs.add(b);
+ }
+
+ public Cluster getParent() {
+ return parent;
+ }
+
+ public Collection<Block> getContents() {
+ return Collections.unmodifiableCollection(blocs);
+ }
+
+ public Block getBlock(int uid) {
+ for (Block b : blocs) {
+ if (b.getUid() == uid) {
+ return b;
+ }
+ }
+ for (Cluster sub : children) {
+ final Block result = sub.getBlock(uid);
+ if (result != null) {
+ return result;
+ }
+ }
+ return null;
+ }
+
+ public Point2D getPosition() {
+ return new Point2D.Double(x, y);
+ }
+
+ public Dimension2D getSize() {
+ return new Dimension2DDouble(width, height);
+ }
+
+ public final void setX(double x) {
+ this.x = x;
+ }
+
+ public final void setY(double y) {
+ this.y = y;
+ }
+
+ public final void setWidth(double width) {
+ this.width = width;
+ }
+
+ public final void setHeight(double height) {
+ this.height = height;
+ }
+
+ public final double getTitleWidth() {
+ return titleWidth;
+ }
+
+ public final double getTitleHeight() {
+ return titleHeight;
+ }
+
+ public void moveSvek(double deltaX, double deltaY) {
+ throw new UnsupportedOperationException();
+ }
+
+
+}
diff --git a/src/net/sourceforge/plantuml/posimo/Clusterable.java b/src/net/sourceforge/plantuml/posimo/Clusterable.java
new file mode 100644
index 0000000..f3560f2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/posimo/Clusterable.java
@@ -0,0 +1,41 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.posimo;
+
+public interface Clusterable extends Positionable {
+
+ public Cluster getParent();
+
+}
diff --git a/src/net/sourceforge/plantuml/posimo/Decor.java b/src/net/sourceforge/plantuml/posimo/Decor.java
new file mode 100644
index 0000000..c415c14
--- /dev/null
+++ b/src/net/sourceforge/plantuml/posimo/Decor.java
@@ -0,0 +1,44 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.posimo;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public interface Decor {
+
+ void drawDecor(UGraphic ug, Point2D start, double direction);
+}
diff --git a/src/net/sourceforge/plantuml/posimo/DecorInterfaceProvider.java b/src/net/sourceforge/plantuml/posimo/DecorInterfaceProvider.java
new file mode 100644
index 0000000..b95f951
--- /dev/null
+++ b/src/net/sourceforge/plantuml/posimo/DecorInterfaceProvider.java
@@ -0,0 +1,79 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.posimo;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.cucadiagram.LinkStyle;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class DecorInterfaceProvider implements Decor {
+
+ private final double radius = 5;
+ private final double radius2 = 9;
+ private final LinkStyle style;
+
+ // private final double distanceCircle = 16;
+
+ public DecorInterfaceProvider(LinkStyle style) {
+ if (style != LinkStyle.__toremove_INTERFACE_PROVIDER && style != LinkStyle.__toremove_INTERFACE_USER) {
+ throw new IllegalArgumentException();
+ }
+ this.style = style;
+ }
+
+ public void drawDecor(UGraphic ug, Point2D start, double direction) {
+ final double cornerX = start.getX() - radius;
+ final double cornerY = start.getY() - radius;
+ final double cornerX2 = start.getX() - radius2 - 0 * Math.sin(direction * Math.PI / 180.0);
+ final double cornerY2 = start.getY() - radius2 - 0 * Math.cos(direction * Math.PI / 180.0);
+
+ if (style == LinkStyle.__toremove_INTERFACE_USER) {
+ direction += 180;
+ }
+ if (direction >= 360) {
+ direction -= 360;
+ }
+
+ final UEllipse arc = new UEllipse(2 * radius2, 2 * radius2, direction + 15, 180 - 30);
+ ug = ug.apply(new UStroke(1.5));
+ ug.apply(new UTranslate(cornerX2, cornerY2)).draw(arc);
+ ug.apply(new UTranslate(cornerX, cornerY)).draw(new UEllipse(2 * radius, 2 * radius));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/posimo/DotPath.java b/src/net/sourceforge/plantuml/posimo/DotPath.java
new file mode 100644
index 0000000..9145028
--- /dev/null
+++ b/src/net/sourceforge/plantuml/posimo/DotPath.java
@@ -0,0 +1,540 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.posimo;
+
+import java.awt.Graphics2D;
+import java.awt.Shape;
+import java.awt.geom.CubicCurve2D;
+import java.awt.geom.GeneralPath;
+import java.awt.geom.Line2D;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import net.sourceforge.plantuml.EnsureVisible;
+import net.sourceforge.plantuml.asciiart.BasicCharArea;
+import net.sourceforge.plantuml.eps.EpsGraphics;
+import net.sourceforge.plantuml.svek.ClusterPosition;
+import net.sourceforge.plantuml.svek.MinFinder;
+import net.sourceforge.plantuml.svek.PointAndAngle;
+import net.sourceforge.plantuml.svek.PointDirected;
+import net.sourceforge.plantuml.ugraphic.MinMax;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.USegmentType;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DotPath implements UShape, Moveable {
+
+ static class TriPoints {
+ public TriPoints(String p1, String p2, String p, double deltaY) {
+ final StringTokenizer st1 = new StringTokenizer(p1, ",");
+ x1 = Double.parseDouble(st1.nextToken());
+ y1 = Double.parseDouble(st1.nextToken()) + deltaY;
+ final StringTokenizer st2 = new StringTokenizer(p2, ",");
+ x2 = Double.parseDouble(st2.nextToken());
+ y2 = Double.parseDouble(st2.nextToken()) + deltaY;
+ final StringTokenizer st = new StringTokenizer(p, ",");
+ x = Double.parseDouble(st.nextToken());
+ y = Double.parseDouble(st.nextToken()) + deltaY;
+ }
+
+ private final double x1;
+ private final double y1;
+ private final double x2;
+ private final double y2;
+ private final double x;
+ private final double y;
+
+ // @Override
+ // public String toString() {
+ // return "[" + x1 + "," + y1 + " " + x2 + "," + y2 + " " + x + "," + y
+ // + "]";
+ // }
+ }
+
+ private final List<CubicCurve2D.Double> beziers = new ArrayList<CubicCurve2D.Double>();
+
+ public DotPath() {
+ this(new ArrayList<CubicCurve2D.Double>());
+ }
+
+ public DotPath(DotPath other) {
+ this(new ArrayList<CubicCurve2D.Double>());
+ for (CubicCurve2D.Double c : other.beziers) {
+ this.beziers.add(new CubicCurve2D.Double(c.x1, c.y1, c.ctrlx1, c.ctrly1, c.ctrlx2, c.ctrly2, c.x2, c.y2));
+ }
+ }
+
+ private DotPath(List<CubicCurve2D.Double> beziers) {
+ this.beziers.addAll(beziers);
+ }
+
+ public DotPath(String init, double deltaY) {
+ if (init.startsWith("M") == false) {
+ throw new IllegalArgumentException();
+ }
+ final int posC = init.indexOf("C");
+ if (posC == -1) {
+ throw new IllegalArgumentException();
+ }
+ final StringTokenizer st = new StringTokenizer(init.substring(1, posC), ",");
+ final double startX = Double.parseDouble(st.nextToken());
+ final double startY = Double.parseDouble(st.nextToken()) + deltaY;
+
+ final StringTokenizer st2 = new StringTokenizer(init.substring(posC + 1), " ");
+ final List<TriPoints> triPoints = new ArrayList<TriPoints>();
+ while (st2.hasMoreTokens()) {
+ final String p1 = st2.nextToken();
+ final String p2 = st2.nextToken();
+ final String p = st2.nextToken();
+ triPoints.add(new TriPoints(p1, p2, p, deltaY));
+ }
+ double x = startX;
+ double y = startY;
+ for (TriPoints p : triPoints) {
+ final CubicCurve2D.Double bezier = new CubicCurve2D.Double(x, y, p.x1, p.y1, p.x2, p.y2, p.x, p.y);
+ beziers.add(bezier);
+ x = p.x;
+ y = p.y;
+ }
+ // this.print = triPoints.toString();
+ }
+
+ // private final String print;
+
+ public Point2D getStartPoint() {
+ return beziers.get(0).getP1();
+ }
+
+ public PointAndAngle getMiddle() {
+ Point2D result = null;
+ double angle = 0;
+ for (CubicCurve2D.Double bez : beziers) {
+ final CubicCurve2D.Double left = new CubicCurve2D.Double();
+ final CubicCurve2D.Double right = new CubicCurve2D.Double();
+ bez.subdivide(left, right);
+ final Point2D p1 = left.getP1();
+ final Point2D p2 = left.getP2();
+ final Point2D p3 = right.getP1();
+ final Point2D p4 = right.getP2();
+ if (result == null || getCost(p1) < getCost(result)) {
+ result = p1;
+ angle = BezierUtils.getStartingAngle(left);
+ }
+ if (getCost(p2) < getCost(result)) {
+ result = p2;
+ angle = BezierUtils.getEndingAngle(left);
+ }
+ if (getCost(p3) < getCost(result)) {
+ result = p3;
+ angle = BezierUtils.getStartingAngle(right);
+ }
+ if (getCost(p4) < getCost(result)) {
+ result = p4;
+ angle = BezierUtils.getEndingAngle(right);
+ }
+ }
+ return new PointAndAngle(result, angle);
+ }
+
+ private double getCost(Point2D pt) {
+ final Point2D start = getStartPoint();
+ final Point2D end = getEndPoint();
+ return pt.distanceSq(start) + pt.distanceSq(end);
+ }
+
+ public void forceStartPoint(double x, double y) {
+ beziers.get(0).x1 = x;
+ beziers.get(0).y1 = y;
+ beziers.get(0).ctrlx1 = x;
+ beziers.get(0).ctrly1 = y;
+ }
+
+ public Point2D getEndPoint() {
+ return beziers.get(beziers.size() - 1).getP2();
+ }
+
+ public void forceEndPoint(double x, double y) {
+ beziers.get(beziers.size() - 1).x2 = x;
+ beziers.get(beziers.size() - 1).y2 = y;
+ beziers.get(beziers.size() - 1).ctrlx2 = x;
+ beziers.get(beziers.size() - 1).ctrly2 = y;
+ }
+
+ public void moveEndPoint(double dx, double dy) {
+ beziers.get(beziers.size() - 1).x2 += dx;
+ beziers.get(beziers.size() - 1).y2 += dy;
+ beziers.get(beziers.size() - 1).ctrlx2 += dx;
+ beziers.get(beziers.size() - 1).ctrly2 += dy;
+ }
+
+ public MinFinder getMinFinder() {
+ final MinFinder result = new MinFinder();
+ for (CubicCurve2D.Double c : beziers) {
+ result.manage(c.x1, c.y1);
+ result.manage(c.x2, c.y2);
+ result.manage(c.ctrlx1, c.ctrly1);
+ result.manage(c.ctrlx2, c.ctrly2);
+ }
+ return result;
+ }
+
+ public MinMax getMinMax() {
+ MinMax result = MinMax.getEmpty(false);
+ for (CubicCurve2D.Double c : beziers) {
+ result = result.addPoint(c.x1, c.y1);
+ result = result.addPoint(c.x2, c.y2);
+ result = result.addPoint(c.ctrlx1, c.ctrly1);
+ result = result.addPoint(c.ctrlx2, c.ctrly2);
+ }
+ return result;
+ }
+
+ public double getMinDist(Point2D ref) {
+ double result = Double.MAX_VALUE;
+ for (CubicCurve2D.Double c : beziers) {
+ final double d1 = ref.distance(c.x1, c.y1);
+ if (d1 < result) {
+ result = d1;
+ }
+ final double d2 = ref.distance(c.x2, c.y2);
+ if (d2 < result) {
+ result = d2;
+ }
+ final double d3 = ref.distance(c.ctrlx1, c.ctrly1);
+ if (d3 < result) {
+ result = d3;
+ }
+ final double d4 = ref.distance(c.ctrlx2, c.ctrly2);
+ if (d4 < result) {
+ result = d4;
+ }
+ }
+ return result;
+
+ }
+
+ public Line2D getEndTangeante() {
+ final CubicCurve2D.Double last = beziers.get(beziers.size() - 1);
+ double dx = last.x2 - last.ctrlx2;
+ double dy = last.y2 - last.ctrly2;
+ if (dx == 0 && dy == 0) {
+ dx = last.x2 - last.x1;
+ dy = last.y2 - last.y1;
+ }
+ return new Line2D.Double(last.x2, last.y2, last.x2 + dx, last.y2 + dy);
+ }
+
+ public double getEndAngle() {
+ final Line2D tan = getEndTangeante();
+ final double theta1 = Math.atan2(tan.getY2() - tan.getY1(), tan.getX2() - tan.getX1());
+ return theta1;
+ }
+
+ public double getStartAngle() {
+ final Line2D tan = getStartTangeante();
+ final double theta1 = Math.atan2(tan.getY2() - tan.getY1(), tan.getX2() - tan.getX1());
+ return theta1;
+ }
+
+ public Line2D getStartTangeante() {
+ final CubicCurve2D.Double first = beziers.get(0);
+ double dx = first.ctrlx1 - first.x1;
+ double dy = first.ctrly1 - first.y1;
+ if (dx == 0 && dy == 0) {
+ dx = first.x2 - first.x1;
+ dy = first.y2 - first.y1;
+ }
+ return new Line2D.Double(first.x1, first.y1, first.x1 + dx, first.y1 + dy);
+ }
+
+ public DotPath addBefore(CubicCurve2D.Double before) {
+ final List<CubicCurve2D.Double> copy = new ArrayList<CubicCurve2D.Double>(beziers);
+ copy.add(0, before);
+ return new DotPath(copy);
+ }
+
+ public DotPath addBefore(DotPath other) {
+ final List<CubicCurve2D.Double> copy = new ArrayList<CubicCurve2D.Double>(beziers);
+ copy.addAll(0, other.beziers);
+ return new DotPath(copy);
+ }
+
+ public DotPath addAfter(CubicCurve2D.Double after) {
+ final List<CubicCurve2D.Double> copy = new ArrayList<CubicCurve2D.Double>(beziers);
+ copy.add(after);
+ return new DotPath(copy);
+ }
+
+ public DotPath addAfter(DotPath other) {
+ final List<CubicCurve2D.Double> copy = new ArrayList<CubicCurve2D.Double>(beziers);
+ copy.addAll(other.beziers);
+ return new DotPath(copy);
+ }
+
+ public Map<Point2D, Double> somePoints() {
+ final Map<Point2D, Double> result = new HashMap<Point2D, Double>();
+ for (CubicCurve2D.Double bez : beziers) {
+ final CubicCurve2D.Double left = new CubicCurve2D.Double();
+ final CubicCurve2D.Double right = new CubicCurve2D.Double();
+ bez.subdivide(left, right);
+ result.put(left.getP1(), BezierUtils.getStartingAngle(left));
+ result.put(left.getP2(), BezierUtils.getEndingAngle(left));
+ result.put(right.getP1(), BezierUtils.getStartingAngle(right));
+ result.put(right.getP2(), BezierUtils.getEndingAngle(right));
+ }
+ return result;
+ }
+
+ public PointDirected getIntersection(ClusterPosition position) {
+ for (CubicCurve2D.Double bez : beziers) {
+ final PointDirected result = position.getIntersection(bez);
+ if (result != null) {
+ return result;
+ }
+ }
+ return null;
+ }
+
+ // public void drawOld(Graphics2D g2d, double x, double y) {
+ // for (CubicCurve2D.Double bez : beziers) {
+ // bez = new CubicCurve2D.Double(x + bez.x1, y + bez.y1, x + bez.ctrlx1, y +
+ // bez.ctrly1, x + bez.ctrlx2, y
+ // + bez.ctrly2, x + bez.x2, y + bez.y2);
+ // g2d.draw(bez);
+ // }
+ // }
+ //
+ public void draw(Graphics2D g2d, double x, double y) {
+ final GeneralPath p = new GeneralPath();
+ for (CubicCurve2D.Double bez : beziers) {
+ bez = new CubicCurve2D.Double(x + bez.x1, y + bez.y1, x + bez.ctrlx1, y + bez.ctrly1, x + bez.ctrlx2, y
+ + bez.ctrly2, x + bez.x2, y + bez.y2);
+ p.append(bez, true);
+ }
+ g2d.draw(p);
+ }
+
+ public void manageEnsureVisible(double x, double y, EnsureVisible visible) {
+ for (CubicCurve2D.Double bez : beziers) {
+ visible.ensureVisible(x + bez.x1, y + bez.y1);
+ visible.ensureVisible(x + bez.x2, y + bez.y2);
+ }
+
+ }
+
+ public void drawOk(EpsGraphics eps, double x, double y) {
+ // boolean first = true;
+ for (CubicCurve2D.Double bez : beziers) {
+ bez = new CubicCurve2D.Double(x + bez.x1, y + bez.y1, x + bez.ctrlx1, y + bez.ctrly1, x + bez.ctrlx2, y
+ + bez.ctrly2, x + bez.x2, y + bez.y2);
+ eps.epsLine(bez.x1, bez.y1, bez.x2, bez.y2);
+ }
+ }
+
+ public void draw(EpsGraphics eps, double x, double y) {
+ eps.newpathDot();
+ final boolean dashed = false;
+ boolean first = true;
+ for (CubicCurve2D.Double bez : beziers) {
+ bez = new CubicCurve2D.Double(x + bez.x1, y + bez.y1, x + bez.ctrlx1, y + bez.ctrly1, x + bez.ctrlx2, y
+ + bez.ctrly2, x + bez.x2, y + bez.y2);
+ if (first) {
+ eps.movetoNoMacro(bez.x1, bez.y1);
+ first = dashed;
+ }
+ eps.curvetoNoMacro(bez.ctrlx1, bez.ctrly1, bez.ctrlx2, bez.ctrly2, bez.x2, bez.y2);
+ }
+ eps.closepathDot();
+ }
+
+ public UPath toUPath() {
+ final UPath result = new UPath();
+ boolean start = true;
+ for (CubicCurve2D.Double bez : beziers) {
+ if (start) {
+ result.add(new double[] { bez.x1, bez.y1 }, USegmentType.SEG_MOVETO);
+ start = false;
+ }
+ result.add(new double[] { bez.ctrlx1, bez.ctrly1, bez.ctrlx2, bez.ctrly2, bez.x2, bez.y2 },
+ USegmentType.SEG_CUBICTO);
+
+ }
+ return result;
+ }
+
+ public Point2D getFrontierIntersection(Shape shape, Rectangle2D... notIn) {
+ final List<CubicCurve2D.Double> all = new ArrayList<CubicCurve2D.Double>(beziers);
+ for (int i = 0; i < 8; i++) {
+ for (CubicCurve2D.Double immutable : all) {
+ if (contains(immutable, notIn)) {
+ continue;
+ }
+ final CubicCurve2D.Double bez = new CubicCurve2D.Double();
+ bez.setCurve(immutable);
+ if (BezierUtils.isCutting(bez, shape)) {
+ while (BezierUtils.dist(bez) > 1.0) {
+ BezierUtils.shorten(bez, shape);
+ }
+ final Point2D.Double result = new Point2D.Double((bez.x1 + bez.x2) / 2, (bez.y1 + bez.y2) / 2);
+ if (contains(result, notIn) == false) {
+ return result;
+ }
+ }
+ }
+ cutAllCubic(all);
+ }
+ throw new IllegalArgumentException("shape=" + shape);
+ }
+
+ private void cutAllCubic(List<CubicCurve2D.Double> all) {
+ final List<CubicCurve2D.Double> tmp = new ArrayList<CubicCurve2D.Double>(all);
+ all.clear();
+ for (CubicCurve2D.Double bez : tmp) {
+ final CubicCurve2D.Double left = new CubicCurve2D.Double();
+ final CubicCurve2D.Double right = new CubicCurve2D.Double();
+ bez.subdivide(left, right);
+ all.add(left);
+ all.add(right);
+ }
+ }
+
+ static private boolean contains(Point2D.Double point, Rectangle2D... rects) {
+ for (Rectangle2D r : rects) {
+ if (r.contains(point)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ static private boolean contains(CubicCurve2D.Double cubic, Rectangle2D... rects) {
+ for (Rectangle2D r : rects) {
+ if (r.contains(cubic.getP1()) && r.contains(cubic.getP2())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public DotPath manageRect(Rectangle2D start, Rectangle2D end) {
+ final List<CubicCurve2D.Double> list = new ArrayList<CubicCurve2D.Double>(this.beziers);
+ while (true) {
+ if (BezierUtils.isCutting(list.get(0), start) == false) {
+ throw new IllegalStateException();
+ }
+ if (BezierUtils.dist(list.get(0)) <= 1.0) {
+ break;
+ }
+ final CubicCurve2D.Double left = new CubicCurve2D.Double();
+ final CubicCurve2D.Double right = new CubicCurve2D.Double();
+ list.get(0).subdivide(left, right);
+ list.set(0, left);
+ list.add(1, right);
+ if (BezierUtils.isCutting(list.get(1), start)) {
+ list.remove(0);
+ }
+ }
+ return new DotPath(list);
+ }
+
+ public Point2D getFrontierIntersection(Positionable p) {
+ return getFrontierIntersection(PositionableUtils.convert(p));
+ }
+
+ public void draw(BasicCharArea area, double pixelXPerChar, double pixelYPerChar) {
+ for (CubicCurve2D.Double bez : beziers) {
+ if (bez.x1 == bez.x2) {
+ area.drawVLine('|', (int) (bez.x1 / pixelXPerChar), (int) (bez.y1 / pixelYPerChar),
+ (int) (bez.y2 / pixelYPerChar));
+ } else if (bez.y1 == bez.y2) {
+ area.drawHLine('-', (int) (bez.y1 / pixelYPerChar), (int) (bez.x1 / pixelXPerChar),
+ (int) (bez.x2 / pixelXPerChar));
+ } /*
+ * else { throw new UnsupportedOperationException("bez=" + toString(bez)); }
+ */
+ }
+ }
+
+ static String toString(CubicCurve2D.Double c) {
+ return "(" + c.x1 + "," + c.y1 + ") " + "(" + c.ctrlx1 + "," + c.ctrly1 + ") " + "(" + c.ctrlx2 + ","
+ + c.ctrly2 + ") " + "(" + c.x2 + "," + c.y2 + ") ";
+
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ for (CubicCurve2D.Double c : beziers) {
+ sb.append(toString(c));
+ }
+ return sb.toString();
+ }
+
+ public static CubicCurve2D.Double reverse(CubicCurve2D curv) {
+ return new CubicCurve2D.Double(curv.getX2(), curv.getY2(), curv.getCtrlX2(), curv.getCtrlY2(),
+ curv.getCtrlX1(), curv.getCtrlY1(), curv.getX1(), curv.getY1());
+ }
+
+ public DotPath reverse() {
+ final List<CubicCurve2D.Double> reverse = new ArrayList<CubicCurve2D.Double>(beziers);
+ Collections.reverse(reverse);
+ final List<CubicCurve2D.Double> copy = new ArrayList<CubicCurve2D.Double>();
+ for (CubicCurve2D.Double cub : reverse) {
+ copy.add(reverse(cub));
+ }
+ return new DotPath(copy);
+
+ }
+
+ public void moveSvek(double deltaX, double deltaY) {
+ for (int i = 0; i < beziers.size(); i++) {
+ final CubicCurve2D.Double c = beziers.get(i);
+ beziers.set(i, new CubicCurve2D.Double(c.x1 + deltaX, c.y1 + deltaY, c.ctrlx1 + deltaX, c.ctrly1 + deltaY,
+ c.ctrlx2 + deltaX, c.ctrly2 + deltaY, c.x2 + deltaX, c.y2 + deltaY));
+ }
+
+ }
+
+ public final List<CubicCurve2D.Double> getBeziers() {
+ return Collections.unmodifiableList(beziers);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/posimo/DotxMaker.java b/src/net/sourceforge/plantuml/posimo/DotxMaker.java
new file mode 100644
index 0000000..d97a42e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/posimo/DotxMaker.java
@@ -0,0 +1,135 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.posimo;
+
+import java.awt.geom.Dimension2D;
+import java.util.Collection;
+
+import net.sourceforge.plantuml.Log;
+
+public class DotxMaker {
+
+ private final Cluster root;
+ private final Collection<Path> paths;
+
+ public DotxMaker(Cluster root, Collection<Path> paths) {
+ this.root = root;
+ this.paths = paths;
+ }
+
+ public String createDotString(String... dotStrings) {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("digraph unix {");
+
+ for (String s : dotStrings) {
+ sb.append(s);
+ }
+
+ sb.append("compound=true;");
+
+ printCluster(sb, root);
+
+ for (Path p : paths) {
+ sb.append(getPathString(p) + ";");
+ }
+
+ sb.append("}");
+
+ return sb.toString();
+ }
+
+ private void printCluster(StringBuilder sb, Cluster cl) {
+ if (cl.getContents().size() == 0 && cl.getSubClusters().size() == 0) {
+ throw new IllegalStateException(cl.toString());
+ }
+ for (Cluster sub : cl.getSubClusters()) {
+ sb.append("subgraph cluster" + sub.getUid() + " {");
+ if (sub.getTitleWidth() > 0 && sub.getTitleHeight() > 0) {
+ sb.append("label=<<TABLE FIXEDSIZE=\"TRUE\" WIDTH=\"" + sub.getTitleWidth() + "\" HEIGHT=\""
+ + sub.getTitleHeight() + "\"><TR><TD></TD></TR></TABLE>>");
+ }
+
+ printCluster(sb, sub);
+ sb.append("}");
+
+ }
+ for (Block b : cl.getContents()) {
+ sb.append("b" + b.getUid() + getNodeAttibute(b) + ";");
+ }
+
+ }
+
+ private String getPathString(Path p) {
+ if (p == null) {
+ throw new IllegalArgumentException();
+ }
+ final StringBuilder sb = new StringBuilder("b" + p.getStart().getUid() + " -> b" + p.getEnd().getUid());
+ sb.append(" [dir=none, arrowhead=none, headclip=true, tailclip=true");
+ final int len = p.getLength();
+ if (len >= 3) {
+ sb.append(",minlen=" + (len - 1));
+ }
+ if (p.getLabel() == null) {
+ sb.append("]");
+ } else {
+ final Dimension2D size = p.getLabel().getSize();
+ sb.append(", label=<<TABLE FIXEDSIZE=\"TRUE\" WIDTH=\"" + size.getWidth() + "\" HEIGHT=\""
+ + size.getHeight() + "\"><TR><TD></TD></TR></TABLE>>]");
+ }
+
+ if (p.getLength() <= 1) {
+ final boolean samePackage = p.getStart().getParent() == p.getEnd().getParent();
+ if (samePackage) {
+ sb.append("{rank=same; b" + p.getStart().getUid() + "; b" + p.getEnd().getUid() + "}");
+ } else {
+ Log.println("!!!!!!!!!!!!!!!!!TURNING ARROUND DOT BUG!!!!!!!!!!!!!!!!!!");
+ }
+ }
+
+ return sb.toString();
+ }
+
+ private String getNodeAttibute(Block b) {
+ final StringBuilder sb = new StringBuilder("[");
+ sb.append("label=\"\",");
+ sb.append("fixedsize=true,");
+ sb.append("width=" + b.getSize().getWidth() / 72.0 + ",");
+ sb.append("height=" + b.getSize().getHeight() / 72.0 + ",");
+ sb.append("shape=rect");
+ sb.append("]");
+ return sb.toString();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/posimo/EntityImageNote2.java b/src/net/sourceforge/plantuml/posimo/EntityImageNote2.java
new file mode 100644
index 0000000..5c0048c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/posimo/EntityImageNote2.java
@@ -0,0 +1,80 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.posimo;
+
+import java.awt.geom.Dimension2D;
+import java.util.Collection;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.SimpleContext2D;
+import net.sourceforge.plantuml.skin.rose.Rose;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class EntityImageNote2 extends AbstractEntityImage2 {
+
+ private final Component comp;
+
+ public EntityImageNote2(IEntity entity, ISkinParam skinParam, Collection<Link> links) {
+ super(entity, skinParam);
+
+ final Rose skin = new Rose();
+
+ comp = skin.createComponent(ComponentType.NOTE, null, skinParam, entity.getDisplay());
+
+ }
+
+ @Override
+ public Dimension2D getDimension(StringBounder stringBounder) {
+ final double height = comp.getPreferredHeight(stringBounder);
+ final double width = comp.getPreferredWidth(stringBounder);
+ return new Dimension2DDouble(width, height);
+ }
+
+ public void drawU(UGraphic ug, double xTheoricalPosition, double yTheoricalPosition, double marginWidth,
+ double marginHeight) {
+ ug = ug.apply(new UTranslate(xTheoricalPosition, yTheoricalPosition));
+ comp.drawU(ug, new Area(getDimension(ug.getStringBounder())), new SimpleContext2D(false));
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/posimo/Frame.java b/src/net/sourceforge/plantuml/posimo/Frame.java
new file mode 100644
index 0000000..ee60f7d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/posimo/Frame.java
@@ -0,0 +1,135 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.posimo;
+
+import java.awt.geom.Dimension2D;
+import java.util.List;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.SpriteContainerEmpty;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.skin.rose.Rose;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class Frame implements Component {
+
+ private final List<? extends CharSequence> name;
+ private final ISkinParam skinParam;
+ private final Rose rose = new Rose();
+
+ // private final Color textColor;
+ // private final Color lineColor;
+ // private final Font font;
+
+ public Frame(List<? extends CharSequence> name, ISkinParam skinParam) {
+ this.name = name;
+ this.skinParam = skinParam;
+ // this.textColor = textColor;
+ // this.lineColor = lineColor;
+ // this.font = font;
+ }
+
+ public void drawU(UGraphic ug, Area area, Context2D context) {
+ final Dimension2D dimensionToUse = area.getDimensionToUse();
+ final HtmlColor lineColor = rose.getHtmlColor(skinParam, ColorParam.packageBorder);
+ ug = ug.apply(new UChangeColor(lineColor));
+ ug = ug.apply(new UChangeBackColor(null));
+ ug.apply(new UStroke(1.4)).draw(new URectangle(dimensionToUse.getWidth(), dimensionToUse.getHeight()));
+
+ final TextBlock textBlock = createTextBloc();
+ textBlock.drawU(ug.apply(new UTranslate(2, 2)));
+
+ final Dimension2D textDim = getTextDim(ug.getStringBounder());
+ final double x = textDim.getWidth() + 6;
+ final double y = textDim.getHeight() + 6;
+ final UPolygon poly = new UPolygon();
+ poly.addPoint(x, 0);
+ poly.addPoint(x, y - 6);
+ poly.addPoint(x - 6, y);
+ poly.addPoint(0, y);
+ poly.addPoint(0, 0);
+ ug.apply(new UStroke(1.4)).draw(poly);
+
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ final Dimension2D dim = getTextDim(stringBounder);
+ return dim.getHeight() + 8;
+ }
+
+ public double getPreferredWidth(StringBounder stringBounder) {
+ final Dimension2D dim = getTextDim(stringBounder);
+ return dim.getWidth() + 8;
+ }
+
+ public Dimension2D getTextDim(StringBounder stringBounder) {
+ final TextBlock bloc = createTextBloc();
+ return bloc.calculateDimension(stringBounder);
+ }
+
+ private TextBlock createTextBloc() {
+ final UFont font = skinParam.getFont(FontParam.PACKAGE, null, false);
+ final HtmlColor textColor = skinParam.getFontHtmlColor(FontParam.PACKAGE, null);
+ final TextBlock bloc = TextBlockUtils.create(Display.create(name), new FontConfiguration(font, textColor, skinParam.getHyperlinkColor(), skinParam.useUnderlineForHyperlink()),
+ HorizontalAlignment.LEFT, new SpriteContainerEmpty());
+ return bloc;
+ }
+
+ public final Dimension2D getPreferredDimension(StringBounder stringBounder) {
+ final double w = getPreferredWidth(stringBounder);
+ final double h = getPreferredHeight(stringBounder);
+ return new Dimension2DDouble(w, h);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/posimo/GraphvizSolverB.java b/src/net/sourceforge/plantuml/posimo/GraphvizSolverB.java
new file mode 100644
index 0000000..e117355
--- /dev/null
+++ b/src/net/sourceforge/plantuml/posimo/GraphvizSolverB.java
@@ -0,0 +1,265 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.posimo;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.StringTokenizer;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.Log;
+import net.sourceforge.plantuml.OptionFlags;
+import net.sourceforge.plantuml.cucadiagram.dot.Graphviz;
+import net.sourceforge.plantuml.cucadiagram.dot.GraphvizUtils;
+import net.sourceforge.plantuml.cucadiagram.dot.ProcessState;
+import net.sourceforge.plantuml.svek.MinFinder;
+import net.sourceforge.plantuml.utils.UniqueSequence;
+
+public class GraphvizSolverB {
+
+ static private void traceDotString(String dotString) throws IOException {
+ final File f = new File("dottmpfile" + UniqueSequence.getValue() + ".tmp");
+ PrintWriter pw = null;
+ try {
+ pw = new PrintWriter(new FileWriter(f));
+ pw.print(dotString);
+ Log.info("Creating file " + f);
+ } finally {
+ if (pw != null) {
+ pw.close();
+ }
+ }
+ }
+
+ static private void traceSvgString(String svg) throws IOException {
+ final File f = new File("svgtmpfile" + UniqueSequence.getValue() + ".svg");
+ PrintWriter pw = null;
+ try {
+ pw = new PrintWriter(new FileWriter(f));
+ pw.print(svg);
+ Log.info("Creating file " + f);
+ } finally {
+ if (pw != null) {
+ pw.close();
+ }
+ }
+ }
+
+ public Dimension2D solve(Cluster root, Collection<Path> paths) throws IOException {
+ final String dotString = new DotxMaker(root, paths).createDotString("nodesep=0.2;", "ranksep=0.2;");
+
+ if (OptionFlags.getInstance().isKeepTmpFiles()) {
+ traceDotString(dotString);
+ }
+
+ final MinFinder minMax = new MinFinder();
+
+ // Log.println("dotString=" + dotString);
+
+ // exportPng(dotString, new File("png", "test1.png"));
+
+ final Graphviz graphviz = GraphvizUtils.create(dotString, "svg");
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final ProcessState state = graphviz.createFile3(baos);
+ baos.close();
+ if (state.differs(ProcessState.TERMINATED_OK())) {
+ throw new IllegalStateException("Timeout2 " + state);
+ }
+ final byte[] result = baos.toByteArray();
+ final String s = new String(result, "UTF-8");
+ // Log.println("result=" + s);
+
+ if (OptionFlags.getInstance().isKeepTmpFiles()) {
+ traceSvgString(s);
+ }
+
+ final Pattern pGraph = Pattern.compile("(?m)\\<svg\\s+width=\"(\\d+)pt\"\\s+height=\"(\\d+)pt\"");
+ final Matcher mGraph = pGraph.matcher(s);
+ if (mGraph.find() == false) {
+ throw new IllegalStateException();
+ }
+ final int width = Integer.parseInt(mGraph.group(1));
+ final int height = Integer.parseInt(mGraph.group(2));
+
+ for (Block b : root.getRecursiveContents()) {
+ final String start = "b" + b.getUid();
+ final int p1 = s.indexOf("<title>" + start + "</title>");
+ if (p1 == -1) {
+ throw new IllegalStateException();
+ }
+ final List<Point2D.Double> pointsList = extractPointsList(s, p1);
+ b.setX(getMinX(pointsList));
+ b.setY(getMinY(pointsList) + height);
+ minMax.manage(b.getPosition());
+ }
+
+ for (Cluster cl : root.getSubClusters()) {
+ final String start = "cluster" + cl.getUid();
+ final int p1 = s.indexOf("<title>" + start + "</title>");
+ if (p1 == -1) {
+ throw new IllegalStateException();
+ }
+ final List<Point2D.Double> pointsList = extractPointsList(s, p1);
+ cl.setX(getMinX(pointsList));
+ cl.setY(getMinY(pointsList) + height);
+ final double w = getMaxX(pointsList) - getMinX(pointsList);
+ final double h = getMaxY(pointsList) - getMinY(pointsList);
+ cl.setHeight(h);
+ cl.setWidth(w);
+ minMax.manage(cl.getPosition());
+ }
+
+ for (Path p : paths) {
+ final String start = "b" + p.getStart().getUid();
+ final String end = "b" + p.getEnd().getUid();
+ final String searched = "<title>" + start + "&#45;&gt;" + end + "</title>";
+ final int p1 = s.indexOf(searched);
+ if (p1 == -1) {
+ throw new IllegalStateException(searched);
+ }
+ final int p2 = s.indexOf(" d=\"", p1);
+ final int p3 = s.indexOf("\"", p2 + " d=\"".length());
+ final String points = s.substring(p2 + " d=\"".length(), p3);
+ final DotPath dotPath = new DotPath(points, height);
+ p.setDotPath(dotPath);
+ minMax.manage(dotPath.getMinFinder());
+
+ // Log.println("pointsList=" + pointsList);
+ if (p.getLabel() != null) {
+ final List<Point2D.Double> pointsList = extractPointsList(s, p1);
+ final double x = getMinX(pointsList);
+ final double y = getMinY(pointsList) + height;
+ p.setLabelPosition(x, y);
+ minMax.manage(x, y);
+ }
+ }
+ return new Dimension2DDouble(width, height);
+ }
+
+ static private List<Point2D.Double> extractPointsList(final String svg, final int starting) {
+ final String pointsString = "points=\"";
+ final int p2 = svg.indexOf(pointsString, starting);
+ final int p3 = svg.indexOf("\"", p2 + pointsString.length());
+ final String points = svg.substring(p2 + pointsString.length(), p3);
+ final List<Point2D.Double> pointsList = getPoints(points);
+ return pointsList;
+ }
+
+ static private double getMaxX(List<Point2D.Double> points) {
+ double result = points.get(0).x;
+ for (int i = 1; i < points.size(); i++) {
+ if (points.get(i).x > result) {
+ result = points.get(i).x;
+ }
+ }
+ return result;
+ }
+
+ static private double getMinX(List<Point2D.Double> points) {
+ double result = points.get(0).x;
+ for (int i = 1; i < points.size(); i++) {
+ if (points.get(i).x < result) {
+ result = points.get(i).x;
+ }
+ }
+ return result;
+ }
+
+ static private double getMaxY(List<Point2D.Double> points) {
+ double result = points.get(0).y;
+ for (int i = 1; i < points.size(); i++) {
+ if (points.get(i).y > result) {
+ result = points.get(i).y;
+ }
+ }
+ return result;
+ }
+
+ static private double getMinY(List<Point2D.Double> points) {
+ double result = points.get(0).y;
+ for (int i = 1; i < points.size(); i++) {
+ if (points.get(i).y < result) {
+ result = points.get(i).y;
+ }
+ }
+ return result;
+ }
+
+ static private List<Point2D.Double> getPoints(String points) {
+ final List<Point2D.Double> result = new ArrayList<Point2D.Double>();
+ final StringTokenizer st = new StringTokenizer(points, " ");
+ while (st.hasMoreTokens()) {
+ final String t = st.nextToken();
+ final StringTokenizer st2 = new StringTokenizer(t, ",");
+ final double x = Double.parseDouble(st2.nextToken());
+ final double y = Double.parseDouble(st2.nextToken());
+ result.add(new Point2D.Double(x, y));
+ }
+ return result;
+ }
+
+ private void exportPng(final String dotString, File f) throws IOException {
+ final Graphviz graphviz = GraphvizUtils.create(dotString, "png");
+ final OutputStream os = new BufferedOutputStream(new FileOutputStream(f));
+ final ProcessState state = graphviz.createFile3(os);
+ os.close();
+ if (state.differs(ProcessState.TERMINATED_OK())) {
+ throw new IllegalStateException("Timeout3 " + state);
+ }
+ }
+
+ private Path getPath(Collection<Path> paths, int start, int end) {
+ for (Path p : paths) {
+ if (p.getStart().getUid() == start && p.getEnd().getUid() == end) {
+ return p;
+ }
+ }
+ throw new IllegalArgumentException();
+
+ }
+}
diff --git a/src/net/sourceforge/plantuml/posimo/IEntityImageBlock.java b/src/net/sourceforge/plantuml/posimo/IEntityImageBlock.java
new file mode 100644
index 0000000..a895e35
--- /dev/null
+++ b/src/net/sourceforge/plantuml/posimo/IEntityImageBlock.java
@@ -0,0 +1,48 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.posimo;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public interface IEntityImageBlock {
+
+ Dimension2D getDimension(StringBounder stringBounder);
+
+ void drawU(UGraphic ug, double xTheoricalPosition, double yTheoricalPosition, double marginWidth,
+ double marginHeight);
+}
diff --git a/src/net/sourceforge/plantuml/posimo/Label.java b/src/net/sourceforge/plantuml/posimo/Label.java
new file mode 100644
index 0000000..74694b1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/posimo/Label.java
@@ -0,0 +1,91 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.posimo;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+
+public class Label implements Positionable {
+
+ private double width;
+ private double height;
+ private double x;
+ private double y;
+
+ public Label(double width, double height) {
+ this.width = width;
+ this.height = height;
+ }
+
+ public final void setCenterX(double center) {
+ this.x = center - width / 2;
+ }
+
+ public final void setCenterY(double center) {
+ this.y = center - height / 2;
+ }
+
+ public Point2D getPosition() {
+ return new Point2D.Double(x, y);
+ }
+
+ public Dimension2D getSize() {
+ return new Dimension2DDouble(width, height);
+ }
+
+ public final void setWidth(double width) {
+ this.width = width;
+ }
+
+ public final void setHeight(double height) {
+ this.height = height;
+ }
+
+ public final void setX(double x) {
+ this.x = x;
+ }
+
+ public final void setY(double y) {
+ this.y = y;
+ }
+
+ public void moveSvek(double deltaX, double deltaY) {
+ throw new UnsupportedOperationException();
+ }
+
+
+}
diff --git a/src/net/sourceforge/plantuml/posimo/LabelImage.java b/src/net/sourceforge/plantuml/posimo/LabelImage.java
new file mode 100644
index 0000000..219fe90
--- /dev/null
+++ b/src/net/sourceforge/plantuml/posimo/LabelImage.java
@@ -0,0 +1,86 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.posimo;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.SpriteContainerEmpty;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.skin.rose.Rose;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class LabelImage {
+
+ // private final Entity entity;
+ final private ISkinParam param;
+ final private Rose rose;
+ final private TextBlock name;
+
+ public LabelImage(Link link, Rose rose, ISkinParam param) {
+ if (link == null) {
+ throw new IllegalArgumentException();
+ }
+ // this.entity = entity;
+ this.param = param;
+ this.rose = rose;
+ this.name = TextBlockUtils.create(link.getLabel(),
+ new FontConfiguration(param.getFont(FontParam.CLASS, null, false), HtmlColorUtils.BLACK, param.getHyperlinkColor(), param.useUnderlineForHyperlink()), HorizontalAlignment.CENTER, new SpriteContainerEmpty());
+ }
+
+ public Dimension2D getDimension(StringBounder stringBounder) {
+ final Dimension2D dim = name.calculateDimension(stringBounder);
+ return dim;
+ // return Dimension2DDouble.delta(dim, 2 * margin);
+ }
+
+ public void drawU(UGraphic ug, double x, double y) {
+ // final Dimension2D dim = getDimension(ug.getStringBounder());
+ // ug.getParam().setBackcolor(rose.getHtmlColor(param,
+ // ColorParam.classBackground).getColor());
+ // ug.getParam().setColor(rose.getHtmlColor(param,
+ // ColorParam.classBorder).getColor());
+ // ug.draw(x, y, new URectangle(dim.getWidth(), dim.getHeight()));
+ name.drawU(ug.apply(new UTranslate(x, y)));
+ }
+}
diff --git a/src/net/sourceforge/plantuml/posimo/LineRectIntersection.java b/src/net/sourceforge/plantuml/posimo/LineRectIntersection.java
new file mode 100644
index 0000000..29e318e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/posimo/LineRectIntersection.java
@@ -0,0 +1,82 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.posimo;
+
+import java.awt.geom.Line2D;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+
+public class LineRectIntersection {
+
+ private final Point2D inter;
+
+ public LineRectIntersection(Line2D line, Rectangle2D rect) {
+ final Point2D p1 = new Point2D.Double(rect.getMinX(), rect.getMinY());
+ final Point2D p2 = new Point2D.Double(rect.getMaxX(), rect.getMinY());
+ final Point2D p3 = new Point2D.Double(rect.getMaxX(), rect.getMaxY());
+ final Point2D p4 = new Point2D.Double(rect.getMinX(), rect.getMaxY());
+
+ final Point2D inter1 = new LineSegmentIntersection(new Line2D.Double(p1, p2), line).getIntersection();
+ final Point2D inter2 = new LineSegmentIntersection(new Line2D.Double(p2, p3), line).getIntersection();
+ final Point2D inter3 = new LineSegmentIntersection(new Line2D.Double(p3, p4), line).getIntersection();
+ final Point2D inter4 = new LineSegmentIntersection(new Line2D.Double(p4, p1), line).getIntersection();
+
+ final Point2D o = line.getP1();
+ inter = getCloser(o, inter1, inter2, inter3, inter4);
+
+ }
+
+ public static Point2D getCloser(final Point2D o, final Point2D... other) {
+ double minDist = Double.MAX_VALUE;
+ Point2D result = null;
+
+ for (Point2D pt : other) {
+ if (pt != null) {
+ final double dist = pt.distanceSq(o);
+ if (dist < minDist) {
+ minDist = dist;
+ result = pt;
+ }
+ }
+ }
+
+ return result;
+ }
+
+ public final Point2D getIntersection() {
+ return inter;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/posimo/LineSegmentIntersection.java b/src/net/sourceforge/plantuml/posimo/LineSegmentIntersection.java
new file mode 100644
index 0000000..d3d3575
--- /dev/null
+++ b/src/net/sourceforge/plantuml/posimo/LineSegmentIntersection.java
@@ -0,0 +1,80 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.posimo;
+
+import java.awt.geom.Line2D;
+import java.awt.geom.Point2D;
+
+public class LineSegmentIntersection {
+
+ private final Point2D inter;
+
+ // http://local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/
+
+ public LineSegmentIntersection(Line2D segment, Line2D lineB) {
+ final double x1 = segment.getX1();
+ final double y1 = segment.getY1();
+ final double x2 = segment.getX2();
+ final double y2 = segment.getY2();
+ final double x3 = lineB.getX1();
+ final double y3 = lineB.getY1();
+ final double x4 = lineB.getX2();
+ final double y4 = lineB.getY2();
+
+ final double den = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1);
+
+ if (den == 0) {
+ inter = null;
+ } else {
+
+ final double uA1 = (x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3);
+ final double uA = uA1 / den;
+
+ final double x = x1 + uA * (x2 - x1);
+ final double y = y1 + uA * (y2 - y1);
+
+ if (uA >= 0 && uA <= 1) {
+ inter = new Point2D.Double(x, y);
+ } else {
+ inter = null;
+ }
+ }
+ }
+
+ public final Point2D getIntersection() {
+ return inter;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/posimo/MargedBlock.java b/src/net/sourceforge/plantuml/posimo/MargedBlock.java
new file mode 100644
index 0000000..65a8ca7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/posimo/MargedBlock.java
@@ -0,0 +1,89 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.posimo;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+
+public class MargedBlock {
+
+ private final Block block;
+ private final IEntityImageBlock imageBlock;
+ private final double marginDecorator;
+ private final Dimension2D imageDimension;
+
+ static private int uid = 1;
+
+ public MargedBlock(StringBounder stringBounder, IEntityImageBlock imageBlock, double marginDecorator, Cluster parent) {
+ this.imageBlock = imageBlock;
+ this.marginDecorator = marginDecorator;
+ this.imageDimension = imageBlock.getDimension(stringBounder);
+ this.block = new Block(uid++, imageDimension.getWidth() + 2 * marginDecorator, imageDimension.getHeight() + 2
+ * marginDecorator, parent);
+ }
+
+ public Block getBlock() {
+ return block;
+ }
+
+ public double getMarginDecorator() {
+ return marginDecorator;
+ }
+
+ public IEntityImageBlock getImageBlock() {
+ return imageBlock;
+ }
+
+ public Positionable getImagePosition() {
+ return new Positionable() {
+
+ public Dimension2D getSize() {
+ return imageDimension;
+ }
+
+ public Point2D getPosition() {
+ final Point2D pos = block.getPosition();
+ return new Point2D.Double(pos.getX() + marginDecorator, pos.getY() + marginDecorator);
+ }
+
+ public void moveSvek(double deltaX, double deltaY) {
+ throw new UnsupportedOperationException();
+ }
+ };
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/posimo/Mirror.java b/src/net/sourceforge/plantuml/posimo/Mirror.java
new file mode 100644
index 0000000..f979a6e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/posimo/Mirror.java
@@ -0,0 +1,53 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.posimo;
+
+public class Mirror {
+
+ private final double max;
+
+ public Mirror(double max) {
+ this.max = max;
+ }
+
+ public double getMirrored(double v) {
+ if (v < 0 || v > max) {
+ throw new IllegalArgumentException();
+ }
+ //return v;
+ return max - v;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/posimo/Moveable.java b/src/net/sourceforge/plantuml/posimo/Moveable.java
new file mode 100644
index 0000000..a738d50
--- /dev/null
+++ b/src/net/sourceforge/plantuml/posimo/Moveable.java
@@ -0,0 +1,41 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.posimo;
+
+public interface Moveable {
+
+ void moveSvek(double deltaX, double deltaY);
+
+}
diff --git a/src/net/sourceforge/plantuml/posimo/Path.java b/src/net/sourceforge/plantuml/posimo/Path.java
new file mode 100644
index 0000000..452fd7c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/posimo/Path.java
@@ -0,0 +1,97 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.posimo;
+
+public class Path {
+
+ private final Label label;
+ private final Block start;
+ private final Block end;
+ private final int length;
+ private DotPath dotPath;
+
+ public Path(Block start, Block end, Label label) {
+ this(start, end, label, 2);
+ }
+
+ public Path(Block start, Block end, Label label, int length) {
+ if (start == null || end == null) {
+ throw new IllegalArgumentException();
+ }
+ if (length < 1) {
+ throw new IllegalArgumentException("length=" + length);
+ }
+ this.start = start;
+ this.end = end;
+ this.label = label;
+ this.length = length;
+ }
+
+ public final Label getLabel() {
+ return label;
+ }
+
+ public final Block getStart() {
+ return start;
+ }
+
+ public final Block getEnd() {
+ return end;
+ }
+
+ public void setLabelPositionCenter(double labelX, double labelY) {
+ label.setCenterX(labelX);
+ label.setCenterY(labelY);
+ }
+
+ public void setLabelPosition(double x, double y) {
+ label.setX(x);
+ label.setY(y);
+ }
+
+ public void setDotPath(DotPath dotPath) {
+ this.dotPath = dotPath;
+
+ }
+
+ public final DotPath getDotPath() {
+ return dotPath;
+ }
+
+ public int getLength() {
+ return length;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/posimo/PathDrawer.java b/src/net/sourceforge/plantuml/posimo/PathDrawer.java
new file mode 100644
index 0000000..78c57b8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/posimo/PathDrawer.java
@@ -0,0 +1,45 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.posimo;
+
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public interface PathDrawer {
+
+ public void drawPathBefore(UGraphic ug, Positionable start, Positionable end, Path path);
+
+ public void drawPathAfter(UGraphic ug, Positionable start, Positionable end, Path path);
+
+}
diff --git a/src/net/sourceforge/plantuml/posimo/PathDrawerInterface.java b/src/net/sourceforge/plantuml/posimo/PathDrawerInterface.java
new file mode 100644
index 0000000..e030684
--- /dev/null
+++ b/src/net/sourceforge/plantuml/posimo/PathDrawerInterface.java
@@ -0,0 +1,327 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.posimo;
+
+import java.awt.geom.CubicCurve2D;
+import java.awt.geom.Point2D;
+import java.util.Collection;
+import java.util.Map;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.cucadiagram.LinkDecor;
+import net.sourceforge.plantuml.cucadiagram.LinkStyle;
+import net.sourceforge.plantuml.cucadiagram.LinkType;
+import net.sourceforge.plantuml.skin.rose.Rose;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class PathDrawerInterface implements PathDrawer {
+
+ private final Rose rose;
+ private final ISkinParam param;
+ private final LinkType linkType;
+
+ public static PathDrawerInterface create(ISkinParam param, LinkType linkType) {
+ return new PathDrawerInterface(new Rose(), param, linkType);
+ }
+
+ private PathDrawerInterface(Rose rose, ISkinParam param, LinkType linkType) {
+ this.rose = rose;
+ this.param = param;
+ this.linkType = linkType;
+ }
+
+ public void drawPathBefore(UGraphic ug, Positionable start, Positionable end, Path path) {
+ // // final DotPath dotPath = path.getDotPath();
+ // // goDash(ug);
+ // // ug.draw(0, 0, dotPath);
+ // // noDash(ug);
+ }
+
+ private void noDash(UGraphic ug) {
+ // ug.getParam().resetStroke();
+ throw new UnsupportedOperationException();
+ }
+
+ private void goDash(UGraphic ug) {
+ // ug.getParam().setStroke(new UStroke(8, 8, 1.0));
+ throw new UnsupportedOperationException();
+ }
+
+ public void drawPathAfter(UGraphic ug, Positionable start, Positionable end, Path path) {
+ DotPath dotPath = path.getDotPath();
+ final Racorder racorder = new RacorderOrthogonal();
+ // final Racorder racorder = new RacorderInToCenter();
+ // final Racorder racorder = new RacorderFollowTangeante();
+
+ final Point2D endPath = dotPath.getEndPoint();
+ final DotPath in = racorder.getRacordIn(PositionableUtils.convert(end), dotPath.getEndTangeante());
+ // final Point2D inPoint = in.getFrontierIntersection(end);
+ final Point2D inPoint = in.getEndPoint();
+ // final double theta1_ = in.getEndAngle() + Math.PI / 2;
+ // Log.println("theta1_=" + theta1_ + " " + theta1_ * 180 /
+ // Math.PI);
+ final double theta1 = atan2(endPath, inPoint);
+ // Log.println("theta1=" + theta1 + " " + theta1 * 180 /
+ // Math.PI);
+ final Point2D middle1 = drawSymbol(ug, theta1, inPoint, linkType.getDecor1());
+
+ final Point2D startPath = dotPath.getStartPoint();
+ final DotPath out = racorder.getRacordOut(PositionableUtils.convert(start), dotPath.getStartTangeante());
+ // final Point2D outPoint = out.getFrontierIntersection(start);
+ final Point2D outPoint = out.getStartPoint();
+ // final double theta2_ = out.getStartAngle() - Math.PI / 2;
+ // Log.println("theta2_=" + theta2_ + " " + theta2_ * 180 /
+ // Math.PI);
+ final double theta2 = atan2(startPath, outPoint);
+ // Log.println("theta2=" + theta2 + " " + theta2 * 180 /
+ // Math.PI);
+ final Point2D middle2 = drawSymbol(ug, theta2, outPoint, linkType.getDecor2());
+
+ if (middle1 != null) {
+ final CubicCurve2D.Double after = getLine(endPath, middle1);
+ dotPath = dotPath.addAfter(after);
+ // dotPath = dotPath.addAfter(in);
+ }
+
+ if (middle2 != null) {
+ final CubicCurve2D.Double before = getLine(middle2, startPath);
+ dotPath = dotPath.addBefore(before);
+ // dotPath = dotPath.addBefore(out);
+ }
+
+ final LinkStyle style = linkType.getStyle();
+ if (style == LinkStyle.__toremove_INTERFACE_PROVIDER || style == LinkStyle.__toremove_INTERFACE_USER) {
+ final Decor decor = new DecorInterfaceProvider(style);
+ final Map<Point2D, Double> all = dotPath.somePoints();
+ final Point2D p = getFarest(outPoint, inPoint, all.keySet());
+
+ ug = ug.apply(new UChangeBackColor(rose.getHtmlColor(param, ColorParam.background)));
+ ug = ug.apply(new UChangeColor(rose.getHtmlColor(param, ColorParam.classBorder)));
+
+ decor.drawDecor(ug, p, all.get(p));
+ }
+
+ ug = ug.apply(new UChangeColor(rose.getHtmlColor(param, ColorParam.classBorder)));
+ if (linkType.isDashed()) {
+ goDash(ug);
+ }
+ ug.draw(dotPath);
+ if (linkType.isDashed()) {
+ noDash(ug);
+ }
+ }
+
+ private double atan2(final Point2D endPath, final Point2D inPoint) {
+ final double y = -endPath.getX() + inPoint.getX();
+ final double x = endPath.getY() - inPoint.getY();
+ final double angle = Math.atan2(y, x);
+ // Log.println("x=" + x + " y=" + y + " angle=" + angle + " " + angle * 180.0 / Math.PI);
+ return angle;
+ }
+
+ private Point2D drawSymbol(UGraphic ug, double theta, final Point2D position, LinkDecor decor) {
+ // if (1==1) {
+ // return null;
+ // }
+ // Point2D middle1 = null;
+ // // final double theta = Math.atan2(
+ // // -direction.getX() + position.getX(), direction.getY()
+ // // - position.getY());
+ // if (decor == LinkDecor.SQUARRE) {
+ // middle1 = drawSquare(ug, position.getX(), position.getY());
+ // } else if (decor == LinkDecor.EXTENDS) {
+ // middle1 = drawExtends(ug, position.getX(), position.getY(), theta);
+ // } else if (decor == LinkDecor.AGREGATION) {
+ // ug.getParam().setBackcolor(rose.getHtmlColor(param, ColorParam.background));
+ // ug.getParam().setColor(rose.getHtmlColor(param, ColorParam.classBorder));
+ // middle1 = drawDiamond(ug, position.getX(), position.getY(), theta);
+ // } else if (decor == LinkDecor.COMPOSITION) {
+ // ug.getParam().setBackcolor(rose.getHtmlColor(param, ColorParam.classBorder));
+ // ug.getParam().setColor(null);
+ // middle1 = drawDiamond(ug, position.getX(), position.getY(), theta);
+ // } else if (decor == LinkDecor.NONE) {
+ // middle1 = position;
+ // } else if (decor == LinkDecor.ARROW) {
+ // ug.getParam().setBackcolor(rose.getHtmlColor(param, ColorParam.classBorder));
+ // ug.getParam().setColor(rose.getHtmlColor(param, ColorParam.classBorder));
+ // middle1 = drawArrow(ug, position.getX(), position.getY(), theta);
+ // }
+ // return middle1;
+ throw new UnsupportedOperationException();
+ }
+
+ private CubicCurve2D.Double getLine(final Point2D p1, Point2D p2) {
+ return new CubicCurve2D.Double(p1.getX(), p1.getY(), p1.getX(), p1.getY(), p2.getX(), p2.getY(), p2.getX(),
+ p2.getY());
+ }
+
+ private static Point2D getFarest(Point2D p1, Point2D p2, Collection<Point2D> all) {
+ Point2D result = null;
+ double farest = 0;
+ for (Point2D p : all) {
+ if (result == null) {
+ result = p;
+ farest = p1.distanceSq(result) + p2.distanceSq(result);
+ continue;
+ }
+ final double candidat = p1.distanceSq(p) + p2.distanceSq(p);
+ if (candidat < farest) {
+ result = p;
+ farest = candidat;
+ }
+ }
+ if (result == null) {
+ throw new IllegalArgumentException();
+ }
+ return result;
+ }
+
+ private Point2D drawSquare(UGraphic ug, double centerX, double centerY) {
+ ug = ug.apply(new UChangeBackColor(rose.getHtmlColor(param, ColorParam.classBackground)));
+ ug = ug.apply(new UChangeColor(rose.getHtmlColor(param, ColorParam.classBorder)));
+ final double width = 10;
+ final double height = 10;
+ ug.apply(new UTranslate(centerX - width / 2, centerY - height / 2)).draw(new URectangle(width, height));
+ return new Point2D.Double(centerX, centerY);
+ }
+
+ Point2D drawExtends(UGraphic ug, double x, double y, double theta) {
+ ug = ug.apply(new UChangeBackColor(rose.getHtmlColor(param, ColorParam.background)));
+ ug = ug.apply(new UChangeColor(rose.getHtmlColor(param, ColorParam.classBorder)));
+
+ // final double theta = Math.atan2(-pathPoint.getX() + x,
+ // pathPoint.getY() - y);
+
+ final UPolygon triangle = new UPolygon();
+ triangle.addPoint(0, 1);
+ final double width = 18;
+ final double height = 26;
+ triangle.addPoint(-width / 2, height);
+ triangle.addPoint(width / 2, height);
+ triangle.rotate(theta);
+ ug.apply(new UTranslate(x, y)).draw(triangle);
+
+ final Point2D middle = BezierUtils.middle(triangle.getPoints().get(1), triangle.getPoints().get(2));
+ middle.setLocation(middle.getX() + x, middle.getY() + y);
+ return middle;
+ }
+
+ private Point2D drawDiamond(UGraphic ug, double x, double y, double theta) {
+
+ // final double theta = Math.atan2(-pathPoint.getX() + x,
+ // pathPoint.getY() - y);
+
+ final UPolygon triangle = new UPolygon();
+ triangle.addPoint(0, 0);
+ final double width = 10;
+ final double height = 14;
+ triangle.addPoint(-width / 2, height / 2);
+ triangle.addPoint(0, height);
+ triangle.addPoint(width / 2, height / 2);
+ triangle.rotate(theta);
+ ug.apply(new UTranslate(x, y)).draw(triangle);
+
+ final Point2D middle = triangle.getPoints().get(2);
+ middle.setLocation(middle.getX() + x, middle.getY() + y);
+ return middle;
+
+ }
+
+ private Point2D drawArrow(UGraphic ug, double x, double y, double theta) {
+
+ // final double theta = Math.atan2(-pathPoint.getX() + x,
+ // pathPoint.getY() - y);
+
+ final UPolygon triangle = new UPolygon();
+ triangle.addPoint(0, 0);
+ final double width = 12;
+ final double height = 10;
+ triangle.addPoint(-width / 2, height);
+ final double height2 = 4;
+ triangle.addPoint(0, height2);
+ triangle.addPoint(width / 2, height);
+ triangle.rotate(theta);
+ ug.apply(new UTranslate(x, y)).draw(triangle);
+
+ final Point2D middle = triangle.getPoints().get(2);
+ middle.setLocation(middle.getX() + x, middle.getY() + y);
+ return middle;
+ }
+
+ private Point2D nullIfContained(Point2D p, Positionable start, Positionable end) {
+ if (PositionableUtils.contains(start, p)) {
+ return null;
+ }
+ if (PositionableUtils.contains(end, p)) {
+ return null;
+ }
+ return p;
+ }
+
+ // private void drawPath(UGraphic ug, PointList points, Positionable start,
+ // Positionable end) {
+ // Decor decor = new DecorInterfaceProvider();
+ // Point2D last = null;
+ // final int nb = 10;
+ // final double t1 =
+ // points.getIntersectionDouble(PositionableUtils.convert(start));
+ // final double t2 =
+ // points.getIntersectionDouble(PositionableUtils.convert(end));
+ // for (int i = 0; i <= nb; i++) {
+ // final double d = t1 + (t2 - t1) * i / nb;
+ // final Point2D cur = nullIfContained(points.getPoint(d), start, end);
+ // if (last != null && cur != null) {
+ // ug.draw(last.getX(), last.getY(), new ULine(cur.getX() - last.getX(),
+ // cur.getY() - last.getY()));
+ // if (decor != null) {
+ // decor.drawLine(ug, last, cur);
+ // decor = null;
+ // }
+ // }
+ // last = cur;
+ // }
+ //
+ // for (Point2D p : points.getPoints()) {
+ // ug.draw(p.getX() - 1, p.getY() - 1, new UEllipse(2, 2));
+ // }
+ // }
+
+}
diff --git a/src/net/sourceforge/plantuml/posimo/Positionable.java b/src/net/sourceforge/plantuml/posimo/Positionable.java
new file mode 100644
index 0000000..30fa0e8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/posimo/Positionable.java
@@ -0,0 +1,46 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.posimo;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+
+public interface Positionable extends Moveable {
+
+ public Dimension2D getSize();
+
+ public Point2D getPosition();
+
+}
diff --git a/src/net/sourceforge/plantuml/posimo/PositionableImpl.java b/src/net/sourceforge/plantuml/posimo/PositionableImpl.java
new file mode 100644
index 0000000..1763af4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/posimo/PositionableImpl.java
@@ -0,0 +1,67 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.posimo;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+
+public class PositionableImpl implements Positionable {
+
+ private final Point2D pos;
+
+ private final Dimension2D dim;
+
+ public PositionableImpl(double x, double y, Dimension2D dim) {
+ this.pos = new Point2D.Double(x, y);
+ this.dim = dim;
+ }
+
+ public PositionableImpl(Point2D pt, Dimension2D dim) {
+ this(pt.getX(), pt.getY(), dim);
+ }
+
+ public Point2D getPosition() {
+ return pos;
+ }
+
+ public Dimension2D getSize() {
+ return dim;
+ }
+
+ public void moveSvek(double deltaX, double deltaY) {
+ this.pos.setLocation(pos.getX() + deltaX, pos.getY() + deltaY);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/posimo/PositionableUtils.java b/src/net/sourceforge/plantuml/posimo/PositionableUtils.java
new file mode 100644
index 0000000..4349833
--- /dev/null
+++ b/src/net/sourceforge/plantuml/posimo/PositionableUtils.java
@@ -0,0 +1,177 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.posimo;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+
+public class PositionableUtils {
+
+ static public Rectangle2D convert(Positionable positionable) {
+ final Point2D position = positionable.getPosition();
+ final Dimension2D size = positionable.getSize();
+ return new Rectangle2D.Double(position.getX(), position.getY(), size.getWidth(), size.getHeight());
+ }
+
+ static public boolean contains(Positionable positionable, Point2D p) {
+ final Point2D position = positionable.getPosition();
+ final Dimension2D size = positionable.getSize();
+ final double width = size.getWidth();
+ final double height = size.getHeight();
+
+ if (p.getX() < position.getX()) {
+ return false;
+ }
+ if (p.getX() > position.getX() + width) {
+ return false;
+ }
+ if (p.getY() < position.getY()) {
+ return false;
+ }
+ if (p.getY() > position.getY() + height) {
+ return false;
+ }
+ return true;
+ }
+
+ static public boolean intersect(Positionable big, Positionable small) {
+ final Rectangle2D bigR = convert(big);
+ final Rectangle2D smallR = convert(small);
+ return bigR.intersects(smallR);
+ // final Point2D pt = small.getPosition();
+ // final Dimension2D dim = small.getSize();
+ //
+ // if (contains(big, pt)) {
+ // return true;
+ // }
+ // if (contains(big, new Point2D.Double(pt.getX() + dim.getWidth(),
+ // pt.getY()))) {
+ // return true;
+ // }
+ // if (contains(big, new Point2D.Double(pt.getX() + dim.getWidth(),
+ // pt.getY() + dim.getHeight()))) {
+ // return true;
+ // }
+ // if (contains(big, new Point2D.Double(pt.getX(), pt.getY() +
+ // dim.getHeight()))) {
+ // return true;
+ // }
+ // return false;
+ }
+
+ //
+ // public boolean intersect(Positionable p) {
+ // return intersect(p.getPosition(), p.getSize());
+ // }
+
+ static public Positionable addMargin(final Positionable pos, final double widthMargin, final double heightMargin) {
+ return new Positionable() {
+
+ public Point2D getPosition() {
+ final Point2D p = pos.getPosition();
+ return new Point2D.Double(p.getX() - widthMargin, p.getY() - heightMargin);
+ }
+
+ public Dimension2D getSize() {
+ return Dimension2DDouble.delta(pos.getSize(), 2 * widthMargin, 2 * heightMargin);
+ }
+
+ public void moveSvek(double deltaX, double deltaY) {
+ pos.moveSvek(deltaX, deltaY);
+ }
+ };
+ }
+
+ static Rectangle2D move(Rectangle2D rect, double dx, double dy) {
+ return new Rectangle2D.Double(rect.getX() + dx, rect.getY() + dy, rect.getWidth(), rect.getHeight());
+ }
+
+ static public Point2D getCenter(Positionable p) {
+ final Point2D pt = p.getPosition();
+ final Dimension2D dim = p.getSize();
+ return new Point2D.Double(pt.getX() + dim.getWidth() / 2, pt.getY() + dim.getHeight() / 2);
+ }
+
+ static public Positionable move(Positionable p, double deltaX, double deltaY) {
+ final Point2D pt = p.getPosition();
+ final Dimension2D dim = p.getSize();
+ return new PositionableImpl(pt.getX() + deltaX, pt.getY() + deltaY, dim);
+
+ }
+
+ public static Positionable moveAwayFrom(Positionable fixe, Positionable toMove) {
+ final Point2D centerFixe = getCenter(fixe);
+ final Point2D centerToMove = getCenter(toMove);
+ // final Point2D pt = toMove.getPosition();
+ // return new PositionableImpl(pt.getX() + 20, pt.getY(),
+ // toMove.getSize());
+
+ final double deltaX = centerToMove.getX() - centerFixe.getX();
+ final double deltaY = centerToMove.getY() - centerFixe.getY();
+
+ double min = 0.0;
+ if (doesIntersectWithThisCoef(fixe, toMove, deltaX, deltaY, min) == false) {
+ throw new IllegalArgumentException();
+ }
+ double max = 0.1;
+ while (doesIntersectWithThisCoef(fixe, toMove, deltaX, deltaY, max)) {
+ max = max * 2;
+ }
+ for (int i = 0; i < 5; i++) {
+ assert doesIntersectWithThisCoef(fixe, toMove, deltaX, deltaY, min);
+ assert doesIntersectWithThisCoef(fixe, toMove, deltaX, deltaY, max) == false;
+ final double candidat = (min + max) / 2.0;
+ if (doesIntersectWithThisCoef(fixe, toMove, deltaX, deltaY, candidat)) {
+ min = candidat;
+ } else {
+ max = candidat;
+ }
+ // Log.println("min=" + min + " max=" + max);
+ }
+ final double candidat = (min + max) / 2.0;
+ return move(toMove, deltaX * candidat, deltaY * candidat);
+
+ }
+
+ private static boolean doesIntersectWithThisCoef(Positionable fixe, Positionable toMove, double deltaX,
+ double deltaY, double c) {
+ final Positionable result = move(toMove, deltaX * c, deltaY * c);
+ return intersect(fixe, result);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/posimo/Racorder.java b/src/net/sourceforge/plantuml/posimo/Racorder.java
new file mode 100644
index 0000000..3e50f58
--- /dev/null
+++ b/src/net/sourceforge/plantuml/posimo/Racorder.java
@@ -0,0 +1,43 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.posimo;
+
+import java.awt.geom.Line2D;
+import java.awt.geom.Rectangle2D;
+
+public interface Racorder {
+ public DotPath getRacordIn(Rectangle2D rect, Line2D tangeante);
+ public DotPath getRacordOut(Rectangle2D rect, Line2D tangeante);
+}
diff --git a/src/net/sourceforge/plantuml/posimo/RacorderAbstract.java b/src/net/sourceforge/plantuml/posimo/RacorderAbstract.java
new file mode 100644
index 0000000..9ebb9d4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/posimo/RacorderAbstract.java
@@ -0,0 +1,57 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.posimo;
+
+import java.awt.geom.Line2D;
+import java.awt.geom.Rectangle2D;
+
+public abstract class RacorderAbstract implements Racorder {
+
+ public final DotPath getRacordOut(Rectangle2D rect, Line2D tangeante) {
+ tangeante = symetric(tangeante);
+ return getRacordIn(rect, tangeante).reverse();
+ }
+
+ private static Line2D symetric(Line2D line) {
+ final double x1 = line.getX1();
+ final double y1 = line.getY1();
+ final double x2 = line.getX2();
+ final double y2 = line.getY2();
+ final double dx = x2 - x1;
+ final double dy = y2 - y1;
+ return new Line2D.Double(x1, y1, x1 - dx, y1 - dy);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/posimo/RacorderFollowTangeante.java b/src/net/sourceforge/plantuml/posimo/RacorderFollowTangeante.java
new file mode 100644
index 0000000..9ade66b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/posimo/RacorderFollowTangeante.java
@@ -0,0 +1,72 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.posimo;
+
+import java.awt.geom.CubicCurve2D;
+import java.awt.geom.Line2D;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+
+public class RacorderFollowTangeante extends RacorderAbstract implements Racorder {
+
+ public DotPath getRacordIn(Rectangle2D rect, Line2D tangeante) {
+
+// Log.println("rect x=" + rect.getX() + " y=" + rect.getY() + " w=" + rect.getWidth() + " h="
+// + rect.getHeight());
+// Log.println("tangeante (" + tangeante.getX1() + "," + tangeante.getY1() + ") (" + tangeante.getX2()
+// + "," + tangeante.getY2() + ")");
+
+ final DotPath result = new DotPath();
+
+ // final Point2D inter = BezierUtils.intersect((Line2D.Double)
+ // tangeante, rect);
+ Point2D inter = new LineRectIntersection(tangeante, rect).getIntersection();
+// Log.println("inter=" + inter);
+
+ if (inter == null) {
+ final Point2D p1 = new Point2D.Double(rect.getMinX(), rect.getMinY());
+ final Point2D p2 = new Point2D.Double(rect.getMaxX(), rect.getMinY());
+ final Point2D p3 = new Point2D.Double(rect.getMaxX(), rect.getMaxY());
+ final Point2D p4 = new Point2D.Double(rect.getMinX(), rect.getMaxY());
+
+ inter = LineRectIntersection.getCloser(tangeante.getP1(), p1, p2, p3, p4);
+ }
+
+ final CubicCurve2D.Double curv = new CubicCurve2D.Double(tangeante.getX1(), tangeante.getY1(),
+ tangeante.getX1(), tangeante.getY1(), inter.getX(), inter.getY(), inter.getX(), inter.getY());
+ return result.addAfter(curv);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/posimo/RacorderFollowTangeanteOld.java b/src/net/sourceforge/plantuml/posimo/RacorderFollowTangeanteOld.java
new file mode 100644
index 0000000..6f426ad
--- /dev/null
+++ b/src/net/sourceforge/plantuml/posimo/RacorderFollowTangeanteOld.java
@@ -0,0 +1,57 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.posimo;
+
+import java.awt.geom.CubicCurve2D;
+import java.awt.geom.Line2D;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+
+public class RacorderFollowTangeanteOld extends RacorderAbstract implements Racorder {
+
+ public DotPath getRacordIn(Rectangle2D rect, Line2D tangeante) {
+
+ final DotPath result = new DotPath();
+
+ final Point2D center = new Point2D.Double(rect.getCenterX(), rect.getCenterY());
+ final Line2D.Double line = new Line2D.Double(tangeante.getP1(), center);
+ final Point2D inter = BezierUtils.intersect(line, rect);
+
+ final CubicCurve2D.Double curv = new CubicCurve2D.Double(tangeante.getX1(), tangeante.getY1(), tangeante
+ .getX2(), tangeante.getY2(), tangeante.getX2(), tangeante.getY2(), inter.getX(), inter.getY());
+ return result.addAfter(curv);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/posimo/RacorderInToCenter.java b/src/net/sourceforge/plantuml/posimo/RacorderInToCenter.java
new file mode 100644
index 0000000..aef885f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/posimo/RacorderInToCenter.java
@@ -0,0 +1,56 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.posimo;
+
+import java.awt.geom.CubicCurve2D;
+import java.awt.geom.Line2D;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+
+public class RacorderInToCenter extends RacorderAbstract implements Racorder {
+
+ public DotPath getRacordIn(Rectangle2D rect, Line2D tangeante) {
+ final DotPath result = new DotPath();
+
+ final Point2D center = new Point2D.Double(rect.getCenterX(), rect.getCenterY());
+ final Line2D.Double line = new Line2D.Double(tangeante.getP1(), center);
+ final Point2D inter = BezierUtils.intersect(line, rect);
+
+ final CubicCurve2D.Double curv = new CubicCurve2D.Double(line.getX1(), line.getY1(), line.getX1(),
+ line.getY1(), inter.getX(), inter.getY(), inter.getX(), inter.getY());
+ return result.addAfter(curv);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/posimo/RacorderOrthogonal.java b/src/net/sourceforge/plantuml/posimo/RacorderOrthogonal.java
new file mode 100644
index 0000000..74eb8fb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/posimo/RacorderOrthogonal.java
@@ -0,0 +1,82 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.posimo;
+
+import java.awt.geom.CubicCurve2D;
+import java.awt.geom.Line2D;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+
+public class RacorderOrthogonal extends RacorderAbstract implements Racorder {
+
+ public DotPath getRacordIn(Rectangle2D rect, Line2D tangeante) {
+
+ final Point2D in = tangeante.getP1();
+
+ final DotPath result = new DotPath();
+ Point2D inter = null;
+
+ if (in.getX() > rect.getMinX() && in.getX() < rect.getMaxX()) {
+ if (in.getY() < rect.getMinY()) {
+ inter = new Point2D.Double(in.getX(), rect.getMinY());
+ } else if (in.getY() > rect.getMaxY()) {
+ inter = new Point2D.Double(in.getX(), rect.getMaxY());
+ } else {
+ throw new IllegalArgumentException();
+ }
+ } else if (in.getY() > rect.getMinY() && in.getY() < rect.getMaxY()) {
+ if (in.getX() < rect.getMinX()) {
+ inter = new Point2D.Double(rect.getMinX(), in.getY());
+ } else if (in.getX() > rect.getMaxX()) {
+ inter = new Point2D.Double(rect.getMaxX(), in.getY());
+ } else {
+ throw new IllegalArgumentException();
+ }
+ } else {
+ final Point2D p1 = new Point2D.Double(rect.getMinX(), rect.getMinY());
+ final Point2D p2 = new Point2D.Double(rect.getMaxX(), rect.getMinY());
+ final Point2D p3 = new Point2D.Double(rect.getMaxX(), rect.getMaxY());
+ final Point2D p4 = new Point2D.Double(rect.getMinX(), rect.getMaxY());
+
+ inter = LineRectIntersection.getCloser(tangeante.getP1(), p1, p2, p3, p4);
+
+ }
+
+ final CubicCurve2D.Double curv = new CubicCurve2D.Double(tangeante.getX1(), tangeante.getY1(),
+ tangeante.getX1(), tangeante.getY1(), inter.getX(), inter.getY(), inter.getX(), inter.getY());
+ return result.addAfter(curv);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/posimo/SimpleDrawer.java b/src/net/sourceforge/plantuml/posimo/SimpleDrawer.java
new file mode 100644
index 0000000..f5fb504
--- /dev/null
+++ b/src/net/sourceforge/plantuml/posimo/SimpleDrawer.java
@@ -0,0 +1,98 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.posimo;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+import java.util.ArrayList;
+import java.util.Collection;
+
+public class SimpleDrawer {
+
+ private final Cluster root;
+ private final Collection<Path> paths;
+
+ public SimpleDrawer(Cluster root, Collection<Path> paths) {
+ this.root = root;
+ this.paths = paths;
+ }
+
+ public void draw(Graphics2D g2d) {
+ g2d.setColor(Color.BLACK);
+ for (Clusterable cl : root.getContents()) {
+ final Block b = (Block) cl;
+ final Point2D pos = b.getPosition();
+ final Dimension2D dim = b.getSize();
+ // drawRectCentered(g2d, pos, dim);
+ drawRect(g2d, pos, dim);
+ }
+
+ g2d.setColor(Color.GREEN);
+ for (Path p : paths) {
+ final Label label = p.getLabel();
+ final Point2D labelPos = label.getPosition();
+ final Dimension2D labelDim = label.getSize();
+ // final double x1 = labelPos.getX();
+ // final double y1 = labelPos.getY();
+ // g2d.draw(new Ellipse2D.Double(x1 - 1, y1 - 1, 3, 3));
+ // drawRectCentered(g2d, labelPos, labelDim);
+ drawRect(g2d, labelPos, labelDim);
+ }
+
+ g2d.setColor(Color.RED);
+ for (Path p : paths) {
+ p.getDotPath().draw(g2d, 0, 0);
+ }
+
+ for (Cluster sub : root.getSubClusters()) {
+ new SimpleDrawer(sub, new ArrayList<Path>()).draw(g2d);
+ }
+
+ }
+
+ private void drawRectCentered(Graphics2D g2d, final Point2D pos, final Dimension2D dim) {
+ final Rectangle2D rect = new Rectangle2D.Double(pos.getX() - dim.getWidth() / 2, pos.getY() - dim.getHeight()
+ / 2, dim.getWidth(), dim.getHeight());
+ g2d.draw(rect);
+ }
+
+ private void drawRect(Graphics2D g2d, final Point2D pos, final Dimension2D dim) {
+ final Rectangle2D rect = new Rectangle2D.Double(pos.getX(), pos.getY(), dim.getWidth(), dim.getHeight());
+ g2d.draw(rect);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/posimo/TwoLinesIntersection.java b/src/net/sourceforge/plantuml/posimo/TwoLinesIntersection.java
new file mode 100644
index 0000000..15996e1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/posimo/TwoLinesIntersection.java
@@ -0,0 +1,72 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.posimo;
+
+import java.awt.geom.Line2D;
+import java.awt.geom.Point2D;
+
+public class TwoLinesIntersection {
+
+ private final Point2D inter;
+
+ public TwoLinesIntersection(Line2D lineA, Line2D lineB) {
+ final double x1 = lineA.getX1();
+ final double y1 = lineA.getY1();
+ final double x2 = lineA.getX2();
+ final double y2 = lineA.getY2();
+ final double x3 = lineB.getX1();
+ final double y3 = lineB.getY1();
+ final double x4 = lineB.getX2();
+ final double y4 = lineB.getY2();
+
+ final double den = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1);
+
+ final double uA1 = (x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3);
+ final double uA = uA1 / den;
+
+ // final double uB1 = (x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3);
+ // uB = uB1 / den;
+
+ final double x = x1 + uA * (x2 - x1);
+ final double y = y1 + uA * (y2 - y1);
+
+ inter = new Point2D.Double(x, y);
+ }
+
+ public final Point2D getIntersection() {
+ return inter;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/posimo/data.txt b/src/net/sourceforge/plantuml/posimo/data.txt
new file mode 100644
index 0000000..9d68054
--- /dev/null
+++ b/src/net/sourceforge/plantuml/posimo/data.txt
@@ -0,0 +1,38 @@
+@startuml
+interface Positionable {
+ + Dimension2D getSize();
+ + Point2D getPosition();
+}
+
+interface Clusterable {
+ +Cluster getParent();
+}
+
+Positionable <|-- Clusterable
+
+class Cluster
+
+Cluster *-- Cluster : subclusters
+Clusterable <|.. Cluster
+Cluster *-- Block
+Clusterable <|.. Block
+
+Path *-- "2" Cluster
+Path --> Label : has one
+Positionable <|-- Label
+
+SimpleDrawer --> Cluster
+SimpleDrawer *--> Path
+
+class GraphvizSolver {
+ + Dimension2D solve(Cluster root, Collection<Path> paths)
+}
+GraphvizSolver --> Cluster
+GraphvizSolver *--> Path
+
+
+'Clusterable --> Cluster : Parent
+
+
+
+@enduml
diff --git a/src/net/sourceforge/plantuml/postit/Area.java b/src/net/sourceforge/plantuml/postit/Area.java
new file mode 100644
index 0000000..a14a3ad
--- /dev/null
+++ b/src/net/sourceforge/plantuml/postit/Area.java
@@ -0,0 +1,111 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.postit;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class Area implements Elastic {
+
+ private final String title;
+ private final char id;
+
+ private Dimension2D minimunDimension;
+
+ private final List<PostIt> postIts = new ArrayList<PostIt>();
+
+ public Area(char id, String title) {
+ this.id = id;
+ this.title = title;
+ }
+
+ public char getId() {
+ return id;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public Dimension2D getMinimunDimension() {
+ return minimunDimension;
+ }
+
+ public void setMinimunDimension(Dimension2D minimunDimension) {
+ this.minimunDimension = minimunDimension;
+ }
+
+ public Dimension2D getDimension() {
+ throw new UnsupportedOperationException();
+ }
+
+ public double heightWhenWidthIs(double width, StringBounder stringBounder) {
+ final AreaLayoutFixedWidth layout = new AreaLayoutFixedWidth(width);
+ final Map<PostIt, Point2D> pos = layout.getPositions(postIts, stringBounder);
+ double max = 10;
+ for (Map.Entry<PostIt, Point2D> ent : pos.entrySet()) {
+ final double y = ent.getKey().getDimension(stringBounder).getHeight() + ent.getValue().getY();
+ max = Math.max(max, y);
+ }
+
+ return max + 10;
+ }
+
+ public double widthWhenHeightIs(double height, StringBounder stringBounder) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void add(PostIt postIt) {
+ postIts.add(postIt);
+ }
+
+ public void drawU(UGraphic ug, double width) {
+ final AreaLayout layout = new AreaLayoutFixedWidth(width);
+ final Map<PostIt, Point2D> pos = layout.getPositions(postIts, ug.getStringBounder());
+ for (Map.Entry<PostIt, Point2D> ent : pos.entrySet()) {
+ final UGraphic ugTranslated = ug.apply(new UTranslate(ent.getValue().getX(), ent.getValue().getY()));
+ ent.getKey().drawU(ugTranslated);
+ }
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/postit/AreaLayout.java b/src/net/sourceforge/plantuml/postit/AreaLayout.java
new file mode 100644
index 0000000..21e34ad
--- /dev/null
+++ b/src/net/sourceforge/plantuml/postit/AreaLayout.java
@@ -0,0 +1,47 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.postit;
+
+import java.awt.geom.Point2D;
+import java.util.Collection;
+import java.util.Map;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+
+public interface AreaLayout {
+
+ Map<PostIt, Point2D> getPositions(Collection<PostIt> all, StringBounder stringBounder);
+
+}
diff --git a/src/net/sourceforge/plantuml/postit/AreaLayoutFixedWidth.java b/src/net/sourceforge/plantuml/postit/AreaLayoutFixedWidth.java
new file mode 100644
index 0000000..0443817
--- /dev/null
+++ b/src/net/sourceforge/plantuml/postit/AreaLayoutFixedWidth.java
@@ -0,0 +1,74 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.postit;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+
+public class AreaLayoutFixedWidth implements AreaLayout {
+
+ private final double width;
+
+ public AreaLayoutFixedWidth(double width) {
+ this.width = width;
+ }
+
+ public Map<PostIt, Point2D> getPositions(Collection<PostIt> all, StringBounder stringBounder) {
+ double x = 0;
+ double y = 0;
+ double maxY = 0;
+ final Map<PostIt, Point2D> result = new LinkedHashMap<PostIt, Point2D>();
+
+ for (PostIt p : all) {
+ final Dimension2D dim = p.getDimension(stringBounder);
+ if (x + dim.getWidth() > width) {
+ x = 0;
+ y = maxY;
+ }
+ result.put(p, new Point2D.Double(x, y));
+ x += dim.getWidth();
+ maxY = Math.max(maxY, y + dim.getHeight());
+ }
+
+ return Collections.unmodifiableMap(result);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/postit/CommandCreatePostIt.java b/src/net/sourceforge/plantuml/postit/CommandCreatePostIt.java
new file mode 100644
index 0000000..777559a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/postit/CommandCreatePostIt.java
@@ -0,0 +1,66 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.postit;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Display;
+
+public class CommandCreatePostIt extends SingleLineCommand2<PostItDiagram> {
+
+ public CommandCreatePostIt() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("post[-[%s]]?it[%s]+"), //
+ new RegexLeaf("ID", "([-\\p{L}0-9_./]+)"), //
+ new RegexLeaf("[%s]+"), //
+ new RegexLeaf("TEXT", ":?(.*)?$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(PostItDiagram diagram, RegexResult arg) {
+ final String id = arg.get("ID", 0);
+ final String text = arg.get("TEXT", 0);
+ diagram.createPostIt(id, Display.getWithNewlines(text));
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/postit/CommandWidth.java b/src/net/sourceforge/plantuml/postit/CommandWidth.java
new file mode 100644
index 0000000..ea6d6ac
--- /dev/null
+++ b/src/net/sourceforge/plantuml/postit/CommandWidth.java
@@ -0,0 +1,56 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.postit;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+
+public class CommandWidth extends SingleLineCommand<PostItDiagram> {
+
+ public CommandWidth() {
+ super("(?i)^width[%s]+(\\d+)$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(PostItDiagram system, List<String> arg) {
+
+ final int width = Integer.parseInt(arg.get(0));
+ system.setWidth(width);
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/postit/Elastic.java b/src/net/sourceforge/plantuml/postit/Elastic.java
new file mode 100644
index 0000000..9c77412
--- /dev/null
+++ b/src/net/sourceforge/plantuml/postit/Elastic.java
@@ -0,0 +1,45 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.postit;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+
+public interface Elastic {
+
+ double widthWhenHeightIs(double height, StringBounder stringBounder);
+
+ double heightWhenWidthIs(double width, StringBounder stringBounder);
+
+}
diff --git a/src/net/sourceforge/plantuml/postit/PostIdDiagramFactory.java b/src/net/sourceforge/plantuml/postit/PostIdDiagramFactory.java
new file mode 100644
index 0000000..ef742b5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/postit/PostIdDiagramFactory.java
@@ -0,0 +1,59 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.postit;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.command.Command;
+import net.sourceforge.plantuml.command.UmlDiagramFactory;
+
+public class PostIdDiagramFactory extends UmlDiagramFactory {
+
+ @Override
+ protected List<Command> createCommands() {
+ final List<Command> cmds = new ArrayList<Command>();
+ addCommonCommands(cmds);
+ cmds.add(new CommandCreatePostIt());
+ cmds.add(new CommandWidth());
+ return cmds;
+ }
+
+ @Override
+ public PostItDiagram createEmptyDiagram() {
+ return new PostItDiagram();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/postit/PostIt.java b/src/net/sourceforge/plantuml/postit/PostIt.java
new file mode 100644
index 0000000..33103fa
--- /dev/null
+++ b/src/net/sourceforge/plantuml/postit/PostIt.java
@@ -0,0 +1,120 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.postit;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.SkinParam;
+import net.sourceforge.plantuml.SpriteContainerEmpty;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorSetSimple;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.SymbolContext;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.SimpleContext2D;
+import net.sourceforge.plantuml.skin.rose.ComponentRoseNote;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+
+public class PostIt {
+
+ private final String id;
+ private final Display text;
+
+ private Dimension2D minimunDimension;
+
+ public PostIt(String id, Display text) {
+ this.id = id;
+ this.text = text;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public Display getText() {
+ return text;
+ }
+
+ public Dimension2D getMinimunDimension() {
+ return minimunDimension;
+ }
+
+ public void setMinimunDimension(Dimension2D minimunDimension) {
+ this.minimunDimension = minimunDimension;
+ }
+
+ public Dimension2D getDimension(StringBounder stringBounder) {
+ double width = getComponent().getPreferredWidth(stringBounder);
+ double height = getComponent().getPreferredHeight(stringBounder);
+
+ if (minimunDimension != null && width < minimunDimension.getWidth()) {
+ width = minimunDimension.getWidth();
+ }
+ if (minimunDimension != null && height < minimunDimension.getHeight()) {
+ height = minimunDimension.getHeight();
+ }
+
+ return new Dimension2DDouble(width, height);
+ }
+
+ public void drawU(UGraphic ug) {
+
+ final Component note = getComponent();
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D dimensionToUse = getDimension(stringBounder);
+
+ note.drawU(ug, new Area(dimensionToUse), new SimpleContext2D(false));
+
+ }
+
+ private Component getComponent() {
+ final HtmlColor noteBackgroundColor = new HtmlColorSetSimple().getColorIfValid("#FBFB77");
+ final HtmlColor borderColor = HtmlColorUtils.MY_RED;
+
+ final SkinParam param = SkinParam.noShadowing();
+ final UFont fontNote = param.getFont(FontParam.NOTE, null, false);
+ final ComponentRoseNote note = new ComponentRoseNote(
+ new SymbolContext(noteBackgroundColor, borderColor).withStroke(new UStroke()), fontNote.toFont2(
+ HtmlColorUtils.BLACK, true, HtmlColorUtils.BLUE), text, 0, 0, new SpriteContainerEmpty());
+ return note;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/postit/PostItDiagram.java b/src/net/sourceforge/plantuml/postit/PostItDiagram.java
new file mode 100644
index 0000000..e383b1e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/postit/PostItDiagram.java
@@ -0,0 +1,140 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.postit;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+import net.sourceforge.plantuml.EmptyImageBuilder;
+import net.sourceforge.plantuml.FileFormat;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.UmlDiagram;
+import net.sourceforge.plantuml.UmlDiagramType;
+import net.sourceforge.plantuml.api.ImageDataSimple;
+import net.sourceforge.plantuml.core.DiagramDescription;
+import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.png.PngIO;
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.eps.UGraphicEps;
+import net.sourceforge.plantuml.ugraphic.g2d.UGraphicG2d;
+import net.sourceforge.plantuml.ugraphic.svg.UGraphicSvg;
+
+public class PostItDiagram extends UmlDiagram {
+
+ private final Area defaultArea = new Area('\0', null);
+
+ private final Map<String, PostIt> postIts = new HashMap<String, PostIt>();
+
+ @Override
+ public UmlDiagramType getUmlDiagramType() {
+ return null;
+ }
+
+ @Override
+ final protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption) throws IOException {
+ final UGraphic ug = createImage(fileFormatOption);
+ drawU(ug);
+ if (ug instanceof UGraphicG2d) {
+ final BufferedImage im = ((UGraphicG2d) ug).getBufferedImage();
+ PngIO.write(im, os, fileFormatOption.isWithMetadata() ? getMetadata() : null, this.getDpi(fileFormatOption));
+ } else if (ug instanceof UGraphicSvg) {
+ final UGraphicSvg svg = (UGraphicSvg) ug;
+ svg.createXml(os);
+ } else if (ug instanceof UGraphicEps) {
+ final UGraphicEps eps = (UGraphicEps) ug;
+ os.write(eps.getEPSCode().getBytes());
+ }
+ return new ImageDataSimple();
+ }
+
+ public DiagramDescription getDescription() {
+ return new DiagramDescriptionImpl("Board of post-it", getClass());
+ }
+
+ public Area getDefaultArea() {
+ return defaultArea;
+ }
+
+ public Area createArea(char id) {
+ throw new UnsupportedOperationException();
+ }
+
+ public PostIt createPostIt(String id, Display text) {
+ if (postIts.containsKey(id)) {
+ throw new IllegalArgumentException();
+ }
+ final PostIt postIt = new PostIt(id, text);
+ postIts.put(id, postIt);
+ getDefaultArea().add(postIt);
+ return postIt;
+ }
+
+ void drawU(UGraphic ug) {
+ getDefaultArea().drawU(ug, width);
+ }
+
+ private UGraphic createImage(FileFormatOption fileFormatOption) {
+ final Color backColor = getSkinParam().getColorMapper()
+ .getMappedColor(this.getSkinParam().getBackgroundColor());
+ final FileFormat fileFormat = fileFormatOption.getFileFormat();
+ if (fileFormat == FileFormat.PNG) {
+ final double height = getDefaultArea().heightWhenWidthIs(width, TextBlockUtils.getDummyStringBounder());
+ final EmptyImageBuilder builder = new EmptyImageBuilder(width, height, backColor);
+
+ final Graphics2D graphics2D = builder.getGraphics2D();
+ final double dpiFactor = this.getDpiFactor(fileFormatOption);
+ final UGraphicG2d result = new UGraphicG2d(new ColorMapperIdentity(), graphics2D, dpiFactor);
+ result.setBufferedImage(builder.getBufferedImage());
+ return result;
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ private int width = 800;
+
+ public void setWidth(int width) {
+ this.width = width;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/preproc/Defines.java b/src/net/sourceforge/plantuml/preproc/Defines.java
new file mode 100644
index 0000000..1e1e7f7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/preproc/Defines.java
@@ -0,0 +1,134 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.preproc;
+
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+import java.util.regex.Matcher;
+
+public class Defines {
+
+ private final Map<String, String> values = new LinkedHashMap<String, String>();
+ private final Map<String, String> savedState = new LinkedHashMap<String, String>();
+
+ public void define(String name, List<String> value) {
+ values.put(name, addLineReturn(value));
+ }
+
+ private String addLineReturn(List<String> value) {
+ if (value == null) {
+ return null;
+ }
+ final StringBuilder sb = new StringBuilder();
+ for (final Iterator<String> it = value.iterator(); it.hasNext();) {
+ sb.append(it.next());
+ if (it.hasNext()) {
+ sb.append('\n');
+ }
+ }
+ return sb.toString();
+ }
+
+ public boolean isDefine(String name) {
+ for (String key : values.keySet()) {
+ if (key.equals(name) || key.startsWith(name + "(")) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void undefine(String name) {
+ values.remove(name);
+ }
+
+ public List<String> applyDefines(String line) {
+ for (Map.Entry<String, String> ent : values.entrySet()) {
+ final String key = ent.getKey();
+ if (ent.getValue() == null) {
+ continue;
+ }
+ final String value = Matcher.quoteReplacement(ent.getValue());
+ if (key.contains("(")) {
+ final StringTokenizer st = new StringTokenizer(key, "(),");
+ final String fctName = st.nextToken();
+ String newValue = value;
+ final StringBuilder regex = new StringBuilder("\\b" + fctName + "\\(");
+ int i = 1;
+
+ while (st.hasMoreTokens()) {
+ if (st.hasMoreTokens()) {
+ regex.append("([^,]*?)");
+ } else {
+ regex.append("([^)]*?)");
+ }
+ final String var1 = st.nextToken();
+ final String var2 = "(##" + var1 + "\\b)|(\\b" + var1 + "##)|(\\b" + var1 + "\\b)";
+ newValue = newValue.replaceAll(var2, "\\$" + i);
+ i++;
+ if (st.hasMoreTokens()) {
+ regex.append(",");
+ }
+ }
+
+ regex.append("\\)");
+ line = line.replaceAll(regex.toString(), newValue);
+ } else {
+ final String regex = "\\b" + key + "\\b";
+ line = line.replaceAll(regex, value);
+ }
+ }
+ return Arrays.asList(line.split("\n"));
+ }
+
+ public void saveState() {
+ if (savedState.size() > 0) {
+ throw new IllegalStateException();
+ }
+ this.savedState.putAll(values);
+
+ }
+
+ public void restoreState() {
+ this.values.clear();
+ this.values.putAll(savedState);
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/preproc/IfManager.java b/src/net/sourceforge/plantuml/preproc/IfManager.java
new file mode 100644
index 0000000..d940d9d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/preproc/IfManager.java
@@ -0,0 +1,104 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.preproc;
+
+import java.io.IOException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+
+class IfManager implements ReadLine {
+
+ protected static final Pattern ifdefPattern = MyPattern.cmpile("^[%s]*!if(n)?def[%s]+([A-Za-z_][A-Za-z_0-9]*)$");
+ protected static final Pattern elsePattern = MyPattern.cmpile("^[%s]*!else$");
+ protected static final Pattern endifPattern = MyPattern.cmpile("^[%s]*!endif$");
+
+ private final Defines defines;
+ private final ReadLine source;
+
+ private IfManager child;
+
+ public IfManager(ReadLine source, Defines defines) {
+ this.defines = defines;
+ this.source = source;
+ }
+
+ final public String readLine() throws IOException {
+ if (child != null) {
+ final String s = child.readLine();
+ if (s != null) {
+ return s;
+ }
+ child = null;
+ }
+
+ return readLineInternal();
+ }
+
+ protected String readLineInternal() throws IOException {
+ final String s = source.readLine();
+ if (s == null) {
+ return null;
+ }
+
+ final Matcher m = ifdefPattern.matcher(s);
+ if (m.find()) {
+ boolean ok = defines.isDefine(m.group(2));
+ if (m.group(1) != null) {
+ ok = !ok;
+ }
+ if (ok) {
+ child = new IfManagerPositif(source, defines);
+ } else {
+ child = new IfManagerNegatif(source, defines);
+ }
+ // child = new IfManager(source, defines, ok ? IfPart.IF :
+ // IfPart.SKIP);
+ return this.readLine();
+ }
+
+ // m = endifPattern.matcher(s);
+ // if (m.find()) {
+ // return null;
+ // }
+ return s;
+ }
+
+ public void close() throws IOException {
+ source.close();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/preproc/IfManagerNegatif.java b/src/net/sourceforge/plantuml/preproc/IfManagerNegatif.java
new file mode 100644
index 0000000..d104ba7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/preproc/IfManagerNegatif.java
@@ -0,0 +1,80 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.preproc;
+
+import java.io.IOException;
+import java.util.regex.Matcher;
+
+class IfManagerNegatif extends IfManager {
+
+ private boolean skippingDone = false;
+
+ public IfManagerNegatif(ReadLine source, Defines defines) {
+ super(source, defines);
+ }
+
+ @Override
+ protected String readLineInternal() throws IOException {
+ if (skippingDone == false) {
+ skippingDone = true;
+ do {
+ final String s = readLine();
+ if (s == null) {
+ return null;
+ }
+ Matcher m = endifPattern.matcher(s);
+ if (m.find()) {
+ return null;
+ }
+ m = elsePattern.matcher(s);
+ if (m.find()) {
+ break;
+ }
+ } while (true);
+ }
+
+ final String s = super.readLineInternal();
+ if (s == null) {
+ return null;
+ }
+ final Matcher m = endifPattern.matcher(s);
+ if (m.find()) {
+ return null;
+ }
+ return s;
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/preproc/IfManagerPositif.java b/src/net/sourceforge/plantuml/preproc/IfManagerPositif.java
new file mode 100644
index 0000000..c9dfef9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/preproc/IfManagerPositif.java
@@ -0,0 +1,72 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.preproc;
+
+import java.io.IOException;
+import java.util.regex.Matcher;
+
+class IfManagerPositif extends IfManager {
+
+ public IfManagerPositif(ReadLine source, Defines defines) {
+ super(source, defines);
+ }
+
+ @Override
+ protected String readLineInternal() throws IOException {
+ String s = super.readLineInternal();
+ if (s == null) {
+ return null;
+ }
+ Matcher m = endifPattern.matcher(s);
+ if (m.find()) {
+ return null;
+ }
+ m = elsePattern.matcher(s);
+ if (m.find()) {
+ do {
+ s = readLine();
+ if (s == null) {
+ return null;
+ }
+ m = endifPattern.matcher(s);
+ if (m.find()) {
+ return null;
+ }
+ } while (true);
+ }
+ return s;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/preproc/Preprocessor.java b/src/net/sourceforge/plantuml/preproc/Preprocessor.java
new file mode 100644
index 0000000..5cc73df
--- /dev/null
+++ b/src/net/sourceforge/plantuml/preproc/Preprocessor.java
@@ -0,0 +1,161 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.preproc;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.utils.StartUtils;
+import net.sourceforge.plantuml.StringUtils;
+
+public class Preprocessor implements ReadLine {
+
+ private static final String ID = "[A-Za-z_][A-Za-z_0-9]*";
+ private static final String ARG = "(?:\\(" + ID + "(?:," + ID + ")*?\\))?";
+ private static final Pattern definePattern = MyPattern.cmpile("^[%s]*!define[%s]+(" + ID + ARG + ")"
+ + "(?:[%s]+(.*))?$");
+ private static final Pattern undefPattern = MyPattern.cmpile("^[%s]*!undef[%s]+(" + ID + ")$");
+ private static final Pattern definelongPattern = MyPattern.cmpile("^[%s]*!definelong[%s]+(" + ID + ARG + ")");
+ private static final Pattern enddefinelongPattern = MyPattern.cmpile("^[%s]*!enddefinelong[%s]*$");
+
+ private final Defines defines;
+ private final PreprocessorInclude rawSource;
+ private final ReadLineInsertable source;
+
+ public Preprocessor(ReadLine reader, String charset, Defines defines, Set<File> filesUsed, File newCurrentDir) {
+ this.defines = defines;
+ this.defines.saveState();
+ this.rawSource = new PreprocessorInclude(reader, defines, charset, filesUsed, newCurrentDir);
+ this.source = new ReadLineInsertable(new IfManager(rawSource, defines));
+ }
+
+ public String readLine() throws IOException {
+ final String s = source.readLine();
+ if (s == null) {
+ return null;
+ }
+ if (StartUtils.isArobaseStartDiagram(s)) {
+ this.defines.restoreState();
+ }
+
+ Matcher m = definePattern.matcher(s);
+ if (m.find()) {
+ return manageDefine(m);
+ }
+
+ m = definelongPattern.matcher(s);
+ if (m.find()) {
+ return manageDefineLong(m);
+ }
+
+ m = undefPattern.matcher(s);
+ if (m.find()) {
+ return manageUndef(m);
+ }
+
+ if (ignoreDefineDuringSeveralLines > 0) {
+ ignoreDefineDuringSeveralLines--;
+ return s;
+ }
+
+ final List<String> result = defines.applyDefines(s);
+ if (result.size() > 1) {
+ ignoreDefineDuringSeveralLines = result.size() - 2;
+ source.insert(result.subList(1, result.size() - 1));
+ }
+ return result.get(0);
+ }
+
+ private int ignoreDefineDuringSeveralLines = 0;
+
+ private String manageUndef(Matcher m) throws IOException {
+ defines.undefine(m.group(1));
+ return this.readLine();
+ }
+
+ private String manageDefineLong(Matcher m) throws IOException {
+ final String group1 = m.group(1);
+ final List<String> def = new ArrayList<String>();
+ while (true) {
+ final String read = this.readLine();
+ if (read == null) {
+ return null;
+ }
+ def.add(read);
+ if (enddefinelongPattern.matcher(read).find()) {
+ defines.define(group1, def);
+ return this.readLine();
+ }
+ }
+ }
+
+ private String manageDefine(Matcher m) throws IOException {
+ final String group1 = m.group(1);
+ final String group2 = m.group(2);
+ if (group2 == null) {
+ defines.define(group1, null);
+ } else {
+ final List<String> strings = defines.applyDefines(group2);
+ if (strings.size() > 1) {
+ throw new UnsupportedOperationException();
+ }
+ final StringBuilder value = new StringBuilder(strings.get(0));
+ while (StringUtils.endsWithBackslash(value.toString())) {
+ value.setLength(value.length() - 1);
+ final String read = this.readLine();
+ value.append(read);
+ }
+ final List<String> li = new ArrayList<String>();
+ li.add(value.toString());
+ defines.define(group1, li);
+ }
+ return this.readLine();
+ }
+
+ public int getLineNumber() {
+ return rawSource.getLineNumber();
+ }
+
+ public void close() throws IOException {
+ rawSource.close();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/preproc/PreprocessorInclude.java b/src/net/sourceforge/plantuml/preproc/PreprocessorInclude.java
new file mode 100644
index 0000000..0fbae08
--- /dev/null
+++ b/src/net/sourceforge/plantuml/preproc/PreprocessorInclude.java
@@ -0,0 +1,240 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.preproc;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.FileSystem;
+import net.sourceforge.plantuml.Log;
+import net.sourceforge.plantuml.OptionFlags;
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.utils.StartUtils;
+
+class PreprocessorInclude implements ReadLine {
+
+ private static final Pattern includePattern = MyPattern.cmpile("^[%s]*!include[%s]+[%g]?([^%g]+)[%g]?$");
+ private static final Pattern includeURLPattern = MyPattern.cmpile("^[%s]*!includeurl[%s]+[%g]?([^%g]+)[%g]?$");
+
+ private final ReadLine reader2;
+ private final String charset;
+ private final Defines defines;
+
+ private int numLine = 0;
+
+ private PreprocessorInclude included = null;
+
+ private final File oldCurrentDir;
+ private final Set<File> filesUsed;
+
+ public PreprocessorInclude(ReadLine reader, Defines defines, String charset, Set<File> filesUsed, File newCurrentDir) {
+ this.defines = defines;
+ this.charset = charset;
+ this.reader2 = reader;
+ this.filesUsed = filesUsed;
+ if (newCurrentDir == null) {
+ oldCurrentDir = null;
+ } else {
+ oldCurrentDir = FileSystem.getInstance().getCurrentDir();
+ FileSystem.getInstance().setCurrentDir(newCurrentDir);
+ }
+ }
+
+ private void restoreCurrentDir() {
+ if (oldCurrentDir != null) {
+ FileSystem.getInstance().setCurrentDir(oldCurrentDir);
+ }
+ }
+
+ public String readLine() throws IOException {
+ final String result = readLineInternal();
+ if (result != null && (StartUtils.isArobaseEndDiagram(result) || StartUtils.isArobaseStartDiagram(result))) {
+ // http://plantuml.sourceforge.net/qa/?qa=3389/error-generating-when-same-file-included-different-diagram
+ filesUsed.clear();
+ }
+ return result;
+ }
+
+ private String readLineInternal() throws IOException {
+ if (included != null) {
+ final String s = included.readLine();
+ if (s != null) {
+ return s;
+ }
+ included.close();
+ included = null;
+ }
+
+ final String s = reader2.readLine();
+ numLine++;
+ if (s == null) {
+ return null;
+ }
+ if (OptionFlags.ALLOW_INCLUDE) {
+ final Matcher m = includePattern.matcher(s);
+ assert included == null;
+ if (m.find()) {
+ return manageFileInclude(m);
+ }
+ }
+ final Matcher mUrl = includeURLPattern.matcher(s);
+ if (mUrl.find()) {
+ return manageUrlInclude(mUrl);
+ }
+ return s;
+ }
+
+ private String manageUrlInclude(Matcher m) throws IOException {
+ String urlString = m.group(1);
+ urlString = defines.applyDefines(urlString).get(0);
+ //
+ final int idx = urlString.lastIndexOf('!');
+ String suf = null;
+ if (idx != -1) {
+ suf = urlString.substring(idx + 1);
+ urlString = urlString.substring(0, idx);
+ }
+ try {
+ final URL url = new URL(urlString);
+ included = new PreprocessorInclude(getReaderInclude(url, suf), defines, charset, filesUsed, null);
+ } catch (MalformedURLException e) {
+ return "Cannot include url " + urlString;
+ }
+ return this.readLine();
+ }
+
+ private String manageFileInclude(Matcher m) throws IOException {
+ String fileName = m.group(1);
+ fileName = defines.applyDefines(fileName).get(0);
+ final int idx = fileName.lastIndexOf('!');
+ String suf = null;
+ if (idx != -1) {
+ suf = fileName.substring(idx + 1);
+ fileName = fileName.substring(0, idx);
+ }
+ final File f = FileSystem.getInstance().getFile(withEnvironmentVariable(fileName));
+ if (f.exists() == false) {
+ return "Cannot include " + f.getAbsolutePath();
+ } else if (filesUsed.contains(f)) {
+ return "File already included " + f.getAbsolutePath();
+ } else {
+ filesUsed.add(f);
+ included = new PreprocessorInclude(getReaderInclude(f, suf), defines, charset, filesUsed, f.getParentFile());
+ }
+ return this.readLine();
+ }
+
+ static String withEnvironmentVariable(String s) {
+ final Pattern p = Pattern.compile("%(\\w+)%");
+
+ final Matcher m = p.matcher(s);
+ final StringBuffer sb = new StringBuffer();
+ while (m.find()) {
+ final String var = m.group(1);
+ final String value = getenv(var);
+ if (value != null) {
+ m.appendReplacement(sb, Matcher.quoteReplacement(value));
+ }
+ }
+ m.appendTail(sb);
+ s = sb.toString();
+ return s;
+ }
+
+ private static String getenv(String var) {
+ final String env = System.getProperty(var);
+ if (StringUtils.isNotEmpty(env)) {
+ return StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(env);
+ }
+ final String getenv = System.getenv(var);
+ if (StringUtils.isNotEmpty(getenv)) {
+ return StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(getenv);
+ }
+ return null;
+ }
+
+ private ReadLine getReaderInclude(final File f, String suf) throws IOException {
+ if (StartDiagramExtractReader.containsStartDiagram(f, charset)) {
+ int bloc = 0;
+ if (suf != null && suf.matches("\\d+")) {
+ bloc = Integer.parseInt(suf);
+ }
+ return new StartDiagramExtractReader(f, bloc, charset);
+ }
+ if (charset == null) {
+ Log.info("Using default charset");
+ return new ReadLineReader(new FileReader(f));
+ }
+ Log.info("Using charset " + charset);
+ return new ReadLineReader(new InputStreamReader(new FileInputStream(f), charset));
+ }
+
+ private ReadLine getReaderInclude(final URL url, String suf) throws IOException {
+ if (StartDiagramExtractReader.containsStartDiagram(url, charset)) {
+ int bloc = 0;
+ if (suf != null && suf.matches("\\d+")) {
+ bloc = Integer.parseInt(suf);
+ }
+ return new StartDiagramExtractReader(url, bloc, charset);
+ }
+ final InputStream is = url.openStream();
+ if (charset == null) {
+ Log.info("Using default charset");
+ return new ReadLineReader(new InputStreamReader(is));
+ }
+ Log.info("Using charset " + charset);
+ return new ReadLineReader(new InputStreamReader(is, charset));
+ }
+
+ public int getLineNumber() {
+ return numLine;
+ }
+
+ public void close() throws IOException {
+ restoreCurrentDir();
+ reader2.close();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/preproc/ReadLine.java b/src/net/sourceforge/plantuml/preproc/ReadLine.java
new file mode 100644
index 0000000..163468b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/preproc/ReadLine.java
@@ -0,0 +1,43 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.preproc;
+
+import java.io.Closeable;
+import java.io.IOException;
+
+public interface ReadLine extends Closeable {
+
+ public String readLine() throws IOException;
+}
diff --git a/src/net/sourceforge/plantuml/preproc/ReadLineInsertable.java b/src/net/sourceforge/plantuml/preproc/ReadLineInsertable.java
new file mode 100644
index 0000000..764a4c5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/preproc/ReadLineInsertable.java
@@ -0,0 +1,69 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.preproc;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+class ReadLineInsertable implements ReadLine {
+
+ private final ReadLine source;
+ private final List<String> inserted = new LinkedList<String>();
+
+ public ReadLineInsertable(ReadLine source) {
+ this.source = source;
+ }
+
+ public void close() throws IOException {
+ source.close();
+ }
+
+ public String readLine() throws IOException {
+ if (inserted.size() > 0) {
+ final Iterator<String> it = inserted.iterator();
+ final String result = it.next();
+ it.remove();
+ return result;
+ }
+ return source.readLine();
+ }
+
+ public void insert(List<String> data) {
+ inserted.addAll(data);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/preproc/ReadLineReader.java b/src/net/sourceforge/plantuml/preproc/ReadLineReader.java
new file mode 100644
index 0000000..7316fc6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/preproc/ReadLineReader.java
@@ -0,0 +1,75 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.preproc;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.Reader;
+
+public class ReadLineReader implements ReadLine {
+
+ private final BufferedReader br;
+
+ public ReadLineReader(Reader reader) {
+ br = new BufferedReader(reader);
+ }
+
+ public String readLine() throws IOException {
+ String s = br.readLine();
+ if (s != null && s.startsWith("\uFEFF")) {
+ s = s.substring(1);
+ }
+ if (s != null) {
+ s = s.replace('\u2013', '-');
+ // s = s.replace('\u00A0', ' ');
+ // s = s.replace('\u201c', '\"');
+ // s = s.replace('\u201d', '\"');
+ // s = s.replace('\u00ab', '\"');
+ // s = s.replace('\u00bb', '\"');
+ // s = s.replace('\u2018', '\'');
+ // s = s.replace('\u2019', '\'');
+ // for (int i = 0; i < s.length(); i++) {
+ // char c = s.charAt(i);
+ // System.err.println("X " + Integer.toHexString((int) c) + " " + c);
+ // }
+ }
+ return s;
+ }
+
+ public void close() throws IOException {
+ br.close();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/preproc/StackReadLine.java b/src/net/sourceforge/plantuml/preproc/StackReadLine.java
new file mode 100644
index 0000000..128ab9b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/preproc/StackReadLine.java
@@ -0,0 +1,58 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.preproc;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+public class StackReadLine implements ReadLine {
+
+ final private Iterator<String> it;
+
+ public StackReadLine(Collection<String> all) {
+ this.it = all.iterator();
+ }
+
+ public void close() {
+ }
+
+ public String readLine() {
+ if (it.hasNext()) {
+ return it.next();
+ }
+ return null;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/preproc/StartDiagramExtractReader.java b/src/net/sourceforge/plantuml/preproc/StartDiagramExtractReader.java
new file mode 100644
index 0000000..15bc52d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/preproc/StartDiagramExtractReader.java
@@ -0,0 +1,139 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.preproc;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URL;
+
+import net.sourceforge.plantuml.Log;
+import net.sourceforge.plantuml.utils.StartUtils;
+
+public class StartDiagramExtractReader implements ReadLine {
+
+ private final ReadLine raw;
+ private boolean finished = false;
+
+ public StartDiagramExtractReader(File f, int num, String charset) throws IOException {
+ this(getReadLine(f, charset), num, charset);
+ }
+
+ public StartDiagramExtractReader(URL url, int num, String charset) throws IOException {
+ this(getReadLine(url, charset), num, charset);
+ }
+
+ private StartDiagramExtractReader(ReadLine raw, int num, String charset) throws IOException {
+ if (num < 0) {
+ throw new IllegalArgumentException();
+ }
+ this.raw = raw;
+ String s = null;
+ while ((s = raw.readLine()) != null) {
+ if (StartUtils.isArobaseStartDiagram(s)) {
+ if (num == 0) {
+ return;
+ }
+ num--;
+ }
+ }
+ finished = true;
+ }
+
+ private static ReadLine getReadLine(File f, String charset) throws IOException {
+
+ if (charset == null) {
+ Log.info("Using default charset");
+ return new UncommentReadLine(new ReadLineReader(new FileReader(f)));
+ }
+ Log.info("Using charset " + charset);
+ return new UncommentReadLine(new ReadLineReader(new InputStreamReader(new FileInputStream(f), charset)));
+ }
+
+ private static ReadLine getReadLine(URL url, String charset) throws IOException {
+
+ if (charset == null) {
+ Log.info("Using default charset");
+ return new UncommentReadLine(new ReadLineReader(new InputStreamReader(url.openStream())));
+ }
+ Log.info("Using charset " + charset);
+ return new UncommentReadLine(new ReadLineReader(new InputStreamReader(url.openStream(), charset)));
+ }
+
+ static public boolean containsStartDiagram(File f, String charset) throws IOException {
+ final ReadLine r = getReadLine(f, charset);
+ return containsStartDiagram(r);
+ }
+
+ static public boolean containsStartDiagram(URL url, String charset) throws IOException {
+ final ReadLine r = getReadLine(url, charset);
+ return containsStartDiagram(r);
+ }
+
+ private static boolean containsStartDiagram(final ReadLine r) throws IOException {
+ try {
+ String s = null;
+ while ((s = r.readLine()) != null) {
+ if (StartUtils.isArobaseStartDiagram(s)) {
+ return true;
+ }
+ }
+ } finally {
+ if (r != null) {
+ r.close();
+ }
+ }
+ return false;
+ }
+
+ public String readLine() throws IOException {
+ if (finished) {
+ return null;
+ }
+ final String result = raw.readLine();
+ if (result != null && StartUtils.isArobaseEndDiagram(result)) {
+ finished = true;
+ return null;
+ }
+ return result;
+ }
+
+ public void close() throws IOException {
+ raw.close();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/preproc/UncommentReadLine.java b/src/net/sourceforge/plantuml/preproc/UncommentReadLine.java
new file mode 100644
index 0000000..2647ecb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/preproc/UncommentReadLine.java
@@ -0,0 +1,91 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.preproc;
+
+import java.io.IOException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+
+public class UncommentReadLine implements ReadLine {
+
+ private final ReadLine raw;
+ private final Pattern start;
+ private final Pattern unpause;
+ private String headerToRemove;
+ private boolean paused;
+
+ public UncommentReadLine(ReadLine source) {
+ this.raw = source;
+ this.start = MyPattern.cmpile("(?i)((?:\\W|\\<[^<>]*\\>)*)@start");
+ this.unpause = MyPattern.cmpile("(?i)((?:\\W|\\<[^<>]*\\>)*)@unpause");
+ }
+
+ public String readLine() throws IOException {
+ final String result = raw.readLine();
+
+ if (result == null) {
+ return null;
+ }
+
+ final Matcher m = start.matcher(result);
+ if (m.find()) {
+ headerToRemove = m.group(1);
+ }
+ if (paused) {
+ final Matcher m2 = unpause.matcher(result);
+ if (m2.find()) {
+ headerToRemove = m2.group(1);
+ }
+ }
+ if (headerToRemove != null && headerToRemove.startsWith(result)) {
+ return "";
+ }
+ if (headerToRemove != null && result.startsWith(headerToRemove)) {
+ return result.substring(headerToRemove.length());
+ }
+ return result;
+ }
+
+ public void close() throws IOException {
+ this.raw.close();
+ }
+
+ public void setPaused(boolean paused) {
+ this.paused = paused;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/printskin/PrintSkin.java b/src/net/sourceforge/plantuml/printskin/PrintSkin.java
new file mode 100644
index 0000000..516ca31
--- /dev/null
+++ b/src/net/sourceforge/plantuml/printskin/PrintSkin.java
@@ -0,0 +1,171 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.printskin;
+
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.Graphics2D;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.List;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.EmptyImageBuilder;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.SkinParam;
+import net.sourceforge.plantuml.SpriteContainerEmpty;
+import net.sourceforge.plantuml.api.ImageDataSimple;
+import net.sourceforge.plantuml.core.DiagramDescription;
+import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.png.PngIO;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.ArrowConfiguration;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.SimpleContext2D;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.skin.SkinUtils;
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+import net.sourceforge.plantuml.ugraphic.g2d.UGraphicG2d;
+
+class PrintSkin extends AbstractPSystem {
+
+ private static final UFont FONT1 = new UFont("SansSerif", Font.PLAIN, 10);
+
+ final private Skin skin;
+ final private List<String> toPrint;
+ private UGraphic ug;
+ private float xpos = 10;
+ private float ypos = 0;
+ private float maxYpos = 0;
+
+ // public List<File> createFiles(File suggestedFile, FileFormatOption fileFormat) throws IOException,
+ // InterruptedException {
+ // final List<File> result = Arrays.asList(suggestedFile);
+ // final BufferedImage im = createImage();
+ //
+ // PngIO.write(im.getSubimage(0, 0, im.getWidth(), (int) maxYpos), suggestedFile, 96);
+ // return result;
+ //
+ // }
+
+ public ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormatOption) throws IOException {
+ final BufferedImage im = createImage();
+ final ImageData imageData = new ImageDataSimple(im.getWidth(), (int) maxYpos);
+ PngIO.write(im.getSubimage(0, 0, imageData.getWidth(), imageData.getHeight()), os, 96);
+ return imageData;
+ }
+
+ private BufferedImage createImage() {
+ final EmptyImageBuilder builder = new EmptyImageBuilder(2000, 830, Color.WHITE);
+
+ final BufferedImage im = builder.getBufferedImage();
+ final Graphics2D g2d = builder.getGraphics2D();
+
+ ug = new UGraphicG2d(new ColorMapperIdentity(), g2d, 1.0);
+
+ for (ComponentType type : ComponentType.values()) {
+ printComponent(type);
+ ypos += 10;
+ maxYpos = Math.max(maxYpos, ypos);
+ if (ypos > 620) {
+ ypos = 0;
+ xpos += 200;
+ }
+ }
+ g2d.dispose();
+ return im;
+ }
+
+ private void printComponent(ComponentType type) {
+ println(type.name());
+ final Component comp = skin.createComponent(type, ArrowConfiguration.withDirectionNormal(),
+ SkinParam.noShadowing(), Display.create(toPrint));
+ if (comp == null) {
+ println("null");
+ return;
+ }
+ double height = comp.getPreferredHeight(ug.getStringBounder());
+ double width = comp.getPreferredWidth(ug.getStringBounder());
+ println("height = " + String.format("%4.2f", height));
+ println("width = " + width);
+
+ if (height == 0) {
+ height = 42;
+ }
+ if (width == 0) {
+ width = 42;
+ }
+ ug.apply(new UChangeBackColor(HtmlColorUtils.LIGHT_GRAY)).apply(new UChangeColor(HtmlColorUtils.LIGHT_GRAY))
+ .apply(new UTranslate((double) (xpos - 1), (double) (ypos - 1)))
+ .draw(new URectangle(width + 2, height + 2));
+
+ comp.drawU(ug.apply(new UTranslate(xpos, ypos)), new Area(new Dimension2DDouble(width, height)),
+ new SimpleContext2D(false));
+
+ ypos += height;
+ }
+
+ private void println(String s) {
+ final TextBlock textBlock = TextBlockUtils.create(Display.create(s), new FontConfiguration(FONT1,
+ HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true), HorizontalAlignment.LEFT, new SpriteContainerEmpty());
+ textBlock.drawU(ug.apply(new UTranslate(xpos, ypos)));
+ ypos += textBlock.calculateDimension(ug.getStringBounder()).getHeight();
+ }
+
+ public DiagramDescription getDescription() {
+ return new DiagramDescriptionImpl("Printing of " + skin.getClass().getName(), getClass());
+ }
+
+ public PrintSkin(String className, List<String> toPrint) {
+ this.skin = SkinUtils.loadSkin(className);
+ this.toPrint = toPrint;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/printskin/PrintSkinFactory.java b/src/net/sourceforge/plantuml/printskin/PrintSkinFactory.java
new file mode 100644
index 0000000..4a28052
--- /dev/null
+++ b/src/net/sourceforge/plantuml/printskin/PrintSkinFactory.java
@@ -0,0 +1,58 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.printskin;
+
+import java.util.Arrays;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.command.PSystemSingleLineFactory;
+import net.sourceforge.plantuml.command.regex.MyPattern;
+
+public class PrintSkinFactory extends PSystemSingleLineFactory {
+
+ static final Pattern p = MyPattern.cmpile("(?i)^testskin[%s]+([\\w.]+)[%s]*(.*)$");
+
+ @Override
+ protected AbstractPSystem executeLine(String line) {
+ final Matcher m = p.matcher(line);
+ if (m.find() == false) {
+ return null;
+ }
+ return new PrintSkin(m.group(1), Arrays.asList(m.group(2)));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/project/BasicInstantArithmetic.java b/src/net/sourceforge/plantuml/project/BasicInstantArithmetic.java
new file mode 100644
index 0000000..a0cecb5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project/BasicInstantArithmetic.java
@@ -0,0 +1,83 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project;
+
+class BasicInstantArithmetic implements InstantArithmetic {
+
+ private final DayClose dayClose;
+
+ BasicInstantArithmetic(DayClose dayClose) {
+ if (dayClose == null) {
+ throw new IllegalArgumentException();
+ }
+ this.dayClose = dayClose;
+ }
+
+ public Instant add(Instant i1, Duration duration) {
+ Instant result = i1;
+ final long min = duration.getMinutes();
+ if (min < 0) {
+ throw new IllegalArgumentException();
+ }
+ for (long i = 0; i < min; i += 24 * 60 * 60) {
+ result = result.next(dayClose);
+ }
+ return result;
+ }
+
+ public Instant sub(Instant i1, Duration duration) {
+ Instant result = i1;
+ final long min = duration.getMinutes();
+ if (min < 0) {
+ throw new IllegalArgumentException();
+ }
+ for (long i = 0; i < min; i += 24 * 60 * 60) {
+ result = result.prev(dayClose);
+ }
+ return result;
+ }
+
+ public Duration diff(Instant i1, Instant i2) {
+ if (i2.compareTo(i1) < 0) {
+ throw new IllegalArgumentException();
+ }
+ long minutes = 0;
+ while (i2.compareTo(i1) > 0) {
+ minutes += 24 * 60 * 60;
+ i1 = i1.next(null);
+ }
+ return new Duration(minutes);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/project/Constant.java b/src/net/sourceforge/plantuml/project/Constant.java
new file mode 100644
index 0000000..9b1395b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project/Constant.java
@@ -0,0 +1,57 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project;
+
+class Constant implements Expression {
+
+ private final Numeric value;
+
+ public Constant(Numeric value) {
+ this.value = value;
+ }
+
+ public String getDescription() {
+ return "Constant:" + value;
+ }
+
+ public NumericType getNumericType() {
+ return value.getNumericType();
+ }
+
+ public Numeric getValue() {
+ return value;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/project/Day.java b/src/net/sourceforge/plantuml/project/Day.java
new file mode 100644
index 0000000..e57af57
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project/Day.java
@@ -0,0 +1,176 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project;
+
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+
+public class Day implements Comparable<Day> {
+
+ private final int numDay;
+ private final Month month;
+ private final int year;
+ private final WeekDay weekDay;
+
+ private Day(int year, Month month, int numDay, WeekDay weekDay) {
+ this.year = year;
+ this.month = month;
+ this.numDay = numDay;
+ this.weekDay = weekDay;
+ }
+
+ public static boolean isValidDesc(String desc) {
+ if (desc.matches("^\\d{4}/\\d{2}/\\d{2}$")) {
+ return true;
+ }
+ if (desc.matches("^\\d{2}-[A-Za-z]{3}-\\d{4}$")) {
+ return true;
+ }
+ return false;
+ }
+
+ public Day(String desc) {
+ if (desc.matches("^\\d{4}/\\d{2}/\\d{2}$")) {
+ this.year = Integer.parseInt(desc.substring(0, 4));
+ this.month = Month.fromNum(Integer.parseInt(desc.substring(5, 7)));
+ this.numDay = Integer.parseInt(desc.substring(8, 10));
+ } else if (desc.matches("^\\d{2}-[A-Za-z]{3}-\\d{4}$")) {
+ this.year = Integer.parseInt(desc.substring(7, 11));
+ this.month = Month.valueOf(desc.substring(3, 6));
+ this.numDay = Integer.parseInt(desc.substring(0, 2));
+ } else {
+ throw new IllegalArgumentException(desc);
+ }
+ final int wd = new GregorianCalendar(year, month.getNum() - 1, numDay).get(Calendar.DAY_OF_WEEK);
+ this.weekDay = WeekDay.values()[wd - 1];
+ }
+
+ public Day next(DayClose dayClose) {
+ if (dayClose == null) {
+ return nextInternal();
+ }
+ if (dayClose.isClose(this)) {
+ throw new IllegalArgumentException();
+ }
+ Day result = nextInternal();
+ while (dayClose.isClose(result)) {
+ result = result.nextInternal();
+ }
+ return result;
+ }
+
+ public Day prev(DayClose dayClose) {
+ if (dayClose == null) {
+ return prevInternal();
+ }
+ if (dayClose.isClose(this)) {
+ throw new IllegalArgumentException();
+ }
+ Day result = prevInternal();
+ while (dayClose.isClose(result)) {
+ result = result.prevInternal();
+ }
+ return result;
+ }
+
+ private Day nextInternal() {
+ if (numDay < month.getNbDays(year)) {
+ return new Day(year, month, numDay + 1, weekDay.next());
+ }
+ final Month next = month.next();
+ if (next == null) {
+ return new Day(year + 1, Month.JAN, 1, weekDay.next());
+ }
+ return new Day(year, next, 1, weekDay.next());
+ }
+
+ private Day prevInternal() {
+ if (numDay > 1) {
+ return new Day(year, month, numDay - 1, weekDay.prev());
+ }
+ final Month prev = month.prev();
+ if (prev == null) {
+ return new Day(year - 1, Month.DEC, 31, weekDay.prev());
+ }
+ return new Day(year, prev, prev.getNbDays(year), weekDay.prev());
+ }
+
+ @Override
+ public String toString() {
+ return "" + weekDay + " " + year + "-" + month + "-" + String.format("%02d", numDay);
+ }
+
+ public final int getNumDay() {
+ return numDay;
+ }
+
+ public final Month getMonth() {
+ return month;
+ }
+
+ public final int getYear() {
+ return year;
+ }
+
+ public int compareTo(Day other) {
+ if (year > other.year) {
+ return 1;
+ }
+ if (year < other.year) {
+ return -1;
+ }
+ final int cmpMonth = month.compareTo(other.month);
+ if (cmpMonth != 0) {
+ return cmpMonth;
+ }
+ return numDay - other.numDay;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ final Day this2 = (Day) obj;
+ return this.numDay == this2.numDay && this.month == this2.month && this.year == this2.year;
+ }
+
+ @Override
+ public int hashCode() {
+ return numDay * 420 + year + month.hashCode();
+ }
+
+ public final WeekDay getWeekDay() {
+ return weekDay;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/project/DayClose.java b/src/net/sourceforge/plantuml/project/DayClose.java
new file mode 100644
index 0000000..bcec283
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project/DayClose.java
@@ -0,0 +1,41 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project;
+
+interface DayClose {
+
+ boolean isClose(Day day);
+
+}
diff --git a/src/net/sourceforge/plantuml/project/DayCloseNone.java b/src/net/sourceforge/plantuml/project/DayCloseNone.java
new file mode 100644
index 0000000..800678f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project/DayCloseNone.java
@@ -0,0 +1,43 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project;
+
+class DayCloseNone implements DayClose {
+
+ public boolean isClose(Day day) {
+ return false;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/project/DayCloseOr.java b/src/net/sourceforge/plantuml/project/DayCloseOr.java
new file mode 100644
index 0000000..11d1195
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project/DayCloseOr.java
@@ -0,0 +1,57 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project;
+
+import java.util.ArrayList;
+import java.util.List;
+
+class DayCloseOr implements DayClose {
+
+ private final List<DayClose> all = new ArrayList<DayClose>();
+
+ public boolean isClose(Day day) {
+ for (DayClose dc : all) {
+ if (dc.isClose(day)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void add(DayClose dayClose) {
+ all.add(dayClose);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/project/DayCloseWeekDay.java b/src/net/sourceforge/plantuml/project/DayCloseWeekDay.java
new file mode 100644
index 0000000..17dbb9d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project/DayCloseWeekDay.java
@@ -0,0 +1,52 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project;
+
+class DayCloseWeekDay implements DayClose {
+
+ private final WeekDay weekDay;
+
+ public DayCloseWeekDay(WeekDay weekDay) {
+ this.weekDay = weekDay;
+ }
+
+ public boolean isClose(Day day) {
+ if (day.getWeekDay() == weekDay) {
+ return true;
+ }
+ return false;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/project/Duration.java b/src/net/sourceforge/plantuml/project/Duration.java
new file mode 100644
index 0000000..7ae5668
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project/Duration.java
@@ -0,0 +1,81 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project;
+
+class Duration implements Numeric {
+
+ private final long minutes;
+
+ public Duration(long minutes) {
+ this.minutes = minutes;
+ }
+
+ public Duration(NumericNumber value) {
+ this(value.getIntValue() * 24L * 60 * 60);
+ }
+
+ public Numeric add(Numeric other) {
+ return new Duration(((Duration) other).minutes + minutes);
+ }
+
+ public static Duration of(long days) {
+ return new Duration(days * 24 * 60 * 60);
+ }
+
+ public NumericType getNumericType() {
+ return NumericType.DURATION;
+ }
+
+ public long getMinutes() {
+ return minutes;
+ }
+
+ @Override
+ public String toString() {
+ return "DURATION:" + minutes / (24 * 60 * 60);
+ }
+
+ public int compareTo(Numeric other) {
+ final Duration this2 = (Duration) other;
+ if (this2.minutes > minutes) {
+ return -1;
+ }
+ if (this2.minutes < minutes) {
+ return 1;
+ }
+ return 0;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/project/Expression.java b/src/net/sourceforge/plantuml/project/Expression.java
new file mode 100644
index 0000000..6a7aec7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project/Expression.java
@@ -0,0 +1,45 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project;
+
+public interface Expression {
+
+ Numeric getValue();
+
+ String getDescription();
+
+ NumericType getNumericType();
+
+}
diff --git a/src/net/sourceforge/plantuml/project/Formal.java b/src/net/sourceforge/plantuml/project/Formal.java
new file mode 100644
index 0000000..7204a0c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project/Formal.java
@@ -0,0 +1,39 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project;
+
+interface Formal extends Expression {
+
+}
diff --git a/src/net/sourceforge/plantuml/project/FormalAddition.java b/src/net/sourceforge/plantuml/project/FormalAddition.java
new file mode 100644
index 0000000..84a6064
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project/FormalAddition.java
@@ -0,0 +1,59 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project;
+
+class FormalAddition implements Formal {
+
+ private final Expression exp1;
+ private final Expression exp2;
+
+ public FormalAddition(Expression exp1, Expression exp2) {
+ this.exp1 = exp1;
+ this.exp2 = exp2;
+ }
+
+ public String getDescription() {
+ return "add " + exp1 + " " + exp2;
+ }
+
+ public NumericType getNumericType() {
+ return exp1.getNumericType();
+ }
+
+ public Numeric getValue() {
+ return exp1.getValue().add(exp2.getValue());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/project/FormalAdditionInstantDuration.java b/src/net/sourceforge/plantuml/project/FormalAdditionInstantDuration.java
new file mode 100644
index 0000000..9f83406
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project/FormalAdditionInstantDuration.java
@@ -0,0 +1,66 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project;
+
+class FormalAdditionInstantDuration implements Formal {
+
+ private final Expression exp1;
+ private final Expression exp2;
+ private final InstantArithmetic math;
+
+ public FormalAdditionInstantDuration(Expression exp1, Expression exp2, InstantArithmetic math) {
+ this.exp1 = exp1;
+ this.exp2 = exp2;
+ this.math = math;
+ }
+
+ public String getDescription() {
+ return "addID " + exp1 + " " + exp2;
+ }
+
+ public NumericType getNumericType() {
+ return exp1.getNumericType();
+ }
+
+ public Numeric getValue() {
+ if (exp2.getNumericType() == NumericType.NUMBER) {
+ final Duration d = new Duration((NumericNumber) exp2.getValue());
+ return math.add((Instant) exp1.getValue(), d);
+ }
+
+ return math.add((Instant) exp1.getValue(), (Duration) exp2.getValue());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/project/FreeVariable.java b/src/net/sourceforge/plantuml/project/FreeVariable.java
new file mode 100644
index 0000000..b2846b9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project/FreeVariable.java
@@ -0,0 +1,70 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project;
+
+class FreeVariable implements Expression {
+
+ private Expression value;
+ private final String name;
+ private final NumericType type;
+
+ public FreeVariable(String name, NumericType type) {
+ this.name = name;
+ this.type = type;
+ }
+
+ public String getDescription() {
+ return "$" + name + "=" + (value == null ? "null" : value.getDescription());
+ }
+
+ public NumericType getNumericType() {
+ return type;
+ }
+
+ public Numeric getValue() {
+ if (value == null) {
+ return null;
+ }
+ return value.getValue();
+ }
+
+ public void setValue(Expression expression) {
+ if (expression.getNumericType() != type) {
+ throw new IllegalArgumentException("Bad type");
+ }
+ this.value = expression;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/project/IncompleteItem.java b/src/net/sourceforge/plantuml/project/IncompleteItem.java
new file mode 100644
index 0000000..5f3f6e2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project/IncompleteItem.java
@@ -0,0 +1,191 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project;
+
+import java.util.EnumMap;
+import java.util.EnumSet;
+import java.util.List;
+import java.util.Map;
+
+class IncompleteItem implements Item {
+
+ private Map<ItemCaract, Numeric> data = new EnumMap<ItemCaract, Numeric>(ItemCaract.class);
+
+ private final InstantArithmetic math;
+
+ private final Item parent;
+
+ private final String code;
+
+ public IncompleteItem(String code, Item parent, InstantArithmetic math) {
+ this.math = math;
+ this.code = code;
+ this.parent = parent;
+ }
+
+ public void setData(ItemCaract caract, Numeric value) {
+ if (caract.getNumericType() != value.getNumericType()) {
+ throw new IllegalArgumentException();
+ }
+ if (data.containsKey(caract.getNumericType())) {
+ throw new IllegalStateException();
+ }
+ data.put(caract, value);
+ boolean change = false;
+ do {
+ change = false;
+ change = eventuallyUseBeginComplete() || change;
+ change = eventuallyUseBeginDuration() || change;
+ change = eventuallyUseCompleteDuration() || change;
+ change = eventuallyUseDurationWork() || change;
+ change = eventuallyUseDurationLoad() || change;
+ change = eventuallyUseLoadWork() || change;
+ } while (change);
+ }
+
+ private boolean eventuallyUseDurationWork() {
+ if (data.containsKey(ItemCaract.DURATION) && data.containsKey(ItemCaract.WORK)
+ && data.containsKey(ItemCaract.LOAD) == false) {
+ final Duration d = (Duration) data.get(ItemCaract.DURATION);
+ final NumericNumber w = (NumericNumber) data.get(ItemCaract.WORK);
+ data.put(ItemCaract.LOAD, new Load(d.getMinutes() * w.getIntValue()));
+ return true;
+ }
+ return false;
+ }
+
+ private boolean eventuallyUseLoadWork() {
+ if (data.containsKey(ItemCaract.LOAD) && data.containsKey(ItemCaract.WORK)
+ && data.containsKey(ItemCaract.DURATION) == false) {
+ final Load l = (Load) data.get(ItemCaract.LOAD);
+ final NumericNumber w = (NumericNumber) data.get(ItemCaract.WORK);
+ data.put(ItemCaract.DURATION, new Duration(l.getMinuteMen() / w.getIntValue()));
+ return true;
+ }
+ return false;
+ }
+
+ private boolean eventuallyUseDurationLoad() {
+ if (data.containsKey(ItemCaract.DURATION) && data.containsKey(ItemCaract.LOAD)
+ && data.containsKey(ItemCaract.WORK) == false) {
+ final Duration d = (Duration) data.get(ItemCaract.DURATION);
+ final Load l = (Load) data.get(ItemCaract.LOAD);
+ data.put(ItemCaract.WORK, new NumericNumber((int) (l.getMinuteMen() / d.getMinutes())));
+ return true;
+ }
+ return false;
+ }
+
+ private boolean eventuallyUseBeginDuration() {
+ if (data.containsKey(ItemCaract.BEGIN) && data.containsKey(ItemCaract.DURATION)
+ && data.containsKey(ItemCaract.COMPLETED) == false) {
+ final Instant i1 = (Instant) data.get(ItemCaract.BEGIN);
+ final Duration d = (Duration) data.get(ItemCaract.DURATION);
+ data.put(ItemCaract.COMPLETED, math.add(i1, d));
+ return true;
+ }
+ return false;
+ }
+
+ private boolean eventuallyUseCompleteDuration() {
+ if (data.containsKey(ItemCaract.COMPLETED) && data.containsKey(ItemCaract.DURATION)
+ && data.containsKey(ItemCaract.BEGIN) == false) {
+ final Instant i2 = (Instant) data.get(ItemCaract.COMPLETED);
+ final Duration d = (Duration) data.get(ItemCaract.DURATION);
+ data.put(ItemCaract.BEGIN, math.sub(i2, d));
+ return true;
+ }
+ return false;
+ }
+
+ private boolean eventuallyUseBeginComplete() {
+ if (data.containsKey(ItemCaract.BEGIN) && data.containsKey(ItemCaract.COMPLETED)
+ && data.containsKey(ItemCaract.DURATION) == false) {
+ final Instant i1 = (Instant) data.get(ItemCaract.BEGIN);
+ final Instant i2 = (Instant) data.get(ItemCaract.COMPLETED);
+ if (i2.compareTo(i1) <= 0) {
+ throw new IllegalArgumentException();
+ }
+ data.put(ItemCaract.DURATION, math.diff(i1, i2));
+ return true;
+ }
+ return false;
+ }
+
+ public boolean isValid() {
+ return data.size() == EnumSet.allOf(ItemCaract.class).size();
+ }
+
+ public Instant getBegin() {
+ return (Instant) data.get(ItemCaract.BEGIN);
+ }
+
+ public Instant getCompleted() {
+ return (Instant) data.get(ItemCaract.COMPLETED);
+ }
+
+ public Duration getDuration() {
+ return (Duration) data.get(ItemCaract.DURATION);
+ }
+
+ public Load getLoad() {
+ return (Load) data.get(ItemCaract.LOAD);
+ }
+
+ public NumericNumber getWork() {
+ return (NumericNumber) data.get(ItemCaract.WORK);
+ }
+
+ public boolean isLeaf() {
+ return true;
+ }
+
+ public Item getParent() {
+ return parent;
+ }
+
+ public List<Item> getChildren() {
+ return null;
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ @Override
+ public String toString() {
+ return code + " " + data.toString();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/project/Instant.java b/src/net/sourceforge/plantuml/project/Instant.java
new file mode 100644
index 0000000..7ddbba6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project/Instant.java
@@ -0,0 +1,86 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project;
+
+public class Instant implements Numeric {
+
+ private final Day value;
+
+ public Instant(Day d) {
+ this.value = d;
+ }
+
+ public Numeric add(Numeric other) {
+ throw new UnsupportedOperationException();
+ }
+
+ public NumericType getNumericType() {
+ return NumericType.INSTANT;
+ }
+
+ public Day getDay() {
+ return value;
+ }
+
+ public Instant next(DayClose dayClose) {
+ return new Instant(value.next(dayClose));
+ }
+
+ public Instant prev(DayClose dayClose) {
+ return new Instant(value.prev(dayClose));
+ }
+
+ @Override
+ public String toString() {
+ return "Instant:" + value;
+ }
+
+ public int compareTo(Numeric other) {
+ final Instant this2 = (Instant) other;
+ return value.compareTo(this2.value);
+ }
+
+ @Override
+ public int hashCode() {
+ return value.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ final Instant other = (Instant) obj;
+ return value.equals(other.value);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/project/InstantArithmetic.java b/src/net/sourceforge/plantuml/project/InstantArithmetic.java
new file mode 100644
index 0000000..c86b8e0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project/InstantArithmetic.java
@@ -0,0 +1,44 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project;
+
+interface InstantArithmetic {
+
+ public Instant add(Instant i1, Duration duration);
+
+ public Instant sub(Instant i1, Duration duration);
+
+ public Duration diff(Instant i1, Instant i2);
+}
diff --git a/src/net/sourceforge/plantuml/project/Item.java b/src/net/sourceforge/plantuml/project/Item.java
new file mode 100644
index 0000000..8c155be
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project/Item.java
@@ -0,0 +1,61 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project;
+
+import java.util.List;
+
+public interface Item {
+
+ Instant getBegin();
+
+ Instant getCompleted();
+
+ Duration getDuration();
+
+ Load getLoad();
+
+ NumericNumber getWork();
+
+ boolean isLeaf();
+
+ Item getParent();
+
+ List<Item> getChildren();
+
+ public String getCode();
+
+ public boolean isValid();
+
+}
diff --git a/src/net/sourceforge/plantuml/project/ItemCaract.java b/src/net/sourceforge/plantuml/project/ItemCaract.java
new file mode 100644
index 0000000..08baadb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project/ItemCaract.java
@@ -0,0 +1,72 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project;
+
+enum ItemCaract {
+ BEGIN(NumericType.INSTANT), //
+ COMPLETED(NumericType.INSTANT), //
+ DURATION(NumericType.DURATION), //
+ LOAD(NumericType.LOAD), //
+ WORK(NumericType.NUMBER);
+
+ private final NumericType type;
+
+ private ItemCaract(NumericType type) {
+ this.type = type;
+ }
+
+ public NumericType getNumericType() {
+ return type;
+ }
+
+ public Numeric getData(Item item) {
+ if (this == BEGIN) {
+ return item.getBegin();
+ }
+ if (this == COMPLETED) {
+ return item.getCompleted();
+ }
+ if (this == DURATION) {
+ return item.getDuration();
+ }
+ if (this == LOAD) {
+ return item.getLoad();
+ }
+ if (this == WORK) {
+ return item.getWork();
+ }
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/project/ItemComparator.java b/src/net/sourceforge/plantuml/project/ItemComparator.java
new file mode 100644
index 0000000..c17f330
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project/ItemComparator.java
@@ -0,0 +1,59 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project;
+
+import java.util.Comparator;
+
+public class ItemComparator implements Comparator<Item> {
+
+ public int compare(Item it1, Item it2) {
+ final int cmp1 = it1.getBegin().compareTo(it2.getBegin());
+ if (cmp1 != 0) {
+ return cmp1;
+ }
+ if (it1 instanceof Jalon && it2 instanceof Jalon == false) {
+ return -1;
+ }
+ if (it2 instanceof Jalon && it1 instanceof Jalon == false) {
+ return 1;
+ }
+ final int cmp2 = it2.getCompleted().compareTo(it1.getCompleted());
+ if (cmp2 != 0) {
+ return cmp2;
+ }
+ return it1.getCode().compareTo(it2.getCode());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/project/Jalon.java b/src/net/sourceforge/plantuml/project/Jalon.java
new file mode 100644
index 0000000..057e260
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project/Jalon.java
@@ -0,0 +1,94 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project;
+
+import java.util.List;
+
+public class Jalon implements Item {
+
+ private Instant begin;
+ private final String code;
+ private final Item parent;
+
+ public Jalon(String code, Item parent) {
+ this.code = code;
+ this.parent = parent;
+ }
+
+ public Instant getBegin() {
+ return begin;
+ }
+
+ public Instant getCompleted() {
+ return begin;
+ }
+
+ public Duration getDuration() {
+ return new Duration(0);
+ }
+
+ public Load getLoad() {
+ return new Load(0);
+ }
+
+ public NumericNumber getWork() {
+ return new NumericNumber(1);
+ }
+
+ public boolean isLeaf() {
+ return true;
+ }
+
+ public Item getParent() {
+ return parent;
+ }
+
+ public List<Item> getChildren() {
+ return null;
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public boolean isValid() {
+ return begin != null;
+ }
+
+ public void setInstant(Numeric value) {
+ this.begin = (Instant) value;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/project/Load.java b/src/net/sourceforge/plantuml/project/Load.java
new file mode 100644
index 0000000..088ce39
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project/Load.java
@@ -0,0 +1,79 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project;
+
+class Load implements Numeric {
+
+ private final long minuteMen;
+
+ public Load(long minuteMen) {
+ this.minuteMen = minuteMen;
+ }
+
+ public Load(NumericNumber value) {
+ this(value.getIntValue() * 24L * 60 * 60);
+ }
+
+ public Numeric add(Numeric other) {
+ return new Load(((Load) other).minuteMen + minuteMen);
+ }
+
+ public NumericType getNumericType() {
+ return NumericType.LOAD;
+ }
+
+ public int compareTo(Numeric other) {
+ final Load this2 = (Load) other;
+ if (this2.minuteMen > minuteMen) {
+ return -1;
+ }
+ if (this2.minuteMen < minuteMen) {
+ return 1;
+ }
+ return 0;
+ }
+
+ public final long getMinuteMen() {
+ return minuteMen;
+ }
+
+ @Override
+ public String toString() {
+ return "LOAD:" + minuteMen / (24 * 60 * 60);
+ }
+
+
+
+}
diff --git a/src/net/sourceforge/plantuml/project/Month.java b/src/net/sourceforge/plantuml/project/Month.java
new file mode 100644
index 0000000..ad55d5b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project/Month.java
@@ -0,0 +1,89 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project;
+
+import java.util.ArrayList;
+import java.util.EnumSet;
+import java.util.List;
+
+public enum Month {
+
+ JAN(31), FEB(28), MAR(31), APR(30), MAY(31), JUN(30), JUL(31), AUG(31), SEP(30), OCT(31), NOV(30), DEC(31);
+
+ final private int nbDays;
+
+ private Month(int nbDays) {
+ this.nbDays = nbDays;
+ }
+
+ public final int getNbDays(int year) {
+ if (this == FEB && year % 4 == 0) {
+ return 29;
+ }
+ return nbDays;
+ }
+
+ public final int getNum() {
+ return ordinal() + 1;
+ }
+
+ public final int getNumNormal() {
+ return ordinal();
+ }
+
+ public Month next() {
+ if (this == DEC) {
+ return null;
+ }
+ final List<Month> all = new ArrayList<Month>(EnumSet.allOf(Month.class));
+ return all.get(getNum());
+ }
+
+ public Month prev() {
+ if (this == JAN) {
+ return null;
+ }
+ final List<Month> all = new ArrayList<Month>(EnumSet.allOf(Month.class));
+ return all.get(getNum() - 2);
+ }
+
+ public static Month fromNum(int num) {
+ if (num < 1 || num > 12) {
+ throw new IllegalArgumentException();
+ }
+ final List<Month> all = new ArrayList<Month>(EnumSet.allOf(Month.class));
+ return all.get(num - 1);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/project/Numeric.java b/src/net/sourceforge/plantuml/project/Numeric.java
new file mode 100644
index 0000000..5361039
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project/Numeric.java
@@ -0,0 +1,42 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project;
+
+public interface Numeric extends Comparable<Numeric> {
+ Numeric add(Numeric other);
+
+ NumericType getNumericType();
+
+}
diff --git a/src/net/sourceforge/plantuml/project/NumericNumber.java b/src/net/sourceforge/plantuml/project/NumericNumber.java
new file mode 100644
index 0000000..d1a1c22
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project/NumericNumber.java
@@ -0,0 +1,76 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project;
+
+class NumericNumber implements Numeric {
+
+ private final int value;
+
+ public NumericNumber(int v) {
+ this.value = v;
+ }
+
+ public Numeric add(Numeric other) {
+ if (other.getNumericType() != getNumericType()) {
+ throw new IllegalArgumentException();
+ }
+ return new NumericNumber(value + ((NumericNumber) other).value);
+ }
+
+ public NumericType getNumericType() {
+ return NumericType.NUMBER;
+ }
+
+ public int getIntValue() {
+ return value;
+ }
+
+ @Override
+ public String toString() {
+ return "Number:" + value;
+ }
+
+ public int compareTo(Numeric other) {
+ final NumericNumber this2 = (NumericNumber) other;
+ if (this2.value > value) {
+ return -1;
+ }
+ if (this2.value < value) {
+ return 1;
+ }
+ return 0;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/project/NumericType.java b/src/net/sourceforge/plantuml/project/NumericType.java
new file mode 100644
index 0000000..ddbaac9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project/NumericType.java
@@ -0,0 +1,79 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project;
+
+enum NumericType {
+
+ NUMBER, INSTANT, LOAD, DURATION;
+
+ public NumericType add(NumericType other) {
+ if (this == NUMBER) {
+ return addNumber(other);
+ }
+ if (this == INSTANT) {
+ return null;
+ }
+ if (this == LOAD) {
+ return addLoad(other);
+ }
+ if (this == DURATION) {
+ return addDuration(other);
+ }
+ throw new UnsupportedOperationException();
+
+ }
+
+ private NumericType addDuration(NumericType other) {
+ if (other == DURATION) {
+ return DURATION;
+ }
+ return null;
+ }
+
+ private NumericType addLoad(NumericType other) {
+ if (other == LOAD) {
+ return LOAD;
+ }
+ return null;
+ }
+
+ private NumericType addNumber(NumericType other) {
+ if (other == NUMBER) {
+ return NUMBER;
+ }
+ return null;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/project/PSystemProject.java b/src/net/sourceforge/plantuml/project/PSystemProject.java
new file mode 100644
index 0000000..d940375
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project/PSystemProject.java
@@ -0,0 +1,124 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.EmptyImageBuilder;
+import net.sourceforge.plantuml.FileFormat;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.api.ImageDataSimple;
+import net.sourceforge.plantuml.core.DiagramDescription;
+import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.eps.EpsStrategy;
+import net.sourceforge.plantuml.png.PngIO;
+import net.sourceforge.plantuml.project.graphic.GanttDiagram;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+import net.sourceforge.plantuml.ugraphic.eps.UGraphicEps;
+import net.sourceforge.plantuml.ugraphic.g2d.UGraphicG2d;
+import net.sourceforge.plantuml.ugraphic.svg.UGraphicSvg;
+import net.sourceforge.plantuml.StringUtils;
+
+public class PSystemProject extends AbstractPSystem {
+
+ private final Project project = new Project();
+ private final Color background = Color.WHITE;
+ private final ColorMapper colorMapper = new ColorMapperIdentity();
+
+ public int getNbImages() {
+ return 1;
+ }
+
+ public DiagramDescription getDescription() {
+ return new DiagramDescriptionImpl("(Project)", getClass());
+ }
+
+ public ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormatOption) throws IOException {
+ final GanttDiagram diagram = new GanttDiagram(project);
+ final FileFormat fileFormat = fileFormatOption.getFileFormat();
+ if (fileFormat == FileFormat.PNG) {
+ final BufferedImage im = createImage(diagram);
+ PngIO.write(im, os, fileFormatOption.isWithMetadata() ? getMetadata() : null, 96);
+ } else if (fileFormat == FileFormat.SVG) {
+ final UGraphicSvg svg = new UGraphicSvg(colorMapper, StringUtils.getAsHtml(background), false, 1.0);
+ diagram.draw(svg, 0, 0);
+ svg.createXml(os);
+ } else if (fileFormat == FileFormat.EPS) {
+ final UGraphicEps eps = new UGraphicEps(colorMapper, EpsStrategy.getDefault2());
+ diagram.draw(eps, 0, 0);
+ os.write(eps.getEPSCode().getBytes());
+ } else if (fileFormat == FileFormat.EPS_TEXT) {
+ final UGraphicEps eps = new UGraphicEps(colorMapper, EpsStrategy.WITH_MACRO_AND_TEXT);
+ diagram.draw(eps, 0, 0);
+ os.write(eps.getEPSCode().getBytes());
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ return new ImageDataSimple();
+ }
+
+ private BufferedImage createImage(GanttDiagram diagram) {
+ EmptyImageBuilder builder = new EmptyImageBuilder(10, 10, background);
+ Graphics2D g2d = builder.getGraphics2D();
+ UGraphicG2d ug = new UGraphicG2d(colorMapper, g2d, 1.0);
+
+ final double height = diagram.getHeight(ug.getStringBounder());
+ final double width = diagram.getWidth(ug.getStringBounder());
+
+ g2d.dispose();
+
+ builder = new EmptyImageBuilder(width, height, background);
+ final BufferedImage im = builder.getBufferedImage();
+ g2d = builder.getGraphics2D();
+
+ ug = new UGraphicG2d(colorMapper, g2d, 1.0);
+ ug.setBufferedImage(im);
+ diagram.draw(ug, 0, 0);
+ g2d.dispose();
+ return im;
+ }
+
+ public final Project getProject() {
+ return project;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/project/ParentItem.java b/src/net/sourceforge/plantuml/project/ParentItem.java
new file mode 100644
index 0000000..98eb5c7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project/ParentItem.java
@@ -0,0 +1,132 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+public class ParentItem implements Item {
+
+ private final String code;
+ private final Item parent;
+
+ private final List<Item> children = new ArrayList<Item>();
+
+ public ParentItem(String code, Item parent) {
+ this.code = code;
+ this.parent = parent;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder(code + " {");
+ for (final Iterator<Item> it = children.iterator(); it.hasNext();) {
+ final Item child = it.next();
+ sb.append(child.getCode());
+ if (it.hasNext()) {
+ sb.append(", ");
+ }
+ }
+ sb.append("}");
+ return sb.toString();
+ }
+
+ public Instant getBegin() {
+ Instant result = null;
+ for (Item it : children) {
+ if (result == null || result.compareTo(it.getBegin()) > 0) {
+ result = it.getBegin();
+ }
+ }
+ return result;
+ }
+
+ public Instant getCompleted() {
+ Instant result = null;
+ for (Item it : children) {
+ if (result == null || result.compareTo(it.getCompleted()) < 0) {
+ result = it.getCompleted();
+ }
+ }
+ return result;
+ }
+
+ public Duration getDuration() {
+ throw new UnsupportedOperationException();
+ }
+
+ public Load getLoad() {
+ throw new UnsupportedOperationException();
+ }
+
+ public NumericNumber getWork() {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isLeaf() {
+ return false;
+ }
+
+ public Item getParent() {
+ return parent;
+ }
+
+ public List<Item> getChildren() {
+ return Collections.unmodifiableList(children);
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public void addChild(Item child) {
+ this.children.add(child);
+ }
+
+ public boolean isValid() {
+ if (children.size() == 0) {
+ return false;
+ }
+ for (Item it : children) {
+ if (it.isValid() == false) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/project/Project.java b/src/net/sourceforge/plantuml/project/Project.java
new file mode 100644
index 0000000..74ccd3e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project/Project.java
@@ -0,0 +1,282 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+import net.sourceforge.plantuml.StringUtils;
+
+public class Project {
+
+ private final Map<String, FreeVariable> variables = new TreeMap<String, FreeVariable>();
+
+ private final Map<String, Item> items = new TreeMap<String, Item>();
+
+ private final Map<String, Ressource> ressources = new TreeMap<String, Ressource>();
+
+ private final DayCloseOr dayClose = new DayCloseOr();
+
+ public Project() {
+ }
+
+ public final Instant getStart() {
+ Instant result = null;
+ for (Item it : getValidItems()) {
+ if (result == null || result.compareTo(it.getBegin()) > 0) {
+ result = it.getBegin();
+ }
+ }
+ return result;
+ }
+
+ public final Instant getEnd() {
+ Instant result = null;
+ for (Item it : getValidItems()) {
+ if (result == null || result.compareTo(it.getCompleted()) < 0) {
+ result = it.getCompleted();
+ }
+ }
+ return result;
+ }
+
+ public FreeVariable createVariable(String name, NumericType type) {
+ if (variables.containsKey(name)) {
+ throw new IllegalArgumentException("Already exist: " + name);
+ }
+ final FreeVariable variable = new FreeVariable(name, type);
+ variables.put(name, variable);
+ return variable;
+ }
+
+ public Expression getExpression(String desc) {
+ desc = desc.trim();
+ final int plus = desc.indexOf('+');
+
+ if (plus != -1) {
+ final Expression exp1 = getExpression(desc.substring(0, plus));
+ final Expression exp2 = getExpression(desc.substring(plus + 1));
+ if (exp1.getNumericType() == NumericType.INSTANT
+ && (exp2.getNumericType() == NumericType.DURATION || exp2.getNumericType() == NumericType.NUMBER)) {
+ return new FormalAdditionInstantDuration(exp1, exp2, new BasicInstantArithmetic(dayClose));
+ }
+ if (exp2.getNumericType() == NumericType.INSTANT
+ && (exp1.getNumericType() == NumericType.DURATION || exp1.getNumericType() == NumericType.NUMBER)) {
+ return new FormalAdditionInstantDuration(exp2, exp1, new BasicInstantArithmetic(dayClose));
+ }
+ return new FormalAddition(exp1, exp2);
+ }
+
+ if (desc.matches("^\\d+$")) {
+ return new Constant(new NumericNumber(Integer.parseInt(desc)));
+ }
+ if (desc.matches("^\\$\\w+$")) {
+ final String varName = desc.substring(1);
+ final FreeVariable v = variables.get(varName);
+ if (v != null) {
+ return v;
+ }
+ throw new IllegalArgumentException("No such variable: " + desc);
+ }
+ if (Day.isValidDesc(desc)) {
+ final Day d = new Day(desc);
+ return new Constant(new Instant(d));
+ }
+ if (desc.matches("^[\\w/]+\\$(begin|completed|work|load|duration)$")) {
+ final int idx = desc.indexOf('$');
+ final String varName = desc.substring(0, idx);
+ final Item item = items.get(varName);
+ if (item == null) {
+ throw new IllegalArgumentException("No such variable: " + desc);
+ }
+ return new Constant(ItemCaract.valueOf(StringUtils.goUpperCase(desc.substring(idx + 1))).getData(item));
+ }
+ if (desc.startsWith("^")) {
+ final Item item = items.get(desc.substring(1));
+ if (item == null) {
+ throw new IllegalArgumentException("No such variable: " + desc);
+ }
+ return new Constant(item.getBegin());
+ }
+ throw new IllegalArgumentException("cannot parse");
+ }
+
+ public boolean affectation(String destination, Expression expression) {
+ if (destination.startsWith("^")) {
+ return affectationJalon(destination, expression);
+ }
+ if (destination.startsWith("~")) {
+ return affectationRessource(destination, expression);
+ }
+ final int idx = destination.indexOf('$');
+ if (idx == -1) {
+ return affectationVariable(destination, expression);
+ }
+ final String itemName = destination.substring(0, idx);
+ final Item item = getItem(itemName);
+ if (item instanceof IncompleteItem == false) {
+ return false;
+ }
+ final IncompleteItem incompleteItem = (IncompleteItem) item;
+ final String suf = destination.substring(idx + 1);
+ if (suf.equalsIgnoreCase("begin")) {
+ incompleteItem.setData(ItemCaract.BEGIN, expression.getValue());
+ } else if (suf.equalsIgnoreCase("completed")) {
+ incompleteItem.setData(ItemCaract.COMPLETED, expression.getValue());
+ } else if (suf.equalsIgnoreCase("work")) {
+ incompleteItem.setData(ItemCaract.WORK, expression.getValue());
+ } else if (suf.equalsIgnoreCase("duration")) {
+ if (expression.getNumericType() == NumericType.NUMBER) {
+ expression = new Constant(new Duration((NumericNumber) expression.getValue()));
+ }
+ incompleteItem.setData(ItemCaract.DURATION, expression.getValue());
+ } else if (suf.equalsIgnoreCase("LOAD")) {
+ if (expression.getNumericType() == NumericType.NUMBER) {
+ expression = new Constant(new Load((NumericNumber) expression.getValue()));
+ }
+ incompleteItem.setData(ItemCaract.LOAD, expression.getValue());
+ } else {
+ return false;
+ }
+ return true;
+ }
+
+ private boolean affectationRessource(String res, Expression expression) {
+ res = res.substring(1);
+ final int idx = res.indexOf('$');
+ final String suf = res.substring(idx + 1);
+ if (suf.equals("capacity")) {
+ final Ressource ressource = getRessource(res.substring(0, idx));
+ ressource.setCapacity(((NumericNumber) expression.getValue()).getIntValue());
+ return true;
+ }
+ return false;
+ }
+
+ private Ressource getRessource(String code) {
+ Ressource result = ressources.get(code);
+ if (result == null) {
+ result = new Ressource(code);
+ ressources.put(code, result);
+ }
+ return result;
+ }
+
+ private boolean affectationJalon(String jalon, Expression expression) {
+ final Jalon it = getItemJalon(jalon.substring(1));
+ it.setInstant(expression.getValue());
+ return true;
+ }
+
+ private Jalon getItemJalon(String jalon) {
+ Jalon result = (Jalon) items.get(jalon);
+ if (result == null) {
+ result = new Jalon(jalon, null);
+ items.put(jalon, result);
+
+ }
+ return result;
+ }
+
+ private Item getItem(String code) {
+ Item result = items.get(code);
+ if (result == null) {
+ final int idx = code.indexOf('/');
+ if (idx == -1) {
+ result = new IncompleteItem(code, null, new BasicInstantArithmetic(dayClose));
+ } else {
+ final ParentItem parent = getItemParent(code.substring(0, idx));
+ result = new IncompleteItem(code, parent, new BasicInstantArithmetic(dayClose));
+ parent.addChild(result);
+ }
+ items.put(code, result);
+ }
+ return result;
+ }
+
+ private ParentItem getItemParent(String code) {
+ Item result = items.get(code);
+ if (result == null) {
+ final int idx = code.indexOf('/');
+ if (idx == -1) {
+ result = new ParentItem(code, null);
+ items.put(code, result);
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ }
+ return (ParentItem) result;
+ }
+
+ private boolean affectationVariable(String destination, Expression expression) {
+ if (variables.containsKey(destination) == false) {
+ return false;
+ }
+ variables.get(destination).setValue(expression);
+ return true;
+ }
+
+ public List<Item> getValidItems() {
+ final List<Item> result = new ArrayList<Item>();
+ for (Item item : items.values()) {
+ if (item.isValid()) {
+ result.add(item);
+ }
+ }
+ Collections.sort(result, new ItemComparator());
+ return Collections.unmodifiableList(result);
+ }
+
+ public final DayClose getDayClose() {
+ return dayClose;
+ }
+
+ public void closeWeekDay(WeekDay weekDay) {
+ dayClose.add(new DayCloseWeekDay(weekDay));
+ }
+
+ // public Item getItem(String code) {
+ // BasicItem result = items.get(code);
+ // if (result == null) {
+ // result = new BasicItem(code);
+ // items.put(code, result);
+ // }
+ // return result;
+ // }
+
+}
diff --git a/src/net/sourceforge/plantuml/project/Ressource.java b/src/net/sourceforge/plantuml/project/Ressource.java
new file mode 100644
index 0000000..469c69f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project/Ressource.java
@@ -0,0 +1,59 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project;
+
+public class Ressource {
+
+ private final String code;
+
+ private int capacity = 1;
+
+ public Ressource(String code) {
+ this.code = code;
+ }
+
+ public DayClose getDayClose() {
+ return new DayCloseNone();
+ }
+
+ public final int getCapacity() {
+ return capacity;
+ }
+
+ public final void setCapacity(int capacity) {
+ this.capacity = capacity;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/project/WeekDay.java b/src/net/sourceforge/plantuml/project/WeekDay.java
new file mode 100644
index 0000000..e3b0413
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project/WeekDay.java
@@ -0,0 +1,61 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project;
+
+import java.util.ArrayList;
+import java.util.EnumSet;
+import java.util.List;
+
+public enum WeekDay {
+
+ SUN, MON, TUE, WED, THU, FRI, SAT;
+
+ public WeekDay next() {
+ if (this.ordinal() == 6) {
+ return SUN;
+ }
+ final List<WeekDay> all = new ArrayList<WeekDay>(EnumSet.allOf(WeekDay.class));
+ return all.get(this.ordinal() + 1);
+ }
+
+ public WeekDay prev() {
+ if (this.ordinal() == 0) {
+ return SAT;
+ }
+ final List<WeekDay> all = new ArrayList<WeekDay>(EnumSet.allOf(WeekDay.class));
+ return all.get(this.ordinal() - 1);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/project/command/CommandAffectation.java b/src/net/sourceforge/plantuml/project/command/CommandAffectation.java
new file mode 100644
index 0000000..cad5d97
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project/command/CommandAffectation.java
@@ -0,0 +1,59 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.project.Expression;
+import net.sourceforge.plantuml.project.PSystemProject;
+
+public class CommandAffectation extends SingleLineCommand<PSystemProject> {
+
+ public CommandAffectation() {
+ super("(?i)^\\s*([~\\^]?[\\w$/]+)\\s*:=\\s*(.+)$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(PSystemProject diagram, List<String> arg) {
+ final Expression exp = diagram.getProject().getExpression(arg.get(1).trim());
+ final boolean ok = diagram.getProject().affectation(arg.get(0).trim(), exp);
+ if (ok) {
+ return CommandExecutionResult.ok();
+ }
+ return CommandExecutionResult.error("Cannot execute");
+ }
+}
diff --git a/src/net/sourceforge/plantuml/project/command/CommandCloseWeekDay.java b/src/net/sourceforge/plantuml/project/command/CommandCloseWeekDay.java
new file mode 100644
index 0000000..07cf386
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project/command/CommandCloseWeekDay.java
@@ -0,0 +1,57 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.project.PSystemProject;
+import net.sourceforge.plantuml.project.WeekDay;
+
+public class CommandCloseWeekDay extends SingleLineCommand<PSystemProject> {
+
+ public CommandCloseWeekDay() {
+ super("(?i)^\\s*close\\s+(\\w{3,}day)\\s*$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(PSystemProject diagram, List<String> arg) {
+ final WeekDay weekDay = WeekDay.valueOf(StringUtils.goUpperCase(arg.get(0).substring(0, 3)));
+ diagram.getProject().closeWeekDay(weekDay);
+ return CommandExecutionResult.ok();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/project/graphic/GanttDiagram.java b/src/net/sourceforge/plantuml/project/graphic/GanttDiagram.java
new file mode 100644
index 0000000..b7d063c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project/graphic/GanttDiagram.java
@@ -0,0 +1,139 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project.graphic;
+
+import java.util.Map;
+import java.util.SortedMap;
+
+import net.sourceforge.plantuml.Log;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorSetSimple;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.project.Instant;
+import net.sourceforge.plantuml.project.Item;
+import net.sourceforge.plantuml.project.Jalon;
+import net.sourceforge.plantuml.project.Project;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class GanttDiagram {
+
+ private final Project project;
+ private final TimeScale timeScale;
+ private final ItemHeader itemHeader;
+
+ public GanttDiagram(Project project) {
+ this.project = project;
+ this.timeScale = new TimeScale(project);
+ this.itemHeader = new ItemHeader(project);
+ }
+
+ public void draw(UGraphic ug, double x, double y) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final double x0start = itemHeader.getWidth(stringBounder);
+
+ final double timeScaleHeight = timeScale.getHeight(stringBounder);
+
+ final SortedMap<Instant, Double> pos = timeScale.getAbscisse(stringBounder);
+ for (Item it : project.getValidItems()) {
+ final Instant start = it.getBegin();
+ final Instant completed = it.getCompleted();
+ if (pos.get(start) == null || pos.get(completed) == null) {
+ Log.println("PB " + it);
+ continue;
+ }
+ final double x1 = pos.get(start) + 3;
+ final double x2 = pos.get(completed) - 3;
+
+ final double yitem = timeScaleHeight + itemHeader.getPosition(stringBounder, it) + 3;
+
+ final UShape rect;
+ if (it instanceof Jalon) {
+ rect = new UPolygon();
+ ((UPolygon) rect).addPoint(0, 3);
+ ((UPolygon) rect).addPoint(3, 0);
+ ((UPolygon) rect).addPoint(6, 3);
+ ((UPolygon) rect).addPoint(3, 6);
+ } else {
+ rect = new URectangle(x2 - x1, 3);
+ }
+ ug = ug.apply(new UChangeColor(HtmlColorUtils.GREEN));
+ ug = ug.apply(new UChangeBackColor(HtmlColorUtils.GRAY));
+ ug.apply(new UTranslate(x0start + x1, yitem)).draw(rect);
+
+ }
+
+ drawGrid(ug, x + x0start, y + timeScaleHeight, pos);
+
+ ug = ug.apply(new UChangeColor(HtmlColorUtils.BLACK));
+ ug = ug.apply(new UChangeBackColor(null));
+ timeScale.draw(ug, x + x0start, y);
+ itemHeader.draw(ug, x, y + timeScaleHeight);
+
+ }
+
+ private final HtmlColor lightGray = new HtmlColorSetSimple().getColorIfValid("#C8C8C8");
+
+ private void drawGrid(UGraphic ug, double x, double y, SortedMap<Instant, Double> pos) {
+ final ULine line = new ULine(0, itemHeader.getHeight(ug.getStringBounder()));
+ Instant last = null;
+ for (Map.Entry<Instant, Double> ent : pos.entrySet()) {
+ final double xcur = ent.getValue();
+ if (last == null || last.next(null).equals(ent.getKey())) {
+ ug = ug.apply(new UChangeColor(lightGray));
+ } else {
+ ug = ug.apply(new UChangeColor(HtmlColorUtils.BLACK));
+ }
+ ug.apply(new UTranslate(x + xcur, y)).draw(line);
+ last = ent.getKey();
+ }
+ }
+
+ public double getWidth(StringBounder stringBounder) {
+ return itemHeader.getWidth(stringBounder) + timeScale.getWidth(stringBounder) + 3;
+ }
+
+ public double getHeight(StringBounder stringBounder) {
+ return itemHeader.getHeight(stringBounder) + timeScale.getHeight(stringBounder) + 3;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/project/graphic/ItemHeader.java b/src/net/sourceforge/plantuml/project/graphic/ItemHeader.java
new file mode 100644
index 0000000..73ef1da
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project/graphic/ItemHeader.java
@@ -0,0 +1,116 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project.graphic;
+
+import java.awt.Font;
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.SpriteContainerEmpty;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.project.Item;
+import net.sourceforge.plantuml.project.Project;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class ItemHeader {
+
+ private final UFont font = new UFont("Serif", Font.PLAIN, 9);
+ private final Project project;
+ private final FontConfiguration fontConfig = new FontConfiguration(font, HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true);
+
+ public ItemHeader(Project project) {
+ this.project = project;
+ }
+
+ public void draw(UGraphic ug, double x, double y) {
+
+ final StringBounder stringBounder = ug.getStringBounder();
+
+ ug = ug.apply(new UChangeColor(HtmlColorUtils.BLACK));
+ ug.apply(new UTranslate(x, y)).draw(new URectangle(getWidth(stringBounder), getHeight(stringBounder)));
+
+ for (Item it : project.getValidItems()) {
+ final TextBlock b = TextBlockUtils.create(Display.create("" + it.getCode()), fontConfig,
+ HorizontalAlignment.LEFT, new SpriteContainerEmpty());
+ final Dimension2D dim = b.calculateDimension(stringBounder);
+ b.drawU(ug.apply(new UTranslate(x, y)));
+ y += dim.getHeight();
+ ug.apply(new UTranslate(x, y)).draw(new ULine(getWidth(stringBounder), 0));
+ }
+ }
+
+ public double getWidth(StringBounder stringBounder) {
+ double width = 0;
+ for (Item it : project.getValidItems()) {
+ final Dimension2D dim = stringBounder.calculateDimension(font, it.getCode());
+ width = Math.max(width, dim.getWidth());
+ }
+ return width;
+ }
+
+ public double getHeight(StringBounder stringBounder) {
+ double height = 0;
+ for (Item it : project.getValidItems()) {
+ final Dimension2D dim = stringBounder.calculateDimension(font, it.getCode());
+ height += dim.getHeight();
+
+ }
+ return height;
+ }
+
+ public double getPosition(StringBounder stringBounder, Item item) {
+ double pos = 0;
+ for (Item it : project.getValidItems()) {
+ if (it == item) {
+ return pos;
+ }
+ final Dimension2D dim = stringBounder.calculateDimension(font, it.getCode());
+ pos += dim.getHeight();
+
+ }
+ throw new IllegalArgumentException();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/project/graphic/TimeScale.java b/src/net/sourceforge/plantuml/project/graphic/TimeScale.java
new file mode 100644
index 0000000..743bcad
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project/graphic/TimeScale.java
@@ -0,0 +1,158 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project.graphic;
+
+import java.awt.Font;
+import java.awt.geom.Dimension2D;
+import java.util.Collections;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import net.sourceforge.plantuml.SpriteContainerEmpty;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.project.Day;
+import net.sourceforge.plantuml.project.Instant;
+import net.sourceforge.plantuml.project.Month;
+import net.sourceforge.plantuml.project.Project;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class TimeScale {
+
+ private final UFont font = new UFont("Serif", Font.PLAIN, 9);
+ private final Project project;
+ private final FontConfiguration fontConfig = new FontConfiguration(font, HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true);
+
+ public TimeScale(Project project) {
+ this.project = project;
+ }
+
+ public void draw(UGraphic ug, final double x, double y) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final double monthHeight = getMonthHeight(stringBounder);
+ final double caseWidth = getCaseWidth(stringBounder);
+ final double caseHeight = getCaseHeight(stringBounder);
+ final int nb = getNbCase();
+
+ ug = ug.apply(new UChangeColor(HtmlColorUtils.BLACK));
+ ug.apply(new UTranslate(x, y)).draw(new URectangle(nb * caseWidth, monthHeight));
+ final Instant end = project.getEnd();
+
+ Month printed = null;
+
+ double curx = x;
+ for (Instant cur = project.getStart(); cur.compareTo(end) <= 0; cur = cur.next(project.getDayClose())) {
+ final Day d = cur.getDay();
+ if (printed == null || d.getMonth() != printed) {
+ ug.apply(new UTranslate(curx, y)).draw(new ULine(0, monthHeight));
+ printed = d.getMonth();
+ final TextBlock b = TextBlockUtils.create(Display.create(printed.name()), fontConfig,
+ HorizontalAlignment.LEFT, new SpriteContainerEmpty());
+ final Dimension2D dim = b.calculateDimension(stringBounder);
+ b.drawU(ug.apply(new UTranslate(curx, (y + (monthHeight - dim.getHeight()) / 2))));
+ }
+ curx += caseWidth;
+ }
+
+ curx = x;
+ y += monthHeight;
+ ug.apply(new UTranslate(x, y)).draw(new URectangle(nb * caseWidth, caseHeight));
+
+ for (Instant cur = project.getStart(); cur.compareTo(end) <= 0; cur = cur.next(project.getDayClose())) {
+ final Day d = cur.getDay();
+ final TextBlock b = TextBlockUtils.create(Display.create("" + d.getNumDay()), fontConfig,
+ HorizontalAlignment.LEFT, new SpriteContainerEmpty());
+ final Dimension2D dim = b.calculateDimension(stringBounder);
+ b.drawU(ug.apply(new UTranslate((curx + (caseWidth - dim.getWidth()) / 2), (y + (caseHeight - dim.getHeight()) / 2))));
+ curx += caseWidth;
+ ug.apply(new UTranslate(curx, y)).draw(new ULine(0, caseHeight));
+ }
+ }
+
+ public SortedMap<Instant, Double> getAbscisse(StringBounder stringBounder) {
+ final SortedMap<Instant, Double> pos = new TreeMap<Instant, Double>();
+ final double caseWidth = getCaseWidth(stringBounder);
+ final Instant end = project.getEnd();
+ double x = 0;
+ for (Instant cur = project.getStart(); cur.compareTo(end) <= 0; cur = cur.next(project.getDayClose())) {
+ pos.put(cur, x);
+ x += caseWidth;
+ }
+ return Collections.unmodifiableSortedMap(pos);
+ }
+
+ private int getNbCase() {
+ int result = 0;
+ final Instant end = project.getEnd();
+ for (Instant cur = project.getStart(); cur.compareTo(end) <= 0; cur = cur.next(project.getDayClose())) {
+ result++;
+ }
+ return result;
+ }
+
+ private double getCaseWidth(StringBounder stringBounder) {
+ final Dimension2D dim00 = stringBounder.calculateDimension(font, "00");
+ return dim00.getWidth() + 3;
+ }
+
+ private double getCaseHeight(StringBounder stringBounder) {
+ final Dimension2D dim00 = stringBounder.calculateDimension(font, "00");
+ return dim00.getHeight() + 3;
+ }
+
+ private double getMonthHeight(StringBounder stringBounder) {
+ final Dimension2D dimZZ = stringBounder.calculateDimension(font, "ZZ");
+ return dimZZ.getHeight() + 3;
+ }
+
+ public double getWidth(StringBounder stringBounder) {
+ return getCaseWidth(stringBounder) * getNbCase();
+ }
+
+ public double getHeight(StringBounder stringBounder) {
+ return getCaseHeight(stringBounder) + getMonthHeight(stringBounder);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/project2/Day.java b/src/net/sourceforge/plantuml/project2/Day.java
new file mode 100644
index 0000000..2d1ab04
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project2/Day.java
@@ -0,0 +1,170 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project2;
+
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.SimpleTimeZone;
+
+import net.sourceforge.plantuml.project.Month;
+import net.sourceforge.plantuml.project.WeekDay;
+
+public class Day implements TimeElement {
+
+ private final int numDay;
+ private final Month month;
+ private final int year;
+ private final WeekDay weekDay;
+
+ private Day(int year, Month month, int numDay, WeekDay weekDay) {
+ this.year = year;
+ this.month = month;
+ this.numDay = numDay;
+ this.weekDay = weekDay;
+ }
+
+ public static boolean isValidDesc(String desc) {
+ if (desc.matches("^\\d{4}/\\d{2}/\\d{2}$")) {
+ return true;
+ }
+ if (desc.matches("^\\d{2}-[A-Za-z]{3}-\\d{4}$")) {
+ return true;
+ }
+ return false;
+ }
+
+ public Day(String desc) {
+ if (desc.matches("^\\d{4}/\\d{2}/\\d{2}$")) {
+ this.year = Integer.parseInt(desc.substring(0, 4));
+ this.month = Month.fromNum(Integer.parseInt(desc.substring(5, 7)));
+ this.numDay = Integer.parseInt(desc.substring(8, 10));
+ } else if (desc.matches("^\\d{2}-[A-Za-z]{3}-\\d{4}$")) {
+ this.year = Integer.parseInt(desc.substring(7, 11));
+ this.month = Month.valueOf(desc.substring(3, 6));
+ this.numDay = Integer.parseInt(desc.substring(0, 2));
+ } else {
+ throw new IllegalArgumentException(desc);
+ }
+ final int wd = new GregorianCalendar(year, month.getNum() - 1, numDay).get(Calendar.DAY_OF_WEEK);
+ this.weekDay = WeekDay.values()[wd - 1];
+ }
+
+ public Day next() {
+ if (numDay < month.getNbDays(year)) {
+ return new Day(year, month, numDay + 1, weekDay.next());
+ }
+ final Month next = month.next();
+ if (next == null) {
+ return new Day(year + 1, Month.JAN, 1, weekDay.next());
+ }
+ return new Day(year, next, 1, weekDay.next());
+ }
+
+ public Day previous() {
+ if (numDay > 1) {
+ return new Day(year, month, numDay - 1, weekDay.prev());
+ }
+ final Month prev = month.prev();
+ if (prev == null) {
+ return new Day(year - 1, Month.DEC, 31, weekDay.prev());
+ }
+ return new Day(year, prev, prev.getNbDays(year), weekDay.prev());
+ }
+
+ @Override
+ public String toString() {
+ return "" + weekDay + " " + year + "-" + month + "-" + String.format("%02d", numDay);
+ }
+
+ public final int getNumDay() {
+ return numDay;
+ }
+
+ public final Month getMonth() {
+ return month;
+ }
+
+ public final int getYear() {
+ return year;
+ }
+
+ public int compareTo(TimeElement other2) {
+ final Day other = (Day) other2;
+ if (year > other.year) {
+ return 1;
+ }
+ if (year < other.year) {
+ return -1;
+ }
+ final int cmpMonth = month.compareTo(other.month);
+ if (cmpMonth != 0) {
+ return cmpMonth;
+ }
+ return numDay - other.numDay;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ final Day this2 = (Day) obj;
+ return this.numDay == this2.numDay && this.month == this2.month && this.year == this2.year;
+ }
+
+ @Override
+ public int hashCode() {
+ return numDay * 420 + year + month.hashCode();
+ }
+
+ public final WeekDay getWeekDay() {
+ return weekDay;
+ }
+
+ public long getTypicalDuration() {
+ return 1000L * 60 * 60 * 24;
+ }
+
+ public long getStartUTC() {
+ final GregorianCalendar cal = new GregorianCalendar(new SimpleTimeZone(0, "GMT"));
+ cal.setTimeInMillis(0);
+ cal.set(GregorianCalendar.YEAR, year);
+ cal.set(GregorianCalendar.MONTH, month.getNumNormal());
+ cal.set(GregorianCalendar.DAY_OF_MONTH, numDay);
+ return cal.getTimeInMillis();
+ }
+
+ public long getEndUTC() {
+ return next().getStartUTC();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/project2/GanttDiagram2.java b/src/net/sourceforge/plantuml/project2/GanttDiagram2.java
new file mode 100644
index 0000000..4a624ae
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project2/GanttDiagram2.java
@@ -0,0 +1,111 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project2;
+
+import java.awt.Font;
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.SpriteContainerEmpty;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class GanttDiagram2 {
+
+ private final Project2 project;
+ private final double dayWith = 20;
+
+ public GanttDiagram2(Project2 project) {
+ this.project = project;
+ }
+
+ private final UFont font = new UFont("Serif", Font.PLAIN, 9);
+ private final FontConfiguration fontConfig = new FontConfiguration(font, HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true);
+
+ public void draw(UGraphic ug, double x, double y) {
+
+ final TextBlock timeHeader = project.getTimeHeader(dayWith);
+ final Row row = getMainRow();
+ final TextBlock headers = row.header();
+
+ final double deltaX = headers.calculateDimension(ug.getStringBounder()).getWidth();
+ final double deltaY = timeHeader.calculateDimension(ug.getStringBounder()).getHeight();
+
+ headers.drawU(ug.apply(new UTranslate(x, (y + deltaY))));
+ final TextBlock tbRow = row.asTextBloc(project.getTimeConverter(dayWith));
+ tbRow.drawU(ug.apply(new UTranslate((x + deltaX), (y + deltaY))));
+
+ timeHeader.drawU(ug.apply(new UTranslate((x + deltaX), y)));
+ }
+
+ private Row getMainRow() {
+ final List<Task> tasks = project.getTasks();
+ final List<Row> rows = new ArrayList<Row>();
+ for (Task t : tasks) {
+ final String text = t.getCode();
+ final TextBlock label = TextBlockUtils.create(Display.create(text), fontConfig, HorizontalAlignment.LEFT,
+ new SpriteContainerEmpty());
+ rows.add(new RowSimple((Day) t.getStart(), (Day) t.getEnd(), HtmlColorUtils.BLACK, TextBlockUtils
+ .withMargin(label, 3, 3)));
+ }
+ final Row row = RowUtils.merge(rows);
+ return row;
+ }
+
+ public double getWidth(StringBounder stringBounder) {
+ final TextBlock timeHeader = project.getTimeHeader(dayWith);
+ final Row row = getMainRow();
+ final TextBlock headers = row.header();
+ return headers.calculateDimension(stringBounder).getWidth()
+ + timeHeader.calculateDimension(stringBounder).getWidth() + 1;
+ }
+
+ public double getHeight(StringBounder stringBounder) {
+ final TextBlock timeHeader = project.getTimeHeader(dayWith);
+ final Row row = getMainRow();
+ final TextBlock headers = row.header();
+ return headers.calculateDimension(stringBounder).getHeight()
+ + timeHeader.calculateDimension(stringBounder).getHeight();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/project2/Knowledge.java b/src/net/sourceforge/plantuml/project2/Knowledge.java
new file mode 100644
index 0000000..f5ecc6e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project2/Knowledge.java
@@ -0,0 +1,115 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project2;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class Knowledge {
+
+ private final TaskContainer taskContainer;
+ private final TimeLine timeline;
+ private final Map<String, Value> variables = new HashMap<String, Value>();
+
+ public Knowledge(TaskContainer taskContainer, TimeLine timeline) {
+ this.taskContainer = taskContainer;
+ this.timeline = timeline;
+ }
+
+ public Value evaluate(String exp) {
+ exp = exp.trim();
+ int idx = exp.indexOf('$');
+ if (idx != -1) {
+ return evaluate(exp.substring(0, idx), exp.substring(idx + 1));
+ }
+ if (exp.matches("\\d+")) {
+ return new ValueInt(Integer.parseInt(exp));
+ }
+ if (Day.isValidDesc(exp)) {
+ final Day day = new Day(exp);
+ return new ValueTime(day);
+ }
+ if (exp.startsWith("^")) {
+ exp = exp.substring(1);
+ }
+ if (variables.containsKey(exp)) {
+ return variables.get(exp);
+ }
+ idx = exp.indexOf("+");
+ if (idx != -1) {
+ return plus(exp.substring(0, idx), exp.substring(idx + 1));
+ }
+ throw new UnsupportedOperationException(exp);
+
+ }
+
+ private Value plus(String arg1, String arg2) {
+ final Value v1 = evaluate(arg1);
+ final Value v2 = evaluate(arg2);
+ if (v1 instanceof ValueInt && v2 instanceof ValueInt) {
+ return new ValueInt(((ValueInt) v1).getValue() + ((ValueInt) v2).getValue());
+ }
+ if (v1 instanceof ValueTime && v2 instanceof ValueInt) {
+ final int nb = ((ValueInt) v2).getValue();
+ TimeElement t = ((ValueTime) v1).getValue();
+ if (nb > 0) {
+ for (int i = 0; i < nb; i++) {
+ t = timeline.next(t);
+ }
+ }
+ if (nb < 0) {
+ for (int i = 0; i < -nb; i++) {
+ t = timeline.previous(t);
+ }
+ }
+ return new ValueTime(t);
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ private Value evaluate(String task, String attribute) {
+ final Task t = taskContainer.getTask(task);
+ final TaskAttribute att = TaskAttribute.fromString(attribute);
+ if (att == TaskAttribute.COMPLETED) {
+ return new ValueTime(t.getCompleted());
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ public void set(String var, Value exp) {
+ variables.put(var, exp);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/project2/PSystemProject2.java b/src/net/sourceforge/plantuml/project2/PSystemProject2.java
new file mode 100644
index 0000000..ba63f6d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project2/PSystemProject2.java
@@ -0,0 +1,123 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project2;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.EmptyImageBuilder;
+import net.sourceforge.plantuml.FileFormat;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.api.ImageDataSimple;
+import net.sourceforge.plantuml.core.DiagramDescription;
+import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.eps.EpsStrategy;
+import net.sourceforge.plantuml.png.PngIO;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+import net.sourceforge.plantuml.ugraphic.eps.UGraphicEps;
+import net.sourceforge.plantuml.ugraphic.g2d.UGraphicG2d;
+import net.sourceforge.plantuml.ugraphic.svg.UGraphicSvg;
+import net.sourceforge.plantuml.StringUtils;
+
+public class PSystemProject2 extends AbstractPSystem {
+
+ private final Project2 project = new Project2();
+ private final Color background = Color.WHITE;
+ private final ColorMapper colorMapper = new ColorMapperIdentity();
+
+ public int getNbImages() {
+ return 1;
+ }
+
+ public DiagramDescription getDescription() {
+ return new DiagramDescriptionImpl("(Project)", getClass());
+ }
+
+ public ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormatOption) throws IOException {
+ final GanttDiagram2 diagram = new GanttDiagram2(project);
+ final FileFormat fileFormat = fileFormatOption.getFileFormat();
+ if (fileFormat == FileFormat.PNG) {
+ final BufferedImage im = createImage(diagram);
+ PngIO.write(im, os, fileFormatOption.isWithMetadata() ? getMetadata() : null, 96);
+ } else if (fileFormat == FileFormat.SVG) {
+ final UGraphicSvg svg = new UGraphicSvg(colorMapper, StringUtils.getAsHtml(background), false, 1.0);
+ diagram.draw(svg, 0, 0);
+ svg.createXml(os);
+ } else if (fileFormat == FileFormat.EPS) {
+ final UGraphicEps eps = new UGraphicEps(colorMapper, EpsStrategy.getDefault2());
+ diagram.draw(eps, 0, 0);
+ os.write(eps.getEPSCode().getBytes());
+ } else if (fileFormat == FileFormat.EPS_TEXT) {
+ final UGraphicEps eps = new UGraphicEps(colorMapper, EpsStrategy.WITH_MACRO_AND_TEXT);
+ diagram.draw(eps, 0, 0);
+ os.write(eps.getEPSCode().getBytes());
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ return new ImageDataSimple();
+ }
+
+ private BufferedImage createImage(GanttDiagram2 diagram) {
+ EmptyImageBuilder builder = new EmptyImageBuilder(10, 10, background);
+ Graphics2D g2d = builder.getGraphics2D();
+ UGraphicG2d ug = new UGraphicG2d(colorMapper, g2d, 1.0);
+
+ final double height = diagram.getHeight(ug.getStringBounder());
+ final double width = diagram.getWidth(ug.getStringBounder());
+
+ g2d.dispose();
+
+ builder = new EmptyImageBuilder(width, height, background);
+ final BufferedImage im = builder.getBufferedImage();
+ g2d = builder.getGraphics2D();
+
+ ug = new UGraphicG2d(colorMapper, g2d, 1.0);
+ ug.setBufferedImage(im);
+ diagram.draw(ug, 0, 0);
+ g2d.dispose();
+ return im;
+ }
+
+ public final Project2 getProject() {
+ return project;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/project2/PSystemProjectFactory2.java b/src/net/sourceforge/plantuml/project2/PSystemProjectFactory2.java
new file mode 100644
index 0000000..298a3a2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project2/PSystemProjectFactory2.java
@@ -0,0 +1,71 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project2;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.command.Command;
+import net.sourceforge.plantuml.command.CommandComment;
+import net.sourceforge.plantuml.command.CommandMultilinesComment;
+import net.sourceforge.plantuml.command.CommandNope;
+import net.sourceforge.plantuml.command.UmlDiagramFactory;
+import net.sourceforge.plantuml.core.DiagramType;
+import net.sourceforge.plantuml.project2.command.CommandAffectation;
+import net.sourceforge.plantuml.project2.command.CommandCloseWeekDay;
+
+public class PSystemProjectFactory2 extends UmlDiagramFactory {
+
+ public PSystemProjectFactory2() {
+ super(DiagramType.PROJECT);
+ }
+
+ @Override
+ protected List<Command> createCommands() {
+ final List<Command> cmds = new ArrayList<Command>();
+ cmds.add(new CommandNope());
+ cmds.add(new CommandComment());
+ cmds.add(new CommandMultilinesComment());
+ cmds.add(new CommandAffectation());
+ cmds.add(new CommandCloseWeekDay());
+ return cmds;
+ }
+
+ @Override
+ public PSystemProject2 createEmptyDiagram() {
+ return new PSystemProject2();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/project2/Project2.java b/src/net/sourceforge/plantuml/project2/Project2.java
new file mode 100644
index 0000000..b7a2210
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project2/Project2.java
@@ -0,0 +1,165 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project2;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+
+public class Project2 implements TaskContainer {
+
+ private final TimeLine timeline;
+ private final Knowledge knowledge;
+ private final List<TaskImpl> tasks = new ArrayList<TaskImpl>();
+
+ public Project2() {
+ this.timeline = new TimeLineDay();
+ this.knowledge = new Knowledge(this, timeline);
+ }
+
+ public TimeConverter getTimeConverter(double dayWith) {
+ return new TimeConverterDay(timeline, getStart(), dayWith);
+ }
+
+ public Value getExpression(String exp) {
+ return knowledge.evaluate(exp);
+ }
+
+ public boolean affectation(String var, Value exp) {
+ final int idx = var.indexOf('$');
+ if (idx != -1) {
+ return affectationTask(var.substring(0, idx), var.substring(idx + 1), exp);
+ }
+ if (var.startsWith("^")) {
+ return affectationJalon(var.substring(1), exp);
+ }
+ knowledge.set(var, exp);
+ return true;
+ }
+
+ private boolean affectationJalon(String taskCode, Value exp) {
+ final TaskImpl result = new TaskImpl(timeline, taskCode);
+ result.setStart(((ValueTime) exp).getValue());
+ result.setDuration(0);
+ tasks.add(result);
+ knowledge.set(taskCode, exp);
+ return true;
+ }
+
+ private boolean affectationTask(String taskCode, String attribute, Value exp) {
+ final TaskImpl t = getOrCreateTask(taskCode);
+ final TaskAttribute att = TaskAttribute.fromString(attribute);
+ if (att == TaskAttribute.START) {
+ t.setStart(((ValueTime) exp).getValue());
+ return true;
+ }
+ if (att == TaskAttribute.DURATION) {
+ t.setDuration(((ValueInt) exp).getValue());
+ return true;
+ }
+ if (att == TaskAttribute.LOAD) {
+ t.setLoad(((ValueInt) exp).getValue());
+ return true;
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ private TaskImpl getOrCreateTask(String taskCode) {
+ TaskImpl result = (TaskImpl) getTask(taskCode);
+ if (result != null) {
+ return result;
+ }
+ result = new TaskImpl(timeline, taskCode);
+ tasks.add(result);
+ return result;
+ }
+
+ public final List<Task> getTasks() {
+ final List<Task> result = new ArrayList<Task>(tasks);
+ return Collections.unmodifiableList(result);
+ }
+
+ public Task getTask(String code) {
+ for (TaskImpl t : tasks) {
+ if (t.getCode().equals(code)) {
+ return t;
+ }
+ }
+ Task result = null;
+ for (Task t : tasks) {
+ if (t.getCode().startsWith(code) == false) {
+ continue;
+ }
+ if (result == null) {
+ result = t;
+ } else {
+ result = new TaskMerge(result.getCode(), result.getName(), result, t);
+ }
+
+ }
+ return result;
+ }
+
+ public TextBlock getTimeHeader(double dayWith) {
+ final TimeHeaderDay day = new TimeHeaderDay(getStart(), getEnd(), timeline, dayWith);
+ final TimeHeaderMonth month = new TimeHeaderMonth(getStart(), getEnd(), timeline, dayWith);
+ return TextBlockUtils.mergeTB(month, day, HorizontalAlignment.CENTER);
+ }
+
+ private Day getStart() {
+ Day result = null;
+ for (Task t : tasks) {
+ if (result == null || result.compareTo(t.getStart()) > 0) {
+ result = (Day) t.getStart();
+ }
+ }
+ return result;
+ }
+
+ private Day getEnd() {
+ Day result = null;
+ for (Task t : tasks) {
+ if (result == null || result.compareTo(t.getEnd()) < 0) {
+ result = (Day) t.getEnd();
+ }
+ }
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/project2/Ressource.java b/src/net/sourceforge/plantuml/project2/Ressource.java
new file mode 100644
index 0000000..4cd9414
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project2/Ressource.java
@@ -0,0 +1,45 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project2;
+
+public class Ressource {
+
+ private final String code;
+
+ public Ressource(String code) {
+ this.code = code;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/project2/Row.java b/src/net/sourceforge/plantuml/project2/Row.java
new file mode 100644
index 0000000..db2bc63
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project2/Row.java
@@ -0,0 +1,51 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project2;
+
+import net.sourceforge.plantuml.graphic.TextBlock;
+
+public interface Row {
+
+ public TextBlock asTextBloc(TimeConverter timeConverter);
+
+ public double getMinXwithoutHeader(TimeConverter timeConverter);
+
+ public double getMaxXwithoutHeader(TimeConverter timeConverter);
+
+ public TextBlock header();
+
+ public double getHeight();
+
+}
diff --git a/src/net/sourceforge/plantuml/project2/RowMerge.java b/src/net/sourceforge/plantuml/project2/RowMerge.java
new file mode 100644
index 0000000..3cb125e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project2/RowMerge.java
@@ -0,0 +1,100 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project2;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class RowMerge implements Row {
+
+ private final Row r1;
+ private final Row r2;
+
+ public RowMerge(Row r1, Row r2) {
+ this.r1 = r1;
+ this.r2 = r2;
+ }
+
+ public TextBlock asTextBloc(final TimeConverter timeConverter) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ r1.asTextBloc(timeConverter).drawU(ug);
+ r2.asTextBloc(timeConverter).drawU(ug.apply(new UTranslate(0, r1.getHeight())));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final double width = getMaxXwithoutHeader(timeConverter) - getMinXwithoutHeader(timeConverter);
+ final double height = getHeight();
+ return new Dimension2DDouble(width, height);
+ }
+ };
+ }
+
+ public double getMinXwithoutHeader(TimeConverter timeConverter) {
+ return Math.min(r1.getMinXwithoutHeader(timeConverter), r2.getMinXwithoutHeader(timeConverter));
+ }
+
+ public double getMaxXwithoutHeader(TimeConverter timeConverter) {
+ return Math.max(r1.getMaxXwithoutHeader(timeConverter), r2.getMaxXwithoutHeader(timeConverter));
+ }
+
+ public double getHeight() {
+ return r1.getHeight() + r2.getHeight();
+ }
+
+ public TextBlock header() {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ r1.header().drawU(ug);
+ r2.header().drawU(ug.apply(new UTranslate(0, r1.getHeight())));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final double width = Math.max(r1.header().calculateDimension(stringBounder).getWidth(), r2.header()
+ .calculateDimension(stringBounder).getWidth());
+ final double height = getHeight();
+ return new Dimension2DDouble(width, height);
+ }
+ };
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/project2/RowOverwrite.java b/src/net/sourceforge/plantuml/project2/RowOverwrite.java
new file mode 100644
index 0000000..8e85735
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project2/RowOverwrite.java
@@ -0,0 +1,90 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project2;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class RowOverwrite implements Row {
+
+ private final Row r1;
+ private final Row r2;
+
+ public RowOverwrite(Row r1, Row r2) {
+ this.r1 = r1;
+ this.r2 = r2;
+ }
+
+ public TextBlock asTextBloc(final TimeConverter timeConverter) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final double minX = getMinXwithoutHeader(timeConverter);
+ final double minXr1 = r1.getMinXwithoutHeader(timeConverter);
+ final double minXr2 = r2.getMinXwithoutHeader(timeConverter);
+ r1.asTextBloc(timeConverter).drawU(ug.apply(new UTranslate((minXr1 - minX), 0)));
+ r2.asTextBloc(timeConverter).drawU(ug.apply(new UTranslate((minXr2 - minX), 0)));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final double width = getMaxXwithoutHeader(timeConverter) - getMinXwithoutHeader(timeConverter);
+ final double height = getHeight();
+ return new Dimension2DDouble(width, height);
+ }
+ };
+ }
+
+ public double getMinXwithoutHeader(TimeConverter timeConverter) {
+ return Math.min(r1.getMinXwithoutHeader(timeConverter), r2.getMinXwithoutHeader(timeConverter));
+ }
+
+ public double getMaxXwithoutHeader(TimeConverter timeConverter) {
+ return Math.max(r1.getMaxXwithoutHeader(timeConverter), r2.getMaxXwithoutHeader(timeConverter));
+ }
+
+ public double getHeight() {
+ return Math.max(r1.getHeight(), r2.getHeight());
+ }
+
+ public TextBlock header() {
+ return r1.header();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/project2/RowSimple.java b/src/net/sourceforge/plantuml/project2/RowSimple.java
new file mode 100644
index 0000000..6a5275d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project2/RowSimple.java
@@ -0,0 +1,112 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project2;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class RowSimple implements Row {
+
+ private static final int HEIGHT = 12;
+ private final Day first;
+ private final Day last;
+ private final HtmlColor backcolor;
+ private final TextBlock header;
+
+ public RowSimple(Day first, Day last) {
+ this(first, last, HtmlColorUtils.BLACK);
+ }
+
+ public RowSimple(Day first, Day last, HtmlColor backcolor) {
+ this(first, last, backcolor, TextBlockUtils.empty(0, HEIGHT));
+ }
+
+ public RowSimple(Day first, Day last, HtmlColor backcolor, TextBlock header) {
+ this.first = first;
+ this.last = last;
+ this.backcolor = backcolor;
+ if (last.compareTo(first) < 0) {
+ throw new IllegalArgumentException();
+ }
+ this.header = header;
+ }
+
+ public TextBlock asTextBloc(final TimeConverter timeConverter) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final double x1 = getMinXwithoutHeader(timeConverter) + 1;
+ final double x2 = getMaxXwithoutHeader(timeConverter) - 1;
+ final double height = getHeight() - 4;
+ final UShape rect = new URectangle(x2 - x1, height, 4, 4);
+ ug.apply(new UChangeColor(HtmlColorUtils.RED)).apply(new UChangeBackColor(backcolor)).apply(new UTranslate(x1, 2)).draw(rect);
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final double width = getMaxXwithoutHeader(timeConverter) - getMinXwithoutHeader(timeConverter);
+ final double height = getHeight();
+ return new Dimension2DDouble(width, height);
+ }
+ };
+ }
+
+ public double getMinXwithoutHeader(TimeConverter timeConverter) {
+ return timeConverter.getStartPosition(first);
+ }
+
+ public double getMaxXwithoutHeader(TimeConverter timeConverter) {
+ return timeConverter.getEndPosition(last);
+ }
+
+ public double getHeight() {
+ return HEIGHT;
+ }
+
+ public TextBlock header() {
+ return header;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/project2/RowUtils.java b/src/net/sourceforge/plantuml/project2/RowUtils.java
new file mode 100644
index 0000000..ffa92f9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project2/RowUtils.java
@@ -0,0 +1,58 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project2;
+
+import java.util.List;
+
+public abstract class RowUtils {
+
+ public static Row overwrite(Row r1, Row r2) {
+ return new RowOverwrite(r1, r2);
+ }
+
+ public static Row merge(Row r1, Row r2) {
+ return new RowMerge(r1, r2);
+ }
+
+ public static Row merge(List<Row> rows) {
+ Row result = rows.get(0);
+ for (int i = 1; i < rows.size(); i++) {
+ result = merge(result, rows.get(i));
+ }
+ return result;
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/project2/Task.java b/src/net/sourceforge/plantuml/project2/Task.java
new file mode 100644
index 0000000..063489f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project2/Task.java
@@ -0,0 +1,51 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project2;
+
+public interface Task {
+
+ public String getCode();
+
+ public String getName();
+
+ public long getLoad();
+
+ public TimeElement getStart();
+
+ public TimeElement getEnd();
+
+ public TimeElement getCompleted();
+
+}
diff --git a/src/net/sourceforge/plantuml/project2/TaskAttribute.java b/src/net/sourceforge/plantuml/project2/TaskAttribute.java
new file mode 100644
index 0000000..12c0b04
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project2/TaskAttribute.java
@@ -0,0 +1,63 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project2;
+
+public enum TaskAttribute {
+
+ START, END, COMPLETED, DURATION, LOAD;
+
+ static public TaskAttribute fromString(String n) {
+ if (n.equalsIgnoreCase("begin")) {
+ return START;
+ }
+ if (n.equalsIgnoreCase("start")) {
+ return START;
+ }
+ if (n.equalsIgnoreCase("work")) {
+ return LOAD;
+ }
+ if (n.equalsIgnoreCase("load")) {
+ return LOAD;
+ }
+ if (n.equalsIgnoreCase("duration")) {
+ return DURATION;
+ }
+ if (n.equalsIgnoreCase("completed")) {
+ return COMPLETED;
+ }
+ return null;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/project2/TaskContainer.java b/src/net/sourceforge/plantuml/project2/TaskContainer.java
new file mode 100644
index 0000000..9189d0a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project2/TaskContainer.java
@@ -0,0 +1,41 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project2;
+
+public interface TaskContainer {
+
+ public Task getTask(String code);
+
+}
diff --git a/src/net/sourceforge/plantuml/project2/TaskImpl.java b/src/net/sourceforge/plantuml/project2/TaskImpl.java
new file mode 100644
index 0000000..8c576b6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project2/TaskImpl.java
@@ -0,0 +1,89 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project2;
+
+public class TaskImpl implements Task {
+
+ private final String code;
+ private TimeElement start;
+ private TimeElement end;
+ private int duration;
+ private final TimeLine timeLine;
+
+ public TaskImpl(TimeLine timeLine, String code) {
+ this.code = code;
+ this.timeLine = timeLine;
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public String getName() {
+ return code;
+ }
+
+ public long getLoad() {
+ throw new UnsupportedOperationException();
+ }
+
+ public TimeElement getStart() {
+ return start;
+ }
+
+ public TimeElement getEnd() {
+ TimeElement result = start;
+ for (int i = 1; i < duration; i++) {
+ result = timeLine.next(result);
+ }
+ return result;
+ }
+
+ public TimeElement getCompleted() {
+ return timeLine.next(getEnd());
+ }
+
+ public void setStart(TimeElement exp) {
+ this.start = exp;
+ }
+
+ public void setDuration(int value) {
+ this.duration = value;
+ }
+
+ public void setLoad(int value) {
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/project2/TaskMerge.java b/src/net/sourceforge/plantuml/project2/TaskMerge.java
new file mode 100644
index 0000000..d2fbd8c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project2/TaskMerge.java
@@ -0,0 +1,75 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project2;
+
+class TaskMerge implements Task {
+
+ private final String code;
+ private final String name;
+ private final Task task1;
+ private final Task task2;
+
+ TaskMerge(String code, String name, Task task1, Task task2) {
+ this.code = code;
+ this.name = name;
+ this.task1 = task1;
+ this.task2 = task2;
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public long getLoad() {
+ throw new UnsupportedOperationException();
+ }
+
+ public TimeElement getStart() {
+ return TimeUtils.min(task1.getStart(), task2.getStart());
+ }
+
+ public TimeElement getEnd() {
+ return TimeUtils.max(task1.getEnd(), task2.getEnd());
+ }
+
+ public TimeElement getCompleted() {
+ return TimeUtils.max(task1.getCompleted(), task2.getCompleted());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/project2/TimeConverter.java b/src/net/sourceforge/plantuml/project2/TimeConverter.java
new file mode 100644
index 0000000..9008d42
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project2/TimeConverter.java
@@ -0,0 +1,45 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project2;
+
+public interface TimeConverter {
+
+ public TimeElement getCorrespondingElement(long position);
+
+ public double getStartPosition(TimeElement timeElement);
+
+ public double getEndPosition(TimeElement timeElement);
+
+}
diff --git a/src/net/sourceforge/plantuml/project2/TimeConverterDay.java b/src/net/sourceforge/plantuml/project2/TimeConverterDay.java
new file mode 100644
index 0000000..951bf00
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project2/TimeConverterDay.java
@@ -0,0 +1,111 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project2;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class TimeConverterDay implements TimeConverter {
+
+ private Day biggest;
+ private Day smallest;
+ private final double dayWith;
+ private final Map<Day, Integer> map1 = new HashMap<Day, Integer>();
+ private final Map<Integer, Day> map2 = new HashMap<Integer, Day>();
+ private final TimeLine timeLine;
+
+ public TimeConverterDay(TimeLine timeLine, Day start, double dayWith) {
+ this.timeLine = timeLine;
+ this.dayWith = dayWith;
+ this.biggest = start;
+ this.smallest = start;
+ putDay(start, 0);
+ }
+
+// private boolean isClosed(Day d) {
+// WeekDay wd = d.getWeekDay();
+// if (wd == WeekDay.SAT || wd == WeekDay.SUN) {
+// return true;
+// }
+// return false;
+// }
+
+ private int getPosition(Day d) {
+ Integer result = map1.get(d);
+ if (result != null) {
+ return result.intValue();
+ }
+ while (d.compareTo(biggest) > 0) {
+ int n = getPosition(biggest);
+ biggest = biggest.next();
+ if (timeLine.isClosed(biggest) == false) {
+ n++;
+ }
+ putDay(biggest, n);
+ }
+ while (d.compareTo(smallest) < 0) {
+ int n = getPosition(smallest);
+ smallest = smallest.previous();
+ if (timeLine.isClosed(smallest) == false) {
+ n--;
+ }
+ putDay(smallest, n);
+ }
+ result = map1.get(d);
+ if (result != null) {
+ return result.intValue();
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ private void putDay(Day d, int n) {
+ map1.put(d, n);
+ map2.put(n, d);
+
+ }
+
+ public Day getCorrespondingElement(long position) {
+ throw new UnsupportedOperationException();
+ }
+
+ public double getStartPosition(TimeElement timeElement) {
+ return getPosition((Day) timeElement) * dayWith;
+ }
+
+ public double getEndPosition(TimeElement timeElement) {
+ return (getPosition((Day) timeElement) + 1) * dayWith;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/project2/TimeElement.java b/src/net/sourceforge/plantuml/project2/TimeElement.java
new file mode 100644
index 0000000..e3a7696
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project2/TimeElement.java
@@ -0,0 +1,49 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project2;
+
+public interface TimeElement extends Comparable<TimeElement> {
+
+ public long getTypicalDuration();
+
+ public long getStartUTC();
+
+ public long getEndUTC();
+
+ public TimeElement next();
+
+ public TimeElement previous();
+
+}
diff --git a/src/net/sourceforge/plantuml/project2/TimeHeaderDay.java b/src/net/sourceforge/plantuml/project2/TimeHeaderDay.java
new file mode 100644
index 0000000..f3c3cc1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project2/TimeHeaderDay.java
@@ -0,0 +1,101 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project2;
+
+import java.awt.Font;
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.SpriteContainerEmpty;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class TimeHeaderDay implements TextBlock {
+
+ private final Day start;
+ private final Day end;
+ private final TimeLine timeline;
+ private final double dayWidth;
+
+ private final UFont font = new UFont("Serif", Font.PLAIN, 9);
+ private final FontConfiguration fontConfig = new FontConfiguration(font, HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true);
+
+ public TimeHeaderDay(Day start, Day end, TimeLine timeline, double dayWidth) {
+ this.start = start;
+ this.end = end;
+ this.timeline = timeline;
+ this.dayWidth = dayWidth;
+ }
+
+ public void drawU(UGraphic ug) {
+ int n = 0;
+ for (Day d = start; d.compareTo(end) <= 0; d = (Day) timeline.next(d)) {
+ final String text = "" + d.getNumDay();
+ final TextBlock b = TextBlockUtils.create(Display.create(text), fontConfig, HorizontalAlignment.LEFT,
+ new SpriteContainerEmpty());
+ final Dimension2D dimText = b.calculateDimension(ug.getStringBounder());
+ final double diffX = dayWidth - dimText.getWidth();
+ final double diffY = getHeight() - dimText.getHeight();
+ ug = ug.apply(new UChangeColor(HtmlColorUtils.BLACK));
+ ug = ug.apply(new UChangeBackColor(HtmlColorUtils.WHITE));
+ ug.apply(new UTranslate(n * dayWidth, 0)).draw(new URectangle(dayWidth, getHeight()));
+ b.drawU(ug.apply(new UTranslate((n * dayWidth + diffX / 2), (diffY / 2))));
+ n++;
+ }
+ }
+
+ private double getHeight() {
+ return 20;
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ int n = 0;
+ for (Day d = start; d.compareTo(end) <= 0; d = (Day) timeline.next(d)) {
+ n++;
+ }
+ return new Dimension2DDouble(n * dayWidth, getHeight());
+ }
+}
diff --git a/src/net/sourceforge/plantuml/project2/TimeHeaderMonth.java b/src/net/sourceforge/plantuml/project2/TimeHeaderMonth.java
new file mode 100644
index 0000000..dedc7e3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project2/TimeHeaderMonth.java
@@ -0,0 +1,118 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project2;
+
+import java.awt.Font;
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.SpriteContainerEmpty;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class TimeHeaderMonth implements TextBlock {
+
+ private final Day start;
+ private final Day end;
+ private final TimeLine timeline;
+ private final double dayWidth;
+
+ private final UFont font = new UFont("Serif", Font.PLAIN, 9);
+ private final FontConfiguration fontConfig = new FontConfiguration(font, HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true);
+
+ public TimeHeaderMonth(Day start, Day end, TimeLine timeline, double dayWidth) {
+ this.start = start;
+ this.end = end;
+ this.timeline = timeline;
+ this.dayWidth = dayWidth;
+ }
+
+ public void drawU(UGraphic ug) {
+ int n = 0;
+ String last = null;
+
+ double pendingX = -1;
+ for (Day d = start; d.compareTo(end) <= 0; d = (Day) timeline.next(d)) {
+ final String text = "" + d.getMonth().name();
+ if (pendingX == -1) {
+ pendingX = n * dayWidth;
+ last = text;
+ }
+ ug = ug.apply(new UChangeColor(HtmlColorUtils.BLACK));
+ ug = ug.apply(new UChangeBackColor(HtmlColorUtils.WHITE));
+ if (text.equals(last) == false) {
+ manage(ug, 0, 0, n, last, pendingX);
+ pendingX = n * dayWidth;
+ }
+ last = text;
+ n++;
+ }
+ manage(ug, 0, 0, n, last, pendingX);
+ }
+
+ private void manage(UGraphic ug, double x, double y, int n, String last, double pendingX) {
+ final double width = n * dayWidth - pendingX;
+ ug.apply(new UTranslate(x + pendingX, y)).draw(new URectangle(width, getHeight()));
+ final TextBlock b = TextBlockUtils.create(Display.create(last), fontConfig, HorizontalAlignment.LEFT,
+ new SpriteContainerEmpty());
+ final Dimension2D dimText = b.calculateDimension(ug.getStringBounder());
+ final double diffX = width - dimText.getWidth();
+ final double diffY = getHeight() - dimText.getHeight();
+ b.drawU(ug.apply(new UTranslate((x + pendingX + diffX / 2), (y + diffY / 2))));
+ }
+
+ private double getHeight() {
+ return 20;
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ int n = 0;
+ for (Day d = start; d.compareTo(end) <= 0; d = (Day) timeline.next(d)) {
+ n++;
+ }
+ return new Dimension2DDouble(n * dayWidth, getHeight());
+ }
+}
diff --git a/src/net/sourceforge/plantuml/project2/TimeLine.java b/src/net/sourceforge/plantuml/project2/TimeLine.java
new file mode 100644
index 0000000..a3311ac
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project2/TimeLine.java
@@ -0,0 +1,47 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project2;
+
+public interface TimeLine {
+
+ public TimeElement next(TimeElement timeElement);
+
+ public TimeElement previous(TimeElement timeElement);
+
+ public TimeResolution getTimeResolution();
+
+ public boolean isClosed(TimeElement timeElement);
+
+}
diff --git a/src/net/sourceforge/plantuml/project2/TimeLineDay.java b/src/net/sourceforge/plantuml/project2/TimeLineDay.java
new file mode 100644
index 0000000..78f8a12
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project2/TimeLineDay.java
@@ -0,0 +1,71 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project2;
+
+import net.sourceforge.plantuml.project.WeekDay;
+
+public class TimeLineDay implements TimeLine {
+
+ public TimeElement next(TimeElement timeElement) {
+ do {
+ timeElement = timeElement.next();
+ if (isClosed(timeElement) == false) {
+ return timeElement;
+ }
+ } while (true);
+ }
+
+ public TimeElement previous(TimeElement timeElement) {
+ do {
+ timeElement = timeElement.previous();
+ if (isClosed(timeElement) == false) {
+ return timeElement;
+ }
+ } while (true);
+ }
+
+ public TimeResolution getTimeResolution() {
+ return TimeResolution.DAY;
+ }
+
+ public boolean isClosed(TimeElement timeElement) {
+ final WeekDay wd = ((Day) timeElement).getWeekDay();
+ if (wd == WeekDay.SAT || wd == WeekDay.SUN) {
+ return true;
+ }
+ return false;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/project2/TimeResolution.java b/src/net/sourceforge/plantuml/project2/TimeResolution.java
new file mode 100644
index 0000000..5451297
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project2/TimeResolution.java
@@ -0,0 +1,39 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project2;
+
+public enum TimeResolution {
+ DAY, WEEK, MONTH, YEAR
+}
diff --git a/src/net/sourceforge/plantuml/project2/TimeUtils.java b/src/net/sourceforge/plantuml/project2/TimeUtils.java
new file mode 100644
index 0000000..fccce3f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project2/TimeUtils.java
@@ -0,0 +1,65 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project2;
+
+public class TimeUtils {
+
+ static public TimeElement max(TimeElement t1, TimeElement t2) {
+ if (t1 == null) {
+ throw new IllegalArgumentException();
+ }
+ if (t2 == null) {
+ throw new IllegalArgumentException();
+ }
+ if (t1.compareTo(t2) > 0) {
+ return t1;
+ }
+ return t2;
+ }
+
+ static public TimeElement min(TimeElement t1, TimeElement t2) {
+ if (t1 == null) {
+ throw new IllegalArgumentException();
+ }
+ if (t2 == null) {
+ throw new IllegalArgumentException();
+ }
+ if (t1.compareTo(t2) < 0) {
+ return t1;
+ }
+ return t2;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/project2/Value.java b/src/net/sourceforge/plantuml/project2/Value.java
new file mode 100644
index 0000000..d6ffb9a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project2/Value.java
@@ -0,0 +1,38 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project2;
+
+public interface Value {
+}
diff --git a/src/net/sourceforge/plantuml/project2/ValueInt.java b/src/net/sourceforge/plantuml/project2/ValueInt.java
new file mode 100644
index 0000000..85b568e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project2/ValueInt.java
@@ -0,0 +1,54 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project2;
+
+public class ValueInt implements Value {
+
+ private final int value;
+
+ public ValueInt(int value) {
+ this.value = value;
+ }
+
+ public final int getValue() {
+ return value;
+ }
+
+ public Value plus(Value other) {
+ final ValueInt other2 = (ValueInt) other;
+ return new ValueInt(value + other2.value);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/project2/ValueTime.java b/src/net/sourceforge/plantuml/project2/ValueTime.java
new file mode 100644
index 0000000..643fb15
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project2/ValueTime.java
@@ -0,0 +1,48 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project2;
+
+public class ValueTime implements Value {
+
+ private final TimeElement value;
+
+ public ValueTime(TimeElement value) {
+ this.value = value;
+ }
+
+ public final TimeElement getValue() {
+ return value;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/project2/command/CommandAffectation.java b/src/net/sourceforge/plantuml/project2/command/CommandAffectation.java
new file mode 100644
index 0000000..08e41ce
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project2/command/CommandAffectation.java
@@ -0,0 +1,59 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project2.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.project2.PSystemProject2;
+import net.sourceforge.plantuml.project2.Value;
+
+public class CommandAffectation extends SingleLineCommand<PSystemProject2> {
+
+ public CommandAffectation() {
+ super("(?i)^[%s]*([~\\^]?[\\w$/]+)[%s]*:=[%s]*(.+)$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(PSystemProject2 diagram, List<String> arg) {
+ final Value exp = diagram.getProject().getExpression(arg.get(1).trim());
+ final boolean ok = diagram.getProject().affectation(arg.get(0).trim(), exp);
+ if (ok) {
+ return CommandExecutionResult.ok();
+ }
+ return CommandExecutionResult.error("Cannot execute CommandAffectation");
+ }
+}
diff --git a/src/net/sourceforge/plantuml/project2/command/CommandCloseWeekDay.java b/src/net/sourceforge/plantuml/project2/command/CommandCloseWeekDay.java
new file mode 100644
index 0000000..b5385cf
--- /dev/null
+++ b/src/net/sourceforge/plantuml/project2/command/CommandCloseWeekDay.java
@@ -0,0 +1,55 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.project2.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.project2.PSystemProject2;
+
+public class CommandCloseWeekDay extends SingleLineCommand<PSystemProject2> {
+
+ public CommandCloseWeekDay() {
+ super("(?i)^[%s]*close[%s]+(\\w{3,}day)[%s]*$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(PSystemProject2 diagram, List<String> arg) {
+ // final WeekDay weekDay = WeekDay.valueOf(arg.get(0).substring(0, 3).goUpperCase());
+// getSystem().getProject().closeWeekDay(weekDay);
+ return CommandExecutionResult.ok();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/real/PositiveForce.java b/src/net/sourceforge/plantuml/real/PositiveForce.java
new file mode 100644
index 0000000..8e46583
--- /dev/null
+++ b/src/net/sourceforge/plantuml/real/PositiveForce.java
@@ -0,0 +1,68 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.real;
+
+class PositiveForce {
+
+ private final Real fixedPoint;
+ private final RealMoveable movingPoint;
+ private final double minimunDistance;
+
+ public PositiveForce(Real fixedPoint, RealMoveable movingPoint, double minimunDistance) {
+ if (fixedPoint == movingPoint) {
+ throw new IllegalArgumentException();
+ }
+ this.fixedPoint = fixedPoint;
+ this.movingPoint = movingPoint;
+ this.minimunDistance = minimunDistance;
+ }
+
+ @Override
+ public String toString() {
+ return "PositiveForce fixed=" + fixedPoint + " moving=" + movingPoint + " min=" + minimunDistance;
+ }
+
+ public boolean apply() {
+ final double distance = movingPoint.getCurrentValue() - fixedPoint.getCurrentValue();
+ final double diff = distance - minimunDistance;
+ if (diff >= 0) {
+ return false;
+ }
+ // System.err.println("moving " + (-diff) + " " + movingPoint);
+ movingPoint.move(-diff);
+ return true;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/real/Real.java b/src/net/sourceforge/plantuml/real/Real.java
new file mode 100644
index 0000000..427fbed
--- /dev/null
+++ b/src/net/sourceforge/plantuml/real/Real.java
@@ -0,0 +1,51 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.real;
+
+public interface Real {
+
+ public String getName();
+
+ public double getCurrentValue();
+
+ public Real addFixed(double delta);
+
+ public Real addAtLeast(double delta);
+
+ public void ensureBiggerThan(Real other);
+
+ public void compile();
+
+}
diff --git a/src/net/sourceforge/plantuml/real/RealDelta.java b/src/net/sourceforge/plantuml/real/RealDelta.java
new file mode 100644
index 0000000..bf59eff
--- /dev/null
+++ b/src/net/sourceforge/plantuml/real/RealDelta.java
@@ -0,0 +1,73 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.real;
+
+class RealDelta extends RealMoveable {
+
+ private final Real delegated;
+ private final double diff;
+
+ RealDelta(Real delegated, double diff) {
+ super("[Delegated {" + delegated.getName() + "} d=" + diff + "]");
+ this.delegated = delegated;
+ this.diff = diff;
+ }
+
+ public double getCurrentValue() {
+ return delegated.getCurrentValue() + diff;
+ }
+
+ public Real addAtLeast(double delta) {
+ return new RealDelta(delegated.addAtLeast(delta), diff);
+ }
+
+ public void ensureBiggerThan(Real other) {
+ delegated.ensureBiggerThan(new RealDelta(other, -diff));
+
+ }
+
+ public void compile() {
+ delegated.compile();
+ }
+
+ void move(double delta) {
+ ((RealMoveable) delegated).move(delta);
+ }
+
+ RealLine getLine() {
+ return ((RealMoveable) delegated).getLine();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/real/RealImpl.java b/src/net/sourceforge/plantuml/real/RealImpl.java
new file mode 100644
index 0000000..97f2a6d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/real/RealImpl.java
@@ -0,0 +1,74 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.real;
+
+class RealImpl extends RealMoveable {
+
+ private final RealLine line;
+ private double currentValue;
+
+ public RealImpl(String name, RealLine line, double currentValue) {
+ super(name);
+ this.line = line;
+ this.currentValue = currentValue;
+ }
+
+ void move(double delta) {
+ this.currentValue += delta;
+ }
+
+ public double getCurrentValue() {
+ return currentValue;
+ }
+
+ public Real addAtLeast(double delta) {
+ final RealImpl result = new RealImpl(getName() + ".addAtLeast" + delta, line, this.currentValue + delta);
+ line.addForce(new PositiveForce(this, result, delta));
+ return result;
+ }
+
+ public void ensureBiggerThan(Real other) {
+ line.addForce(new PositiveForce(other, this, 0));
+ }
+
+ public void compile() {
+ line.compile();
+ }
+
+ RealLine getLine() {
+ return line;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/real/RealLine.java b/src/net/sourceforge/plantuml/real/RealLine.java
new file mode 100644
index 0000000..c9d246f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/real/RealLine.java
@@ -0,0 +1,76 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.real;
+
+import java.util.ArrayList;
+import java.util.List;
+
+class RealLine {
+
+ private final List<PositiveForce> forces = new ArrayList<PositiveForce>();
+
+ public void addForce(PositiveForce force) {
+ this.forces.add(force);
+ }
+
+ static private int CPT;
+
+ public void compile() {
+ int cpt = 0;
+ do {
+ boolean done = true;
+ for (PositiveForce f : forces) {
+ // System.err.println("force=" + f);
+ final boolean change = f.apply();
+ if (change) {
+ // System.err.println("changed! " + f);
+ done = false;
+ }
+ }
+ if (done) {
+ // System.err.println("cpt=" + cpt + " size=" + forces.size());
+ CPT += cpt;
+ // System.err.println("CPT=" + CPT);
+ return;
+ }
+ cpt++;
+ if (cpt > 99999) {
+ throw new IllegalStateException("Inifinite Loop?");
+ }
+ } while (true);
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/real/RealMax.java b/src/net/sourceforge/plantuml/real/RealMax.java
new file mode 100644
index 0000000..0092108
--- /dev/null
+++ b/src/net/sourceforge/plantuml/real/RealMax.java
@@ -0,0 +1,85 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.real;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class RealMax implements Real {
+
+ private final List<Real> all = new ArrayList<Real>();
+
+ public void put(Real real) {
+ if (real == null) {
+ throw new IllegalArgumentException();
+ }
+ if (real == this) {
+ return;
+ }
+ all.add(real);
+ }
+
+ public String getName() {
+ return "max " + all;
+ }
+
+ public double getCurrentValue() {
+ double result = all.get(0).getCurrentValue();
+ for (int i = 1; i < all.size(); i++) {
+ final double v = all.get(i).getCurrentValue();
+ if (v > result) {
+ result = v;
+ }
+ }
+ return result;
+ }
+
+ public Real addFixed(double delta) {
+ return new RealDelta(this, delta);
+ }
+
+ public Real addAtLeast(double delta) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void ensureBiggerThan(Real other) {
+ all.add(other);
+ }
+
+ public void compile() {
+ all.get(0).compile();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/real/RealMiddle.java b/src/net/sourceforge/plantuml/real/RealMiddle.java
new file mode 100644
index 0000000..25200d5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/real/RealMiddle.java
@@ -0,0 +1,77 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.real;
+
+class RealMiddle implements Real {
+
+ private final RealMoveable p1;
+ private final RealMoveable p2;
+ private final double delta;
+
+ private RealMiddle(RealMoveable p1, RealMoveable p2, double delta) {
+ this.p1 = p1;
+ this.p2 = p2;
+ this.delta = delta;
+ }
+
+ RealMiddle(RealMoveable p1, RealMoveable p2) {
+ this(p1, p2, 0);
+ }
+
+ public double getCurrentValue() {
+ return (p1.getCurrentValue() + p2.getCurrentValue()) / 2 + delta;
+ }
+
+ public Real addFixed(double diff) {
+ return new RealMiddle(p1, p2, delta + diff);
+ }
+
+ public Real addAtLeast(double delta) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void ensureBiggerThan(Real other) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void compile() {
+ p1.compile();
+ }
+
+ public String getName() {
+ return "[Middle " + p1.getName() + " and " + p2.getName() + "]";
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/real/RealMin.java b/src/net/sourceforge/plantuml/real/RealMin.java
new file mode 100644
index 0000000..cea620d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/real/RealMin.java
@@ -0,0 +1,89 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.real;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class RealMin implements Real {
+
+ private final List<Real> all = new ArrayList<Real>();
+
+ public void put(Real real) {
+ if (real == null) {
+ throw new IllegalArgumentException();
+ }
+ if (real == this) {
+ return;
+ }
+ all.add(real);
+ }
+
+ public String getName() {
+ return "min " + all;
+ }
+
+ public double getCurrentValue() {
+ double result = all.get(0).getCurrentValue();
+ for (int i = 1; i < all.size(); i++) {
+ final double v = all.get(i).getCurrentValue();
+ if (v < result) {
+ result = v;
+ }
+ }
+ return result;
+ }
+
+ public Real addFixed(double delta) {
+ return new RealDelta(this, delta);
+ }
+
+ public Real addAtLeast(double delta) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void ensureBiggerThan(Real other) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void compile() {
+ all.get(0).compile();
+ }
+
+ public int size() {
+ return all.size();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/real/RealMoveable.java b/src/net/sourceforge/plantuml/real/RealMoveable.java
new file mode 100644
index 0000000..7d68da0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/real/RealMoveable.java
@@ -0,0 +1,62 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.real;
+
+abstract class RealMoveable implements Real {
+
+ private final String name;
+
+ RealMoveable(String name) {
+ this.name = name;
+ }
+
+ abstract void move(double delta);
+
+ abstract RealLine getLine();
+
+ final public Real addFixed(double delta) {
+ return new RealDelta(this, delta);
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+
+ final public String getName() {
+ return name;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/real/RealUtils.java b/src/net/sourceforge/plantuml/real/RealUtils.java
new file mode 100644
index 0000000..0ee94c3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/real/RealUtils.java
@@ -0,0 +1,59 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.real;
+
+import java.util.List;
+
+public class RealUtils {
+
+ public static Real createOrigin() {
+ final RealLine line = new RealLine();
+ final RealImpl result = new RealImpl("O", line, 0);
+ return result;
+ }
+
+ public static Real middle(Real r1, Real r2) {
+ return new RealMiddle((RealMoveable) r1, (RealMoveable) r2);
+ }
+
+ // public static Real max(List<Real> all) {
+ // return new RealMax(all);
+ // }
+ //
+ // public static Real min(List<Real> all) {
+ // return new RealMin(all);
+ // }
+
+}
diff --git a/src/net/sourceforge/plantuml/salt/Cell.java b/src/net/sourceforge/plantuml/salt/Cell.java
new file mode 100644
index 0000000..e7e348a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/Cell.java
@@ -0,0 +1,85 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt;
+
+
+public class Cell {
+
+ private int minRow;
+ private int maxRow;
+ private int minCol;
+ private int maxCol;
+
+ public Cell(int row, int col) {
+ minRow = row;
+ maxRow = row;
+ minCol = col;
+ maxCol = col;
+ }
+
+ public void mergeLeft() {
+ maxCol++;
+ }
+
+ public int getMinRow() {
+ return minRow;
+ }
+
+ public int getMaxRow() {
+ return maxRow;
+ }
+
+ public int getMinCol() {
+ return minCol;
+ }
+
+ public int getMaxCol() {
+ return maxCol;
+ }
+
+ public int getNbRows() {
+ return maxRow - minRow + 1;
+ }
+
+ public int getNbCols() {
+ return maxCol - minCol + 1;
+ }
+
+ @Override
+ public String toString() {
+ return "(" + minRow + "," + minCol + ")-(" + maxRow + "," + maxCol + ")";
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/salt/DataSource.java b/src/net/sourceforge/plantuml/salt/DataSource.java
new file mode 100644
index 0000000..20afbbc
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/DataSource.java
@@ -0,0 +1,42 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt;
+
+import java.util.Iterator;
+
+public interface DataSource extends Iterator<Terminated<String>> {
+
+ Terminated<String> peek(int i);
+}
diff --git a/src/net/sourceforge/plantuml/salt/DataSourceImpl.java b/src/net/sourceforge/plantuml/salt/DataSourceImpl.java
new file mode 100644
index 0000000..d0fec7a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/DataSourceImpl.java
@@ -0,0 +1,114 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+
+public class DataSourceImpl implements DataSource {
+
+ private int i = 0;
+ private final List<Terminated<String>> data = new ArrayList<Terminated<String>>();
+
+ public DataSourceImpl(List<String> data) {
+ final Pattern p = MyPattern.cmpile("\\{[-+#!*/]?");
+ for (String s : data) {
+ final StringTokenizer st = new StringTokenizer(s, "|}", true);
+ while (st.hasMoreTokens()) {
+ final String token = st.nextToken().trim();
+ if (token.equals("|")) {
+ continue;
+ }
+ final Terminator terminator = st.hasMoreTokens() ? Terminator.NEWCOL : Terminator.NEWLINE;
+ final Matcher m = p.matcher(token);
+ final boolean found = m.find();
+ if (found == false) {
+ addInternal(token, terminator);
+ continue;
+ }
+ int lastStart = 0;
+ int end = 0;
+ do {
+ final int start = m.start();
+ if (start > lastStart) {
+ addInternal(token.substring(lastStart, start), Terminator.NEWCOL);
+ }
+ end = m.end();
+ final Terminator t = end == token.length() ? terminator : Terminator.NEWCOL;
+ addInternal(token.substring(start, end), t);
+ lastStart = end;
+ } while (m.find());
+ if (end < token.length()) {
+ addInternal(token.substring(end), terminator);
+ }
+ }
+ }
+ }
+
+ private void addInternal(String s, Terminator t) {
+ s = s.trim();
+ if (s.length() > 0) {
+ data.add(new Terminated<String>(s, t));
+ }
+ }
+
+ public Terminated<String> peek(int nb) {
+ return data.get(i + nb);
+ }
+
+ public boolean hasNext() {
+ return i < data.size();
+ }
+
+ public Terminated<String> next() {
+ final Terminated<String> result = data.get(i);
+ i++;
+ return result;
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+
+ public String toString() {
+ return super.toString() + " " + (hasNext() ? peek(0) : "$$$");
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/salt/Dictionary.java b/src/net/sourceforge/plantuml/salt/Dictionary.java
new file mode 100644
index 0000000..80a4eb3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/Dictionary.java
@@ -0,0 +1,78 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.SpriteContainer;
+import net.sourceforge.plantuml.salt.element.Element;
+import net.sourceforge.plantuml.salt.element.WrappedElement;
+import net.sourceforge.plantuml.ugraphic.Sprite;
+
+public class Dictionary implements SpriteContainer, ISkinSimple {
+
+ private final Map<String, Element> data = new HashMap<String, Element>();
+
+ public void put(String name, Element element) {
+ data.put(name, element);
+ }
+
+ public Element get(String name) {
+ final Element result = data.get(name);
+ if (result == null) {
+ throw new IllegalArgumentException();
+ }
+ return new WrappedElement(result);
+ }
+
+ public Sprite getSprite(String name) {
+ return null;
+ }
+
+ public String getValue(String key) {
+ return null;
+ }
+
+ public double getPadding() {
+ return 0;
+ }
+
+ public boolean useGuillemet() {
+ return true;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/salt/PSystemSalt.java b/src/net/sourceforge/plantuml/salt/PSystemSalt.java
new file mode 100644
index 0000000..23c42a9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/PSystemSalt.java
@@ -0,0 +1,131 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.geom.Dimension2D;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.imageio.ImageIO;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.EmptyImageBuilder;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.api.ImageDataSimple;
+import net.sourceforge.plantuml.core.DiagramDescription;
+import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.salt.element.Element;
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+import net.sourceforge.plantuml.ugraphic.ImageBuilder;
+import net.sourceforge.plantuml.ugraphic.UAntiAliasing;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.g2d.UGraphicG2d;
+
+public class PSystemSalt extends AbstractPSystem {
+
+ private final List<String> data;
+
+ @Deprecated
+ public PSystemSalt(List<String> data) {
+ this.data = data;
+ }
+
+ public PSystemSalt() {
+ this(new ArrayList<String>());
+ }
+
+ public void add(String s) {
+ data.add(s);
+ }
+
+ public ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormat) throws IOException {
+ final Element salt = SaltUtils.createElement(data);
+
+ final Dimension2D size = salt.getPreferredDimension(TextBlockUtils.getDummyStringBounder(), 0, 0);
+ final ImageBuilder builder = new ImageBuilder(new ColorMapperIdentity(), 1.0, HtmlColorUtils.WHITE, null,
+ null, 5, 5, null, false);
+ builder.addUDrawable(new UDrawable() {
+
+ public void drawU(UGraphic ug) {
+ ug = ug.apply(new UChangeColor(HtmlColorUtils.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.getFileFormat(), os);
+ }
+
+ private ImageData exportDiagramOld(OutputStream os, int num, FileFormatOption fileFormat) throws IOException {
+ final Element salt = SaltUtils.createElement(data);
+
+ EmptyImageBuilder builder = new EmptyImageBuilder(10, 10, Color.WHITE);
+ Graphics2D g2d = builder.getGraphics2D();
+
+ final Dimension2D size = salt.getPreferredDimension(
+ new UGraphicG2d(new ColorMapperIdentity(), g2d, 1.0).getStringBounder(), 0, 0);
+ g2d.dispose();
+
+ builder = new EmptyImageBuilder(size.getWidth() + 6, size.getHeight() + 6, Color.WHITE);
+ final BufferedImage im = builder.getBufferedImage();
+ g2d = builder.getGraphics2D();
+ g2d.translate(3, 3);
+ UAntiAliasing.ANTI_ALIASING_ON.apply(g2d);
+ UGraphic ug = new UGraphicG2d(new ColorMapperIdentity(), g2d, 1.0);
+ ug = ug.apply(new UChangeColor(HtmlColorUtils.BLACK));
+ salt.drawU(ug, 0, new Dimension2DDouble(size.getWidth(), size.getHeight()));
+ salt.drawU(ug, 1, new Dimension2DDouble(size.getWidth(), size.getHeight()));
+ g2d.dispose();
+
+ // Writes the off-screen image into a PNG file
+ ImageIO.write(im, "png", os);
+ return new ImageDataSimple(im.getWidth(), im.getHeight());
+ }
+
+ public DiagramDescription getDescription() {
+ return new DiagramDescriptionImpl("(Salt)", getClass());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/salt/PSystemSaltFactory.java b/src/net/sourceforge/plantuml/salt/PSystemSaltFactory.java
new file mode 100644
index 0000000..ad11fbb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/PSystemSaltFactory.java
@@ -0,0 +1,69 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt;
+
+import net.sourceforge.plantuml.command.PSystemBasicFactory;
+import net.sourceforge.plantuml.core.DiagramType;
+
+public class PSystemSaltFactory extends PSystemBasicFactory<PSystemSalt> {
+
+ public PSystemSaltFactory(DiagramType diagramType) {
+ super(diagramType);
+ }
+
+ public PSystemSalt init(String startLine) {
+ if (getDiagramType() == DiagramType.UML) {
+ return null;
+ } else if (getDiagramType() == DiagramType.SALT) {
+ return new PSystemSalt();
+ } else {
+ throw new IllegalStateException(getDiagramType().name());
+ }
+
+ }
+
+ @Override
+ public PSystemSalt executeLine(PSystemSalt system, String line) {
+ if (system == null && line.equals("salt")) {
+ return new PSystemSalt();
+ }
+ if (system == null) {
+ return null;
+ }
+ system.add(line.trim());
+ return system;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/salt/Position.java b/src/net/sourceforge/plantuml/salt/Position.java
new file mode 100644
index 0000000..7e6fe57
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/Position.java
@@ -0,0 +1,66 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt;
+
+public class Position {
+
+ final private int row;
+ final private int col;
+
+ public Position(int row, int col) {
+ this.row = row;
+ this.col = col;
+ }
+
+ public int getRow() {
+ return row;
+ }
+
+ public int getCol() {
+ return col;
+ }
+
+ @Override
+ public int hashCode() {
+ return row * 49 + col;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ final Position other = (Position) obj;
+ return row == other.row && col == other.col;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/salt/Positionner2.java b/src/net/sourceforge/plantuml/salt/Positionner2.java
new file mode 100644
index 0000000..394e5b9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/Positionner2.java
@@ -0,0 +1,112 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt;
+
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import net.sourceforge.plantuml.salt.element.Element;
+
+public class Positionner2 {
+
+ private int row;
+ private int col;
+
+ private int maxRow;
+ private int maxCol;
+
+ private final Map<Element, Cell> positions = new LinkedHashMap<Element, Cell>();
+
+ private Cell last;
+
+ public void add(Terminated<Element> element) {
+ addWithoutMove(element.getElement());
+ final Terminator terminator = element.getTerminator();
+ if (terminator == Terminator.NEWCOL) {
+ moveNextColumn();
+ } else {
+ moveNextRow();
+ }
+ }
+
+ private void moveNextColumn() {
+ col++;
+ }
+
+ private void moveNextRow() {
+ row++;
+ col = 0;
+ }
+
+ private void addWithoutMove(Element elmt) {
+ last = new Cell(row, col);
+ positions.put(elmt, last);
+ updateMax();
+ }
+
+ public void mergeLeft(Terminator terminator) {
+ updateMax();
+ if (terminator == Terminator.NEWCOL) {
+ col++;
+ } else {
+ row++;
+ col = 0;
+ }
+ last.mergeLeft();
+ }
+
+ private void updateMax() {
+ if (row > maxRow) {
+ maxRow = row;
+ }
+ if (col > maxCol) {
+ maxCol = col;
+ }
+ }
+
+ public Map<Element, Cell> getAll() {
+ return Collections.unmodifiableMap(positions);
+ }
+
+ public final int getNbRows() {
+ return maxRow + 1;
+ }
+
+ public final int getNbCols() {
+ return maxCol + 1;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/salt/SaltUtils.java b/src/net/sourceforge/plantuml/salt/SaltUtils.java
new file mode 100644
index 0000000..4005948
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/SaltUtils.java
@@ -0,0 +1,114 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import net.sourceforge.plantuml.Log;
+import net.sourceforge.plantuml.salt.element.Element;
+import net.sourceforge.plantuml.salt.factory.AbstractElementFactoryComplex;
+import net.sourceforge.plantuml.salt.factory.ElementFactory;
+import net.sourceforge.plantuml.salt.factory.ElementFactoryBorder;
+import net.sourceforge.plantuml.salt.factory.ElementFactoryButton;
+import net.sourceforge.plantuml.salt.factory.ElementFactoryCheckboxOff;
+import net.sourceforge.plantuml.salt.factory.ElementFactoryCheckboxOn;
+import net.sourceforge.plantuml.salt.factory.ElementFactoryDroplist;
+import net.sourceforge.plantuml.salt.factory.ElementFactoryImage;
+import net.sourceforge.plantuml.salt.factory.ElementFactoryLine;
+import net.sourceforge.plantuml.salt.factory.ElementFactoryMenu;
+import net.sourceforge.plantuml.salt.factory.ElementFactoryPyramid;
+import net.sourceforge.plantuml.salt.factory.ElementFactoryRadioOff;
+import net.sourceforge.plantuml.salt.factory.ElementFactoryRadioOn;
+import net.sourceforge.plantuml.salt.factory.ElementFactoryRetrieveFromDictonnary;
+import net.sourceforge.plantuml.salt.factory.ElementFactoryTab;
+import net.sourceforge.plantuml.salt.factory.ElementFactoryText;
+import net.sourceforge.plantuml.salt.factory.ElementFactoryTextField;
+import net.sourceforge.plantuml.salt.factory.ElementFactoryTree;
+
+public class SaltUtils {
+
+ public static Element createElement(List<String> data) {
+ final DataSourceImpl source = new DataSourceImpl(data);
+
+ final Collection<AbstractElementFactoryComplex> cpx = new ArrayList<AbstractElementFactoryComplex>();
+
+ final Dictionary dictionnary = new Dictionary();
+
+ // cpx.add(new ElementFactorySimpleFrame(source, dictionnary));
+ cpx.add(new ElementFactoryPyramid(source, dictionnary));
+ cpx.add(new ElementFactoryBorder(source, dictionnary));
+
+ for (AbstractElementFactoryComplex f : cpx) {
+ addSimpleFactory(f, source, dictionnary);
+ }
+ for (AbstractElementFactoryComplex f1 : cpx) {
+ for (AbstractElementFactoryComplex f2 : cpx) {
+ f1.addFactory(f2);
+ }
+ }
+
+ for (ElementFactory f : cpx) {
+ if (f.ready()) {
+ Log.info("Using " + f);
+ return f.create().getElement();
+ }
+ }
+
+ Log.println("data=" + data);
+ throw new IllegalArgumentException();
+
+ }
+
+ private static void addSimpleFactory(final AbstractElementFactoryComplex cpxFactory, final DataSource source,
+ Dictionary dictionnary) {
+ cpxFactory.addFactory(new ElementFactoryMenu(source, dictionnary));
+ cpxFactory.addFactory(new ElementFactoryTree(source, dictionnary));
+ cpxFactory.addFactory(new ElementFactoryTab(source, dictionnary));
+ cpxFactory.addFactory(new ElementFactoryLine(source));
+ cpxFactory.addFactory(new ElementFactoryTextField(source, dictionnary));
+ cpxFactory.addFactory(new ElementFactoryButton(source, dictionnary));
+ cpxFactory.addFactory(new ElementFactoryDroplist(source, dictionnary));
+ cpxFactory.addFactory(new ElementFactoryRadioOn(source, dictionnary));
+ cpxFactory.addFactory(new ElementFactoryRadioOff(source, dictionnary));
+ cpxFactory.addFactory(new ElementFactoryCheckboxOn(source, dictionnary));
+ cpxFactory.addFactory(new ElementFactoryCheckboxOff(source, dictionnary));
+ cpxFactory.addFactory(new ElementFactoryImage(source, dictionnary));
+ cpxFactory.addFactory(new ElementFactoryRetrieveFromDictonnary(source, dictionnary));
+ cpxFactory.addFactory(new ElementFactoryText(source, dictionnary));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/salt/Terminated.java b/src/net/sourceforge/plantuml/salt/Terminated.java
new file mode 100644
index 0000000..f8317ac
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/Terminated.java
@@ -0,0 +1,62 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt;
+
+public class Terminated<O> {
+
+ private final O element;
+ private final Terminator terminator;
+
+ public Terminated(O element, Terminator terminator) {
+ if (terminator == null) {
+ throw new IllegalArgumentException();
+ }
+ this.element = element;
+ this.terminator = terminator;
+ }
+
+ public O getElement() {
+ return element;
+ }
+
+ public Terminator getTerminator() {
+ return terminator;
+ }
+
+ public String toString() {
+ return element.toString() + " " + terminator;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/salt/Terminator.java b/src/net/sourceforge/plantuml/salt/Terminator.java
new file mode 100644
index 0000000..7493664
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/Terminator.java
@@ -0,0 +1,39 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt;
+
+public enum Terminator {
+ NEWLINE, NEWCOL
+}
diff --git a/src/net/sourceforge/plantuml/salt/element/AbstractElement.java b/src/net/sourceforge/plantuml/salt/element/AbstractElement.java
new file mode 100644
index 0000000..b61f2e5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/element/AbstractElement.java
@@ -0,0 +1,39 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt.element;
+
+public abstract class AbstractElement implements Element {
+
+}
diff --git a/src/net/sourceforge/plantuml/salt/element/AbstractElementText.java b/src/net/sourceforge/plantuml/salt/element/AbstractElementText.java
new file mode 100644
index 0000000..8a1e6e6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/element/AbstractElementText.java
@@ -0,0 +1,114 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt.element;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+abstract class AbstractElementText extends AbstractElement {
+
+ private final TextBlock block;
+ private final FontConfiguration config;
+ private final int charLength;
+
+ public AbstractElementText(String text, UFont font, boolean manageLength, ISkinSimple spriteContainer) {
+ config = new FontConfiguration(font, HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true);
+ if (manageLength) {
+ this.charLength = getCharNumber(text);
+ text = text.trim();
+ } else {
+ this.charLength = 0;
+ }
+ this.block = TextBlockUtils.create(Display.create(text), config, HorizontalAlignment.LEFT, spriteContainer);
+ }
+
+ private int getCharNumber(String text) {
+ text = text.replaceAll("<&[-\\w]+>", "00");
+ return text.length();
+ }
+
+ protected void drawText(UGraphic ug, double x, double y) {
+ block.drawU(ug.apply(new UTranslate(x, y)));
+ }
+
+ protected Dimension2D getPureTextDimension(StringBounder stringBounder) {
+ return block.calculateDimension(stringBounder);
+ }
+
+ protected Dimension2D getTextDimensionAt(StringBounder stringBounder, double x) {
+ final Dimension2D result = block.calculateDimension(stringBounder);
+ if (charLength == 0) {
+ return result;
+ }
+ final double dimSpace = getSingleSpace(stringBounder);
+ // final double endx = x + result.getWidth();
+ // final double mod = endx % CHAR_SIZE;
+ // final double delta = charLength * CHAR_SIZE - mod;
+ // return Dimension2DDouble.delta(result, delta, 0);
+ return new Dimension2DDouble(Math.max(result.getWidth(), charLength * dimSpace), result.getHeight());
+ }
+
+ private double getSingleSpace(StringBounder stringBounder) {
+ // double max = 0;
+ // for (int i = 32; i < 127; i++) {
+ // final char c = (char) i;
+ // final double w = TextBlockUtils.create(Arrays.asList("" + c), config, HorizontalAlignment.LEFT)
+ // .calculateDimension(stringBounder).getWidth();
+ // if (w > max) {
+ // Log.println("c="+c+" "+max);
+ // max = w;
+ // }
+ // }
+ // return max;
+ return 8;
+ }
+
+ protected final FontConfiguration getConfig() {
+ return config;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/salt/element/Element.java b/src/net/sourceforge/plantuml/salt/element/Element.java
new file mode 100644
index 0000000..5467124
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/element/Element.java
@@ -0,0 +1,48 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt.element;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public interface Element {
+
+ public Dimension2D getPreferredDimension(StringBounder stringBounder, double x, double y);
+
+ public void drawU(UGraphic ug, int zIndex, Dimension2D dimToUse);
+
+}
diff --git a/src/net/sourceforge/plantuml/salt/element/ElementBorder.java b/src/net/sourceforge/plantuml/salt/element/ElementBorder.java
new file mode 100644
index 0000000..bc7a5d1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/element/ElementBorder.java
@@ -0,0 +1,106 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt.element;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+import net.sourceforge.plantuml.utils.MathUtils;
+
+public class ElementBorder extends AbstractElement {
+
+ private Element north = new ElementEmpty();
+ private Element south = new ElementEmpty();
+ private Element east = new ElementEmpty();
+ private Element west = new ElementEmpty();
+ private Element center = new ElementEmpty();
+
+ public final void setNorth(Element north) {
+ this.north = north;
+ }
+
+ public final void setSouth(Element south) {
+ this.south = south;
+ }
+
+ public final void setEast(Element east) {
+ this.east = east;
+ }
+
+ public final void setWest(Element west) {
+ this.west = west;
+ }
+
+ public final void setCenter(Element center) {
+ this.center = center;
+ }
+
+ public void drawU(UGraphic ug, int zIndex, Dimension2D dimToUse) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D dimNorth = north.getPreferredDimension(stringBounder, 0, 0);
+ final Dimension2D dimSouth = south.getPreferredDimension(stringBounder, 0, 0);
+ final Dimension2D dimEast = east.getPreferredDimension(stringBounder, 0, 0);
+ final Dimension2D dimWest = west.getPreferredDimension(stringBounder, 0, 0);
+ final Point2D pA = new Point2D.Double(dimWest.getWidth(), dimNorth.getHeight());
+ final Point2D pB = new Point2D.Double(dimToUse.getWidth() - dimEast.getWidth(), dimNorth.getHeight());
+ final Point2D pC = new Point2D.Double(dimWest.getWidth(), dimToUse.getHeight() - dimSouth.getHeight());
+ // final Point2D pD = new Point2D.Double(dimToUse.getWidth() - dimEast.getWidth(), dimToUse.getHeight()
+ // - dimSouth.getHeight());
+
+ north.drawU(ug, zIndex, dimToUse);
+ south.drawU(ug.apply(new UTranslate(0, pC.getY())), zIndex, dimToUse);
+ west.drawU(ug.apply(new UTranslate(0, pA.getY())), zIndex, dimToUse);
+ east.drawU(ug.apply(new UTranslate(pB.getX(), pB.getY())), zIndex, dimToUse);
+ center.drawU(ug.apply(new UTranslate(pA.getX(), pA.getY())), zIndex, dimToUse);
+ }
+
+ public Dimension2D getPreferredDimension(StringBounder stringBounder, double x, double y) {
+ final Dimension2D dimNorth = north.getPreferredDimension(stringBounder, x, y);
+ final Dimension2D dimSouth = south.getPreferredDimension(stringBounder, x, y);
+ final Dimension2D dimEast = east.getPreferredDimension(stringBounder, x, y);
+ final Dimension2D dimWest = west.getPreferredDimension(stringBounder, x, y);
+ final Dimension2D dimCenter = center.getPreferredDimension(stringBounder, x, y);
+ final double width = MathUtils.max(dimNorth.getWidth(), dimSouth.getWidth(),
+ dimWest.getWidth() + dimCenter.getWidth() + dimEast.getWidth());
+ final double height = dimNorth.getHeight()
+ + MathUtils.max(dimWest.getHeight(), dimCenter.getHeight(), dimEast.getHeight()) + dimSouth.getHeight();
+ return new Dimension2DDouble(width, height);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/salt/element/ElementButton.java b/src/net/sourceforge/plantuml/salt/element/ElementButton.java
new file mode 100644
index 0000000..47bb772
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/element/ElementButton.java
@@ -0,0 +1,77 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt.element;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.graphic.HtmlColorSet;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ElementButton extends AbstractElementText implements Element {
+
+ private final double stroke = 2.5;
+ private final double marginX = 2;
+ private final double marginY = 2;
+
+ public ElementButton(String text, UFont font, ISkinSimple spriteContainer) {
+ super(text, font, true, spriteContainer);
+ }
+
+ public Dimension2D getPreferredDimension(StringBounder stringBounder, double x, double y) {
+ Dimension2D dim = getTextDimensionAt(stringBounder, x + stroke + marginX);
+ dim = Dimension2DDouble.delta(dim, 2 * marginX, 2 * marginY);
+ return Dimension2DDouble.delta(dim, 2 * stroke);
+ }
+
+ public void drawU(UGraphic ug, int zIndex, Dimension2D dimToUse) {
+ if (zIndex != 0) {
+ return;
+ }
+ final Dimension2D dim = getPreferredDimension(ug.getStringBounder(), 0, 0);
+ ug = ug.apply(new UStroke(stroke));
+ ug.apply(new UChangeBackColor(HtmlColorSet.getInstance().getColorIfValid("#EEEEEE"))).apply(new UTranslate(stroke, stroke))
+ .draw(new URectangle(dim.getWidth() - 2 * stroke, dim.getHeight() - 2 * stroke, 10, 10));
+ final Dimension2D dimPureText = getPureTextDimension(ug.getStringBounder());
+ drawText(ug, (dim.getWidth() - dimPureText.getWidth()) / 2, stroke + marginY);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/salt/element/ElementDroplist.java b/src/net/sourceforge/plantuml/salt/element/ElementDroplist.java
new file mode 100644
index 0000000..edff73e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/element/ElementDroplist.java
@@ -0,0 +1,121 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt.element;
+
+import java.awt.geom.Dimension2D;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColorSet;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ElementDroplist extends AbstractElementText implements Element {
+
+ private final int box = 12;
+ private final TextBlock openDrop;
+
+ public ElementDroplist(String text, UFont font, ISkinSimple spriteContainer) {
+ super(extract(text), font, true, spriteContainer);
+ final StringTokenizer st = new StringTokenizer(text, "^");
+ final List<String> drop = new ArrayList<String>();
+ while (st.hasMoreTokens()) {
+ drop.add(st.nextToken());
+ }
+ if (drop.size() > 0) {
+ drop.remove(0);
+ }
+ if (drop.size() == 0) {
+ this.openDrop = null;
+ } else {
+ this.openDrop = TextBlockUtils.create(Display.create(drop), getConfig(), HorizontalAlignment.LEFT,
+ spriteContainer);
+ }
+ }
+
+ private static String extract(String text) {
+ final int idx = text.indexOf('^');
+ if (idx == -1) {
+ return text;
+ }
+ return text.substring(0, idx);
+ }
+
+ public Dimension2D getPreferredDimension(StringBounder stringBounder, double x, double y) {
+ final Dimension2D dim = getTextDimensionAt(stringBounder, x + 2);
+ return Dimension2DDouble.delta(dim, 4 + box, 4);
+ }
+
+ public void drawU(UGraphic ug, int zIndex, Dimension2D dimToUse) {
+ final Dimension2D dim = getPreferredDimension(ug.getStringBounder(), 0, 0);
+ if (zIndex == 0) {
+ ug.apply(new UChangeBackColor(HtmlColorSet.getInstance().getColorIfValid("#EEEEEE"))).draw(
+ new URectangle(dim.getWidth() - 1, dim.getHeight() - 1));
+ drawText(ug, 2, 2);
+ final double xline = dim.getWidth() - box;
+ ug.apply(new UTranslate(xline, 0)).draw(new ULine(0, dim.getHeight() - 1));
+
+ final UPolygon poly = new UPolygon();
+ poly.addPoint(0, 0);
+ poly.addPoint(box - 6, 0);
+ final Dimension2D dimText = getPureTextDimension(ug.getStringBounder());
+ poly.addPoint((box - 6) / 2, dimText.getHeight() - 8);
+
+ ug.apply(new UChangeBackColor(ug.getParam().getColor())).apply(new UTranslate(xline + 3, 6)).draw(poly);
+ }
+
+ if (openDrop != null) {
+ final Dimension2D dimOpen = Dimension2DDouble.atLeast(openDrop.calculateDimension(ug.getStringBounder()),
+ dim.getWidth() - 1, 0);
+ ug.apply(new UChangeBackColor(HtmlColorSet.getInstance().getColorIfValid("#EEEEEE")))
+ .apply(new UTranslate(0, dim.getHeight() - 1))
+ .draw(new URectangle(dimOpen.getWidth() - 1, dimOpen.getHeight() - 1));
+ openDrop.drawU(ug.apply(new UTranslate(0, dim.getHeight() - 1)));
+ }
+ }
+}
diff --git a/src/net/sourceforge/plantuml/salt/element/ElementEmpty.java b/src/net/sourceforge/plantuml/salt/element/ElementEmpty.java
new file mode 100644
index 0000000..82af160
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/element/ElementEmpty.java
@@ -0,0 +1,51 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt.element;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class ElementEmpty extends AbstractElement {
+
+ public Dimension2D getPreferredDimension(StringBounder stringBounder, double x, double y) {
+ return new Dimension2DDouble(1, 1);
+ }
+
+ public void drawU(UGraphic ug, int zIndex, Dimension2D dimToUse) {
+ }
+}
diff --git a/src/net/sourceforge/plantuml/salt/element/ElementImage.java b/src/net/sourceforge/plantuml/salt/element/ElementImage.java
new file mode 100644
index 0000000..c6937c4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/element/ElementImage.java
@@ -0,0 +1,73 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt.element;
+
+import java.awt.geom.Dimension2D;
+import java.util.List;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UPixel;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ElementImage extends AbstractElement {
+
+ private final List<String> img;
+
+ public ElementImage(List<String> img) {
+ this.img = img;
+ }
+
+ public Dimension2D getPreferredDimension(StringBounder stringBounder, double x, double y) {
+ return new Dimension2DDouble(img.get(0).length(), img.size());
+ }
+
+ public void drawU(UGraphic ug, int zIndex, Dimension2D dimToUse) {
+ if (zIndex != 0) {
+ return;
+ }
+ final int w = img.get(0).length();
+ final int h = img.size();
+ for (int i = 0; i < w; i++) {
+ for (int j = 0; j < h; j++) {
+ final char c = img.get(j).charAt(i);
+ if (c == 'X') {
+ ug.apply(new UTranslate(i, j)).draw(new UPixel());
+ }
+ }
+ }
+ }
+}
diff --git a/src/net/sourceforge/plantuml/salt/element/ElementLine.java b/src/net/sourceforge/plantuml/salt/element/ElementLine.java
new file mode 100644
index 0000000..61fb696
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/element/ElementLine.java
@@ -0,0 +1,85 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt.element;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.HtmlColorSet;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ElementLine extends AbstractElement {
+
+ private final char separator;
+
+ public ElementLine(char separator) {
+ this.separator = separator;
+ }
+
+ public Dimension2D getPreferredDimension(StringBounder stringBounder, double x, double y) {
+ return new Dimension2DDouble(10, 6);
+ }
+
+ public void drawU(UGraphic ug, int zIndex, Dimension2D dimToUse) {
+ if (zIndex != 0) {
+ return;
+ }
+ ug = ug.apply(new UChangeColor(HtmlColorSet.getInstance().getColorIfValid("#AAAAAA")));
+ double y2 = dimToUse.getHeight() / 2;
+ if (separator == '=') {
+ y2 = y2 - 1;
+ }
+ drawLine(ug, 0, y2, dimToUse.getWidth(), separator);
+ }
+
+ private static void drawLine(UGraphic ug, double x, double y, double widthToUse, char separator) {
+ if (separator == '=') {
+ ug.apply(new UStroke()).apply(new UTranslate(x, y)).draw(new ULine(widthToUse, 0));
+ ug.apply(new UStroke()).apply(new UTranslate(x, y + 2)).draw(new ULine(widthToUse, 0));
+ } else if (separator == '.') {
+ ug.apply(new UStroke(1, 2, 1)).apply(new UTranslate(x, y)).draw(new ULine(widthToUse, 0));
+ } else if (separator == '-') {
+ ug.apply(new UStroke()).apply(new UTranslate(x, y)).draw(new ULine(widthToUse, 0));
+ } else {
+ ug.apply(new UStroke(1.5)).apply(new UTranslate(x, y)).draw(new ULine(widthToUse, 0));
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/salt/element/ElementMenuBar.java b/src/net/sourceforge/plantuml/salt/element/ElementMenuBar.java
new file mode 100644
index 0000000..c38400d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/element/ElementMenuBar.java
@@ -0,0 +1,133 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt.element;
+
+import java.awt.geom.Dimension2D;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.graphic.HtmlColorSet;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ElementMenuBar extends AbstractElement {
+
+ private final Collection<ElementMenuEntry> entries = new ArrayList<ElementMenuEntry>();
+ private final Map<ElementMenuEntry, ElementMenuPopup> popups = new HashMap<ElementMenuEntry, ElementMenuPopup>();
+ private final UFont font;
+ private final ISkinSimple spriteContainer;
+
+ public ElementMenuBar(UFont font, ISkinSimple spriteContainer) {
+ this.font = font;
+ this.spriteContainer = spriteContainer;
+ }
+
+ public void addEntry(String s) {
+ entries.add(new ElementMenuEntry(s, font, spriteContainer));
+ }
+
+ public void addSubEntry(String s, String sub) {
+ final ElementMenuPopup popup = getPopup(getElementMenuEntry(s));
+ popup.addEntry(sub);
+ }
+
+ private ElementMenuPopup getPopup(ElementMenuEntry s) {
+ ElementMenuPopup popup = popups.get(s);
+ if (popup == null) {
+ popup = new ElementMenuPopup(font, spriteContainer);
+ popups.put(s, popup);
+ }
+ return popup;
+ }
+
+ private ElementMenuEntry getElementMenuEntry(String n) {
+ for (ElementMenuEntry entry : entries) {
+ if (entry.getText().equals(n)) {
+ return entry;
+ }
+ }
+ throw new IllegalArgumentException();
+ }
+
+ public Dimension2D getPreferredDimension(StringBounder stringBounder, double x, double y) {
+ double w = 0;
+ double h = 0;
+ for (ElementMenuEntry entry : entries) {
+ final Dimension2D dim = entry.getPreferredDimension(stringBounder, x, y);
+ w += dim.getWidth() + 10;
+ h = Math.max(h, dim.getHeight());
+ }
+ return new Dimension2DDouble(w, h);
+ }
+
+ public void drawU(UGraphic ug, int zIndex, Dimension2D dimToUse) {
+ final Dimension2D preferred = getPreferredDimension(ug.getStringBounder(), 0, 0);
+
+ double x1 = 0;
+ if (zIndex == 0) {
+ ug.apply(new UChangeBackColor(HtmlColorSet.getInstance().getColorIfValid("#DDDDDD"))).draw(
+ new URectangle(dimToUse.getWidth(), dimToUse.getHeight()));
+ for (ElementMenuEntry entry : entries) {
+ entry.drawU(ug.apply(new UTranslate(x1, 0)), zIndex, dimToUse);
+ final double w = entry.getPreferredDimension(ug.getStringBounder(), x1, 0).getWidth();
+ entry.setX(x1);
+ x1 += w + 10;
+ }
+ return;
+ }
+
+ if (zIndex == 1) {
+ for (ElementMenuEntry entry : popups.keySet()) {
+ entry.setBackground(HtmlColorSet.getInstance().getColorIfValid("#BBBBBB"));
+ }
+
+ final double y1 = preferred.getHeight();
+ for (Map.Entry<ElementMenuEntry, ElementMenuPopup> ent : popups.entrySet()) {
+ final ElementMenuPopup p = ent.getValue();
+ final double xpopup = ent.getKey().getX();
+ p.drawU(ug.apply(new UTranslate(xpopup, y1)), zIndex,
+ p.getPreferredDimension(ug.getStringBounder(), xpopup, y1));
+ }
+ }
+ }
+}
diff --git a/src/net/sourceforge/plantuml/salt/element/ElementMenuEntry.java b/src/net/sourceforge/plantuml/salt/element/ElementMenuEntry.java
new file mode 100644
index 0000000..17b2277
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/element/ElementMenuEntry.java
@@ -0,0 +1,101 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt.element;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+
+public class ElementMenuEntry extends AbstractElement {
+
+ private final TextBlock block;
+ private final String text;
+ private HtmlColor background;
+ private double xxx;
+
+ public ElementMenuEntry(String text, UFont font, ISkinSimple spriteContainer) {
+ final FontConfiguration config = new FontConfiguration(font, HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true);
+ this.block = TextBlockUtils.create(Display.create(text), config, HorizontalAlignment.LEFT, spriteContainer);
+ this.text = text;
+ }
+
+ public Dimension2D getPreferredDimension(StringBounder stringBounder, double x, double y) {
+ if (text.equals("-")) {
+ return new Dimension2DDouble(10, 5);
+ }
+ return block.calculateDimension(stringBounder);
+ }
+
+ public void drawU(UGraphic ug, int zIndex, Dimension2D dimToUse) {
+ if (background != null) {
+ final Dimension2D dim = getPreferredDimension(ug.getStringBounder(), 0, 0);
+ ug.apply(new UChangeBackColor(background)).draw(new URectangle(dim.getWidth(), dim.getHeight()));
+ }
+ block.drawU(ug);
+ }
+
+ public double getX() {
+ return xxx;
+ }
+
+ public void setX(double x) {
+ this.xxx = x;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public HtmlColor getBackground() {
+ return background;
+ }
+
+ public void setBackground(HtmlColor background) {
+ this.background = background;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/salt/element/ElementMenuPopup.java b/src/net/sourceforge/plantuml/salt/element/ElementMenuPopup.java
new file mode 100644
index 0000000..2de6997
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/element/ElementMenuPopup.java
@@ -0,0 +1,97 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt.element;
+
+import java.awt.geom.Dimension2D;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.graphic.HtmlColorSet;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ElementMenuPopup extends AbstractElement {
+
+ private final Collection<ElementMenuEntry> entries = new ArrayList<ElementMenuEntry>();
+ private final UFont font;
+ private final ISkinSimple spriteContainer;
+
+ public ElementMenuPopup(UFont font, ISkinSimple spriteContainer) {
+ this.font = font;
+ this.spriteContainer = spriteContainer;
+ }
+
+ public void addEntry(String s) {
+ entries.add(new ElementMenuEntry(s, font, spriteContainer));
+ }
+
+ public Dimension2D getPreferredDimension(StringBounder stringBounder, double x, double y) {
+ double w = 0;
+ double h = 0;
+ for (ElementMenuEntry entry : entries) {
+ final Dimension2D dim = entry.getPreferredDimension(stringBounder, x, y);
+ w = Math.max(w, dim.getWidth());
+ h += dim.getHeight();
+ }
+ return new Dimension2DDouble(w, h);
+ }
+
+ public void drawU(UGraphic ug, int zIndex, Dimension2D dimToUse) {
+ if (zIndex != 1) {
+ return;
+ }
+ ug.apply(new UChangeBackColor(HtmlColorSet.getInstance().getColorIfValid("#DDDDDD"))).draw(
+ new URectangle(dimToUse.getWidth(), dimToUse.getHeight()));
+
+ double y1 = 0;
+ for (ElementMenuEntry entry : entries) {
+ final double h = entry.getPreferredDimension(ug.getStringBounder(), 0, y1).getHeight();
+ if (entry.getText().equals("-")) {
+ ug.apply(new UTranslate(0, y1 + h / 2)).draw(new ULine(dimToUse.getWidth(), 0));
+ } else {
+ entry.drawU(ug.apply(new UTranslate(0, y1)), zIndex, dimToUse);
+ }
+ y1 += h;
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/salt/element/ElementPyramid.java b/src/net/sourceforge/plantuml/salt/element/ElementPyramid.java
new file mode 100644
index 0000000..f1aa53d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/element/ElementPyramid.java
@@ -0,0 +1,151 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt.element;
+
+import java.awt.geom.Dimension2D;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.salt.Cell;
+import net.sourceforge.plantuml.salt.Positionner2;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ElementPyramid extends AbstractElement {
+
+ private int rows;
+ private int cols;
+ private final TableStrategy tableStrategy;
+ private final Map<Element, Cell> positions1;
+ private final Map<Cell, Element> positions2 = new HashMap<Cell, Element>();
+
+ private double rowsStart[];
+ private double colsStart[];
+
+ public ElementPyramid(Positionner2 positionner, TableStrategy tableStrategy) {
+ positions1 = positionner.getAll();
+ for (Map.Entry<Element, Cell> ent : positions1.entrySet()) {
+ positions2.put(ent.getValue(), ent.getKey());
+ }
+
+ this.rows = positionner.getNbRows();
+ this.cols = positionner.getNbCols();
+ this.tableStrategy = tableStrategy;
+
+ for (Cell c : positions1.values()) {
+ rows = Math.max(rows, c.getMaxRow());
+ cols = Math.max(cols, c.getMaxCol());
+ }
+
+ }
+
+ public Dimension2D getPreferredDimension(StringBounder stringBounder, double x, double y) {
+ init(stringBounder);
+ return new Dimension2DDouble(colsStart[colsStart.length - 1], rowsStart[rowsStart.length - 1]);
+ }
+
+ public void drawU(UGraphic ug, int zIndex, Dimension2D dimToUse) {
+ init(ug.getStringBounder());
+ final Grid grid = new Grid(rowsStart, colsStart, tableStrategy);
+ for (Map.Entry<Element, Cell> ent : positions1.entrySet()) {
+ final Element elt = ent.getKey();
+ final Cell cell = ent.getValue();
+ final double xcell = colsStart[cell.getMinCol()];
+ final double ycell = rowsStart[cell.getMinRow()];
+ final double width = colsStart[cell.getMaxCol() + 1] - colsStart[cell.getMinCol()] - 1;
+ final double height = rowsStart[cell.getMaxRow() + 1] - rowsStart[cell.getMinRow()] - 1;
+ grid.addCell(cell);
+ elt.drawU(ug.apply(new UTranslate(xcell + 1, ycell + 1)), zIndex, new Dimension2DDouble(width, height));
+ }
+ if (zIndex == 0) {
+ grid.drawU(ug, 0, 0);
+ }
+ }
+
+ private void init(StringBounder stringBounder) {
+ if (rowsStart != null) {
+ return;
+ }
+ rowsStart = new double[rows + 1];
+ colsStart = new double[cols + 1];
+ final List<Cell> all = new ArrayList<Cell>(positions1.values());
+ Collections.sort(all, new LeftFirst());
+ for (Cell cell : all) {
+ final Element elt = positions2.get(cell);
+ final Dimension2D dim = elt.getPreferredDimension(stringBounder, 0, 0);
+ ensureColWidth(cell.getMinCol(), cell.getMaxCol() + 1, dim.getWidth() + 2);
+ }
+ Collections.sort(all, new TopFirst());
+ for (Cell cell : all) {
+ final Element elt = positions2.get(cell);
+ final Dimension2D dim = elt.getPreferredDimension(stringBounder, 0, 0);
+ ensureRowHeight(cell.getMinRow(), cell.getMaxRow() + 1, dim.getHeight() + 2);
+ }
+ }
+
+ private void ensureColWidth(int first, int last, double width) {
+ final double actual = colsStart[last] - colsStart[first];
+ final double missing = width - actual;
+ if (missing > 0) {
+ for (int i = last; i < colsStart.length; i++) {
+ colsStart[i] += missing;
+ }
+ }
+ }
+
+ private void ensureRowHeight(int first, int last, double height) {
+ final double actual = rowsStart[last] - rowsStart[first];
+ final double missing = height - actual;
+ if (missing > 0) {
+ for (int i = last; i < rowsStart.length; i++) {
+ rowsStart[i] += missing;
+ }
+ }
+ }
+
+ public final int getNbRows() {
+ return rows + 1;
+ }
+
+ public final int getNbCols() {
+ return cols + 1;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/salt/element/ElementRadioCheckbox.java b/src/net/sourceforge/plantuml/salt/element/ElementRadioCheckbox.java
new file mode 100644
index 0000000..b36d1df
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/element/ElementRadioCheckbox.java
@@ -0,0 +1,111 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt.element;
+
+import java.awt.geom.Dimension2D;
+import java.util.List;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ElementRadioCheckbox extends AbstractElement {
+
+ private static final int RECTANGLE = 10;
+ private static final int ELLIPSE = 10;
+ private static final int ELLIPSE2 = 4;
+ private final TextBlock block;
+ private final int margin = 20;
+ private final double stroke = 1.5;
+ private final boolean radio;
+ private final boolean checked;
+
+ public ElementRadioCheckbox(List<String> text, UFont font, boolean radio, boolean checked,
+ ISkinSimple spriteContainer) {
+ final FontConfiguration config = new FontConfiguration(font, HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true);
+ this.block = TextBlockUtils.create(Display.create(text), config, HorizontalAlignment.LEFT, spriteContainer);
+ this.radio = radio;
+ this.checked = checked;
+ }
+
+ public Dimension2D getPreferredDimension(StringBounder stringBounder, double x, double y) {
+ final Dimension2D dim = block.calculateDimension(stringBounder);
+ return Dimension2DDouble.delta(dim, margin, 0);
+ }
+
+ public void drawU(UGraphic ug, int zIndex, Dimension2D dimToUse) {
+ if (zIndex != 0) {
+ return;
+ }
+ block.drawU(ug.apply(new UTranslate(margin, 0)));
+
+ final Dimension2D dim = getPreferredDimension(ug.getStringBounder(), 0, 0);
+ final double height = dim.getHeight();
+
+ ug = ug.apply(new UStroke(stroke));
+ if (radio) {
+ ug.apply(new UTranslate(2, (height - ELLIPSE) / 2)).draw(new UEllipse(ELLIPSE, ELLIPSE));
+ if (checked) {
+ ug.apply(new UChangeBackColor(ug.getParam().getColor()))
+ .apply(new UTranslate(2 + (ELLIPSE - ELLIPSE2) / 2, (height - ELLIPSE2) / 2))
+ .draw(new UEllipse(ELLIPSE2, ELLIPSE2));
+ }
+ } else {
+ ug.apply(new UTranslate(2, (height - RECTANGLE) / 2)).draw(new URectangle(RECTANGLE, RECTANGLE));
+ if (checked) {
+ final UPolygon poly = new UPolygon();
+ poly.addPoint(0, 0);
+ poly.addPoint(3, 3);
+ poly.addPoint(10, -6);
+ poly.addPoint(3, 1);
+ ug.apply(new UChangeBackColor(ug.getParam().getColor())).apply(new UTranslate(3, 6)).draw(poly);
+ }
+ }
+ }
+}
diff --git a/src/net/sourceforge/plantuml/salt/element/ElementTabBar.java b/src/net/sourceforge/plantuml/salt/element/ElementTabBar.java
new file mode 100644
index 0000000..73ce12e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/element/ElementTabBar.java
@@ -0,0 +1,151 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt.element;
+
+import java.awt.geom.Dimension2D;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ElementTabBar extends AbstractElement {
+
+ private final Collection<Element> tabs = new ArrayList<Element>();
+ private final UFont font;
+ private final ISkinSimple spriteContainer;
+
+ private final double margin1 = 2;
+ private final double margin2 = 3;
+ private final double margin3 = 10;
+
+ private boolean vertical = false;
+
+ public ElementTabBar(UFont font, ISkinSimple spriteContainer) {
+ this.font = font;
+ this.spriteContainer = spriteContainer;
+ }
+
+ public void addTab(String tab) {
+ final Element elt = new ElementText(Arrays.asList(tab), font, spriteContainer);
+ tabs.add(elt);
+ }
+
+ public Dimension2D getPreferredDimension(StringBounder stringBounder, double x, double y) {
+ if (vertical) {
+ return getPreferredDimensionVertical(stringBounder, x, y);
+ }
+ return getPreferredDimensionHorizontal(stringBounder, x, y);
+
+ }
+
+ private Dimension2D getPreferredDimensionHorizontal(StringBounder stringBounder, double x, double y) {
+ double w = 0;
+ double h = 0;
+ for (Element elt : tabs) {
+ final Dimension2D dim = elt.getPreferredDimension(stringBounder, x, y);
+ w += dim.getWidth() + margin1 + margin2 + margin3;
+ h = Math.max(h, dim.getHeight());
+ }
+ return new Dimension2DDouble(w, h);
+ }
+
+ public void drawU(UGraphic ug, int zIndex, Dimension2D dimToUse) {
+ if (zIndex != 0) {
+ return;
+ }
+ if (vertical) {
+ drawUVertical(ug, 0, 0, zIndex, dimToUse);
+ } else {
+ drawUHorizontal(ug, 0, 0, zIndex, dimToUse);
+ }
+ }
+
+ private void drawUHorizontal(UGraphic ug, final double x, final double y, int zIndex, Dimension2D dimToUse) {
+ double x1 = x;
+ for (Element elt : tabs) {
+ elt.drawU(ug.apply(new UTranslate(x1 + margin1, y)), zIndex, dimToUse);
+ final Dimension2D dimText = elt.getPreferredDimension(ug.getStringBounder(), x1, y);
+ final double w = dimText.getWidth();
+ ug.apply(new UTranslate(x1, y)).draw(new ULine(0, dimText.getHeight()));
+ ug.apply(new UTranslate(x1, y)).draw(new ULine(w + margin1 + margin2, 0));
+ ug.apply(new UTranslate(x1 + w + margin1 + margin2, y)).draw(new ULine(0, dimText.getHeight()));
+ ug.apply(new UTranslate(x1 + w + margin1 + margin2, y + dimText.getHeight())).draw(new ULine(margin3, 0));
+ x1 += w + margin1 + margin2 + margin3;
+ }
+ }
+
+ private Dimension2D getPreferredDimensionVertical(StringBounder stringBounder, double x, double y) {
+ double w = 0;
+ double h = 0;
+ for (Element elt : tabs) {
+ final Dimension2D dim = elt.getPreferredDimension(stringBounder, x, y);
+ h += dim.getHeight() + margin1 + margin2 + margin3;
+ w = Math.max(w, dim.getWidth());
+ }
+ return new Dimension2DDouble(w, h);
+ }
+
+ private void drawUVertical(UGraphic ug, final double x, final double y, int zIndex, Dimension2D dimToUse) {
+ final Dimension2D preferred = getPreferredDimension(ug.getStringBounder(), x, y);
+ ug = ug.apply(new UTranslate(x, y));
+ double y1 = x;
+ for (Element elt : tabs) {
+ elt.drawU(ug.apply(new UTranslate(0, y1 + margin1)), zIndex, dimToUse);
+ final Dimension2D dimText = elt.getPreferredDimension(ug.getStringBounder(), x, y1);
+ final double h = dimText.getHeight();
+ ug.apply(new UTranslate(0, y1)).draw(new ULine(preferred.getWidth(), 0));
+ ug.apply(new UTranslate(0, y1)).draw(new ULine(0, h + margin1 + margin2));
+ ug.apply(new UTranslate(0, y1 + h + margin1 + margin2)).draw(new ULine(preferred.getWidth(), 0));
+ ug.apply(new UTranslate(preferred.getWidth(), y1 + h + margin1 + margin2)).draw(new ULine(0, margin3));
+ y1 += h + margin1 + margin2 + margin3;
+ }
+ }
+
+ public boolean isVertical() {
+ return vertical;
+ }
+
+ public void setVertical(boolean vertical) {
+ this.vertical = vertical;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/salt/element/ElementText.java b/src/net/sourceforge/plantuml/salt/element/ElementText.java
new file mode 100644
index 0000000..26e9a44
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/element/ElementText.java
@@ -0,0 +1,81 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt.element;
+
+import java.awt.geom.Dimension2D;
+import java.util.List;
+
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class ElementText extends AbstractElement {
+
+ private final TextBlock block;
+ private final boolean show;
+ private final String text;
+
+ public ElementText(List<String> text, UFont font, ISkinSimple spriteContainer) {
+ final FontConfiguration config = new FontConfiguration(font, HtmlColorUtils.BLACK, HtmlColorUtils.BLUE, true);
+ this.block = TextBlockUtils.create(Display.create(text), config, HorizontalAlignment.LEFT, spriteContainer);
+ this.show = text.get(0).equals(".") == false;
+ this.text = text.get(0);
+ }
+
+ public Dimension2D getPreferredDimension(StringBounder stringBounder, double x, double y) {
+ return block.calculateDimension(stringBounder);
+ }
+
+ public void drawU(UGraphic ug, int zIndex, Dimension2D dimToUse) {
+ if (zIndex != 0) {
+ return;
+ }
+ if (show) {
+ block.drawU(ug);
+ }
+ }
+
+ public final String getText() {
+ return text;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/salt/element/ElementTextField.java b/src/net/sourceforge/plantuml/salt/element/ElementTextField.java
new file mode 100644
index 0000000..dddc4b9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/element/ElementTextField.java
@@ -0,0 +1,71 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt.element;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ElementTextField extends AbstractElementText implements Element {
+
+ public ElementTextField(String text, UFont font, ISkinSimple spriteContainer) {
+ super(text, font, true, spriteContainer);
+ }
+
+ public Dimension2D getPreferredDimension(StringBounder stringBounder, double x, double y) {
+ final Dimension2D dim = getTextDimensionAt(stringBounder, x);
+ return Dimension2DDouble.delta(dim, 6, 2);
+ }
+
+ public void drawU(UGraphic ug, int zIndex, Dimension2D dimToUse) {
+ if (zIndex != 0) {
+ return;
+ }
+ drawText(ug, 3, 0);
+ final Dimension2D dim = getPreferredDimension(ug.getStringBounder(), 0, 0);
+ final Dimension2D textDim = getTextDimensionAt(ug.getStringBounder(), 0);
+ ug.apply(new UTranslate(1, textDim.getHeight())).draw(new ULine(dim.getWidth() - 3, 0));
+ final double y3 = textDim.getHeight() - 3;
+ ug.apply(new UTranslate(1, y3)).draw(new ULine(0, 2));
+ ug.apply(new UTranslate(3 + textDim.getWidth() + 1, y3)).draw(new ULine(0, 2));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/salt/element/ElementTree.java b/src/net/sourceforge/plantuml/salt/element/ElementTree.java
new file mode 100644
index 0000000..b05ef09
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/element/ElementTree.java
@@ -0,0 +1,209 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt.element;
+
+import java.awt.geom.Dimension2D;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.graphic.HtmlColorSet;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ElementTree extends AbstractElement {
+
+ private final List<ElementTreeEntry> entries = new ArrayList<ElementTreeEntry>();
+ private final UFont font;
+ private final ISkinSimple spriteContainer;
+ private final double margin = 10;
+ private final TableStrategy strategy;
+
+ public ElementTree(UFont font, ISkinSimple spriteContainer, TableStrategy strategy) {
+ this.font = font;
+ this.spriteContainer = spriteContainer;
+ this.strategy = strategy;
+ }
+
+ public void addEntry(String s) {
+ int level = 0;
+ while (s.startsWith("+")) {
+ level++;
+ s = s.substring(1);
+ }
+ final Element elmt = new ElementText(Arrays.asList(s.trim()), font, spriteContainer);
+ entries.add(new ElementTreeEntry(level, elmt));
+ }
+
+ public void addCellToEntry(String s) {
+ final int size = entries.size();
+ if (size > 0) {
+ final Element elmt = new ElementText(Arrays.asList(s.trim()), font, spriteContainer);
+ entries.get(size - 1).addCell(elmt);
+ }
+ }
+
+ public Dimension2D getPreferredDimension(StringBounder stringBounder, double x, double y) {
+ double w1 = 0;
+ double h = 0;
+ for (ElementTreeEntry entry : entries) {
+ final Dimension2D dim1 = entry.getPreferredDimensionFirstCell(stringBounder);
+ w1 = Math.max(w1, dim1.getWidth());
+ h += dim1.getHeight();
+ }
+ double w2 = getWidthOther(stringBounder).getTotalWidthWithMargin(margin);
+ if (w2 > 0) {
+ w2 += margin;
+ }
+ return new Dimension2DDouble(w1 + w2 + 2, h);
+ }
+
+ private ListWidth getWidthOther(StringBounder stringBounder) {
+ ListWidth merge = new ListWidth();
+ for (ElementTreeEntry entry : entries) {
+ final ListWidth dim2 = entry.getPreferredDimensionOtherCell(stringBounder);
+ merge = merge.mergeMax(dim2);
+ }
+ return merge;
+ }
+
+ private double getWidth1(StringBounder stringBounder) {
+ double w1 = 0;
+ for (ElementTreeEntry entry : entries) {
+ final Dimension2D dim1 = entry.getPreferredDimensionFirstCell(stringBounder);
+ w1 = Math.max(w1, dim1.getWidth());
+ }
+ return w1;
+ }
+
+ public void drawU(UGraphic ug, int zIndex, Dimension2D dimToUse) {
+ if (zIndex != 0) {
+ return;
+ }
+
+ final StringBounder stringBounder = ug.getStringBounder();
+ final double w1 = getWidth1(stringBounder);
+ final ListWidth otherWidth = getWidthOther(stringBounder);
+ final Skeleton skeleton = new Skeleton();
+ double yvar = 0;
+ final List<Double> rows = new ArrayList<Double>();
+ final List<Double> cols = new ArrayList<Double>();
+ rows.add(yvar);
+ double xvar = 0;
+ cols.add(xvar);
+ xvar += w1 + margin / 2;
+ cols.add(xvar);
+ for (final Iterator<Double> it = otherWidth.iterator(); it.hasNext();) {
+ xvar += it.next() + margin;
+ cols.add(xvar);
+ }
+
+ for (ElementTreeEntry entry : entries) {
+ entry.drawFirstCell(ug, 0, yvar);
+ entry.drawSecondCell(ug, w1 + margin, yvar, otherWidth, margin);
+ final double h = entry.getPreferredDimensionFirstCell(stringBounder).getHeight();
+ skeleton.add(entry.getXDelta() - 7, yvar + h / 2 - 1);
+ yvar += h;
+ rows.add(yvar);
+ }
+ ug = ug.apply(new UChangeColor(HtmlColorSet.getInstance().getColorIfValid("#888888")));
+ skeleton.draw(ug, 0, 0);
+ if (strategy != TableStrategy.DRAW_NONE) {
+ final Grid2 grid = new Grid2(rows, cols, strategy);
+ grid.drawU(ug);
+ }
+ }
+
+ static class Skeleton {
+
+ private final List<Entry> entries = new ArrayList<Entry>();
+
+ static class Entry {
+ private final double xpos;
+ private final double ypos;
+
+ public Entry(double x, double y) {
+ this.xpos = x;
+ this.ypos = y;
+ }
+
+ public void drawRectangle(UGraphic ug) {
+ ug.apply(new UTranslate(xpos, ypos)).draw(new URectangle(2, 2));
+ }
+ }
+
+ public void add(double x, double y) {
+ entries.add(new Entry(x, y));
+ }
+
+ public void draw(UGraphic ug, double x, double y) {
+ for (int i = 0; i < entries.size(); i++) {
+ final Entry en = entries.get(i);
+ if (i + 1 < entries.size() && entries.get(i + 1).xpos > en.xpos) {
+ en.drawRectangle(ug);
+ }
+ Entry parent = null;
+ for (int j = 0; j < i; j++) {
+ final Entry en0 = entries.get(j);
+ if (en0.xpos < en.xpos) {
+ parent = en0;
+ }
+ }
+ if (parent != null) {
+ drawChild(ug, parent, en);
+ }
+ }
+ }
+
+ private void drawChild(UGraphic ug, Entry parent, Entry child) {
+ final double dy = child.ypos - parent.ypos - 2;
+ ug.apply(new UTranslate(parent.xpos + 1, parent.ypos + 3)).draw(new ULine(0, dy));
+
+ final double dx = child.xpos - parent.xpos - 2;
+ ug.apply(new UTranslate(parent.xpos + 1, child.ypos + 1)).draw(new ULine(dx, 0));
+
+ }
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/salt/element/ElementTreeEntry.java b/src/net/sourceforge/plantuml/salt/element/ElementTreeEntry.java
new file mode 100644
index 0000000..4b928b0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/element/ElementTreeEntry.java
@@ -0,0 +1,90 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt.element;
+
+import java.awt.geom.Dimension2D;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ElementTreeEntry {
+
+ private final Element firstElement;
+ private final int level;
+ private final List<Element> otherElements = new ArrayList<Element>();
+
+ public ElementTreeEntry(int level, Element elmt) {
+ this.firstElement = elmt;
+ this.level = level;
+ }
+
+ public void addCell(Element elmt) {
+ this.otherElements.add(elmt);
+ }
+
+ public Dimension2D getPreferredDimensionFirstCell(StringBounder stringBounder) {
+ return Dimension2DDouble.delta(firstElement.getPreferredDimension(stringBounder, 0, 0), getXDelta(), 0);
+ }
+
+ public ListWidth getPreferredDimensionOtherCell(StringBounder stringBounder) {
+ final ListWidth result = new ListWidth();
+ for (Element element : otherElements) {
+ result.add(element.getPreferredDimension(stringBounder, 0, 0).getWidth());
+ }
+ return result;
+ }
+
+ public double getXDelta() {
+ return level * 10;
+ }
+
+ public void drawFirstCell(UGraphic ug, double x, double y) {
+ firstElement.drawU(ug.apply(new UTranslate(x + getXDelta(), y)), 0, null);
+ }
+
+ public void drawSecondCell(UGraphic ug, double x, double y, ListWidth otherWidth, double margin) {
+ final Iterator<Double> it = otherWidth.iterator();
+ for (Element element : otherElements) {
+ element.drawU(ug.apply(new UTranslate(x, y)), 0, null);
+ x += it.next() + margin;
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/salt/element/Grid.java b/src/net/sourceforge/plantuml/salt/element/Grid.java
new file mode 100644
index 0000000..019d720
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/element/Grid.java
@@ -0,0 +1,118 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt.element;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import net.sourceforge.plantuml.salt.Cell;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class Grid {
+
+ private final double[] rowsStart;
+ private final double[] colsStart;
+ private final TableStrategy strategy;
+
+ private final Set<Segment> horizontals = new HashSet<Segment>();
+ private final Set<Segment> verticals = new HashSet<Segment>();
+
+ public Grid(double[] rowsStart, double[] colsStart, TableStrategy strategy) {
+ this.rowsStart = rowsStart;
+ this.colsStart = colsStart;
+ this.strategy = strategy;
+ if (strategy == TableStrategy.DRAW_OUTSIDE || strategy == TableStrategy.DRAW_ALL) {
+ addOutside();
+ }
+ }
+
+ private void addOutside() {
+ final int nbRow = rowsStart.length;
+ final int nbCol = colsStart.length;
+ for (int c = 0; c < nbCol - 1; c++) {
+ horizontals.add(new Segment(0, c));
+ horizontals.add(new Segment(nbRow - 1, c));
+ }
+ for (int r = 0; r < nbRow - 1; r++) {
+ verticals.add(new Segment(r, 0));
+ verticals.add(new Segment(r, nbCol - 1));
+ }
+
+ }
+
+ public void drawU(UGraphic ug, double x, double y) {
+ // Hlines
+ for (Segment seg : horizontals) {
+ final int row1 = seg.getRow();
+ final int col1 = seg.getCol();
+ final double width = colsStart[col1 + 1] - colsStart[col1];
+ ug.apply(new UTranslate(x + colsStart[col1], y + rowsStart[row1])).draw(new ULine(width, 0));
+ }
+ // Vlines
+ for (Segment seg : verticals) {
+ final int row1 = seg.getRow();
+ final int col1 = seg.getCol();
+ final double height = rowsStart[row1 + 1] - rowsStart[row1];
+ ug.apply(new UTranslate(x + colsStart[col1], y + rowsStart[row1])).draw(new ULine(0, height));
+ }
+ }
+
+ public void addCell(Cell cell) {
+
+ if (strategy == TableStrategy.DRAW_NONE) {
+ return;
+ }
+ if (strategy == TableStrategy.DRAW_OUTSIDE) {
+ return;
+ }
+
+ if (strategy == TableStrategy.DRAW_HORIZONTAL || strategy == TableStrategy.DRAW_ALL) {
+ // Hlines
+ for (int c = cell.getMinCol(); c <= cell.getMaxCol(); c++) {
+ horizontals.add(new Segment(cell.getMinRow(), c));
+ horizontals.add(new Segment(cell.getMaxRow() + 1, c));
+ }
+ }
+ if (strategy == TableStrategy.DRAW_VERTICAL || strategy == TableStrategy.DRAW_ALL) {
+ // Vlines
+ for (int r = cell.getMinRow(); r <= cell.getMaxRow(); r++) {
+ verticals.add(new Segment(r, cell.getMinCol()));
+ verticals.add(new Segment(r, cell.getMaxCol() + 1));
+ }
+ }
+ }
+}
diff --git a/src/net/sourceforge/plantuml/salt/element/Grid2.java b/src/net/sourceforge/plantuml/salt/element/Grid2.java
new file mode 100644
index 0000000..cd93ca8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/element/Grid2.java
@@ -0,0 +1,92 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt.element;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class Grid2 {
+
+ private final List<Double> rowsStart;
+ private final List<Double> colsStart;
+ private final TableStrategy strategy;
+
+ public Grid2(List<Double> rowsStart, List<Double> colsStart, TableStrategy strategy) {
+ this.rowsStart = rowsStart;
+ this.colsStart = colsStart;
+ this.strategy = strategy;
+ }
+
+ public void drawU(UGraphic ug) {
+ final double xmin = colsStart.get(0);
+ final double xmax = colsStart.get(colsStart.size() - 1);
+ final double ymin = rowsStart.get(0);
+ final double ymax = rowsStart.get(rowsStart.size() - 1);
+ if (strategy == TableStrategy.DRAW_OUTSIDE) {
+ ug.apply(new UTranslate(xmin, ymin)).draw(new ULine(xmax - xmin, 0));
+ ug.apply(new UTranslate(xmin, ymax)).draw(new ULine(xmax - xmin, 0));
+ ug.apply(new UTranslate(xmin, ymin)).draw(new ULine(0, ymax - ymin));
+ ug.apply(new UTranslate(xmax, ymin)).draw(new ULine(0, ymax - ymin));
+ }
+ if (drawHorizontal()) {
+ for (Double y : rowsStart) {
+ ug.apply(new UTranslate(xmin, y)).draw(new ULine(xmax - xmin, 0));
+ }
+ }
+ if (drawVertical()) {
+ for (Double x : colsStart) {
+ ug.apply(new UTranslate(x, ymin)).draw(new ULine(0, ymax - ymin));
+ }
+ }
+ }
+
+ private boolean drawHorizontal() {
+ if (strategy == TableStrategy.DRAW_HORIZONTAL || strategy == TableStrategy.DRAW_ALL) {
+ return true;
+ }
+ return false;
+ }
+
+ private boolean drawVertical() {
+ if (strategy == TableStrategy.DRAW_VERTICAL || strategy == TableStrategy.DRAW_ALL) {
+ return true;
+ }
+ return false;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/salt/element/LeftFirst.java b/src/net/sourceforge/plantuml/salt/element/LeftFirst.java
new file mode 100644
index 0000000..63a5dc3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/element/LeftFirst.java
@@ -0,0 +1,52 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt.element;
+
+import java.util.Comparator;
+
+import net.sourceforge.plantuml.salt.Cell;
+
+class LeftFirst implements Comparator<Cell> {
+
+ public int compare(Cell c0, Cell c1) {
+ final int diffNb = c0.getNbCols() - c1.getNbCols();
+ if (diffNb != 0) {
+ return diffNb;
+ }
+ final int diffPos = c0.getMinCol() - c1.getMinCol();
+ return diffPos;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/salt/element/ListWidth.java b/src/net/sourceforge/plantuml/salt/element/ListWidth.java
new file mode 100644
index 0000000..866c675
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/element/ListWidth.java
@@ -0,0 +1,81 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt.element;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+public class ListWidth {
+
+ private final List<Double> allWidth = new ArrayList<Double>();
+
+ public void add(double width) {
+ this.allWidth.add(width);
+ }
+
+ public ListWidth mergeMax(ListWidth other) {
+ final ListWidth result = new ListWidth();
+ for (int i = 0; i < this.allWidth.size() || i < other.allWidth.size(); i++) {
+ final double w1 = this.getWidthSafe(i);
+ final double w2 = other.getWidthSafe(i);
+ result.add(Math.max(w1, w2));
+ }
+ return result;
+ }
+
+ private double getWidthSafe(int i) {
+ if (i < allWidth.size()) {
+ return allWidth.get(i);
+ }
+ return 0;
+ }
+
+ public double getTotalWidthWithMargin(final double margin) {
+ double result = 0;
+ for (Double w : allWidth) {
+ if (result > 0) {
+ result += margin;
+ }
+ result += w;
+ }
+ return result;
+ }
+
+ public Iterator<Double> iterator() {
+ return allWidth.iterator();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/salt/element/Segment.java b/src/net/sourceforge/plantuml/salt/element/Segment.java
new file mode 100644
index 0000000..4e3ae28
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/element/Segment.java
@@ -0,0 +1,66 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt.element;
+
+public class Segment {
+
+ private final int row;
+ private final int col;
+
+ public Segment(int row, int col) {
+ this.row = row;
+ this.col = col;
+ }
+
+ @Override
+ public int hashCode() {
+ return row * 47 + col;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ final Segment this2 = (Segment) obj;
+ return row == this2.row && col == this2.col;
+ }
+
+ public final int getRow() {
+ return row;
+ }
+
+ public final int getCol() {
+ return col;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/salt/element/TableStrategy.java b/src/net/sourceforge/plantuml/salt/element/TableStrategy.java
new file mode 100644
index 0000000..c4370f8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/element/TableStrategy.java
@@ -0,0 +1,54 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt.element;
+
+public enum TableStrategy {
+ DRAW_NONE(' '), DRAW_OUTSIDE('+'), DRAW_HORIZONTAL('-'), DRAW_VERTICAL('!'), DRAW_ALL('#');
+
+ private final char c;
+
+ private TableStrategy(char c) {
+ this.c = c;
+ }
+
+ public static TableStrategy fromChar(char c) {
+ for (TableStrategy t : TableStrategy.values()) {
+ if (c == t.c) {
+ return t;
+ }
+ }
+ return null;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/salt/element/TopFirst.java b/src/net/sourceforge/plantuml/salt/element/TopFirst.java
new file mode 100644
index 0000000..3ddedb6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/element/TopFirst.java
@@ -0,0 +1,52 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt.element;
+
+import java.util.Comparator;
+
+import net.sourceforge.plantuml.salt.Cell;
+
+class TopFirst implements Comparator<Cell> {
+
+ public int compare(Cell c0, Cell c1) {
+ final int diffNb = c0.getNbRows() - c1.getNbRows();
+ if (diffNb != 0) {
+ return diffNb;
+ }
+ final int diffPos = c0.getMinRow() - c1.getMinRow();
+ return diffPos;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/salt/element/WrappedElement.java b/src/net/sourceforge/plantuml/salt/element/WrappedElement.java
new file mode 100644
index 0000000..4b11b1a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/element/WrappedElement.java
@@ -0,0 +1,58 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt.element;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class WrappedElement implements Element {
+
+ private final Element wrapped;
+
+ public WrappedElement(Element element) {
+ this.wrapped = element;
+ }
+
+ public Dimension2D getPreferredDimension(StringBounder stringBounder, double x, double y) {
+ return wrapped.getPreferredDimension(stringBounder, 0, 0);
+ }
+
+ public void drawU(UGraphic ug, int zIndex, Dimension2D dimToUse) {
+ wrapped.drawU(ug, zIndex, dimToUse);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/salt/factory/AbstractElementFactoryComplex.java b/src/net/sourceforge/plantuml/salt/factory/AbstractElementFactoryComplex.java
new file mode 100644
index 0000000..206852f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/factory/AbstractElementFactoryComplex.java
@@ -0,0 +1,78 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt.factory;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import net.sourceforge.plantuml.salt.DataSource;
+import net.sourceforge.plantuml.salt.Dictionary;
+import net.sourceforge.plantuml.salt.Terminated;
+import net.sourceforge.plantuml.salt.element.Element;
+
+public abstract class AbstractElementFactoryComplex implements ElementFactory {
+
+ final private DataSource dataSource;
+ final private Collection<ElementFactory> factories = new ArrayList<ElementFactory>();
+ final private Dictionary dictionary;
+
+
+ public AbstractElementFactoryComplex(DataSource dataSource, Dictionary dictionary) {
+ this.dataSource = dataSource;
+ this.dictionary = dictionary;
+ }
+
+ final public void addFactory(ElementFactory factory) {
+ factories.add(factory);
+ }
+
+ protected Terminated<Element> getNextElement() {
+ for (ElementFactory factory : factories) {
+ if (factory.ready()) {
+ return factory.create();
+ }
+ }
+ throw new IllegalStateException(dataSource.peek(0).getElement());
+ }
+
+ protected final DataSource getDataSource() {
+ return dataSource;
+ }
+
+ protected final Dictionary getDictionary() {
+ return dictionary;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/salt/factory/ElementFactory.java b/src/net/sourceforge/plantuml/salt/factory/ElementFactory.java
new file mode 100644
index 0000000..c1d088f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/factory/ElementFactory.java
@@ -0,0 +1,46 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt.factory;
+
+import net.sourceforge.plantuml.salt.Terminated;
+import net.sourceforge.plantuml.salt.element.Element;
+
+public interface ElementFactory {
+
+ Terminated<Element> create();
+
+ boolean ready();
+
+}
diff --git a/src/net/sourceforge/plantuml/salt/factory/ElementFactoryBorder.java b/src/net/sourceforge/plantuml/salt/factory/ElementFactoryBorder.java
new file mode 100644
index 0000000..cae3d19
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/factory/ElementFactoryBorder.java
@@ -0,0 +1,101 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt.factory;
+
+import net.sourceforge.plantuml.salt.DataSource;
+import net.sourceforge.plantuml.salt.Dictionary;
+import net.sourceforge.plantuml.salt.Terminated;
+import net.sourceforge.plantuml.salt.element.Element;
+import net.sourceforge.plantuml.salt.element.ElementBorder;
+
+public class ElementFactoryBorder extends AbstractElementFactoryComplex {
+
+ public ElementFactoryBorder(DataSource dataSource, Dictionary dictionary) {
+ super(dataSource, dictionary);
+ }
+
+ public Terminated<Element> create() {
+ if (ready() == false) {
+ throw new IllegalStateException();
+ }
+ final String header = getDataSource().next().getElement();
+ assert header.startsWith("{");
+
+// TableStrategy strategy = TableStrategy.DRAW_NONE;
+// if (header.length() == 2) {
+// strategy = TableStrategy.fromChar(header.charAt(1));
+// }
+
+ final ElementBorder result = new ElementBorder();
+
+ while (getDataSource().peek(0).getElement().equals("}") == false) {
+ final String pos = getDataSource().next().getElement();
+ switch (pos.charAt(0)) {
+ case 'N':
+ result.setNorth(getNextElement().getElement());
+ break;
+ case 'S':
+ result.setSouth(getNextElement().getElement());
+ break;
+ case 'E':
+ result.setEast(getNextElement().getElement());
+ break;
+ case 'W':
+ result.setWest(getNextElement().getElement());
+ break;
+ case 'C':
+ result.setCenter(getNextElement().getElement());
+ break;
+ default:
+ throw new IllegalStateException();
+
+ }
+ }
+ final Terminated<String> next = getDataSource().next();
+ return new Terminated<Element>(result, next.getTerminator());
+ }
+
+ public boolean ready() {
+ final String text = getDataSource().peek(0).getElement();
+ if (text.equals("{") || text.equals("{+") || text.equals("{#") || text.equals("{!") || text.equals("{-")) {
+ final String text1 = getDataSource().peek(1).getElement();
+ if (text1.matches("[NSEW]=")) {
+ return true;
+ }
+ return false;
+ }
+ return false;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/salt/factory/ElementFactoryButton.java b/src/net/sourceforge/plantuml/salt/factory/ElementFactoryButton.java
new file mode 100644
index 0000000..6be09eb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/factory/ElementFactoryButton.java
@@ -0,0 +1,71 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt.factory;
+
+import java.awt.Font;
+
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.salt.DataSource;
+import net.sourceforge.plantuml.salt.Terminated;
+import net.sourceforge.plantuml.salt.element.Element;
+import net.sourceforge.plantuml.salt.element.ElementButton;
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public class ElementFactoryButton implements ElementFactory {
+
+ final private DataSource dataSource;
+ final private ISkinSimple spriteContainer;
+
+ public ElementFactoryButton(DataSource dataSource, ISkinSimple spriteContainer) {
+ this.dataSource = dataSource;
+ this.spriteContainer = spriteContainer;
+ }
+
+ public Terminated<Element> create() {
+ if (ready() == false) {
+ throw new IllegalStateException();
+ }
+ final Terminated<String> next = dataSource.next();
+ final String text = next.getElement();
+ final UFont font = new UFont("Default", Font.PLAIN, 12);
+ return new Terminated<Element>(new ElementButton(text.substring(1, text.length() - 1), font, spriteContainer),
+ next.getTerminator());
+ }
+
+ public boolean ready() {
+ final String text = dataSource.peek(0).getElement();
+ return text.startsWith("[") && text.endsWith("]");
+ }
+}
diff --git a/src/net/sourceforge/plantuml/salt/factory/ElementFactoryCheckboxOff.java b/src/net/sourceforge/plantuml/salt/factory/ElementFactoryCheckboxOff.java
new file mode 100644
index 0000000..d336918
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/factory/ElementFactoryCheckboxOff.java
@@ -0,0 +1,78 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt.factory;
+
+import java.awt.Font;
+import java.util.Arrays;
+import java.util.List;
+
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.salt.DataSource;
+import net.sourceforge.plantuml.salt.Terminated;
+import net.sourceforge.plantuml.salt.element.Element;
+import net.sourceforge.plantuml.salt.element.ElementRadioCheckbox;
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public class ElementFactoryCheckboxOff implements ElementFactory {
+
+ final private DataSource dataSource;
+ final private ISkinSimple spriteContainer;
+
+ public ElementFactoryCheckboxOff(DataSource dataSource, ISkinSimple spriteContainer) {
+ this.dataSource = dataSource;
+ this.spriteContainer = spriteContainer;
+ }
+
+ public Terminated<Element> create() {
+ if (ready() == false) {
+ throw new IllegalStateException();
+ }
+ final Terminated<String> next = dataSource.next();
+ final String text = next.getElement();
+ final UFont font = new UFont("Default", Font.PLAIN, 12);
+ return new Terminated<Element>(new ElementRadioCheckbox(extracted(text), font, false, false, spriteContainer),
+ next.getTerminator());
+ }
+
+ private List<String> extracted(final String text) {
+ final int x = text.indexOf(']');
+ return Arrays.asList(text.substring(x + 1).trim());
+ }
+
+ public boolean ready() {
+ final String text = dataSource.peek(0).getElement();
+ return text.startsWith("[]") || text.startsWith("[ ]");
+ }
+}
diff --git a/src/net/sourceforge/plantuml/salt/factory/ElementFactoryCheckboxOn.java b/src/net/sourceforge/plantuml/salt/factory/ElementFactoryCheckboxOn.java
new file mode 100644
index 0000000..7562f84
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/factory/ElementFactoryCheckboxOn.java
@@ -0,0 +1,78 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt.factory;
+
+import java.awt.Font;
+import java.util.Arrays;
+import java.util.List;
+
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.salt.DataSource;
+import net.sourceforge.plantuml.salt.Terminated;
+import net.sourceforge.plantuml.salt.element.Element;
+import net.sourceforge.plantuml.salt.element.ElementRadioCheckbox;
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public class ElementFactoryCheckboxOn implements ElementFactory {
+
+ final private DataSource dataSource;
+ final private ISkinSimple spriteContainer;
+
+ public ElementFactoryCheckboxOn(DataSource dataSource, ISkinSimple spriteContainer) {
+ this.dataSource = dataSource;
+ this.spriteContainer = spriteContainer;
+ }
+
+ public Terminated<Element> create() {
+ if (ready() == false) {
+ throw new IllegalStateException();
+ }
+ final Terminated<String> next = dataSource.next();
+ final String text = next.getElement();
+ final UFont font = new UFont("Default", Font.PLAIN, 12);
+ return new Terminated<Element>(new ElementRadioCheckbox(extracted(text), font, false, true, spriteContainer),
+ next.getTerminator());
+ }
+
+ private List<String> extracted(final String text) {
+ final int x = text.indexOf(']');
+ return Arrays.asList(text.substring(x + 1).trim());
+ }
+
+ public boolean ready() {
+ final String text = dataSource.peek(0).getElement();
+ return text.startsWith("[X]");
+ }
+}
diff --git a/src/net/sourceforge/plantuml/salt/factory/ElementFactoryDroplist.java b/src/net/sourceforge/plantuml/salt/factory/ElementFactoryDroplist.java
new file mode 100644
index 0000000..7cb0cff
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/factory/ElementFactoryDroplist.java
@@ -0,0 +1,71 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt.factory;
+
+import java.awt.Font;
+
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.salt.DataSource;
+import net.sourceforge.plantuml.salt.Terminated;
+import net.sourceforge.plantuml.salt.element.Element;
+import net.sourceforge.plantuml.salt.element.ElementDroplist;
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public class ElementFactoryDroplist implements ElementFactory {
+
+ final private DataSource dataSource;
+ final private ISkinSimple spriteContainer;
+
+ public ElementFactoryDroplist(DataSource dataSource, ISkinSimple spriteContainer) {
+ this.dataSource = dataSource;
+ this.spriteContainer = spriteContainer;
+ }
+
+ public Terminated<Element> create() {
+ if (ready() == false) {
+ throw new IllegalStateException();
+ }
+ final Terminated<String> next = dataSource.next();
+ final String text = next.getElement();
+ final UFont font = new UFont("Default", Font.PLAIN, 12);
+ return new Terminated<Element>(new ElementDroplist(text.substring(1, text.length() - 1), font, spriteContainer),
+ next.getTerminator());
+ }
+
+ public boolean ready() {
+ final String text = dataSource.peek(0).getElement();
+ return text.startsWith("^") && text.endsWith("^");
+ }
+}
diff --git a/src/net/sourceforge/plantuml/salt/factory/ElementFactoryImage.java b/src/net/sourceforge/plantuml/salt/factory/ElementFactoryImage.java
new file mode 100644
index 0000000..60a44e4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/factory/ElementFactoryImage.java
@@ -0,0 +1,78 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt.factory;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.salt.DataSource;
+import net.sourceforge.plantuml.salt.Dictionary;
+import net.sourceforge.plantuml.salt.Terminated;
+import net.sourceforge.plantuml.salt.element.Element;
+import net.sourceforge.plantuml.salt.element.ElementImage;
+
+public class ElementFactoryImage implements ElementFactory {
+
+ final private DataSource dataSource;
+ final private Dictionary dictionary;
+
+ public ElementFactoryImage(DataSource dataSource, Dictionary dictionary) {
+ this.dataSource = dataSource;
+ this.dictionary = dictionary;
+ }
+
+ public Terminated<Element> create() {
+ if (ready() == false) {
+ throw new IllegalStateException();
+ }
+ final String header = dataSource.next().getElement();
+ final String name = header.length() > 2 ? header.substring(2) : null;
+ final List<String> img = new ArrayList<String>();
+ while (dataSource.peek(0).getElement().equals(">>") == false) {
+ img.add(dataSource.next().getElement());
+ }
+ final Terminated<String> next = dataSource.next();
+ final ElementImage element = new ElementImage(img);
+ if (name != null) {
+ dictionary.put(name, element);
+ }
+ return new Terminated<Element>(element, next.getTerminator());
+ }
+
+ public boolean ready() {
+ final String text = dataSource.peek(0).getElement();
+ return text.equals("<<") || text.matches("\\<\\<\\w+");
+ }
+}
diff --git a/src/net/sourceforge/plantuml/salt/factory/ElementFactoryLine.java b/src/net/sourceforge/plantuml/salt/factory/ElementFactoryLine.java
new file mode 100644
index 0000000..8091ffe
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/factory/ElementFactoryLine.java
@@ -0,0 +1,80 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt.factory;
+
+import net.sourceforge.plantuml.salt.DataSource;
+import net.sourceforge.plantuml.salt.Terminated;
+import net.sourceforge.plantuml.salt.element.Element;
+import net.sourceforge.plantuml.salt.element.ElementLine;
+
+public class ElementFactoryLine implements ElementFactory {
+
+ final private DataSource dataSource;
+
+ public ElementFactoryLine(DataSource dataSource) {
+ this.dataSource = dataSource;
+ }
+
+ public Terminated<Element> create() {
+ if (ready() == false) {
+ throw new IllegalStateException();
+ }
+ final Terminated<String> next = dataSource.next();
+ final String text = next.getElement();
+ return new Terminated<Element>(new ElementLine(text.charAt(0)), next.getTerminator());
+ }
+
+ public boolean ready() {
+ final String text = dataSource.peek(0).getElement();
+ if (isLine(text, '-')) {
+ return true;
+ }
+ if (isLine(text, '=')) {
+ return true;
+ }
+ if (isLine(text, '~')) {
+ return true;
+ }
+ if (isLine(text, '.')) {
+ return true;
+ }
+ return false;
+ }
+
+ private boolean isLine(String text, char c) {
+ final String s = "" + c + c;
+ return text.startsWith(s) && text.endsWith(s);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/salt/factory/ElementFactoryMenu.java b/src/net/sourceforge/plantuml/salt/factory/ElementFactoryMenu.java
new file mode 100644
index 0000000..2b7dfb0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/factory/ElementFactoryMenu.java
@@ -0,0 +1,90 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt.factory;
+
+import java.awt.Font;
+
+import net.sourceforge.plantuml.salt.DataSource;
+import net.sourceforge.plantuml.salt.Dictionary;
+import net.sourceforge.plantuml.salt.Terminated;
+import net.sourceforge.plantuml.salt.Terminator;
+import net.sourceforge.plantuml.salt.element.Element;
+import net.sourceforge.plantuml.salt.element.ElementMenuBar;
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public class ElementFactoryMenu extends AbstractElementFactoryComplex {
+
+ public ElementFactoryMenu(DataSource dataSource, Dictionary dictionary) {
+ super(dataSource, dictionary);
+ }
+
+ public Terminated<Element> create() {
+ if (ready() == false) {
+ throw new IllegalStateException();
+ }
+ final String header = getDataSource().next().getElement();
+ assert header.startsWith("{*");
+
+ final UFont font = new UFont("Default", Font.PLAIN, 12);
+ final ElementMenuBar result = new ElementMenuBar(font, getDictionary());
+
+ String subentry = null;
+
+ while (getDataSource().peek(0).getElement().equals("}") == false) {
+ final Terminated<String> t = getDataSource().next();
+ final String s = t.getElement();
+ if (subentry == null) {
+ result.addEntry(s);
+ } else if (subentry.length() == 0) {
+ subentry = s;
+ } else {
+ result.addSubEntry(subentry, s);
+ }
+ if (t.getTerminator() == Terminator.NEWLINE) {
+ subentry = "";
+ }
+ }
+ final Terminated<String> next = getDataSource().next();
+ return new Terminated<Element>(result, next.getTerminator());
+ }
+
+ public boolean ready() {
+ final String text = getDataSource().peek(0).getElement();
+ if (text.equals("{*")) {
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/salt/factory/ElementFactoryPyramid.java b/src/net/sourceforge/plantuml/salt/factory/ElementFactoryPyramid.java
new file mode 100644
index 0000000..7925ee4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/factory/ElementFactoryPyramid.java
@@ -0,0 +1,96 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt.factory;
+
+import net.sourceforge.plantuml.salt.DataSource;
+import net.sourceforge.plantuml.salt.Dictionary;
+import net.sourceforge.plantuml.salt.Positionner2;
+import net.sourceforge.plantuml.salt.Terminated;
+import net.sourceforge.plantuml.salt.element.Element;
+import net.sourceforge.plantuml.salt.element.ElementPyramid;
+import net.sourceforge.plantuml.salt.element.ElementText;
+import net.sourceforge.plantuml.salt.element.TableStrategy;
+
+public class ElementFactoryPyramid extends AbstractElementFactoryComplex {
+
+ public ElementFactoryPyramid(DataSource dataSource, Dictionary dictionary) {
+ super(dataSource, dictionary);
+ }
+
+ public Terminated<Element> create() {
+ if (ready() == false) {
+ throw new IllegalStateException();
+ }
+ final String header = getDataSource().next().getElement();
+ assert header.startsWith("{");
+
+ TableStrategy strategy = TableStrategy.DRAW_NONE;
+ if (header.length() == 2) {
+ strategy = TableStrategy.fromChar(header.charAt(1));
+ }
+
+ final Positionner2 positionner = new Positionner2();
+
+ while (getDataSource().peek(0).getElement().equals("}") == false) {
+ final Terminated<Element> next = getNextElement();
+ if (isStar(next.getElement())) {
+ positionner.mergeLeft(next.getTerminator());
+ } else {
+ positionner.add(next);
+ }
+ }
+ final Terminated<String> next = getDataSource().next();
+ return new Terminated<Element>(new ElementPyramid(positionner, strategy), next.getTerminator());
+ }
+
+ private boolean isStar(Element element) {
+ if (element instanceof ElementText == false) {
+ return false;
+ }
+ return "*".equals(((ElementText) element).getText());
+ }
+
+ public boolean ready() {
+ final String text = getDataSource().peek(0).getElement();
+ if (text.equals("{") || text.equals("{+") || text.equals("{#") || text.equals("{!") || text.equals("{-")) {
+ final String text1 = getDataSource().peek(1).getElement();
+ if (text1.matches("[NSEW]=|T")) {
+ return false;
+ }
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/salt/factory/ElementFactoryRadioOff.java b/src/net/sourceforge/plantuml/salt/factory/ElementFactoryRadioOff.java
new file mode 100644
index 0000000..bc47032
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/factory/ElementFactoryRadioOff.java
@@ -0,0 +1,78 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt.factory;
+
+import java.awt.Font;
+import java.util.Arrays;
+import java.util.List;
+
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.salt.DataSource;
+import net.sourceforge.plantuml.salt.Terminated;
+import net.sourceforge.plantuml.salt.element.Element;
+import net.sourceforge.plantuml.salt.element.ElementRadioCheckbox;
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public class ElementFactoryRadioOff implements ElementFactory {
+
+ final private DataSource dataSource;
+ final private ISkinSimple spriteContainer;
+
+ public ElementFactoryRadioOff(DataSource dataSource, ISkinSimple spriteContainer) {
+ this.dataSource = dataSource;
+ this.spriteContainer = spriteContainer;
+ }
+
+ public Terminated<Element> create() {
+ if (ready() == false) {
+ throw new IllegalStateException();
+ }
+ final Terminated<String> next = dataSource.next();
+ final String text = next.getElement();
+ final UFont font = new UFont("Default", Font.PLAIN, 12);
+ return new Terminated<Element>(new ElementRadioCheckbox(extracted(text), font, true, false, spriteContainer),
+ next.getTerminator());
+ }
+
+ private List<String> extracted(final String text) {
+ final int x = text.indexOf(')');
+ return Arrays.asList(text.substring(x + 1).trim());
+ }
+
+ public boolean ready() {
+ final String text = dataSource.peek(0).getElement();
+ return text.startsWith("()") || text.startsWith("( )");
+ }
+}
diff --git a/src/net/sourceforge/plantuml/salt/factory/ElementFactoryRadioOn.java b/src/net/sourceforge/plantuml/salt/factory/ElementFactoryRadioOn.java
new file mode 100644
index 0000000..6472ea3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/factory/ElementFactoryRadioOn.java
@@ -0,0 +1,78 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt.factory;
+
+import java.awt.Font;
+import java.util.Arrays;
+import java.util.List;
+
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.salt.DataSource;
+import net.sourceforge.plantuml.salt.Terminated;
+import net.sourceforge.plantuml.salt.element.Element;
+import net.sourceforge.plantuml.salt.element.ElementRadioCheckbox;
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public class ElementFactoryRadioOn implements ElementFactory {
+
+ final private DataSource dataSource;
+ final private ISkinSimple spriteContainer;
+
+ public ElementFactoryRadioOn(DataSource dataSource, ISkinSimple spriteContainer) {
+ this.dataSource = dataSource;
+ this.spriteContainer = spriteContainer;
+ }
+
+ public Terminated<Element> create() {
+ if (ready() == false) {
+ throw new IllegalStateException();
+ }
+ final Terminated<String> next = dataSource.next();
+ final String text = next.getElement();
+ final UFont font = new UFont("Default", Font.PLAIN, 12);
+ return new Terminated<Element>(new ElementRadioCheckbox(extracted(text), font, true, true, spriteContainer),
+ next.getTerminator());
+ }
+
+ private List<String> extracted(final String text) {
+ final int x = text.indexOf(')');
+ return Arrays.asList(text.substring(x + 1).trim());
+ }
+
+ public boolean ready() {
+ final String text = dataSource.peek(0).getElement();
+ return text.startsWith("(X)");
+ }
+}
diff --git a/src/net/sourceforge/plantuml/salt/factory/ElementFactoryRetrieveFromDictonnary.java b/src/net/sourceforge/plantuml/salt/factory/ElementFactoryRetrieveFromDictonnary.java
new file mode 100644
index 0000000..86d5df8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/factory/ElementFactoryRetrieveFromDictonnary.java
@@ -0,0 +1,72 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt.factory;
+
+import net.sourceforge.plantuml.salt.DataSource;
+import net.sourceforge.plantuml.salt.Dictionary;
+import net.sourceforge.plantuml.salt.Terminated;
+import net.sourceforge.plantuml.salt.element.Element;
+
+public class ElementFactoryRetrieveFromDictonnary implements ElementFactory {
+
+ private final Dictionary dictionary;
+ private final DataSource dataSource;
+
+ public ElementFactoryRetrieveFromDictonnary(DataSource dataSource, Dictionary dictionary) {
+ this.dataSource = dataSource;
+ this.dictionary = dictionary;
+ }
+
+ public Terminated<Element> create() {
+ if (ready() == false) {
+ throw new IllegalStateException();
+ }
+ final Terminated<String> next = dataSource.next();
+
+ String name = next.getElement();
+ name = name.substring(2, name.length() - 2);
+ final Element retrieve = dictionary.get(name);
+ if (retrieve == null) {
+ throw new IllegalArgumentException("Cannot retrieve " + name);
+ }
+
+ return new Terminated<Element>(retrieve, next.getTerminator());
+ }
+
+ public boolean ready() {
+ final String text = dataSource.peek(0).getElement();
+ return text.matches("\\<\\<\\w+\\>\\>");
+ }
+}
diff --git a/src/net/sourceforge/plantuml/salt/factory/ElementFactoryTab.java b/src/net/sourceforge/plantuml/salt/factory/ElementFactoryTab.java
new file mode 100644
index 0000000..8395f0e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/factory/ElementFactoryTab.java
@@ -0,0 +1,81 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt.factory;
+
+import java.awt.Font;
+
+import net.sourceforge.plantuml.salt.DataSource;
+import net.sourceforge.plantuml.salt.Dictionary;
+import net.sourceforge.plantuml.salt.Terminated;
+import net.sourceforge.plantuml.salt.Terminator;
+import net.sourceforge.plantuml.salt.element.Element;
+import net.sourceforge.plantuml.salt.element.ElementTabBar;
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public class ElementFactoryTab extends AbstractElementFactoryComplex {
+
+ public ElementFactoryTab(DataSource dataSource, Dictionary dictionary) {
+ super(dataSource, dictionary);
+ }
+
+ public Terminated<Element> create() {
+ if (ready() == false) {
+ throw new IllegalStateException();
+ }
+ final String header = getDataSource().next().getElement();
+ assert header.startsWith("{/");
+
+ final UFont font = new UFont("Default", Font.PLAIN, 12);
+ final ElementTabBar result = new ElementTabBar(font, getDictionary());
+
+ while (getDataSource().peek(0).getElement().equals("}") == false) {
+ final Terminated<String> t = getDataSource().next();
+ result.addTab(t.getElement());
+ if (t.getTerminator() == Terminator.NEWLINE) {
+ result.setVertical(true);
+ }
+ }
+ final Terminated<String> next = getDataSource().next();
+ return new Terminated<Element>(result, next.getTerminator());
+ }
+
+ public boolean ready() {
+ final String text = getDataSource().peek(0).getElement();
+ if (text.equals("{/")) {
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/salt/factory/ElementFactoryText.java b/src/net/sourceforge/plantuml/salt/factory/ElementFactoryText.java
new file mode 100644
index 0000000..91bc510
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/factory/ElementFactoryText.java
@@ -0,0 +1,78 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt.factory;
+
+import java.awt.Font;
+import java.util.Arrays;
+
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.SpriteContainer;
+import net.sourceforge.plantuml.salt.DataSource;
+import net.sourceforge.plantuml.salt.Terminated;
+import net.sourceforge.plantuml.salt.element.Element;
+import net.sourceforge.plantuml.salt.element.ElementText;
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public class ElementFactoryText implements ElementFactory {
+
+ final private DataSource dataSource;
+ final private ISkinSimple spriteContainer;
+
+ public ElementFactoryText(DataSource dataSource, ISkinSimple spriteContainer) {
+ this.dataSource = dataSource;
+ this.spriteContainer = spriteContainer;
+ }
+
+ public Terminated<Element> create() {
+ if (ready() == false) {
+ throw new IllegalStateException();
+ }
+ final Terminated<String> next = dataSource.next();
+ final String text = next.getElement();
+ final UFont font = new UFont("Default", Font.PLAIN, 12);
+ return new Terminated<Element>(new ElementText(Arrays.asList(text), font, spriteContainer),
+ next.getTerminator());
+ }
+
+ public boolean ready() {
+ final String text = dataSource.peek(0).getElement();
+ // return text.startsWith("\"") && text.endsWith("\"");
+ if (text.startsWith("{") || text.startsWith("}")) {
+ return false;
+ }
+ return text.trim().length() > 0;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/salt/factory/ElementFactoryTextField.java b/src/net/sourceforge/plantuml/salt/factory/ElementFactoryTextField.java
new file mode 100644
index 0000000..c6fcbe5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/factory/ElementFactoryTextField.java
@@ -0,0 +1,72 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt.factory;
+
+import java.awt.Font;
+
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.salt.DataSource;
+import net.sourceforge.plantuml.salt.Terminated;
+import net.sourceforge.plantuml.salt.element.Element;
+import net.sourceforge.plantuml.salt.element.ElementTextField;
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public class ElementFactoryTextField implements ElementFactory {
+
+ final private DataSource dataSource;
+ final private ISkinSimple spriteContainer;
+
+ public ElementFactoryTextField(DataSource dataSource, ISkinSimple spriteContainer) {
+ this.dataSource = dataSource;
+ this.spriteContainer = spriteContainer;
+ }
+
+ public Terminated<Element> create() {
+ if (ready() == false) {
+ throw new IllegalStateException();
+ }
+ final Terminated<String> next = dataSource.next();
+ final String text = next.getElement();
+ final UFont font = new UFont("Default", Font.PLAIN, 12);
+ return new Terminated<Element>(
+ new ElementTextField(text.substring(1, text.length() - 1), font, spriteContainer), next.getTerminator());
+ }
+
+ public boolean ready() {
+ final String text = dataSource.peek(0).getElement();
+ return text.startsWith("\"") && text.endsWith("\"");
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/salt/factory/ElementFactoryTree.java b/src/net/sourceforge/plantuml/salt/factory/ElementFactoryTree.java
new file mode 100644
index 0000000..681a8c7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/salt/factory/ElementFactoryTree.java
@@ -0,0 +1,101 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.salt.factory;
+
+import java.awt.Font;
+
+import net.sourceforge.plantuml.salt.DataSource;
+import net.sourceforge.plantuml.salt.Dictionary;
+import net.sourceforge.plantuml.salt.Terminated;
+import net.sourceforge.plantuml.salt.Terminator;
+import net.sourceforge.plantuml.salt.element.Element;
+import net.sourceforge.plantuml.salt.element.ElementTree;
+import net.sourceforge.plantuml.salt.element.TableStrategy;
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public class ElementFactoryTree extends AbstractElementFactoryComplex {
+
+ public ElementFactoryTree(DataSource dataSource, Dictionary dictionary) {
+ super(dataSource, dictionary);
+ }
+
+ public Terminated<Element> create() {
+ if (ready() == false) {
+ throw new IllegalStateException();
+ }
+ final String header = getDataSource().next().getElement();
+ final String textT = getDataSource().next().getElement();
+ TableStrategy strategy = TableStrategy.DRAW_NONE;
+ if (textT.length() == 2) {
+ strategy = TableStrategy.fromChar(textT.charAt(1));
+ }
+
+ final UFont font = new UFont("Default", Font.PLAIN, 12);
+ final ElementTree result = new ElementTree(font, getDictionary(), strategy);
+
+ boolean takeMe = true;
+ while (getDataSource().peek(0).getElement().equals("}") == false) {
+ final Terminated<String> t = getDataSource().next();
+ final Terminator terminator = t.getTerminator();
+ final String s = t.getElement();
+ if (takeMe) {
+ result.addEntry(s);
+ } else {
+ result.addCellToEntry(s);
+ }
+ takeMe = terminator == Terminator.NEWLINE;
+
+ }
+ final Terminated<String> next = getDataSource().next();
+ return new Terminated<Element>(result, next.getTerminator());
+ }
+
+ public boolean ready() {
+ final String text = getDataSource().peek(0).getElement();
+ if (text.equals("{")) {
+ final String text1 = getDataSource().peek(1).getElement();
+ if (text1.equals("T")) {
+ return true;
+ }
+ if (text1.length() == 2 && text1.startsWith("T")) {
+ final char c = text1.charAt(1);
+ return TableStrategy.fromChar(c) != null;
+
+ }
+ return false;
+ }
+ return false;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/AbstractEvent.java b/src/net/sourceforge/plantuml/sequencediagram/AbstractEvent.java
new file mode 100644
index 0000000..0670a72
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/AbstractEvent.java
@@ -0,0 +1,53 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import net.sourceforge.plantuml.Url;
+
+public abstract class AbstractEvent implements Event {
+
+ public boolean isParallel() {
+ return false;
+ }
+
+ public Url getUrl() {
+ return null;
+ }
+
+ public boolean hasUrl() {
+ return false;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/AbstractMessage.java b/src/net/sourceforge/plantuml/sequencediagram/AbstractMessage.java
new file mode 100644
index 0000000..a601b2f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/AbstractMessage.java
@@ -0,0 +1,206 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import java.util.EnumSet;
+import java.util.HashSet;
+import java.util.Set;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.SkinParamBackcolored;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorSet;
+import net.sourceforge.plantuml.skin.ArrowConfiguration;
+
+public abstract class AbstractMessage implements EventWithDeactivate {
+
+ final private Display label;
+ final private ArrowConfiguration arrowConfiguration;
+
+ final private Set<LifeEventType> lifeEventsType = EnumSet.noneOf(LifeEventType.class);
+
+ private Display notes;
+ private NotePosition notePosition;
+ private HtmlColor noteBackColor;
+ private Url urlNote;
+ private final Url url;
+ private final String messageNumber;
+ private boolean parallel = false;
+
+ public AbstractMessage(Display label, ArrowConfiguration arrowConfiguration, String messageNumber) {
+ this.url = label.initUrl();
+ this.label = label.removeUrl(url);
+ this.arrowConfiguration = arrowConfiguration;
+ this.messageNumber = messageNumber;
+ }
+
+ public void goParallel() {
+ this.parallel = true;
+ }
+
+ public boolean isParallel() {
+ return parallel;
+ }
+
+ final public Url getUrl() {
+ if (url == null) {
+ return urlNote;
+ }
+ return url;
+ }
+
+ public boolean hasUrl() {
+ if (notes != null && notes.hasUrl()) {
+ return true;
+ }
+ if (label != null && label.hasUrl()) {
+ return true;
+ }
+ return getUrl() != null;
+ }
+
+ private boolean firstIsActivate = false;
+ private final Set<Participant> noActivationAuthorized2 = new HashSet<Participant>();
+
+ public final boolean addLifeEvent(LifeEvent lifeEvent) {
+ lifeEvent.setMessage(this);
+ lifeEventsType.add(lifeEvent.getType());
+ if (lifeEventsType.size() == 1 && isActivate()) {
+ firstIsActivate = true;
+ }
+
+ if (lifeEvent.getType() == LifeEventType.ACTIVATE
+ && noActivationAuthorized2.contains(lifeEvent.getParticipant())) {
+ return false;
+ }
+
+ if (lifeEvent.getType() == LifeEventType.DEACTIVATE || lifeEvent.getType() == LifeEventType.DESTROY) {
+ noActivationAuthorized2.add(lifeEvent.getParticipant());
+ }
+
+ return true;
+ }
+
+ public final boolean isCreate() {
+ return lifeEventsType.contains(LifeEventType.CREATE);
+ }
+
+ public boolean isActivate() {
+ return lifeEventsType.contains(LifeEventType.ACTIVATE);
+ }
+
+ public boolean isDeactivate() {
+ return lifeEventsType.contains(LifeEventType.DEACTIVATE);
+ }
+
+ private boolean isDeactivateOrDestroy() {
+ return lifeEventsType.contains(LifeEventType.DEACTIVATE) || lifeEventsType.contains(LifeEventType.DESTROY);
+ }
+
+ public final boolean isActivateAndDeactive() {
+ return firstIsActivate && isDeactivateOrDestroy();
+ }
+
+ public final Display getLabel() {
+ return label;
+ }
+
+ public final ArrowConfiguration getArrowConfiguration() {
+ return arrowConfiguration;
+ }
+
+ public final Display getNote() {
+ return notes == null ? notes : notes;
+ }
+
+ public final Url getUrlNote() {
+ return urlNote;
+ }
+
+ public final void setNote(Display strings, NotePosition notePosition, String backcolor, Url url) {
+ if (notePosition != NotePosition.LEFT && notePosition != NotePosition.RIGHT) {
+ throw new IllegalArgumentException();
+ }
+ this.notes = strings;
+ this.urlNote = url;
+ this.notePosition = overideNotePosition(notePosition);
+ this.noteBackColor = HtmlColorSet.getInstance().getColorIfValid(backcolor);
+ }
+
+ protected NotePosition overideNotePosition(NotePosition notePosition) {
+ return notePosition;
+ }
+
+ private final HtmlColor getSpecificBackColor() {
+ return noteBackColor;
+ }
+
+ public SkinParamBackcolored getSkinParamNoteBackcolored(ISkinParam skinParam) {
+ return new SkinParamBackcolored(skinParam, getSpecificBackColor());
+ }
+
+ public final NotePosition getNotePosition() {
+ return notePosition;
+ }
+
+ public final String getMessageNumber() {
+ return messageNumber;
+ }
+
+ public abstract boolean compatibleForCreate(Participant p);
+
+ public abstract boolean isSelfMessage();
+
+ private double posYendLevel;
+ private double posYstartLevel;
+
+ public double getPosYstartLevel() {
+ return posYstartLevel;
+ }
+
+ public void setPosYstartLevel(double posYstartLevel) {
+ this.posYstartLevel = posYstartLevel;
+ }
+
+ public void setPosYendLevel(double posYendLevel) {
+ this.posYendLevel = posYendLevel;
+ }
+
+ public double getPosYendLevel() {
+ return posYendLevel;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/Delay.java b/src/net/sourceforge/plantuml/sequencediagram/Delay.java
new file mode 100644
index 0000000..788fb7d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/Delay.java
@@ -0,0 +1,54 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import net.sourceforge.plantuml.cucadiagram.Display;
+
+public class Delay extends AbstractEvent implements Event {
+
+ private final Display text;
+
+ public Delay(Display text) {
+ this.text = text;
+ }
+
+ public final Display getText() {
+ return text;
+ }
+
+ public boolean dealWith(Participant someone) {
+ return false;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/Divider.java b/src/net/sourceforge/plantuml/sequencediagram/Divider.java
new file mode 100644
index 0000000..422a41a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/Divider.java
@@ -0,0 +1,55 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import net.sourceforge.plantuml.cucadiagram.Display;
+
+public class Divider extends AbstractEvent implements Event {
+
+ private final Display text;
+
+ public Divider(Display text) {
+ this.text = text;
+ }
+
+ public final Display getText() {
+ return text;
+ }
+
+ public boolean dealWith(Participant someone) {
+ return false;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/Event.java b/src/net/sourceforge/plantuml/sequencediagram/Event.java
new file mode 100644
index 0000000..c128bbc
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/Event.java
@@ -0,0 +1,49 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import net.sourceforge.plantuml.Url;
+
+public interface Event {
+
+ boolean dealWith(Participant someone);
+
+ Url getUrl();
+
+ boolean hasUrl();
+
+ boolean isParallel();
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/EventWithDeactivate.java b/src/net/sourceforge/plantuml/sequencediagram/EventWithDeactivate.java
new file mode 100644
index 0000000..7d55aa0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/EventWithDeactivate.java
@@ -0,0 +1,46 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+public interface EventWithDeactivate extends Event {
+
+ public void setPosYendLevel(double posYendLevel);
+
+ public double getPosYendLevel();
+
+ public boolean addLifeEvent(LifeEvent lifeEvent);
+
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/Grouping.java b/src/net/sourceforge/plantuml/sequencediagram/Grouping.java
new file mode 100644
index 0000000..21ae2a5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/Grouping.java
@@ -0,0 +1,81 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+
+public abstract class Grouping implements Event {
+
+ private final String title;
+ private final GroupingType type;
+ private final String comment;
+ private final HtmlColor backColorElement;
+
+ public Grouping(String title, String comment, GroupingType type,
+ HtmlColor backColorElement) {
+ this.title = title;
+ this.comment = comment;
+ this.type = type;
+ this.backColorElement = backColorElement;
+ }
+
+ @Override
+ public final String toString() {
+ return super.toString() + " " + type + " " + title;
+ }
+
+ final public String getTitle() {
+ return title;
+ }
+
+ final public GroupingType getType() {
+ return type;
+ }
+
+ public abstract int getLevel();
+
+ public abstract HtmlColor getBackColorGeneral();
+
+ final public String getComment() {
+ return comment;
+ }
+
+ public final HtmlColor getBackColorElement() {
+ return backColorElement;
+ }
+
+ public abstract boolean isParallel();
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/GroupingLeaf.java b/src/net/sourceforge/plantuml/sequencediagram/GroupingLeaf.java
new file mode 100644
index 0000000..9841962
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/GroupingLeaf.java
@@ -0,0 +1,117 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+
+final public class GroupingLeaf extends Grouping implements EventWithDeactivate {
+
+ private final GroupingStart start;
+ private final HtmlColor backColorGeneral;
+
+ public GroupingLeaf(String title, String comment, GroupingType type, HtmlColor backColorGeneral,
+ HtmlColor backColorElement, GroupingStart start) {
+ super(title, comment, type, backColorElement);
+ if (start == null) {
+ throw new IllegalArgumentException();
+ }
+ this.backColorGeneral = backColorGeneral;
+ this.start = start;
+ start.addChildren(this);
+ }
+
+ public Grouping getJustAfter() {
+ final int idx = start.getChildren().indexOf(this);
+ if (idx == -1) {
+ throw new IllegalStateException();
+ }
+ if (idx + 1 >= start.getChildren().size()) {
+ return null;
+ }
+ return start.getChildren().get(idx + 1);
+ }
+
+ public GroupingStart getGroupingStart() {
+ return start;
+ }
+
+ @Override
+ public int getLevel() {
+ return start.getLevel();
+ }
+
+ @Override
+ public final HtmlColor getBackColorGeneral() {
+ if (backColorGeneral == null) {
+ return start.getBackColorGeneral();
+ }
+ return backColorGeneral;
+ }
+
+ public boolean dealWith(Participant someone) {
+ return false;
+ }
+
+ public Url getUrl() {
+ return null;
+ }
+
+ public boolean hasUrl() {
+ return false;
+ }
+
+ @Override
+ public boolean isParallel() {
+ return start.isParallel();
+ }
+
+ private double posYendLevel;
+
+ public void setPosYendLevel(double posYendLevel) {
+ this.posYendLevel = posYendLevel;
+ }
+
+ public double getPosYendLevel() {
+ return posYendLevel;
+ }
+
+ public boolean addLifeEvent(LifeEvent lifeEvent) {
+ lifeEvent.setLinkedToGroupingEnd(true);
+ return true;
+ }
+
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/GroupingStart.java b/src/net/sourceforge/plantuml/sequencediagram/GroupingStart.java
new file mode 100644
index 0000000..6b0e8df
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/GroupingStart.java
@@ -0,0 +1,96 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+
+public class GroupingStart extends Grouping {
+
+ private final List<GroupingLeaf> children = new ArrayList<GroupingLeaf>();
+ private final HtmlColor backColorGeneral;
+
+ final private GroupingStart parent;
+
+ public GroupingStart(String title, String comment, HtmlColor backColorGeneral, HtmlColor backColorElement,
+ GroupingStart parent) {
+ super(title, comment, GroupingType.START, backColorElement);
+ this.backColorGeneral = backColorGeneral;
+ this.parent = parent;
+ }
+
+ List<GroupingLeaf> getChildren() {
+ return Collections.unmodifiableList(children);
+ }
+
+ public void addChildren(GroupingLeaf g) {
+ children.add(g);
+ }
+
+ public int getLevel() {
+ if (parent == null) {
+ return 0;
+ }
+ return parent.getLevel() + 1;
+ }
+
+ @Override
+ public HtmlColor getBackColorGeneral() {
+ return backColorGeneral;
+ }
+
+ public boolean dealWith(Participant someone) {
+ return false;
+ }
+
+ public Url getUrl() {
+ return null;
+ }
+
+ public boolean hasUrl() {
+ return false;
+ }
+
+
+ @Override
+ public boolean isParallel() {
+ return getTitle().equals("par2");
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/GroupingType.java b/src/net/sourceforge/plantuml/sequencediagram/GroupingType.java
new file mode 100644
index 0000000..7f8fe63
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/GroupingType.java
@@ -0,0 +1,66 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+public enum GroupingType {
+ START, ELSE, END;
+ public static GroupingType getType(String s) {
+ if (s.equalsIgnoreCase("opt")) {
+ return GroupingType.START;
+ } else if (s.equalsIgnoreCase("alt")) {
+ return GroupingType.START;
+ } else if (s.equalsIgnoreCase("loop")) {
+ return GroupingType.START;
+ } else if (s.equalsIgnoreCase("par")) {
+ return GroupingType.START;
+ } else if (s.equalsIgnoreCase("par2")) {
+ return GroupingType.START;
+ } else if (s.equalsIgnoreCase("break")) {
+ return GroupingType.START;
+ } else if (s.equalsIgnoreCase("group")) {
+ return GroupingType.START;
+ } else if (s.equalsIgnoreCase("critical")) {
+ return GroupingType.START;
+ } else if (s.equalsIgnoreCase("also")) {
+ return GroupingType.ELSE;
+ } else if (s.equalsIgnoreCase("else")) {
+ return GroupingType.ELSE;
+ } else if (s.equalsIgnoreCase("end")) {
+ return GroupingType.END;
+ }
+
+ throw new IllegalArgumentException();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/HSpace.java b/src/net/sourceforge/plantuml/sequencediagram/HSpace.java
new file mode 100644
index 0000000..f7d3a7e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/HSpace.java
@@ -0,0 +1,57 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+public class HSpace extends AbstractEvent implements Event {
+
+ private final int pixel;
+
+ public HSpace() {
+ this(25);
+ }
+
+ public HSpace(int pixel) {
+ this.pixel = pixel;
+ }
+
+ public int getPixel() {
+ return pixel;
+ }
+
+ public boolean dealWith(Participant someone) {
+ return false;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/InGroupable.java b/src/net/sourceforge/plantuml/sequencediagram/InGroupable.java
new file mode 100644
index 0000000..080189f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/InGroupable.java
@@ -0,0 +1,47 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+
+public interface InGroupable {
+
+ public double getMinX(StringBounder stringBounder);
+
+ public double getMaxX(StringBounder stringBounder);
+
+ public String toString(StringBounder stringBounder);
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/InGroupableList.java b/src/net/sourceforge/plantuml/sequencediagram/InGroupableList.java
new file mode 100644
index 0000000..57c9b2d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/InGroupableList.java
@@ -0,0 +1,219 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.sequencediagram.graphic.GroupingGraphicalElementElse;
+import net.sourceforge.plantuml.sequencediagram.graphic.LivingParticipantBox;
+import net.sourceforge.plantuml.sequencediagram.graphic.MessageExoArrow;
+import net.sourceforge.plantuml.sequencediagram.graphic.ParticipantBox;
+
+public class InGroupableList implements InGroupable {
+
+ private static final int MARGIN5 = 5;
+ public static final int MARGIN10 = 10;
+
+ private final Grouping grouping;
+ private final Set<InGroupable> inGroupables = new HashSet<InGroupable>();
+
+ private double minWidth;
+
+ public List<InGroupableList> getInnerList() {
+ final List<InGroupableList> result = new ArrayList<InGroupableList>();
+ for (InGroupable i : inGroupables) {
+ if (i instanceof InGroupableList) {
+ result.add((InGroupableList) i);
+ }
+ }
+ return result;
+ }
+
+ private final ParticipantBox veryfirst;
+
+ public InGroupableList(ParticipantBox veryfirst, Grouping grouping, double startingY) {
+ this.grouping = grouping;
+ this.veryfirst = veryfirst;
+ }
+
+ public void addInGroupable(InGroupable in) {
+ // Thread.dumpStack();
+ this.inGroupables.add(in);
+ cacheMin = null;
+ cacheMax = null;
+ }
+
+ public boolean isEmpty() {
+ return inGroupables.isEmpty();
+ }
+
+ @Override
+ public String toString() {
+ return "GS " + grouping + " " + inGroupables.toString();
+ }
+
+ public String toString(StringBounder stringBounder) {
+ final StringBuilder sb = new StringBuilder("GS " + grouping + " ");
+ for (InGroupable in : inGroupables) {
+ sb.append(in.toString(stringBounder));
+ sb.append(' ');
+ }
+ return sb.toString();
+ }
+
+ private InGroupable getMinSlow(StringBounder stringBounder) {
+ InGroupable result = null;
+ for (InGroupable in : inGroupables) {
+ if (in instanceof GroupingGraphicalElementElse) {
+ continue;
+ }
+ if (result == null || in.getMinX(stringBounder) < result.getMinX(stringBounder)) {
+ result = in;
+ }
+ }
+ return result;
+ }
+
+ private InGroupable getMaxSlow(StringBounder stringBounder) {
+ InGroupable result = null;
+ for (InGroupable in : inGroupables) {
+ if (result == null || in.getMaxX(stringBounder) > result.getMaxX(stringBounder)) {
+ result = in;
+ }
+ }
+ return result;
+ }
+
+ private InGroupable cacheMin = null;
+ private InGroupable cacheMax = null;
+
+ private InGroupable getMin(StringBounder stringBounder) {
+ if (cacheMin == null) {
+ cacheMin = getMinSlow(stringBounder);
+ }
+ // Since // MODIF42 // the assert does not work...
+ // System.err.println("cacheMin1="+cacheMin+" cacheMin2="+getMinSlow(stringBounder));
+ assert cacheMin == getMinSlow(stringBounder);
+ return cacheMin;
+ }
+
+ private InGroupable getMax(StringBounder stringBounder) {
+ if (cacheMax == null) {
+ cacheMax = getMaxSlow(stringBounder);
+ }
+ assert cacheMax == getMaxSlow(stringBounder);
+ return cacheMax;
+ }
+
+ public void setMinWidth(double minWidth) {
+ this.minWidth = minWidth;
+ }
+
+ public ParticipantBox getFirstParticipantBox() {
+ ParticipantBox first = null;
+ for (InGroupable in : inGroupables) {
+ if (in instanceof LivingParticipantBox) {
+ final ParticipantBox participantBox = ((LivingParticipantBox) in).getParticipantBox();
+ if (first == null || participantBox.getStartingX() < first.getStartingX()) {
+ first = participantBox;
+ }
+ }
+ }
+ return first;
+ }
+
+ public ParticipantBox getLastParticipantBox() {
+ ParticipantBox last = null;
+ for (InGroupable in : inGroupables) {
+ if (in instanceof LivingParticipantBox) {
+ final ParticipantBox participantBox = ((LivingParticipantBox) in).getParticipantBox();
+ if (last == null || participantBox.getStartingX() > last.getStartingX()) {
+ last = participantBox;
+ }
+ }
+ }
+ return last;
+ }
+
+ public double getMinX(StringBounder stringBounder) {
+ final InGroupable min = getMin(stringBounder);
+ if (min == null) {
+ return MARGIN10 + MARGIN5 + (veryfirst == null ? 0 : veryfirst.getStartingX());
+ // return MARGIN10 + MARGIN5;
+ }
+ double m = min.getMinX(stringBounder);
+ if (min instanceof MessageExoArrow
+ && (((MessageExoArrow) min).getType() == MessageExoType.FROM_LEFT || ((MessageExoArrow) min).getType() == MessageExoType.TO_LEFT)) {
+ m += 3;
+ } else if (min instanceof InGroupableList) {
+ m -= MARGIN10;
+ } else {
+ m -= MARGIN5;
+ }
+ return m;
+ }
+
+ public double getMaxX(StringBounder stringBounder) {
+ final double min = getMinX(stringBounder);
+ final double max = getMaxXInternal(stringBounder);
+ assert max - min >= 0;
+ if (max - min < minWidth) {
+ return min + minWidth;
+ }
+ return max;
+ }
+
+ private final double getMaxXInternal(StringBounder stringBounder) {
+ final InGroupable max = getMax(stringBounder);
+ if (max == null) {
+ return MARGIN10 + MARGIN5 + minWidth;
+ }
+ double m = max.getMaxX(stringBounder);
+ if (max instanceof MessageExoArrow
+ && (((MessageExoArrow) max).getType() == MessageExoType.FROM_RIGHT || ((MessageExoArrow) max).getType() == MessageExoType.TO_RIGHT)) {
+ m -= 3;
+ } else if (max instanceof InGroupableList) {
+ m += MARGIN10;
+ } else {
+ m += MARGIN5;
+ }
+ return m;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/LifeEvent.java b/src/net/sourceforge/plantuml/sequencediagram/LifeEvent.java
new file mode 100644
index 0000000..a719f5a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/LifeEvent.java
@@ -0,0 +1,108 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+
+public class LifeEvent extends AbstractEvent implements Event {
+
+ private final Participant p;
+ private final LifeEventType type;
+ private final HtmlColor backcolor;
+
+ public LifeEvent(Participant p, LifeEventType type, HtmlColor backcolor) {
+ this.p = p;
+ this.type = type;
+ this.backcolor = backcolor;
+ }
+
+ @Override
+ public String toString() {
+ return "LifeEvent:" + p + " " + type;
+ }
+
+ public Participant getParticipant() {
+ return p;
+ }
+
+ public LifeEventType getType() {
+ return type;
+ }
+
+ public HtmlColor getSpecificBackColor() {
+ return backcolor;
+ }
+
+ public boolean dealWith(Participant someone) {
+ return this.p == someone;
+ }
+
+ public boolean isActivate() {
+ return type == LifeEventType.ACTIVATE;
+ }
+
+ public boolean isDeactivateOrDestroy() {
+ return type == LifeEventType.DEACTIVATE || type == LifeEventType.DESTROY;
+ }
+
+ public boolean isDestroy() {
+ return type == LifeEventType.DESTROY;
+ }
+
+ // public double getStrangePos() {
+ // return message.getPosYendLevel();
+ // }
+ //
+ private AbstractMessage message;
+
+ public void setMessage(AbstractMessage message) {
+ this.message = message;
+ }
+
+ public AbstractMessage getMessage() {
+ return message;
+ }
+
+ // private boolean linkedToGroupingEnd;
+ //
+ // // public boolean isLinkedToGroupingEnd() {
+ // // return linkedToGroupingEnd;
+ // // }
+
+ public void setLinkedToGroupingEnd(boolean linkedToGroupingEnd) {
+ // this.linkedToGroupingEnd = linkedToGroupingEnd;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/LifeEventType.java b/src/net/sourceforge/plantuml/sequencediagram/LifeEventType.java
new file mode 100644
index 0000000..e606589
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/LifeEventType.java
@@ -0,0 +1,40 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+public enum LifeEventType {
+ ACTIVATE, DEACTIVATE, DESTROY, CREATE
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/Message.java b/src/net/sourceforge/plantuml/sequencediagram/Message.java
new file mode 100644
index 0000000..69c7bb7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/Message.java
@@ -0,0 +1,78 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.skin.ArrowConfiguration;
+
+public final class Message extends AbstractMessage {
+
+ final private Participant p1;
+ final private Participant p2;
+
+ public Message(Participant p1, Participant p2, Display label, ArrowConfiguration arrowConfiguration,
+ String messageNumber) {
+ super(label, arrowConfiguration, messageNumber);
+ this.p1 = p1;
+ this.p2 = p2;
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + " " + p1 + "->" + p2 + " " + getLabel();
+ }
+
+ public Participant getParticipant1() {
+ return p1;
+ }
+
+ public Participant getParticipant2() {
+ return p2;
+ }
+
+ public boolean dealWith(Participant someone) {
+ return someone == p1 || someone == p2;
+ }
+
+ @Override
+ public boolean compatibleForCreate(Participant p) {
+ return p1 != p && p2 == p;
+ }
+
+ public boolean isSelfMessage() {
+ return p1 == p2;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/MessageExo.java b/src/net/sourceforge/plantuml/sequencediagram/MessageExo.java
new file mode 100644
index 0000000..a950c75
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/MessageExo.java
@@ -0,0 +1,93 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.skin.ArrowConfiguration;
+
+public class MessageExo extends AbstractMessage {
+
+ final private MessageExoType type;
+ final private Participant participant;
+ final private boolean shortArrow;
+
+ public MessageExo(Participant p, MessageExoType type, Display label, ArrowConfiguration arrowConfiguration,
+ String messageNumber, boolean shortArrow) {
+ super(label, arrowConfiguration, messageNumber);
+ this.participant = p;
+ this.type = type;
+ this.shortArrow = shortArrow;
+ }
+
+ public boolean isShortArrow() {
+ return shortArrow;
+ }
+
+
+ @Override
+ protected NotePosition overideNotePosition(NotePosition notePosition) {
+ if (type == MessageExoType.FROM_LEFT || type == MessageExoType.TO_LEFT) {
+ return NotePosition.RIGHT;
+ }
+ if (type == MessageExoType.FROM_RIGHT || type == MessageExoType.TO_RIGHT) {
+ return NotePosition.LEFT;
+ }
+ throw new IllegalStateException();
+ }
+
+ public Participant getParticipant() {
+ return participant;
+ }
+
+ public final MessageExoType getType() {
+ return type;
+ }
+
+ public boolean dealWith(Participant someone) {
+ return participant == someone;
+ }
+
+ @Override
+ public boolean compatibleForCreate(Participant p) {
+ return p == participant;
+ }
+
+ public boolean isSelfMessage() {
+ return false;
+ }
+
+
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/MessageExoType.java b/src/net/sourceforge/plantuml/sequencediagram/MessageExoType.java
new file mode 100644
index 0000000..498aaef
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/MessageExoType.java
@@ -0,0 +1,64 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+public enum MessageExoType {
+ FROM_LEFT, TO_LEFT, FROM_RIGHT, TO_RIGHT;
+
+ public int getDirection() {
+ if (this == MessageExoType.FROM_LEFT) {
+ return 1;
+ }
+ if (this == MessageExoType.TO_LEFT) {
+ return -1;
+ }
+ if (this == MessageExoType.TO_RIGHT) {
+ return 1;
+ }
+ if (this == MessageExoType.FROM_RIGHT) {
+ return -1;
+ }
+ throw new IllegalStateException();
+ }
+
+ public boolean isLeftBorder() {
+ return this == MessageExoType.FROM_LEFT || this == MessageExoType.TO_LEFT;
+ }
+
+ public boolean isRightBorder() {
+ return this == MessageExoType.FROM_RIGHT || this == MessageExoType.TO_RIGHT;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/MessageNumber.java b/src/net/sourceforge/plantuml/sequencediagram/MessageNumber.java
new file mode 100644
index 0000000..bc7f460
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/MessageNumber.java
@@ -0,0 +1,66 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+public class MessageNumber implements CharSequence {
+
+ private final String representation;
+
+ @Override
+ public String toString() {
+ return representation;
+ }
+
+ public MessageNumber(String s) {
+ this.representation = s;
+ }
+
+ public String getNumber() {
+ return representation;
+ }
+
+ public char charAt(int arg0) {
+ return representation.charAt(arg0);
+ }
+
+ public int length() {
+ return representation.length();
+ }
+
+ public CharSequence subSequence(int arg0, int arg1) {
+ return representation.subSequence(arg0, arg1);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/Newpage.java b/src/net/sourceforge/plantuml/sequencediagram/Newpage.java
new file mode 100644
index 0000000..e3760e5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/Newpage.java
@@ -0,0 +1,54 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import net.sourceforge.plantuml.cucadiagram.Display;
+
+public class Newpage extends AbstractEvent implements Event {
+
+ private final Display title;
+
+ public Newpage(Display strings) {
+ this.title = strings;
+ }
+
+ public final Display getTitle() {
+ return title;
+ }
+
+ public boolean dealWith(Participant someone) {
+ return false;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/Note.java b/src/net/sourceforge/plantuml/sequencediagram/Note.java
new file mode 100644
index 0000000..ccad6ce
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/Note.java
@@ -0,0 +1,134 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.SkinParamBackcolored;
+import net.sourceforge.plantuml.SpecificBackcolorable;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+
+public class Note extends AbstractEvent implements Event, SpecificBackcolorable {
+
+ private final Participant p;
+ private final Participant p2;
+
+ private final Display strings;
+
+ private final NotePosition position;
+ private NoteStyle style = NoteStyle.NORMAL;
+
+ private final Url url;
+
+ public Note(Participant p, NotePosition position, Display strings) {
+ this(p, null, position, strings);
+ }
+
+ public Note(Participant p, Participant p2, Display strings) {
+ this(p, p2, NotePosition.OVER_SEVERAL, strings);
+ }
+
+ private Note(Participant p, Participant p2, NotePosition position, Display strings) {
+ this.p = p;
+ this.p2 = p2;
+ this.position = position;
+ if (strings != null && strings.size() > 0) {
+ final UrlBuilder urlBuilder = new UrlBuilder(null, ModeUrl.STRICT);
+ this.url = urlBuilder.getUrl(strings.get(0).toString());
+ } else {
+ this.url = null;
+ }
+
+ if (this.url == null) {
+ this.strings = strings;
+ } else {
+ this.strings = strings.subList(1, strings.size());
+ }
+ }
+
+ public Participant getParticipant() {
+ return p;
+ }
+
+ public Participant getParticipant2() {
+ return p2;
+ }
+
+ public Display getStrings() {
+ return strings;
+ }
+
+ public NotePosition getPosition() {
+ return position;
+ }
+
+ private HtmlColor specificBackcolor;
+
+ public HtmlColor getSpecificBackColor() {
+ return specificBackcolor;
+ }
+
+ public void setSpecificBackcolor(HtmlColor color) {
+ this.specificBackcolor = color;
+ }
+
+ public boolean dealWith(Participant someone) {
+ return p == someone || p2 == someone;
+ }
+
+ public Url getUrl() {
+ return url;
+ }
+
+ public boolean hasUrl() {
+ return url != null;
+ }
+
+ public final NoteStyle getStyle() {
+ return style;
+ }
+
+ public final void setStyle(NoteStyle style) {
+ this.style = style;
+ }
+
+ public SkinParamBackcolored getSkinParamBackcolored(ISkinParam skinParam) {
+ return new SkinParamBackcolored(skinParam, getSpecificBackColor());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/NotePosition.java b/src/net/sourceforge/plantuml/sequencediagram/NotePosition.java
new file mode 100644
index 0000000..549f8d5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/NotePosition.java
@@ -0,0 +1,39 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+public enum NotePosition {
+ LEFT, RIGHT, OVER, OVER_SEVERAL
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/NoteStyle.java b/src/net/sourceforge/plantuml/sequencediagram/NoteStyle.java
new file mode 100644
index 0000000..1201068
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/NoteStyle.java
@@ -0,0 +1,50 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+public enum NoteStyle {
+
+ NORMAL, HEXAGONAL, BOX;
+
+ public static NoteStyle getNoteStyle(String s) {
+ if (s.equalsIgnoreCase("hnote")) {
+ return NoteStyle.HEXAGONAL;
+ } else if (s.equalsIgnoreCase("rnote")) {
+ return NoteStyle.BOX;
+ }
+ return NoteStyle.NORMAL;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/Notes.java b/src/net/sourceforge/plantuml/sequencediagram/Notes.java
new file mode 100644
index 0000000..51d26a0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/Notes.java
@@ -0,0 +1,66 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+public class Notes extends AbstractEvent implements Event, Iterable<Note> {
+
+ private final List<Note> notes = new ArrayList<Note>();
+
+ public Notes(Note n1, Note n2) {
+ notes.add(n1);
+ notes.add(n2);
+ }
+
+ public void add(Note n) {
+ notes.add(n);
+ }
+
+ public boolean dealWith(Participant someone) {
+ for (Note n : notes) {
+ if (n.dealWith(someone)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public Iterator<Note> iterator() {
+ return notes.iterator();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/Participant.java b/src/net/sourceforge/plantuml/sequencediagram/Participant.java
new file mode 100644
index 0000000..f514763
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/Participant.java
@@ -0,0 +1,162 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.SkinParamBackcolored;
+import net.sourceforge.plantuml.SpecificBackcolorable;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+
+public class Participant implements SpecificBackcolorable {
+
+ private final String code;
+ private Display display;
+ private final ParticipantType type;
+
+ private int initialLife = 0;
+
+ private Stereotype stereotype;
+
+ public Participant(ParticipantType type, String code, Display display) {
+ if (type == null) {
+ throw new IllegalArgumentException();
+ }
+ if (code == null || code.length() == 0) {
+ throw new IllegalArgumentException();
+ }
+ if (display == null || display.size() == 0) {
+ throw new IllegalArgumentException();
+ }
+ this.code = code;
+ this.type = type;
+ this.display = display;
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ @Override
+ public String toString() {
+ return getCode();
+ }
+
+ public Display getDisplay(boolean underlined) {
+ if (underlined) {
+ return display.underlined();
+ }
+ return display;
+ }
+
+ public ParticipantType getType() {
+ return type;
+ }
+
+ public final void setStereotype(Stereotype stereotype, boolean stereotypePositionTop) {
+ // if (type == ParticipantType.ACTOR) {
+ // return;
+ // }
+ if (this.stereotype != null) {
+ throw new IllegalStateException();
+ }
+ if (stereotype == null) {
+ throw new IllegalArgumentException();
+ }
+ this.stereotype = stereotype;
+ if (stereotypePositionTop) {
+ display = display.addFirst(stereotype);
+ } else {
+ display = display.add(stereotype);
+ }
+ }
+
+ public final int getInitialLife() {
+ return initialLife;
+ }
+
+ private HtmlColor liveBackcolor;
+
+ public final void incInitialLife(HtmlColor backcolor) {
+ initialLife++;
+ this.liveBackcolor = backcolor;
+ }
+
+ public HtmlColor getLiveSpecificBackColor() {
+ return liveBackcolor;
+ }
+
+ private HtmlColor specificBackcolor;
+
+ public HtmlColor getSpecificBackColor() {
+ return specificBackcolor;
+ }
+
+ public void setSpecificBackcolor(HtmlColor color) {
+ this.specificBackcolor = color;
+ }
+
+ private Url url;
+
+ public final Url getUrl() {
+ return url;
+ }
+
+ public final void setUrl(Url url) {
+ this.url = url;
+ }
+
+ public final Stereotype getStereotype() {
+ return stereotype;
+ }
+
+ public ColorParam getBackgroundColorParam() {
+ return type.getBackgroundColorParam();
+ }
+
+ public SkinParamBackcolored getSkinParamBackcolored(ISkinParam skinParam) {
+ HtmlColor specificBackColor = getSpecificBackColor();
+ final boolean clickable = getUrl() != null;
+ final HtmlColor stereoBackColor = skinParam.getHtmlColor(getBackgroundColorParam(), getStereotype(), clickable);
+ if (stereoBackColor != null && specificBackColor == null) {
+ specificBackColor = stereoBackColor;
+ }
+ return new SkinParamBackcolored(skinParam, specificBackColor, clickable);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/ParticipantEnglober.java b/src/net/sourceforge/plantuml/sequencediagram/ParticipantEnglober.java
new file mode 100644
index 0000000..8dfc4ff
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/ParticipantEnglober.java
@@ -0,0 +1,59 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+
+public class ParticipantEnglober {
+
+ final private Display title;
+ final private HtmlColor boxColor;
+
+ public ParticipantEnglober(Display title, HtmlColor boxColor) {
+ this.title = title;
+ this.boxColor = boxColor;
+ }
+
+ public final Display getTitle() {
+ return title;
+ }
+
+ public final HtmlColor getBoxColor() {
+ return boxColor;
+ }
+
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/ParticipantEngloberContexted.java b/src/net/sourceforge/plantuml/sequencediagram/ParticipantEngloberContexted.java
new file mode 100644
index 0000000..5ab0b33
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/ParticipantEngloberContexted.java
@@ -0,0 +1,78 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ParticipantEngloberContexted {
+
+ final private ParticipantEnglober participantEnglober;
+ final private List<Participant> participants = new ArrayList<Participant>();
+
+ public ParticipantEngloberContexted(ParticipantEnglober participantEnglober, Participant first) {
+ this.participantEnglober = participantEnglober;
+ this.participants.add(first);
+ }
+
+ public final ParticipantEnglober getParticipantEnglober() {
+ return participantEnglober;
+ }
+
+ public boolean contains(Participant p) {
+ return participants.contains(p);
+ }
+
+ public void add(Participant p) {
+ if (participants.contains(p)) {
+ throw new IllegalArgumentException();
+ }
+ participants.add(p);
+ }
+
+ public final Participant getFirst2() {
+ return participants.get(0);
+ }
+
+ public final Participant getLast2() {
+ return participants.get(participants.size() - 1);
+ }
+
+ @Override
+ public String toString() {
+ return super.toString()+" "+participants;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/ParticipantType.java b/src/net/sourceforge/plantuml/sequencediagram/ParticipantType.java
new file mode 100644
index 0000000..001adc9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/ParticipantType.java
@@ -0,0 +1,57 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import net.sourceforge.plantuml.ColorParam;
+
+public enum ParticipantType {
+ PARTICIPANT(ColorParam.participantBackground), //
+ ACTOR(ColorParam.actorBackground), //
+ BOUNDARY(ColorParam.boundaryBackground), //
+ CONTROL(ColorParam.controlBackground), //
+ ENTITY(ColorParam.entityBackground), //
+ DATABASE(ColorParam.databaseBackground);
+
+ private final ColorParam background;
+
+ private ParticipantType(ColorParam background) {
+ this.background = background;
+ }
+
+ public ColorParam getBackgroundColorParam() {
+ return background;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/Reference.java b/src/net/sourceforge/plantuml/sequencediagram/Reference.java
new file mode 100644
index 0000000..b2e027e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/Reference.java
@@ -0,0 +1,103 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+
+public class Reference extends AbstractEvent implements Event {
+
+ private final List<Participant> participants;
+ private final Url url;
+ private final HtmlColor backColorGeneral;
+ private final HtmlColor backColorElement;
+
+ private final Display strings;
+
+ public Reference(List<Participant> participants, Url url, Display strings, HtmlColor backColorGeneral,
+ HtmlColor backColorElement) {
+ this.participants = participants;
+ this.url = url;
+ this.strings = strings;
+ this.backColorGeneral = backColorGeneral;
+ this.backColorElement = backColorElement;
+ }
+
+ public List<Participant> getParticipant() {
+ return Collections.unmodifiableList(participants);
+ }
+
+ public Display getStrings() {
+ return strings;
+ }
+
+ public boolean dealWith(Participant someone) {
+ return participants.contains(someone);
+ }
+
+ public final Url getUrl() {
+ return url;
+ }
+
+ public boolean hasUrl() {
+ return url != null;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ for (final Iterator<Participant> it = participants.iterator(); it.hasNext();) {
+ sb.append(it.next().getCode());
+ if (it.hasNext()) {
+ sb.append("-");
+ }
+
+ }
+ return sb.toString();
+ }
+
+ public final HtmlColor getBackColorGeneral() {
+ return backColorGeneral;
+ }
+
+ public final HtmlColor getBackColorElement() {
+ return backColorElement;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagram.java b/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagram.java
new file mode 100644
index 0000000..48d351c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagram.java
@@ -0,0 +1,451 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Stack;
+
+import net.sourceforge.plantuml.FileFormat;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.OptionFlags;
+import net.sourceforge.plantuml.UmlDiagram;
+import net.sourceforge.plantuml.UmlDiagramType;
+import net.sourceforge.plantuml.core.DiagramDescription;
+import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.sequencediagram.graphic.FileMaker;
+import net.sourceforge.plantuml.sequencediagram.graphic.SequenceDiagramFileMakerPuma2;
+import net.sourceforge.plantuml.sequencediagram.graphic.SequenceDiagramTxtMaker;
+import net.sourceforge.plantuml.sequencediagram.teoz.SequenceDiagramFileMakerTeoz;
+import net.sourceforge.plantuml.skin.ProtectedSkin;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.skin.SkinUtils;
+import net.sourceforge.plantuml.skin.rose.Rose;
+
+public class SequenceDiagram extends UmlDiagram {
+
+ private final Map<String, Participant> participants = new LinkedHashMap<String, Participant>();
+
+ private final List<Event> events = new ArrayList<Event>();
+
+ private final Map<Participant, ParticipantEnglober> participantEnglobers2 = new HashMap<Participant, ParticipantEnglober>();
+
+ private Skin skin = new ProtectedSkin(new Rose());
+
+ @Deprecated
+ public Participant getOrCreateParticipant(String code) {
+ return getOrCreateParticipant(code, Display.getWithNewlines(code));
+ }
+
+ public Participant getOrCreateParticipant(String code, Display display) {
+ Participant result = participants.get(code);
+ if (result == null) {
+ result = new Participant(ParticipantType.PARTICIPANT, code, display);
+ participants.put(code, result);
+ participantEnglobers2.put(result, participantEnglober);
+ }
+ return result;
+ }
+
+ private EventWithDeactivate lastEventWithDeactivate;
+
+ public EventWithDeactivate getLastEventWithDeactivate() {
+ return lastEventWithDeactivate;
+ }
+
+ public Participant createNewParticipant(ParticipantType type, String code, Display display) {
+ if (participants.containsKey(code)) {
+ throw new IllegalArgumentException();
+ }
+ if (display == null) {
+ // display = Arrays.asList(code);
+ display = Display.getWithNewlines(code);
+ }
+ final Participant result = new Participant(type, code, display);
+ participants.put(code, result);
+ participantEnglobers2.put(result, participantEnglober);
+ return result;
+ }
+
+ public Map<String, Participant> participants() {
+ return Collections.unmodifiableMap(participants);
+ }
+
+ public String addMessage(AbstractMessage m) {
+ lastEventWithDeactivate = m;
+ lastDelay = null;
+ events.add(m);
+ if (pendingCreate != null) {
+ if (m.compatibleForCreate(pendingCreate.getParticipant()) == false) {
+ return "After create command, you have to send a message to \"" + pendingCreate.getParticipant() + "\"";
+ }
+ m.addLifeEvent(pendingCreate);
+ pendingCreate = null;
+ }
+ return null;
+ }
+
+ public void addNote(Note n, boolean tryMerge) {
+ if (tryMerge && events.size() > 0) {
+ final Event last = events.get(events.size() - 1);
+ if (last instanceof Note) {
+ final Notes notes = new Notes((Note) last, n);
+ events.set(events.size() - 1, notes);
+ return;
+ }
+ if (last instanceof Notes) {
+ ((Notes) last).add(n);
+ return;
+ }
+ }
+ events.add(n);
+ }
+
+ public void newpage(Display strings) {
+ if (ignoreNewpage) {
+ return;
+ }
+ events.add(new Newpage(strings));
+ }
+
+ private boolean ignoreNewpage = false;
+
+ public void ignoreNewpage() {
+ this.ignoreNewpage = true;
+ }
+
+ private int autonewpage = -1;
+
+ public final int getAutonewpage() {
+ return autonewpage;
+ }
+
+ public void setAutonewpage(int autonewpage) {
+ this.autonewpage = autonewpage;
+ }
+
+ public void divider(Display strings) {
+ events.add(new Divider(strings));
+ }
+
+ public void hspace() {
+ events.add(new HSpace());
+ }
+
+ public void hspace(int pixel) {
+ events.add(new HSpace(pixel));
+ }
+
+ private Delay lastDelay;
+
+ public void delay(Display strings) {
+ final Delay delay = new Delay(strings);
+ events.add(delay);
+ lastDelay = delay;
+ }
+
+ public List<Event> events() {
+ return Collections.unmodifiableList(events);
+ }
+
+ private FileMaker getSequenceDiagramPngMaker(FileFormatOption fileFormatOption) {
+
+ final FileFormat fileFormat = fileFormatOption.getFileFormat();
+
+ if (fileFormat == FileFormat.ATXT || fileFormat == FileFormat.UTXT) {
+ return new SequenceDiagramTxtMaker(this, fileFormat);
+ }
+
+ if (OptionFlags.FORCE_TEOZ || getPragma().useTeozLayout()) {
+ return new SequenceDiagramFileMakerTeoz(this, skin, fileFormatOption);
+ }
+
+ return new SequenceDiagramFileMakerPuma2(this, skin, fileFormatOption);
+ }
+
+ @Override
+ protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormat)
+ throws IOException {
+ final FileMaker sequenceDiagramPngMaker = getSequenceDiagramPngMaker(fileFormat);
+ return sequenceDiagramPngMaker.createOne(os, index, fileFormat.isWithMetadata());
+ }
+
+ // support for CommandReturn
+ private final Stack<Message> activationState = new Stack<Message>();
+
+ public Message getActivatingMessage() {
+ if (activationState.empty()) {
+ return null;
+ }
+ return activationState.peek();
+ }
+
+ private LifeEvent pendingCreate = null;
+
+ public String activate(Participant p, LifeEventType lifeEventType, HtmlColor backcolor) {
+ if (lastDelay != null) {
+ return "You cannot Activate/Deactivate just after a ...";
+ }
+ final LifeEvent lifeEvent = new LifeEvent(p, lifeEventType, backcolor);
+ events.add(lifeEvent);
+ if (lifeEventType == LifeEventType.CREATE) {
+ pendingCreate = lifeEvent;
+ return null;
+ }
+ if (lastEventWithDeactivate == null) {
+ if (lifeEventType == LifeEventType.ACTIVATE) {
+ p.incInitialLife(backcolor);
+ return null;
+ }
+ return "Only activate command can occur before message are send";
+ }
+ if (lifeEventType == LifeEventType.ACTIVATE && lastEventWithDeactivate instanceof Message) {
+ activationState.push((Message) lastEventWithDeactivate);
+ } else if (lifeEventType == LifeEventType.DEACTIVATE && activationState.empty() == false) {
+ activationState.pop();
+ }
+ final boolean ok = lastEventWithDeactivate.addLifeEvent(lifeEvent);
+ if (lastEventWithDeactivate instanceof AbstractMessage) {
+ lifeEvent.setMessage((AbstractMessage) lastEventWithDeactivate);
+ }
+ if (ok) {
+ return null;
+ }
+ return "Activate/Deactivate already done on " + p.getCode();
+ }
+
+ private final List<GroupingStart> openGroupings = new ArrayList<GroupingStart>();
+
+ public boolean grouping(String title, String comment, GroupingType type, HtmlColor backColorGeneral,
+ HtmlColor backColorElement) {
+ if (type != GroupingType.START && openGroupings.size() == 0) {
+ return false;
+ }
+
+ final GroupingStart top = openGroupings.size() > 0 ? openGroupings.get(0) : null;
+
+ final Grouping g = type == GroupingType.START ? new GroupingStart(title, comment, backColorGeneral,
+ backColorElement, top)
+ : new GroupingLeaf(title, comment, type, backColorGeneral, backColorElement, top);
+ events.add(g);
+
+ if (type == GroupingType.START) {
+ openGroupings.add(0, (GroupingStart) g);
+ } else if (type == GroupingType.END) {
+ openGroupings.remove(0);
+ lastEventWithDeactivate = (GroupingLeaf) g;
+ }
+
+ return true;
+ }
+
+ public DiagramDescription getDescription() {
+ return new DiagramDescriptionImpl("(" + participants.size() + " participants)", getClass());
+ }
+
+ public boolean changeSkin(String className) {
+ final Skin s = SkinUtils.loadSkin(className);
+ final Integer expected = new Integer(1);
+ if (s != null && expected.equals(s.getProtocolVersion())) {
+ this.skin = new ProtectedSkin(s);
+ return true;
+ }
+ return false;
+ }
+
+ public Skin getSkin() {
+ return skin;
+ }
+
+ private Integer messageNumber = null;
+ private int incrementMessageNumber;
+
+ private DecimalFormat decimalFormat;
+
+ public final void goAutonumber(int startingNumber, int increment, DecimalFormat decimalFormat) {
+ this.messageNumber = startingNumber;
+ this.incrementMessageNumber = increment;
+ this.decimalFormat = decimalFormat;
+ }
+
+ public String getNextMessageNumber() {
+ if (messageNumber == null) {
+ return null;
+ }
+ final Integer result = messageNumber;
+ messageNumber += incrementMessageNumber;
+ return decimalFormat.format(result);
+ }
+
+ public boolean isShowFootbox() {
+ if (getSkinParam().strictUmlStyle()) {
+ return false;
+ }
+ final String footbox = getSkinParam().getValue("footbox");
+ if (footbox == null) {
+ return showFootbox;
+ }
+ if (footbox.equalsIgnoreCase("hide")) {
+ return false;
+ }
+ return true;
+ }
+
+ private boolean showFootbox = true;
+
+ public void setShowFootbox(boolean footbox) {
+ this.showFootbox = footbox;
+
+ }
+
+ @Override
+ public UmlDiagramType getUmlDiagramType() {
+ return UmlDiagramType.SEQUENCE;
+ }
+
+ private ParticipantEnglober participantEnglober;
+
+ public void boxStart(Display comment, HtmlColor color) {
+ if (participantEnglober != null) {
+ throw new IllegalStateException();
+ }
+ this.participantEnglober = new ParticipantEnglober(comment, color);
+ }
+
+ public void endBox() {
+ if (participantEnglober == null) {
+ throw new IllegalStateException();
+ }
+ this.participantEnglober = null;
+ }
+
+ public boolean isBoxPending() {
+ return participantEnglober != null;
+ }
+
+ @Override
+ public int getNbImages() {
+ return getSequenceDiagramPngMaker(new FileFormatOption(FileFormat.PNG)).getNbPages();
+ }
+
+ public void removeHiddenParticipants() {
+ for (Participant p : new ArrayList<Participant>(participants.values())) {
+ if (isAlone(p)) {
+ remove(p);
+ }
+ }
+ }
+
+ private void remove(Participant p) {
+ final boolean ok = participants.values().remove(p);
+ if (ok == false) {
+ throw new IllegalArgumentException();
+ }
+ participantEnglobers2.remove(p);
+ }
+
+ private boolean isAlone(Participant p) {
+ for (Event ev : events) {
+ if (ev.dealWith(p)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public void putParticipantInLast(String code) {
+ final Participant p = participants.get(code);
+ if (p == null) {
+ throw new IllegalArgumentException(code);
+ }
+ participants.remove(code);
+ participants.put(code, p);
+ participantEnglobers2.put(p, participantEnglober);
+ }
+
+ public ParticipantEnglober getEnglober(Participant p) {
+ return participantEnglobers2.get(p);
+ }
+
+ private boolean autoactivate;
+
+ public final void setAutoactivate(boolean autoactivate) {
+ this.autoactivate = autoactivate;
+ }
+
+ public final boolean isAutoactivate() {
+ return autoactivate;
+ }
+
+ public boolean hasUrl() {
+ for (Participant p : participants.values()) {
+ if (p.getUrl() != null) {
+ return true;
+ }
+ }
+ for (Event ev : events) {
+ if (ev.hasUrl()) {
+ return true;
+ }
+ }
+ if (getLegend() != null && getLegend().hasUrl()) {
+ return true;
+ }
+ return false;
+ }
+
+ public void addReference(Reference ref) {
+ events.add(ref);
+ }
+
+ @Override
+ public boolean isOk() {
+ if (participants.size() == 0) {
+ return false;
+ }
+ return true;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagramFactory.java b/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagramFactory.java
new file mode 100644
index 0000000..2fdc66b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagramFactory.java
@@ -0,0 +1,146 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram;
+
+import java.util.ArrayList;
+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.note.sequence.FactorySequenceNoteCommand;
+import net.sourceforge.plantuml.command.note.sequence.FactorySequenceNoteOnArrowCommand;
+import net.sourceforge.plantuml.command.note.sequence.FactorySequenceNoteOverSeveralCommand;
+import net.sourceforge.plantuml.sequencediagram.command.CommandActivate;
+import net.sourceforge.plantuml.sequencediagram.command.CommandActivate2;
+import net.sourceforge.plantuml.sequencediagram.command.CommandArrow;
+import net.sourceforge.plantuml.sequencediagram.command.CommandAutoNewpage;
+import net.sourceforge.plantuml.sequencediagram.command.CommandAutoactivate;
+import net.sourceforge.plantuml.sequencediagram.command.CommandAutonumber;
+import net.sourceforge.plantuml.sequencediagram.command.CommandBoxEnd;
+import net.sourceforge.plantuml.sequencediagram.command.CommandBoxStart;
+import net.sourceforge.plantuml.sequencediagram.command.CommandDelay;
+import net.sourceforge.plantuml.sequencediagram.command.CommandDivider;
+import net.sourceforge.plantuml.sequencediagram.command.CommandExoArrowLeft;
+import net.sourceforge.plantuml.sequencediagram.command.CommandExoArrowRight;
+import net.sourceforge.plantuml.sequencediagram.command.CommandFootbox;
+import net.sourceforge.plantuml.sequencediagram.command.CommandFootboxOld;
+import net.sourceforge.plantuml.sequencediagram.command.CommandGrouping;
+import net.sourceforge.plantuml.sequencediagram.command.CommandHSpace;
+import net.sourceforge.plantuml.sequencediagram.command.CommandIgnoreNewpage;
+import net.sourceforge.plantuml.sequencediagram.command.CommandNewpage;
+import net.sourceforge.plantuml.sequencediagram.command.CommandParticipantA;
+import net.sourceforge.plantuml.sequencediagram.command.CommandParticipantA2;
+import net.sourceforge.plantuml.sequencediagram.command.CommandParticipantA3;
+import net.sourceforge.plantuml.sequencediagram.command.CommandParticipantA4;
+import net.sourceforge.plantuml.sequencediagram.command.CommandReferenceMultilinesOverSeveral;
+import net.sourceforge.plantuml.sequencediagram.command.CommandReferenceOverSeveral;
+import net.sourceforge.plantuml.sequencediagram.command.CommandReturn;
+import net.sourceforge.plantuml.sequencediagram.command.CommandSkin;
+import net.sourceforge.plantuml.sequencediagram.command.CommandUrl;
+
+public class SequenceDiagramFactory extends UmlDiagramFactory {
+
+ @Override
+ public SequenceDiagram createEmptyDiagram() {
+ return new SequenceDiagram();
+ }
+
+ @Override
+ protected List<Command> createCommands() {
+
+ final List<Command> cmds = new ArrayList<Command>();
+
+ addCommonCommands(cmds);
+
+ cmds.add(new CommandActivate());
+
+ cmds.add(new CommandParticipantA());
+ cmds.add(new CommandParticipantA2());
+ cmds.add(new CommandParticipantA3());
+ cmds.add(new CommandParticipantA4());
+ cmds.add(new CommandArrow());
+ // addCommand(new CommandArrowCrossX());
+ cmds.add(new CommandExoArrowLeft());
+ cmds.add(new CommandExoArrowRight());
+
+ final FactorySequenceNoteCommand factorySequenceNoteCommand = new FactorySequenceNoteCommand();
+ cmds.add(factorySequenceNoteCommand.createSingleLine());
+
+ final FactorySequenceNoteOverSeveralCommand factorySequenceNoteOverSeveralCommand = new FactorySequenceNoteOverSeveralCommand();
+ cmds.add(factorySequenceNoteOverSeveralCommand.createSingleLine());
+
+ cmds.add(new CommandBoxStart());
+ cmds.add(new CommandBoxEnd());
+ cmds.add(new CommandGrouping());
+
+ cmds.add(new CommandActivate2());
+ cmds.add(new CommandReturn());
+
+ final FactorySequenceNoteOnArrowCommand factorySequenceNoteOnArrowCommand = new FactorySequenceNoteOnArrowCommand();
+ cmds.add(factorySequenceNoteOnArrowCommand.createSingleLine());
+
+ cmds.add(factorySequenceNoteCommand.createMultiLine());
+ cmds.add(factorySequenceNoteOverSeveralCommand.createMultiLine());
+ cmds.add(factorySequenceNoteOnArrowCommand.createMultiLine());
+
+ cmds.add(new CommandNewpage());
+ cmds.add(new CommandIgnoreNewpage());
+ cmds.add(new CommandAutoNewpage());
+ cmds.add(new CommandDivider());
+ cmds.add(new CommandHSpace());
+ cmds.add(new CommandReferenceOverSeveral());
+ cmds.add(new CommandReferenceMultilinesOverSeveral());
+ cmds.add(new CommandSkin());
+ cmds.add(new CommandAutonumber());
+ cmds.add(new CommandAutoactivate());
+ cmds.add(new CommandFootbox());
+ cmds.add(new CommandDelay());
+ cmds.add(new CommandFootboxOld());
+ cmds.add(new CommandUrl());
+
+ return cmds;
+ }
+
+ @Override
+ public String checkFinalError(AbstractPSystem sys) {
+ final SequenceDiagram system = (SequenceDiagram) sys;
+ if (system.isHideUnlinkedData()) {
+ system.removeHiddenParticipants();
+ }
+ return super.checkFinalError(system);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandActivate.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandActivate.java
new file mode 100644
index 0000000..3d8b195
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandActivate.java
@@ -0,0 +1,66 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.sequencediagram.LifeEventType;
+import net.sourceforge.plantuml.sequencediagram.Participant;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+import net.sourceforge.plantuml.StringUtils;
+
+public class CommandActivate extends SingleLineCommand<SequenceDiagram> {
+
+ public CommandActivate() {
+ super("(?i)^(activate|deactivate|destroy|create)[%s]+([\\p{L}0-9_.@]+|[%g][^%g]+[%g])[%s]*(#\\w+)?$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(SequenceDiagram diagram, List<String> arg) {
+ final LifeEventType type = LifeEventType.valueOf(StringUtils.goUpperCase(arg.get(0)));
+ final Participant p = diagram.getOrCreateParticipant(StringUtils
+ .eventuallyRemoveStartingAndEndingDoubleQuote(arg.get(1)));
+ final String error = diagram.activate(p, type,
+ diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get(2)));
+ if (error == null) {
+ return CommandExecutionResult.ok();
+ }
+ return CommandExecutionResult.error(error);
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandActivate2.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandActivate2.java
new file mode 100644
index 0000000..2214319
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandActivate2.java
@@ -0,0 +1,63 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.sequencediagram.LifeEventType;
+import net.sourceforge.plantuml.sequencediagram.Participant;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+
+public class CommandActivate2 extends SingleLineCommand<SequenceDiagram> {
+
+ public CommandActivate2() {
+ super("(?i)^([\\p{L}0-9_.@]+)[%s]*(\\+\\+|--)[%s]*(#\\w+)?$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(SequenceDiagram diagram, List<String> arg) {
+ final LifeEventType type = arg.get(1).equals("++") ? LifeEventType.ACTIVATE : LifeEventType.DEACTIVATE;
+ final Participant p = diagram.getOrCreateParticipant(arg.get(0));
+ final String error = diagram.activate(p, type,
+ diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get(2)));
+ if (error == null) {
+ return CommandExecutionResult.ok();
+ }
+ return CommandExecutionResult.error(error);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandArrow.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandArrow.java
new file mode 100644
index 0000000..96357fc
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandArrow.java
@@ -0,0 +1,284 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import java.util.StringTokenizer;
+
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.classdiagram.command.CommandLinkClass;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexOr;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorSet;
+import net.sourceforge.plantuml.sequencediagram.LifeEventType;
+import net.sourceforge.plantuml.sequencediagram.Message;
+import net.sourceforge.plantuml.sequencediagram.Participant;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+import net.sourceforge.plantuml.skin.ArrowConfiguration;
+import net.sourceforge.plantuml.skin.ArrowDecoration;
+import net.sourceforge.plantuml.skin.ArrowHead;
+import net.sourceforge.plantuml.skin.ArrowPart;
+
+public class CommandArrow extends SingleLineCommand2<SequenceDiagram> {
+
+ public CommandArrow() {
+ super(getRegexConcat());
+ }
+
+ public static String getColorOrStylePattern() {
+ return "(?:\\[((?:#\\w+|dotted|dashed|bold|hidden)(?:,#\\w+|,dotted|,dashed|,bold|,hidden)*)\\])?";
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(
+ new RegexLeaf("^"), //
+ new RegexLeaf("PARALLEL", "(&%s*)?"), //
+ new RegexOr("PART1", //
+ new RegexLeaf("PART1CODE", "([\\p{L}0-9_.@]+)"), //
+ new RegexLeaf("PART1LONG", "[%g]([^%g]+)[%g]"), //
+ new RegexLeaf("PART1LONGCODE", "[%g]([^%g]+)[%g][%s]*as[%s]+([\\p{L}0-9_.@]+)"), //
+ new RegexLeaf("PART1CODELONG", "([\\p{L}0-9_.@]+)[%s]+as[%s]*[%g]([^%g]+)[%g]")), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("ARROW_DRESSING1", "([%s][ox]|(?:[%s][ox])?<<?|(?:[%s][ox])?//?|(?:[%s][ox])?\\\\\\\\?)?"), //
+ new RegexOr(new RegexConcat( //
+ new RegexLeaf("ARROW_BODYA1", "(-+)"), //
+ new RegexLeaf("ARROW_STYLE1", getColorOrStylePattern()), //
+ new RegexLeaf("ARROW_BODYB1", "(-*)")), //
+ new RegexConcat( //
+ new RegexLeaf("ARROW_BODYA2", "(-*)"), //
+ new RegexLeaf("ARROW_STYLE2", getColorOrStylePattern()), //
+ new RegexLeaf("ARROW_BODYB2", "(-+)"))), //
+ new RegexLeaf("ARROW_DRESSING2", "(>>?(?:[ox][%s])?|//?(?:[ox][%s])?|\\\\\\\\?(?:[ox][%s])?|[ox][%s])?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexOr("PART2", //
+ new RegexLeaf("PART2CODE", "([\\p{L}0-9_.@]+)"), //
+ new RegexLeaf("PART2LONG", "[%g]([^%g]+)[%g]"), //
+ new RegexLeaf("PART2LONGCODE", "[%g]([^%g]+)[%g][%s]*as[%s]+([\\p{L}0-9_.@]+)"), //
+ new RegexLeaf("PART2CODELONG", "([\\p{L}0-9_.@]+)[%s]+as[%s]*[%g]([^%g]+)[%g]")), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("ACTIVATION", "(?:([+*!-]+)?)"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("LIFECOLOR", "(?:(#\\w+)?)"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("MESSAGE", "(?::[%s]*(.*))?$"));
+ }
+
+ private Participant getOrCreateParticipant(SequenceDiagram system, RegexResult arg2, String n) {
+ final String code;
+ final Display display;
+ if (arg2.get(n + "CODE", 0) != null) {
+ code = arg2.get(n + "CODE", 0);
+ display = Display.getWithNewlines(code);
+ } else if (arg2.get(n + "LONG", 0) != null) {
+ code = arg2.get(n + "LONG", 0);
+ display = Display.getWithNewlines(code);
+ } else if (arg2.get(n + "LONGCODE", 0) != null) {
+ display = Display.getWithNewlines(arg2.get(n + "LONGCODE", 0));
+ code = arg2.get(n + "LONGCODE", 1);
+ } else if (arg2.get(n + "CODELONG", 0) != null) {
+ code = arg2.get(n + "CODELONG", 0);
+ display = Display.getWithNewlines(arg2.get(n + "CODELONG", 1));
+ return system.getOrCreateParticipant(code, display);
+ } else {
+ throw new IllegalStateException();
+ }
+ return system.getOrCreateParticipant(code, display);
+ }
+
+ private boolean contains(String string, String... totest) {
+ for (String t : totest) {
+ if (string.contains(t)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(SequenceDiagram diagram, RegexResult arg) {
+
+ Participant p1;
+ Participant p2;
+
+ final String dressing1 = StringUtils.goLowerCase(CommandLinkClass.notNull(arg.get("ARROW_DRESSING1", 0)));
+ final String dressing2 = StringUtils.goLowerCase(CommandLinkClass.notNull(arg.get("ARROW_DRESSING2", 0)));
+
+ final boolean circleAtStart;
+ final boolean circleAtEnd;
+
+ final boolean hasDressing2 = contains(dressing2, ">", "\\", "/", "x");
+ final boolean hasDressing1 = contains(dressing1, "x", "<", "\\", "/");
+ if (hasDressing2) {
+ p1 = getOrCreateParticipant(diagram, arg, "PART1");
+ p2 = getOrCreateParticipant(diagram, arg, "PART2");
+ circleAtStart = dressing1.contains("o");
+ circleAtEnd = dressing2.contains("o");
+ } else if (hasDressing1) {
+ p2 = getOrCreateParticipant(diagram, arg, "PART1");
+ p1 = getOrCreateParticipant(diagram, arg, "PART2");
+ circleAtStart = dressing2.contains("o");
+ circleAtEnd = dressing1.contains("o");
+ } else {
+ return CommandExecutionResult.error("Illegal sequence arrow");
+
+ }
+
+ final boolean sync = contains(dressing1, "<<", "\\\\", "//") || contains(dressing2, ">>", "\\\\", "//");
+
+ final boolean dotted = getLength(arg) > 1;
+
+ final Display labels;
+ if (arg.get("MESSAGE", 0) == null) {
+ labels = Display.create("");
+ } else {
+ labels = Display.getWithNewlines(arg.get("MESSAGE", 0));
+ }
+
+ ArrowConfiguration config = hasDressing1 && hasDressing2 ? ArrowConfiguration.withDirectionBoth()
+ : ArrowConfiguration.withDirectionNormal();
+ if (dotted) {
+ config = config.withDotted();
+ }
+ if (sync) {
+ config = config.withHead(ArrowHead.ASYNC);
+ }
+ if (dressing2.contains("\\") || dressing1.contains("/")) {
+ config = config.withPart(ArrowPart.TOP_PART);
+ }
+ if (dressing2.contains("/") || dressing1.contains("\\")) {
+ config = config.withPart(ArrowPart.BOTTOM_PART);
+ }
+ if (circleAtEnd) {
+ config = config.withDecoration2(ArrowDecoration.CIRCLE);
+ }
+ if (circleAtStart) {
+ config = config.withDecoration1(ArrowDecoration.CIRCLE);
+ }
+ if (dressing1.contains("x")) {
+ config = config.withHead2(ArrowHead.CROSSX);
+
+ }
+ if (dressing2.contains("x")) {
+ config = config.withHead2(ArrowHead.CROSSX);
+ }
+
+ config = applyStyle(arg.getLazzy("ARROW_STYLE", 0), config);
+
+ final String activationSpec = arg.get("ACTIVATION", 0);
+
+ if (activationSpec != null && activationSpec.charAt(0) == '*') {
+ diagram.activate(p2, LifeEventType.CREATE, null);
+ }
+
+ final Message msg = new Message(p1, p2, labels, config, diagram.getNextMessageNumber());
+ final boolean parallel = arg.get("PARALLEL", 0) != null;
+ if (parallel) {
+ msg.goParallel();
+ }
+
+ final String error = diagram.addMessage(msg);
+ if (error != null) {
+ return CommandExecutionResult.error(error);
+ }
+
+ final HtmlColor activationColor = diagram.getSkinParam().getIHtmlColorSet()
+ .getColorIfValid(arg.get("LIFECOLOR", 0));
+
+ if (activationSpec != null) {
+ switch (activationSpec.charAt(0)) {
+ case '+':
+ diagram.activate(p2, LifeEventType.ACTIVATE, activationColor);
+ break;
+ case '-':
+ diagram.activate(p1, LifeEventType.DEACTIVATE, null);
+ break;
+ case '!':
+ diagram.activate(p2, LifeEventType.DESTROY, null);
+ break;
+ default:
+ break;
+ }
+ } else if (diagram.isAutoactivate()
+ && (config.getHead() == ArrowHead.NORMAL || config.getHead() == ArrowHead.ASYNC)) {
+ if (config.isDotted()) {
+ diagram.activate(p1, LifeEventType.DEACTIVATE, null);
+ } else {
+ diagram.activate(p2, LifeEventType.ACTIVATE, activationColor);
+ }
+
+ }
+ return CommandExecutionResult.ok();
+ }
+
+ private int getLength(RegexResult arg2) {
+ String sa = arg2.getLazzy("ARROW_BODYA", 0);
+ if (sa == null) {
+ sa = "";
+ }
+ String sb = arg2.getLazzy("ARROW_BODYB", 0);
+ if (sb == null) {
+ sb = "";
+ }
+ return sa.length() + sb.length();
+ }
+
+ public static ArrowConfiguration applyStyle(String arrowStyle, ArrowConfiguration config) {
+ if (arrowStyle == null) {
+ return config;
+ }
+ final StringTokenizer st = new StringTokenizer(arrowStyle, ",");
+ while (st.hasMoreTokens()) {
+ final String s = st.nextToken();
+ if (s.equalsIgnoreCase("dashed")) {
+ // link.goDashed();
+ } else if (s.equalsIgnoreCase("bold")) {
+ // link.goBold();
+ } else if (s.equalsIgnoreCase("dotted")) {
+ // link.goDotted();
+ } else if (s.equalsIgnoreCase("hidden")) {
+ // link.goHidden();
+ } else {
+ config = config.withColor(HtmlColorSet.getInstance().getColorIfValid(s));
+ }
+ }
+ return config;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutoNewpage.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutoNewpage.java
new file mode 100644
index 0000000..e03dd9b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutoNewpage.java
@@ -0,0 +1,54 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+
+public class CommandAutoNewpage extends SingleLineCommand<SequenceDiagram> {
+
+ public CommandAutoNewpage() {
+ super("(?i)^autonewpage[%s]+(\\d+)$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, List<String> arg) {
+ sequenceDiagram.setAutonewpage(Integer.parseInt(arg.get(0)));
+ return CommandExecutionResult.ok();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutoactivate.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutoactivate.java
new file mode 100644
index 0000000..32d8536
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutoactivate.java
@@ -0,0 +1,54 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+
+public class CommandAutoactivate extends SingleLineCommand<SequenceDiagram> {
+
+ public CommandAutoactivate() {
+ super("(?i)^autoactivate[%s]+(off|on)*$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, List<String> arg) {
+ sequenceDiagram.setAutoactivate("on".equalsIgnoreCase(arg.get(0)));
+ return CommandExecutionResult.ok();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutonumber.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutonumber.java
new file mode 100644
index 0000000..37f936c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandAutonumber.java
@@ -0,0 +1,72 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import java.text.DecimalFormat;
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+
+public class CommandAutonumber extends SingleLineCommand<SequenceDiagram> {
+
+ public CommandAutonumber() {
+ super("(?i)^autonumber[%s]*(\\d+)?(?:[%s]+(\\d+))?(?:[%s]+[%g]([^%g]+)[%g])?[%s]*$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, List<String> arg) {
+ int start = 1;
+ if (arg.get(0) != null) {
+ start = Integer.parseInt(arg.get(0));
+ }
+ int inc = 1;
+ if (arg.get(1) != null) {
+ inc = Integer.parseInt(arg.get(1));
+ }
+
+ final String df = arg.get(2) == null ? "<b>0</b>" : arg.get(2);
+ final DecimalFormat decimalFormat;
+ try {
+ decimalFormat = new DecimalFormat(df);
+ } catch (IllegalArgumentException e) {
+ return CommandExecutionResult.error("Error in pattern : " + df);
+ }
+
+ sequenceDiagram.goAutonumber(start, inc, decimalFormat);
+ return CommandExecutionResult.ok();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandBoxEnd.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandBoxEnd.java
new file mode 100644
index 0000000..8465258
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandBoxEnd.java
@@ -0,0 +1,58 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+
+public class CommandBoxEnd extends SingleLineCommand<SequenceDiagram> {
+
+ public CommandBoxEnd() {
+ super("(?i)^end[%s]?box$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, List<String> arg) {
+ if (sequenceDiagram.isBoxPending() == false) {
+ return CommandExecutionResult.error("Missing starting box");
+ }
+ sequenceDiagram.endBox();
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandBoxStart.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandBoxStart.java
new file mode 100644
index 0000000..f899e7c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandBoxStart.java
@@ -0,0 +1,62 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+
+public class CommandBoxStart extends SingleLineCommand<SequenceDiagram> {
+
+ public CommandBoxStart() {
+ super("(?i)^box(?:[%s]+[%g]([^%g]+)[%g])?(?:[%s]+(#\\w+))?$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(SequenceDiagram diagram, List<String> arg) {
+ if (diagram.isBoxPending()) {
+ return CommandExecutionResult.error("Box cannot be nested");
+ }
+ final HtmlColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get(1));
+ final String title = arg.get(0) == null ? "" : arg.get(0);
+ diagram.boxStart(Display.getWithNewlines(title), color);
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandDelay.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandDelay.java
new file mode 100644
index 0000000..d73165e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandDelay.java
@@ -0,0 +1,56 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+
+public class CommandDelay extends SingleLineCommand<SequenceDiagram> {
+
+ public CommandDelay() {
+ super("(?i)^(?:\\.{3}|\u2026)(?:(.*)(?:\\.{3}|\u2026))?$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, List<String> arg) {
+ final Display strings = arg.get(0) == null ? Display.empty() : Display.getWithNewlines(arg.get(0));
+ sequenceDiagram.delay(strings);
+ return CommandExecutionResult.ok();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandDivider.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandDivider.java
new file mode 100644
index 0000000..025dab6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandDivider.java
@@ -0,0 +1,56 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+
+public class CommandDivider extends SingleLineCommand<SequenceDiagram> {
+
+ public CommandDivider() {
+ super("(?i)^==[%s]*(.*)[%s]*==$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, List<String> arg) {
+ final Display strings = Display.getWithNewlines(arg.get(0));
+ sequenceDiagram.divider(strings);
+ return CommandExecutionResult.ok();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowAny.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowAny.java
new file mode 100644
index 0000000..3ce2ebe
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowAny.java
@@ -0,0 +1,162 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.sequencediagram.MessageExo;
+import net.sourceforge.plantuml.sequencediagram.MessageExoType;
+import net.sourceforge.plantuml.sequencediagram.Participant;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+import net.sourceforge.plantuml.skin.ArrowConfiguration;
+import net.sourceforge.plantuml.skin.ArrowDecoration;
+import net.sourceforge.plantuml.skin.ArrowHead;
+import net.sourceforge.plantuml.skin.ArrowPart;
+import net.sourceforge.plantuml.StringUtils;
+
+abstract class CommandExoArrowAny extends SingleLineCommand2<SequenceDiagram> {
+
+ public CommandExoArrowAny(RegexConcat pattern) {
+ super(pattern);
+ }
+
+ @Override
+ final protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, RegexResult arg2) {
+ final String body = arg2.getLazzy("ARROW_BODYA", 0) + arg2.getLazzy("ARROW_BODYB", 0);
+ final String dressing = arg2.getLazzy("ARROW_DRESSING", 0);
+ final Participant p = sequenceDiagram.getOrCreateParticipant(StringUtils
+ .eventuallyRemoveStartingAndEndingDoubleQuote(arg2.get("PARTICIPANT", 0)));
+
+ final boolean sync = dressing.length() == 2;
+ final boolean dotted = body.contains("--");
+
+ final Display labels;
+ if (arg2.get("LABEL", 0) == null) {
+ labels = Display.create("");
+ } else {
+ labels = Display.getWithNewlines(arg2.get("LABEL", 0));
+ }
+
+ final boolean bothDirection = arg2.get("ARROW_BOTHDRESSING", 0) != null;
+
+ ArrowConfiguration config = bothDirection ? ArrowConfiguration.withDirectionBoth() : ArrowConfiguration
+ .withDirectionNormal();
+ if (dotted) {
+ config = config.withDotted();
+ }
+ if (sync) {
+ config = config.withHead(ArrowHead.ASYNC);
+ }
+ config = config.withPart(getArrowPart(dressing));
+ config = CommandArrow.applyStyle(arg2.getLazzy("ARROW_STYLE", 0), config);
+ final MessageExoType messageExoType = getMessageExoType(arg2);
+
+ if (messageExoType == MessageExoType.TO_RIGHT || messageExoType == MessageExoType.TO_LEFT) {
+ if (containsSymbolExterior(arg2, "o")) {
+ config = config.withDecoration2(ArrowDecoration.CIRCLE);
+ }
+ if (containsSymbol(arg2, "o")) {
+ config = config.withDecoration1(ArrowDecoration.CIRCLE);
+ }
+ } else {
+ if (containsSymbolExterior(arg2, "o")) {
+ config = config.withDecoration1(ArrowDecoration.CIRCLE);
+ }
+ if (containsSymbol(arg2, "o")) {
+ config = config.withDecoration2(ArrowDecoration.CIRCLE);
+ }
+ }
+
+ if (containsSymbolExterior(arg2, "x") || containsSymbol(arg2, "x")) {
+ config = config.withHead2(ArrowHead.CROSSX);
+ }
+// if (messageExoType.getDirection() == 1) {
+// if (containsSymbolExterior(arg2, "x") || containsSymbol(arg2, "x")) {
+// config = config.withHead2(ArrowHead.CROSSX);
+// }
+// } else {
+// if (containsSymbolExterior(arg2, "x") || containsSymbol(arg2, "x")) {
+// config = config.withHead2(ArrowHead.CROSSX);
+// }
+// }
+
+ final String error = sequenceDiagram.addMessage(new MessageExo(p, messageExoType, labels, config,
+ sequenceDiagram.getNextMessageNumber(), isShortArrow(arg2)));
+ if (error != null) {
+ return CommandExecutionResult.error(error);
+ }
+ return CommandExecutionResult.ok();
+ }
+
+ private ArrowPart getArrowPart(String dressing) {
+ if (dressing.contains("/")) {
+ return ArrowPart.BOTTOM_PART;
+ }
+ if (dressing.contains("\\")) {
+ return ArrowPart.TOP_PART;
+ }
+ return ArrowPart.FULL;
+ }
+
+ abstract MessageExoType getMessageExoType(RegexResult arg2);
+
+ private boolean isShortArrow(RegexResult arg2) {
+ final String s = arg2.get("SHORT", 0);
+ if (s != null && s.contains("?")) {
+ return true;
+ }
+ return false;
+ }
+
+ private boolean containsSymbolExterior(RegexResult arg2, String symbol) {
+ final String s = arg2.get("SHORT", 0);
+ if (s != null && s.contains(symbol)) {
+ return true;
+ }
+ return false;
+ }
+
+ private boolean containsSymbol(RegexResult arg2, String symbol) {
+ final String s = arg2.get("ARROW_SUPPCIRCLE", 0);
+ if (s != null && s.contains(symbol)) {
+ return true;
+ }
+ return false;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowLeft.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowLeft.java
new file mode 100644
index 0000000..e419541
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowLeft.java
@@ -0,0 +1,95 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexOr;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.sequencediagram.MessageExoType;
+
+public class CommandExoArrowLeft extends CommandExoArrowAny {
+
+ public CommandExoArrowLeft() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("SHORT", "([?\\[\\]][ox]?)?"), //
+ new RegexOr( //
+ new RegexConcat( //
+ new RegexLeaf("ARROW_BOTHDRESSING", "(<<?|//?|\\\\\\\\?)?"), //
+ new RegexLeaf("ARROW_BODYA1", "(-+)"), //
+ new RegexLeaf("ARROW_STYLE1", CommandArrow.getColorOrStylePattern()), //
+ new RegexLeaf("ARROW_BODYB1", "(-*)"), //
+ new RegexLeaf("ARROW_DRESSING1", "(>>?|//?|\\\\\\\\?)")), //
+ new RegexConcat( //
+ new RegexLeaf("ARROW_DRESSING2", "(<<?|//?|\\\\\\\\?)"), //
+ new RegexLeaf("ARROW_BODYB2", "(-*)"), //
+ new RegexLeaf("ARROW_STYLE2", CommandArrow.getColorOrStylePattern()), //
+ new RegexLeaf("ARROW_BODYA2", "(-+)"))), //
+ new RegexLeaf("ARROW_SUPPCIRCLE", "([ox][%s]+)?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("PARTICIPANT", "([\\p{L}0-9_.@]+|[%g][^%g]+[%g])"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("LABEL", "(?::[%s]*(.*))?"), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ MessageExoType getMessageExoType(RegexResult arg2) {
+ final String start = arg2.get("SHORT", 0);
+ final String dressing1 = arg2.get("ARROW_DRESSING1", 0);
+ final String dressing2 = arg2.get("ARROW_DRESSING2", 0);
+ if (start != null && start.contains("]")) {
+ if (dressing1 != null) {
+ return MessageExoType.FROM_RIGHT;
+ }
+ if (dressing2 != null) {
+ return MessageExoType.TO_RIGHT;
+ }
+ throw new IllegalArgumentException();
+ }
+ if (dressing1 != null) {
+ return MessageExoType.FROM_LEFT;
+ }
+ if (dressing2 != null) {
+ return MessageExoType.TO_LEFT;
+ }
+ throw new IllegalArgumentException();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowRight.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowRight.java
new file mode 100644
index 0000000..fbe168c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowRight.java
@@ -0,0 +1,95 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexOr;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.sequencediagram.MessageExoType;
+
+public class CommandExoArrowRight extends CommandExoArrowAny {
+
+ public CommandExoArrowRight() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("PARTICIPANT", "([\\p{L}0-9_.@]+|[%g][^%g]+[%g])"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("ARROW_SUPPCIRCLE", "([%s]+[ox])?"), //
+ new RegexOr( //
+ new RegexConcat( //
+ new RegexLeaf("ARROW_BOTHDRESSING", "(<<?|//?|\\\\\\\\?)?"), //
+ new RegexLeaf("ARROW_BODYA1", "(-+)"), //
+ new RegexLeaf("ARROW_STYLE1", CommandArrow.getColorOrStylePattern()), //
+ new RegexLeaf("ARROW_BODYB1", "(-*)"), //
+ new RegexLeaf("ARROW_DRESSING1", "(>>?|//?|\\\\\\\\?)")), //
+ new RegexConcat( //
+ new RegexLeaf("ARROW_DRESSING2", "(<<?|//?|\\\\\\\\?)"), //
+ new RegexLeaf("ARROW_BODYB2", "(-*)"), //
+ new RegexLeaf("ARROW_STYLE2", CommandArrow.getColorOrStylePattern()), //
+ new RegexLeaf("ARROW_BODYA2", "(-+)"))), //
+ new RegexLeaf("SHORT", "([ox]?[?\\]\\[])?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("LABEL", "(?::[%s]*(.*))?"), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ MessageExoType getMessageExoType(RegexResult arg2) {
+ final String start = arg2.get("SHORT", 0);
+ final String dressing1 = arg2.get("ARROW_DRESSING1", 0);
+ final String dressing2 = arg2.get("ARROW_DRESSING2", 0);
+ if (start != null && start.contains("[")) {
+ if (dressing1 != null) {
+ return MessageExoType.TO_LEFT;
+ }
+ if (dressing2 != null) {
+ return MessageExoType.FROM_LEFT;
+ }
+ throw new IllegalArgumentException();
+ }
+ if (dressing1 != null) {
+ return MessageExoType.TO_RIGHT;
+ }
+ if (dressing2 != null) {
+ return MessageExoType.FROM_RIGHT;
+ }
+ throw new IllegalArgumentException();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandFootbox.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandFootbox.java
new file mode 100644
index 0000000..2d932c8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandFootbox.java
@@ -0,0 +1,55 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+
+public class CommandFootbox extends SingleLineCommand<SequenceDiagram> {
+
+ public CommandFootbox() {
+ super("(?i)^(hide|show)?[%s]*footbox$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, List<String> arg) {
+ final boolean footbox = arg.get(0).equalsIgnoreCase("show");
+ sequenceDiagram.setShowFootbox(footbox);
+ return CommandExecutionResult.ok();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandFootboxOld.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandFootboxOld.java
new file mode 100644
index 0000000..3cf62c2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandFootboxOld.java
@@ -0,0 +1,55 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+
+public class CommandFootboxOld extends SingleLineCommand<SequenceDiagram> {
+
+ public CommandFootboxOld() {
+ super("(?i)^footbox[%s]*(on|off)?[%s]*$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, List<String> arg) {
+ final boolean footbox = arg.get(0).equalsIgnoreCase("on");
+ sequenceDiagram.setShowFootbox(footbox);
+ return CommandExecutionResult.ok();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandGrouping.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandGrouping.java
new file mode 100644
index 0000000..79c24e0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandGrouping.java
@@ -0,0 +1,92 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.sequencediagram.GroupingType;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+import net.sourceforge.plantuml.StringUtils;
+
+public class CommandGrouping extends SingleLineCommand2<SequenceDiagram> {
+
+ public CommandGrouping() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(//
+ new RegexLeaf("^"), //
+ new RegexLeaf("TYPE", "(opt|alt|loop|par|par2|break|critical|else|end|also|group)"), //
+ new RegexLeaf("COLORS", "((?<!else)(?<!also)(?<!end)#\\w+)?(?:[%s]+(#\\w+))?"), //
+ new RegexLeaf("COMMENT", "(?:[%s]+(.*?))?"), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(SequenceDiagram diagram, RegexResult arg) {
+ String type = StringUtils.goLowerCase(arg.get("TYPE", 0));
+ final HtmlColor backColorElement = diagram.getSkinParam().getIHtmlColorSet()
+ .getColorIfValid(arg.get("COLORS", 0));
+ final HtmlColor backColorGeneral = diagram.getSkinParam().getIHtmlColorSet()
+ .getColorIfValid(arg.get("COLORS", 1));
+ String comment = arg.get("COMMENT", 0);
+ final GroupingType groupingType = GroupingType.getType(type);
+ if ("group".equals(type)) {
+ if (StringUtils.isEmpty(comment)) {
+ comment = "group";
+ } else {
+ final Pattern p = Pattern.compile("^(.*?)\\[(.*)\\]$");
+ final Matcher m = p.matcher(comment);
+ if (m.find()) {
+ type = m.group(1);
+ comment = m.group(2);
+ }
+ }
+ }
+ final boolean result = diagram.grouping(type, comment, groupingType, backColorGeneral, backColorElement);
+ if (result == false) {
+ return CommandExecutionResult.error("Cannot create group");
+ }
+ return CommandExecutionResult.ok();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandHSpace.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandHSpace.java
new file mode 100644
index 0000000..92bbfdf
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandHSpace.java
@@ -0,0 +1,60 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+import net.sourceforge.plantuml.StringUtils;
+
+public class CommandHSpace extends SingleLineCommand<SequenceDiagram> {
+
+ public CommandHSpace() {
+ super("(?i)^\\|\\|(\\d+)?\\|+$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, List<String> arg) {
+ final String size = arg.get(0);
+ if (StringUtils.isNotEmpty(size)) {
+ sequenceDiagram.hspace(Integer.parseInt(size));
+ } else {
+ sequenceDiagram.hspace();
+ }
+ return CommandExecutionResult.ok();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandIgnoreNewpage.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandIgnoreNewpage.java
new file mode 100644
index 0000000..5ffa480
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandIgnoreNewpage.java
@@ -0,0 +1,54 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+
+public class CommandIgnoreNewpage extends SingleLineCommand<SequenceDiagram> {
+
+ public CommandIgnoreNewpage() {
+ super("(?i)^ignore[%s]*newpage$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, List<String> arg) {
+ sequenceDiagram.ignoreNewpage();
+ return CommandExecutionResult.ok();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandNewpage.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandNewpage.java
new file mode 100644
index 0000000..8ef40bd
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandNewpage.java
@@ -0,0 +1,56 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+
+public class CommandNewpage extends SingleLineCommand<SequenceDiagram> {
+
+ public CommandNewpage() {
+ super("(?i)^@?newpage(?:(?:[%s]*:[%s]*|[%s]+)(.*[\\p{L}0-9_.].*))?$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, List<String> arg) {
+ final Display strings = arg.get(0) == null ? null : Display.getWithNewlines(arg.get(0));
+ sequenceDiagram.newpage(strings);
+ return CommandExecutionResult.ok();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipant.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipant.java
new file mode 100644
index 0000000..8c3d999
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipant.java
@@ -0,0 +1,128 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
+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.RegexOr;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.sequencediagram.LifeEventType;
+import net.sourceforge.plantuml.sequencediagram.Participant;
+import net.sourceforge.plantuml.sequencediagram.ParticipantType;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public abstract class CommandParticipant extends SingleLineCommand2<SequenceDiagram> {
+
+ public CommandParticipant(RegexConcat pattern) {
+ super(pattern);
+ }
+
+ static IRegex getRegexType() {
+ return new RegexOr(new RegexLeaf("TYPE", "(participant|actor|create|boundary|control|entity|database)"), //
+ new RegexLeaf("CREATE", "create[%s](participant|actor|boundary|control|entity|database)"));
+ }
+
+ @Override
+ final protected CommandExecutionResult executeArg(SequenceDiagram diagram, RegexResult arg) {
+ final String code = arg.get("CODE", 0);
+ if (diagram.participants().containsKey(code)) {
+ diagram.putParticipantInLast(code);
+ return CommandExecutionResult.ok();
+ }
+
+ Display strings = null;
+ if (arg.get("FULL", 0) != null) {
+ strings = Display.getWithNewlines(arg.get("FULL", 0));
+ }
+
+ final String typeString1 = arg.get("TYPE", 0);
+ final String typeCreate1 = arg.get("CREATE", 0);
+ final ParticipantType type;
+ final boolean create;
+ if (typeCreate1 != null) {
+ type = ParticipantType.valueOf(StringUtils.goUpperCase(typeCreate1));
+ create = true;
+ } else if (typeString1.equalsIgnoreCase("CREATE")) {
+ type = ParticipantType.PARTICIPANT;
+ create = true;
+ } else {
+ type = ParticipantType.valueOf(StringUtils.goUpperCase(typeString1));
+ create = false;
+ }
+ final Participant participant = diagram.createNewParticipant(type, code, strings);
+
+ final String stereotype = arg.get("STEREO", 0);
+
+ if (stereotype != null) {
+ final ISkinParam skinParam = diagram.getSkinParam();
+ final boolean stereotypePositionTop = skinParam.stereotypePositionTop();
+ final UFont font = skinParam.getFont(FontParam.CIRCLED_CHARACTER, null, false);
+ participant.setStereotype(new Stereotype(stereotype, skinParam.getCircledCharacterRadius(), font, diagram
+ .getSkinParam().getIHtmlColorSet()), stereotypePositionTop);
+ }
+ participant
+ .setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0)));
+
+ final String urlString = arg.get("URL", 0);
+ if (urlString != null) {
+ final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
+ final Url url = urlBuilder.getUrl(urlString);
+ participant.setUrl(url);
+ }
+
+ if (create) {
+ final String error = diagram.activate(participant, LifeEventType.CREATE, null);
+ if (error != null) {
+ return CommandExecutionResult.error(error);
+ }
+
+ }
+
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA.java
new file mode 100644
index 0000000..1acc19f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA.java
@@ -0,0 +1,63 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+
+public class CommandParticipantA extends CommandParticipant {
+
+ public CommandParticipantA() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ getRegexType(), //
+ new RegexLeaf("[%s]+"), //
+ new RegexLeaf("FULL", "(?:[%g]([^%g]+)[%g][%s]+as[%s]+)?"), //
+ new RegexLeaf("CODE", "([\\p{L}0-9_.@]+)"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("COLOR", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), //
+ new RegexLeaf("$"));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA2.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA2.java
new file mode 100644
index 0000000..b3545c6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA2.java
@@ -0,0 +1,64 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+
+public class CommandParticipantA2 extends CommandParticipant {
+
+ public CommandParticipantA2() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ getRegexType(), //
+ new RegexLeaf("[%s]+"), //
+ new RegexLeaf("CODE", "([\\p{L}0-9_.@]+)"), //
+ new RegexLeaf("[%s]+as[%s]+"), //
+ new RegexLeaf("FULL", "[%g]([^%g]+)[%g]"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("COLOR", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), //
+ new RegexLeaf("$"));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA3.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA3.java
new file mode 100644
index 0000000..4c8d538
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA3.java
@@ -0,0 +1,63 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+
+public class CommandParticipantA3 extends CommandParticipant {
+
+ public CommandParticipantA3() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ getRegexType(), //
+ new RegexLeaf("[%s]+"), //
+ new RegexLeaf("FULL", "([\\p{L}0-9_.@]+)[%s]+as[%s]+"), //
+ new RegexLeaf("CODE", "([\\p{L}0-9_.@]+)"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("COLOR", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), //
+ new RegexLeaf("$"));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA4.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA4.java
new file mode 100644
index 0000000..bf1032e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandParticipantA4.java
@@ -0,0 +1,62 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+
+public class CommandParticipantA4 extends CommandParticipant {
+
+ public CommandParticipantA4() {
+ super(getRegexConcat());
+ }
+
+ static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ getRegexType(), //
+ new RegexLeaf("[%s]+"), //
+ new RegexLeaf("CODE", "[%g]([^%g]+)[%g]"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("COLOR", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), //
+ new RegexLeaf("$"));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandReferenceMultilinesOverSeveral.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandReferenceMultilinesOverSeveral.java
new file mode 100644
index 0000000..4e0bd43
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandReferenceMultilinesOverSeveral.java
@@ -0,0 +1,92 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.CommandMultilines;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.sequencediagram.Participant;
+import net.sourceforge.plantuml.sequencediagram.Reference;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+import net.sourceforge.plantuml.StringUtils;
+
+public class CommandReferenceMultilinesOverSeveral extends CommandMultilines<SequenceDiagram> {
+
+ public CommandReferenceMultilinesOverSeveral() {
+ super(
+ "(?i)^ref(#\\w+)?[%s]+over[%s]+((?:[\\p{L}0-9_.@]+|[%g][^%g]+[%g])(?:[%s]*,[%s]*(?:[\\p{L}0-9_.@]+|[%g][^%g]+[%g]))*)[%s]*(#\\w+)?$");
+ }
+
+ @Override
+ public String getPatternEnd() {
+ return "(?i)^end[%s]?(ref)?$";
+ }
+
+ public CommandExecutionResult execute(final SequenceDiagram diagram, List<String> lines) {
+ final List<String> line0 = StringUtils.getSplit(getStartingPattern(), lines.get(0).trim());
+ final HtmlColor backColorElement = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(line0.get(0));
+ // final HtmlColor backColorGeneral = HtmlColorSet.getInstance().getColorIfValid(line0.get(1));
+
+ final List<String> participants = StringUtils.splitComma(line0.get(1));
+ final List<Participant> p = new ArrayList<Participant>();
+ for (String s : participants) {
+ p.add(diagram.getOrCreateParticipant(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(s)));
+ }
+
+ Display strings = Display.create(lines.subList(1, lines.size() - 1)).removeEmptyColumns();
+
+ Url u = null;
+ if (strings.size() > 0) {
+ final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
+ u = urlBuilder.getUrl(strings.get(0).toString());
+ }
+ if (u != null) {
+ strings = strings.subList(1, strings.size());
+ }
+
+ final HtmlColor backColorGeneral = null;
+ final Reference ref = new Reference(p, u, strings, backColorGeneral, backColorElement);
+ diagram.addReference(ref);
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandReferenceOverSeveral.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandReferenceOverSeveral.java
new file mode 100644
index 0000000..46e2821
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandReferenceOverSeveral.java
@@ -0,0 +1,98 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.sequencediagram.Participant;
+import net.sourceforge.plantuml.sequencediagram.Reference;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+import net.sourceforge.plantuml.StringUtils;
+
+public class CommandReferenceOverSeveral extends SingleLineCommand2<SequenceDiagram> {
+
+ public CommandReferenceOverSeveral() {
+ super(getConcat());
+ }
+
+ private static RegexConcat getConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("REF", "ref(#\\w+)?[%s]+over[%s]+"), //
+ new RegexLeaf("PARTS",
+ "(([\\p{L}0-9_.@]+|[%g][^%g]+[%g])([%s]*,[%s]*([\\p{L}0-9_.@]+|[%g][^%g]+[%g]))*)"), //
+ new RegexLeaf("[%s]*:[%s]*"), //
+ new RegexLeaf("URL", "(?:\\[\\[([^|]*)(?:\\|([^|]*))?\\]\\])?"), //
+ new RegexLeaf("TEXT", "(.*)"), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(SequenceDiagram diagram, RegexResult arg) {
+ final HtmlColor backColorElement = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("REF", 0));
+ // final HtmlColor backColorGeneral = HtmlColorSet.getInstance().getColorIfValid(arg.get("REF").get(1));
+
+ final List<String> participants = StringUtils.splitComma(arg.get("PARTS", 0));
+ final String url = arg.get("URL", 0);
+ final String title = arg.get("URL", 1);
+ final String text = arg.get("TEXT", 0).trim();
+
+ final List<Participant> p = new ArrayList<Participant>();
+ for (String s : participants) {
+ p.add(diagram.getOrCreateParticipant(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(s)));
+ }
+
+ final Display strings = Display.getWithNewlines(text);
+
+ Url u = null;
+ if (url != null) {
+ u = new Url(url, title);
+ }
+
+ final HtmlColor backColorGeneral = null;
+ final Reference ref = new Reference(p, u, strings, backColorGeneral, backColorElement);
+ diagram.addReference(ref);
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandReturn.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandReturn.java
new file mode 100644
index 0000000..5e9e278
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandReturn.java
@@ -0,0 +1,85 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.sequencediagram.AbstractMessage;
+import net.sourceforge.plantuml.sequencediagram.EventWithDeactivate;
+import net.sourceforge.plantuml.sequencediagram.LifeEventType;
+import net.sourceforge.plantuml.sequencediagram.Message;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+import net.sourceforge.plantuml.skin.ArrowConfiguration;
+
+public class CommandReturn extends SingleLineCommand<SequenceDiagram> {
+
+ public CommandReturn() {
+ super("(?i)^return[%s]*(.*)$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, List<String> arg) {
+
+ Message message = sequenceDiagram.getActivatingMessage();
+ boolean doDeactivation = true;
+ if (message == null) {
+ final EventWithDeactivate last = sequenceDiagram.getLastEventWithDeactivate();
+ if (last instanceof Message == false) {
+ return CommandExecutionResult.error("Nowhere to return to.");
+ }
+ message = (Message) last;
+ doDeactivation = false;
+ }
+
+ final ArrowConfiguration arrow = message.getArrowConfiguration().withDotted();
+
+ sequenceDiagram.addMessage(
+ new Message(message.getParticipant2(), message.getParticipant1(), Display.getWithNewlines(arg
+ .get(0)), arrow, sequenceDiagram.getNextMessageNumber()));
+
+ if (doDeactivation) {
+ final String error = sequenceDiagram.activate(message.getParticipant2(), LifeEventType.DEACTIVATE, null);
+ if (error != null) {
+ return CommandExecutionResult.error(error);
+ }
+ }
+ return CommandExecutionResult.ok();
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandSkin.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandSkin.java
new file mode 100644
index 0000000..5ba2ca4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandSkin.java
@@ -0,0 +1,57 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+
+public class CommandSkin extends SingleLineCommand<SequenceDiagram> {
+
+ public CommandSkin() {
+ super("(?i)^skin[%s]+([\\w.]+)$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(SequenceDiagram system, List<String> arg) {
+ if (system.changeSkin(arg.get(0))) {
+ return CommandExecutionResult.ok();
+ }
+ return CommandExecutionResult.error("Cannot change skin");
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandUrl.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandUrl.java
new file mode 100644
index 0000000..8241f1d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandUrl.java
@@ -0,0 +1,65 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.sequencediagram.Participant;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+
+public class CommandUrl extends SingleLineCommand<SequenceDiagram> {
+
+ public CommandUrl() {
+ super("(?i)^url[%s]*(?:of|for)?[%s]+([\\p{L}0-9_.@]+|[%g][^%g]+[%g])[%s]+(?:is)?[%s]*(" + UrlBuilder.getRegexp() + ")$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(SequenceDiagram diagram, List<String> arg) {
+ final String code = arg.get(0);
+ final String urlString = arg.get(1);
+ // final String title = arg.get(2);
+ final Participant p = diagram.getOrCreateParticipant(code);
+ final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
+ final Url url = urlBuilder.getUrl(urlString);
+ p.setUrl(url);
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/Arrow.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/Arrow.java
new file mode 100644
index 0000000..08e215e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/Arrow.java
@@ -0,0 +1,126 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.sequencediagram.InGroupable;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+abstract class Arrow extends GraphicalElement implements InGroupable {
+
+ private final Skin skin;
+ private final Component arrowComponent;
+ private double paddingArrowHead = 0;
+ private double maxX;
+ private final Url url;
+
+ public void setMaxX(double m) {
+ if (maxX != 0) {
+ throw new IllegalStateException();
+ }
+ this.maxX = m;
+ }
+
+ final protected double getMaxX() {
+ if (maxX == 0) {
+ // throw new IllegalStateException();
+ }
+ return maxX;
+ }
+
+ public abstract double getActualWidth(StringBounder stringBounder);
+
+ Arrow(double startingY, Skin skin, Component arrowComponent, Url url) {
+ super(startingY);
+ this.skin = skin;
+ this.arrowComponent = arrowComponent;
+ this.url = url;
+ }
+
+ protected Url getUrl() {
+ return url;
+ }
+
+ protected final void startUrl(UGraphic ug) {
+ if (url != null) {
+ ug.startUrl(url);
+ }
+ }
+
+ protected final void endUrl(UGraphic ug) {
+ if (url != null) {
+ ug.closeAction();
+ }
+ }
+
+
+ public abstract int getDirection(StringBounder stringBounder);
+
+ protected Skin getSkin() {
+ return skin;
+ }
+
+ protected final Component getArrowComponent() {
+ return arrowComponent;
+ }
+
+ public double getArrowOnlyWidth(StringBounder stringBounder) {
+ return getPreferredWidth(stringBounder);
+ }
+
+ public abstract double getArrowYStartLevel(StringBounder stringBounder);
+
+ public abstract double getArrowYEndLevel(StringBounder stringBounder);
+
+ public abstract LivingParticipantBox getParticipantAt(StringBounder stringBounder, NotePosition position);
+
+ protected final double getPaddingArrowHead() {
+ return paddingArrowHead;
+ }
+
+ protected final void setPaddingArrowHead(double paddingArrowHead) {
+ this.paddingArrowHead = paddingArrowHead;
+ }
+
+ final public double getMargin() {
+ return 5;
+ }
+
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/ArrowAndNoteBox.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/ArrowAndNoteBox.java
new file mode 100644
index 0000000..25c2361
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/ArrowAndNoteBox.java
@@ -0,0 +1,138 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.sequencediagram.InGroupable;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+class ArrowAndNoteBox extends Arrow implements InGroupable {
+
+ private final Arrow arrow;
+ private final NoteBox noteBox;
+
+ public ArrowAndNoteBox(StringBounder stringBounder, Arrow arrow, NoteBox noteBox) {
+ super(arrow.getStartingY(), arrow.getSkin(), arrow.getArrowComponent(), arrow.getUrl());
+ this.arrow = arrow;
+ this.noteBox = noteBox;
+
+ final double arrowHeight = arrow.getPreferredHeight(stringBounder);
+ final double noteHeight = noteBox.getPreferredHeight(stringBounder);
+ final double myHeight = getPreferredHeight(stringBounder);
+
+ final double diffHeightArrow = myHeight - arrowHeight;
+ final double diffHeightNote = myHeight - noteHeight;
+ if (diffHeightArrow > 0) {
+ arrow.pushToDown(diffHeightArrow / 2);
+ }
+ if (diffHeightNote > 0) {
+ noteBox.pushToDown(diffHeightNote / 2);
+ }
+ }
+
+ @Override
+ final public double getArrowOnlyWidth(StringBounder stringBounder) {
+ return arrow.getPreferredWidth(stringBounder);
+ }
+
+ @Override
+ public void setMaxX(double m) {
+ super.setMaxX(m);
+ arrow.setMaxX(m);
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, double maxX, Context2D context) {
+ arrow.drawU(ug, maxX, context);
+ noteBox.drawU(ug, maxX, context);
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return Math.max(arrow.getPreferredHeight(stringBounder), noteBox.getPreferredHeight(stringBounder));
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ double w = arrow.getPreferredWidth(stringBounder);
+ w = Math.max(w, arrow.getActualWidth(stringBounder));
+ return w + noteBox.getPreferredWidth(stringBounder);
+ }
+
+ @Override
+ public double getActualWidth(StringBounder stringBounder) {
+ return getPreferredWidth(stringBounder);
+ }
+
+ @Override
+ public double getStartingX(StringBounder stringBounder) {
+ return Math.min(arrow.getStartingX(stringBounder), noteBox.getStartingX(stringBounder));
+ }
+
+ @Override
+ public int getDirection(StringBounder stringBounder) {
+ return arrow.getDirection(stringBounder);
+ }
+
+ @Override
+ public double getArrowYStartLevel(StringBounder stringBounder) {
+ return arrow.getArrowYStartLevel(stringBounder);
+ }
+
+ @Override
+ public double getArrowYEndLevel(StringBounder stringBounder) {
+ return arrow.getArrowYEndLevel(stringBounder);
+ }
+
+ public double getMaxX(StringBounder stringBounder) {
+ return getStartingX(stringBounder) + getPreferredWidth(stringBounder);
+ }
+
+ public double getMinX(StringBounder stringBounder) {
+ return getStartingX(stringBounder);
+ }
+
+ public String toString(StringBounder stringBounder) {
+ return toString();
+ }
+
+ @Override
+ public LivingParticipantBox getParticipantAt(StringBounder stringBounder, NotePosition position) {
+ return arrow.getParticipantAt(stringBounder, position);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/ArrowAndParticipant.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/ArrowAndParticipant.java
new file mode 100644
index 0000000..3944bb4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/ArrowAndParticipant.java
@@ -0,0 +1,148 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.sequencediagram.InGroupable;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class ArrowAndParticipant extends Arrow implements InGroupable {
+
+ private final Arrow arrow;
+ private final ParticipantBox participantBox;
+
+ public ArrowAndParticipant(StringBounder stringBounder, Arrow arrow, ParticipantBox participantBox) {
+ super(arrow.getStartingY(), arrow.getSkin(), arrow.getArrowComponent(), arrow.getUrl());
+ this.arrow = arrow;
+ this.participantBox = participantBox;
+ arrow.setPaddingArrowHead(participantBox.getPreferredWidth(stringBounder) / 2);
+ }
+
+ @Override
+ public void setMaxX(double m) {
+ super.setMaxX(m);
+ arrow.setMaxX(m);
+ }
+
+ @Override
+ final public double getArrowOnlyWidth(StringBounder stringBounder) {
+ return arrow.getPreferredWidth(stringBounder) + participantBox.getPreferredWidth(stringBounder) / 2;
+ }
+
+ @Override
+ public double getArrowYEndLevel(StringBounder stringBounder) {
+ return arrow.getArrowYEndLevel(stringBounder);
+ }
+
+ @Override
+ public double getArrowYStartLevel(StringBounder stringBounder) {
+ return arrow.getArrowYStartLevel(stringBounder);
+ }
+
+ @Override
+ public int getDirection(StringBounder stringBounder) {
+ return arrow.getDirection(stringBounder);
+ }
+
+ @Override
+ public LivingParticipantBox getParticipantAt(StringBounder stringBounder, NotePosition position) {
+ return arrow.getParticipantAt(stringBounder, position);
+ }
+
+ @Override
+ protected void drawInternalU(final UGraphic ug, double maxX, Context2D context) {
+ final double participantBoxStartingX = participantBox.getStartingX();
+ final double arrowStartingX = arrow.getStartingX(ug.getStringBounder());
+
+ if (arrowStartingX < participantBoxStartingX) {
+ arrow.drawInternalU(ug, maxX, context);
+ } else {
+ final double boxWidth = participantBox.getPreferredWidth(ug.getStringBounder());
+ arrow.drawInternalU(ug.apply(new UTranslate(boxWidth / 2, 0)), maxX, context);
+ }
+
+ final double arrowHeight = arrow.getPreferredHeight(ug.getStringBounder());
+ final double boxHeight = participantBox.getHeadHeight(ug.getStringBounder());
+ // final double diff = getDiff(ug);
+ double diff = 0;
+ if (arrowHeight > boxHeight) {
+ diff = arrowHeight - boxHeight;
+ }
+ participantBox.drawParticipantHead(ug.apply(new UTranslate(participantBoxStartingX, getStartingY() + diff)));
+ }
+
+ private double getDiff(UGraphic ug) {
+ final double y1 = arrow.getPreferredHeight(ug.getStringBounder());
+ final double y2 = participantBox.getHeadHeight(ug.getStringBounder());
+ final double diff = y1 - y2;
+ return diff;
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return Math.max(arrow.getPreferredHeight(stringBounder), participantBox.getHeadHeight(stringBounder));
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return arrow.getPreferredWidth(stringBounder) + participantBox.getPreferredWidth(stringBounder) / 2;
+ }
+
+ @Override
+ public double getActualWidth(StringBounder stringBounder) {
+ return arrow.getActualWidth(stringBounder) + participantBox.getPreferredWidth(stringBounder) / 2;
+ }
+
+ @Override
+ public double getStartingX(StringBounder stringBounder) {
+ return arrow.getStartingX(stringBounder);
+ }
+
+ public double getMaxX(StringBounder stringBounder) {
+ return arrow.getMaxX(stringBounder);
+ }
+
+ public double getMinX(StringBounder stringBounder) {
+ return arrow.getMinX(stringBounder);
+ }
+
+ public String toString(StringBounder stringBounder) {
+ return arrow.toString(stringBounder);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/Constraint.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/Constraint.java
new file mode 100644
index 0000000..4fa69d7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/Constraint.java
@@ -0,0 +1,78 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+public class Constraint {
+
+ private final Pushable p1;
+ private final Pushable p2;
+ private double value;
+
+ public Constraint(Pushable p1, Pushable p2) {
+ if (p1 == null || p2 == null) {
+ throw new IllegalArgumentException();
+ }
+ this.p1 = p1;
+ this.p2 = p2;
+ }
+
+ public final Pushable getParticipant1() {
+ return p1;
+ }
+
+ public final Pushable getParticipant2() {
+ return p2;
+ }
+
+ public final double getValue() {
+ return value;
+ }
+
+ public final void ensureValue(double newValue) {
+ if (newValue > value) {
+ this.value = newValue;
+ }
+ }
+
+ public void push(double delta) {
+ value += delta;
+ }
+
+ @Override
+ public String toString() {
+ return "Constraint " + p1 + " " + p2 + " " + value;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/ConstraintSet.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/ConstraintSet.java
new file mode 100644
index 0000000..535fcc4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/ConstraintSet.java
@@ -0,0 +1,186 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+
+public class ConstraintSet {
+
+ private final ParticipantBoxSimple firstBorder;
+
+ private final ParticipantBoxSimple lastborder;
+
+ final private List<Pushable> participantList = new ArrayList<Pushable>();
+ final private Map<List<Pushable>, Constraint> constraints = new HashMap<List<Pushable>, Constraint>();
+
+ public ConstraintSet(Collection<? extends Pushable> all, double freeX) {
+ this.participantList.add(firstBorder = new ParticipantBoxSimple(0, "LEFT"));
+ this.participantList.addAll(all);
+ this.participantList.add(lastborder = new ParticipantBoxSimple(freeX, "RIGHT"));
+ }
+
+ @Override
+ public String toString() {
+ return constraints.values().toString();
+ }
+
+ public double getMaxX() {
+ return lastborder.getCenterX(null);
+ }
+
+ public Constraint getConstraint(Pushable p1, Pushable p2) {
+ if (p1 == null || p2 == null || p1 == p2) {
+ throw new IllegalArgumentException();
+ }
+ final int i1 = participantList.indexOf(p1);
+ final int i2 = participantList.indexOf(p2);
+ if (i1 == -1 || i2 == -1) {
+ throw new IllegalArgumentException();
+ }
+ if (i1 > i2) {
+ return getConstraint(p2, p1);
+ }
+ final List<Pushable> key = Arrays.asList(p1, p2);
+ Constraint result = constraints.get(key);
+ if (result == null) {
+ result = new Constraint(p1, p2);
+ constraints.put(key, result);
+ }
+ return result;
+ }
+
+ public Constraint getConstraintAfter(Pushable p1) {
+ if (p1 == null) {
+ throw new IllegalArgumentException();
+ }
+ return getConstraint(p1, getNext(p1));
+ }
+
+ public Constraint getConstraintBefore(Pushable p1) {
+ if (p1 == null) {
+ throw new IllegalArgumentException();
+ }
+ return getConstraint(p1, getPrevious(p1));
+ }
+
+ public Pushable getPrevious(Pushable p) {
+ return getOtherParticipant(p, -1);
+ }
+
+ public Pushable getNext(Pushable p) {
+ return getOtherParticipant(p, 1);
+ }
+
+ private Pushable getOtherParticipant(Pushable p, int delta) {
+ final int i = participantList.indexOf(p);
+ if (i == -1) {
+ throw new IllegalArgumentException();
+ }
+ return participantList.get(i + delta);
+ }
+
+ public void takeConstraintIntoAccount(StringBounder stringBounder) {
+ for (int dist = 1; dist < participantList.size(); dist++) {
+ pushEverybody(stringBounder, dist);
+ }
+ }
+
+ private void pushEverybody(StringBounder stringBounder, int dist) {
+ for (int i = 0; i < participantList.size() - dist; i++) {
+ final Pushable p1 = participantList.get(i);
+ final Pushable p2 = participantList.get(i + dist);
+ final Constraint c = getConstraint(p1, p2);
+ ensureSpaceAfter(stringBounder, p1, p2, c.getValue());
+ }
+ }
+
+ public void pushToLeftParticipantBox(double deltaX, Pushable firstToChange, boolean including) {
+ if (deltaX <= 0) {
+ throw new IllegalArgumentException();
+ }
+ if (firstToChange == null) {
+ throw new IllegalArgumentException();
+ }
+ // freeX += deltaX;
+ boolean founded = false;
+ for (Pushable box : participantList) {
+ if (box.equals(firstToChange)) {
+ founded = true;
+ if (including == false) {
+ continue;
+ }
+ }
+ if (founded) {
+ box.pushToLeft(deltaX);
+ }
+ }
+ }
+
+ public void pushToLeft(double delta) {
+ pushToLeftParticipantBox(delta, firstBorder, true);
+ }
+
+ private void ensureSpaceAfter(StringBounder stringBounder, Pushable p1, Pushable p2, double space) {
+ if (p1.equals(p2)) {
+ throw new IllegalArgumentException();
+ }
+ if (p1.getCenterX(stringBounder) > p2.getCenterX(stringBounder)) {
+ ensureSpaceAfter(stringBounder, p2, p1, space);
+ return;
+ }
+ assert p1.getCenterX(stringBounder) < p2.getCenterX(stringBounder);
+ final double existingSpace = p2.getCenterX(stringBounder) - p1.getCenterX(stringBounder);
+ if (existingSpace < space) {
+ pushToLeftParticipantBox(space - existingSpace, p2, true);
+ }
+
+ }
+
+ public final Pushable getFirstBorder() {
+ return firstBorder;
+ }
+
+ public final Pushable getLastborder() {
+ return lastborder;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSet.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSet.java
new file mode 100644
index 0000000..fc2f0c0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSet.java
@@ -0,0 +1,461 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.awt.geom.Dimension2D;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.SkinParamBackcolored;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.sequencediagram.Event;
+import net.sourceforge.plantuml.sequencediagram.Newpage;
+import net.sourceforge.plantuml.sequencediagram.Participant;
+import net.sourceforge.plantuml.sequencediagram.ParticipantEnglober;
+import net.sourceforge.plantuml.sequencediagram.ParticipantEngloberContexted;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.skin.SimpleContext2D;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.ugraphic.UClip;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class DrawableSet {
+
+ private final Map<Participant, LivingParticipantBox> participants = new LinkedHashMap<Participant, LivingParticipantBox>();
+ private final Map<Event, GraphicalElement> events = new HashMap<Event, GraphicalElement>();
+ private final Map<Participant, ParticipantEnglober> participantEnglobers2 = new LinkedHashMap<Participant, ParticipantEnglober>();
+
+ private final List<Event> eventsList = new ArrayList<Event>();
+ private final Skin skin;
+ private final ISkinParam skinParam;
+ private Dimension2D dimension;
+ private double topStartingY;
+
+ DrawableSet(Skin skin, ISkinParam skinParam) {
+ if (skin == null) {
+ throw new IllegalArgumentException();
+ }
+ if (skinParam == null) {
+ throw new IllegalArgumentException();
+ }
+ this.skin = skin;
+ this.skinParam = skinParam;
+ }
+
+ public ParticipantBox getVeryfirst() {
+ return participants.values().iterator().next().getParticipantBox();
+ }
+
+ public final Skin getSkin() {
+ return skin;
+ }
+
+ public final ISkinParam getSkinParam() {
+ return skinParam;
+ }
+
+ public Collection<Event> getAllEvents() {
+ return Collections.unmodifiableCollection(eventsList);
+ }
+
+ public Set<Participant> getAllParticipants() {
+ return Collections.unmodifiableSet(participants.keySet());
+ }
+
+ public Collection<LivingParticipantBox> getAllLivingParticipantBox() {
+ return Collections.unmodifiableCollection(participants.values());
+ }
+
+ public Collection<GraphicalElement> getAllGraphicalElements() {
+ final Collection<GraphicalElement> result = new ArrayList<GraphicalElement>();
+ for (Event ev : eventsList) {
+ result.add(events.get(ev));
+ }
+ return Collections.unmodifiableCollection(result);
+ }
+
+ public LivingParticipantBox getLivingParticipantBox(Participant p) {
+ return participants.get(p);
+ }
+
+ public GraphicalElement getEvent(Event ev) {
+ return events.get(ev);
+ }
+
+ public double getHeadHeight(StringBounder stringBounder) {
+ double r = 0;
+ for (Participant p : participants.keySet()) {
+ final double y = getHeadAndEngloberHeight(p, stringBounder);
+ r = Math.max(r, y);
+ }
+ return r;
+ }
+
+ public double getHeadAndEngloberHeight(Participant p, StringBounder stringBounder) {
+ final LivingParticipantBox box = participants.get(p);
+ final double height = box.getParticipantBox().getHeadHeight(stringBounder);
+ final ParticipantEngloberContexted englober = getParticipantEnglober(p);
+ if (englober == null) {
+ return height;
+ }
+ final Component comp = skin.createComponent(ComponentType.ENGLOBER, null, skinParam, englober
+ .getParticipantEnglober().getTitle());
+ final double heightEnglober = comp.getPreferredHeight(stringBounder);
+ return height + heightEnglober;
+ }
+
+ public List<ParticipantEngloberContexted> getExistingParticipantEnglober() {
+ final List<ParticipantEngloberContexted> result = new ArrayList<ParticipantEngloberContexted>();
+ ParticipantEngloberContexted pending = null;
+ for (Map.Entry<Participant, ParticipantEnglober> ent : participantEnglobers2.entrySet()) {
+ final ParticipantEnglober englober = ent.getValue();
+ if (englober == null) {
+ pending = null;
+ continue;
+ }
+ assert englober != null;
+ if (pending != null && englober == pending.getParticipantEnglober()) {
+ pending.add(ent.getKey());
+ continue;
+ }
+ pending = new ParticipantEngloberContexted(englober, ent.getKey());
+ result.add(pending);
+ }
+ return Collections.unmodifiableList(result);
+ }
+
+ public double getOffsetForEnglobers(StringBounder stringBounder) {
+ double result = 0;
+ for (ParticipantEngloberContexted englober : getExistingParticipantEnglober()) {
+ final Component comp = skin.createComponent(ComponentType.ENGLOBER, null, skinParam, englober
+ .getParticipantEnglober().getTitle());
+ final double height = comp.getPreferredHeight(stringBounder);
+ if (height > result) {
+ result = height;
+ }
+ }
+ return result;
+ }
+
+ static private final int MARGIN_FOR_ENGLOBERS = 4;
+ static private final int MARGIN_FOR_ENGLOBERS1 = 2;
+
+ public double getTailHeight(StringBounder stringBounder, boolean showTail) {
+ final double marginForEnglobers = getExistingParticipantEnglober().size() > 0 ? MARGIN_FOR_ENGLOBERS : 0;
+
+ if (showTail == false) {
+ return 1 + marginForEnglobers;
+ }
+ double r = 0;
+ for (LivingParticipantBox livingParticipantBox : participants.values()) {
+ final double y = livingParticipantBox.getParticipantBox().getTailHeight(stringBounder);
+ r = Math.max(r, y);
+ }
+ return r + marginForEnglobers;
+ }
+
+ public void addParticipant(Participant p, ParticipantEnglober participantEnglober) {
+ participants.put(p, null);
+ participantEnglobers2.put(p, participantEnglober);
+ }
+
+ public void setLivingParticipantBox(Participant p, LivingParticipantBox box) {
+ if (participants.containsKey(p) == false) {
+ throw new IllegalArgumentException();
+ }
+ participants.put(p, box);
+ }
+
+ public void addEvent(Event event, GraphicalElement object) {
+ if (events.keySet().contains(event) == false) {
+ eventsList.add(event);
+ }
+ events.put(event, object);
+ }
+
+ public void addEvent(Newpage newpage, GraphicalNewpage object, Event justBefore) {
+ final int idx = eventsList.indexOf(justBefore);
+ if (idx == -1) {
+ throw new IllegalArgumentException();
+ }
+ eventsList.add(idx, newpage);
+ events.put(newpage, object);
+ assert events.size() == eventsList.size();
+ }
+
+ void setDimension(Dimension2D dim) {
+ if (dimension != null) {
+ throw new IllegalStateException();
+ }
+ this.dimension = dim;
+ }
+
+ public Dimension2D getDimension() {
+ return dimension;
+ }
+
+ void drawU_REMOVEDME_4243(UGraphic ug, final double delta, double width, Page page, boolean showTail) {
+
+ final UGraphic ugOrig = ug;
+
+ final int height = (int) page.getHeight();
+
+ ug = clipAndTranslate2(delta, width, page, ug);
+ final SimpleContext2D context = new SimpleContext2D(true);
+ this.drawPlaygroundU(ug, context);
+ ug = ugOrig;
+
+ this.drawEnglobers(ug, height - MARGIN_FOR_ENGLOBERS1, context);
+
+ this.drawLineU_REMOVEDME_4243(ug, showTail, page);
+ this.drawHeadTailU(ug, page, showTail ? height - getTailHeight(ug.getStringBounder(), true) : 0);
+
+ ug = clipAndTranslate2(delta, width, page, ug);
+ this.drawPlaygroundU(ug, new SimpleContext2D(false));
+ }
+
+ void drawU22(final UGraphic ug, final double delta, double width, Page page, boolean showTail) {
+ // final UGraphic ugOrig = ug;
+ final double height = page.getHeight();
+
+ final UGraphic ugTranslated = clipAndTranslate2(delta, width, page, ug);
+ final SimpleContext2D context = new SimpleContext2D(true);
+ this.drawPlaygroundU(ugTranslated, context);
+ // ug = ugOrig;
+
+ this.drawEnglobers(ug, height - MARGIN_FOR_ENGLOBERS1, context);
+
+ this.drawLineU22(ug, showTail, page);
+ this.drawHeadTailU(ug, page, showTail ? height - getTailHeight(ug.getStringBounder(), true) : 0);
+
+ // ug = clipAndTranslate2(delta, width, page, ug);
+ this.drawPlaygroundU(ugTranslated, new SimpleContext2D(false));
+ }
+
+ private UGraphic clipAndTranslate2(final double delta, double width, Page p, UGraphic ug) {
+ ug = ug.apply(new UClip(0, p.getBodyRelativePosition(), width, p.getBodyHeight() + 1));
+ if (delta > 0) {
+ ug = ug.apply(new UTranslate(0, -delta));
+ }
+ return ug;
+ }
+
+ private void drawLineU22(UGraphic ug, boolean showTail, Page page) {
+ for (LivingParticipantBox box : getAllLivingParticipantBox()) {
+ final double create = box.getCreate();
+ final double startMin = page.getBodyRelativePosition() - box.magicMargin(ug.getStringBounder());
+ final double endMax = startMin + page.getBodyHeight() + 2 * box.magicMargin(ug.getStringBounder());
+ double start = startMin;
+ if (create > 0) {
+ if (create > page.getNewpage2()) {
+ continue;
+ }
+ if (create >= page.getNewpage1() && create < page.getNewpage2()) {
+ start += create - page.getNewpage1() + 2 * box.magicMargin(ug.getStringBounder());
+ }
+ }
+ final double myDelta = page.getNewpage1() - page.getHeaderHeight();
+ box.drawLineU22(ug, start, endMax, showTail, myDelta);
+ }
+ }
+
+ private void drawLineU_REMOVEDME_4243(UGraphic ug, boolean showTail, Page page) {
+ for (LivingParticipantBox box : getAllLivingParticipantBox()) {
+ final double create = box.getCreate();
+ final double startMin = page.getBodyRelativePosition() - box.magicMargin(ug.getStringBounder());
+ // final double endMax = page.getHeight() - 1;
+ final double endMax = startMin + page.getBodyHeight() + 2 * box.magicMargin(ug.getStringBounder());
+ double start = startMin;
+ if (create > 0) {
+ if (create > page.getNewpage2()) {
+ continue;
+ }
+ if (create >= page.getNewpage1() && create < page.getNewpage2()) {
+ start += create - page.getNewpage1() + 2 * box.magicMargin(ug.getStringBounder());
+ }
+ }
+ final double myDelta = page.getNewpage1() - page.getHeaderHeight();
+ box.drawLineUTOBEREMOVED_4243(ug, start, endMax, showTail, myDelta);
+ }
+ }
+
+ private void drawHeadTailU(UGraphic ug, Page page, double positionTail) {
+ for (Map.Entry<Participant, LivingParticipantBox> ent : participants.entrySet()) {
+ final Participant p = ent.getKey();
+ final LivingParticipantBox box = ent.getValue();
+ final double create = box.getCreate();
+ boolean showHead = true;
+ if (create > 0) {
+ if (create > page.getNewpage2()) {
+ continue;
+ }
+ if (create >= page.getNewpage1() && create < page.getNewpage2()) {
+ showHead = false;
+ }
+ }
+ final Url url = p.getUrl();
+ if (url != null) {
+ ug.startUrl(url);
+ }
+ box.getParticipantBox().drawHeadTailU(ug, topStartingY, showHead, positionTail);
+ if (url != null) {
+ ug.closeAction();
+ }
+ }
+ }
+
+ private double getMaxX() {
+ return dimension.getWidth();
+ }
+
+ private double getMaxY() {
+ return dimension.getHeight();
+ }
+
+ private void drawPlaygroundU(UGraphic ug, Context2D context) {
+ for (Participant p : getAllParticipants()) {
+ drawLifeLineU(ug, p);
+ }
+
+ for (GraphicalElement element : getAllGraphicalElements()) {
+ element.drawU(ug, getMaxX(), context);
+ }
+ }
+
+ private void drawEnglobers(UGraphic ug, double height, Context2D context) {
+ for (ParticipantEngloberContexted englober : getExistingParticipantEnglober()) {
+ double x1 = getX1(englober);
+ final double x2 = getX2(ug.getStringBounder(), englober);
+
+ final Component comp = getEngloberComponent(englober.getParticipantEnglober());
+
+ final double width = x2 - x1;
+ final double preferedWidth = getEngloberPreferedWidth(ug.getStringBounder(),
+ englober.getParticipantEnglober());
+ if (preferedWidth > width) {
+ // if (englober.getFirst2() == englober.getLast2()) {
+ x1 -= (preferedWidth - width) / 2;
+ // }
+ final Dimension2DDouble dim = new Dimension2DDouble(preferedWidth, height);
+ comp.drawU(ug.apply(new UTranslate(x1, 1)), new Area(dim), context);
+ } else {
+ final Dimension2DDouble dim = new Dimension2DDouble(width, height);
+ comp.drawU(ug.apply(new UTranslate(x1, 1)), new Area(dim), context);
+ }
+ }
+ }
+
+ public double getEngloberPreferedWidth(StringBounder stringBounder, ParticipantEnglober englober) {
+ return getEngloberComponent(englober).getPreferredWidth(stringBounder);
+ }
+
+ private Component getEngloberComponent(ParticipantEnglober englober) {
+ final ISkinParam s = englober.getBoxColor() == null ? skinParam : new SkinParamBackcolored(skinParam,
+ englober.getBoxColor());
+ return skin.createComponent(ComponentType.ENGLOBER, null, s, englober.getTitle());
+ }
+
+ public double getX1(ParticipantEngloberContexted englober) {
+ final Participant first = englober.getFirst2();
+ final ParticipantBox firstBox = participants.get(first).getParticipantBox();
+ return firstBox.getStartingX() + 1;
+ }
+
+ public double getX2(StringBounder stringBounder, ParticipantEngloberContexted englober) {
+ final Participant last = englober.getLast2();
+ final ParticipantBox lastBox = participants.get(last).getParticipantBox();
+ return lastBox.getMaxX(stringBounder) - 1;
+ }
+
+ private void drawLifeLineU(UGraphic ug, Participant p) {
+ final LifeLine line = getLivingParticipantBox(p).getLifeLine();
+
+ line.finish(getMaxY());
+ line.drawU(ug, getSkin(), skinParam);
+ }
+
+ private ParticipantEngloberContexted getParticipantEnglober(Participant p) {
+ for (ParticipantEngloberContexted pe : getExistingParticipantEnglober()) {
+ if (pe.contains(p)) {
+ return pe;
+ }
+ }
+ return null;
+ }
+
+ public void setTopStartingY(double topStartingY) {
+ this.topStartingY = topStartingY;
+ }
+
+ Participant getFirst(Collection<Participant> someParticipants) {
+ final List<Participant> list = new ArrayList<Participant>(participants.keySet());
+ int min = -1;
+ for (Participant p : someParticipants) {
+ final int n = list.indexOf(p);
+ assert n != -1;
+ if (min == -1 || min > n) {
+ min = n;
+ }
+ }
+ return list.get(min);
+ }
+
+ Participant getLast(Collection<Participant> someParticipants) {
+ final List<Participant> list = new ArrayList<Participant>(participants.keySet());
+ int max = -1;
+ for (Participant p : someParticipants) {
+ final int n = list.indexOf(p);
+ assert n != -1;
+ if (max == -1 || max < n) {
+ max = n;
+ }
+ }
+ return list.get(max);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java
new file mode 100644
index 0000000..4d9d995
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java
@@ -0,0 +1,613 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.OptionFlags;
+import net.sourceforge.plantuml.SkinParamBackcolored;
+import net.sourceforge.plantuml.SkinParamBackcoloredReference;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.sequencediagram.AbstractMessage;
+import net.sourceforge.plantuml.sequencediagram.Delay;
+import net.sourceforge.plantuml.sequencediagram.Divider;
+import net.sourceforge.plantuml.sequencediagram.Event;
+import net.sourceforge.plantuml.sequencediagram.GroupingLeaf;
+import net.sourceforge.plantuml.sequencediagram.GroupingStart;
+import net.sourceforge.plantuml.sequencediagram.GroupingType;
+import net.sourceforge.plantuml.sequencediagram.HSpace;
+import net.sourceforge.plantuml.sequencediagram.InGroupableList;
+import net.sourceforge.plantuml.sequencediagram.LifeEvent;
+import net.sourceforge.plantuml.sequencediagram.LifeEventType;
+import net.sourceforge.plantuml.sequencediagram.Message;
+import net.sourceforge.plantuml.sequencediagram.MessageExo;
+import net.sourceforge.plantuml.sequencediagram.Newpage;
+import net.sourceforge.plantuml.sequencediagram.Note;
+import net.sourceforge.plantuml.sequencediagram.NoteStyle;
+import net.sourceforge.plantuml.sequencediagram.Notes;
+import net.sourceforge.plantuml.sequencediagram.Participant;
+import net.sourceforge.plantuml.sequencediagram.ParticipantEnglober;
+import net.sourceforge.plantuml.sequencediagram.ParticipantEngloberContexted;
+import net.sourceforge.plantuml.sequencediagram.ParticipantType;
+import net.sourceforge.plantuml.sequencediagram.Reference;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Skin;
+
+class DrawableSetInitializer {
+
+ private ComponentType defaultLineType;
+ private final DrawableSet drawableSet;
+ private final boolean showTail;
+
+ private double freeX = 0;
+ private Frontier freeY2 = null;
+ private Frontier lastFreeY2 = null;
+
+ private final double autonewpage;
+
+ private ConstraintSet constraintSet;
+
+ public DrawableSetInitializer(Skin skin, ISkinParam skinParam, boolean showTail, double autonewpage) {
+ this.drawableSet = new DrawableSet(skin, skinParam);
+ this.showTail = showTail;
+ this.autonewpage = autonewpage;
+
+ }
+
+ private boolean useContinueLineBecauseOfDelay() {
+ final String strategy = drawableSet.getSkinParam().getValue("lifelineStrategy");
+ if ("nosolid".equalsIgnoreCase(strategy)) {
+ return false;
+ }
+ if ("solid".equalsIgnoreCase(strategy)) {
+ return true;
+ }
+ for (Event ev : drawableSet.getAllEvents()) {
+ if (ev instanceof Delay) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private ParticipantRange getFullParticipantRange() {
+ return new ParticipantRange(0, drawableSet.getAllParticipants().size());
+ }
+
+ private ParticipantRange getParticipantRange(Event ev) {
+ return getFullParticipantRange();
+ }
+
+ // private int getParticipantRangeIndex(Participant participant) {
+ // int r = 0;
+ // for (Participant p : drawableSet.getAllParticipants()) {
+ // r++;
+ // if (p == participant) {
+ // return r;
+ // }
+ // }
+ // throw new IllegalArgumentException();
+ // }
+
+ public DrawableSet createDrawableSet(StringBounder stringBounder) {
+ if (freeY2 != null) {
+ throw new IllegalStateException();
+ }
+
+ this.defaultLineType = useContinueLineBecauseOfDelay() ? ComponentType.CONTINUE_LINE
+ : ComponentType.PARTICIPANT_LINE;
+
+ for (Participant p : drawableSet.getAllParticipants()) {
+ prepareParticipant(stringBounder, p);
+ }
+
+ this.freeY2 = new FrontierStackImpl(drawableSet.getHeadHeight(stringBounder), drawableSet.getAllParticipants()
+ .size());
+
+ this.lastFreeY2 = this.freeY2;
+
+ drawableSet.setTopStartingY(this.freeY2.getFreeY(getFullParticipantRange()));
+
+ for (Participant p : drawableSet.getAllParticipants()) {
+ final LivingParticipantBox living = drawableSet.getLivingParticipantBox(p);
+ for (int i = 0; i < p.getInitialLife(); i++) {
+ living.getLifeLine().addSegmentVariation(LifeSegmentVariation.LARGER,
+ freeY2.getFreeY(getFullParticipantRange()), p.getLiveSpecificBackColor());
+ }
+ }
+
+ final List<ParticipantBox> col = new ArrayList<ParticipantBox>();
+ for (LivingParticipantBox livingParticipantBox : drawableSet.getAllLivingParticipantBox()) {
+ col.add(livingParticipantBox.getParticipantBox());
+ }
+
+ constraintSet = new ConstraintSet(col, freeX);
+
+ for (Event ev : new ArrayList<Event>(drawableSet.getAllEvents())) {
+ final ParticipantRange range = getParticipantRange(ev);
+ final double diffY = freeY2.getFreeY(range) - lastFreeY2.getFreeY(range);
+ // final double diffY = freeY2.diff(lastFreeY2);
+ if (autonewpage > 0 && diffY > 0 && diffY + getTotalHeight(0, stringBounder) > autonewpage) {
+ prepareNewpageSpecial(stringBounder, new Newpage(null), ev, range);
+ }
+ if (ev instanceof MessageExo) {
+ prepareMessageExo(stringBounder, (MessageExo) ev, range);
+ } else if (ev instanceof Message) {
+ prepareMessage(stringBounder, (Message) ev, range);
+ } else if (ev instanceof Note) {
+ prepareNote(stringBounder, (Note) ev, range);
+ } else if (ev instanceof Notes) {
+ prepareNotes(stringBounder, (Notes) ev, range);
+ } else if (ev instanceof LifeEvent) {
+ prepareLiveEvent(stringBounder, (LifeEvent) ev, range);
+ } else if (ev instanceof GroupingLeaf) {
+ prepareGroupingLeaf(stringBounder, (GroupingLeaf) ev, range);
+ } else if (ev instanceof GroupingStart) {
+ prepareGroupingStart(stringBounder, (GroupingStart) ev, range);
+ } else if (ev instanceof Newpage) {
+ prepareNewpage(stringBounder, (Newpage) ev, range);
+ } else if (ev instanceof Divider) {
+ prepareDivider(stringBounder, (Divider) ev, range);
+ } else if (ev instanceof HSpace) {
+ prepareHSpace(stringBounder, (HSpace) ev, range);
+ } else if (ev instanceof Delay) {
+ prepareDelay(stringBounder, (Delay) ev, col, range);
+ } else if (ev instanceof Reference) {
+ prepareReference(stringBounder, (Reference) ev, range);
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ constraintSet.takeConstraintIntoAccount(stringBounder);
+ takeParticipantEngloberTitleWidth3(stringBounder);
+
+ prepareMissingSpace(stringBounder);
+
+ drawableSet.setDimension(new Dimension2DDouble(freeX, getTotalHeight(
+ freeY2.getFreeY(getFullParticipantRange()), stringBounder)));
+ return drawableSet;
+ }
+
+ private void takeParticipantEngloberTitleWidth3(StringBounder stringBounder) {
+ for (ParticipantEngloberContexted pe : drawableSet.getExistingParticipantEnglober()) {
+ final double preferredWidth = drawableSet.getEngloberPreferedWidth(stringBounder,
+ pe.getParticipantEnglober());
+ final ParticipantBox first = drawableSet.getLivingParticipantBox(pe.getFirst2()).getParticipantBox();
+ final ParticipantBox last = drawableSet.getLivingParticipantBox(pe.getLast2()).getParticipantBox();
+ final double x1 = drawableSet.getX1(pe);
+ final double x2 = drawableSet.getX2(stringBounder, pe);
+ final double missing = preferredWidth - (x2 - x1);
+ if (missing > 0) {
+ constraintSet.pushToLeftParticipantBox(missing / 2, first, true);
+ constraintSet.pushToLeftParticipantBox(missing / 2, last, false);
+ }
+ }
+ }
+
+ private double getTotalHeight(double y, StringBounder stringBounder) {
+ final double signature = 0;
+ return y + drawableSet.getTailHeight(stringBounder, showTail) + signature;
+ }
+
+ public double getYposition(StringBounder stringBounder, Newpage newpage) {
+ if (newpage == null) {
+ throw new IllegalArgumentException();
+ }
+ final GraphicalNewpage graphicalNewpage = (GraphicalNewpage) drawableSet.getEvent(newpage);
+ return graphicalNewpage.getStartingY();
+ }
+
+ private void prepareMissingSpace(StringBounder stringBounder) {
+ freeX = constraintSet.getMaxX();
+
+ double missingSpace1 = 0;
+ double missingSpace2 = 0;
+
+ for (GraphicalElement ev : drawableSet.getAllGraphicalElements()) {
+ if (ev instanceof GraphicalDelayText) {
+ final double missing = ev.getPreferredWidth(stringBounder) - freeX;
+ if (missing > 0) {
+ missingSpace1 = Math.max(missingSpace1, missing / 2);
+ missingSpace2 = Math.max(missingSpace2, missing / 2);
+ }
+ continue;
+ }
+ final double startX = ev.getStartingX(stringBounder);
+ final double delta1 = -startX;
+ if (delta1 > missingSpace1) {
+ missingSpace1 = delta1;
+ }
+ if (ev instanceof Arrow) {
+ final Arrow a = (Arrow) ev;
+ a.setMaxX(freeX);
+ }
+ double width = ev.getPreferredWidth(stringBounder);
+ if (ev instanceof Arrow) {
+ final Arrow a = (Arrow) ev;
+ if (width < a.getActualWidth(stringBounder)) {
+ width = a.getActualWidth(stringBounder);
+ }
+ }
+ if (ev instanceof GroupingGraphicalElementHeader) {
+ final GroupingGraphicalElementHeader gh = (GroupingGraphicalElementHeader) ev;
+ if (width < gh.getActualWidth(stringBounder)) {
+ width = gh.getActualWidth(stringBounder);
+ }
+ }
+ final double endX = startX + width;
+ final double delta2 = endX - freeX;
+ if (delta2 > missingSpace2) {
+ missingSpace2 = delta2;
+ }
+ }
+
+ if (missingSpace1 > 0) {
+ constraintSet.pushToLeft(missingSpace1);
+ }
+ freeX = constraintSet.getMaxX() + missingSpace2;
+ }
+
+ private void prepareNewpage(StringBounder stringBounder, Newpage newpage, ParticipantRange range) {
+ final GraphicalNewpage graphicalNewpage = new GraphicalNewpage(freeY2.getFreeY(range), drawableSet.getSkin()
+ .createComponent(ComponentType.NEWPAGE, null, drawableSet.getSkinParam(), null));
+ this.lastFreeY2 = freeY2;
+ freeY2 = freeY2.add(graphicalNewpage.getPreferredHeight(stringBounder), range);
+ drawableSet.addEvent(newpage, graphicalNewpage);
+ }
+
+ private void prepareNewpageSpecial(StringBounder stringBounder, Newpage newpage, Event justBefore,
+ ParticipantRange range) {
+ final GraphicalNewpage graphicalNewpage = new GraphicalNewpage(freeY2.getFreeY(range), drawableSet.getSkin()
+ .createComponent(ComponentType.NEWPAGE, null, drawableSet.getSkinParam(), null));
+ this.lastFreeY2 = freeY2;
+ freeY2 = freeY2.add(graphicalNewpage.getPreferredHeight(stringBounder), range);
+ drawableSet.addEvent(newpage, graphicalNewpage, justBefore);
+ }
+
+ private void prepareDivider(StringBounder stringBounder, Divider divider, ParticipantRange range) {
+ final GraphicalDivider graphicalDivider = new GraphicalDivider(freeY2.getFreeY(range), drawableSet.getSkin()
+ .createComponent(ComponentType.DIVIDER, null, drawableSet.getSkinParam(), divider.getText()));
+ freeY2 = freeY2.add(graphicalDivider.getPreferredHeight(stringBounder), range);
+ drawableSet.addEvent(divider, graphicalDivider);
+ }
+
+ private void prepareHSpace(StringBounder stringBounder, HSpace hspace, ParticipantRange range) {
+ final GraphicalHSpace graphicalHSpace = new GraphicalHSpace(freeY2.getFreeY(range), hspace.getPixel());
+ freeY2 = freeY2.add(graphicalHSpace.getPreferredHeight(stringBounder), range);
+ drawableSet.addEvent(hspace, graphicalHSpace);
+ }
+
+ private void prepareDelay(StringBounder stringBounder, Delay delay, List<ParticipantBox> participants,
+ ParticipantRange range) {
+ final Component compText = drawableSet.getSkin().createComponent(ComponentType.DELAY_TEXT, null,
+ drawableSet.getSkinParam(), delay.getText());
+ final ParticipantBox first = participants.get(0);
+ final ParticipantBox last = participants.get(participants.size() - 1);
+ final GraphicalDelayText graphicalDivider = new GraphicalDelayText(freeY2.getFreeY(range), compText, first,
+ last);
+ for (ParticipantBox p : participants) {
+ p.addDelay(graphicalDivider);
+ }
+ freeY2 = freeY2.add(graphicalDivider.getPreferredHeight(stringBounder), range);
+ drawableSet.addEvent(delay, graphicalDivider);
+ }
+
+ final private InGroupablesStack inGroupableStack = new InGroupablesStack();
+
+ private void prepareGroupingStart(StringBounder stringBounder, GroupingStart m, ParticipantRange range) {
+ if (m.getType() != GroupingType.START) {
+ throw new IllegalStateException();
+ }
+ final ISkinParam skinParam = new SkinParamBackcolored(drawableSet.getSkinParam(), m.getBackColorElement(),
+ m.getBackColorGeneral());
+
+ final Component comp = drawableSet.getSkin().createComponent(ComponentType.GROUPING_SPACE, null, skinParam,
+ Display.create(m.getComment()));
+ final double preferredHeight = comp.getPreferredHeight(stringBounder);
+ freeY2 = freeY2.add(preferredHeight, range);
+
+ final Display strings = m.getTitle().equals("group") ? Display.create(m.getComment()) : Display.create(
+ m.getTitle(), m.getComment());
+ final Component header = drawableSet.getSkin().createComponent(ComponentType.GROUPING_HEADER, null, skinParam,
+ strings);
+ final ParticipantBox veryfirst = drawableSet.getVeryfirst();
+ final InGroupableList inGroupableList = new InGroupableList(veryfirst, m, freeY2.getFreeY(range));
+ inGroupableStack.addList(inGroupableList);
+
+ final GraphicalElement element = new GroupingGraphicalElementHeader(freeY2.getFreeY(range), header,
+ inGroupableList, m.isParallel());
+ inGroupableList.setMinWidth(element.getPreferredWidth(stringBounder));
+ freeY2 = freeY2.add(element.getPreferredHeight(stringBounder), range);
+ drawableSet.addEvent(m, element);
+ if (m.isParallel()) {
+ freeY2 = ((FrontierStack) freeY2).openBar();
+ }
+
+ }
+
+ private void prepareGroupingLeaf(StringBounder stringBounder, final GroupingLeaf m, ParticipantRange range) {
+ final GraphicalElement element;
+ final ISkinParam skinParam = new SkinParamBackcolored(drawableSet.getSkinParam(), null, m.getBackColorGeneral());
+ if (m.getType() == GroupingType.ELSE) {
+ if (m.isParallel()) {
+ freeY2 = ((FrontierStack) freeY2).restore();
+ }
+ final Component compElse = drawableSet.getSkin().createComponent(ComponentType.GROUPING_ELSE, null,
+ skinParam, Display.create(m.getComment()));
+ final Lazy lazy = new Lazy() {
+ public double getNow() {
+ final GraphicalElement after = drawableSet.getEvent(m.getJustAfter());
+ if (after == null) {
+ return 0;
+ }
+ return after.getStartingY();
+ }
+ };
+ element = new GroupingGraphicalElementElse(freeY2.getFreeY(range), compElse,
+ inGroupableStack.getTopGroupingStructure(), m.isParallel(), lazy);
+ final double preferredHeight = element.getPreferredHeight(stringBounder);
+ freeY2 = freeY2.add(preferredHeight, range);
+ // MODIF42
+ inGroupableStack.addElement((GroupingGraphicalElementElse) element);
+ } else if (m.getType() == GroupingType.END) {
+ if (m.isParallel()) {
+ freeY2 = ((FrontierStack) freeY2).closeBar();
+ }
+ final GroupingGraphicalElementHeader groupingHeaderStart = (GroupingGraphicalElementHeader) drawableSet
+ .getEvent(m.getGroupingStart());
+ if (groupingHeaderStart != null) {
+ groupingHeaderStart.setEndY(freeY2.getFreeY(range));
+ }
+ element = new GroupingGraphicalElementTail(freeY2.getFreeY(range),
+ inGroupableStack.getTopGroupingStructure(), m.isParallel());
+ final Component comp = drawableSet.getSkin().createComponent(ComponentType.GROUPING_SPACE, null, skinParam,
+ Display.create(m.getComment()));
+ final double preferredHeight = comp.getPreferredHeight(stringBounder);
+ freeY2 = freeY2.add(preferredHeight, range);
+ inGroupableStack.pop();
+ } else {
+ throw new IllegalStateException();
+ }
+ drawableSet.addEvent(m, element);
+
+ }
+
+ private void prepareNote(StringBounder stringBounder, Note n, ParticipantRange range) {
+ final NoteBox noteBox = createNoteBox(stringBounder, n, range);
+ inGroupableStack.addElement(noteBox);
+
+ drawableSet.addEvent(n, noteBox);
+ freeY2 = freeY2.add(noteBox.getPreferredHeight(stringBounder), range);
+ }
+
+ private NoteBox createNoteBox(StringBounder stringBounder, Note n, ParticipantRange range) {
+ LivingParticipantBox p1 = drawableSet.getLivingParticipantBox(n.getParticipant());
+ LivingParticipantBox p2;
+ if (n.getParticipant2() == null) {
+ p2 = null;
+ } else {
+ p2 = drawableSet.getLivingParticipantBox(n.getParticipant2());
+ if (p1.getParticipantBox().getCenterX(stringBounder) > p2.getParticipantBox().getCenterX(stringBounder)) {
+ final LivingParticipantBox tmp = p1;
+ p1 = p2;
+ p2 = tmp;
+ }
+ }
+ final ISkinParam skinParam = n.getSkinParamBackcolored(drawableSet.getSkinParam());
+ final ComponentType type = getNoteComponentType(n.getStyle());
+ final NoteBox noteBox = new NoteBox(freeY2.getFreeY(range), drawableSet.getSkin().createComponent(type, null,
+ skinParam, n.getStrings()), p1, p2, n.getPosition(), n.getUrl());
+ return noteBox;
+ }
+
+ private void prepareNotes(StringBounder stringBounder, Notes notes, ParticipantRange range) {
+ final NotesBoxes notesBoxes = new NotesBoxes(freeY2.getFreeY(range));
+ for (Note n : notes) {
+ final NoteBox noteBox = createNoteBox(stringBounder, n, range);
+ final ParticipantBox p1 = drawableSet.getLivingParticipantBox(n.getParticipant()).getParticipantBox();
+ final ParticipantBox p2 = n.getParticipant2() == null ? null : drawableSet.getLivingParticipantBox(
+ n.getParticipant2()).getParticipantBox();
+ notesBoxes.add(noteBox, p1, p2);
+ }
+ notesBoxes.ensureConstraints(stringBounder, constraintSet);
+ inGroupableStack.addElement(notesBoxes);
+
+ drawableSet.addEvent(notes, notesBoxes);
+ freeY2 = freeY2.add(notesBoxes.getPreferredHeight(stringBounder), range);
+ }
+
+ private ComponentType getNoteComponentType(NoteStyle noteStyle) {
+ if (noteStyle == NoteStyle.HEXAGONAL) {
+ return ComponentType.NOTE_HEXAGONAL;
+ }
+ if (noteStyle == NoteStyle.BOX) {
+ return ComponentType.NOTE_BOX;
+ }
+ return ComponentType.NOTE;
+ }
+
+ private void prepareLiveEvent(StringBounder stringBounder, LifeEvent lifeEvent, ParticipantRange range) {
+ final double y = freeY2.getFreeY(range);
+ final AbstractMessage message = lifeEvent.getMessage();
+ if (lifeEvent.getType() == LifeEventType.ACTIVATE) {
+ double pos = 0;
+ if (message != null) {
+ int delta1 = 0;
+ if (message.isCreate()) {
+ delta1 += 10;
+ } else if (OptionFlags.STRICT_SELFMESSAGE_POSITION && message.isSelfMessage()) {
+ delta1 += 8;
+ }
+ pos = message.getPosYstartLevel() + delta1;
+ }
+ final LifeLine line1 = drawableSet.getLivingParticipantBox(lifeEvent.getParticipant()).getLifeLine();
+ line1.addSegmentVariation(LifeSegmentVariation.LARGER, pos, lifeEvent.getSpecificBackColor());
+ } else if (lifeEvent.getType() == LifeEventType.DESTROY || lifeEvent.getType() == LifeEventType.DEACTIVATE) {
+ double delta = 0;
+ if (OptionFlags.STRICT_SELFMESSAGE_POSITION && message != null && message.isSelfMessage()) {
+ delta += 7;
+ }
+ final Participant p = lifeEvent.getParticipant();
+ final LifeLine line = drawableSet.getLivingParticipantBox(p).getLifeLine();
+ double pos2 = y;
+ if (message != null) {
+ pos2 = message.getPosYendLevel() - delta;
+ }
+ line.addSegmentVariation(LifeSegmentVariation.SMALLER, pos2, lifeEvent.getSpecificBackColor());
+ }
+
+ if (lifeEvent.getType() == LifeEventType.DESTROY) {
+ final Component comp = drawableSet.getSkin().createComponent(ComponentType.DESTROY, null,
+ drawableSet.getSkinParam(), null);
+ final double delta = comp.getPreferredHeight(stringBounder) / 2;
+ final LivingParticipantBox livingParticipantBox = drawableSet.getLivingParticipantBox(lifeEvent
+ .getParticipant());
+ final LifeDestroy destroy = new LifeDestroy(lifeEvent.getMessage().getPosYendLevel() - delta,
+ livingParticipantBox.getParticipantBox(), comp);
+ drawableSet.addEvent(lifeEvent, destroy);
+ } else {
+ drawableSet.addEvent(lifeEvent, new GraphicalElementLiveEvent(y));
+ }
+
+ }
+
+ private void prepareMessageExo(StringBounder stringBounder, MessageExo m, ParticipantRange range) {
+ final Step1MessageExo step1Message = new Step1MessageExo(range, stringBounder, m, drawableSet, freeY2);
+ freeY2 = step1Message.prepareMessage(constraintSet, inGroupableStack);
+ }
+
+ private void prepareMessage(StringBounder stringBounder, Message m, ParticipantRange range) {
+ final Step1Message step1Message = new Step1Message(range, stringBounder, m, drawableSet, freeY2);
+ freeY2 = step1Message.prepareMessage(constraintSet, inGroupableStack);
+ }
+
+ private void prepareReference(StringBounder stringBounder, Reference reference, ParticipantRange range) {
+ final LivingParticipantBox p1 = drawableSet.getLivingParticipantBox(drawableSet.getFirst(reference
+ .getParticipant()));
+ final LivingParticipantBox p2 = drawableSet.getLivingParticipantBox(drawableSet.getLast(reference
+ .getParticipant()));
+ final ISkinParam skinParam = new SkinParamBackcoloredReference(drawableSet.getSkinParam(),
+ reference.getBackColorElement(), reference.getBackColorGeneral());
+
+ Display strings = Display.empty();
+ strings = strings.add("ref");
+ strings = strings.addAll(reference.getStrings());
+ final Component comp = drawableSet.getSkin().createComponent(ComponentType.REFERENCE, null, skinParam, strings);
+ final GraphicalReference graphicalReference = new GraphicalReference(freeY2.getFreeY(range), comp, p1, p2,
+ reference.getUrl());
+
+ final ParticipantBox pbox1 = p1.getParticipantBox();
+ final ParticipantBox pbox2 = p2.getParticipantBox();
+ final double width = graphicalReference.getPreferredWidth(stringBounder)
+ - pbox1.getPreferredWidth(stringBounder) / 2 - pbox2.getPreferredWidth(stringBounder) / 2;
+
+ final Constraint constraint;
+ if (p1 == p2) {
+ constraint = constraintSet.getConstraintAfter(pbox1);
+ } else {
+ constraint = constraintSet.getConstraint(pbox1, pbox2);
+ }
+ constraint.ensureValue(width);
+
+ inGroupableStack.addElement(graphicalReference);
+ inGroupableStack.addElement(p1);
+ if (p1 != p2) {
+ inGroupableStack.addElement(p2);
+ }
+
+ freeY2 = freeY2.add(graphicalReference.getPreferredHeight(stringBounder), range);
+ drawableSet.addEvent(reference, graphicalReference);
+ }
+
+ private void prepareParticipant(StringBounder stringBounder, Participant p) {
+ final ComponentType headType;
+ final ComponentType tailType;
+ if (p.getType() == ParticipantType.PARTICIPANT) {
+ headType = ComponentType.PARTICIPANT_HEAD;
+ tailType = ComponentType.PARTICIPANT_TAIL;
+ } else if (p.getType() == ParticipantType.ACTOR) {
+ headType = ComponentType.ACTOR_HEAD;
+ tailType = ComponentType.ACTOR_TAIL;
+ } else if (p.getType() == ParticipantType.BOUNDARY) {
+ headType = ComponentType.BOUNDARY_HEAD;
+ tailType = ComponentType.BOUNDARY_TAIL;
+ } else if (p.getType() == ParticipantType.CONTROL) {
+ headType = ComponentType.CONTROL_HEAD;
+ tailType = ComponentType.CONTROL_TAIL;
+ } else if (p.getType() == ParticipantType.ENTITY) {
+ headType = ComponentType.ENTITY_HEAD;
+ tailType = ComponentType.ENTITY_TAIL;
+ } else if (p.getType() == ParticipantType.DATABASE) {
+ headType = ComponentType.DATABASE_HEAD;
+ tailType = ComponentType.DATABASE_TAIL;
+ } else {
+ throw new IllegalArgumentException();
+ }
+
+ final ISkinParam skinParam = p.getSkinParamBackcolored(drawableSet.getSkinParam());
+ final Display participantDisplay = p.getDisplay(skinParam.forceSequenceParticipantUnderlined());
+ final Component head = drawableSet.getSkin().createComponent(headType, null, skinParam, participantDisplay);
+ final Component tail = drawableSet.getSkin().createComponent(tailType, null, skinParam, participantDisplay);
+ final Component line = drawableSet.getSkin().createComponent(this.defaultLineType, null,
+ drawableSet.getSkinParam(), participantDisplay);
+ final Component delayLine = drawableSet.getSkin().createComponent(ComponentType.DELAY_LINE, null,
+ drawableSet.getSkinParam(), participantDisplay);
+ final ParticipantBox box = new ParticipantBox(head, line, tail, delayLine, this.freeX);
+
+ final Component comp = drawableSet.getSkin().createComponent(ComponentType.ALIVE_BOX_CLOSE_CLOSE, null,
+ drawableSet.getSkinParam(), null);
+
+ final LifeLine lifeLine = new LifeLine(box, comp.getPreferredWidth(stringBounder), drawableSet.getSkinParam()
+ .shadowing());
+ drawableSet.setLivingParticipantBox(p, new LivingParticipantBox(box, lifeLine));
+
+ this.freeX = box.getMaxX(stringBounder);
+ }
+
+ public void addParticipant(Participant p, ParticipantEnglober participantEnglober) {
+ drawableSet.addParticipant(p, participantEnglober);
+ }
+
+ public void addEvent(Event event) {
+ drawableSet.addEvent(event, null);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/FileMaker.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/FileMaker.java
new file mode 100644
index 0000000..8fb5a18
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/FileMaker.java
@@ -0,0 +1,47 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import net.sourceforge.plantuml.core.ImageData;
+
+public interface FileMaker {
+
+ ImageData createOne(OutputStream os, int index, boolean isWithMetadata) throws IOException;
+
+ public int getNbPages();
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/FreeYStrategy.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/FreeYStrategy.java
new file mode 100644
index 0000000..3a9d38b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/FreeYStrategy.java
@@ -0,0 +1,44 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import net.sourceforge.plantuml.sequencediagram.Event;
+
+interface FreeYStrategy {
+
+ double peekPosition(Event event, ParticipantRange range);
+
+ void addElement(Event event, ParticipantRange range, double height);
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/FreeYStrategyBasic.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/FreeYStrategyBasic.java
new file mode 100644
index 0000000..0d3ceca
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/FreeYStrategyBasic.java
@@ -0,0 +1,48 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import net.sourceforge.plantuml.sequencediagram.Event;
+
+class FreeYStrategyBasic implements FreeYStrategy {
+
+ public double peekPosition(Event event, ParticipantRange range) {
+ return 0;
+ }
+
+ public void addElement(Event event, ParticipantRange range, double height) {
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/Frontier.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/Frontier.java
new file mode 100644
index 0000000..09d1a1e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/Frontier.java
@@ -0,0 +1,43 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+
+interface Frontier {
+
+ double getFreeY(ParticipantRange range);
+
+ Frontier add(double delta, ParticipantRange range);
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/FrontierComplex.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/FrontierComplex.java
new file mode 100644
index 0000000..1602d17
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/FrontierComplex.java
@@ -0,0 +1,106 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.util.Arrays;
+
+class FrontierComplex implements Frontier {
+
+ private final double freeY[];
+
+ public FrontierComplex(double freeY, int rangeEnd) {
+ this.freeY = new double[rangeEnd + 1];
+ for (int i = 0; i <= rangeEnd; i++) {
+ this.freeY[i] = freeY;
+ }
+ }
+
+ private FrontierComplex(double freeY[]) {
+ this.freeY = freeY;
+ }
+
+ private FrontierComplex(double freeY[], double delta, ParticipantRange range) {
+ this(freeY.clone());
+ final double newV = getFreeY(range) + delta;
+ for (int i = range.start(); i <= range.end(); i++) {
+ this.freeY[i] = newV;
+ }
+ }
+
+ public double getFreeY(ParticipantRange range) {
+ if (range == null) {
+ throw new IllegalArgumentException();
+ }
+ double result = freeY[range.start()];
+ for (int i = range.start(); i <= range.end(); i++) {
+ if (freeY[i] > result) {
+ result = freeY[i];
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return Arrays.toString(freeY);
+ }
+
+ public FrontierComplex add(double delta, ParticipantRange range) {
+ if (range == null) {
+ throw new IllegalArgumentException();
+ }
+ return new FrontierComplex(freeY, delta, range);
+ }
+
+ FrontierComplex copy() {
+ return new FrontierComplex(freeY.clone());
+ }
+
+ FrontierComplex mergeMax(FrontierComplex other) {
+ if (this.freeY.length != other.freeY.length) {
+ throw new IllegalArgumentException();
+ }
+ final FrontierComplex result = new FrontierComplex(new double[freeY.length]);
+ for (int i=0; i<freeY.length; i++) {
+ result.freeY[i] = Math.max(this.freeY[i], other.freeY[i]);
+ }
+ return result;
+ }
+
+ // public double diff(Frontier other) {
+ // return freeY - other.freeY;
+ // }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/FrontierSimple.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/FrontierSimple.java
new file mode 100644
index 0000000..03546f9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/FrontierSimple.java
@@ -0,0 +1,60 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+
+class FrontierSimple implements Frontier {
+
+ private final double freeY;
+
+ public FrontierSimple(double freeY) {
+ this.freeY = freeY;
+ }
+
+ public double getFreeY(ParticipantRange range) {
+ if (range == null) {
+ throw new IllegalArgumentException();
+ }
+ return freeY;
+ }
+
+ public FrontierSimple add(double delta, ParticipantRange range) {
+ if (range == null) {
+ throw new IllegalArgumentException();
+ }
+ return new FrontierSimple(freeY + delta);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/FrontierStack.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/FrontierStack.java
new file mode 100644
index 0000000..a58ed13
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/FrontierStack.java
@@ -0,0 +1,44 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+interface FrontierStack extends Frontier {
+
+ FrontierStack openBar();
+
+ FrontierStack restore();
+
+ FrontierStack closeBar();
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/FrontierStackImpl.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/FrontierStackImpl.java
new file mode 100644
index 0000000..ed5e97e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/FrontierStackImpl.java
@@ -0,0 +1,128 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+class FrontierStackImpl implements FrontierStack {
+
+ class Stack {
+ final private FrontierComplex current;
+ final private FrontierComplex envelop;
+
+ Stack(FrontierComplex current) {
+ this(current, null);
+ }
+
+ private Stack(FrontierComplex current, FrontierComplex envelop) {
+ this.current = current;
+ this.envelop = envelop;
+ }
+
+ Stack addEnvelop(FrontierComplex env) {
+ if (this.envelop == null) {
+ return new Stack(this.current, env);
+ }
+ return new Stack(this.current, this.envelop.mergeMax(env));
+ }
+ }
+
+ final private List<Stack> all;
+
+ public FrontierStackImpl(double freeY, int rangeEnd) {
+ final Stack s = new Stack(new FrontierComplex(freeY, rangeEnd));
+ all = Collections.singletonList(s);
+ }
+
+ private FrontierStackImpl(List<Stack> all) {
+ this.all = Collections.unmodifiableList(all);
+ }
+
+ private FrontierComplex getLast() {
+ return all.get(all.size() - 1).current;
+ }
+
+ public double getFreeY(ParticipantRange range) {
+ return getLast().getFreeY(range);
+ }
+
+ public FrontierStackImpl add(double delta, ParticipantRange range) {
+ final List<Stack> result = new ArrayList<Stack>(all);
+ final Stack s = new Stack(getLast().add(delta, range));
+ result.set(result.size() - 1, s);
+ return new FrontierStackImpl(result);
+ }
+
+ public FrontierStack openBar() {
+ final List<Stack> result = new ArrayList<Stack>(all);
+ final Stack s = new Stack(getLast().copy());
+ result.add(s);
+ return new FrontierStackImpl(result);
+ }
+
+ public FrontierStack restore() {
+ final List<Stack> result = new ArrayList<Stack>(all);
+ final Stack openedBar = result.get(result.size() - 2);
+ final Stack lastStack = result.get(result.size() - 1);
+ result.set(result.size() - 2, openedBar.addEnvelop(lastStack.current));
+ result.remove(result.size() - 1);
+ final Stack s = new Stack(openedBar.current.copy());
+ result.add(s);
+ return new FrontierStackImpl(result);
+ }
+
+ public FrontierStack closeBar() {
+ final List<Stack> result = new ArrayList<Stack>(all);
+ final Stack openedBar = result.get(result.size() - 2);
+ final Stack lastStack = result.get(result.size() - 1);
+ final Stack merge = openedBar.addEnvelop(lastStack.current);
+ result.set(result.size() - 2, new Stack(merge.envelop));
+ result.remove(result.size() - 1);
+ return new FrontierStackImpl(result);
+ }
+
+ public FrontierStackImpl copy() {
+ // return new FrontierStackImpl(all);
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String toString() {
+ return "nb=" + all.size() + " " + getLast().toString();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalDelayText.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalDelayText.java
new file mode 100644
index 0000000..1dbd01a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalDelayText.java
@@ -0,0 +1,93 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class GraphicalDelayText extends GraphicalElement {
+
+ private final Component compText;
+
+ private final ParticipantBox p1;
+ private final ParticipantBox p2;
+
+ public GraphicalDelayText(double startingY, Component compText, ParticipantBox first, ParticipantBox last) {
+ super(startingY);
+ this.compText = compText;
+ this.p1 = first;
+ this.p2 = last;
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, double maxX, Context2D context) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final double x1 = p1.getCenterX(stringBounder);
+ final double x2 = p2.getCenterX(stringBounder);
+ final double middle = (x1 + x2) / 2;
+ final double textWidth = compText.getPreferredWidth(stringBounder);
+ ug = ug.apply(new UTranslate(middle - textWidth / 2, getStartingY()));
+ // ug.translate(x1, getStartingY());
+ final Dimension2D dim = new Dimension2DDouble(textWidth, compText.getPreferredHeight(stringBounder));
+ compText.drawU(ug, new Area(dim), context);
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return compText.getPreferredHeight(stringBounder);
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return compText.getPreferredWidth(stringBounder);
+ }
+
+ @Override
+ public double getStartingX(StringBounder stringBounder) {
+ return 0;
+ }
+
+ public double getEndingY(StringBounder stringBounder) {
+ return getStartingY() + compText.getPreferredHeight(stringBounder);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalDivider.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalDivider.java
new file mode 100644
index 0000000..95cee65
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalDivider.java
@@ -0,0 +1,79 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class GraphicalDivider extends GraphicalElement {
+
+ private final Component comp;
+
+ public GraphicalDivider(double startingY, Component comp) {
+ super(startingY);
+ this.comp = comp;
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, double maxX, Context2D context) {
+ ug = ug.apply(new UTranslate(0, getStartingY()));
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D dim = new Dimension2DDouble(maxX, comp.getPreferredHeight(stringBounder));
+ comp.drawU(ug, new Area(dim), context);
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return comp.getPreferredHeight(stringBounder);
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return comp.getPreferredWidth(stringBounder);
+ }
+
+ @Override
+ public double getStartingX(StringBounder stringBounder) {
+ return 0;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalElement.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalElement.java
new file mode 100644
index 0000000..38e6f7f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalElement.java
@@ -0,0 +1,70 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+abstract class GraphicalElement {
+
+ private double startingY;
+
+ GraphicalElement(double startingY) {
+ this.startingY = startingY;
+ }
+
+ void pushToDown(double delta) {
+ startingY += delta;
+ }
+
+ protected final double getStartingY() {
+ return startingY;
+ }
+
+ public final void drawU(UGraphic ug, double maxX, Context2D context) {
+ // bugnewway
+ drawInternalU(ug, maxX, context);
+ }
+
+ protected abstract void drawInternalU(UGraphic ug, double maxX, Context2D context);
+
+ public abstract double getStartingX(StringBounder stringBounder);
+
+ public abstract double getPreferredWidth(StringBounder stringBounder);
+
+ public abstract double getPreferredHeight(StringBounder stringBounder);
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalElementLiveEvent.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalElementLiveEvent.java
new file mode 100644
index 0000000..5062308
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalElementLiveEvent.java
@@ -0,0 +1,62 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class GraphicalElementLiveEvent extends GraphicalElement {
+
+ public GraphicalElementLiveEvent(double startingY) {
+ super(startingY);
+ }
+
+ protected void drawInternalU(UGraphic ug, double maxX, Context2D context) {
+ }
+
+ public double getStartingX(StringBounder stringBounder) {
+ return 0;
+ }
+
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return 0;
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return 0;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalHSpace.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalHSpace.java
new file mode 100644
index 0000000..7648a24
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalHSpace.java
@@ -0,0 +1,69 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+class GraphicalHSpace extends GraphicalElement {
+
+ private final int size;
+
+ public GraphicalHSpace(double startingY, int size) {
+ super(startingY);
+ this.size = size;
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, double maxX, Context2D context) {
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return size;
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return 0;
+ }
+
+ @Override
+ public double getStartingX(StringBounder stringBounder) {
+ return 0;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalNewpage.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalNewpage.java
new file mode 100644
index 0000000..b97c674
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalNewpage.java
@@ -0,0 +1,81 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class GraphicalNewpage extends GraphicalElement {
+
+ private final Component comp;
+
+ public GraphicalNewpage(double startingY, Component comp) {
+ super(startingY);
+ this.comp = comp;
+ }
+
+
+ @Override
+ protected void drawInternalU(UGraphic ug, double maxX, Context2D context) {
+ //final double x = ug.getTranslateX();
+ ug = ug.apply(new UTranslate(0, getStartingY()));
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D dim = new Dimension2DDouble(maxX, comp.getPreferredHeight(stringBounder));
+ comp.drawU(ug, new Area(dim), context);
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return comp.getPreferredHeight(stringBounder);
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return comp.getPreferredWidth(stringBounder);
+ }
+
+ @Override
+ public double getStartingX(StringBounder stringBounder) {
+ return 0;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalReference.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalReference.java
new file mode 100644
index 0000000..86291d4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/GraphicalReference.java
@@ -0,0 +1,117 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.sequencediagram.InGroupable;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class GraphicalReference extends GraphicalElement implements InGroupable {
+
+ private final Component comp;
+ private final LivingParticipantBox livingParticipantBox1;
+ private final LivingParticipantBox livingParticipantBox2;
+ private final Url url;
+
+ public GraphicalReference(double startingY, Component comp, LivingParticipantBox livingParticipantBox1,
+ LivingParticipantBox livingParticipantBox2, Url url) {
+ super(startingY);
+ if (livingParticipantBox1 == null || livingParticipantBox2 == null) {
+ throw new IllegalArgumentException();
+ }
+ this.url = url;
+ this.comp = comp;
+ this.livingParticipantBox1 = livingParticipantBox1;
+ this.livingParticipantBox2 = livingParticipantBox2;
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, double maxX, Context2D context) {
+
+ final StringBounder stringBounder = ug.getStringBounder();
+ final double posX = getMinX(stringBounder);
+
+ ug = ug.apply(new UTranslate(posX, getStartingY()));
+ final double preferredWidth = comp.getPreferredWidth(stringBounder);
+ final double w = getMaxX(stringBounder) - getMinX(stringBounder);
+
+ final double width = Math.max(preferredWidth, w);
+
+ final Dimension2D dim = new Dimension2DDouble(width, comp.getPreferredHeight(stringBounder));
+ if (url != null) {
+ ug.startUrl(url);
+ }
+ comp.drawU(ug, new Area(dim), context);
+ if (url != null) {
+ ug.closeAction();
+ }
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return comp.getPreferredHeight(stringBounder);
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return comp.getPreferredWidth(stringBounder);
+ }
+
+ @Override
+ public double getStartingX(StringBounder stringBounder) {
+ return getMinX(stringBounder);
+ }
+
+ public double getMaxX(StringBounder stringBounder) {
+ return Math.max(livingParticipantBox1.getMaxX(stringBounder), livingParticipantBox2.getMaxX(stringBounder));
+ }
+
+ public double getMinX(StringBounder stringBounder) {
+ return Math.min(livingParticipantBox1.getMinX(stringBounder), livingParticipantBox2.getMinX(stringBounder));
+ }
+
+ public String toString(StringBounder stringBounder) {
+ return toString();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/GroupingGraphicalElement.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/GroupingGraphicalElement.java
new file mode 100644
index 0000000..eeb7a09
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/GroupingGraphicalElement.java
@@ -0,0 +1,66 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.sequencediagram.InGroupableList;
+
+abstract class GroupingGraphicalElement extends GraphicalElement {
+
+ private final InGroupableList inGroupableList;
+
+ public GroupingGraphicalElement(double currentY, InGroupableList inGroupableList) {
+ super(currentY);
+ this.inGroupableList = inGroupableList;
+ if (inGroupableList == null) {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ final public double getActualWidth(StringBounder stringBounder) {
+ return Math.max(getPreferredWidth(stringBounder), inGroupableList.getMaxX(stringBounder)
+ - inGroupableList.getMinX(stringBounder) + 2 * InGroupableList.MARGIN10);
+ }
+
+ @Override
+ final public double getStartingX(StringBounder stringBounder) {
+ return inGroupableList.getMinX(stringBounder) - InGroupableList.MARGIN10;
+ }
+
+ protected final InGroupableList getInGroupableList() {
+ return inGroupableList;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/GroupingGraphicalElementElse.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/GroupingGraphicalElementElse.java
new file mode 100644
index 0000000..8a8531b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/GroupingGraphicalElementElse.java
@@ -0,0 +1,106 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.sequencediagram.InGroupable;
+import net.sourceforge.plantuml.sequencediagram.InGroupableList;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class GroupingGraphicalElementElse extends GroupingGraphicalElement implements InGroupable {
+
+ private final Component compElse;
+ private final Lazy afterY;
+ private final boolean parallel;
+
+ public GroupingGraphicalElementElse(double startingY, Component compElse, InGroupableList inGroupableList,
+ boolean parallel, Lazy afterY) {
+ super(startingY, inGroupableList);
+ this.parallel = parallel;
+ this.compElse = compElse;
+ this.afterY = afterY;
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, double maxX, Context2D context) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final double x1 = getInGroupableList().getMinX(stringBounder);
+ final double x2 = getInGroupableList().getMaxX(stringBounder);
+ ug = ug.apply(new UTranslate(x1, getStartingY()));
+
+ final double height = afterY.getNow() - getStartingY();
+ if (height <= 0) {
+ return;
+ }
+ final Dimension2D dim = new Dimension2DDouble(x2 - x1, height);
+
+ if (parallel == false) {
+ compElse.drawU(ug, new Area(dim), context);
+ }
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ if (parallel) {
+ return 0;
+ }
+ return compElse.getPreferredHeight(stringBounder);
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return compElse.getPreferredWidth(stringBounder);
+ }
+
+ public double getMinX(StringBounder stringBounder) {
+ return getStartingX(stringBounder);
+ }
+
+ public double getMaxX(StringBounder stringBounder) {
+ return getMinX(stringBounder) + getPreferredWidth(stringBounder);
+ }
+
+ public String toString(StringBounder stringBounder) {
+ return toString();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/GroupingGraphicalElementHeader.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/GroupingGraphicalElementHeader.java
new file mode 100644
index 0000000..0b7bac4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/GroupingGraphicalElementHeader.java
@@ -0,0 +1,99 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.sequencediagram.InGroupableList;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class GroupingGraphicalElementHeader extends GroupingGraphicalElement {
+
+ private final Component comp;
+ private double endY;
+ private final boolean isParallel;
+
+ public GroupingGraphicalElementHeader(double currentY, Component comp, InGroupableList inGroupableList, boolean isParallel) {
+ super(currentY, inGroupableList);
+ this.comp = comp;
+ this.isParallel = isParallel;
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + " " + (getInGroupableList() == null ? "no" : getInGroupableList().toString());
+ }
+
+ @Override
+ final public double getPreferredWidth(StringBounder stringBounder) {
+ return comp.getPreferredWidth(stringBounder) + 5;
+ }
+
+ @Override
+ final public double getPreferredHeight(StringBounder stringBounder) {
+ return comp.getPreferredHeight(stringBounder);
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, double maxX, Context2D context) {
+ if (isParallel) {
+ return;
+ }
+ final StringBounder stringBounder = ug.getStringBounder();
+ final double x1 = getInGroupableList().getMinX(stringBounder);
+ final double x2 = getInGroupableList().getMaxX(stringBounder);
+ ug = ug.apply(new UTranslate(x1, getStartingY()));
+ double height = comp.getPreferredHeight(stringBounder);
+ if (endY > 0) {
+ height = endY - getStartingY();
+ } else {
+ // assert false;
+ return;
+ }
+ final Dimension2D dim = new Dimension2DDouble(x2 - x1, height);
+ comp.drawU(ug, new Area(dim), context);
+ }
+
+ public void setEndY(double y) {
+ this.endY = y;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/GroupingGraphicalElementTail.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/GroupingGraphicalElementTail.java
new file mode 100644
index 0000000..017b0ce
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/GroupingGraphicalElementTail.java
@@ -0,0 +1,63 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.sequencediagram.InGroupableList;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+class GroupingGraphicalElementTail extends GroupingGraphicalElement {
+
+ public GroupingGraphicalElementTail(double currentY, InGroupableList inGroupableList, boolean parallel) {
+ super(currentY, inGroupableList);
+ }
+
+ //
+ @Override
+ protected void drawInternalU(UGraphic ug, double maxX, Context2D context) {
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return 0;
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return 0;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/InGroupablesStack.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/InGroupablesStack.java
new file mode 100644
index 0000000..bd34413
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/InGroupablesStack.java
@@ -0,0 +1,73 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.sequencediagram.InGroupable;
+import net.sourceforge.plantuml.sequencediagram.InGroupableList;
+
+class InGroupablesStack {
+
+ final private List<InGroupableList> inGroupableStack = new ArrayList<InGroupableList>();
+
+ public void addList(InGroupableList inGroupableList) {
+ for (InGroupableList other : inGroupableStack) {
+ other.addInGroupable(inGroupableList);
+ }
+ inGroupableStack.add(inGroupableList);
+
+ }
+
+ public void pop() {
+ final int idx = inGroupableStack.size() - 1;
+ inGroupableStack.remove(idx);
+ }
+
+ public void addElement(InGroupable inGroupable) {
+ for (InGroupableList groupingStructure : inGroupableStack) {
+ groupingStructure.addInGroupable(inGroupable);
+ }
+ }
+
+ public InGroupableList getTopGroupingStructure() {
+ if (inGroupableStack.size() == 0) {
+ return null;
+ }
+ return inGroupableStack.get(inGroupableStack.size() - 1);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/Lazy.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/Lazy.java
new file mode 100644
index 0000000..1010887
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/Lazy.java
@@ -0,0 +1,40 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+
+interface Lazy {
+ public double getNow();
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/LifeDestroy.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/LifeDestroy.java
new file mode 100644
index 0000000..166dcbf
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/LifeDestroy.java
@@ -0,0 +1,77 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class LifeDestroy extends GraphicalElement {
+
+ private final ParticipantBox participant;
+
+ private final Component comp;
+
+ public LifeDestroy(double startingY, ParticipantBox participant, Component comp) {
+ super(startingY);
+ this.participant = participant;
+ this.comp = comp;
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, double maxX, Context2D context) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ ug = ug.apply(new UTranslate(getStartingX(stringBounder), getStartingY()));
+ comp.drawU(ug, null, context);
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return comp.getPreferredHeight(stringBounder);
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return comp.getPreferredWidth(stringBounder);
+ }
+
+ @Override
+ public double getStartingX(StringBounder stringBounder) {
+ return participant.getCenterX(stringBounder) - getPreferredWidth(stringBounder) / 2.0;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/LifeLine.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/LifeLine.java
new file mode 100644
index 0000000..3401aa4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/LifeLine.java
@@ -0,0 +1,242 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.SkinParamBackcolored;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class LifeLine {
+
+ static class Variation {
+ final private LifeSegmentVariation type;
+ final private HtmlColor backcolor;
+ final private double y;
+
+ Variation(LifeSegmentVariation type, double y, HtmlColor backcolor) {
+ this.type = type;
+ this.y = y;
+ this.backcolor = backcolor;
+ }
+
+ @Override
+ public String toString() {
+ return type + " " + y;
+ }
+ }
+
+ private final Pushable participant;
+ private final double nominalPreferredWidth;
+
+ private final List<Variation> events = new ArrayList<Variation>();
+ private final Stairs stairs = new Stairs();
+ private int maxLevel = 0;
+ private final boolean shadowing;
+
+ public LifeLine(Pushable participant, double nominalPreferredWidth, boolean shadowing) {
+ this.participant = participant;
+ this.nominalPreferredWidth = nominalPreferredWidth;
+ this.shadowing = shadowing;
+ }
+
+ public void addSegmentVariation(LifeSegmentVariation type, double y, HtmlColor backcolor) {
+ if (events.size() > 0) {
+ final Variation last = events.get(events.size() - 1);
+ if (y < last.y) {
+ return;
+ // throw new IllegalArgumentException();
+ }
+ if (y == last.y && type != last.type) {
+ return;
+ // throw new IllegalArgumentException();
+ }
+ }
+ events.add(new Variation(type, y, backcolor));
+ final int currentLevel = type.apply(stairs.getLastValue());
+ stairs.addStep(y, currentLevel);
+ assert getLevel(y) == stairs.getValue(y);
+ assert currentLevel == stairs.getValue(y);
+ assert getLevel(y) == currentLevel;
+ maxLevel = Math.max(getLevel(y), maxLevel);
+ }
+
+ public void finish(double y) {
+ final int missingClose = getMissingClose();
+ for (int i = 0; i < missingClose; i++) {
+ addSegmentVariation(LifeSegmentVariation.SMALLER, y, null);
+ }
+ }
+
+ int getMissingClose() {
+ int level = 0;
+ for (Variation ev : events) {
+ if (ev.type == LifeSegmentVariation.LARGER) {
+ level++;
+ } else {
+ level--;
+ }
+ }
+ return level;
+ }
+
+ int getLevel(double y) {
+ return stairs.getValue(y);
+ }
+
+ public int getMaxLevel() {
+ return maxLevel;
+ }
+
+ public double getRightShift(double y) {
+ return getRightShiftAtLevel(getLevel(y));
+ }
+
+ public double getLeftShift(double y) {
+ return getLeftShiftAtLevel(getLevel(y));
+ }
+
+ public double getMaxRightShift() {
+ return getRightShiftAtLevel(getMaxLevel());
+ }
+
+ public double getMaxLeftShift() {
+ return getLeftShiftAtLevel(getMaxLevel());
+ }
+
+ private double getRightShiftAtLevel(int level) {
+ if (level == 0) {
+ return 0;
+ }
+ return level * (nominalPreferredWidth / 2.0);
+ }
+
+ private double getLeftShiftAtLevel(int level) {
+ if (level == 0) {
+ return 0;
+ }
+ return nominalPreferredWidth / 2.0;
+ }
+
+ private double getStartingX(StringBounder stringBounder) {
+ final double delta = participant.getCenterX(stringBounder) - nominalPreferredWidth / 2.0;
+ return delta;
+ }
+
+ private SegmentColored getSegment(int i) {
+ if (events.get(i).type != LifeSegmentVariation.LARGER) {
+ return null;
+ }
+ int level = 1;
+ for (int j = i + 1; j < events.size(); j++) {
+ if (events.get(j).type == LifeSegmentVariation.LARGER) {
+ level++;
+ } else {
+ level--;
+ }
+ if (level == 0) {
+ final double y1 = events.get(i).y;
+ final double y2 = events.get(j).y;
+ return new SegmentColored(y1, y2, events.get(i).backcolor, shadowing);
+ }
+ }
+ return new SegmentColored(events.get(i).y, events.get(events.size() - 1).y, events.get(i).backcolor, shadowing);
+ }
+
+ private Collection<SegmentColored> getSegmentsCutted(StringBounder stringBounder, int i) {
+ final SegmentColored seg = getSegment(i);
+ if (seg != null) {
+ return seg.cutSegmentIfNeed(participant.getDelays(stringBounder));
+ }
+ return Collections.emptyList();
+ }
+
+ public void drawU(UGraphic ug, Skin skin, ISkinParam skinParam) {
+ final StringBounder stringBounder = ug.getStringBounder();
+
+ ug = ug.apply(new UTranslate(getStartingX(stringBounder), 0));
+
+ for (int i = 0; i < events.size(); i++) {
+ ComponentType type = ComponentType.ALIVE_BOX_CLOSE_OPEN;
+ for (final Iterator<SegmentColored> it = getSegmentsCutted(stringBounder, i).iterator(); it.hasNext();) {
+ final SegmentColored seg = it.next();
+ final ISkinParam skinParam2 = new SkinParamBackcolored(skinParam, seg.getSpecificBackColor());
+ if (it.hasNext() == false) {
+ type = type == ComponentType.ALIVE_BOX_CLOSE_OPEN ? ComponentType.ALIVE_BOX_CLOSE_CLOSE
+ : ComponentType.ALIVE_BOX_OPEN_CLOSE;
+ }
+ final Component compAliveBox = skin.createComponent(type, null, skinParam2, null);
+ type = ComponentType.ALIVE_BOX_OPEN_OPEN;
+ final int currentLevel = getLevel(seg.getPos1Initial());
+ seg.drawU(ug, compAliveBox, currentLevel);
+ }
+ }
+ }
+
+ private double create = 0;
+
+ // private double destroy = 0;
+
+ public final void setCreate(double create) {
+ this.create = create;
+ }
+
+ public final double getCreate() {
+ return create;
+ }
+
+ public final double getDestroy() {
+ return 0;
+ }
+
+ // public final void setDestroy(double destroy) {
+ // this.destroy = destroy;
+ // }
+
+ public final boolean shadowing() {
+ return shadowing;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/LifeSegmentVariation.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/LifeSegmentVariation.java
new file mode 100644
index 0000000..aaa9ce6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/LifeSegmentVariation.java
@@ -0,0 +1,51 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+public enum LifeSegmentVariation {
+ LARGER, SMALLER;
+
+ public int apply(int v) {
+ if (this == LARGER) {
+ return v + 1;
+ }
+ assert this == SMALLER;
+ if (v == 0) {
+ return 0;
+ }
+ return v - 1;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/LivingParticipantBox.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/LivingParticipantBox.java
new file mode 100644
index 0000000..322f116
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/LivingParticipantBox.java
@@ -0,0 +1,122 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.sequencediagram.InGroupable;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class LivingParticipantBox implements InGroupable {
+
+ private final ParticipantBox participantBox;
+ private final LifeLine lifeLine;
+
+ public LivingParticipantBox(ParticipantBox participantBox, LifeLine lifeLine) {
+ this.participantBox = participantBox;
+ this.lifeLine = lifeLine;
+ }
+
+ /**
+ * @deprecated a virer
+ */
+ public ParticipantBox getParticipantBox() {
+ return participantBox;
+ }
+
+ /**
+ * @deprecated a virer
+ */
+ public LifeLine getLifeLine() {
+ return lifeLine;
+ }
+
+ public SegmentColored getLiveThicknessAt(StringBounder stringBounder, double y) {
+ final double left = lifeLine.getLeftShift(y);
+ assert left >= 0;
+ final double right = lifeLine.getRightShift(y);
+ assert right >= 0 : "right=" + right;
+ final double centerX = participantBox.getCenterX(stringBounder);
+ // Log.println("AZERTY " + y + " centerX=" + centerX + " left=" + left + " right=" + right);
+ // Log.println("Attention, null for segment");
+ return new SegmentColored(centerX - left, centerX + right, null, lifeLine.shadowing());
+ }
+
+ public void drawLineUTOBEREMOVED_4243(UGraphic ug, double startingY, double endingY, boolean showTail, double myDelta) {
+ if (endingY <= startingY) {
+ return;
+ }
+ final double destroy = lifeLine.getDestroy();
+ if (destroy != 0 && destroy > startingY && destroy < endingY) {
+ endingY = destroy;
+ }
+ participantBox.drawLineUTOBEREMOVED_4243(ug, startingY, endingY, showTail, myDelta);
+ }
+
+ public void drawLineU22(UGraphic ug, double startingY, double endingY, boolean showTail, double myDelta) {
+ if (endingY <= startingY) {
+ return;
+ }
+ final double destroy = lifeLine.getDestroy();
+ if (destroy != 0 && destroy > startingY && destroy < endingY) {
+ endingY = destroy;
+ }
+ participantBox.drawLineU22(ug, startingY, endingY, showTail, myDelta);
+ }
+
+ public double magicMargin(StringBounder stringBounder) {
+ return participantBox.magicMargin(stringBounder);
+ }
+
+ public void create(double ypos) {
+ lifeLine.setCreate(ypos);
+ }
+
+ public double getCreate() {
+ return lifeLine.getCreate();
+ }
+
+ public double getMaxX(StringBounder stringBounder) {
+ return participantBox.getMaxX(stringBounder);
+ }
+
+ public double getMinX(StringBounder stringBounder) {
+ return participantBox.getStartingX();
+ }
+
+ public String toString(StringBounder stringBounder) {
+ return toString();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/MessageArrow.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/MessageArrow.java
new file mode 100644
index 0000000..73a9774
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/MessageArrow.java
@@ -0,0 +1,190 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.ArrowComponent;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class MessageArrow extends Arrow {
+
+ private final LivingParticipantBox p1;
+ private final LivingParticipantBox p2;
+ private final Component compAliveBox;
+
+ public MessageArrow(double startingY, Skin skin, Component arrow, LivingParticipantBox p1, LivingParticipantBox p2,
+ Url url, Component compAliveBox) {
+ super(startingY, skin, arrow, url);
+
+ if (p1 == p2) {
+ throw new IllegalArgumentException();
+ }
+ if (p1 == null || p2 == null) {
+ throw new IllegalArgumentException();
+ }
+ this.p1 = p1;
+ this.p2 = p2;
+ this.compAliveBox = compAliveBox;
+ }
+
+ @Override
+ public double getActualWidth(StringBounder stringBounder) {
+ final double r = getRightEndInternal(stringBounder) - getLeftStartInternal(stringBounder);
+ assert r > 0;
+ return r;
+ }
+
+ private double getLeftStartInternal(StringBounder stringBounder) {
+ return getParticipantAt(stringBounder, NotePosition.LEFT)
+ .getLiveThicknessAt(stringBounder, getArrowYStartLevel(stringBounder)).getSegment().getPos2();
+ }
+
+ private double getRightEndInternalOld(StringBounder stringBounder) {
+ return getParticipantAt(stringBounder, NotePosition.RIGHT).getLiveThicknessAt(stringBounder,
+ getArrowYStartLevel(stringBounder)).getSegment().getPos1();
+ }
+
+
+ private double getRightEndInternal(StringBounder stringBounder) {
+ final Segment segment = getParticipantAt(stringBounder, NotePosition.RIGHT).getLiveThicknessAt(stringBounder,
+ getArrowYStartLevel(stringBounder)).getSegment();
+ if (segment.getLength() == 0) {
+ return segment.getPos1();
+ }
+ final double rectWidth = compAliveBox.getPreferredWidth(stringBounder);
+ return segment.getPos2() - rectWidth;
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return getArrowComponent().getPreferredHeight(stringBounder);
+ }
+
+ @Override
+ public double getStartingX(StringBounder stringBounder) {
+ return getLeftStartInternal(stringBounder);
+ }
+
+ @Override
+ public int getDirection(StringBounder stringBounder) {
+ final double x1 = p1.getParticipantBox().getCenterX(stringBounder);
+ final double x2 = p2.getParticipantBox().getCenterX(stringBounder);
+ if (x1 < x2) {
+ return 1;
+ }
+ return -1;
+ }
+
+ public LivingParticipantBox getParticipantAt(StringBounder stringBounder, NotePosition position) {
+ final int direction = getDirection(stringBounder);
+ if (direction == 1 && position == NotePosition.RIGHT) {
+ return p2;
+ }
+ if (direction == 1 && position == NotePosition.LEFT) {
+ return p1;
+ }
+ if (direction == -1 && position == NotePosition.RIGHT) {
+ return p1;
+ }
+ if (direction == -1 && position == NotePosition.LEFT) {
+ return p2;
+ }
+ throw new IllegalArgumentException();
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return getArrowComponent().getPreferredWidth(stringBounder);
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, double maxX, Context2D context) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ ug = ug.apply(new UTranslate(getStartingX(stringBounder), getStartingY()));
+ startUrl(ug);
+ getArrowComponent().drawU(ug, new Area(getActualDimension(stringBounder)), context);
+ endUrl(ug);
+ }
+
+ private Dimension2D getActualDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(getActualWidth(stringBounder) - getPaddingArrowHead(), getArrowComponent()
+ .getPreferredHeight(stringBounder));
+ }
+
+ @Override
+ public double getArrowYStartLevel(StringBounder stringBounder) {
+ if (getArrowComponent() instanceof ArrowComponent) {
+ final ArrowComponent arrowComponent = (ArrowComponent) getArrowComponent();
+ final Dimension2D dim = new Dimension2DDouble(arrowComponent.getPreferredWidth(stringBounder),
+ arrowComponent.getPreferredHeight(stringBounder));
+ return getStartingY() + arrowComponent.getStartPoint(stringBounder, dim).getY();
+ }
+ return getStartingY();
+ }
+
+ @Override
+ public double getArrowYEndLevel(StringBounder stringBounder) {
+ if (getArrowComponent() instanceof ArrowComponent) {
+ final ArrowComponent arrowComponent = (ArrowComponent) getArrowComponent();
+ final Dimension2D dim = new Dimension2DDouble(arrowComponent.getPreferredWidth(stringBounder),
+ arrowComponent.getPreferredHeight(stringBounder));
+ return getStartingY() + arrowComponent.getEndPoint(stringBounder, dim).getY();
+ }
+ return getStartingY() + getArrowComponent().getPreferredHeight(stringBounder);
+ }
+
+ public double getMaxX(StringBounder stringBounder) {
+ return getRightEndInternal(stringBounder);
+ }
+
+ public double getMinX(StringBounder stringBounder) {
+ return getLeftStartInternal(stringBounder);
+ }
+
+ public String toString(StringBounder stringBounder) {
+ return getMinX(stringBounder) + "-" + getMaxX(stringBounder);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/MessageExoArrow.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/MessageExoArrow.java
new file mode 100644
index 0000000..18d500f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/MessageExoArrow.java
@@ -0,0 +1,210 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.sequencediagram.MessageExoType;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.ArrowComponent;
+import net.sourceforge.plantuml.skin.ArrowConfiguration;
+import net.sourceforge.plantuml.skin.ArrowDecoration;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.skin.rose.ComponentRoseArrow;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class MessageExoArrow extends Arrow {
+
+ private final LivingParticipantBox p;
+ private final MessageExoType type;
+ private final boolean shortArrow;
+ private final ArrowConfiguration arrowConfiguration;
+
+ public MessageExoArrow(double startingY, Skin skin, Component arrow, LivingParticipantBox p, MessageExoType type,
+ Url url, boolean shortArrow, ArrowConfiguration arrowConfiguration) {
+ super(startingY, skin, arrow, url);
+ this.p = p;
+ this.type = type;
+ this.shortArrow = shortArrow;
+ this.arrowConfiguration = arrowConfiguration;
+ }
+
+ double getActualWidth(StringBounder stringBounder, double maxX) {
+ final double r = getRightEndInternal(stringBounder, maxX) - getLeftStartInternal(stringBounder);
+ assert r > 0;
+ return r;
+ }
+
+ private double getLeftStartInternal(StringBounder stringBounder) {
+ if (type == MessageExoType.FROM_LEFT || type == MessageExoType.TO_LEFT) {
+ if (shortArrow) {
+ return p.getLiveThicknessAt(stringBounder, getArrowYStartLevel(stringBounder)).getSegment().getPos2()
+ - getPreferredWidth(stringBounder);
+ } else {
+ if (arrowConfiguration.getDecoration1() == ArrowDecoration.CIRCLE && type == MessageExoType.FROM_LEFT) {
+ return ComponentRoseArrow.diamCircle;
+ }
+ if (arrowConfiguration.getDecoration2() == ArrowDecoration.CIRCLE && type == MessageExoType.TO_LEFT) {
+ return ComponentRoseArrow.diamCircle;
+ }
+ return 0;
+ }
+ }
+ return p.getLiveThicknessAt(stringBounder, getArrowYStartLevel(stringBounder)).getSegment().getPos2();
+ }
+
+ private double getRightEndInternal(StringBounder stringBounder, double maxX) {
+ if (type == MessageExoType.FROM_LEFT || type == MessageExoType.TO_LEFT) {
+ return p.getLiveThicknessAt(stringBounder, getArrowYStartLevel(stringBounder)).getSegment().getPos1();
+ }
+ if (shortArrow) {
+ return getLeftStartInternal(stringBounder) + getPreferredWidth(stringBounder);
+ }
+ double result = Math.max(maxX, getLeftStartInternal(stringBounder) + getPreferredWidth(stringBounder));
+ if (arrowConfiguration.getDecoration2() == ArrowDecoration.CIRCLE && type == MessageExoType.TO_RIGHT) {
+ result -= ComponentRoseArrow.diamCircle;
+ }
+ if (arrowConfiguration.getDecoration1() == ArrowDecoration.CIRCLE && type == MessageExoType.FROM_RIGHT) {
+ result -= ComponentRoseArrow.diamCircle;
+ }
+ return result;
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return getArrowComponent().getPreferredHeight(stringBounder);
+ }
+
+ @Override
+ public double getStartingX(StringBounder stringBounder) {
+ return getLeftStartInternal(stringBounder);
+ }
+
+ @Override
+ public int getDirection(StringBounder stringBounder) {
+ return type.getDirection();
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ double result = getArrowComponent().getPreferredWidth(stringBounder);
+ if (arrowConfiguration.getDecoration2() == ArrowDecoration.CIRCLE && type == MessageExoType.TO_RIGHT) {
+ result += ComponentRoseArrow.diamCircle;
+ }
+ if (arrowConfiguration.getDecoration1() == ArrowDecoration.CIRCLE && type == MessageExoType.FROM_RIGHT) {
+ result += ComponentRoseArrow.diamCircle;
+ }
+ if (arrowConfiguration.getDecoration1() == ArrowDecoration.CIRCLE && type == MessageExoType.FROM_LEFT) {
+ result += ComponentRoseArrow.diamCircle;
+ }
+ if (arrowConfiguration.getDecoration2() == ArrowDecoration.CIRCLE && type == MessageExoType.TO_LEFT) {
+ result += ComponentRoseArrow.diamCircle;
+ }
+
+ return result;
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, double maxX, Context2D context) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final double x1 = getStartingX(stringBounder);
+ final double x2 = maxX;
+ ug = ug.apply(new UTranslate(x1, getStartingY()));
+ startUrl(ug);
+ getArrowComponent().drawU(ug, new Area(getActualDimension(stringBounder, x2)), context);
+ endUrl(ug);
+ }
+
+ private Dimension2D getActualDimension(StringBounder stringBounder, double maxX) {
+ return new Dimension2DDouble(getActualWidth(stringBounder, maxX), getArrowComponent().getPreferredHeight(
+ stringBounder));
+ }
+
+ @Override
+ public double getArrowYStartLevel(StringBounder stringBounder) {
+ if (getArrowComponent() instanceof ArrowComponent) {
+ final ArrowComponent arrowComponent = (ArrowComponent) getArrowComponent();
+ final Dimension2D dim = new Dimension2DDouble(arrowComponent.getPreferredWidth(stringBounder),
+ arrowComponent.getPreferredHeight(stringBounder));
+ return getStartingY() + arrowComponent.getStartPoint(stringBounder, dim).getY();
+ }
+ return getStartingY();
+ }
+
+ @Override
+ public double getArrowYEndLevel(StringBounder stringBounder) {
+ if (getArrowComponent() instanceof ArrowComponent) {
+ final ArrowComponent arrowComponent = (ArrowComponent) getArrowComponent();
+ final Dimension2D dim = new Dimension2DDouble(arrowComponent.getPreferredWidth(stringBounder),
+ arrowComponent.getPreferredHeight(stringBounder));
+ return getStartingY() + arrowComponent.getEndPoint(stringBounder, dim).getY();
+ }
+ return getStartingY() + getArrowComponent().getPreferredHeight(stringBounder);
+ }
+
+ public double getMaxX(StringBounder stringBounder) {
+ return getRightEndInternal(stringBounder, 0);
+ }
+
+ public double getMinX(StringBounder stringBounder) {
+ return getLeftStartInternal(stringBounder);
+ }
+
+ public String toString(StringBounder stringBounder) {
+ return getMinX(stringBounder) + "-" + getMaxX(stringBounder);
+ }
+
+ public final MessageExoType getType() {
+ return type;
+ }
+
+ @Override
+ public LivingParticipantBox getParticipantAt(StringBounder stringBounder, NotePosition position) {
+ return p;
+ }
+
+ @Override
+ public double getActualWidth(StringBounder stringBounder) {
+ return getActualWidth(stringBounder, getMaxX());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/MessageSelfArrow.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/MessageSelfArrow.java
new file mode 100644
index 0000000..6b92ece
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/MessageSelfArrow.java
@@ -0,0 +1,147 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.ArrowComponent;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class MessageSelfArrow extends Arrow {
+
+ private final LivingParticipantBox p1;
+ private final double deltaX;
+ private final double deltaY;
+
+ public MessageSelfArrow(double startingY, Skin skin, Component arrow, LivingParticipantBox p1, double deltaY,
+ Url url, double deltaX) {
+ super(startingY, skin, arrow, url);
+ this.p1 = p1;
+ this.deltaY = deltaY;
+ this.deltaX = deltaX;
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return getArrowComponent().getPreferredHeight(stringBounder);
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return getArrowComponent().getPreferredWidth(stringBounder);
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, double maxX, Context2D context) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ ug = ug.apply(new UTranslate(getStartingX(stringBounder), getStartingY() + deltaY));
+ final Area area = new Area(new Dimension2DDouble(getPreferredWidth(stringBounder),
+ getPreferredHeight(stringBounder)));
+ area.setDeltaX1(deltaY);
+ startUrl(ug);
+ getArrowComponent().drawU(ug, area, context);
+ endUrl(ug);
+ }
+
+ @Override
+ public double getStartingX(StringBounder stringBounder) {
+ // if (OptionFlags.STRICT_SELFMESSAGE_POSITION) {
+ // final double pos1 = p1.getLiveThicknessAt(stringBounder, getArrowYEndLevel(stringBounder)).getSegment()
+ // .getPos2();
+ // return pos1;
+ // }
+ final double pos2 = p1.getLiveThicknessAt(stringBounder, getArrowYStartLevel(stringBounder)).getSegment()
+ .getPos2();
+ return pos2 + deltaX;
+ }
+
+ @Override
+ public int getDirection(StringBounder stringBounder) {
+ return 1;
+ }
+
+ @Override
+ public double getArrowYStartLevel(StringBounder stringBounder) {
+ if (getArrowComponent() instanceof ArrowComponent) {
+ final ArrowComponent arrowComponent = (ArrowComponent) getArrowComponent();
+ final Dimension2D dim = new Dimension2DDouble(arrowComponent.getPreferredWidth(stringBounder),
+ arrowComponent.getPreferredHeight(stringBounder));
+ return getStartingY() + arrowComponent.getStartPoint(stringBounder, dim).getY();
+ }
+ return getStartingY();
+ }
+
+ @Override
+ public double getArrowYEndLevel(StringBounder stringBounder) {
+ if (getArrowComponent() instanceof ArrowComponent) {
+ final ArrowComponent arrowComponent = (ArrowComponent) getArrowComponent();
+ final Dimension2D dim = new Dimension2DDouble(arrowComponent.getPreferredWidth(stringBounder),
+ arrowComponent.getPreferredHeight(stringBounder));
+ return getStartingY() + arrowComponent.getEndPoint(stringBounder, dim).getY();
+ }
+ return getStartingY() + getArrowComponent().getPreferredHeight(stringBounder);
+ }
+
+ public double getMaxX(StringBounder stringBounder) {
+ return getStartingX(stringBounder) + getPreferredWidth(stringBounder);
+ }
+
+ public double getMinX(StringBounder stringBounder) {
+ return getStartingX(stringBounder);
+ }
+
+ public String toString(StringBounder stringBounder) {
+ return super.toString();
+ }
+
+ @Override
+ public LivingParticipantBox getParticipantAt(StringBounder stringBounder, NotePosition position) {
+ return p1;
+ }
+
+ @Override
+ public double getActualWidth(StringBounder stringBounder) {
+ return getPreferredWidth(stringBounder);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/NoteBox.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/NoteBox.java
new file mode 100644
index 0000000..ca08c3d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/NoteBox.java
@@ -0,0 +1,160 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.sequencediagram.InGroupable;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+final class NoteBox extends GraphicalElement implements InGroupable {
+
+ private final NotePosition position;
+ private final Url url;
+
+ private final LivingParticipantBox p1;
+ private final LivingParticipantBox p2;
+
+ private final Component comp;
+
+ private double delta = 0;
+
+ public NoteBox(double startingY, Component comp, LivingParticipantBox p1, LivingParticipantBox p2,
+ NotePosition position, Url url) {
+ super(startingY);
+ if (p1 == null) {
+ throw new IllegalArgumentException();
+ }
+ if (p2 != null ^ position == NotePosition.OVER_SEVERAL) {
+ throw new IllegalArgumentException();
+ }
+ this.p1 = p1;
+ this.p2 = p2;
+ this.position = position;
+ this.url = url;
+ this.comp = comp;
+ }
+
+ @Override
+ final public double getPreferredWidth(StringBounder stringBounder) {
+ final double preferredWidth = comp.getPreferredWidth(stringBounder);
+ if (position == NotePosition.OVER_SEVERAL) {
+ assert p1 != p2;
+ final double diff1 = p2.getParticipantBox().getMaxX(stringBounder) - p1.getParticipantBox().getMinX();
+ if (diff1 > preferredWidth) {
+ return diff1;
+ }
+
+ }
+ return preferredWidth;
+ }
+
+ @Override
+ final public double getPreferredHeight(StringBounder stringBounder) {
+ return comp.getPreferredHeight(stringBounder);
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, double maxX, Context2D context) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final double xStart = getStartingX(stringBounder);
+ ug = ug.apply(new UTranslate(xStart, getStartingY()));
+ final Dimension2D dimensionToUse = new Dimension2DDouble(getPreferredWidth(stringBounder), comp
+ .getPreferredHeight(stringBounder));
+ if (url != null) {
+ ug.startUrl(url);
+ }
+ comp.drawU(ug, new Area(dimensionToUse), context);
+ if (url != null) {
+ ug.closeAction();
+ }
+ }
+
+ @Override
+ public double getStartingX(StringBounder stringBounder) {
+ final SegmentColored segment = getSegment(stringBounder);
+ final int xStart;
+ if (position == NotePosition.LEFT) {
+ xStart = (int) (segment.getSegment().getPos1() - getPreferredWidth(stringBounder));
+ } else if (position == NotePosition.RIGHT) {
+ xStart = (int) (segment.getSegment().getPos2());
+ } else if (position == NotePosition.OVER) {
+ xStart = (int) (p1.getParticipantBox().getCenterX(stringBounder) - getPreferredWidth(stringBounder) / 2);
+ } else if (position == NotePosition.OVER_SEVERAL) {
+ final double centre = (p1.getParticipantBox().getCenterX(stringBounder) + p2.getParticipantBox()
+ .getCenterX(stringBounder)) / 2.0;
+ xStart = (int) (centre - getPreferredWidth(stringBounder) / 2.0);
+ } else {
+ throw new IllegalStateException();
+ }
+ return xStart + delta;
+ }
+
+ private SegmentColored getSegment(StringBounder stringBounder) {
+ final SegmentColored segment = p1.getLiveThicknessAt(stringBounder, getStartingY());
+ final SegmentColored segment2 = p1.getLiveThicknessAt(stringBounder, getStartingY()
+ + comp.getPreferredHeight(stringBounder));
+ return segment.merge(segment2);
+ }
+
+ public void pushToRight(double x) {
+ this.delta += x;
+ }
+
+ public double getMaxX(StringBounder stringBounder) {
+ return getStartingX(stringBounder) + getPreferredWidth(stringBounder);
+ }
+
+ public double getMinX(StringBounder stringBounder) {
+ return getStartingX(stringBounder);
+ }
+
+ public String toString(StringBounder stringBounder) {
+ return toString();
+ }
+
+ public final Url getUrl() {
+ return url;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/NotesBoxes.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/NotesBoxes.java
new file mode 100644
index 0000000..1800e36
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/NotesBoxes.java
@@ -0,0 +1,149 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.sequencediagram.InGroupable;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+final class NotesBoxes extends GraphicalElement implements InGroupable {
+
+ private final List<NoteBox> notes = new ArrayList<NoteBox>();
+ private final List<ParticipantBox> participants1 = new ArrayList<ParticipantBox>();
+ private final List<ParticipantBox> participants2 = new ArrayList<ParticipantBox>();
+
+ NotesBoxes(double startingY) {
+ super(startingY);
+ }
+
+ public void add(NoteBox noteBox, ParticipantBox participantBox1, ParticipantBox participantBox2) {
+ notes.add(noteBox);
+ participants1.add(participantBox1);
+ if (participantBox2 == null) {
+ participants2.add(participantBox1);
+ } else {
+ participants2.add(participantBox2);
+ }
+ }
+
+ public void ensureConstraints(StringBounder stringBounder, ConstraintSet constraintSet) {
+ for (int i = 0; i < notes.size(); i++) {
+ final NoteBox noteBox = notes.get(i);
+ final ParticipantBox participantBox1 = participants1.get(i);
+ final ParticipantBox participantBox2 = participants2.get(i);
+ final double width = noteBox.getPreferredWidth(stringBounder);
+ // System.err.println("i=" + i);
+ // System.err.println("width=" + width);
+ // System.err.println("participantBox1=" + participantBox1);
+ // System.err.println("participantBox2=" + participantBox2);
+ constraintSet.getConstraintBefore(participantBox1).ensureValue(width / 2);
+ constraintSet.getConstraintAfter(participantBox2).ensureValue(width / 2);
+ for (int j = i + 1; j < notes.size(); j++) {
+ final NoteBox noteBox2 = notes.get(j);
+ final ParticipantBox otherParticipantBox1 = participants1.get(j);
+ final double width2 = noteBox2.getPreferredWidth(stringBounder);
+ constraintSet.getConstraint(participantBox2, otherParticipantBox1).ensureValue((width + width2) / 2);
+ }
+ }
+ }
+
+ public double getMinX(StringBounder stringBounder) {
+ double result = Double.MAX_VALUE;
+ for (NoteBox n : notes) {
+ final double m = n.getMinX(stringBounder);
+ if (m < result) {
+ result = m;
+ }
+ }
+ return result;
+ }
+
+ public double getMaxX(StringBounder stringBounder) {
+ double result = -Double.MAX_VALUE;
+ for (NoteBox n : notes) {
+ final double m = n.getMaxX(stringBounder);
+ if (m > result) {
+ result = m;
+ }
+ }
+ return result;
+ }
+
+ public String toString(StringBounder stringBounder) {
+ return toString();
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, double maxX, Context2D context) {
+ for (NoteBox n : notes) {
+ n.drawInternalU(ug, maxX, context);
+ }
+ }
+
+ @Override
+ public double getStartingX(StringBounder stringBounder) {
+ double result = Double.MAX_VALUE;
+ for (NoteBox n : notes) {
+ final double m = n.getStartingX(stringBounder);
+ if (m < result) {
+ result = m;
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ final double result = getMaxX(stringBounder) - getMinX(stringBounder);
+ return result;
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ double result = 0;
+ for (NoteBox n : notes) {
+ final double m = n.getPreferredHeight(stringBounder);
+ if (m > result) {
+ result = m;
+ }
+ }
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/Page.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/Page.java
new file mode 100644
index 0000000..dcaba0a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/Page.java
@@ -0,0 +1,122 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import net.sourceforge.plantuml.cucadiagram.Display;
+
+public final class Page {
+
+ private final double headerHeight;
+ private final double newpage1;
+ private final double newpage2;
+ private final double tailHeight;
+ private final double signatureHeight;
+ private final Display title;
+
+ @Override
+ public String toString() {
+ return "headerHeight=" + headerHeight + " newpage1=" + newpage1 + " newpage2=" + newpage2;
+ }
+
+ public Page(double headerHeight, double newpage1, double newpage2, double tailHeight,
+ double signatureHeight, Display title) {
+ if (headerHeight < 0) {
+ throw new IllegalArgumentException();
+ }
+ if (tailHeight < 0) {
+ throw new IllegalArgumentException();
+ }
+ if (signatureHeight < 0) {
+ throw new IllegalArgumentException();
+ }
+ if (newpage1 > newpage2) {
+ throw new IllegalArgumentException();
+ }
+ this.headerHeight = headerHeight;
+ this.newpage1 = newpage1;
+ this.newpage2 = newpage2;
+ this.tailHeight = tailHeight;
+ this.signatureHeight = signatureHeight;
+ this.title = title;
+ }
+
+ public double getHeight() {
+ return headerHeight + getBodyHeight() + tailHeight + signatureHeight;
+ }
+
+ public double getHeaderRelativePosition() {
+ return 0;
+ }
+
+ public double getBodyRelativePosition() {
+ return getHeaderRelativePosition() + headerHeight;
+ }
+
+ public double getBodyHeight() {
+ return newpage2 - newpage1;
+ }
+
+ public double getTailRelativePosition() {
+ return getBodyRelativePosition() + getBodyHeight();
+ }
+
+ public double getSignatureRelativePosition() {
+ if (displaySignature() == false) {
+ return -1;
+ }
+ return getTailRelativePosition() + tailHeight;
+ }
+
+ public boolean displaySignature() {
+ return signatureHeight > 0;
+ }
+
+ public double getNewpage1() {
+ return newpage1;
+ }
+
+ public double getNewpage2() {
+ return newpage2;
+ }
+
+ public double getHeaderHeight() {
+ return headerHeight;
+ }
+
+ public final Display getTitle() {
+ return title;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/PageSplitter.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/PageSplitter.java
new file mode 100644
index 0000000..83488e3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/PageSplitter.java
@@ -0,0 +1,116 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.sequencediagram.Newpage;
+
+class PageSplitter {
+
+ private final double fullHeight;
+ private final List<Double> positions;
+ private final List<Display> titles;
+ private final double headerHeight;
+ private final double tailHeight;
+ private final double signatureHeight;
+ private final double newpageHeight;
+ private final Display diagramTitle;
+
+ PageSplitter(double fullHeight, double headerHeight, Map<Newpage, Double> newpages, double tailHeight,
+ double signatureHeight, double newpageHeight, Display diagramTitle) {
+ this.fullHeight = fullHeight;
+ this.diagramTitle = diagramTitle;
+ this.titles = new ArrayList<Display>();
+ this.positions = new ArrayList<Double>();
+
+ for (Map.Entry<Newpage, Double> ent : newpages.entrySet()) {
+ titles.add(ent.getKey().getTitle());
+ positions.add(ent.getValue());
+ }
+
+ this.headerHeight = headerHeight;
+ this.tailHeight = tailHeight;
+ this.signatureHeight = signatureHeight;
+ this.newpageHeight = newpageHeight;
+ }
+
+ public List<Page> getPages() {
+
+ if (positions.size() == 0) {
+ return Arrays.asList(onePage());
+ }
+ final List<Page> result = new ArrayList<Page>();
+
+ result.add(firstPage());
+ for (int i = 0; i < positions.size() - 1; i++) {
+ result.add(createPage(i));
+ }
+ result.add(lastPage());
+
+ return result;
+ }
+
+ private Page lastPage() {
+ final double newpage1 = positions.get(positions.size() - 1) - this.newpageHeight;
+ final double newpage2 = this.fullHeight - this.tailHeight - this.signatureHeight;
+ final Display title = titles.get(positions.size() - 1);
+ return new Page(headerHeight, newpage1, newpage2, tailHeight, signatureHeight, title);
+ }
+
+ private Page firstPage() {
+ final double newpage1 = this.headerHeight;
+ final double newpage2 = positions.get(0) + this.newpageHeight;
+ return new Page(headerHeight, newpage1, newpage2, tailHeight, 0, diagramTitle);
+ }
+
+ private Page onePage() {
+ final double newpage1 = this.headerHeight;
+ final double newpage2 = this.fullHeight - this.tailHeight - this.signatureHeight;
+ return new Page(headerHeight, newpage1, newpage2, tailHeight, signatureHeight, diagramTitle);
+ }
+
+ private Page createPage(int i) {
+ final double newpage1 = positions.get(i) - this.newpageHeight;
+ final double newpage2 = positions.get(i + 1) + this.newpageHeight;
+ final Display title = titles.get(i);
+ return new Page(headerHeight, newpage1, newpage2, tailHeight, 0, title);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantBox.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantBox.java
new file mode 100644
index 0000000..3fa95f2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantBox.java
@@ -0,0 +1,255 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.util.AbstractCollection;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.SimpleContext2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ParticipantBox implements Pushable {
+
+ private static int CPT = 0;
+
+ private final int outMargin = 5;
+
+ private double startingX;
+
+ private final Component head;
+ private final Component line;
+ private final Component tail;
+ private final Component delayLine;
+
+ private int cpt = CPT++;
+
+ public ParticipantBox(Component head, Component line, Component tail, Component delayLine, double startingX) {
+ this.startingX = startingX;
+ this.head = head;
+ this.line = line;
+ this.tail = tail;
+ this.delayLine = delayLine;
+ }
+
+ @Override
+ public String toString() {
+ return "PB" + cpt;
+ }
+
+ public double getMinX() {
+ return startingX + outMargin;
+ }
+
+ public double getMaxX(StringBounder stringBounder) {
+ return startingX + head.getPreferredWidth(stringBounder) + 2 * outMargin;
+ }
+
+ public double getCenterX(StringBounder stringBounder) {
+ return startingX + head.getPreferredWidth(stringBounder) / 2.0 + outMargin;
+ }
+
+ public double getHeadHeight(StringBounder stringBounder) {
+ return head.getPreferredHeight(stringBounder) + line.getPreferredHeight(stringBounder) / 2.0;
+ }
+
+ public double getHeadHeightOnly(StringBounder stringBounder) {
+ return head.getPreferredHeight(stringBounder);
+ }
+
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return head.getPreferredWidth(stringBounder);
+ }
+
+ public double getTailHeight(StringBounder stringBounder) {
+ return tail.getPreferredHeight(stringBounder) + line.getPreferredHeight(stringBounder) / 2.0;
+ }
+
+ public void pushToLeft(double deltaX) {
+ startingX += deltaX;
+ }
+
+ public void drawHeadTailU(UGraphic ug, double topStartingY, boolean showHead, double positionTail) {
+ if (topStartingY == 0) {
+ throw new IllegalStateException("setTopStartingY cannot be zero");
+ }
+
+ // final double atX = ug.getTranslateX();
+ // final double atY = ug.getTranslateY();
+ final StringBounder stringBounder = ug.getStringBounder();
+
+ if (showHead) {
+ final double y1 = topStartingY - head.getPreferredHeight(stringBounder)
+ - line.getPreferredHeight(stringBounder) / 2;
+ head.drawU(
+ ug.apply(new UTranslate(getMinX(), y1)),
+ new Area(new Dimension2DDouble(head.getPreferredWidth(stringBounder), head
+ .getPreferredHeight(stringBounder))), new SimpleContext2D(false));
+ // ug.setTranslate(atX, atY);
+ }
+
+ if (positionTail > 0) {
+ // final double y2 = positionTail - topStartingY +
+ // line.getPreferredHeight(stringBounder) / 2 - 1;
+ positionTail += line.getPreferredHeight(stringBounder) / 2 - 1;
+ // if (y2 != y22) {
+ // throw new IllegalStateException();
+ // }
+ ug = ug.apply(new UTranslate(getMinX(), positionTail));
+ tail.drawU(
+ ug,
+ new Area(new Dimension2DDouble(tail.getPreferredWidth(stringBounder), tail
+ .getPreferredHeight(stringBounder))), new SimpleContext2D(false));
+ // ug.setTranslate(atX, atY);
+ }
+ }
+
+ public void drawParticipantHead(UGraphic ug) {
+ // ug.translate(outMargin, 0);
+ final StringBounder stringBounder = ug.getStringBounder();
+ head.drawU(
+ ug.apply(new UTranslate(outMargin, 0)),
+ new Area(new Dimension2DDouble(head.getPreferredWidth(stringBounder), head
+ .getPreferredHeight(stringBounder))), new SimpleContext2D(false));
+ // ug.translate(-outMargin, 0);
+ }
+
+ public void drawLineUTOBEREMOVED_4243(UGraphic ug, double startingY, double endingY, boolean showTail, double myDelta) {
+ throw new UnsupportedOperationException();
+// ug = ug.apply(new UTranslate(startingX, 0));
+// if (delays.size() > 0) {
+// final StringBounder stringBounder = ug.getStringBounder();
+// for (GraphicalDelayText delay : delays) {
+// if (delay.getStartingY() - myDelta >= startingY) {
+// drawLine(ug, startingY, delay.getStartingY() - myDelta, line);
+// drawLine(ug, delay.getStartingY() - myDelta, delay.getEndingY(stringBounder) - myDelta, delayLine);
+// startingY = delay.getEndingY(stringBounder) - myDelta;
+// }
+// }
+// if (delays.get(delays.size() - 1).getEndingY(stringBounder) - myDelta > startingY) {
+// startingY = delays.get(delays.size() - 1).getEndingY(stringBounder) - myDelta;
+// }
+// }
+// drawLine(ug, startingY, endingY, line);
+ }
+
+ public void drawLineU22(UGraphic ug, double startingY, final double endingY, boolean showTail, double myDelta) {
+ ug = ug.apply(new UTranslate(startingX, 0));
+ if (delays.size() > 0) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ for (GraphicalDelayText delay : delays) {
+ if (delay.getStartingY() - myDelta >= startingY) {
+ drawLineIfLowerThan(ug, startingY, delay.getStartingY() - myDelta, line, endingY);
+ drawLineIfLowerThan(ug, delay.getStartingY() - myDelta, delay.getEndingY(stringBounder) - myDelta,
+ delayLine, endingY);
+ startingY = delay.getEndingY(stringBounder) - myDelta;
+ }
+ }
+ if (delays.get(delays.size() - 1).getEndingY(stringBounder) - myDelta > startingY) {
+ startingY = delays.get(delays.size() - 1).getEndingY(stringBounder) - myDelta;
+ }
+ }
+ drawLineIfLowerThan(ug, startingY, endingY, line, endingY);
+ }
+
+ private void drawLineIfLowerThan(UGraphic ug, double startingY, double endingY, Component comp, double limitY) {
+ startingY = Math.min(startingY, limitY);
+ endingY = Math.min(endingY, limitY);
+ if (startingY < limitY || endingY < limitY) {
+ drawLine(ug, startingY, endingY, comp);
+ }
+
+ }
+
+ private void drawLine(UGraphic ug, double startingY, double endingY, Component comp) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ comp.drawU(ug.apply(new UTranslate(0, startingY)),
+ new Area(new Dimension2DDouble(head.getPreferredWidth(stringBounder) + outMargin * 2, endingY
+ - startingY)), new SimpleContext2D(false));
+ }
+
+ public double magicMargin(StringBounder stringBounder) {
+ return line.getPreferredHeight(stringBounder) / 2;
+ }
+
+ public double getStartingX() {
+ return startingX;
+ }
+
+ private final List<GraphicalDelayText> delays = new ArrayList<GraphicalDelayText>();
+
+ public void addDelay(GraphicalDelayText delay) {
+ this.delays.add(delay);
+ }
+
+ public Collection<Segment> getDelays(final StringBounder stringBounder) {
+ return new AbstractCollection<Segment>() {
+
+ @Override
+ public Iterator<Segment> iterator() {
+ return new Iterator<Segment>() {
+
+ private final Iterator<GraphicalDelayText> it = delays.iterator();
+
+ public boolean hasNext() {
+ return it.hasNext();
+ }
+
+ public Segment next() {
+ final GraphicalDelayText d = it.next();
+ return new Segment(d.getStartingY(), d.getEndingY(stringBounder));
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ };
+ }
+
+ @Override
+ public int size() {
+ return delays.size();
+ }
+ };
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantBoxSimple.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantBoxSimple.java
new file mode 100644
index 0000000..c16f259
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantBoxSimple.java
@@ -0,0 +1,78 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.util.Collection;
+import java.util.Collections;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+
+public class ParticipantBoxSimple implements Pushable {
+
+ private double pos = 0;
+ private final String name;
+
+ public ParticipantBoxSimple(double pos) {
+ this(pos, null);
+ }
+
+ public ParticipantBoxSimple(double pos, String name) {
+ this.pos = pos;
+ this.name = name;
+ }
+
+ @Override
+ public String toString() {
+ return name == null ? super.toString() : name;
+ }
+
+ public double getCenterX(StringBounder stringBounder) {
+ return pos;
+ }
+
+ public void pushToLeft(double deltaX) {
+ pos += deltaX;
+ }
+
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return 0;
+ }
+
+ public Collection<Segment> getDelays(StringBounder stringBounder) {
+ return Collections.emptyList();
+ }
+
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantRange.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantRange.java
new file mode 100644
index 0000000..e76233d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantRange.java
@@ -0,0 +1,62 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+class ParticipantRange {
+
+ private final int start;
+ private final int end;
+
+ public ParticipantRange(int start, int end) {
+ if (start > end) {
+ throw new IllegalArgumentException();
+ }
+ this.start = start;
+ this.end = end;
+ }
+
+ public int start() {
+ return start;
+ }
+
+ public int end() {
+ return end;
+ }
+
+ public ParticipantRange merge(ParticipantRange other) {
+ return new ParticipantRange(this.start, other.end);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/Pushable.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/Pushable.java
new file mode 100644
index 0000000..e2fbff3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/Pushable.java
@@ -0,0 +1,52 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.util.Collection;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+
+public interface Pushable {
+
+ double getPreferredWidth(StringBounder stringBounder);
+
+ double getCenterX(StringBounder stringBounder);
+
+ void pushToLeft(double deltaX);
+
+ public Collection<Segment> getDelays(StringBounder stringBounder);
+
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/Segment.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/Segment.java
new file mode 100644
index 0000000..27ec32d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/Segment.java
@@ -0,0 +1,125 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+public class Segment {
+
+ final private double pos1;
+ final private double pos2;
+
+ Segment(double pos1, double pos2) {
+ this.pos1 = pos1;
+ this.pos2 = pos2;
+ if (pos2 < pos1) {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ final Segment this2 = (Segment) obj;
+ return pos1 == this2.pos1 && pos2 == this2.pos2;
+ }
+
+ @Override
+ public int hashCode() {
+ return new Double(pos1).hashCode() + new Double(pos2).hashCode();
+ }
+
+ final public boolean contains(double y) {
+ return y >= pos1 && y <= pos2;
+ }
+
+ final public boolean contains(Segment other) {
+ return contains(other.pos1) && contains(other.pos2);
+ }
+
+ @Override
+ public String toString() {
+ return "" + pos1 + " - " + pos2;
+ }
+
+ final public double getLength() {
+ return pos2 - pos1;
+ }
+
+ final public double getPos1() {
+ return pos1;
+ }
+
+ final public double getPos2() {
+ return pos2;
+ }
+
+ public Segment merge(Segment this2) {
+ return new Segment(Math.min(this.pos1, this2.pos1), Math.max(this.pos2, this2.pos2));
+ }
+
+ public Collection<Segment> cutSegmentIfNeed(Collection<Segment> allDelays) {
+ final List<Segment> sortedDelay = new ArrayList<Segment>(allDelays);
+ Collections.sort(sortedDelay, new SortPos1());
+ final List<Segment> result2 = new ArrayList<Segment>();
+ double pendingStart = pos1;
+ for (Segment d : sortedDelay) {
+ if (d.pos1 <= pendingStart) {
+ continue;
+ }
+ if (d.pos1 > this.pos2) {
+ result2.add(new Segment(pendingStart, this.pos2));
+ return Collections.unmodifiableCollection(result2);
+ }
+ if (this.contains(d) == false) {
+ throw new IllegalStateException();
+ }
+ result2.add(new Segment(pendingStart, d.pos1));
+ pendingStart = d.pos2;
+ }
+ result2.add(new Segment(pendingStart, this.pos2));
+ return Collections.unmodifiableCollection(result2);
+ }
+
+ static class SortPos1 implements Comparator<Segment> {
+ public int compare(Segment segA, Segment segB) {
+ return (int) Math.signum(segA.pos1 - segB.pos1);
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/SegmentColored.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/SegmentColored.java
new file mode 100644
index 0000000..341aad9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/SegmentColored.java
@@ -0,0 +1,159 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.awt.geom.Dimension2D;
+import java.util.AbstractCollection;
+import java.util.Collection;
+import java.util.Iterator;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.SimpleContext2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class SegmentColored {
+
+ final private Segment segment;
+ final private HtmlColor backcolor;
+ final private boolean shadowing;
+ final private double pos1Initial;
+
+ SegmentColored(double pos1, double pos2, HtmlColor backcolor, boolean shadowing) {
+ this(new Segment(pos1, pos2), backcolor, shadowing, pos1);
+ }
+
+ private SegmentColored(Segment segment, HtmlColor backcolor, boolean shadowing, double pos1Initial) {
+ this.segment = segment;
+ this.backcolor = backcolor;
+ this.shadowing = shadowing;
+ this.pos1Initial = pos1Initial;
+ }
+
+ public HtmlColor getSpecificBackColor() {
+ return backcolor;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ final SegmentColored this2 = (SegmentColored) obj;
+ return this.segment.equals(this2.segment);
+ }
+
+ @Override
+ public int hashCode() {
+ return this.segment.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return this.segment.toString();
+ }
+
+ public void drawU(UGraphic ug, Component compAliveBox, int level) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ ug = ug.apply(new UTranslate((level - 1) * compAliveBox.getPreferredWidth(stringBounder) / 2, segment.getPos1()));
+ final Dimension2D dim = new Dimension2DDouble(compAliveBox.getPreferredWidth(stringBounder), segment.getPos2()
+ - segment.getPos1());
+ compAliveBox.drawU(ug, new Area(dim), new SimpleContext2D(false));
+ }
+
+ public Collection<SegmentColored> cutSegmentIfNeed(Collection<Segment> allDelays) {
+ return new Coll2(segment.cutSegmentIfNeed(allDelays), segment.getPos1());
+ }
+
+ public double getPos1Initial() {
+ return pos1Initial;
+ }
+
+ public SegmentColored merge(SegmentColored this2) {
+ final Segment merge = this.segment.merge(this2.segment);
+ return new SegmentColored(merge, backcolor, shadowing, merge.getPos1());
+ }
+
+ public final Segment getSegment() {
+ return segment;
+ }
+
+ class Iterator2 implements Iterator<SegmentColored> {
+
+ private final Iterator<Segment> it;
+ private final double pos1Initial;
+
+ public Iterator2(Iterator<Segment> it, double pos1Initial) {
+ this.it = it;
+ this.pos1Initial = pos1Initial;
+ }
+
+ public boolean hasNext() {
+ return it.hasNext();
+ }
+
+ public SegmentColored next() {
+ return new SegmentColored(it.next(), backcolor, shadowing, pos1Initial);
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ class Coll2 extends AbstractCollection<SegmentColored> {
+
+ private final Collection<Segment> col;
+ private final double pos1Initial;
+
+ public Coll2(Collection<Segment> col, double pos1Initial) {
+ this.col = col;
+ this.pos1Initial = pos1Initial;
+ }
+
+ @Override
+ public Iterator<SegmentColored> iterator() {
+ return new Iterator2(col.iterator(), pos1Initial);
+ }
+
+ @Override
+ public int size() {
+ return col.size();
+ }
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramArea.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramArea.java
new file mode 100644
index 0000000..abcc008
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramArea.java
@@ -0,0 +1,145 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+
+public class SequenceDiagramArea {
+
+ private final double sequenceWidth;
+ private final double sequenceHeight;
+
+ private double headerWidth;
+ private double headerHeight;
+ private double headerMargin;
+
+ private double titleWidth;
+ private double titleHeight;
+
+ private double footerWidth;
+ private double footerHeight;
+ private double footerMargin;
+
+ public SequenceDiagramArea(double width, double height) {
+ this.sequenceWidth = width;
+ this.sequenceHeight = height;
+ }
+
+ public void setTitleArea(double titleWidth, double titleHeight) {
+ this.titleWidth = titleWidth;
+ this.titleHeight = titleHeight;
+ }
+
+ public void setHeaderArea(double headerWidth, double headerHeight, double headerMargin) {
+ this.headerWidth = headerWidth;
+ this.headerHeight = headerHeight;
+ this.headerMargin = headerMargin;
+ }
+
+ public void setFooterArea(double footerWidth, double footerHeight, double footerMargin) {
+ this.footerWidth = footerWidth;
+ this.footerHeight = footerHeight;
+ this.footerMargin = footerMargin;
+ }
+
+ public double getWidth() {
+ double result = sequenceWidth;
+ if (headerWidth > result) {
+ result = headerWidth;
+ }
+ if (titleWidth > result) {
+ result = titleWidth;
+ }
+ if (footerWidth > result) {
+ result = footerWidth;
+ }
+ return result;
+ }
+
+ public double getHeight() {
+ return sequenceHeight + headerHeight + headerMargin + titleHeight + footerMargin + footerHeight;
+ }
+
+ public double getTitleX() {
+ return (getWidth() - titleWidth) / 2;
+ }
+
+ public double getTitleY() {
+ return headerHeight + headerMargin;
+ }
+
+ public double getSequenceAreaX() {
+ return (getWidth() - sequenceWidth) / 2;
+ }
+
+ public double getSequenceAreaY() {
+ return getTitleY() + titleHeight;
+ }
+
+ public double getHeaderY() {
+ return 0;
+ }
+
+ public double getFooterY() {
+ return sequenceHeight + headerHeight + headerMargin + titleHeight + footerMargin;
+ }
+
+ public double getFooterX(HorizontalAlignment align) {
+ if (align == HorizontalAlignment.LEFT) {
+ return 0;
+ }
+ if (align == HorizontalAlignment.RIGHT) {
+ return getWidth() - footerWidth;
+ }
+ if (align == HorizontalAlignment.CENTER) {
+ return (getWidth() - footerWidth) / 2;
+ }
+ throw new IllegalStateException();
+ }
+
+ public double getHeaderX(HorizontalAlignment align) {
+ if (align == HorizontalAlignment.LEFT) {
+ return 0;
+ }
+ if (align == HorizontalAlignment.RIGHT) {
+ return getWidth() - headerWidth;
+ }
+ if (align == HorizontalAlignment.CENTER) {
+ return (getWidth() - headerWidth) / 2;
+ }
+ throw new IllegalStateException();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramFileMakerPuma2.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramFileMakerPuma2.java
new file mode 100644
index 0000000..d79a8ea
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramFileMakerPuma2.java
@@ -0,0 +1,315 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.awt.geom.Dimension2D;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.activitydiagram3.ftile.EntityImageLegend;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.graphic.VerticalAlignment;
+import net.sourceforge.plantuml.png.PngTitler;
+import net.sourceforge.plantuml.sequencediagram.Event;
+import net.sourceforge.plantuml.sequencediagram.Newpage;
+import net.sourceforge.plantuml.sequencediagram.Participant;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.SimpleContext2D;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.ugraphic.ImageBuilder;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class SequenceDiagramFileMakerPuma2 implements FileMaker {
+
+ private static final StringBounder dummyStringBounder = TextBlockUtils.getDummyStringBounder();
+
+ private final SequenceDiagram diagram;
+ private final DrawableSet drawableSet;
+ private final Dimension2D fullDimension;
+ private final List<Page> pages;
+ private final FileFormatOption fileFormatOption;
+
+ private double scale;
+
+ public SequenceDiagramFileMakerPuma2(SequenceDiagram sequenceDiagram, Skin skin, FileFormatOption fileFormatOption) {
+ this.diagram = sequenceDiagram;
+ this.fileFormatOption = fileFormatOption;
+ final DrawableSetInitializer initializer = new DrawableSetInitializer(skin, sequenceDiagram.getSkinParam(),
+ sequenceDiagram.isShowFootbox(), sequenceDiagram.getAutonewpage());
+
+ for (Participant p : sequenceDiagram.participants().values()) {
+ initializer.addParticipant(p, sequenceDiagram.getEnglober(p));
+ }
+
+ for (Event ev : sequenceDiagram.events()) {
+ initializer.addEvent(ev);
+ // if (ev instanceof Message) {
+ // // TODO mieux faire
+ // final Message m = (Message) ev;
+ // for (LifeEvent lifeEvent : m.getLiveEvents()) {
+ // if (lifeEvent.getType() == LifeEventType.DESTROY
+ // /*
+ // * || lifeEvent.getType() == LifeEventType.CREATE
+ // */) {
+ // initializer.addEvent(lifeEvent);
+ // }
+ // }
+ // }
+ }
+ drawableSet = initializer.createDrawableSet(dummyStringBounder);
+ final List<Newpage> newpages = new ArrayList<Newpage>();
+ for (Event ev : drawableSet.getAllEvents()) {
+ if (ev instanceof Newpage) {
+ newpages.add((Newpage) ev);
+ }
+ }
+ fullDimension = drawableSet.getDimension();
+ final Map<Newpage, Double> positions = new LinkedHashMap<Newpage, Double>();
+ for (Newpage n : newpages) {
+ positions.put(n, initializer.getYposition(dummyStringBounder, n));
+ }
+ pages = create(drawableSet, positions, sequenceDiagram.isShowFootbox(), sequenceDiagram.getTitle()).getPages();
+ }
+
+ public int getNbPages() {
+ return pages.size();
+ }
+
+ private PageSplitter create(DrawableSet drawableSet, Map<Newpage, Double> positions, boolean showFootbox,
+ Display title) {
+
+ final double headerHeight = drawableSet.getHeadHeight(dummyStringBounder);
+ final double tailHeight = drawableSet.getTailHeight(dummyStringBounder, showFootbox);
+ final double signatureHeight = 0;
+ final double newpageHeight = drawableSet.getSkin()
+ .createComponent(ComponentType.NEWPAGE, null, drawableSet.getSkinParam(), Display.create(""))
+ .getPreferredHeight(dummyStringBounder);
+
+ return new PageSplitter(fullDimension.getHeight(), headerHeight, positions, tailHeight, signatureHeight,
+ newpageHeight, title);
+ }
+
+ public ImageData createOne(OutputStream os, final int index, boolean isWithMetadata) throws IOException {
+
+ final Page page = pages.get(index);
+ final SequenceDiagramArea area = new SequenceDiagramArea(fullDimension.getWidth(), page.getHeight());
+
+ final Component compTitle;
+ if (page.getTitle() == null) {
+ compTitle = null;
+ } else {
+ compTitle = drawableSet.getSkin().createComponent(ComponentType.TITLE, null, drawableSet.getSkinParam(),
+ page.getTitle());
+ area.setTitleArea(compTitle.getPreferredWidth(dummyStringBounder),
+ compTitle.getPreferredHeight(dummyStringBounder));
+ }
+ addFooter2(area);
+ addHeader2(area);
+
+ // final FileFormat fileFormat = fileFormatOption.getFileFormat();
+
+ final Display legend = diagram.getLegend();
+ final TextBlock legendBlock;
+ if (legend == null) {
+ legendBlock = TextBlockUtils.empty(0, 0);
+ } else {
+ legendBlock = EntityImageLegend.create(legend, diagram.getSkinParam());
+ }
+ final Dimension2D dimLegend = TextBlockUtils.getDimension(legendBlock);
+
+ scale = getScale(area.getWidth(), area.getHeight());
+
+ final double dpiFactor = diagram.getDpiFactor(fileFormatOption);
+ // System.err.println("dpiFactor=" + dpiFactor);
+ // System.err.println("scale=" + scale);
+
+ final ImageBuilder imageBuilder = new ImageBuilder(diagram.getSkinParam().getColorMapper(), oneOf(scale,
+ dpiFactor), diagram.getSkinParam().getBackgroundColor(), null, null, 3, 10, diagram.getAnimation(),
+ diagram.getSkinParam().handwritten());
+
+ imageBuilder.addUDrawable(new UDrawable() {
+ public void drawU(UGraphic ug) {
+
+ double delta = 0;
+ if (index > 0) {
+ delta = page.getNewpage1() - page.getHeaderHeight();
+ }
+ if (delta < 0) {
+ delta = 0;
+ }
+
+ double legendYdelta = 0;
+ if (compTitle != null) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final double h = compTitle.getPreferredHeight(stringBounder);
+ legendYdelta += h;
+ final double w = compTitle.getPreferredWidth(stringBounder);
+ compTitle.drawU(ug.apply(new UTranslate(area.getTitleX(), area.getTitleY())), new Area(
+ new Dimension2DDouble(w, h)), new SimpleContext2D(false));
+ }
+
+ final double delta1 = Math.max(0, dimLegend.getWidth() - area.getWidth());
+
+ final boolean legendTop = legend != null
+ && diagram.getLegendVerticalAlignment() == VerticalAlignment.TOP;
+
+ double sequenceAreaY = area.getSequenceAreaY();
+ if (legendTop) {
+ sequenceAreaY += legendBlock.calculateDimension(ug.getStringBounder()).getHeight();
+ }
+ drawableSet.drawU22(ug.apply(new UTranslate(area.getSequenceAreaX() + delta1 / 2, sequenceAreaY)),
+ delta, fullDimension.getWidth(), page, diagram.isShowFootbox());
+
+ addHeader3(area, ug);
+ addFooter3(area, ug);
+
+ if (legend != null) {
+ final double delta2;
+ if (diagram.getLegendAlignment() == HorizontalAlignment.LEFT) {
+ delta2 = 0;
+ } else if (diagram.getLegendAlignment() == HorizontalAlignment.RIGHT) {
+ delta2 = Math.max(0, area.getWidth() - dimLegend.getWidth());
+ } else {
+ delta2 = Math.max(0, area.getWidth() - dimLegend.getWidth()) / 2;
+ }
+ legendBlock.drawU(ug.apply(new UTranslate(delta2, legendTop ? legendYdelta : legendYdelta
+ + area.getHeight())));
+ }
+
+ }
+ });
+ return imageBuilder.writeImageTOBEMOVED(fileFormatOption.getFileFormat(), os);
+ }
+
+ private double oneOf(double a, double b) {
+ if (a == 1) {
+ return b;
+ }
+ return a;
+ }
+
+ private double getImageWidth(SequenceDiagramArea area, double dpiFactor, double legendWidth) {
+ final int minsize = diagram.getMinwidth();
+ final double w = Math.max(area.getWidth() * getScale(area.getWidth(), area.getHeight()) * dpiFactor,
+ legendWidth);
+ if (minsize == Integer.MAX_VALUE) {
+ return w;
+ }
+ if (w >= minsize) {
+ return w;
+ }
+ return minsize;
+ }
+
+ private double getScale(double width, double height) {
+ if (diagram.getScale() == null) {
+ return 1;
+ }
+ return diagram.getScale().getScale(width, height);
+ }
+
+ private void addFooter2(SequenceDiagramArea area) {
+ final HtmlColor hyperlinkColor = diagram.getSkinParam().getHyperlinkColor();
+ final HtmlColor titleColor = diagram.getSkinParam().getFontHtmlColor(FontParam.FOOTER, null);
+ final String fontFamily = diagram.getSkinParam().getFont(FontParam.FOOTER, null, false).getFamily(null);
+ final int fontSize = diagram.getSkinParam().getFont(FontParam.FOOTER, null, false).getSize();
+ final PngTitler pngTitler = new PngTitler(titleColor, diagram.getFooter(), fontSize, fontFamily,
+ diagram.getFooterAlignment(), hyperlinkColor, diagram.getSkinParam().useUnderlineForHyperlink());
+ final Dimension2D dim = pngTitler.getTextDimension(dummyStringBounder);
+ if (dim != null) {
+ area.setFooterArea(dim.getWidth(), dim.getHeight(), 3);
+ }
+ }
+
+ private void addHeader2(SequenceDiagramArea area) {
+ final HtmlColor hyperlinkColor = diagram.getSkinParam().getHyperlinkColor();
+ final HtmlColor titleColor = diagram.getSkinParam().getFontHtmlColor(FontParam.HEADER, null);
+ final String fontFamily = diagram.getSkinParam().getFont(FontParam.HEADER, null, false).getFamily(null);
+ final int fontSize = diagram.getSkinParam().getFont(FontParam.HEADER, null, false).getSize();
+ final PngTitler pngTitler = new PngTitler(titleColor, diagram.getHeader(), fontSize, fontFamily,
+ diagram.getHeaderAlignment(), hyperlinkColor, diagram.getSkinParam().useUnderlineForHyperlink());
+ final Dimension2D dim = pngTitler.getTextDimension(dummyStringBounder);
+ if (dim != null) {
+ area.setHeaderArea(dim.getWidth(), dim.getHeight(), 3);
+ }
+ }
+
+ private void addFooter3(SequenceDiagramArea area, UGraphic ug) {
+ final HtmlColor hyperlinkColor = diagram.getSkinParam().getHyperlinkColor();
+ final HtmlColor titleColor = diagram.getSkinParam().getFontHtmlColor(FontParam.FOOTER, null);
+ final String fontFamily = diagram.getSkinParam().getFont(FontParam.FOOTER, null, false).getFamily(null);
+ final int fontSize = diagram.getSkinParam().getFont(FontParam.FOOTER, null, false).getSize();
+ final PngTitler pngTitler = new PngTitler(titleColor, diagram.getFooter(), fontSize, fontFamily,
+ diagram.getFooterAlignment(), hyperlinkColor, diagram.getSkinParam().useUnderlineForHyperlink());
+ final TextBlock text = pngTitler.getTextBlock();
+ if (text == null) {
+ return;
+ }
+ text.drawU(ug.apply(new UTranslate(area.getFooterX(diagram.getFooterAlignment()), area.getFooterY())));
+ }
+
+ private void addHeader3(SequenceDiagramArea area, UGraphic ug) {
+ final HtmlColor hyperlinkColor = diagram.getSkinParam().getHyperlinkColor();
+ final HtmlColor titleColor = diagram.getSkinParam().getFontHtmlColor(FontParam.HEADER, null);
+ final String fontFamily = diagram.getSkinParam().getFont(FontParam.HEADER, null, false).getFamily(null);
+ final int fontSize = diagram.getSkinParam().getFont(FontParam.HEADER, null, false).getSize();
+ final PngTitler pngTitler = new PngTitler(titleColor, diagram.getHeader(), fontSize, fontFamily,
+ diagram.getHeaderAlignment(), hyperlinkColor, diagram.getSkinParam().useUnderlineForHyperlink());
+ final TextBlock text = pngTitler.getTextBlock();
+ if (text == null) {
+ return;
+ }
+ text.drawU(ug.apply(new UTranslate(area.getHeaderX(diagram.getHeaderAlignment()), area.getHeaderY())));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramTxtMaker.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramTxtMaker.java
new file mode 100644
index 0000000..b978489
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramTxtMaker.java
@@ -0,0 +1,124 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.awt.geom.Dimension2D;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintStream;
+
+import net.sourceforge.plantuml.FileFormat;
+import net.sourceforge.plantuml.api.ImageDataSimple;
+import net.sourceforge.plantuml.asciiart.TextSkin;
+import net.sourceforge.plantuml.asciiart.TextStringBounder;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.sequencediagram.Event;
+import net.sourceforge.plantuml.sequencediagram.LifeEvent;
+import net.sourceforge.plantuml.sequencediagram.LifeEventType;
+import net.sourceforge.plantuml.sequencediagram.Message;
+import net.sourceforge.plantuml.sequencediagram.Participant;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.ugraphic.txt.UGraphicTxt;
+
+public class SequenceDiagramTxtMaker implements FileMaker {
+
+ private final SequenceDiagram diagram;
+ private final DrawableSet drawableSet;
+ private final Dimension2D fullDimension;
+ private final StringBounder dummyStringBounder = new TextStringBounder();
+ private final UGraphicTxt ug = new UGraphicTxt();
+ private final FileFormat fileFormat;
+ private final Skin skin;
+
+ public SequenceDiagramTxtMaker(SequenceDiagram sequenceDiagram, FileFormat fileFormat) {
+ this.fileFormat = fileFormat;
+ this.diagram = sequenceDiagram;
+ this.skin = new TextSkin(fileFormat);
+
+ final DrawableSetInitializer initializer = new DrawableSetInitializer(skin, sequenceDiagram.getSkinParam(),
+ sequenceDiagram.isShowFootbox(), sequenceDiagram.getAutonewpage());
+
+ for (Participant p : sequenceDiagram.participants().values()) {
+ initializer.addParticipant(p, null);
+ }
+ for (Event ev : sequenceDiagram.events()) {
+ initializer.addEvent(ev);
+// if (ev instanceof Message) {
+// // TODO mieux faire
+// final Message m = (Message) ev;
+// for (LifeEvent lifeEvent : m.getLiveEvents()) {
+// if (lifeEvent.getType() == LifeEventType.DESTROY
+// /*
+// * || lifeEvent.getType() == LifeEventType.CREATE
+// */) {
+// initializer.addEvent(lifeEvent);
+// }
+// }
+// }
+ }
+ drawableSet = initializer.createDrawableSet(dummyStringBounder);
+ // final List<Newpage> newpages = new ArrayList<Newpage>();
+ // for (Event ev : drawableSet.getAllEvents()) {
+ // if (ev instanceof Newpage) {
+ // newpages.add((Newpage) ev);
+ // }
+ // }
+ fullDimension = drawableSet.getDimension();
+ final double headerHeight = drawableSet.getHeadHeight(dummyStringBounder);
+ final double tailHeight = drawableSet.getTailHeight(dummyStringBounder, diagram.isShowFootbox());
+ final double newpage2 = fullDimension.getHeight() - (diagram.isShowFootbox() ? tailHeight : 0) - headerHeight;
+ final Page page = new Page(headerHeight, 0, newpage2, tailHeight, 0, null);
+ //drawableSet.drawU_REMOVEDME_4243(ug, 0, fullDimension.getWidth(), page, diagram.isShowFootbox());
+ drawableSet.drawU22(ug, 0, fullDimension.getWidth(), page, diagram.isShowFootbox());
+ }
+
+
+ public ImageData createOne(OutputStream os, int index, boolean isWithMetadata) throws IOException {
+ if (fileFormat == FileFormat.UTXT) {
+ final PrintStream ps = new PrintStream(os, true, "UTF-8");
+ ug.getCharArea().print(ps);
+ } else {
+ final PrintStream ps = new PrintStream(os);
+ ug.getCharArea().print(ps);
+ }
+ return new ImageDataSimple(1, 1);
+ }
+
+ public int getNbPages() {
+ return 1;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/Stairs.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/Stairs.java
new file mode 100644
index 0000000..3330fe4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/Stairs.java
@@ -0,0 +1,129 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class Stairs {
+
+ private final List<Double> ys = new ArrayList<Double>();
+ private final List<Integer> values = new ArrayList<Integer>();
+ private final Map<Double, Integer> cache = new HashMap<Double, Integer>();
+
+ @Override
+ public String toString() {
+ final List<Double> copy = new ArrayList<Double>(ys);
+ Collections.sort(copy);
+ final StringBuilder sb = new StringBuilder("[");
+ for (Double y : copy) {
+ sb.append(y + "=" + getValue(y) + " ");
+ }
+ sb.append("]");
+ return sb.toString();
+ }
+
+ public void addStep(double y, int value) {
+ assert ys.size() == values.size();
+ if (ys.size() > 0) {
+ final double lastY = ys.get(ys.size() - 1);
+ if (y < lastY) {
+ throw new IllegalArgumentException();
+ }
+ if (lastY == y) {
+ values.set(ys.size() - 1, value);
+ cache.clear();
+ return;
+ }
+ }
+ ys.add(y);
+ values.add(value);
+ cache.clear();
+ }
+
+ public int getMaxValue() {
+ int max = Integer.MIN_VALUE;
+ for (Integer v : values) {
+ if (v > max) {
+ max = v;
+ }
+ }
+ return max;
+ }
+
+ public List<Double> getYs() {
+ return Collections.unmodifiableList(ys);
+ }
+
+ private double getLastY() {
+ if (ys.size() == 0) {
+ return 0;
+ }
+ return ys.get(ys.size() - 1);
+ }
+
+ public int getValue(double y) {
+ Integer result = cache.get(y);
+ if (result == null) {
+ result = getValueSlow(y);
+ cache.put(y, result);
+ }
+ return result;
+ }
+
+ private int getValueSlow(double y) {
+ final int idx = Collections.binarySearch(ys, y);
+ if (idx >= 0) {
+ return values.get(idx);
+ }
+ final int insertPoint = -idx - 1;
+ if (insertPoint == 0) {
+ return 0;
+ }
+ return values.get(insertPoint - 1);
+ }
+
+ public int getLastValue() {
+ final int size = values.size();
+ if (size == 0) {
+ return 0;
+ }
+ return values.get(size - 1);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1Abstract.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1Abstract.java
new file mode 100644
index 0000000..369c5d9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1Abstract.java
@@ -0,0 +1,151 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import net.sourceforge.plantuml.OptionFlags;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.sequencediagram.AbstractMessage;
+import net.sourceforge.plantuml.sequencediagram.LifeEvent;
+import net.sourceforge.plantuml.sequencediagram.LifeEventType;
+import net.sourceforge.plantuml.sequencediagram.MessageNumber;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+import net.sourceforge.plantuml.sequencediagram.Participant;
+import net.sourceforge.plantuml.skin.ArrowConfiguration;
+import net.sourceforge.plantuml.skin.Component;
+
+abstract class Step1Abstract {
+
+ private final StringBounder stringBounder;
+
+ private final DrawableSet drawingSet;
+
+ private final AbstractMessage message;
+
+ private Frontier freeY2;
+
+ // private ComponentType type;
+ private ArrowConfiguration config;
+
+ private Component note;
+
+ private ParticipantRange range;
+
+ Step1Abstract(ParticipantRange range, StringBounder stringBounder, AbstractMessage message, DrawableSet drawingSet,
+ Frontier freeY2) {
+ if (freeY2 == null) {
+ throw new IllegalArgumentException();
+ }
+ this.range = range;
+ this.stringBounder = stringBounder;
+ this.message = message;
+ this.freeY2 = freeY2;
+ this.drawingSet = drawingSet;
+ }
+
+ protected final ParticipantRange getParticipantRange() {
+ return range;
+ }
+
+ abstract Frontier prepareMessage(ConstraintSet constraintSet, InGroupablesStack groupingStructures);
+
+ protected final Display getLabelOfMessage(AbstractMessage message) {
+ if (message.getMessageNumber() == null) {
+ return message.getLabel();
+ }
+ Display result = Display.empty();
+ result = result.add(new MessageNumber(message.getMessageNumber()));
+ result = result.addAll(message.getLabel());
+ return result;
+ }
+
+
+ protected final ArrowConfiguration getConfig() {
+ return config;
+ }
+
+ protected final void setConfig(ArrowConfiguration config) {
+ this.config = config;
+ }
+
+ protected final Component getNote() {
+ return note;
+ }
+
+ protected final void setNote(Component note) {
+ this.note = note;
+ }
+
+ protected final StringBounder getStringBounder() {
+ return stringBounder;
+ }
+
+ protected final AbstractMessage getMessage() {
+ return message;
+ }
+
+ protected final DrawableSet getDrawingSet() {
+ return drawingSet;
+ }
+
+ protected final Frontier getFreeY() {
+ return freeY2;
+ }
+
+ protected final void incFreeY(double v) {
+ freeY2 = freeY2.add(v, range);
+ }
+
+ protected final NoteBox createNoteBox(StringBounder stringBounder, Arrow arrow, Component noteComp,
+ NotePosition notePosition, Url url) {
+ final LivingParticipantBox p = arrow.getParticipantAt(stringBounder, notePosition);
+ final NoteBox noteBox = new NoteBox(arrow.getStartingY(), noteComp, p, null, notePosition, url);
+
+ if (arrow instanceof MessageSelfArrow && notePosition == NotePosition.RIGHT) {
+ noteBox.pushToRight(arrow.getPreferredWidth(stringBounder));
+ }
+ // if (arrow instanceof MessageExoArrow) {
+ // final MessageExoType type = ((MessageExoArrow) arrow).getType();
+ // if (type.isRightBorder()) {
+ // final double width = noteBox.getPreferredWidth(stringBounder);
+ // noteBox.pushToRight(-width);
+ // }
+ // }
+
+ return noteBox;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1Message.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1Message.java
new file mode 100644
index 0000000..3d5d1ce
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1Message.java
@@ -0,0 +1,251 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.OptionFlags;
+import net.sourceforge.plantuml.SkinParamBackcolored;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.sequencediagram.InGroupable;
+import net.sourceforge.plantuml.sequencediagram.Message;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+import net.sourceforge.plantuml.skin.ArrowConfiguration;
+import net.sourceforge.plantuml.skin.ArrowHead;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+
+class Step1Message extends Step1Abstract {
+
+ private final MessageArrow messageArrow;
+
+ Step1Message(ParticipantRange range, StringBounder stringBounder, Message message, DrawableSet drawingSet,
+ Frontier freeY) {
+ super(range, stringBounder, message, drawingSet, freeY);
+
+ final double x1 = getParticipantBox1().getCenterX(stringBounder);
+ final double x2 = getParticipantBox2().getCenterX(stringBounder);
+
+ this.setConfig(isSelfMessage() ? getSelfArrowType(message) : getArrowType(message, x1, x2));
+
+ if (isSelfMessage()) {
+ this.messageArrow = null;
+ } else {
+ final Component comp = drawingSet.getSkin().createComponent(ComponentType.ARROW, getConfig(),
+ drawingSet.getSkinParam(), getLabelOfMessage(message));
+ final Component compAliveBox = drawingSet.getSkin().createComponent(ComponentType.ALIVE_BOX_OPEN_OPEN,
+ null, drawingSet.getSkinParam(), null);
+
+ this.messageArrow = new MessageArrow(freeY.getFreeY(range), drawingSet.getSkin(), comp,
+ getLivingParticipantBox1(), getLivingParticipantBox2(), message.getUrl(), compAliveBox);
+ }
+
+ if (message.getNote() != null) {
+ final ISkinParam skinParam = message.getSkinParamNoteBackcolored(drawingSet.getSkinParam());
+ setNote(drawingSet.getSkin().createComponent(ComponentType.NOTE, null, skinParam, message.getNote()));
+ }
+
+ }
+
+ Frontier prepareMessage(ConstraintSet constraintSet, InGroupablesStack inGroupablesStack) {
+ final Arrow graphic = createArrow();
+ final double arrowYStartLevel = graphic.getArrowYStartLevel(getStringBounder());
+ final double arrowYEndLevel = graphic.getArrowYEndLevel(getStringBounder());
+
+ // final double delta1 = isSelfMessage() ? 4 : 0;
+ final double delta1 = 0;
+ getMessage().setPosYstartLevel(arrowYStartLevel + delta1);
+
+ final double length;
+ if (isSelfMessage()) {
+ length = graphic.getArrowOnlyWidth(getStringBounder())
+ + getLivingParticipantBox1().getLiveThicknessAt(getStringBounder(), arrowYStartLevel).getSegment()
+ .getLength();
+ } else {
+ length = graphic.getArrowOnlyWidth(getStringBounder())
+ + getLivingParticipantBox(NotePosition.LEFT).getLifeLine().getRightShift(arrowYStartLevel)
+ + getLivingParticipantBox(NotePosition.RIGHT).getLifeLine().getLeftShift(arrowYStartLevel);
+ }
+
+ incFreeY(graphic.getPreferredHeight(getStringBounder()));
+ double marginActivateAndDeactive = 0;
+ if (getMessage().isActivateAndDeactive()) {
+ marginActivateAndDeactive = 30;
+ incFreeY(marginActivateAndDeactive);
+ }
+ getDrawingSet().addEvent(getMessage(), graphic);
+
+ if (isSelfMessage()) {
+ constraintSet.getConstraintAfter(getParticipantBox1()).ensureValue(length);
+ } else {
+ constraintSet.getConstraint(getParticipantBox1(), getParticipantBox2()).ensureValue(length);
+ }
+
+ final double posYendLevel = arrowYEndLevel + marginActivateAndDeactive - delta1;
+ getMessage().setPosYendLevel(posYendLevel);
+
+ assert graphic instanceof InGroupable;
+ if (graphic instanceof InGroupable) {
+ inGroupablesStack.addElement((InGroupable) graphic);
+ inGroupablesStack.addElement(getLivingParticipantBox1());
+ if (isSelfMessage() == false) {
+ inGroupablesStack.addElement(getLivingParticipantBox2());
+ }
+ }
+
+ return getFreeY();
+ }
+
+ private boolean isSelfMessage() {
+ return getParticipantBox1().equals(getParticipantBox2());
+ }
+
+ private ParticipantBox getParticipantBox1() {
+ return getLivingParticipantBox1().getParticipantBox();
+ }
+
+ private ParticipantBox getParticipantBox2() {
+ return getLivingParticipantBox2().getParticipantBox();
+ }
+
+ private LivingParticipantBox getLivingParticipantBox1() {
+ return getDrawingSet().getLivingParticipantBox(((Message) getMessage()).getParticipant1());
+ }
+
+ private LivingParticipantBox getLivingParticipantBox2() {
+ return getDrawingSet().getLivingParticipantBox(((Message) getMessage()).getParticipant2());
+ }
+
+ private LivingParticipantBox getLivingParticipantBox(NotePosition position) {
+ if (isSelfMessage()) {
+ throw new IllegalStateException();
+ }
+ return messageArrow.getParticipantAt(getStringBounder(), position);
+ }
+
+ private Arrow createArrow() {
+ if (getMessage().isCreate()) {
+ return createArrowCreate();
+ }
+ if (getMessage().getNote() != null && isSelfMessage()) {
+ final MessageSelfArrow messageSelfArrow = createMessageSelfArrow();
+ final NoteBox noteBox = createNoteBox(getStringBounder(), messageSelfArrow, getNote(), getMessage()
+ .getNotePosition(), getMessage().getUrlNote());
+ return new ArrowAndNoteBox(getStringBounder(), messageSelfArrow, noteBox);
+ } else if (getMessage().getNote() != null) {
+ final NoteBox noteBox = createNoteBox(getStringBounder(), messageArrow, getNote(), getMessage()
+ .getNotePosition(), getMessage().getUrlNote());
+ return new ArrowAndNoteBox(getStringBounder(), messageArrow, noteBox);
+ } else if (isSelfMessage()) {
+ return createMessageSelfArrow();
+ } else {
+ return messageArrow;
+ }
+ }
+
+ private MessageSelfArrow createMessageSelfArrow() {
+ final double posY = getFreeY().getFreeY(getParticipantRange());
+ double deltaY = 0;
+ double deltaX = 0;
+ if (getMessage().isActivate()) {
+ deltaY -= getHalfLifeWidth();
+ if (OptionFlags.STRICT_SELFMESSAGE_POSITION) {
+ deltaX += 5;
+ }
+ }
+ if (getMessage().isDeactivate()) {
+ deltaY += getHalfLifeWidth();
+ }
+
+ return new MessageSelfArrow(posY, getDrawingSet().getSkin(), getDrawingSet().getSkin().createComponent(
+ ComponentType.ARROW, getConfig(), getDrawingSet().getSkinParam(), getLabelOfMessage(getMessage())),
+ getLivingParticipantBox1(), deltaY, getMessage().getUrl(), deltaX);
+ }
+
+ private double getHalfLifeWidth() {
+ return getDrawingSet()
+ .getSkin()
+ .createComponent(ComponentType.ALIVE_BOX_OPEN_OPEN, null, getDrawingSet().getSkinParam(),
+ Display.create("")).getPreferredWidth(null) / 2;
+ }
+
+ private Arrow createArrowCreate() {
+ if (messageArrow == null) {
+ throw new IllegalStateException();
+ }
+ Arrow result = new ArrowAndParticipant(getStringBounder(), messageArrow, getParticipantBox2());
+ if (getMessage().getNote() != null) {
+ final NoteBox noteBox = createNoteBox(getStringBounder(), result, getNote(),
+ getMessage().getNotePosition(), getMessage().getUrlNote());
+ if (getMessage().getNotePosition() == NotePosition.RIGHT) {
+ noteBox.pushToRight(getParticipantBox2().getPreferredWidth(getStringBounder()) / 2);
+ }
+ result = new ArrowAndNoteBox(getStringBounder(), result, noteBox);
+ }
+ getLivingParticipantBox2().create(
+ getFreeY().getFreeY(getParticipantRange()) + result.getPreferredHeight(getStringBounder()) / 2);
+ return result;
+ }
+
+ private ArrowConfiguration getSelfArrowType(Message m) {
+ // return m.getArrowConfiguration().self();
+ ArrowConfiguration result = ArrowConfiguration.withDirectionSelf();
+ if (m.getArrowConfiguration().isDotted()) {
+ result = result.withDotted();
+ }
+ if (m.getArrowConfiguration().isAsync()) {
+ result = result.withHead(ArrowHead.ASYNC);
+ }
+ if (m.getArrowConfiguration().getDressing2().getHead() == ArrowHead.CROSSX) {
+ result = result.withHead2(m.getArrowConfiguration().getDressing2().getHead());
+ System.err.println("WARNING : CROSSX");
+ // assert false;
+ }
+ result = result.withPart(m.getArrowConfiguration().getPart());
+ result = result.withColor(m.getArrowConfiguration().getColor());
+ result = result.withDecoration1(m.getArrowConfiguration().getDecoration1());
+ result = result.withDecoration2(m.getArrowConfiguration().getDecoration2());
+
+ return result;
+ }
+
+ private ArrowConfiguration getArrowType(Message m, final double x1, final double x2) {
+ if (x2 > x1) {
+ return m.getArrowConfiguration();
+ }
+ return m.getArrowConfiguration().reverse();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1MessageExo.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1MessageExo.java
new file mode 100644
index 0000000..08b1df9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1MessageExo.java
@@ -0,0 +1,159 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.graphic;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.SkinParamBackcolored;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.sequencediagram.InGroupable;
+import net.sourceforge.plantuml.sequencediagram.MessageExo;
+import net.sourceforge.plantuml.sequencediagram.MessageExoType;
+import net.sourceforge.plantuml.sequencediagram.MessageNumber;
+import net.sourceforge.plantuml.skin.ArrowConfiguration;
+import net.sourceforge.plantuml.skin.ComponentType;
+
+class Step1MessageExo extends Step1Abstract {
+
+ private final MessageExoArrow messageArrow;
+
+ Step1MessageExo(ParticipantRange range, StringBounder stringBounder, MessageExo message, DrawableSet drawingSet,
+ Frontier freeY) {
+ super(range, stringBounder, message, drawingSet, freeY);
+
+ setConfig(getArrowType(message));
+
+ this.messageArrow = new MessageExoArrow(freeY.getFreeY(range), drawingSet.getSkin(), drawingSet.getSkin()
+ .createComponent(ComponentType.ARROW, getConfig(), drawingSet.getSkinParam(),
+ getLabelOfMessage(message)), getLivingParticipantBox(), message.getType(), message.getUrl(),
+ message.isShortArrow(), message.getArrowConfiguration());
+
+ if (message.getNote() != null) {
+ final ISkinParam skinParam = message.getSkinParamNoteBackcolored(drawingSet.getSkinParam());
+ setNote(drawingSet.getSkin().createComponent(ComponentType.NOTE, null, skinParam, message.getNote()));
+ // throw new UnsupportedOperationException();
+ }
+
+ }
+
+ Frontier prepareMessage(ConstraintSet constraintSet, InGroupablesStack inGroupablesStack) {
+ final Arrow graphic = createArrow();
+ final double arrowYStartLevel = graphic.getArrowYStartLevel(getStringBounder());
+ final double arrowYEndLevel = graphic.getArrowYEndLevel(getStringBounder());
+
+ getMessage().setPosYstartLevel(arrowYStartLevel);
+
+ final double length = graphic.getArrowOnlyWidth(getStringBounder());
+ incFreeY(graphic.getPreferredHeight(getStringBounder()));
+ double marginActivateAndDeactive = 0;
+ if (getMessage().isActivateAndDeactive()) {
+ marginActivateAndDeactive = 30;
+ incFreeY(marginActivateAndDeactive);
+ }
+ getDrawingSet().addEvent(getMessage(), graphic);
+
+ final LivingParticipantBox livingParticipantBox = getLivingParticipantBox();
+ if (messageArrow.getType().isRightBorder()) {
+ constraintSet.getConstraint(livingParticipantBox.getParticipantBox(), constraintSet.getLastborder())
+ .ensureValue(length);
+ } else {
+ constraintSet.getConstraint(constraintSet.getFirstBorder(), livingParticipantBox.getParticipantBox())
+ .ensureValue(length);
+ }
+
+ final double posYendLevel = arrowYEndLevel + marginActivateAndDeactive;
+ getMessage().setPosYendLevel(posYendLevel);
+
+ assert graphic instanceof InGroupable;
+ if (graphic instanceof InGroupable) {
+ inGroupablesStack.addElement((InGroupable) graphic);
+ inGroupablesStack.addElement(livingParticipantBox);
+ }
+
+ return getFreeY();
+ }
+
+ private LivingParticipantBox getLivingParticipantBox() {
+ return getDrawingSet().getLivingParticipantBox(((MessageExo) getMessage()).getParticipant());
+ }
+
+ private Display getLabelOfMessage(MessageExo message) {
+ if (message.getMessageNumber() == null) {
+ return message.getLabel();
+ }
+ Display result = Display.empty();
+ result = result.add(new MessageNumber(message.getMessageNumber()));
+ result = result.addAll(message.getLabel());
+ return result;
+ }
+
+ private Arrow createArrow() {
+ if (getMessage().getNote() == null) {
+ return messageArrow;
+ }
+ final NoteBox toto = createNoteBox(getStringBounder(), messageArrow, getNote(), getMessage().getNotePosition(),
+ getMessage().getUrlNote());
+ return new ArrowAndNoteBox(getStringBounder(), messageArrow, toto);
+ }
+
+ private ArrowConfiguration getArrowType(MessageExo m) {
+ final MessageExoType type = m.getType();
+ ArrowConfiguration result = null;
+
+ if (type.getDirection() == 1) {
+ result = m.getArrowConfiguration();
+ } else {
+ result = m.getArrowConfiguration().reverse();
+ }
+ result = result.withDecoration1(m.getArrowConfiguration().getDecoration1());
+ result = result.withDecoration2(m.getArrowConfiguration().getDecoration2());
+ return result;
+ // ArrowConfiguration result = null;
+ // if (type.getDirection() == 1) {
+ // result = ArrowConfiguration.withDirectionNormal();
+ // } else {
+ // result = ArrowConfiguration.withDirectionReverse();
+ // }
+ // if (m.getArrowConfiguration().isDotted()) {
+ // result = result.withDotted();
+ // }
+ // if (m.getArrowConfiguration().isAsync()) {
+ // result = result.withHead(ArrowHead.ASYNC);
+ // }
+ // result = result.withPart(m.getArrowConfiguration().getPart());
+ // return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/puma/FixedLink.java b/src/net/sourceforge/plantuml/sequencediagram/puma/FixedLink.java
new file mode 100644
index 0000000..16b69f8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/puma/FixedLink.java
@@ -0,0 +1,59 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.puma;
+
+public class FixedLink {
+
+ final private SegmentPosition segmentPosition1;
+ final private SegmentPosition segmentPosition2;
+
+ public FixedLink(SegmentPosition segmentPosition1, SegmentPosition segmentPosition2) {
+ this.segmentPosition1 = segmentPosition1;
+ this.segmentPosition2 = segmentPosition2;
+ }
+
+ public boolean pushIfNeed() {
+ final double p1 = segmentPosition1.getPosition();
+ final double p2 = segmentPosition2.getPosition();
+ if (p1 == p2) {
+ return false;
+ }
+ final double diff = p1 - p2;
+ segmentPosition2.getSegment().push(diff);
+ assert segmentPosition1.getPosition() == segmentPosition2.getPosition();
+ return true;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/puma/PSegment.java b/src/net/sourceforge/plantuml/sequencediagram/puma/PSegment.java
new file mode 100644
index 0000000..b66f949
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/puma/PSegment.java
@@ -0,0 +1,72 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.puma;
+
+public class PSegment {
+
+ private final double minsize;
+ private double startx;
+ private double endx;
+
+ public PSegment(double minsize) {
+ this.minsize = minsize;
+ this.startx = 0;
+ this.endx = minsize;
+ }
+
+ public double getMinsize() {
+ return minsize;
+ }
+
+ public void push(double delta) {
+ this.startx += delta;
+ this.endx += delta;
+ }
+
+ public String getDebugPosition() {
+ return "" + ((int) startx) + "-" + ((int) endx);
+ }
+
+ public double getPosition(double position) {
+ if (position == 0) {
+ return startx;
+ }
+ if (position == 1) {
+ return endx;
+ }
+ throw new UnsupportedOperationException();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/puma/PUnivers.java b/src/net/sourceforge/plantuml/sequencediagram/puma/PUnivers.java
new file mode 100644
index 0000000..fbcb1a2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/puma/PUnivers.java
@@ -0,0 +1,70 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.puma;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+public class PUnivers {
+
+ private final Collection<PSegment> all = new ArrayList<PSegment>();
+ private final Collection<FixedLink> links = new ArrayList<FixedLink>();
+
+ public PSegment createPSegment(double minsize) {
+ final PSegment result = new PSegment(minsize);
+ all.add(result);
+ return result;
+ }
+
+ public void addFixedLink(PSegment segment1, double position1, PSegment segment2, double position2) {
+ final FixedLink link = new FixedLink(new SegmentPosition(segment1, position1), new SegmentPosition(segment2,
+ position2));
+ links.add(link);
+
+ }
+
+ public void solve() {
+ boolean changed = false;
+ do {
+ changed = false;
+ for (FixedLink link : links) {
+ if (link.pushIfNeed()) {
+ changed = true;
+ }
+ }
+ } while (changed);
+
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/puma/PushDirection.java b/src/net/sourceforge/plantuml/sequencediagram/puma/PushDirection.java
new file mode 100644
index 0000000..ef2bf1e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/puma/PushDirection.java
@@ -0,0 +1,40 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.puma;
+
+public enum PushDirection {
+
+ TOLEFT, TORIGHT
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/puma/PushSide.java b/src/net/sourceforge/plantuml/sequencediagram/puma/PushSide.java
new file mode 100644
index 0000000..4577f22
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/puma/PushSide.java
@@ -0,0 +1,40 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.puma;
+
+public enum PushSide {
+
+ START, END
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/puma/PushStrategy.java b/src/net/sourceforge/plantuml/sequencediagram/puma/PushStrategy.java
new file mode 100644
index 0000000..fb2e07f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/puma/PushStrategy.java
@@ -0,0 +1,40 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.puma;
+
+public enum PushStrategy {
+
+ MOVE, ENLARGE
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/puma/SegmentPosition.java b/src/net/sourceforge/plantuml/sequencediagram/puma/SegmentPosition.java
new file mode 100644
index 0000000..5850de1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/puma/SegmentPosition.java
@@ -0,0 +1,56 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.puma;
+
+public class SegmentPosition {
+
+ final private PSegment segment;
+ final private double position;
+
+ public SegmentPosition(PSegment segment, double position) {
+ this.segment = segment;
+ this.position = position;
+ }
+
+ public double getPosition() {
+ return segment.getPosition(position);
+ }
+
+ public PSegment getSegment() {
+ return segment;
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationExoTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationExoTile.java
new file mode 100644
index 0000000..c1b9c86
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationExoTile.java
@@ -0,0 +1,149 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.real.Real;
+import net.sourceforge.plantuml.sequencediagram.Event;
+import net.sourceforge.plantuml.sequencediagram.MessageExo;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.ArrowComponent;
+import net.sourceforge.plantuml.skin.ArrowConfiguration;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class CommunicationExoTile implements TileWithUpdateStairs {
+
+ private final LivingSpace livingSpace;
+ private final MessageExo message;
+ private final Skin skin;
+ private final ISkinParam skinParam;
+ private final Real alpha;
+ private final Real omega;
+
+ public Event getEvent() {
+ return message;
+ }
+
+ public CommunicationExoTile(LivingSpace livingSpace, MessageExo message, Skin skin, ISkinParam skinParam,
+ Real alpha, Real omega) {
+ this.livingSpace = livingSpace;
+ this.message = message;
+ this.skin = skin;
+ this.skinParam = skinParam;
+ this.alpha = alpha;
+ this.omega = omega;
+ }
+
+ private Component getComponent(StringBounder stringBounder) {
+ ArrowConfiguration arrowConfiguration = message.getArrowConfiguration();
+ if (message.getType().getDirection() == -1) {
+ arrowConfiguration = arrowConfiguration.reverse();
+ }
+ final Component comp = skin.createComponent(ComponentType.ARROW, arrowConfiguration, skinParam,
+ message.getLabel());
+ return comp;
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ final double x1 = getPoint1(stringBounder).getCurrentValue();
+ final double x2 = getPoint2(stringBounder).getCurrentValue();
+ final Area area = new Area(x2 - x1, dim.getHeight());
+ ug = ug.apply(new UTranslate(x1, 0));
+ comp.drawU(ug, area, (Context2D) ug);
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ return dim.getHeight();
+ }
+
+ public void addConstraints(StringBounder stringBounder) {
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ final double width = dim.getWidth();
+
+ final Real point1 = getPoint1(stringBounder);
+ final Real point2 = getPoint2(stringBounder);
+ if (point1.getCurrentValue() < point2.getCurrentValue()) {
+ point2.ensureBiggerThan(point1.addFixed(width));
+ } else {
+ point1.ensureBiggerThan(point2.addFixed(width));
+ }
+ }
+
+ public void updateStairs(StringBounder stringBounder, double y) {
+ final ArrowComponent comp = (ArrowComponent) getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ final double arrowY = comp.getStartPoint(stringBounder, dim).getY();
+
+ livingSpace.addStepForLivebox(getEvent(), y + arrowY);
+
+ }
+
+ private Real getPoint1(final StringBounder stringBounder) {
+ if (message.getType().isRightBorder()) {
+ return livingSpace.getPosC(stringBounder);
+ }
+ return alpha;
+ }
+
+ private Real getPoint2(final StringBounder stringBounder) {
+ if (message.getType().isRightBorder()) {
+ return omega;
+ }
+ return livingSpace.getPosC(stringBounder);
+ }
+
+ public Real getMinX(StringBounder stringBounder) {
+ return getPoint1(stringBounder);
+ }
+
+ public Real getMaxX(StringBounder stringBounder) {
+ return getPoint2(stringBounder);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTile.java
new file mode 100644
index 0000000..9e70eb3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTile.java
@@ -0,0 +1,214 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.real.Real;
+import net.sourceforge.plantuml.sequencediagram.Event;
+import net.sourceforge.plantuml.sequencediagram.Message;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.ArrowComponent;
+import net.sourceforge.plantuml.skin.ArrowConfiguration;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class CommunicationTile implements TileWithUpdateStairs {
+
+ private final LivingSpace livingSpace1;
+ private final LivingSpace livingSpace2;
+ private final Message message;
+ private final Skin skin;
+ private final ISkinParam skinParam;
+
+ public Event getEvent() {
+ return message;
+ }
+
+ public CommunicationTile(LivingSpace livingSpace1, LivingSpace livingSpace2, Message message, Skin skin,
+ ISkinParam skinParam) {
+ if (livingSpace1 == livingSpace2) {
+ throw new IllegalArgumentException();
+ }
+ this.livingSpace1 = livingSpace1;
+ this.livingSpace2 = livingSpace2;
+ this.message = message;
+ this.skin = skin;
+ this.skinParam = skinParam;
+ // for (LifeEvent lifeEvent : message.getLiveEvents()) {
+ // System.err.println("lifeEvent = " + lifeEvent);
+ // // livingSpace1.addLifeEvent(this, lifeEvent);
+ // // livingSpace2.addLifeEvent(this, lifeEvent);
+ // }
+ }
+
+ public boolean isReverse(StringBounder stringBounder) {
+ final Real point1 = livingSpace1.getPosC(stringBounder);
+ final Real point2 = livingSpace2.getPosC(stringBounder);
+ if (point1.getCurrentValue() > point2.getCurrentValue()) {
+ return true;
+ }
+ return false;
+
+ }
+
+ private Component getComponent(StringBounder stringBounder) {
+ ArrowConfiguration arrowConfiguration = message.getArrowConfiguration();
+ /*
+ * if (isSelf()) { arrowConfiguration = arrowConfiguration.self(); } else
+ */
+ if (isReverse(stringBounder)) {
+ arrowConfiguration = arrowConfiguration.reverse();
+ }
+ final Component comp = skin.createComponent(ComponentType.ARROW, arrowConfiguration, skinParam,
+ message.getLabel());
+ return comp;
+ }
+
+ public static final double LIVE_DELTA_SIZE = 5;
+
+ public void updateStairs(StringBounder stringBounder, double y) {
+ final ArrowComponent comp = (ArrowComponent) getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ // final Point2D p2 = comp.getEndPoint(stringBounder, dim);
+ // System.err.println("CommunicationTile::updateStairs y=" + y + " p1=" + p1 + " p2=" + p2 + " dim=" + dim);
+ final double arrowY = comp.getStartPoint(stringBounder, dim).getY();
+
+ livingSpace1.addStepForLivebox(getEvent(), y + arrowY);
+ livingSpace2.addStepForLivebox(getEvent(), y + arrowY);
+
+ // System.err.println("CommunicationTile::updateStairs msg=" + message + " y=" + y + " arrowY=" + arrowY);
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ double x1 = getPoint1(stringBounder).getCurrentValue();
+ double x2 = getPoint2(stringBounder).getCurrentValue();
+
+ final int level1 = livingSpace1.getLevelAt(this, EventsHistoryMode.IGNORE_FUTURE_DEACTIVATE);
+ final int level2 = livingSpace2.getLevelAt(this, EventsHistoryMode.IGNORE_FUTURE_DEACTIVATE);
+ // System.err.println("CommunicationTile::draw msg=" + message + " level1=" + level1 + " level2=" + level2);
+
+ final Area area;
+ if (isReverse(stringBounder)) {
+ System.err.println("isreverse!");
+ // x1 -= LIVE_DELTA_SIZE * level1;
+ x2 += LIVE_DELTA_SIZE * level2;
+ area = new Area(x1 - x2, dim.getHeight());
+ ug = ug.apply(new UTranslate(x2, 0));
+ } else {
+ x1 += LIVE_DELTA_SIZE * level1;
+ x2 -= LIVE_DELTA_SIZE * level2;
+ area = new Area(x2 - x1, dim.getHeight());
+ ug = ug.apply(new UTranslate(x1, 0));
+ }
+ comp.drawU(ug, area, (Context2D) ug);
+ // ug.draw(new ULine(x2 - x1, 0));
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ return dim.getHeight();
+ }
+
+ public void addConstraints(StringBounder stringBounder) {
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ final double width = dim.getWidth();
+
+ // if (isSelf()) {
+ // final LivingSpace next = livingSpace1.getNext();
+ // if (next != null) {
+ // next.getPosB().ensureBiggerThan(getMaxX(stringBounder));
+ // }
+ // } else {
+ final Real point1 = getPoint1(stringBounder);
+ final Real point2 = getPoint2(stringBounder);
+ if (point1.getCurrentValue() < point2.getCurrentValue()) {
+ point2.ensureBiggerThan(point1.addFixed(width));
+ } else {
+ point1.ensureBiggerThan(point2.addFixed(width));
+ // }
+ }
+ }
+
+ // private boolean isSelf() {
+ // return livingSpace1 == livingSpace2;
+ // }
+
+ private Real getPoint1(final StringBounder stringBounder) {
+ return livingSpace1.getPosC(stringBounder);
+ }
+
+ private Real getPoint2(final StringBounder stringBounder) {
+ if (message.isCreate()) {
+ if (isReverse(stringBounder)) {
+ return livingSpace2.getPosD(stringBounder);
+ }
+ return livingSpace2.getPosB();
+ }
+ return livingSpace2.getPosC(stringBounder);
+ }
+
+ public Real getMinX(StringBounder stringBounder) {
+ if (isReverse(stringBounder)) {
+ return getPoint2(stringBounder);
+ }
+ return getPoint1(stringBounder);
+ }
+
+ public Real getMaxX(StringBounder stringBounder) {
+ // if (isSelf()) {
+ // final Component comp = getComponent(stringBounder);
+ // final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ // final double width = dim.getWidth();
+ // return livingSpace1.getPosC(stringBounder).addFixed(width);
+ // }
+ if (isReverse(stringBounder)) {
+ return getPoint1(stringBounder);
+ }
+ return getPoint2(stringBounder);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileNoteLeft.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileNoteLeft.java
new file mode 100644
index 0000000..cdf0d64
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileNoteLeft.java
@@ -0,0 +1,124 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.real.Real;
+import net.sourceforge.plantuml.sequencediagram.AbstractMessage;
+import net.sourceforge.plantuml.sequencediagram.Event;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class CommunicationTileNoteLeft implements TileWithUpdateStairs {
+
+ private final TileWithUpdateStairs tile;
+ private final AbstractMessage message;
+ private final Skin skin;
+ private final ISkinParam skinParam;
+ private final Display notes;
+ // private final NotePosition notePosition;
+ private final LivingSpace livingSpace;
+
+ public Event getEvent() {
+ return message;
+ }
+
+
+ public CommunicationTileNoteLeft(TileWithUpdateStairs tile, AbstractMessage message, Skin skin, ISkinParam skinParam,
+ LivingSpace livingSpace) {
+ this.tile = tile;
+ this.message = message;
+ this.skin = skin;
+ this.skinParam = skinParam;
+ this.notes = message.getNote();
+ // this.notePosition = message.getNotePosition();
+ this.livingSpace = livingSpace;
+ }
+
+ public void updateStairs(StringBounder stringBounder, double y) {
+ tile.updateStairs(stringBounder, y);
+ }
+
+
+ private Component getComponent(StringBounder stringBounder) {
+ final Component comp = skin.createComponent(ComponentType.NOTE, null, message.getSkinParamNoteBackcolored(skinParam), notes);
+ return comp;
+ }
+
+ private Real getNotePosition(StringBounder stringBounder) {
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ return livingSpace.getPosC(stringBounder).addFixed(-dim.getWidth());
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ final Area area = new Area(dim.getWidth(), dim.getHeight());
+ tile.drawU(ug);
+ final Real p = getNotePosition(stringBounder);
+
+ comp.drawU(ug.apply(new UTranslate(p.getCurrentValue(), 0)), area, (Context2D) ug);
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ return Math.max(tile.getPreferredHeight(stringBounder), dim.getHeight());
+ }
+
+ public void addConstraints(StringBounder stringBounder) {
+ tile.addConstraints(stringBounder);
+ }
+
+ public Real getMinX(StringBounder stringBounder) {
+ return getNotePosition(stringBounder);
+ }
+
+ public Real getMaxX(StringBounder stringBounder) {
+ return tile.getMaxX(stringBounder);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileNoteRight.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileNoteRight.java
new file mode 100644
index 0000000..87a6508
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileNoteRight.java
@@ -0,0 +1,125 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.real.Real;
+import net.sourceforge.plantuml.sequencediagram.AbstractMessage;
+import net.sourceforge.plantuml.sequencediagram.Event;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class CommunicationTileNoteRight implements TileWithUpdateStairs {
+
+ private final TileWithUpdateStairs tile;
+ private final AbstractMessage message;
+ private final Skin skin;
+ private final ISkinParam skinParam;
+ private final Display notes;
+ // private final NotePosition notePosition;
+ private final LivingSpace livingSpace;
+
+ public Event getEvent() {
+ return message;
+ }
+
+ public CommunicationTileNoteRight(TileWithUpdateStairs tile, AbstractMessage message, Skin skin,
+ ISkinParam skinParam, LivingSpace livingSpace) {
+ this.tile = tile;
+ this.message = message;
+ this.skin = skin;
+ this.skinParam = skinParam;
+ this.notes = message.getNote();
+ // this.notePosition = message.getNotePosition();
+ this.livingSpace = livingSpace;
+ }
+
+ public void updateStairs(StringBounder stringBounder, double y) {
+ tile.updateStairs(stringBounder, y);
+ }
+
+ private Component getComponent(StringBounder stringBounder) {
+ final Component comp = skin.createComponent(ComponentType.NOTE, null,
+ message.getSkinParamNoteBackcolored(skinParam), notes);
+ return comp;
+ }
+
+ private Real getNotePosition(StringBounder stringBounder) {
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ return livingSpace.getPosC(stringBounder);
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ final Area area = new Area(dim.getWidth(), dim.getHeight());
+ tile.drawU(ug);
+ final Real p = getNotePosition(stringBounder);
+
+ comp.drawU(ug.apply(new UTranslate(p.getCurrentValue(), 0)), area, (Context2D) ug);
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ return Math.max(tile.getPreferredHeight(stringBounder), dim.getHeight());
+ }
+
+ public void addConstraints(StringBounder stringBounder) {
+ tile.addConstraints(stringBounder);
+ }
+
+ public Real getMinX(StringBounder stringBounder) {
+ return tile.getMinX(stringBounder);
+ }
+
+ public Real getMaxX(StringBounder stringBounder) {
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ return getNotePosition(stringBounder).addFixed(dim.getWidth());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileSelf.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileSelf.java
new file mode 100644
index 0000000..a846280
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileSelf.java
@@ -0,0 +1,189 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.util.Iterator;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.real.Real;
+import net.sourceforge.plantuml.sequencediagram.Event;
+import net.sourceforge.plantuml.sequencediagram.Message;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.ArrowComponent;
+import net.sourceforge.plantuml.skin.ArrowConfiguration;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.skin.SimpleContext2D;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class CommunicationTileSelf implements TileWithUpdateStairs {
+
+ private final LivingSpace livingSpace1;
+ private final Message message;
+ private final Skin skin;
+ private final ISkinParam skinParam;
+ private final LivingSpaces livingSpaces;
+
+ public Event getEvent() {
+ return message;
+ }
+
+ public CommunicationTileSelf(LivingSpace livingSpace1, Message message, Skin skin, ISkinParam skinParam,
+ LivingSpaces livingSpaces) {
+ this.livingSpace1 = livingSpace1;
+ this.livingSpaces = livingSpaces;
+ this.message = message;
+ this.skin = skin;
+ this.skinParam = skinParam;
+ }
+
+ // private boolean isReverse(StringBounder stringBounder) {
+ // final Real point1 = livingSpace1.getPosC(stringBounder);
+ // final Real point2 = livingSpace2.getPosC(stringBounder);
+ // if (point1.getCurrentValue() > point2.getCurrentValue()) {
+ // return true;
+ // }
+ // return false;
+ //
+ // }
+
+ private Component getComponent(StringBounder stringBounder) {
+ ArrowConfiguration arrowConfiguration = message.getArrowConfiguration();
+ arrowConfiguration = arrowConfiguration.self();
+ final Component comp = skin.createComponent(ComponentType.ARROW, arrowConfiguration, skinParam,
+ message.getLabel());
+ return comp;
+ }
+
+ public void updateStairs(StringBounder stringBounder, double y) {
+ final ArrowComponent comp = (ArrowComponent) getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ final Point2D p1 = comp.getStartPoint(stringBounder, dim);
+ final Point2D p2 = comp.getEndPoint(stringBounder, dim);
+
+ if (message.isActivate()) {
+ livingSpace1.addStepForLivebox(getEvent(), y + p2.getY());
+ System.err.println("CommunicationTileSelf::updateStairs activate y=" + (y + p2.getY()) + " " + message);
+ } else if (message.isDeactivate()) {
+ livingSpace1.addStepForLivebox(getEvent(), y + p1.getY());
+ System.err.println("CommunicationTileSelf::updateStairs deactivate y=" + (y + p1.getY()) + " " + message);
+ }
+
+ // livingSpace1.addStep(y + arrowY, level1);
+ // livingSpace1.addStep(y + dim.getHeight(), level1);
+ // final int level2 = livingSpace2.getLevelAt(this);
+ // livingSpace2.addStep(y + arrowY, level2);
+ // livingSpace2.addStep(y + dim.getHeight(), level2);
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ double x1 = getPoint1(stringBounder).getCurrentValue();
+ final int levelIgnore = livingSpace1.getLevelAt(this, EventsHistoryMode.IGNORE_FUTURE_ACTIVATE);
+ final int levelConsidere = livingSpace1.getLevelAt(this, EventsHistoryMode.CONSIDERE_FUTURE_DEACTIVATE);
+ System.err.println("CommunicationTileSelf::drawU levelIgnore=" + levelIgnore + " levelConsidere="
+ + levelConsidere);
+ x1 += CommunicationTile.LIVE_DELTA_SIZE * levelIgnore;
+ if (levelIgnore < levelConsidere) {
+ x1 += CommunicationTile.LIVE_DELTA_SIZE;
+ }
+
+ final Area area = new Area(dim.getWidth(), dim.getHeight());
+ // if (message.isActivate()) {
+ // area.setDeltaX1(CommunicationTile.LIVE_DELTA_SIZE);
+ // } else if (message.isDeactivate()) {
+ // // area.setDeltaX1(CommunicationTile.LIVE_DELTA_SIZE);
+ // // x1 += CommunicationTile.LIVE_DELTA_SIZE * levelConsidere;
+ // }
+ area.setDeltaX1((levelIgnore - levelConsidere) * CommunicationTile.LIVE_DELTA_SIZE);
+ ug = ug.apply(new UTranslate(x1, 0));
+ comp.drawU(ug, area, (Context2D) ug);
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ return dim.getHeight();
+ }
+
+ public void addConstraints(StringBounder stringBounder) {
+ // final Component comp = getComponent(stringBounder);
+ // final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ // final double width = dim.getWidth();
+
+ final LivingSpace next = getNext();
+ if (next != null) {
+ next.getPosB().ensureBiggerThan(getMaxX(stringBounder));
+ }
+ }
+
+ // private boolean isSelf() {
+ // return livingSpace1 == livingSpace2;
+ // }
+
+ private LivingSpace getNext() {
+ for (Iterator<LivingSpace> it = livingSpaces.values().iterator(); it.hasNext();) {
+ final LivingSpace current = it.next();
+ if (current == livingSpace1 && it.hasNext()) {
+ return it.next();
+ }
+ }
+ return null;
+ }
+
+ private Real getPoint1(final StringBounder stringBounder) {
+ return livingSpace1.getPosC(stringBounder);
+ }
+
+ public Real getMinX(StringBounder stringBounder) {
+ return getPoint1(stringBounder);
+ }
+
+ public Real getMaxX(StringBounder stringBounder) {
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ final double width = dim.getWidth();
+ return livingSpace1.getPosC(stringBounder).addFixed(width);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileSelfNoteRight.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileSelfNoteRight.java
new file mode 100644
index 0000000..ec561b7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileSelfNoteRight.java
@@ -0,0 +1,124 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.real.Real;
+import net.sourceforge.plantuml.sequencediagram.Event;
+import net.sourceforge.plantuml.sequencediagram.Message;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.skin.SimpleContext2D;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class CommunicationTileSelfNoteRight implements TileWithUpdateStairs {
+
+ private final CommunicationTileSelf tile;
+ private final Message message;
+ private final Skin skin;
+ private final ISkinParam skinParam;
+ private final Display notes;
+
+ // private final NotePosition notePosition;
+ // private final LivingSpace livingSpace;
+
+ public Event getEvent() {
+ return message;
+ }
+
+
+ public CommunicationTileSelfNoteRight(CommunicationTileSelf tile, Message message, Skin skin, ISkinParam skinParam) {
+ this.tile = tile;
+ this.message = message;
+ this.skin = skin;
+ this.skinParam = skinParam;
+ this.notes = message.getNote();
+ // this.notePosition = message.getNotePosition();
+ }
+
+ public void updateStairs(StringBounder stringBounder, double y) {
+ tile.updateStairs(stringBounder, y);
+ }
+
+
+ private Component getComponent(StringBounder stringBounder) {
+ final Component comp = skin.createComponent(ComponentType.NOTE, null, message.getSkinParamNoteBackcolored(skinParam), notes);
+ return comp;
+ }
+
+ private Real getNotePosition(StringBounder stringBounder) {
+ return tile.getMaxX(stringBounder);
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ final Area area = new Area(dim.getWidth(), dim.getHeight());
+ tile.drawU(ug);
+ final Real p = getNotePosition(stringBounder);
+
+ comp.drawU(ug.apply(new UTranslate(p.getCurrentValue(), 0)), area, (Context2D) ug);
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ return Math.max(tile.getPreferredHeight(stringBounder), dim.getHeight());
+ }
+
+ public void addConstraints(StringBounder stringBounder) {
+ tile.addConstraints(stringBounder);
+ }
+
+ public Real getMinX(StringBounder stringBounder) {
+ return tile.getMinX(stringBounder);
+ }
+
+ public Real getMaxX(StringBounder stringBounder) {
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ return getNotePosition(stringBounder).addFixed(dim.getWidth());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/DelayTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/DelayTile.java
new file mode 100644
index 0000000..e685861
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/DelayTile.java
@@ -0,0 +1,126 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.real.Real;
+import net.sourceforge.plantuml.sequencediagram.Delay;
+import net.sourceforge.plantuml.sequencediagram.Event;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.skin.SimpleContext2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class DelayTile implements Tile {
+
+ private final Delay delay;
+ private final TileArguments tileArguments;
+ private Real first;
+ private Real last;
+
+ public Event getEvent() {
+ return delay;
+ }
+
+
+ public DelayTile(Delay delay, TileArguments tileArguments) {
+ this.delay = delay;
+ this.tileArguments = tileArguments;
+ }
+
+ private void init(StringBounder stringBounder) {
+ if (first != null) {
+ return;
+ }
+ this.first = tileArguments.getFirstLivingSpace().getPosC(stringBounder);
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ this.last = tileArguments.getLastLivingSpace().getPosC(stringBounder).addAtLeast(0);
+ this.last.ensureBiggerThan(this.first.addFixed(dim.getWidth()));
+
+ }
+
+ private Component getComponent(StringBounder stringBounder) {
+ final Component comp = tileArguments.getSkin().createComponent(ComponentType.DELAY_TEXT, null,
+ tileArguments.getSkinParam(), delay.getText());
+ return comp;
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ init(stringBounder);
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ final Area area = new Area(last.getCurrentValue() - first.getCurrentValue(), dim.getHeight());
+
+ ug = ug.apply(new UTranslate(first.getCurrentValue(), 0));
+ comp.drawU(ug, area, (Context2D) ug);
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ return dim.getHeight();
+ }
+
+ public void addConstraints(StringBounder stringBounder) {
+ }
+
+ public Real getMinX(StringBounder stringBounder) {
+ init(stringBounder);
+ return this.first;
+ }
+
+ public Real getMaxX(StringBounder stringBounder) {
+ init(stringBounder);
+ return this.last;
+ }
+
+// private double startingY;
+//
+// public void setStartingY(double startingY) {
+// this.startingY = startingY;
+// }
+//
+// public double getStartingY() {
+// return startingY;
+// }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/DividerTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/DividerTile.java
new file mode 100644
index 0000000..d01f7af
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/DividerTile.java
@@ -0,0 +1,108 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.real.Real;
+import net.sourceforge.plantuml.sequencediagram.Divider;
+import net.sourceforge.plantuml.sequencediagram.Event;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.skin.SimpleContext2D;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class DividerTile implements Tile {
+
+ private final Skin skin;
+ private final ISkinParam skinParam;
+ private final Divider divider;
+ private final Real origin;
+ private final Real omega;
+
+ public Event getEvent() {
+ return divider;
+ }
+
+
+ public DividerTile(Divider divider, Skin skin, ISkinParam skinParam, Real origin, Real omega) {
+ this.divider = divider;
+ this.skin = skin;
+ this.skinParam = skinParam;
+ this.origin = origin;
+ this.omega = omega;
+ }
+
+ private Component getComponent(StringBounder stringBounder) {
+ final Component comp = skin.createComponent(ComponentType.DIVIDER, null, skinParam, divider.getText());
+ return comp;
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ final Area area = new Area(omega.getCurrentValue() - origin.getCurrentValue(), dim.getHeight());
+
+ // ug = ug.apply(new UTranslate(x, 0));
+ comp.drawU(ug, area, (Context2D) ug);
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ return dim.getHeight();
+ }
+
+ public void addConstraints(StringBounder stringBounder) {
+ // final Component comp = getComponent(stringBounder);
+ // final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ // final double width = dim.getWidth();
+ }
+
+ public Real getMinX(StringBounder stringBounder) {
+ return origin;
+ }
+
+ public Real getMaxX(StringBounder stringBounder) {
+ return omega;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/ElseTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/ElseTile.java
new file mode 100644
index 0000000..8032c36
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/ElseTile.java
@@ -0,0 +1,111 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.real.Real;
+import net.sourceforge.plantuml.sequencediagram.Event;
+import net.sourceforge.plantuml.sequencediagram.GroupingLeaf;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.skin.SimpleContext2D;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ElseTile implements Tile {
+
+ private final Skin skin;
+ private final ISkinParam skinParam;
+ private final GroupingLeaf anElse;
+ private final Tile parent;
+
+ public Event getEvent() {
+ return anElse;
+ }
+
+
+ public ElseTile(GroupingLeaf anElse, Skin skin, ISkinParam skinParam, Tile parent) {
+ this.anElse = anElse;
+ this.skin = skin;
+ this.skinParam = skinParam;
+ this.parent = parent;
+ }
+
+ private Component getComponent(StringBounder stringBounder) {
+ final Display display = Display.create(anElse.getTitle());
+ final Component comp = skin.createComponent(ComponentType.GROUPING_ELSE, null, skinParam, display);
+ return comp;
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ final Real min = getMinX(stringBounder);
+ final Real max = getMaxX(stringBounder);
+ final Area area = new Area(max.getCurrentValue() - min.getCurrentValue(), dim.getHeight());
+ ug = ug.apply(new UTranslate(min.getCurrentValue(), 0));
+ // ug = ug.apply(new UTranslate(x, 0));
+ comp.drawU(ug, area, (Context2D) ug);
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ return dim.getHeight();
+ }
+
+ public void addConstraints(StringBounder stringBounder) {
+ // final Component comp = getComponent(stringBounder);
+ // final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ // final double width = dim.getWidth();
+ }
+
+ public Real getMinX(StringBounder stringBounder) {
+ return parent.getMinX(stringBounder);
+ }
+
+ public Real getMaxX(StringBounder stringBounder) {
+ return parent.getMaxX(stringBounder);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/EventsHistory.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/EventsHistory.java
new file mode 100644
index 0000000..4b566e1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/EventsHistory.java
@@ -0,0 +1,186 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.sequencediagram.Event;
+import net.sourceforge.plantuml.sequencediagram.LifeEvent;
+import net.sourceforge.plantuml.sequencediagram.Message;
+import net.sourceforge.plantuml.sequencediagram.Note;
+import net.sourceforge.plantuml.sequencediagram.Participant;
+
+public class EventsHistory {
+
+ private final Participant p;
+ private final List<Event> events;
+ private final Map<Event, Double> ys3 = new HashMap<Event, Double>();
+
+ public EventsHistory(Participant p, List<Event> events) {
+ this.p = p;
+ this.events = events;
+ }
+
+ public void addStepForLivebox(Event event, double y) {
+ ys3.put(event, y);
+ }
+
+ public Participant getParticipant() {
+ return p;
+ }
+
+ public int getLevelAt(Event event, EventsHistoryMode mode) {
+ final int result = getLevelAtInternal(event, mode);
+ // System.err.println("EventsHistory::getLevelAt " + mode + " " + result + " " + event);
+ return result;
+ }
+
+ private int getLevelAtInternal(Event event, EventsHistoryMode mode) {
+ int level = 0; // p.getInitialLife();
+ // System.err.println("--->EventsHistory for " + p + " " + event);
+ for (Iterator<Event> it = events.iterator(); it.hasNext();) {
+ final Event current = it.next();
+ if (current instanceof LifeEvent) {
+ final LifeEvent le = (LifeEvent) current;
+ if (le.getParticipant() == p && le.isActivate()) {
+ level++;
+ }
+ if (le.getParticipant() == p && le.isDeactivateOrDestroy()) {
+ level--;
+ }
+ }
+ if (event == current) {
+ if (current instanceof Message) {
+ final Event next = nextButSkippingNotes(it);
+ if (next instanceof LifeEvent) {
+ final LifeEvent le = (LifeEvent) next;
+ final Message msg = (Message) current;
+ if (mode != EventsHistoryMode.IGNORE_FUTURE_ACTIVATE && le.isActivate() && msg.dealWith(p)
+ && le.getParticipant() == p) {
+ level++;
+ }
+ if (mode == EventsHistoryMode.CONSIDERE_FUTURE_DEACTIVATE && le.isDeactivateOrDestroy()
+ && msg.dealWith(p) && le.getParticipant() == p) {
+ level--;
+ }
+ // System.err.println("Warning, this is message " + current + " next=" + next);
+ }
+
+ }
+ // System.err.println("<-result1 is " + level);
+ return level;
+ }
+ }
+ throw new IllegalArgumentException();
+ // return level;
+ }
+
+ private boolean isNextEventADestroy(Event event) {
+ for (Iterator<Event> it = events.iterator(); it.hasNext();) {
+ final Event current = it.next();
+ if (event != current) {
+ continue;
+ }
+ if (current instanceof Message) {
+ final Event next = nextButSkippingNotes(it);
+ if (next instanceof LifeEvent) {
+ final LifeEvent le = (LifeEvent) next;
+ return le.isDestroy();
+ }
+ }
+ return false;
+ }
+ return false;
+ }
+
+ private HtmlColor getActivateColor(Event event) {
+ for (Iterator<Event> it = events.iterator(); it.hasNext();) {
+ final Event current = it.next();
+ if (event != current) {
+ continue;
+ }
+ if (current instanceof Message) {
+ final Event next = nextButSkippingNotes(it);
+ if (next instanceof LifeEvent) {
+ final LifeEvent le = (LifeEvent) next;
+ if (le.isActivate()) {
+ return le.getSpecificBackColor();
+ }
+ return null;
+ }
+ }
+ return null;
+ }
+ return null;
+ }
+
+ private Event nextButSkippingNotes(Iterator<Event> it) {
+ while (true) {
+ if (it.hasNext() == false) {
+ return null;
+ }
+ final Event next = it.next();
+ if (next instanceof Note) {
+ continue;
+ }
+ // System.err.println("nextButSkippingNotes=" + next);
+ return next;
+ }
+ }
+
+ public Stairs2 getStairs(double totalHeight) {
+ System.err.println("EventsHistory::getStairs totalHeight=" + totalHeight);
+ final Stairs2 result = new Stairs2();
+ int value = 0;
+ for (Event event : events) {
+ final Double position = ys3.get(event);
+ System.err.println("EventsHistory::getStairs event=" + event + " position=" + position);
+ if (position != null) {
+ assert position <= totalHeight : "position=" + position + " totalHeight=" + totalHeight;
+ value = getLevelAt(event, EventsHistoryMode.CONSIDERE_FUTURE_DEACTIVATE);
+ result.addStep(new StairsPosition(position, isNextEventADestroy(event)), value, getActivateColor(event));
+ }
+ }
+ System.err.println("EventsHistory::getStairs finishing totalHeight=" + totalHeight);
+ result.addStep(new StairsPosition(totalHeight, false), value, null);
+ // System.err.println("EventsHistory::getStairs " + p + " result=" + result);
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/EventsHistoryMode.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/EventsHistoryMode.java
new file mode 100644
index 0000000..b265bb8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/EventsHistoryMode.java
@@ -0,0 +1,40 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+public enum EventsHistoryMode {
+ IGNORE_FUTURE_DEACTIVATE, IGNORE_FUTURE_ACTIVATE, CONSIDERE_FUTURE_DEACTIVATE;
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/GroupingTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/GroupingTile.java
new file mode 100644
index 0000000..8ba04c1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/GroupingTile.java
@@ -0,0 +1,166 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import java.awt.geom.Dimension2D;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.real.Real;
+import net.sourceforge.plantuml.real.RealMax;
+import net.sourceforge.plantuml.real.RealMin;
+import net.sourceforge.plantuml.sequencediagram.Event;
+import net.sourceforge.plantuml.sequencediagram.Grouping;
+import net.sourceforge.plantuml.sequencediagram.GroupingLeaf;
+import net.sourceforge.plantuml.sequencediagram.GroupingStart;
+import net.sourceforge.plantuml.sequencediagram.GroupingType;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class GroupingTile implements Tile {
+
+ private static final int MARGINX = 16;
+ private static final int MARGINY = 10;
+ private final List<Tile> tiles = new ArrayList<Tile>();
+ private final RealMin min = new RealMin();
+ private final RealMax max = new RealMax();
+ private final GroupingStart start;
+
+ // private final double marginX = 20;
+
+ private final Skin skin;
+ private final ISkinParam skinParam;
+ private final Display display;
+
+ private double bodyHeight;
+
+ public Event getEvent() {
+ return start;
+ }
+
+ public GroupingTile(Iterator<Event> it, GroupingStart start, TileArguments tileArgumentsBachColorChanged,
+ TileArguments tileArgumentsOriginal) {
+ final StringBounder stringBounder = tileArgumentsOriginal.getStringBounder();
+ this.start = start;
+ this.display = start.getTitle().equals("group") ? Display.create(start.getComment()) : Display.create(
+ start.getTitle(), start.getComment());
+ this.skin = tileArgumentsOriginal.getSkin();
+ this.skinParam = tileArgumentsBachColorChanged.getSkinParam();
+ // this.max = min.addAtLeast(dim1.getWidth());
+
+ while (it.hasNext()) {
+ final Event ev = it.next();
+ System.err.println("GroupingTile::ev=" + ev);
+ if (ev instanceof GroupingLeaf && ((Grouping) ev).getType() == GroupingType.END) {
+ break;
+ }
+ final Tile tile = TileBuilder.buildOne(it, tileArgumentsOriginal, ev, this);
+ if (tile != null) {
+ tiles.add(tile);
+ min.put(tile.getMinX(stringBounder).addFixed(-MARGINX));
+ final Real m = tile.getMaxX(stringBounder);
+ max.put(m == tileArgumentsOriginal.getOmega() ? m : m.addFixed(MARGINX));
+ bodyHeight += tile.getPreferredHeight(stringBounder);
+ }
+ }
+ final Dimension2D dim1 = getPreferredDimensionIfEmpty(stringBounder);
+ final double width = dim1.getWidth();
+ System.err.println("width=" + width);
+ if (min.size() == 0) {
+ min.put(tileArgumentsOriginal.getOrigin());
+ max.put(tileArgumentsOriginal.getOmega());
+ }
+ // max.ensureBiggerThan(min.addFixed(width));
+ this.max.ensureBiggerThan(getMinX(stringBounder).addFixed(width + 16));
+ }
+
+ private Component getComponent(StringBounder stringBounder) {
+ final Component comp = skin.createComponent(ComponentType.GROUPING_HEADER, null, skinParam, display);
+ return comp;
+ }
+
+ public Dimension2D getPreferredDimensionIfEmpty(StringBounder stringBounder) {
+ return getComponent(stringBounder).getPreferredDimension(stringBounder);
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim1 = getPreferredDimensionIfEmpty(stringBounder);
+ final Area area = new Area(max.getCurrentValue() - min.getCurrentValue(), bodyHeight + dim1.getHeight()
+ + MARGINY / 2);
+
+ if (ug instanceof LiveBoxFinder == false) {
+ comp.drawU(ug.apply(new UTranslate(min.getCurrentValue(), 0)), area, (Context2D) ug);
+ }
+ // ug.apply(new UChangeBackColor(HtmlColorUtils.LIGHT_GRAY)).draw(new URectangle(area.getDimensionToUse()));
+
+ double h = dim1.getHeight() + MARGINY / 2;
+ for (Tile tile : tiles) {
+ ug.apply(new UTranslate(0, h)).draw(tile);
+ h += tile.getPreferredHeight(stringBounder);
+ }
+
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ final Dimension2D dim1 = getPreferredDimensionIfEmpty(stringBounder);
+ return dim1.getHeight() + bodyHeight + MARGINY;
+ }
+
+ public void addConstraints(StringBounder stringBounder) {
+ for (Tile tile : tiles) {
+ tile.addConstraints(stringBounder);
+ }
+ }
+
+ public Real getMinX(StringBounder stringBounder) {
+ return min;
+ }
+
+ public Real getMaxX(StringBounder stringBounder) {
+ return max;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/IntegerColored.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/IntegerColored.java
new file mode 100644
index 0000000..19da327
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/IntegerColored.java
@@ -0,0 +1,62 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+
+public class IntegerColored {
+
+ private final int value;
+ private final HtmlColor color;
+
+ public IntegerColored(int value, HtmlColor color) {
+ this.value = value;
+ this.color = color;
+ }
+
+ @Override
+ public String toString() {
+ return "" + value + " " + color;
+ }
+
+ public int getValue() {
+ return value;
+ }
+
+ public HtmlColor getColor() {
+ return color;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/LifeEventTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/LifeEventTile.java
new file mode 100644
index 0000000..a7430d6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/LifeEventTile.java
@@ -0,0 +1,96 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.real.Real;
+import net.sourceforge.plantuml.sequencediagram.Event;
+import net.sourceforge.plantuml.sequencediagram.LifeEvent;
+import net.sourceforge.plantuml.sequencediagram.LifeEventType;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class LifeEventTile implements TileWithUpdateStairs {
+
+ private final LifeEvent lifeEvent;
+ private final TileArguments tileArguments;
+ private final LivingSpace livingSpace;
+ private final Skin skin;
+ private final ISkinParam skinParam;
+
+ public void updateStairs(StringBounder stringBounder, double y) {
+ System.err.println("LifeEventTile::updateStairs " + lifeEvent + " " + livingSpace.getParticipant() + " y=" + y);
+ livingSpace.addStepForLivebox(getEvent(), y);
+ }
+
+ public Event getEvent() {
+ return lifeEvent;
+ }
+
+ public LifeEventTile(LifeEvent lifeEvent, TileArguments tileArguments, LivingSpace livingSpace, Skin skin,
+ ISkinParam skinParam) {
+ this.lifeEvent = lifeEvent;
+ this.tileArguments = tileArguments;
+ this.livingSpace = livingSpace;
+ this.skin = skin;
+ this.skinParam = skinParam;
+ }
+
+ public void drawU(UGraphic ug) {
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ if (lifeEvent.isActivate()) {
+ return 20;
+ }
+ return 0;
+ }
+
+ public void addConstraints(StringBounder stringBounder) {
+ }
+
+ public Real getMinX(StringBounder stringBounder) {
+ return tileArguments.getLivingSpace(lifeEvent.getParticipant()).getPosB();
+ }
+
+ public Real getMaxX(StringBounder stringBounder) {
+ return tileArguments.getLivingSpace(lifeEvent.getParticipant()).getPosD(stringBounder);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/LiveBoxFinder.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/LiveBoxFinder.java
new file mode 100644
index 0000000..93c943b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/LiveBoxFinder.java
@@ -0,0 +1,121 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+import net.sourceforge.plantuml.ugraphic.UChange;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UParamNull;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class LiveBoxFinder implements UGraphic {
+
+ public boolean isSpecialTxt() {
+ return false;
+ }
+
+ public UGraphic apply(UChange change) {
+ if (change instanceof UTranslate) {
+ return new LiveBoxFinder(stringBounder, translate.compose((UTranslate) change));
+ } else if (change instanceof UStroke) {
+ return new LiveBoxFinder(this);
+ } else if (change instanceof UChangeBackColor) {
+ return new LiveBoxFinder(this);
+ } else if (change instanceof UChangeColor) {
+ return new LiveBoxFinder(this);
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ private final StringBounder stringBounder;
+ private final UTranslate translate;
+
+ public LiveBoxFinder(StringBounder stringBounder) {
+ this(stringBounder, new UTranslate());
+ }
+
+ private LiveBoxFinder(StringBounder stringBounder, UTranslate translate) {
+ this.stringBounder = stringBounder;
+ this.translate = translate;
+ }
+
+ private LiveBoxFinder(LiveBoxFinder other) {
+ this(other.stringBounder, other.translate);
+ }
+
+ public StringBounder getStringBounder() {
+ return stringBounder;
+ }
+
+ public UParam getParam() {
+ return new UParamNull();
+ }
+
+ public void draw(UShape shape) {
+ final double x = translate.getDx();
+ final double y = translate.getDy();
+ if (shape instanceof GroupingTile) {
+ ((GroupingTile) shape).drawU(this);
+ } else if (shape instanceof TileWithUpdateStairs) {
+ ((TileWithUpdateStairs) shape).updateStairs(stringBounder, y);
+ } else if (shape instanceof Tile) {
+ System.err.println("OtherTile " + shape);
+ } else {
+ throw new UnsupportedOperationException(shape.getClass().getName());
+ }
+ }
+
+ public ColorMapper getColorMapper() {
+ return new ColorMapperIdentity();
+ }
+
+ public void startUrl(Url url) {
+ }
+
+ public void closeAction() {
+ }
+
+ public void flushUg() {
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/LiveBoxes.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/LiveBoxes.java
new file mode 100644
index 0000000..c174374
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/LiveBoxes.java
@@ -0,0 +1,120 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import java.awt.geom.Dimension2D;
+import java.util.Iterator;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.SkinParamBackcolored;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class LiveBoxes implements UDrawable {
+
+ private final EventsHistory eventsHistory;
+ private final Skin skin;
+ private final ISkinParam skinParam;
+ private final double totalHeight;
+ private final Context2D context;
+
+ public LiveBoxes(EventsHistory eventsHistory, Skin skin, ISkinParam skinParam, double totalHeight, Context2D context) {
+ this.eventsHistory = eventsHistory;
+ this.skin = skin;
+ this.skinParam = skinParam;
+ this.totalHeight = totalHeight;
+ this.context = context;
+ }
+
+ public void drawU(UGraphic ug) {
+ final Stairs2 stairs = eventsHistory.getStairs(totalHeight);
+ final int max = stairs.getMaxValue();
+ for (int i = 1; i <= max; i++) {
+ drawOneLevel(ug, i, stairs, context);
+ }
+ }
+
+ private void drawOneLevel(UGraphic ug, int levelToDraw, Stairs2 stairs, Context2D context) {
+ final Component comp1 = skin.createComponent(ComponentType.ALIVE_BOX_CLOSE_CLOSE, null, skinParam, null);
+ final Component cross = skin.createComponent(ComponentType.DESTROY, null, skinParam, null);
+ final Dimension2D dimCross = cross.getPreferredDimension(ug.getStringBounder());
+ final double width = comp1.getPreferredWidth(ug.getStringBounder());
+ ug = ug.apply(new UTranslate((levelToDraw - 1) * width / 2.0, 0));
+
+ double y1 = Double.MAX_VALUE;
+ HtmlColor color = null;
+ for (Iterator<StairsPosition> it = stairs.getYs().iterator(); it.hasNext();) {
+ final StairsPosition yposition = it.next();
+ System.err.println("LiveBoxes::drawOneLevel " + levelToDraw + " " + yposition);
+ final IntegerColored integerColored = stairs.getValue(yposition.getValue());
+ System.err.println("integerColored=" + integerColored);
+ final int level = integerColored.getValue();
+ if (y1 == Double.MAX_VALUE && level == levelToDraw) {
+ y1 = yposition.getValue();
+ color = integerColored.getColor();
+ } else if (y1 != Double.MAX_VALUE && (it.hasNext() == false || level < levelToDraw)) {
+ final double y2 = yposition.getValue();
+ final Area area = new Area(width, y2 - y1);
+
+ final ISkinParam skinParam2 = new SkinParamBackcolored(skinParam, color);
+ final Component comp = skin
+ .createComponent(ComponentType.ALIVE_BOX_CLOSE_CLOSE, null, skinParam2, null);
+
+ comp.drawU(ug.apply(new UTranslate(-width / 2, y1)), area, context);
+ System.err.println("LiveBoxes::drawOneLevel one block " + y1 + " " + y2);
+ if (yposition.isDestroy()) {
+ System.err.println("LiveBoxes::drawOneLevel DESTROY " + yposition);
+ cross.drawU(ug.apply(new UTranslate(-dimCross.getWidth() / 2, y2 - dimCross.getHeight() / 2)),
+ null, context);
+ } else {
+ System.err.println("LiveBoxes::drawOneLevel NOTDESTROY " + yposition);
+ }
+ y1 = Double.MAX_VALUE;
+ }
+ }
+ }
+
+ private UGraphic withColor(UGraphic ug) {
+ return ug;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/LivingSpace.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/LivingSpace.java
new file mode 100644
index 0000000..462a35b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/LivingSpace.java
@@ -0,0 +1,205 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import java.awt.geom.Dimension2D;
+import java.util.List;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.real.Real;
+import net.sourceforge.plantuml.sequencediagram.Delay;
+import net.sourceforge.plantuml.sequencediagram.Event;
+import net.sourceforge.plantuml.sequencediagram.Participant;
+import net.sourceforge.plantuml.sequencediagram.ParticipantEnglober;
+import net.sourceforge.plantuml.sequencediagram.ParticipantType;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.skin.rose.Rose;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class LivingSpace {
+
+ private final Participant p;
+ private final Skin skin;
+ private final ISkinParam skinParam;
+ private final ComponentType headType;
+ private final ComponentType tailType;
+ private final boolean useContinueLineBecauseOfDelay;
+ private final MutingLine mutingLine;
+ private final Rose rose = new Rose();
+
+ // private final LivingSpaceImpl previous;
+ // private LivingSpace next;
+
+ private final Real posB;
+ private Real posC;
+ private Real posD;
+
+ private final EventsHistory eventsHistory;
+
+ public int getLevelAt(Tile tile, EventsHistoryMode mode) {
+ // assert mode == EventsHistoryMode.IGNORE_FUTURE_DEACTIVATE;
+ return eventsHistory.getLevelAt(tile.getEvent(), mode);
+ }
+
+ public void addStepForLivebox(Event event, double y) {
+ eventsHistory.addStepForLivebox(event, y);
+ }
+
+ @Override
+ public String toString() {
+ return p.getCode() + " B=" + posB.getCurrentValue() + "/C=" + currentValue(posC) + "/D=" + currentValue(posD);
+ }
+
+ private static String currentValue(Real pos) {
+ if (pos == null) {
+ return null;
+ }
+ return "" + pos.getCurrentValue();
+ }
+
+ public LivingSpace(Participant p, ParticipantEnglober englober, Skin skin, ISkinParam skinParam, Real position,
+ List<Event> events) {
+ this.eventsHistory = new EventsHistory(p, events);
+ this.p = p;
+ this.skin = skin;
+ this.skinParam = skinParam;
+ this.posB = position;
+ if (p.getType() == ParticipantType.PARTICIPANT) {
+ headType = ComponentType.PARTICIPANT_HEAD;
+ tailType = ComponentType.PARTICIPANT_TAIL;
+ } else if (p.getType() == ParticipantType.ACTOR) {
+ headType = ComponentType.ACTOR_HEAD;
+ tailType = ComponentType.ACTOR_TAIL;
+ } else if (p.getType() == ParticipantType.BOUNDARY) {
+ headType = ComponentType.BOUNDARY_HEAD;
+ tailType = ComponentType.BOUNDARY_TAIL;
+ } else if (p.getType() == ParticipantType.CONTROL) {
+ headType = ComponentType.CONTROL_HEAD;
+ tailType = ComponentType.CONTROL_TAIL;
+ } else if (p.getType() == ParticipantType.ENTITY) {
+ headType = ComponentType.ENTITY_HEAD;
+ tailType = ComponentType.ENTITY_TAIL;
+ } else if (p.getType() == ParticipantType.DATABASE) {
+ headType = ComponentType.DATABASE_HEAD;
+ tailType = ComponentType.DATABASE_TAIL;
+ } else {
+ throw new IllegalArgumentException();
+ }
+ // this.stairs2.addStep2(0, p.getInitialLife());
+ // this.stairs2.addStep2(0, 0);
+ this.useContinueLineBecauseOfDelay = useContinueLineBecauseOfDelay(events);
+ this.mutingLine = new MutingLine(skin, skinParam, events);
+
+ }
+
+ private boolean useContinueLineBecauseOfDelay(List<Event> events) {
+ final String strategy = skinParam.getValue("lifelineStrategy");
+ if ("nosolid".equalsIgnoreCase(strategy)) {
+ return false;
+ }
+ for (Event ev : events) {
+ if (ev instanceof Delay) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void drawLineAndLiveBoxes(UGraphic ug, double height, Context2D context) {
+
+ mutingLine.drawLine(ug, height, context);
+ // final ComponentType defaultLineType = useContinueLineBecauseOfDelay ? ComponentType.CONTINUE_LINE
+ // : ComponentType.PARTICIPANT_LINE;
+ // final Component comp = skin.createComponent(defaultLineType, null, skinParam, p.getDisplay(false));
+ // final Dimension2D dim = comp.getPreferredDimension(ug.getStringBounder());
+ // final Area area = new Area(dim.getWidth(), height);
+ // comp.drawU(ug, area, new SimpleContext2D(false));
+
+ final LiveBoxes liveBoxes = new LiveBoxes(eventsHistory, skin, skinParam, height, context);
+ liveBoxes.drawU(ug);
+ }
+
+ // public void addDelayTile(DelayTile tile) {
+ // System.err.println("addDelayTile " + this + " " + tile);
+ // }
+
+ public void drawHead(UGraphic ug, Context2D context) {
+ // final Component comp = skin.createComponent(headType, null, skinParam, p.getDisplay(false));
+ final Component comp = rose.createComponent(headType, null, p.getSkinParamBackcolored(skinParam),
+ p.getDisplay(false));
+ final Dimension2D dim = comp.getPreferredDimension(ug.getStringBounder());
+ final Area area = new Area(dim);
+ comp.drawU(ug, area, context);
+ }
+
+ public Dimension2D getHeadPreferredDimension(StringBounder stringBounder) {
+ // final Component comp = skin.createComponent(headType, null, skinParam, p.getDisplay(false));
+ final Component comp = rose.createComponent(headType, null, skinParam, p.getDisplay(false));
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ return dim;
+ }
+
+ private double getPreferredWidth(StringBounder stringBounder) {
+ return getHeadPreferredDimension(stringBounder).getWidth();
+ }
+
+ public Real getPosC(StringBounder stringBounder) {
+ if (posC == null) {
+ this.posC = posB.addFixed(this.getPreferredWidth(stringBounder) / 2);
+ }
+ return posC;
+ }
+
+ public Real getPosD(StringBounder stringBounder) {
+ if (posD == null) {
+ this.posD = posB.addFixed(this.getPreferredWidth(stringBounder));
+ }
+ return posD;
+ }
+
+ public Real getPosB() {
+ return posB;
+ }
+
+ public Participant getParticipant() {
+ return p;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/LivingSpaces.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/LivingSpaces.java
new file mode 100644
index 0000000..db9823f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/LivingSpaces.java
@@ -0,0 +1,101 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import java.awt.geom.Dimension2D;
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.VerticalAlignment;
+import net.sourceforge.plantuml.sequencediagram.Participant;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class LivingSpaces {
+
+ private final Map<Participant, LivingSpace> all = new LinkedHashMap<Participant, LivingSpace>();
+
+ public Collection<LivingSpace> values() {
+ return all.values();
+ }
+
+ public void put(Participant participant, LivingSpace livingSpace) {
+ all.put(participant, livingSpace);
+ }
+
+ public LivingSpace get(Participant participant) {
+ return all.get(participant);
+ }
+
+ public void drawHeads(final UGraphic ug, Context2D context, VerticalAlignment verticalAlignment) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final double headHeight = getHeadHeight(stringBounder);
+ for (LivingSpace livingSpace : values()) {
+ final double x = livingSpace.getPosB().getCurrentValue();
+ double y = 0;
+ if (verticalAlignment == VerticalAlignment.BOTTOM) {
+ final Dimension2D dimHead = livingSpace.getHeadPreferredDimension(stringBounder);
+ y = headHeight - dimHead.getHeight();
+ }
+ livingSpace.drawHead(ug.apply(new UTranslate(x, y)), context);
+ }
+ }
+
+ public double getHeadHeight(StringBounder stringBounder) {
+ double headHeight = 0;
+ for (LivingSpace livingSpace : values()) {
+ final Dimension2D headDim = livingSpace.getHeadPreferredDimension(stringBounder);
+ headHeight = Math.max(headHeight, headDim.getHeight());
+ }
+ return headHeight;
+ }
+
+ public void drawLifeLines(final UGraphic ug, double height, Context2D context) {
+ int i = 0;
+ for (LivingSpace livingSpace : values()) {
+ // if (i++ == 0) {
+ // System.err.println("TEMPORARY SKIPPING OTHERS");
+ // continue;
+ // }
+ // System.err.println("drawing lines " + livingSpace);
+ final double x = livingSpace.getPosC(ug.getStringBounder()).getCurrentValue();
+ livingSpace.drawLineAndLiveBoxes(ug.apply(new UTranslate(x, 0)), height, context);
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/MainTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/MainTile.java
new file mode 100644
index 0000000..1153f8f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/MainTile.java
@@ -0,0 +1,144 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.real.Real;
+import net.sourceforge.plantuml.real.RealMax;
+import net.sourceforge.plantuml.real.RealMin;
+import net.sourceforge.plantuml.sequencediagram.Event;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.ugraphic.LimitFinder;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class MainTile implements Tile {
+
+ private final RealMin min = new RealMin();
+ private final RealMax max = new RealMax();
+ // private double height;
+
+ private final List<Tile> tiles = new ArrayList<Tile>();
+
+ public MainTile(SequenceDiagram diagram, Skin skin, Real omega, LivingSpaces livingSpaces, Real origin) {
+
+ min.put(origin);
+ max.put(omega);
+
+ final ISkinParam skinParam = diagram.getSkinParam();
+ final StringBounder stringBounder = TextBlockUtils.getDummyStringBounder();
+
+ final TileArguments tileArguments = new TileArguments(stringBounder, omega, livingSpaces, skin, skinParam,
+ origin);
+
+ tiles.addAll(TileBuilder.buildSeveral(diagram.events().iterator(), tileArguments, null));
+
+ for (Tile tile : tiles) {
+ // height += tile.getPreferredHeight(stringBounder);
+ min.put(tile.getMinX(stringBounder));
+ max.put(tile.getMaxX(stringBounder));
+ }
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final LiveBoxFinder liveBoxFinder = new LiveBoxFinder(stringBounder);
+
+ drawUInternal(liveBoxFinder, false);
+ final UGraphicInterceptorTile interceptor = new UGraphicInterceptorTile(ug, true);
+ drawUInternal(interceptor, false);
+ }
+
+ public void drawForeground(UGraphic ug) {
+ final UGraphicInterceptorTile interceptor = new UGraphicInterceptorTile(ug, false);
+ drawUInternal(interceptor, false);
+ }
+
+ private double drawUInternal(UGraphic ug, boolean trace) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ double y = 0;
+ double lastY = 0;
+ final List<YPositionedTile> positionedTiles = new ArrayList<YPositionedTile>();
+ for (Tile tile : tiles) {
+ if (tile.getEvent().isParallel()) {
+ y = lastY;
+ }
+ if (trace) {
+ System.err.println("MainTile::drawUInternal tile=" + tile + " y=" + y);
+ }
+ positionedTiles.add(new YPositionedTile(tile, y));
+ lastY = y;
+ y += tile.getPreferredHeight(stringBounder);
+ }
+ for (YPositionedTile tile : positionedTiles) {
+ tile.drawU(ug);
+ }
+ System.err.println("MainTile::drawUInternal finalY=" + y);
+ return y;
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ final LimitFinder limitFinder = new LimitFinder(stringBounder, true);
+ final UGraphicInterceptorTile interceptor = new UGraphicInterceptorTile(limitFinder, false);
+ final double finalY = drawUInternal(interceptor, true);
+ final double result = Math.max(limitFinder.getMinMax().getDimension().getHeight(), finalY) + 10;
+ System.err.println("MainTile::getPreferredHeight=" + result);
+ return result;
+ }
+
+ public void addConstraints(StringBounder stringBounder) {
+ for (Tile tile : tiles) {
+ tile.addConstraints(stringBounder);
+ }
+ }
+
+ public Real getMinX(StringBounder stringBounder) {
+ return min;
+ }
+
+ public Real getMaxX(StringBounder stringBounder) {
+ return max;
+ }
+
+ public Event getEvent() {
+ return null;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/MutingLine.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/MutingLine.java
new file mode 100644
index 0000000..47a80e6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/MutingLine.java
@@ -0,0 +1,84 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import java.awt.geom.Dimension2D;
+import java.util.List;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.sequencediagram.Delay;
+import net.sourceforge.plantuml.sequencediagram.Event;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class MutingLine {
+
+ private final Skin skin;
+ private final ISkinParam skinParam;
+ private final boolean useContinueLineBecauseOfDelay;
+
+ public MutingLine(Skin skin, ISkinParam skinParam, List<Event> events) {
+ this.skin = skin;
+ this.skinParam = skinParam;
+ this.useContinueLineBecauseOfDelay = useContinueLineBecauseOfDelay(events);
+ }
+
+ private boolean useContinueLineBecauseOfDelay(List<Event> events) {
+ final String strategy = skinParam.getValue("lifelineStrategy");
+ if ("nosolid".equalsIgnoreCase(strategy)) {
+ return false;
+ }
+ for (Event ev : events) {
+ if (ev instanceof Delay) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void drawLine(UGraphic ug, double height, Context2D context) {
+ final ComponentType defaultLineType = useContinueLineBecauseOfDelay ? ComponentType.CONTINUE_LINE
+ : ComponentType.PARTICIPANT_LINE;
+ final Component comp = skin.createComponent(defaultLineType, null, skinParam, null);
+ final Dimension2D dim = comp.getPreferredDimension(ug.getStringBounder());
+ final Area area = new Area(dim.getWidth(), height);
+ comp.drawU(ug, area, context);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/NoteTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/NoteTile.java
new file mode 100644
index 0000000..e639907
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/NoteTile.java
@@ -0,0 +1,148 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.real.Real;
+import net.sourceforge.plantuml.real.RealUtils;
+import net.sourceforge.plantuml.sequencediagram.Event;
+import net.sourceforge.plantuml.sequencediagram.Note;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.skin.SimpleContext2D;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class NoteTile implements Tile {
+
+ private final LivingSpace livingSpace1;
+ private final LivingSpace livingSpace2;
+ private final Skin skin;
+ private final ISkinParam skinParam;
+ private final Note note;
+
+ public Event getEvent() {
+ return note;
+ }
+
+ public NoteTile(LivingSpace livingSpace1, LivingSpace livingSpace2, Note note, Skin skin, ISkinParam skinParam) {
+ this.livingSpace1 = livingSpace1;
+ this.livingSpace2 = livingSpace2;
+ this.note = note;
+ this.skin = skin;
+ this.skinParam = skinParam;
+ }
+
+ private Component getComponent(StringBounder stringBounder) {
+ final Component comp = skin.createComponent(ComponentType.NOTE, null, note.getSkinParamBackcolored(skinParam),
+ note.getStrings());
+ return comp;
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ final double x = getX(stringBounder).getCurrentValue();
+ final Area area = new Area(getUsedWidth(stringBounder), dim.getHeight());
+
+ ug = ug.apply(new UTranslate(x, 0));
+ comp.drawU(ug, area, (Context2D) ug);
+ // ug.draw(new ULine(x2 - x1, 0));
+ }
+
+ private double getUsedWidth(StringBounder stringBounder) {
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ final double width = dim.getWidth();
+ if (note.getPosition() == NotePosition.OVER_SEVERAL) {
+ final double x1 = livingSpace1.getPosB().getCurrentValue();
+ final double x2 = livingSpace2.getPosD(stringBounder).getCurrentValue();
+ final double w = x2 - x1;
+ if (width < w) {
+ return w;
+ }
+ }
+ return width;
+ }
+
+ private Real getX(StringBounder stringBounder) {
+ final NotePosition position = note.getPosition();
+ final double width = getUsedWidth(stringBounder);
+ if (position == NotePosition.LEFT) {
+ return livingSpace1.getPosC(stringBounder).addFixed(-width);
+ } else if (position == NotePosition.RIGHT) {
+ final int level = livingSpace1.getLevelAt(this, EventsHistoryMode.IGNORE_FUTURE_DEACTIVATE);
+ final double dx = level * CommunicationTile.LIVE_DELTA_SIZE;
+ return livingSpace1.getPosC(stringBounder).addFixed(dx);
+ } else if (position == NotePosition.OVER_SEVERAL) {
+ final Real x1 = livingSpace1.getPosC(stringBounder);
+ final Real x2 = livingSpace2.getPosC(stringBounder);
+ return RealUtils.middle(x1, x2).addFixed(-width / 2);
+ } else if (position == NotePosition.OVER) {
+ return livingSpace1.getPosC(stringBounder).addFixed(-width / 2);
+ } else {
+ throw new UnsupportedOperationException(position.toString());
+ }
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ return dim.getHeight();
+ }
+
+ public void addConstraints(StringBounder stringBounder) {
+ // final Component comp = getComponent(stringBounder);
+ // final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ // final double width = dim.getWidth();
+ }
+
+ public Real getMinX(StringBounder stringBounder) {
+ return getX(stringBounder);
+ }
+
+ public Real getMaxX(StringBounder stringBounder) {
+ return getX(stringBounder).addFixed(getUsedWidth(stringBounder));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/ReferenceTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/ReferenceTile.java
new file mode 100644
index 0000000..5e88e7b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/ReferenceTile.java
@@ -0,0 +1,130 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.real.Real;
+import net.sourceforge.plantuml.sequencediagram.Event;
+import net.sourceforge.plantuml.sequencediagram.Participant;
+import net.sourceforge.plantuml.sequencediagram.Reference;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ReferenceTile implements Tile {
+
+ private final Reference reference;
+ private final TileArguments tileArguments;
+ private Real first;
+ private Real last;
+
+ public Event getEvent() {
+ return reference;
+ }
+
+
+ public ReferenceTile(Reference reference, TileArguments tileArguments) {
+ this.reference = reference;
+ this.tileArguments = tileArguments;
+ }
+
+ private void init(StringBounder stringBounder) {
+ if (first != null) {
+ return;
+ }
+ for (Participant p : reference.getParticipant()) {
+ final LivingSpace livingSpace = tileArguments.getLivingSpace(p);
+ final Real pos = livingSpace.getPosC(stringBounder);
+ if (first == null || pos.getCurrentValue() < first.getCurrentValue()) {
+ this.first = pos;
+ }
+ if (last == null || pos.getCurrentValue() > last.getCurrentValue()) {
+ this.last = pos;
+ }
+ }
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ this.last = this.last.addAtLeast(0);
+ this.last.ensureBiggerThan(this.first.addFixed(dim.getWidth()));
+
+ }
+
+ private Component getComponent(StringBounder stringBounder) {
+ Display strings = Display.empty();
+ strings = strings.add("ref");
+ strings = strings.addAll(reference.getStrings());
+
+ final Component comp = tileArguments.getSkin().createComponent(ComponentType.REFERENCE, null,
+ tileArguments.getSkinParam(), strings);
+ return comp;
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ init(stringBounder);
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ final Area area = new Area(last.getCurrentValue() - first.getCurrentValue(), dim.getHeight());
+
+ ug = ug.apply(new UTranslate(first.getCurrentValue(), 0));
+ comp.drawU(ug, area, (Context2D) ug);
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ final Component comp = getComponent(stringBounder);
+ final Dimension2D dim = comp.getPreferredDimension(stringBounder);
+ return dim.getHeight();
+ }
+
+ public void addConstraints(StringBounder stringBounder) {
+ }
+
+ public Real getMinX(StringBounder stringBounder) {
+ init(stringBounder);
+ return this.first;
+ }
+
+ public Real getMaxX(StringBounder stringBounder) {
+ init(stringBounder);
+ return this.last;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java
new file mode 100644
index 0000000..7699637
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java
@@ -0,0 +1,243 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import java.awt.geom.Dimension2D;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.api.ImageDataSimple;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.graphic.VerticalAlignment;
+import net.sourceforge.plantuml.png.PngTitler;
+import net.sourceforge.plantuml.real.Real;
+import net.sourceforge.plantuml.real.RealUtils;
+import net.sourceforge.plantuml.sequencediagram.Participant;
+import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
+import net.sourceforge.plantuml.sequencediagram.graphic.FileMaker;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.skin.SimpleContext2D;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UGraphic2;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+import net.sourceforge.plantuml.ugraphic.hand.UGraphicHandwritten;
+import net.sourceforge.plantuml.utils.MathUtils;
+
+public class SequenceDiagramFileMakerTeoz implements FileMaker {
+
+ private final SequenceDiagram diagram;
+ private final FileFormatOption fileFormatOption;
+ private final Skin skin;
+
+ public SequenceDiagramFileMakerTeoz(SequenceDiagram sequenceDiagram, Skin skin, FileFormatOption fileFormatOption) {
+ this.diagram = sequenceDiagram;
+ this.fileFormatOption = fileFormatOption;
+ this.skin = skin;
+
+ }
+
+ public ImageData createOne(OutputStream os, int index, boolean isWithMetadata) throws IOException {
+ StringBounder stringBounder = TextBlockUtils.getDummyStringBounder();
+
+ final ISkinParam skinParam = diagram.getSkinParam();
+
+ final Real origin = RealUtils.createOrigin();
+ Real currentPos = origin.addAtLeast(0);
+ LivingSpace last = null;
+ LivingSpaces livingSpaces = new LivingSpaces();
+ for (Participant p : diagram.participants().values()) {
+ final LivingSpace livingSpace = new LivingSpace(p, diagram.getEnglober(p), skin, skinParam, currentPos,
+ diagram.events());
+ last = livingSpace;
+ ((LivingSpaces) livingSpaces).put(p, livingSpace);
+ currentPos = livingSpace.getPosD(stringBounder).addAtLeast(0);
+ }
+
+ final MainTile mainTile = new MainTile(diagram, skin, last.getPosD(stringBounder).addAtLeast(0), livingSpaces,
+ origin);
+ mainTile.addConstraints(stringBounder);
+ origin.compile();
+
+ final double mainHeight = mainTile.getPreferredHeight(stringBounder) + 2
+ * livingSpaces.getHeadHeight(stringBounder);
+
+ final Real min1 = mainTile.getMinX(stringBounder);
+ final Real max1 = mainTile.getMaxX(stringBounder);
+ // System.err.println("min1=" + min1.getCurrentValue());
+ // System.err.println("max1=" + max1.getCurrentValue());
+
+ final Component compTitle = getCompTitle();
+
+ final double mainWidth = max1.getCurrentValue() - min1.getCurrentValue();
+
+ Dimension2D dimTitle = new Dimension2DDouble(0, 0);
+ if (compTitle != null) {
+ dimTitle = compTitle.getPreferredDimension(stringBounder);
+ }
+
+ final PngTitler footer = getFooter();
+ Dimension2D dimFooter = new Dimension2DDouble(0, 0);
+ if (footer != null && footer.getTextBlock() != null) {
+ dimFooter = footer.getTextBlock().calculateDimension(stringBounder);
+ }
+
+ final PngTitler header = getHeader();
+ Dimension2D dimHeader = new Dimension2DDouble(0, 0);
+ if (header != null && header.getTextBlock() != null) {
+ dimHeader = header.getTextBlock().calculateDimension(stringBounder);
+ }
+
+ final double totalWidth = MathUtils.max(mainWidth, dimTitle.getWidth(), dimFooter.getWidth(),
+ dimHeader.getWidth());
+ final double totalHeight = mainHeight + dimTitle.getHeight() + dimHeader.getHeight() + dimFooter.getHeight();
+ final Dimension2D dim = new Dimension2DDouble(totalWidth, totalHeight);
+ final UGraphic2 ug2 = (UGraphic2) fileFormatOption.createUGraphic(skinParam.getColorMapper(),
+ diagram.getDpiFactor(fileFormatOption), dim, skinParam.getBackgroundColor(), false).apply(
+ new UTranslate(-min1.getCurrentValue(), 0));
+
+ UGraphic ug = diagram.getSkinParam().handwritten() ? new UGraphicHandwritten(ug2) : ug2;
+
+ if (footer != null && footer.getTextBlock() != null) {
+ double dx = 0;
+ if (diagram.getFooterAlignment() == HorizontalAlignment.RIGHT) {
+ dx = totalWidth - dimFooter.getWidth();
+ } else if (diagram.getFooterAlignment() == HorizontalAlignment.CENTER) {
+ dx = (totalWidth - dimFooter.getWidth()) / 2;
+ }
+ footer.getTextBlock().drawU(
+ ug.apply(new UTranslate(dx, mainHeight + dimTitle.getHeight() + dimHeader.getHeight())));
+ }
+ if (header != null && header.getTextBlock() != null) {
+ double dx = 0;
+ if (diagram.getHeaderAlignment() == HorizontalAlignment.RIGHT) {
+ dx = totalWidth - dimHeader.getWidth();
+ } else if (diagram.getHeaderAlignment() == HorizontalAlignment.CENTER) {
+ dx = (totalWidth - dimHeader.getWidth()) / 2;
+ }
+ header.getTextBlock().drawU(ug.apply(new UTranslate(dx, 0)));
+ }
+ if (compTitle != null) {
+ compTitle.drawU(ug.apply(new UTranslate((totalWidth - dimTitle.getWidth()) / 2, 0)), new Area(dimTitle),
+ new SimpleContext2D(false));
+ ug = ug.apply(new UTranslate((totalWidth - mainWidth) / 2, dimTitle.getHeight() + dimHeader.getHeight()));
+ }
+
+ drawMainTile(ug, mainTile, livingSpaces);
+
+ ug2.writeImageTOBEMOVED(os, isWithMetadata ? diagram.getMetadata() : null, diagram.getDpi(fileFormatOption));
+ final Dimension2D info = new Dimension2DDouble(dim.getWidth(), dim.getHeight());
+
+ // if (fileFormatOption.getFileFormat() == FileFormat.PNG && ug instanceof UGraphicG2d) {
+ // final Set<Url> urls = ((UGraphicG2d) ug).getAllUrlsEncountered();
+ // if (urls.size() > 0) {
+ // if (scale == 0) {
+ // throw new IllegalStateException();
+ // }
+ // final CMapData cmap = CMapData.cmapString(urls, scale);
+ // return new ImageDataComplex(info, cmap, null);
+ // }
+ // }
+ return new ImageDataSimple(info);
+ }
+
+ private Component getCompTitle() {
+ final Display title = diagram.getTitle();
+
+ final Component compTitle;
+ if (title == null) {
+ compTitle = null;
+ } else {
+ compTitle = skin.createComponent(ComponentType.TITLE, null, diagram.getSkinParam(), title);
+ }
+ return compTitle;
+ }
+
+ private PngTitler getFooter() {
+ if (diagram.getFooter() == null) {
+ return null;
+ }
+ final HtmlColor hyperlinkColor = diagram.getSkinParam().getHyperlinkColor();
+ final HtmlColor titleColor = diagram.getSkinParam().getFontHtmlColor(FontParam.FOOTER, null);
+ final String fontFamily = diagram.getSkinParam().getFont(FontParam.FOOTER, null, false).getFamily(null);
+ final int fontSize = diagram.getSkinParam().getFont(FontParam.FOOTER, null, false).getSize();
+ final PngTitler pngTitler = new PngTitler(titleColor, diagram.getFooter(), fontSize, fontFamily,
+ diagram.getFooterAlignment(), hyperlinkColor, diagram.getSkinParam().useUnderlineForHyperlink());
+ return pngTitler;
+ }
+
+ private PngTitler getHeader() {
+ final HtmlColor hyperlinkColor = diagram.getSkinParam().getHyperlinkColor();
+ final HtmlColor titleColor = diagram.getSkinParam().getFontHtmlColor(FontParam.HEADER, null);
+ final String fontFamily = diagram.getSkinParam().getFont(FontParam.HEADER, null, false).getFamily(null);
+ final int fontSize = diagram.getSkinParam().getFont(FontParam.HEADER, null, false).getSize();
+ final PngTitler pngTitler = new PngTitler(titleColor, diagram.getHeader(), fontSize, fontFamily,
+ diagram.getHeaderAlignment(), hyperlinkColor, diagram.getSkinParam().useUnderlineForHyperlink());
+ return pngTitler;
+ }
+
+ private void drawMainTile(final UGraphic ug, final MainTile mainTile, LivingSpaces livingSpaces) {
+ final StringBounder stringBounder = ug.getStringBounder();
+
+ final Context2D context = new SimpleContext2D(false);
+ livingSpaces.drawHeads(ug, context, VerticalAlignment.BOTTOM);
+
+ final double headHeight = livingSpaces.getHeadHeight(stringBounder);
+
+ mainTile.drawU(ug.apply(new UTranslate(0, headHeight)));
+ livingSpaces.drawLifeLines(ug.apply(new UTranslate(0, headHeight)), mainTile.getPreferredHeight(stringBounder),
+ context);
+ livingSpaces.drawHeads(ug.apply(new UTranslate(0, mainTile.getPreferredHeight(stringBounder) + headHeight)),
+ context, VerticalAlignment.TOP);
+ mainTile.drawForeground(ug.apply(new UTranslate(0, headHeight)));
+ }
+
+ public int getNbPages() {
+ return 1;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/Stairs2.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/Stairs2.java
new file mode 100644
index 0000000..f6cdcc3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/Stairs2.java
@@ -0,0 +1,114 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+
+public class Stairs2 {
+
+ private final List<StairsPosition> ys = new ArrayList<StairsPosition>();
+ private final List<IntegerColored> values = new ArrayList<IntegerColored>();
+ private final Map<Double, IntegerColored> cache = new HashMap<Double, IntegerColored>();
+
+ public void addStep(StairsPosition position, int value, HtmlColor color) {
+ System.err.println("Stairs2::addStep " + position + " " + value + " color=" + color);
+ assert ys.size() == values.size();
+ if (ys.size() > 0) {
+ final double lastY = ys.get(ys.size() - 1).getValue();
+ if (position.getValue() < lastY) {
+ throw new IllegalArgumentException();
+ }
+ if (lastY == position.getValue()) {
+ values.set(ys.size() - 1, new IntegerColored(value, color));
+ cache.clear();
+ return;
+ }
+ }
+ ys.add(position);
+ values.add(new IntegerColored(value, color));
+ cache.clear();
+ }
+
+ public int getMaxValue() {
+ int max = Integer.MIN_VALUE;
+ for (IntegerColored vc : values) {
+ final int v = vc.getValue();
+ if (v > max) {
+ max = v;
+ }
+ }
+ return max;
+ }
+
+ public List<StairsPosition> getYs() {
+ return Collections.unmodifiableList(ys);
+ }
+
+ public IntegerColored getValue(double y) {
+ IntegerColored resultc = cache.get(y);
+ if (resultc == null) {
+ resultc = getValueSlow(new StairsPosition(y, false));
+ cache.put(y, resultc);
+ }
+ return resultc;
+ }
+
+ private IntegerColored getValueSlow(StairsPosition y) {
+ final int idx = Collections.binarySearch(ys, y);
+ if (idx >= 0) {
+ return values.get(idx);
+ }
+ final int insertPoint = -idx - 1;
+ if (insertPoint == 0) {
+ return new IntegerColored(0, null);
+ }
+ return values.get(insertPoint - 1);
+ }
+
+ public int getLastValue() {
+ final int size = values.size();
+ if (size == 0) {
+ return 0;
+ }
+ return values.get(size - 1).getValue();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/StairsPosition.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/StairsPosition.java
new file mode 100644
index 0000000..cf4e0f8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/StairsPosition.java
@@ -0,0 +1,71 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+
+public class StairsPosition implements Comparable<StairsPosition> {
+
+ private final double value;
+ private final boolean destroy;
+
+ public StairsPosition(double value, boolean destroy) {
+ this.value = value;
+ this.destroy = destroy;
+ }
+
+ @Override
+ public String toString() {
+ return "" + value + "-(" + destroy + ")";
+ }
+
+ public double getValue() {
+ return value;
+ }
+
+ public int compareTo(StairsPosition other) {
+ if (this.value > other.value) {
+ return 1;
+ }
+ if (this.value < other.value) {
+ return -1;
+ }
+ return 0;
+ }
+
+ public boolean isDestroy() {
+ return destroy;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/Tile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/Tile.java
new file mode 100644
index 0000000..1a106fe
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/Tile.java
@@ -0,0 +1,55 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.real.Real;
+import net.sourceforge.plantuml.sequencediagram.Event;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public interface Tile extends UDrawable, UShape {
+
+ public double getPreferredHeight(StringBounder stringBounder);
+
+ public void addConstraints(StringBounder stringBounder);
+
+ public Real getMinX(StringBounder stringBounder);
+
+ public Real getMaxX(StringBounder stringBounder);
+
+ public Event getEvent();
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/TileArguments.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/TileArguments.java
new file mode 100644
index 0000000..4edee7e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/TileArguments.java
@@ -0,0 +1,121 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.SkinParamBackcolored;
+import net.sourceforge.plantuml.SkinParamBackcoloredReference;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.real.Real;
+import net.sourceforge.plantuml.sequencediagram.Participant;
+import net.sourceforge.plantuml.sequencediagram.Reference;
+import net.sourceforge.plantuml.skin.Skin;
+
+public class TileArguments {
+ private final StringBounder stringBounder;
+ private final Real omega;
+ private final Real origin;
+ private final LivingSpaces livingSpaces;
+ private final Skin skin;
+ private final ISkinParam skinParam;
+
+ public TileArguments(StringBounder stringBounder, Real omega, LivingSpaces livingSpaces, Skin skin,
+ ISkinParam skinParam, Real origin) {
+ this.stringBounder = stringBounder;
+ this.origin = origin;
+ this.omega = omega;
+ this.livingSpaces = livingSpaces;
+ this.skin = skin;
+ this.skinParam = skinParam;
+ }
+
+ public TileArguments withBackColorGeneral(HtmlColor backColorElement, HtmlColor backColorGeneral) {
+ return new TileArguments(stringBounder, omega, livingSpaces, skin, new SkinParamBackcolored(skinParam,
+ backColorElement, backColorGeneral), origin);
+ }
+
+ public TileArguments withBackColor(Reference reference) {
+ final ISkinParam newSkinParam = new SkinParamBackcoloredReference(skinParam, reference.getBackColorElement(),
+ reference.getBackColorGeneral());
+ return new TileArguments(stringBounder, omega, livingSpaces, skin, newSkinParam, origin);
+ }
+
+ public final StringBounder getStringBounder() {
+ return stringBounder;
+ }
+
+ public final Real getOmega() {
+ return omega;
+ }
+
+ public final Real getOrigin() {
+ return origin;
+ }
+
+ public final LivingSpaces getLivingSpaces() {
+ return livingSpaces;
+ }
+
+ public final Skin getSkin() {
+ return skin;
+ }
+
+ public final ISkinParam getSkinParam() {
+ return skinParam;
+ }
+
+ public LivingSpace getLivingSpace(Participant p) {
+ return livingSpaces.get(p);
+ }
+
+ public LivingSpace getFirstLivingSpace() {
+ return livingSpaces.values().iterator().next();
+ }
+
+ public LivingSpace getLastLivingSpace() {
+ LivingSpace result = null;
+ for (LivingSpace v : livingSpaces.values()) {
+ result = v;
+ }
+ return result;
+ }
+
+ // public void ensure(Tile tile) {
+ // getAlpha().ensureLowerThan(tile.getMinX(getStringBounder()));
+ // getOmega().ensureBiggerThan(tile.getMaxX(getStringBounder()));
+ // }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/TileBuilder.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/TileBuilder.java
new file mode 100644
index 0000000..7a46663
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/TileBuilder.java
@@ -0,0 +1,155 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.SkinParamBackcoloredReference;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.sequencediagram.Delay;
+import net.sourceforge.plantuml.sequencediagram.Divider;
+import net.sourceforge.plantuml.sequencediagram.Event;
+import net.sourceforge.plantuml.sequencediagram.GroupingLeaf;
+import net.sourceforge.plantuml.sequencediagram.GroupingStart;
+import net.sourceforge.plantuml.sequencediagram.GroupingType;
+import net.sourceforge.plantuml.sequencediagram.LifeEvent;
+import net.sourceforge.plantuml.sequencediagram.Message;
+import net.sourceforge.plantuml.sequencediagram.MessageExo;
+import net.sourceforge.plantuml.sequencediagram.Note;
+import net.sourceforge.plantuml.sequencediagram.NotePosition;
+import net.sourceforge.plantuml.sequencediagram.Reference;
+import net.sourceforge.plantuml.skin.Skin;
+
+public class TileBuilder {
+
+ public static List<Tile> buildSeveral(Iterator<Event> it, TileArguments tileArguments, Tile parent) {
+ final List<Tile> tiles = new ArrayList<Tile>();
+ while (it.hasNext()) {
+ final Event ev = it.next();
+ final Tile tile = TileBuilder.buildOne(it, tileArguments, ev, parent);
+ if (tile != null) {
+ tiles.add(tile);
+ tileArguments.getOmega().ensureBiggerThan(tile.getMaxX(tileArguments.getStringBounder()));
+ }
+ }
+ return Collections.unmodifiableList(tiles);
+ }
+
+ public static Tile buildOne(Iterator<Event> it, TileArguments tileArguments, final Event ev, Tile parent) {
+
+ final StringBounder stringBounder = tileArguments.getStringBounder();
+ final Skin skin = tileArguments.getSkin();
+ final ISkinParam skinParam = tileArguments.getSkinParam();
+ final LivingSpaces livingSpaces = tileArguments.getLivingSpaces();
+
+ Tile tile = null;
+ // System.err.println("TileBuilder::buildOne " + ev);
+ if (ev instanceof Message) {
+ final Message msg = (Message) ev;
+ final LivingSpace livingSpace1 = livingSpaces.get(msg.getParticipant1());
+ final LivingSpace livingSpace2 = livingSpaces.get(msg.getParticipant2());
+ boolean reverse = false;
+ if (msg.isSelfMessage()) {
+ tile = new CommunicationTileSelf(livingSpace1, msg, skin, skinParam, livingSpaces);
+ } else {
+ // System.err.println("msg=" + msg);
+ tile = new CommunicationTile(livingSpace1, livingSpace2, msg, skin, skinParam);
+ reverse = ((CommunicationTile) tile).isReverse(stringBounder);
+ }
+ if (msg.getNote() != null) {
+ final NotePosition notePosition = msg.getNotePosition();
+ if (notePosition == NotePosition.LEFT) {
+ tile = new CommunicationTileNoteLeft((TileWithUpdateStairs) tile, msg, skin, skinParam,
+ reverse ? livingSpace2 : livingSpace1);
+ } else if (notePosition == NotePosition.RIGHT && msg.isSelfMessage()) {
+ tile = new CommunicationTileSelfNoteRight((CommunicationTileSelf) tile, msg, skin, skinParam);
+ } else if (notePosition == NotePosition.RIGHT) {
+ tile = new CommunicationTileNoteRight((TileWithUpdateStairs) tile, msg, skin, skinParam,
+ reverse ? livingSpace1 : livingSpace2);
+ }
+ }
+ } else if (ev instanceof MessageExo) {
+ final MessageExo exo = (MessageExo) ev;
+ final LivingSpace livingSpace1 = livingSpaces.get(exo.getParticipant());
+ tile = new CommunicationExoTile(livingSpace1, exo, skin, skinParam, tileArguments.getOrigin(),
+ tileArguments.getOmega());
+ if (exo.getNote() != null) {
+ final NotePosition notePosition = exo.getNotePosition();
+ if (notePosition == NotePosition.LEFT) {
+ tile = new CommunicationTileNoteLeft((TileWithUpdateStairs) tile, exo, skin, skinParam,
+ livingSpace1);
+ } else if (notePosition == NotePosition.RIGHT) {
+ tile = new CommunicationTileNoteRight((TileWithUpdateStairs) tile, exo, skin, skinParam,
+ livingSpace1);
+ }
+ }
+ } else if (ev instanceof Note) {
+ final Note note = (Note) ev;
+ final LivingSpace livingSpace1 = livingSpaces.get(note.getParticipant());
+ final LivingSpace livingSpace2 = note.getParticipant2() == null ? null : livingSpaces.get(note
+ .getParticipant2());
+ tile = new NoteTile(livingSpace1, livingSpace2, note, skin, skinParam);
+ } else if (ev instanceof Divider) {
+ final Divider divider = (Divider) ev;
+ tile = new DividerTile(divider, skin, skinParam, tileArguments.getOrigin(), tileArguments.getOmega());
+ } else if (ev instanceof GroupingStart) {
+ final GroupingStart start = (GroupingStart) ev;
+ tile = new GroupingTile(it, start, tileArguments.withBackColorGeneral(start.getBackColorElement(),
+ start.getBackColorGeneral()), tileArguments);
+ // tile = TileUtils.withMargin(tile, 10, 10, 10, 10);
+ } else if (ev instanceof GroupingLeaf && ((GroupingLeaf) ev).getType() == GroupingType.ELSE) {
+ final GroupingLeaf anElse = (GroupingLeaf) ev;
+ tile = new ElseTile(anElse, skin, skinParam, parent);
+ } else if (ev instanceof Reference) {
+ final Reference ref = (Reference) ev;
+ tile = new ReferenceTile(ref, tileArguments.withBackColor(ref));
+ } else if (ev instanceof Delay) {
+ final Delay delay = (Delay) ev;
+ tile = new DelayTile(delay, tileArguments);
+ } else if (ev instanceof LifeEvent) {
+ final LifeEvent lifeEvent = (LifeEvent) ev;
+ final LivingSpace livingSpace = livingSpaces.get(lifeEvent.getParticipant());
+ tile = new LifeEventTile(lifeEvent, tileArguments, livingSpace, skin, skinParam);
+ } else {
+ System.err.println("TileBuilder::Ignoring " + ev.getClass());
+ }
+ return tile;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/TileMarged.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/TileMarged.java
new file mode 100644
index 0000000..b9f698d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/TileMarged.java
@@ -0,0 +1,84 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.real.Real;
+import net.sourceforge.plantuml.sequencediagram.Event;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class TileMarged implements Tile {
+
+ private final Tile tile;
+ private final double x1;
+ private final double x2;
+ private final double y1;
+ private final double y2;
+
+ public TileMarged(Tile tile, double x1, double x2, double y1, double y2) {
+ this.tile = tile;
+ this.x1 = x1;
+ this.x2 = x2;
+ this.y1 = y1;
+ this.y2 = y2;
+ }
+
+ public void drawU(UGraphic ug) {
+ tile.drawU(ug.apply(new UTranslate(x1, y1)));
+
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return tile.getPreferredHeight(stringBounder) + y1 + y2;
+ }
+
+ public void addConstraints(StringBounder stringBounder) {
+ tile.addConstraints(stringBounder);
+ }
+
+ public Real getMinX(StringBounder stringBounder) {
+ return tile.getMinX(stringBounder);
+ }
+
+ public Real getMaxX(StringBounder stringBounder) {
+ return tile.getMaxX(stringBounder).addFixed(x1 + x2);
+ }
+
+ public Event getEvent() {
+ return tile.getEvent();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/TileUtils.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/TileUtils.java
new file mode 100644
index 0000000..2307fa9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/TileUtils.java
@@ -0,0 +1,43 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+public class TileUtils {
+
+ private static Tile withMargin(Tile tile, double x1, double x2, double y1, double y2) {
+ return new TileMarged(tile, x1, x2, y1, y2);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/TileWithUpdateStairs.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/TileWithUpdateStairs.java
new file mode 100644
index 0000000..ebb7266
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/TileWithUpdateStairs.java
@@ -0,0 +1,42 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+
+public interface TileWithUpdateStairs extends Tile {
+
+ public void updateStairs(StringBounder stringBounder, double y);
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/UGraphicInterceptorTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/UGraphicInterceptorTile.java
new file mode 100644
index 0000000..2a13a9a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/UGraphicInterceptorTile.java
@@ -0,0 +1,70 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import net.sourceforge.plantuml.graphic.UGraphicDelegator;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UChange;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class UGraphicInterceptorTile extends UGraphicDelegator implements Context2D {
+
+ private final boolean isBackground;
+
+ public UGraphicInterceptorTile(UGraphic ug, boolean isBackground) {
+ super(ug);
+ this.isBackground = isBackground;
+ }
+
+ public void draw(UShape shape) {
+ if (shape instanceof Tile) {
+ final Tile drawable = (Tile) shape;
+ drawable.drawU(this);
+ } else {
+ getUg().draw(shape);
+ }
+
+ }
+
+ public UGraphic apply(UChange change) {
+ return new UGraphicInterceptorTile(getUg().apply(change), isBackground);
+ }
+
+ public boolean isBackground() {
+ return isBackground;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/YPositionedTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/YPositionedTile.java
new file mode 100644
index 0000000..a9aaf6c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/YPositionedTile.java
@@ -0,0 +1,56 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.sequencediagram.teoz;
+
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class YPositionedTile implements UDrawable {
+
+ private final Tile tile;
+ private final double y;
+
+ public YPositionedTile(Tile tile, double y) {
+ this.tile = tile;
+ this.y = y;
+ }
+
+ public void drawU(UGraphic ug) {
+ // System.err.println("YPositionedTile::drawU y=" + y + " " + tile);
+ ug.apply(new UTranslate(0, y)).draw(tile);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/AbstractComponent.java b/src/net/sourceforge/plantuml/skin/AbstractComponent.java
new file mode 100644
index 0000000..f85af26
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/AbstractComponent.java
@@ -0,0 +1,98 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin;
+
+import java.awt.BasicStroke;
+import java.awt.Graphics2D;
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public abstract class AbstractComponent implements Component {
+
+ final protected void stroke(Graphics2D g2d, float dash, float thickness) {
+ final float[] style = { dash, dash };
+ g2d.setStroke(new BasicStroke(thickness, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, style, 0));
+ }
+
+ final protected UGraphic stroke(UGraphic ug, double dashVisible, double dashSpace, double thickness) {
+ return ug.apply(new UStroke(dashVisible, dashSpace, thickness));
+ }
+
+ final protected void stroke(Graphics2D g2d, float dash) {
+ stroke(g2d, dash, 1);
+ }
+
+ final protected UGraphic stroke(UGraphic ug, double dashVisible, double dashSpace) {
+ return stroke(ug, dashVisible, dashSpace, 1);
+ }
+
+ abstract protected void drawInternalU(UGraphic ug, Area area);
+
+ protected void drawBackgroundInternalU(UGraphic ug, Area area) {
+ }
+
+ public final void drawU(UGraphic ug, Area area, Context2D context) {
+ ug = ug.apply(new UTranslate(getPaddingX(), getPaddingY()));
+ if (context.isBackground()) {
+ drawBackgroundInternalU(ug, area);
+ } else {
+ drawInternalU(ug, area);
+ }
+ }
+
+ public double getPaddingX() {
+ return 0;
+ }
+
+ public double getPaddingY() {
+ return 0;
+ }
+
+ public abstract double getPreferredWidth(StringBounder stringBounder);
+
+ public abstract double getPreferredHeight(StringBounder stringBounder);
+
+ public final Dimension2D getPreferredDimension(StringBounder stringBounder) {
+ final double w = getPreferredWidth(stringBounder);
+ final double h = getPreferredHeight(stringBounder);
+ return new Dimension2DDouble(w, h);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/AbstractTextualComponent.java b/src/net/sourceforge/plantuml/skin/AbstractTextualComponent.java
new file mode 100644
index 0000000..457e155
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/AbstractTextualComponent.java
@@ -0,0 +1,147 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.cucadiagram.BodyEnhanced2;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockEmpty;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public abstract class AbstractTextualComponent extends AbstractComponent {
+
+ private final Display strings;
+
+ private final int marginX1;
+ private final int marginX2;
+ private final int marginY;
+
+ private final TextBlock textBlock;
+
+ private final UFont font;
+ private final HtmlColor fontColor;
+
+ public AbstractTextualComponent(CharSequence label, FontConfiguration font,
+ HorizontalAlignment horizontalAlignment, int marginX1, int marginX2, int marginY,
+ ISkinSimple spriteContainer, double maxMessageSize, UFont fontForStereotype,
+ HtmlColor htmlColorForStereotype) {
+ this(Display.getWithNewlines(label == null ? "" : label.toString()), font, horizontalAlignment, marginX1,
+ marginX2, marginY, spriteContainer, maxMessageSize, false, fontForStereotype, htmlColorForStereotype);
+ }
+
+ public AbstractTextualComponent(Display strings, FontConfiguration font, HorizontalAlignment horizontalAlignment,
+ int marginX1, int marginX2, int marginY, ISkinSimple spriteContainer, double maxMessageSize,
+ boolean enhanced, UFont fontForStereotype, HtmlColor htmlColorForStereotype) {
+ this.font = font.getFont();
+ this.fontColor = font.getColor();
+ this.marginX1 = marginX1;
+ this.marginX2 = marginX2;
+ this.marginY = marginY;
+ this.strings = strings;
+
+ if (strings.size() == 1 && strings.get(0).length() == 0) {
+ textBlock = new TextBlockEmpty();
+ } else if (enhanced) {
+ textBlock = new BodyEnhanced2(strings, FontParam.NOTE, spriteContainer, HorizontalAlignment.LEFT, font);
+ } else {
+ textBlock = TextBlockUtils.create(strings, font, horizontalAlignment, spriteContainer, maxMessageSize,
+ false, fontForStereotype, htmlColorForStereotype);
+ }
+ }
+
+ final protected TextBlock getTextBlock() {
+ return textBlock;
+ }
+
+ final protected double getPureTextWidth(StringBounder stringBounder) {
+ final TextBlock textBlock = getTextBlock();
+ final Dimension2D size = textBlock.calculateDimension(stringBounder);
+ return size.getWidth();
+ }
+
+ final public double getTextWidth(StringBounder stringBounder) {
+ return getPureTextWidth(stringBounder) + marginX1 + marginX2;
+ }
+
+ // // For cache
+ // private Dimension2D size;
+ //
+ // private Dimension2D getSize(StringBounder stringBounder, final TextBlock textBlock) {
+ // if (size == null) {
+ // size = textBlock.calculateDimension(stringBounder);
+ // }
+ // return size;
+ // }
+
+ final protected double getTextHeight(StringBounder stringBounder) {
+ final TextBlock textBlock = getTextBlock();
+ final Dimension2D size = textBlock.calculateDimension(stringBounder);
+ return size.getHeight() + 2 * marginY;
+ }
+
+ final protected Display getLabels() {
+ return strings;
+ }
+
+ final protected int getMarginX1() {
+ return marginX1;
+ }
+
+ final protected int getMarginX2() {
+ return marginX2;
+ }
+
+ final protected int getMarginY() {
+ return marginY;
+ }
+
+ final protected UFont getFont() {
+ return font;
+ }
+
+ protected HtmlColor getFontColor() {
+ return fontColor;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/Area.java b/src/net/sourceforge/plantuml/skin/Area.java
new file mode 100644
index 0000000..b0ae45d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/Area.java
@@ -0,0 +1,71 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+
+public class Area {
+
+ private final Dimension2D dimensionToUse;
+ private double deltaX1;
+
+ @Override
+ public String toString() {
+ return dimensionToUse.toString() + " (" + deltaX1 + ")";
+ }
+
+ public Area(Dimension2D dimensionToUse) {
+ this.dimensionToUse = dimensionToUse;
+ }
+
+ public Area(double with, double height) {
+ this(new Dimension2DDouble(with, height));
+ }
+
+ public Dimension2D getDimensionToUse() {
+ return dimensionToUse;
+ }
+
+ public void setDeltaX1(double deltaX1) {
+ this.deltaX1 = deltaX1;
+ }
+
+ public final double getDeltaX1() {
+ return deltaX1;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/ArrowBody.java b/src/net/sourceforge/plantuml/skin/ArrowBody.java
new file mode 100644
index 0000000..102793b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/ArrowBody.java
@@ -0,0 +1,39 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin;
+
+public enum ArrowBody {
+ NORMAL, DOTTED;
+}
diff --git a/src/net/sourceforge/plantuml/skin/ArrowComponent.java b/src/net/sourceforge/plantuml/skin/ArrowComponent.java
new file mode 100644
index 0000000..0bdcb48
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/ArrowComponent.java
@@ -0,0 +1,50 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+
+public interface ArrowComponent extends Component {
+
+ Point2D getStartPoint(StringBounder stringBounder, Dimension2D dimensionToUse);
+
+ Point2D getEndPoint(StringBounder stringBounder, Dimension2D dimensionToUse);
+
+ double getPaddingY();
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/ArrowConfiguration.java b/src/net/sourceforge/plantuml/skin/ArrowConfiguration.java
new file mode 100644
index 0000000..77bb02a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/ArrowConfiguration.java
@@ -0,0 +1,213 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+
+public class ArrowConfiguration {
+
+ private final ArrowBody body;
+
+ private final ArrowDressing dressing1;
+ private final ArrowDressing dressing2;
+
+ private final ArrowDecoration decoration1;
+ private final ArrowDecoration decoration2;
+
+ private final HtmlColor color;
+
+ private final boolean isSelf;
+
+ private ArrowConfiguration(ArrowBody body, ArrowDressing dressing1, ArrowDressing dressing2,
+ ArrowDecoration decoration1, ArrowDecoration decoration2, HtmlColor color, boolean isSelf) {
+ if (body == null || dressing1 == null || dressing2 == null) {
+ throw new IllegalArgumentException();
+ }
+ this.body = body;
+ this.dressing1 = dressing1;
+ this.dressing2 = dressing2;
+ this.decoration1 = decoration1;
+ this.decoration2 = decoration2;
+ this.color = color;
+ this.isSelf = isSelf;
+ }
+
+ @Override
+ public String toString() {
+ return name();
+ }
+
+ public String name() {
+ return body.name() + "(" + dressing1.name() + " " + decoration1 + ")(" + dressing2.name() + " " + decoration2
+ + ")" + isSelf + " " + color;
+ }
+
+ public static ArrowConfiguration withDirectionNormal() {
+ return new ArrowConfiguration(ArrowBody.NORMAL, ArrowDressing.create(), ArrowDressing.create().withHead(
+ ArrowHead.NORMAL), ArrowDecoration.NONE, ArrowDecoration.NONE, null, false);
+ }
+
+ public static ArrowConfiguration withDirectionBoth() {
+ return new ArrowConfiguration(ArrowBody.NORMAL, ArrowDressing.create().withHead(ArrowHead.NORMAL),
+ ArrowDressing.create().withHead(ArrowHead.NORMAL), ArrowDecoration.NONE, ArrowDecoration.NONE, null,
+ false);
+ }
+
+ public static ArrowConfiguration withDirectionSelf() {
+ return new ArrowConfiguration(ArrowBody.NORMAL, ArrowDressing.create().withHead(ArrowHead.NORMAL),
+ ArrowDressing.create().withHead(ArrowHead.NORMAL), ArrowDecoration.NONE, ArrowDecoration.NONE, null,
+ true);
+ }
+
+ public static ArrowConfiguration withDirectionReverse() {
+ return withDirectionNormal().reverse();
+ }
+
+ public ArrowConfiguration reverse() {
+ return new ArrowConfiguration(body, dressing2, dressing1, decoration2, decoration1, color, isSelf);
+ }
+
+ public ArrowConfiguration self() {
+ return new ArrowConfiguration(body, dressing1, dressing2, decoration1, decoration2, color, true);
+ }
+
+ public ArrowConfiguration withDotted() {
+ return new ArrowConfiguration(ArrowBody.DOTTED, dressing1, dressing2, decoration1, decoration2, color, isSelf);
+ }
+
+ public ArrowConfiguration withHead(ArrowHead head) {
+ final ArrowDressing newDressing1 = addHead(dressing1, head);
+ final ArrowDressing newDressing2 = addHead(dressing2, head);
+ return new ArrowConfiguration(body, newDressing1, newDressing2, decoration1, decoration2, color, isSelf);
+ }
+
+ private static ArrowDressing addHead(ArrowDressing dressing, ArrowHead head) {
+ if (dressing.getHead() == ArrowHead.NONE) {
+ return dressing;
+ }
+ return dressing.withHead(head);
+ }
+
+ public ArrowConfiguration withHead1(ArrowHead head) {
+ return new ArrowConfiguration(body, dressing1.withHead(head), dressing2, decoration1, decoration2, color,
+ isSelf);
+ }
+
+ public ArrowConfiguration withHead2(ArrowHead head) {
+ return new ArrowConfiguration(body, dressing1, dressing2.withHead(head), decoration1, decoration2, color,
+ isSelf);
+ }
+
+ public ArrowConfiguration withPart(ArrowPart part) {
+ if (dressing2.getHead() != ArrowHead.NONE) {
+ return new ArrowConfiguration(body, dressing1, dressing2.withPart(part), decoration1, decoration2, color,
+ isSelf);
+ }
+ return new ArrowConfiguration(body, dressing1.withPart(part), dressing2, decoration1, decoration2, color,
+ isSelf);
+ }
+
+ public ArrowConfiguration withDecoration1(ArrowDecoration decoration1) {
+ return new ArrowConfiguration(body, dressing1, dressing2, decoration1, decoration2, color, isSelf);
+ }
+
+ public ArrowConfiguration withDecoration2(ArrowDecoration decoration2) {
+ return new ArrowConfiguration(body, dressing1, dressing2, decoration1, decoration2, color, isSelf);
+ }
+
+ public ArrowConfiguration withColor(HtmlColor color) {
+ return new ArrowConfiguration(body, dressing1, dressing2, decoration1, decoration2, color, isSelf);
+ }
+
+ public final ArrowDecoration getDecoration1() {
+ return this.decoration1;
+ }
+
+ public final ArrowDecoration getDecoration2() {
+ return this.decoration2;
+ }
+
+ public final ArrowDirection getArrowDirection() {
+ if (isSelf) {
+ return ArrowDirection.SELF;
+ }
+ if (this.dressing1.getHead() == ArrowHead.NONE && this.dressing2.getHead() != ArrowHead.NONE) {
+ return ArrowDirection.LEFT_TO_RIGHT_NORMAL;
+ }
+ if (this.dressing1.getHead() != ArrowHead.NONE && this.dressing2.getHead() == ArrowHead.NONE) {
+ return ArrowDirection.RIGHT_TO_LEFT_REVERSE;
+ }
+ return ArrowDirection.BOTH_DIRECTION;
+ }
+
+ public boolean isSelfArrow() {
+ return getArrowDirection() == ArrowDirection.SELF;
+ }
+
+ public boolean isDotted() {
+ return body == ArrowBody.DOTTED;
+ }
+
+ public ArrowHead getHead() {
+ if (dressing2 != null && dressing2.getHead() != ArrowHead.NONE) {
+ return dressing2.getHead();
+ }
+ return dressing1.getHead();
+ }
+
+ public boolean isAsync() {
+ return dressing1.getHead() == ArrowHead.ASYNC || dressing2.getHead() == ArrowHead.ASYNC;
+ }
+
+ public final ArrowPart getPart() {
+ if (dressing2.getHead() != ArrowHead.NONE) {
+ return dressing2.getPart();
+ }
+ return dressing1.getPart();
+ }
+
+ public HtmlColor getColor() {
+ return color;
+ }
+
+ public ArrowDressing getDressing1() {
+ return dressing1;
+ }
+
+ public ArrowDressing getDressing2() {
+ return dressing2;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/ArrowDecoration.java b/src/net/sourceforge/plantuml/skin/ArrowDecoration.java
new file mode 100644
index 0000000..8d38ea2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/ArrowDecoration.java
@@ -0,0 +1,39 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin;
+
+public enum ArrowDecoration {
+ NONE, CIRCLE
+}
diff --git a/src/net/sourceforge/plantuml/skin/ArrowDirection.java b/src/net/sourceforge/plantuml/skin/ArrowDirection.java
new file mode 100644
index 0000000..6ee24d0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/ArrowDirection.java
@@ -0,0 +1,52 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin;
+
+
+public enum ArrowDirection {
+ LEFT_TO_RIGHT_NORMAL, RIGHT_TO_LEFT_REVERSE, SELF, BOTH_DIRECTION;
+
+ public ArrowDirection reverse() {
+ switch (this) {
+ case LEFT_TO_RIGHT_NORMAL:
+ return RIGHT_TO_LEFT_REVERSE;
+ case RIGHT_TO_LEFT_REVERSE:
+ return LEFT_TO_RIGHT_NORMAL;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/ArrowDressing.java b/src/net/sourceforge/plantuml/skin/ArrowDressing.java
new file mode 100644
index 0000000..5416e62
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/ArrowDressing.java
@@ -0,0 +1,81 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin;
+
+public class ArrowDressing {
+
+ private final ArrowHead head;
+ private final ArrowPart part;
+ // private final ArrowDecoration decoration;
+
+ public String name() {
+ return toString();
+ }
+
+ @Override
+ public String toString() {
+ return head.name();
+ }
+
+ private ArrowDressing(ArrowHead head, ArrowPart part) {
+ if (head == null || part == null) {
+ throw new IllegalArgumentException();
+ }
+ this.head = head;
+ this.part = part;
+ }
+
+ public static ArrowDressing create() {
+ return new ArrowDressing(ArrowHead.NONE, ArrowPart.FULL);
+ }
+
+ public ArrowDressing withHead(ArrowHead head) {
+ return new ArrowDressing(head, part);
+ }
+
+ public ArrowDressing withPart(ArrowPart part) {
+ return new ArrowDressing(head, part);
+ }
+
+ public ArrowHead getHead() {
+ return head;
+ }
+
+ public ArrowPart getPart() {
+ return part;
+ }
+
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/ArrowHead.java b/src/net/sourceforge/plantuml/skin/ArrowHead.java
new file mode 100644
index 0000000..562f8ce
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/ArrowHead.java
@@ -0,0 +1,39 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin;
+
+public enum ArrowHead {
+ NORMAL, CROSSX, ASYNC, NONE
+}
diff --git a/src/net/sourceforge/plantuml/skin/ArrowPart.java b/src/net/sourceforge/plantuml/skin/ArrowPart.java
new file mode 100644
index 0000000..08ba7cc
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/ArrowPart.java
@@ -0,0 +1,39 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin;
+
+public enum ArrowPart {
+ FULL, TOP_PART, BOTTOM_PART
+}
diff --git a/src/net/sourceforge/plantuml/skin/CircleInterface.java b/src/net/sourceforge/plantuml/skin/CircleInterface.java
new file mode 100644
index 0000000..dc6afda
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/CircleInterface.java
@@ -0,0 +1,80 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class CircleInterface implements UDrawable {
+
+ private final float thickness;
+ private final double headDiam;
+ private final HtmlColor backgroundColor;
+ private final HtmlColor foregroundColor;
+
+ public CircleInterface(HtmlColor backgroundColor, HtmlColor foregroundColor) {
+ this(backgroundColor, foregroundColor, 16, 2);
+ }
+
+ public CircleInterface(HtmlColor backgroundColor, HtmlColor foregroundColor, double headDiam, float thickness) {
+ this.backgroundColor = backgroundColor;
+ this.foregroundColor = foregroundColor;
+ this.headDiam = headDiam;
+ this.thickness = thickness;
+ }
+
+ public void drawU(UGraphic ug) {
+ final UEllipse head = new UEllipse(headDiam, headDiam);
+
+ ug.apply(new UStroke(thickness)).apply(new UChangeBackColor(backgroundColor))
+ .apply(new UChangeColor(foregroundColor)).apply(new UTranslate((double) thickness, (double) thickness)).draw(head);
+ }
+
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return headDiam + 2 * thickness;
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return headDiam + 2 * thickness;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/Component.java b/src/net/sourceforge/plantuml/skin/Component.java
new file mode 100644
index 0000000..2701e42
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/Component.java
@@ -0,0 +1,52 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public interface Component {
+
+ Dimension2D getPreferredDimension(StringBounder stringBounder);
+
+ double getPreferredWidth(StringBounder stringBounder);
+
+ double getPreferredHeight(StringBounder stringBounder);
+
+ void drawU(UGraphic ug, Area area, Context2D context);
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/ComponentType.java b/src/net/sourceforge/plantuml/skin/ComponentType.java
new file mode 100644
index 0000000..3420f5e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/ComponentType.java
@@ -0,0 +1,69 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin;
+
+public enum ComponentType {
+
+ ARROW,
+
+ ACTOR_HEAD, ACTOR_TAIL,
+
+ BOUNDARY_HEAD, BOUNDARY_TAIL,
+ CONTROL_HEAD, CONTROL_TAIL,
+ ENTITY_HEAD, ENTITY_TAIL,
+ DATABASE_HEAD, DATABASE_TAIL,
+
+ //
+ ALIVE_BOX_CLOSE_CLOSE, ALIVE_BOX_CLOSE_OPEN, ALIVE_BOX_OPEN_CLOSE, ALIVE_BOX_OPEN_OPEN,
+
+ DELAY_TEXT, DESTROY,
+
+ DELAY_LINE, PARTICIPANT_LINE, CONTINUE_LINE,
+
+ //
+ GROUPING_ELSE, GROUPING_HEADER, GROUPING_SPACE,
+ //
+ NEWPAGE, NOTE, NOTE_HEXAGONAL, NOTE_BOX, DIVIDER, REFERENCE, ENGLOBER,
+
+ //
+ PARTICIPANT_HEAD, PARTICIPANT_TAIL,
+
+ //
+ TITLE, SIGNATURE;
+
+ public boolean isArrow() {
+ return this == ARROW;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/skin/Context2D.java b/src/net/sourceforge/plantuml/skin/Context2D.java
new file mode 100644
index 0000000..1c4e00f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/Context2D.java
@@ -0,0 +1,39 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin;
+
+public interface Context2D {
+ boolean isBackground();
+}
diff --git a/src/net/sourceforge/plantuml/skin/GrayComponent.java b/src/net/sourceforge/plantuml/skin/GrayComponent.java
new file mode 100644
index 0000000..21704c8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/GrayComponent.java
@@ -0,0 +1,93 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin;
+
+import java.awt.Font;
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.SpriteContainerEmpty;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+
+class GrayComponent extends AbstractComponent {
+
+ private static final UFont NORMAL = new UFont("SansSerif", Font.PLAIN, 7);
+
+ private final ComponentType type;
+
+ public GrayComponent(ComponentType type) {
+ this.type = type;
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, Area area) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ ug = ug.apply(new UChangeBackColor(HtmlColorUtils.LIGHT_GRAY)).apply(new UChangeColor(HtmlColorUtils.BLACK));
+ ug.draw(new URectangle(getPreferredWidth(stringBounder), getPreferredHeight(stringBounder)));
+
+ final String n = type.name();
+ final int split = 9;
+ final List<String> strings = new ArrayList<String>();
+ for (int i = 0; i < n.length(); i += split) {
+ strings.add(n.substring(i, Math.min(i + split, n.length())));
+ }
+
+ final TextBlock textBlock = TextBlockUtils.create(Display.create(strings), new FontConfiguration(NORMAL, HtmlColorUtils.BLACK,
+ HtmlColorUtils.BLUE, true), HorizontalAlignment.LEFT, new SpriteContainerEmpty());
+ textBlock.drawU(ug);
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return 42;
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return 42;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/ProtectedSkin.java b/src/net/sourceforge/plantuml/skin/ProtectedSkin.java
new file mode 100644
index 0000000..45cc87e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/ProtectedSkin.java
@@ -0,0 +1,65 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.cucadiagram.Display;
+
+public class ProtectedSkin implements Skin {
+
+ final private Skin skinToProtect;
+
+ public ProtectedSkin(Skin skinToProtect) {
+ this.skinToProtect = skinToProtect;
+
+ }
+
+ public Component createComponent(ComponentType type, ArrowConfiguration config, ISkinParam param, Display stringsToDisplay) {
+ Component result = null;
+ try {
+ result = skinToProtect.createComponent(type, config, param, stringsToDisplay);
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ if (result == null) {
+ return new GrayComponent(type);
+ }
+ return result;
+ }
+
+ public Object getProtocolVersion() {
+ return skinToProtect.getProtocolVersion();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/skin/SimpleContext2D.java b/src/net/sourceforge/plantuml/skin/SimpleContext2D.java
new file mode 100644
index 0000000..84eb6dc
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/SimpleContext2D.java
@@ -0,0 +1,49 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin;
+
+public class SimpleContext2D implements Context2D {
+
+ private final boolean isBackground;
+
+ public SimpleContext2D(boolean isBackground) {
+ this.isBackground = isBackground;
+ }
+
+ public boolean isBackground() {
+ return isBackground;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/Skin.java b/src/net/sourceforge/plantuml/skin/Skin.java
new file mode 100644
index 0000000..0232273
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/Skin.java
@@ -0,0 +1,46 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.cucadiagram.Display;
+
+public interface Skin {
+
+ Object getProtocolVersion();
+
+ Component createComponent(ComponentType type, ArrowConfiguration config, ISkinParam param, Display stringsToDisplay);
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/SkinUtils.java b/src/net/sourceforge/plantuml/skin/SkinUtils.java
new file mode 100644
index 0000000..63b01f2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/SkinUtils.java
@@ -0,0 +1,79 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.Log;
+import net.sourceforge.plantuml.StringUtils;
+
+public class SkinUtils {
+
+ static public Skin loadSkin(String className) {
+ final List<String> errors = new ArrayList<String>();
+ Skin result = tryLoading(className, errors);
+ if (result != null) {
+ return result;
+ }
+ result = tryLoading("net.sourceforge.plantuml.skin." + className, errors);
+ if (result != null) {
+ return result;
+ }
+ final String packageName = StringUtils.goLowerCase(className);
+ result = tryLoading(packageName + "." + className, errors);
+ if (result != null) {
+ return result;
+ }
+ result = tryLoading("net.sourceforge.plantuml.skin." + packageName + "." + className, errors);
+ if (result != null) {
+ return result;
+ }
+ for (String e : errors) {
+ Log.println("err="+e);
+ }
+ return null;
+ }
+
+ private static Skin tryLoading(String className, List<String> errors) {
+ try {
+ final Class<Skin> cl = (Class<Skin>) Class.forName(className);
+ return cl.newInstance();
+ } catch (Exception e) {
+ errors.add("Cannot load " + className);
+ return null;
+ }
+ }
+}
diff --git a/src/net/sourceforge/plantuml/skin/StickMan.java b/src/net/sourceforge/plantuml/skin/StickMan.java
new file mode 100644
index 0000000..33c27e5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/StickMan.java
@@ -0,0 +1,114 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.SymbolContext;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class StickMan implements TextBlock {
+
+ private final double armsY = 8;
+ private final double armsLenght = 13;
+ private final double bodyLenght = 27;
+ private final double legsX = 13;
+ private final double legsY = 15;
+ private final double headDiam = 16;
+
+ private final SymbolContext symbolContext;
+
+ public StickMan(SymbolContext symbolContext) {
+ this.symbolContext = symbolContext;
+ }
+
+ private StickMan(HtmlColor backgroundColor, HtmlColor foregroundColor, double deltaShadow) {
+ this(new SymbolContext(backgroundColor, foregroundColor).withDeltaShadow(deltaShadow).withStroke(new UStroke(2)));
+ }
+
+ public StickMan(HtmlColor backgroundColor, HtmlColor foregroundColor) {
+ this(new SymbolContext(backgroundColor, foregroundColor).withStroke(new UStroke(2)));
+ }
+
+ public void drawU(UGraphic ug) {
+
+ final double startX = Math.max(armsLenght, legsX) - headDiam / 2.0 + thickness();
+
+ final UEllipse head = new UEllipse(headDiam, headDiam);
+ final double centerX = startX + headDiam / 2;
+
+ final UPath path = new UPath();
+ path.moveTo(0, 0);
+ path.lineTo(0, bodyLenght);
+ path.moveTo(-armsLenght, armsY);
+ path.lineTo(armsLenght, armsY);
+ path.moveTo(0, bodyLenght);
+ path.lineTo(-legsX, bodyLenght + legsY);
+ path.moveTo(0, bodyLenght);
+ path.lineTo(legsX, bodyLenght + legsY);
+ if (symbolContext.getDeltaShadow() != 0) {
+ head.setDeltaShadow(symbolContext.getDeltaShadow());
+ path.setDeltaShadow(symbolContext.getDeltaShadow());
+ }
+
+ ug = symbolContext.apply(ug);
+ ug.apply(new UTranslate(startX, thickness())).draw(head);
+ ug.apply(new UTranslate(centerX, headDiam + thickness())).draw(path);
+ }
+
+ private double thickness() {
+ return symbolContext.getStroke().getThickness();
+ }
+
+ public double getPreferredWidth() {
+ return Math.max(armsLenght, legsX) * 2 + 2 * thickness();
+ }
+
+ public double getPreferredHeight() {
+ return headDiam + bodyLenght + legsY + 2 * thickness() + symbolContext.getDeltaShadow() + 1;
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(getPreferredWidth(), getPreferredHeight());
+ }
+}
diff --git a/src/net/sourceforge/plantuml/skin/VisibilityModifier.java b/src/net/sourceforge/plantuml/skin/VisibilityModifier.java
new file mode 100644
index 0000000..186484f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/VisibilityModifier.java
@@ -0,0 +1,235 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public enum VisibilityModifier {
+ PRIVATE_FIELD(ColorParam.iconPrivate, null), PROTECTED_FIELD(ColorParam.iconProtected, null), PACKAGE_PRIVATE_FIELD(
+ ColorParam.iconPackage, null), PUBLIC_FIELD(ColorParam.iconPublic, null),
+
+ PRIVATE_METHOD(ColorParam.iconPrivate, ColorParam.iconPrivateBackground), PROTECTED_METHOD(
+ ColorParam.iconProtected, ColorParam.iconProtectedBackground), PACKAGE_PRIVATE_METHOD(
+ ColorParam.iconPackage, ColorParam.iconPackageBackground), PUBLIC_METHOD(ColorParam.iconPublic,
+ ColorParam.iconPublicBackground);
+
+ private final ColorParam foregroundParam;
+ private final ColorParam backgroundParam;
+
+ private VisibilityModifier(ColorParam foreground, ColorParam background) {
+ this.foregroundParam = foreground;
+ this.backgroundParam = background;
+ }
+
+ public UDrawable getUDrawable(final int size, final HtmlColor foregroundColor, final HtmlColor backgoundColor) {
+ return new UDrawable() {
+ public void drawU(UGraphic ug) {
+ drawInternal(ug, size, foregroundColor, backgoundColor, 0, 0);
+ }
+
+ };
+ }
+
+ public TextBlock getUBlock(final int size, final HtmlColor foregroundColor, final HtmlColor backgoundColor) {
+ return new TextBlock() {
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(size + 1, size + 1);
+ }
+
+ public void drawU(UGraphic ug) {
+ // final double tx = ug.getTranslateX();
+ // final double ty = ug.getTranslateY();
+ // ug.translate(x, y);F
+ drawInternal(ug, size, foregroundColor, backgoundColor, 0, 0);
+ // ug.setTranslate(tx, ty);
+ }
+ };
+ }
+
+ private void drawInternal(UGraphic ug, int size, final HtmlColor foregroundColor, final HtmlColor backgoundColor,
+ double x, double y) {
+ ug = ug.apply(new UChangeBackColor(backgoundColor)).apply(new UChangeColor(foregroundColor));
+ size = ensureEven(size);
+ switch (this) {
+ case PACKAGE_PRIVATE_FIELD:
+ drawTriangle(ug, false, size, x, y);
+ break;
+
+ case PRIVATE_FIELD:
+ drawSquare(ug, false, size, x, y);
+ break;
+
+ case PROTECTED_FIELD:
+ drawDiamond(ug, false, size, x, y);
+ break;
+
+ case PUBLIC_FIELD:
+ drawCircle(ug, false, size, x, y);
+ break;
+
+ case PACKAGE_PRIVATE_METHOD:
+ drawTriangle(ug, true, size, x, y);
+ break;
+
+ case PRIVATE_METHOD:
+ drawSquare(ug, true, size, x, y);
+ break;
+
+ case PROTECTED_METHOD:
+ drawDiamond(ug, true, size, x, y);
+ break;
+
+ case PUBLIC_METHOD:
+ drawCircle(ug, true, size, x, y);
+ break;
+
+ default:
+ throw new IllegalStateException();
+ }
+ }
+
+ private void drawSquare(UGraphic ug, boolean filled, int size, double x, double y) {
+ ug.apply(new UTranslate(x + 2, y + 2)).draw(new URectangle(size - 4, size - 4));
+ }
+
+ private void drawCircle(UGraphic ug, boolean filled, int size, double x, double y) {
+ ug.apply(new UTranslate(x + 2, y + 2)).draw(new UEllipse(size - 4, size - 4));
+ }
+
+ static private int ensureEven(int n) {
+ if (n % 2 == 1) {
+ n--;
+ }
+ return n;
+ }
+
+ private void drawDiamond(UGraphic ug, boolean filled, int size, double x, double y) {
+ final UPolygon poly = new UPolygon();
+ size -= 2;
+ poly.addPoint(size / 2.0, 0);
+ poly.addPoint(size, size / 2.0);
+ poly.addPoint(size / 2.0, size);
+ poly.addPoint(0, size / 2.0);
+ ug.apply(new UTranslate(x + 1, y)).draw(poly);
+ }
+
+ private void drawTriangle(UGraphic ug, boolean filled, int size, double x, double y) {
+ final UPolygon poly = new UPolygon();
+ size -= 2;
+ poly.addPoint(size / 2.0, 1);
+ poly.addPoint(0, size - 1);
+ poly.addPoint(size, size - 1);
+ ug.apply(new UTranslate(x + 1, y)).draw(poly);
+ }
+
+ public static boolean isVisibilityCharacter(char c) {
+ if (c == '-') {
+ return true;
+ }
+ if (c == '#') {
+ return true;
+ }
+ if (c == '+') {
+ return true;
+ }
+ if (c == '~') {
+ return true;
+ }
+ return false;
+ }
+
+ public static VisibilityModifier getVisibilityModifier(char c, boolean isField) {
+ if (isField) {
+ return getVisibilityModifierForField(c);
+ }
+ return getVisibilityModifierForMethod(c);
+ }
+
+ private static VisibilityModifier getVisibilityModifierForField(char c) {
+ if (c == '-') {
+ return VisibilityModifier.PRIVATE_FIELD;
+ }
+ if (c == '#') {
+ return VisibilityModifier.PROTECTED_FIELD;
+ }
+ if (c == '+') {
+ return VisibilityModifier.PUBLIC_FIELD;
+ }
+ if (c == '~') {
+ return VisibilityModifier.PACKAGE_PRIVATE_FIELD;
+ }
+ return null;
+ }
+
+ private static VisibilityModifier getVisibilityModifierForMethod(char c) {
+ if (c == '-') {
+ return VisibilityModifier.PRIVATE_METHOD;
+ }
+ if (c == '#') {
+ return VisibilityModifier.PROTECTED_METHOD;
+ }
+ if (c == '+') {
+ return VisibilityModifier.PUBLIC_METHOD;
+ }
+ if (c == '~') {
+ return VisibilityModifier.PACKAGE_PRIVATE_METHOD;
+ }
+ return null;
+ }
+
+ public final ColorParam getForeground() {
+ return foregroundParam;
+ }
+
+ public final ColorParam getBackground() {
+ return backgroundParam;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/AbstractComponentBlueModernArrow.java b/src/net/sourceforge/plantuml/skin/bluemodern/AbstractComponentBlueModernArrow.java
new file mode 100644
index 0000000..de3a6b4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/bluemodern/AbstractComponentBlueModernArrow.java
@@ -0,0 +1,92 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin.bluemodern;
+
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.skin.AbstractTextualComponent;
+import net.sourceforge.plantuml.skin.ArrowComponent;
+import net.sourceforge.plantuml.skin.ArrowConfiguration;
+
+public abstract class AbstractComponentBlueModernArrow extends AbstractTextualComponent implements ArrowComponent {
+
+ private final int arrowDeltaX = 12;
+ private final int arrowDeltaY = 10;
+
+ private final int arrowDeltaX2 = 10;
+ private final int arrowDeltaY2 = 5;
+ private final ArrowConfiguration arrowConfiguration;
+ private final HtmlColor foregroundColor;
+
+ public AbstractComponentBlueModernArrow(HtmlColor foregroundColor, FontConfiguration font, Display stringsToDisplay, ArrowConfiguration arrowConfiguration, ISkinSimple spriteContainer) {
+ super(stringsToDisplay, font, HorizontalAlignment.LEFT, 17, 17, 2,
+ spriteContainer, 0, false, null, null);
+ this.arrowConfiguration = arrowConfiguration;
+ this.foregroundColor = foregroundColor;
+ }
+
+ protected final HtmlColor getForegroundColor() {
+ return foregroundColor;
+ }
+
+ final protected int getArrowDeltaX() {
+ return arrowDeltaX;
+ }
+
+ final protected int getArrowDeltaY() {
+ return arrowDeltaY;
+ }
+
+ final protected int getArrowDeltaY2() {
+ return arrowDeltaY2;
+ }
+
+ final protected int getArrowDeltaX2() {
+ return arrowDeltaX2;
+ }
+
+ @Override
+ public final double getPaddingY() {
+ return 6;
+ }
+
+ final protected ArrowConfiguration getArrowConfiguration() {
+ return arrowConfiguration;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/BlueModern.java b/src/net/sourceforge/plantuml/skin/bluemodern/BlueModern.java
new file mode 100644
index 0000000..6cefbeb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/bluemodern/BlueModern.java
@@ -0,0 +1,185 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin.bluemodern;
+
+import java.awt.Font;
+
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.LineParam;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.SymbolContext;
+import net.sourceforge.plantuml.skin.ArrowConfiguration;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.skin.rose.ComponentRoseDestroy;
+import net.sourceforge.plantuml.skin.rose.ComponentRoseGroupingElse;
+import net.sourceforge.plantuml.skin.rose.ComponentRoseGroupingSpace;
+import net.sourceforge.plantuml.skin.rose.ComponentRoseReference;
+import net.sourceforge.plantuml.skin.rose.ComponentRoseTitle;
+import net.sourceforge.plantuml.skin.rose.Rose;
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public class BlueModern implements Skin {
+
+ private final UFont bigFont = new UFont("SansSerif", Font.BOLD, 20);
+ private final UFont participantFont = new UFont("SansSerif", Font.PLAIN, 17);
+ private final UFont normalFont = new UFont("SansSerif", Font.PLAIN, 13);
+ private final UFont smallFont = new UFont("SansSerif", Font.BOLD, 11);
+
+ private final HtmlColor hyperlinkColor = HtmlColorUtils.BLUE;
+ private final boolean useUnderlineForHyperlink = true;
+ private final HtmlColor blue1 = HtmlColorUtils.COL_527BC6;
+ private final HtmlColor blue2 = HtmlColorUtils.COL_D1DBEF;
+ private final HtmlColor blue3 = HtmlColorUtils.COL_D7E0F2;
+
+ private final HtmlColor red = HtmlColorUtils.MY_RED;
+
+ private final HtmlColor lineColor = HtmlColorUtils.COL_989898;
+ private final HtmlColor borderGroupColor = HtmlColorUtils.COL_BBBBBB;
+
+ public Component createComponent(ComponentType type, ArrowConfiguration config, ISkinParam param,
+ Display stringsToDisplay) {
+
+ if (type.isArrow()) {
+ final HtmlColor sequenceArrow = config.getColor() == null ? HtmlColorUtils.BLACK : config.getColor();
+ if (config.isSelfArrow()) {
+ return new ComponentBlueModernSelfArrow(sequenceArrow, normalFont.toFont2(HtmlColorUtils.BLACK,
+ useUnderlineForHyperlink, hyperlinkColor), stringsToDisplay, config, param);
+ }
+ return new ComponentBlueModernArrow(sequenceArrow, useUnderlineForHyperlink, normalFont.toFont2(
+ HtmlColorUtils.BLACK, useUnderlineForHyperlink, hyperlinkColor), stringsToDisplay, config, param);
+ }
+ if (type == ComponentType.PARTICIPANT_HEAD) {
+ return new ComponentBlueModernParticipant(blue1, blue2, participantFont.toFont2(HtmlColorUtils.WHITE,
+ useUnderlineForHyperlink, hyperlinkColor), stringsToDisplay, param);
+ }
+ if (type == ComponentType.PARTICIPANT_TAIL) {
+ return new ComponentBlueModernParticipant(blue1, blue2, participantFont.toFont2(HtmlColorUtils.WHITE,
+ useUnderlineForHyperlink, hyperlinkColor), stringsToDisplay, param);
+ }
+ if (type == ComponentType.PARTICIPANT_LINE) {
+ return new ComponentBlueModernLine(lineColor);
+ }
+ if (type == ComponentType.CONTINUE_LINE) {
+ return new ComponentBlueModernLine(lineColor);
+ }
+ if (type == ComponentType.ACTOR_HEAD) {
+ return new ComponentBlueModernActor(blue2, blue1, participantFont.toFont2(blue1, useUnderlineForHyperlink,
+ hyperlinkColor), stringsToDisplay, true, param);
+ }
+ if (type == ComponentType.ACTOR_TAIL) {
+ return new ComponentBlueModernActor(blue2, blue1, participantFont.toFont2(blue1, useUnderlineForHyperlink,
+ hyperlinkColor), stringsToDisplay, false, param);
+ }
+ if (type == ComponentType.NOTE) {
+ return new ComponentBlueModernNote(HtmlColorUtils.WHITE, HtmlColorUtils.BLACK, normalFont.toFont2(
+ HtmlColorUtils.BLACK, useUnderlineForHyperlink, hyperlinkColor), stringsToDisplay, param);
+ }
+ if (type == ComponentType.ALIVE_BOX_CLOSE_CLOSE) {
+ return new ComponentBlueModernActiveLine(blue1, true, true);
+ }
+ if (type == ComponentType.ALIVE_BOX_CLOSE_OPEN) {
+ return new ComponentBlueModernActiveLine(blue1, true, false);
+ }
+ if (type == ComponentType.ALIVE_BOX_OPEN_CLOSE) {
+ return new ComponentBlueModernActiveLine(blue1, false, true);
+ }
+ if (type == ComponentType.ALIVE_BOX_OPEN_OPEN) {
+ return new ComponentBlueModernActiveLine(blue1, false, false);
+ }
+ if (type == ComponentType.DELAY_LINE) {
+ return new ComponentBlueModernDelayLine(lineColor);
+ }
+ if (type == ComponentType.DELAY_TEXT) {
+ return new ComponentBlueModernDelayText(param.getFont(FontParam.SEQUENCE_DELAY, null, false).toFont2(
+ HtmlColorUtils.BLACK, useUnderlineForHyperlink, hyperlinkColor), stringsToDisplay, param);
+ }
+ if (type == ComponentType.DESTROY) {
+ return new ComponentRoseDestroy(red);
+ }
+ if (type == ComponentType.GROUPING_HEADER) {
+ return new ComponentBlueModernGroupingHeader(blue1, blue3, borderGroupColor, HtmlColorUtils.BLACK,
+ normalFont.toFont2(HtmlColorUtils.WHITE, useUnderlineForHyperlink, hyperlinkColor), smallFont,
+ stringsToDisplay, param);
+ }
+ if (type == ComponentType.GROUPING_ELSE) {
+ return new ComponentRoseGroupingElse(HtmlColorUtils.BLACK, smallFont.toFont2(HtmlColorUtils.BLACK,
+ useUnderlineForHyperlink, hyperlinkColor), stringsToDisplay.get(0), param, blue3);
+ }
+ if (type == ComponentType.GROUPING_SPACE) {
+ return new ComponentRoseGroupingSpace(7);
+ }
+ if (type == ComponentType.TITLE) {
+ return new ComponentRoseTitle(bigFont.toFont2(HtmlColorUtils.BLACK, useUnderlineForHyperlink,
+ hyperlinkColor), stringsToDisplay, param);
+ }
+ if (type == ComponentType.REFERENCE) {
+ return new ComponentRoseReference(normalFont.toFont2(HtmlColorUtils.BLACK, useUnderlineForHyperlink,
+ hyperlinkColor), new SymbolContext(blue1, borderGroupColor).withStroke(Rose.getStroke(param,
+ LineParam.sequenceDividerBorder, 2)), normalFont.toFont2(HtmlColorUtils.WHITE,
+ useUnderlineForHyperlink, hyperlinkColor), stringsToDisplay, HorizontalAlignment.CENTER, param,
+ blue3);
+ }
+ if (type == ComponentType.NEWPAGE) {
+ return new ComponentBlueModernNewpage(blue1);
+ }
+ if (type == ComponentType.DIVIDER) {
+ return new ComponentBlueModernDivider(normalFont.toFont2(HtmlColorUtils.BLACK, useUnderlineForHyperlink,
+ hyperlinkColor), blue2, blue1, HtmlColorUtils.BLACK, stringsToDisplay, param);
+ }
+ if (type == ComponentType.SIGNATURE) {
+ return new ComponentRoseTitle(smallFont.toFont2(HtmlColorUtils.BLACK, useUnderlineForHyperlink,
+ hyperlinkColor), Display.create("This skin was created ", "in April 2009."), param);
+ }
+ if (type == ComponentType.ENGLOBER) {
+ return new ComponentBlueModernEnglober(blue1, blue3, stringsToDisplay, param.getFont(
+ FontParam.SEQUENCE_BOX, null, false).toFont2(HtmlColorUtils.BLACK, useUnderlineForHyperlink,
+ hyperlinkColor), param);
+ }
+
+ return null;
+
+ }
+
+ public Object getProtocolVersion() {
+ return 1;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernActiveLine.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernActiveLine.java
new file mode 100644
index 0000000..b125755
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernActiveLine.java
@@ -0,0 +1,81 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin.bluemodern;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.AbstractComponent;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ComponentBlueModernActiveLine extends AbstractComponent {
+
+ private final int shadowview = 3;
+ private final HtmlColor foregroundColor;
+
+ public ComponentBlueModernActiveLine(HtmlColor foregroundColor, boolean closeUp, boolean closeDown) {
+ this.foregroundColor = foregroundColor;
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, Area area) {
+ final Dimension2D dimensionToUse = area.getDimensionToUse();
+ final StringBounder stringBounder = ug.getStringBounder();
+ final int x = (int) (dimensionToUse.getWidth() - getPreferredWidth(stringBounder)) / 2;
+ final ShadowShape shadowShape = new ShadowShape(getPreferredWidth(stringBounder), dimensionToUse.getHeight()
+ - shadowview, 3);
+ shadowShape.drawU(ug.apply(new UTranslate(shadowview, shadowview)));
+
+ ug.apply(new UChangeColor(foregroundColor))
+ .apply(new UChangeBackColor(foregroundColor)).apply(new UTranslate(x, 0)).draw(new URectangle(getPreferredWidth(stringBounder), dimensionToUse.getHeight() - shadowview));
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return 0;
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return 10;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernActor.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernActor.java
new file mode 100644
index 0000000..6dd1f15
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernActor.java
@@ -0,0 +1,97 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin.bluemodern;
+
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.skin.AbstractTextualComponent;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.StickMan;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ComponentBlueModernActor extends AbstractTextualComponent {
+
+ private final StickMan stickman;
+ private final boolean head;
+
+ public ComponentBlueModernActor(HtmlColor backgroundColor, HtmlColor foregroundColor, FontConfiguration font,
+ Display stringsToDisplay, boolean head, ISkinSimple spriteContainer) {
+ super(stringsToDisplay, font, HorizontalAlignment.CENTER, 3, 3, 0,
+ spriteContainer, 0, false, null, null);
+ this.head = head;
+ stickman = new StickMan(backgroundColor, foregroundColor);
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, Area area) {
+ ug = ug.apply(new UChangeColor(getFontColor()));
+ final TextBlock textBlock = getTextBlock();
+ final StringBounder stringBounder = ug.getStringBounder();
+ final double delta = (getPreferredWidth(stringBounder) - stickman.getPreferredWidth()) / 2;
+
+ if (head) {
+ textBlock
+ .drawU(ug.apply(new UTranslate(getTextMiddlePostion(stringBounder), stickman.getPreferredHeight())));
+ ug = ug.apply(new UTranslate(delta, 0));
+ } else {
+ textBlock.drawU(ug.apply(new UTranslate(getTextMiddlePostion(stringBounder), 0)));
+ ug = ug.apply(new UTranslate(delta, getTextHeight(stringBounder)));
+ }
+ stickman.drawU(ug);
+
+ }
+
+ private double getTextMiddlePostion(StringBounder stringBounder) {
+ return (getPreferredWidth(stringBounder) - getTextWidth(stringBounder)) / 2.0;
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return stickman.getPreferredHeight() + getTextHeight(stringBounder);
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return Math.max(stickman.getPreferredWidth(), getTextWidth(stringBounder));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernArrow.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernArrow.java
new file mode 100644
index 0000000..c744f41
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernArrow.java
@@ -0,0 +1,192 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin.bluemodern;
+
+import java.awt.Graphics2D;
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.ArrowConfiguration;
+import net.sourceforge.plantuml.skin.ArrowDirection;
+import net.sourceforge.plantuml.skin.ArrowPart;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ComponentBlueModernArrow extends AbstractComponentBlueModernArrow {
+
+ public ComponentBlueModernArrow(HtmlColor foregroundColor, boolean useUnderlineForHyperlink, FontConfiguration font, Display stringsToDisplay, ArrowConfiguration arrowConfiguration,
+ ISkinSimple spriteContainer) {
+ super(foregroundColor, font, stringsToDisplay, arrowConfiguration, spriteContainer);
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, Area area) {
+ final Dimension2D dimensionToUse = area.getDimensionToUse();
+ final StringBounder stringBounder = ug.getStringBounder();
+ final int textHeight = (int) getTextHeight(stringBounder);
+
+ ug = ug.apply(new UChangeColor(getForegroundColor()));
+ ug = ug.apply(new UChangeBackColor(getForegroundColor()));
+
+ final int x2 = (int) dimensionToUse.getWidth();
+
+ if (getArrowConfiguration().isDotted()) {
+ ug = stroke(ug, 5, 2);
+ } else {
+ ug = ug.apply(new UStroke(2));
+ }
+
+ ug.apply(new UTranslate(2, textHeight)).draw(new ULine(x2 - 4, 0));
+ ug = ug.apply(new UStroke());
+
+ final int direction = getDirection();
+ final UPolygon polygon = new UPolygon();
+
+ if (getArrowConfiguration().isAsync()) {
+ ug = ug.apply(new UStroke(1.5));
+ if (direction == 1) {
+ if (getArrowConfiguration().getPart() != ArrowPart.BOTTOM_PART) {
+ ug.apply(new UTranslate(x2 - getArrowDeltaX2(), textHeight - getArrowDeltaY2())).draw(new ULine(getArrowDeltaX2(),
+ getArrowDeltaY2()));
+ }
+ if (getArrowConfiguration().getPart() != ArrowPart.TOP_PART) {
+ ug.apply(new UTranslate(x2 - getArrowDeltaX2(), textHeight + getArrowDeltaY2())).draw(new ULine(getArrowDeltaX2(),
+ -getArrowDeltaY2()));
+ }
+ } else {
+ if (getArrowConfiguration().getPart() != ArrowPart.BOTTOM_PART) {
+ ug.apply(new UTranslate(getArrowDeltaX2(), textHeight - getArrowDeltaY2())).draw(new ULine(-getArrowDeltaX2(),
+ getArrowDeltaY2()));
+ }
+ if (getArrowConfiguration().getPart() != ArrowPart.TOP_PART) {
+ ug.apply(new UTranslate(getArrowDeltaX2(), textHeight + getArrowDeltaY2())).draw(new ULine(-getArrowDeltaX2(),
+ -getArrowDeltaY2()));
+ }
+ }
+ ug = ug.apply(new UStroke());
+ } else if (direction == 1) {
+ createPolygonNormal(textHeight, x2, polygon);
+ } else {
+ createPolygonReverse(textHeight, polygon);
+ }
+ ug.draw(polygon);
+
+ getTextBlock().drawU(ug.apply(new UTranslate(getMarginX1(), 0)));
+ }
+
+ private void createPolygonReverse(final int textHeight, final UPolygon polygon) {
+ if (getArrowConfiguration().getPart() == ArrowPart.TOP_PART) {
+ polygon.addPoint(getArrowDeltaX(), textHeight - getArrowDeltaY());
+ polygon.addPoint(0, textHeight);
+ polygon.addPoint(getArrowDeltaX(), textHeight);
+ } else if (getArrowConfiguration().getPart() == ArrowPart.BOTTOM_PART) {
+ polygon.addPoint(getArrowDeltaX(), textHeight);
+ polygon.addPoint(0, textHeight);
+ polygon.addPoint(getArrowDeltaX(), textHeight + getArrowDeltaY());
+ } else {
+ polygon.addPoint(getArrowDeltaX(), textHeight - getArrowDeltaY());
+ polygon.addPoint(0, textHeight);
+ polygon.addPoint(getArrowDeltaX(), textHeight + getArrowDeltaY());
+ }
+ }
+
+ private void createPolygonNormal(final int textHeight, final int x2, final UPolygon polygon) {
+ if (getArrowConfiguration().getPart() == ArrowPart.TOP_PART) {
+ polygon.addPoint(x2 - getArrowDeltaX(), textHeight - getArrowDeltaY());
+ polygon.addPoint(x2, textHeight);
+ polygon.addPoint(x2 - getArrowDeltaX(), textHeight);
+ } else if (getArrowConfiguration().getPart() == ArrowPart.BOTTOM_PART) {
+ polygon.addPoint(x2 - getArrowDeltaX(), textHeight);
+ polygon.addPoint(x2, textHeight);
+ polygon.addPoint(x2 - getArrowDeltaX(), textHeight + getArrowDeltaY());
+ } else {
+ polygon.addPoint(x2 - getArrowDeltaX(), textHeight - getArrowDeltaY());
+ polygon.addPoint(x2, textHeight);
+ polygon.addPoint(x2 - getArrowDeltaX(), textHeight + getArrowDeltaY());
+ }
+ }
+
+ protected int getDirection(Graphics2D g2d) {
+ return getDirection();
+ }
+
+ protected int getDirection() {
+ if (getArrowConfiguration().getArrowDirection() == ArrowDirection.LEFT_TO_RIGHT_NORMAL) {
+ return 1;
+ }
+ if (getArrowConfiguration().getArrowDirection() == ArrowDirection.RIGHT_TO_LEFT_REVERSE) {
+ return -1;
+ }
+ throw new IllegalStateException();
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return getTextHeight(stringBounder) + getArrowDeltaY() + 2 * getPaddingY();
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return getTextWidth(stringBounder);
+ }
+
+ public Point2D getStartPoint(StringBounder stringBounder, Dimension2D dimensionToUse) {
+ final int textHeight = (int) getTextHeight(stringBounder);
+ if (getArrowConfiguration().getArrowDirection() == ArrowDirection.LEFT_TO_RIGHT_NORMAL) {
+ return new Point2D.Double(getPaddingX(), textHeight + getPaddingY());
+ }
+ return new Point2D.Double(dimensionToUse.getWidth() + getPaddingX(), textHeight + getPaddingY());
+ }
+
+ public Point2D getEndPoint(StringBounder stringBounder, Dimension2D dimensionToUse) {
+ final int textHeight = (int) getTextHeight(stringBounder);
+ if (getArrowConfiguration().getArrowDirection() == ArrowDirection.LEFT_TO_RIGHT_NORMAL) {
+ return new Point2D.Double(dimensionToUse.getWidth() + getPaddingX(), textHeight + getPaddingY());
+ }
+ return new Point2D.Double(getPaddingX(), textHeight + getPaddingY());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernDelayLine.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernDelayLine.java
new file mode 100644
index 0000000..c1bf6b7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernDelayLine.java
@@ -0,0 +1,77 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin.bluemodern;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.AbstractComponent;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.ugraphic.UAntiAliasing;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ComponentBlueModernDelayLine extends AbstractComponent {
+
+ private final HtmlColor color;
+
+ public ComponentBlueModernDelayLine(HtmlColor color) {
+ this.color = color;
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, Area area) {
+ final Dimension2D dimensionToUse = area.getDimensionToUse();
+ ug = ug.apply(new UChangeColor(color));
+ ug = stroke(ug, 1, 4);
+ final int x = (int) (dimensionToUse.getWidth() / 2);
+ ug.apply(new UChangeBackColor(color)).apply(UAntiAliasing.ANTI_ALIASING_OFF).apply(new UTranslate(x + 1, 0)).draw(new ULine(0, dimensionToUse.getHeight()));
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return 20;
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return 2;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernDelayText.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernDelayText.java
new file mode 100644
index 0000000..a352df7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernDelayText.java
@@ -0,0 +1,82 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin.bluemodern;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.cucadiagram.Display;
+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.skin.AbstractTextualComponent;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ComponentBlueModernDelayText extends AbstractTextualComponent {
+
+ public ComponentBlueModernDelayText(FontConfiguration font, Display stringsToDisplay,
+ ISkinSimple spriteContainer) {
+ super(stringsToDisplay, font, HorizontalAlignment.CENTER, 4, 4, 4,
+ spriteContainer, 0, false, null, null);
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, Area area) {
+ final Dimension2D dimensionToUse = area.getDimensionToUse();
+ final TextBlock textBlock = getTextBlock();
+ final StringBounder stringBounder = ug.getStringBounder();
+ final double textWidth = getTextWidth(stringBounder);
+ final double textHeight = getTextHeight(stringBounder);
+
+ final double xpos = (dimensionToUse.getWidth() - textWidth) / 2;
+ final double ypos = (dimensionToUse.getHeight() - textHeight) / 2;
+
+ textBlock.drawU(ug.apply(new UTranslate(xpos, (ypos + getMarginY()))));
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return getTextHeight(stringBounder) + 20;
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return getTextWidth(stringBounder) + 30;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernDivider.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernDivider.java
new file mode 100644
index 0000000..b2558c6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernDivider.java
@@ -0,0 +1,112 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin.bluemodern;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.skin.AbstractTextualComponent;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ComponentBlueModernDivider extends AbstractTextualComponent {
+
+ private final HtmlColor background1;
+ private final HtmlColor background2;
+ private final HtmlColor borderColor;
+
+ public ComponentBlueModernDivider(FontConfiguration font, HtmlColor background1, HtmlColor background2,
+ HtmlColor borderColor, Display stringsToDisplay, ISkinSimple spriteContainer) {
+ super(stringsToDisplay, font, HorizontalAlignment.CENTER, 4, 4, 4,
+ spriteContainer, 0, false, null, null);
+ this.background1 = background1;
+ this.background2 = background2;
+ this.borderColor = borderColor;
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, Area area) {
+ final Dimension2D dimensionToUse = area.getDimensionToUse();
+ final TextBlock textBlock = getTextBlock();
+ final StringBounder stringBounder = ug.getStringBounder();
+ final double textWidth = getTextWidth(stringBounder);
+ final double textHeight = getTextHeight(stringBounder);
+
+ final double deltaX = 6;
+ final double xpos = (dimensionToUse.getWidth() - textWidth - deltaX) / 2;
+ final double ypos = (dimensionToUse.getHeight() - textHeight) / 2;
+
+ ug = ug.apply(new UChangeColor(HtmlColorUtils.BLACK));
+ ug = ug.apply(new UChangeBackColor(HtmlColorUtils.BLACK));
+ ug = ug.apply(new UStroke(2));
+
+ ug.apply(new UTranslate(0, dimensionToUse.getHeight() / 2 - 1)).draw(new ULine(dimensionToUse.getWidth(), 0));
+ ug.apply(new UTranslate(0, dimensionToUse.getHeight() / 2 + 2)).draw(new ULine(dimensionToUse.getWidth(), 0));
+
+ final FillRoundShape shape = new FillRoundShape(textWidth + deltaX, textHeight, background1, background2, 5);
+ shape.drawU(ug.apply(new UTranslate(xpos, ypos)));
+
+ ug = ug.apply(new UChangeColor(borderColor));
+ ug = ug.apply(new UChangeBackColor(null));
+ ug.apply(new UTranslate(xpos, ypos)).draw(new URectangle(textWidth + deltaX, textHeight, 5, 5));
+ ug = ug.apply(new UStroke());
+
+ textBlock.drawU(ug.apply(new UTranslate(xpos + deltaX, ypos + getMarginY())));
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return getTextHeight(stringBounder) + 20;
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return getTextWidth(stringBounder) + 30;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernEnglober.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernEnglober.java
new file mode 100644
index 0000000..45511ac
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernEnglober.java
@@ -0,0 +1,95 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin.bluemodern;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.AbstractTextualComponent;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ComponentBlueModernEnglober extends AbstractTextualComponent {
+
+ private final HtmlColor borderColor;
+ private final HtmlColor backColor;
+
+ public ComponentBlueModernEnglober(HtmlColor borderColor, HtmlColor backColor, Display strings,
+ FontConfiguration font, ISkinSimple spriteContainer) {
+ super(strings, font, HorizontalAlignment.CENTER, 4, 4, 1, spriteContainer, 0, false,
+ null, null);
+ this.borderColor = borderColor;
+ this.backColor = backColor;
+ }
+
+ @Override
+ protected void drawBackgroundInternalU(UGraphic ug, Area area) {
+ final Dimension2D dimensionToUse = area.getDimensionToUse();
+ ug = ug.apply(new UChangeColor(borderColor));
+ ug = ug.apply(new UChangeBackColor(backColor));
+ ug.apply(new UStroke(2)).draw(new URectangle(dimensionToUse.getWidth(), dimensionToUse.getHeight(), 9, 9));
+ final double xpos = (dimensionToUse.getWidth() - getPureTextWidth(ug.getStringBounder())) / 2;
+
+ getTextBlock().drawU(ug.apply(new UTranslate(xpos, 0)));
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, Area area) {
+ // ug.getParam().setColor(Color.RED);
+ // ug.getParam().setBackcolor(Color.YELLOW);
+ // ug.draw(0, 0, new URectangle(dimensionToUse.getWidth(),
+ // dimensionToUse.getHeight()));
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return getTextHeight(stringBounder) + 3;
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return getTextWidth(stringBounder) + 10;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernGroupingHeader.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernGroupingHeader.java
new file mode 100644
index 0000000..e7c98c0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernGroupingHeader.java
@@ -0,0 +1,159 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin.bluemodern;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.skin.AbstractTextualComponent;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ComponentBlueModernGroupingHeader extends AbstractTextualComponent {
+
+ private final int cornersize = 10;
+ private final int commentMargin = 0; // 8;
+
+ private final TextBlock commentTextBlock;
+
+ private final HtmlColor headerBackgroundColor;
+ private final HtmlColor generalBackgroundColor;
+ private final HtmlColor borderColor;
+
+ public ComponentBlueModernGroupingHeader(HtmlColor headerBackgroundColor, HtmlColor generalBackgroundColor,
+ HtmlColor borderColor, HtmlColor fontColor2, FontConfiguration bigFont, UFont smallFont, Display strings, ISkinSimple spriteContainer) {
+ super(strings.get(0), bigFont, HorizontalAlignment.LEFT, 15, 30, 1, spriteContainer, 0, null,
+ null);
+ this.headerBackgroundColor = headerBackgroundColor;
+ this.generalBackgroundColor = generalBackgroundColor;
+ this.borderColor = borderColor;
+ if (strings.size() == 1 || strings.get(1) == null) {
+ this.commentTextBlock = null;
+ } else {
+ this.commentTextBlock = TextBlockUtils.create(Display.create("[" + strings.get(1) + "]"),
+ new FontConfiguration(smallFont, fontColor2, bigFont.getHyperlinkColor(), bigFont.useUnderlineForHyperlink()), HorizontalAlignment.LEFT,
+ spriteContainer);
+ }
+ }
+
+ // @Override
+ // public double getPaddingY() {
+ // return 6;
+ // }
+
+ @Override
+ final public double getPreferredWidth(StringBounder stringBounder) {
+ final double sup;
+ if (commentTextBlock == null) {
+ sup = commentMargin * 2;
+ } else {
+ final Dimension2D size = commentTextBlock.calculateDimension(stringBounder);
+ sup = getMarginX1() + commentMargin + size.getWidth();
+
+ }
+ return getTextWidth(stringBounder) + sup;
+ }
+
+ @Override
+ final public double getPreferredHeight(StringBounder stringBounder) {
+ return getTextHeight(stringBounder) + 2 * getPaddingY();
+ }
+
+ @Override
+ protected void drawBackgroundInternalU(UGraphic ug, Area area) {
+ final Dimension2D dimensionToUse = area.getDimensionToUse();
+ ug.apply(new UChangeColor(borderColor)).apply(new UStroke(2))
+ .apply(new UChangeBackColor(generalBackgroundColor))
+ .draw(new URectangle(dimensionToUse.getWidth(), dimensionToUse.getHeight()));
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, Area area) {
+ final Dimension2D dimensionToUse = area.getDimensionToUse();
+ ug = ug.apply(new UChangeColor(borderColor));
+ ug.apply(new UStroke(2)).draw(new URectangle(dimensionToUse.getWidth(), dimensionToUse.getHeight()));
+
+ final StringBounder stringBounder = ug.getStringBounder();
+ final int textWidth = (int) getTextWidth(stringBounder);
+ final int textHeight = (int) getTextHeight(stringBounder);
+
+ final UPolygon polygon = new UPolygon();
+ polygon.addPoint(0, 0);
+ polygon.addPoint(textWidth, 0);
+
+ polygon.addPoint(textWidth, textHeight - cornersize);
+ polygon.addPoint(textWidth - cornersize, textHeight);
+
+ polygon.addPoint(0, textHeight);
+ polygon.addPoint(0, 0);
+
+ ug = ug.apply(new UStroke(2));
+ ug = ug.apply(new UChangeBackColor(headerBackgroundColor));
+ ug.draw(polygon);
+ ug.draw(new ULine(dimensionToUse.getWidth(), 0));
+
+ final double heightWithoutPadding = dimensionToUse.getHeight() - getPaddingY();
+
+ ug.apply(new UTranslate(dimensionToUse.getWidth(), 0)).draw(new ULine(0, heightWithoutPadding));
+ ug.apply(new UTranslate(0, textHeight)).draw(new ULine(0, heightWithoutPadding - textHeight));
+ ug = ug.apply(new UStroke());
+
+ getTextBlock().drawU(ug.apply(new UTranslate(getMarginX1(), getMarginY())));
+
+ if (commentTextBlock != null) {
+ final int x1 = getMarginX1() + textWidth;
+ final int y2 = getMarginY() + 1;
+
+ commentTextBlock.drawU(ug.apply(new UChangeColor(generalBackgroundColor)).apply(
+ new UTranslate(x1 + commentMargin, y2)));
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernLine.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernLine.java
new file mode 100644
index 0000000..c69c082
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernLine.java
@@ -0,0 +1,75 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin.bluemodern;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.AbstractComponent;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ComponentBlueModernLine extends AbstractComponent {
+
+ private final HtmlColor color;
+
+ public ComponentBlueModernLine(HtmlColor color) {
+ this.color = color;
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, Area area) {
+ final Dimension2D dimensionToUse = area.getDimensionToUse();
+ final int x = (int) (dimensionToUse.getWidth() / 2);
+ final StringBounder stringBounder = ug.getStringBounder();
+ ug.apply(new UChangeColor(color)).apply(new UChangeBackColor(color)).apply(new UTranslate(x, 0)).draw(new URectangle(getPreferredWidth(stringBounder), dimensionToUse.getHeight()));
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return 20;
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return 2;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernNewpage.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernNewpage.java
new file mode 100644
index 0000000..8d6cf38
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernNewpage.java
@@ -0,0 +1,72 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin.bluemodern;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.AbstractComponent;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+
+public class ComponentBlueModernNewpage extends AbstractComponent {
+
+ private final HtmlColor foregroundColor;
+
+ public ComponentBlueModernNewpage(HtmlColor foregroundColor) {
+ this.foregroundColor = foregroundColor;
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, Area area) {
+ final Dimension2D dimensionToUse = area.getDimensionToUse();
+ ug = stroke(ug, 10, 2);
+ ug.apply(new UChangeColor(foregroundColor)).draw(new ULine(dimensionToUse.getWidth(), 0));
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return 2;
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return 0;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernNote.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernNote.java
new file mode 100644
index 0000000..671c086
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernNote.java
@@ -0,0 +1,117 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin.bluemodern;
+
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.AbstractTextualComponent;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+final public class ComponentBlueModernNote extends AbstractTextualComponent {
+
+ private final int shadowview = 4;
+ private final int cornersize = 10;
+ private final HtmlColor back;
+ private final HtmlColor foregroundColor;
+
+ public ComponentBlueModernNote(HtmlColor back, HtmlColor foregroundColor, FontConfiguration font,
+ Display strings, ISkinSimple spriteContainer) {
+ super(strings, font, HorizontalAlignment.LEFT, 6, 15, 5, spriteContainer, 0, false,
+ null, null);
+ this.back = back;
+ this.foregroundColor = foregroundColor;
+ }
+
+ @Override
+ final public double getPreferredWidth(StringBounder stringBounder) {
+ final double result = getTextWidth(stringBounder) + 2 * getPaddingX();
+ return result;
+ }
+
+ @Override
+ final public double getPreferredHeight(StringBounder stringBounder) {
+ return getTextHeight(stringBounder) + 2 * getPaddingY();
+ }
+
+ @Override
+ public double getPaddingX() {
+ return 9;
+ }
+
+ @Override
+ public double getPaddingY() {
+ return 9;
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, Area area) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final double textHeight = getTextHeight(stringBounder);
+
+ final double textWidth = getTextWidth(stringBounder);
+
+ final ShadowShape shadowShape = new ShadowShape(textWidth, textHeight, 3);
+ shadowShape.drawU(ug.apply(new UTranslate(shadowview, shadowview)));
+
+ final UPolygon polygon = new UPolygon();
+ polygon.addPoint(0, 0);
+ polygon.addPoint(0, textHeight);
+ polygon.addPoint(textWidth, textHeight);
+ polygon.addPoint(textWidth, cornersize);
+ polygon.addPoint(textWidth - cornersize, 0);
+ polygon.addPoint(0, 0);
+
+ ug = ug.apply(new UChangeBackColor(back));
+ ug = ug.apply(new UChangeColor(foregroundColor));
+ ug.draw(polygon);
+
+ ug.apply(new UTranslate(textWidth - cornersize, 0)).draw(new ULine(0, cornersize));
+ ug.apply(new UTranslate(textWidth, cornersize)).draw(new ULine(-cornersize, 0));
+
+ getTextBlock().drawU(ug.apply(new UTranslate(getMarginX1(), getMarginY())));
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernParticipant.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernParticipant.java
new file mode 100644
index 0000000..f9bb38d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernParticipant.java
@@ -0,0 +1,90 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin.bluemodern;
+
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.AbstractTextualComponent;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ComponentBlueModernParticipant extends AbstractTextualComponent {
+
+ private final int shadowview = 3;
+ private final HtmlColor blue1;
+ private final HtmlColor blue2;
+
+ public ComponentBlueModernParticipant(HtmlColor blue1, HtmlColor blue2, FontConfiguration font,
+ Display stringsToDisplay, ISkinSimple spriteContainer) {
+ super(stringsToDisplay, font, HorizontalAlignment.CENTER, 7, 7, 7,
+ spriteContainer, 0, false, null, null);
+ this.blue1 = blue1;
+ this.blue2 = blue2;
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, Area area) {
+ final StringBounder stringBounder = ug.getStringBounder();
+
+ final ShadowShape shadowShape = new ShadowShape(getTextWidth(stringBounder), getTextHeight(stringBounder), 10);
+ final UGraphic ugShadow = ug.apply(new UTranslate(shadowview, shadowview)).apply(new UChangeColor(null));
+ // ug.translate(shadowview, shadowview);
+ shadowShape.drawU(ugShadow);
+ // ug.translate(-shadowview, -shadowview);
+
+ final FillRoundShape shape = new FillRoundShape(getTextWidth(stringBounder), getTextHeight(stringBounder),
+ blue1, blue2, 10);
+ shape.drawU(ug);
+
+ getTextBlock().drawU(ug.apply(new UTranslate(getMarginX1(), getMarginY())));
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return getTextHeight(stringBounder) + shadowview;
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return getTextWidth(stringBounder);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernSelfArrow.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernSelfArrow.java
new file mode 100644
index 0000000..fc1dd31
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernSelfArrow.java
@@ -0,0 +1,148 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin.bluemodern;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.ArrowConfiguration;
+import net.sourceforge.plantuml.skin.ArrowPart;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ComponentBlueModernSelfArrow extends AbstractComponentBlueModernArrow {
+
+ private final double arrowWidth = 45;
+
+ public ComponentBlueModernSelfArrow(HtmlColor foregroundColor, FontConfiguration font, Display stringsToDisplay, ArrowConfiguration arrowConfiguration, ISkinSimple spriteContainer) {
+ super(foregroundColor, font, stringsToDisplay, arrowConfiguration, spriteContainer);
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, Area area) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final int textHeight = (int) getTextHeight(stringBounder);
+
+ ug = ug.apply(new UChangeBackColor(getForegroundColor())).apply(new UChangeColor(getForegroundColor()));
+ final double x2 = arrowWidth - 3;
+
+ if (getArrowConfiguration().isDotted()) {
+ ug = stroke(ug, 5, 2);
+ } else {
+ ug = ug.apply(new UStroke(2));
+ }
+
+ ug.apply(new UTranslate(0, textHeight)).draw(new ULine(x2, 0));
+
+ final int textAndArrowHeight = (int) (textHeight + getArrowOnlyHeight(stringBounder));
+
+ ug.apply(new UTranslate(x2, textHeight)).draw(new ULine(0, textAndArrowHeight - textHeight));
+ ug.apply(new UTranslate(x2, textAndArrowHeight)).draw(new ULine(2 - x2, 0));
+
+ ug = ug.apply(new UStroke());
+
+ final int delta = (int) getArrowOnlyHeight(stringBounder);
+
+ if (getArrowConfiguration().isAsync()) {
+ if (getArrowConfiguration().getPart() != ArrowPart.BOTTOM_PART) {
+ ug.apply(new UStroke(1.5)).apply(new UTranslate(getArrowDeltaX2(), textHeight - getArrowDeltaY2() + delta)).draw(new ULine(-getArrowDeltaX2(), getArrowDeltaY2()));
+ }
+ if (getArrowConfiguration().getPart() != ArrowPart.TOP_PART) {
+ ug.apply(new UStroke(1.5)).apply(new UTranslate(getArrowDeltaX2(), textHeight + getArrowDeltaY2() + delta)).draw(new ULine(-getArrowDeltaX2(), -getArrowDeltaY2()));
+ }
+ } else {
+ final UPolygon polygon = getPolygon(textHeight, delta);
+ ug.draw(polygon);
+ }
+
+ getTextBlock().drawU(ug.apply(new UTranslate(getMarginX1(), 0)));
+
+ }
+
+ private UPolygon getPolygon(final int textHeight, final int delta) {
+ final UPolygon polygon = new UPolygon();
+ if (getArrowConfiguration().getPart() == ArrowPart.TOP_PART) {
+ polygon.addPoint(getArrowDeltaX(), textHeight - getArrowDeltaY() + delta);
+ polygon.addPoint(0, textHeight + delta);
+ polygon.addPoint(getArrowDeltaX(), textHeight + delta);
+ } else if (getArrowConfiguration().getPart() == ArrowPart.BOTTOM_PART) {
+ polygon.addPoint(getArrowDeltaX(), textHeight + delta);
+ polygon.addPoint(0, textHeight + delta);
+ polygon.addPoint(getArrowDeltaX(), textHeight + getArrowDeltaY() + delta);
+ } else {
+ polygon.addPoint(getArrowDeltaX(), textHeight - getArrowDeltaY() + delta);
+ polygon.addPoint(0, textHeight + delta);
+ polygon.addPoint(getArrowDeltaX(), textHeight + getArrowDeltaY() + delta);
+ }
+ return polygon;
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return getTextHeight(stringBounder) + getArrowDeltaY() + getArrowOnlyHeight(stringBounder) + 2 * getPaddingY();
+ }
+
+ private double getArrowOnlyHeight(StringBounder stringBounder) {
+ return 13;
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return Math.max(getTextWidth(stringBounder), arrowWidth);
+ }
+
+ public Point2D getStartPoint(StringBounder stringBounder, Dimension2D dimensionToUse) {
+ final int textHeight = (int) getTextHeight(stringBounder);
+ return new Point2D.Double(getPaddingX(), textHeight + getPaddingY());
+ }
+
+ public Point2D getEndPoint(StringBounder stringBounder, Dimension2D dimensionToUse) {
+ final int textHeight = (int) getTextHeight(stringBounder);
+ final int textAndArrowHeight = (int) (textHeight + getArrowOnlyHeight(stringBounder));
+ return new Point2D.Double(getPaddingX(), textAndArrowHeight + getPaddingY());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/FillRoundShape.java b/src/net/sourceforge/plantuml/skin/bluemodern/FillRoundShape.java
new file mode 100644
index 0000000..9af427f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/bluemodern/FillRoundShape.java
@@ -0,0 +1,79 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin.bluemodern;
+
+import java.awt.GradientPaint;
+import java.awt.Graphics2D;
+import java.awt.geom.RoundRectangle2D;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorGradient;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+
+public class FillRoundShape {
+
+ final private double width;
+ final private double height;
+ final private double corner;
+ final private HtmlColor c1;
+ final private HtmlColor c2;
+
+ public FillRoundShape(double width, double height, HtmlColor c1, HtmlColor c2, double corner) {
+ this.width = width;
+ this.height = height;
+ this.c1 = c1;
+ this.c2 = c2;
+ this.corner = corner;
+
+ }
+
+ public void draw(ColorMapper mapper, Graphics2D g2d) {
+ final GradientPaint paint = new GradientPaint(0, 0, mapper.getMappedColor(c1), (float) width, (float) height,
+ mapper.getMappedColor(c2));
+ final RoundRectangle2D r = new RoundRectangle2D.Double(0, 0, width, height, corner * 2, corner * 2);
+ g2d.setPaint(paint);
+ g2d.fill(r);
+ }
+
+ public void drawU(UGraphic ug) {
+ final HtmlColorGradient gradient = new HtmlColorGradient(c1, c2, '\\');
+ final URectangle r = new URectangle(width, height, corner * 2, corner * 2);
+ ug.apply(new UChangeBackColor(gradient)).draw(r);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ShadowShape.java b/src/net/sourceforge/plantuml/skin/bluemodern/ShadowShape.java
new file mode 100644
index 0000000..726fb96
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/bluemodern/ShadowShape.java
@@ -0,0 +1,46 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin.bluemodern;
+
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+
+public class ShadowShape extends FillRoundShape {
+
+ public ShadowShape(double width, double height, double corner) {
+ super(width, height, HtmlColorUtils.LIGHT_GRAY, HtmlColorUtils.GRAY, corner);
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/rose/AbstractComponentRoseArrow.java b/src/net/sourceforge/plantuml/skin/rose/AbstractComponentRoseArrow.java
new file mode 100644
index 0000000..c69804b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/rose/AbstractComponentRoseArrow.java
@@ -0,0 +1,83 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin.rose;
+
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.skin.AbstractTextualComponent;
+import net.sourceforge.plantuml.skin.ArrowComponent;
+import net.sourceforge.plantuml.skin.ArrowConfiguration;
+
+public abstract class AbstractComponentRoseArrow extends AbstractTextualComponent implements ArrowComponent {
+
+ private final int arrowDeltaX = 10;
+ private final int arrowDeltaY = 4;
+ private final HtmlColor foregroundColor;
+ private final ArrowConfiguration arrowConfiguration;
+
+ public AbstractComponentRoseArrow(HtmlColor foregroundColor, FontConfiguration font, Display stringsToDisplay,
+ ArrowConfiguration arrowConfiguration, ISkinSimple spriteContainer, HorizontalAlignment textHorizontalAlignment,
+ double maxMessageSize) {
+ super(stringsToDisplay, font, textHorizontalAlignment, 7, 7, 1, spriteContainer,
+ maxMessageSize, false, null, null);
+ this.arrowConfiguration = arrowConfiguration;
+ this.foregroundColor = foregroundColor;
+ }
+
+ protected final HtmlColor getForegroundColor() {
+ return foregroundColor;
+ }
+
+ final protected int getArrowDeltaX() {
+ return arrowDeltaX;
+ }
+
+ final protected int getArrowDeltaY() {
+ return arrowDeltaY;
+ }
+
+ @Override
+ public final double getPaddingY() {
+ return 4;
+ }
+
+ public final ArrowConfiguration getArrowConfiguration() {
+ return arrowConfiguration;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseActiveLine.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseActiveLine.java
new file mode 100644
index 0000000..de9845e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseActiveLine.java
@@ -0,0 +1,102 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin.rose;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.SymbolContext;
+import net.sourceforge.plantuml.skin.AbstractComponent;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ComponentRoseActiveLine extends AbstractComponent {
+
+ private final SymbolContext symbolContext;
+ private final boolean closeUp;
+ private final boolean closeDown;
+
+ public ComponentRoseActiveLine(SymbolContext symbolContext, boolean closeUp, boolean closeDown) {
+ this.symbolContext = symbolContext;
+ this.closeUp = closeUp;
+ this.closeDown = closeDown;
+ }
+
+ protected void drawInternalU(UGraphic ug, Area area) {
+ final Dimension2D dimensionToUse = area.getDimensionToUse();
+ final StringBounder stringBounder = ug.getStringBounder();
+ final int x = (int) (dimensionToUse.getWidth() - getPreferredWidth(stringBounder)) / 2;
+
+ final URectangle rect = new URectangle(getPreferredWidth(stringBounder), dimensionToUse.getHeight());
+ if (symbolContext.isShadowing()) {
+ rect.setDeltaShadow(1);
+ }
+ ug = ug.apply(new UChangeColor(symbolContext.getForeColor()));
+ if (closeUp && closeDown) {
+ ug.apply(new UChangeBackColor(symbolContext.getBackColor())).apply(new UTranslate(x, 0)).draw(rect);
+ return;
+ }
+ ug.apply(new UChangeBackColor(symbolContext.getBackColor())).apply(new UChangeColor(symbolContext.getBackColor()))
+ .apply(new UTranslate(x, 0)).draw(rect);
+
+ final ULine vline = new ULine(0, dimensionToUse.getHeight());
+ ug.apply(new UTranslate(x, 0)).draw(vline);
+ ug.apply(new UTranslate(x + getPreferredWidth(stringBounder), 0)).draw(vline);
+
+ final ULine hline = new ULine(getPreferredWidth(stringBounder), 0);
+ if (closeUp) {
+ ug.apply(new UTranslate(x, 0)).draw(hline);
+ }
+ if (closeDown) {
+ ug.apply(new UTranslate(x, dimensionToUse.getHeight())).draw(hline);
+ }
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return 0;
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return 10;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseActor.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseActor.java
new file mode 100644
index 0000000..42c6810
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseActor.java
@@ -0,0 +1,99 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin.rose;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.SymbolContext;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.skin.AbstractTextualComponent;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.StickMan;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ComponentRoseActor extends AbstractTextualComponent {
+
+ private final TextBlock stickman;
+ private final boolean head;
+
+ public ComponentRoseActor(SymbolContext biColor, FontConfiguration font, Display stringsToDisplay, boolean head,
+ ISkinSimple spriteContainer, UFont fontForStereotype, HtmlColor htmlColorForStereotype) {
+ super(stringsToDisplay, font, HorizontalAlignment.CENTER, 3, 3, 0, spriteContainer, 0, false,
+ fontForStereotype, htmlColorForStereotype);
+ this.head = head;
+ this.stickman = new StickMan(biColor);
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, Area area) {
+ final TextBlock textBlock = getTextBlock();
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D dimStickman = stickman.calculateDimension(stringBounder);
+ final double delta = (getPreferredWidth(stringBounder) - dimStickman.getWidth()) / 2;
+
+ if (head) {
+ textBlock.drawU(ug.apply(new UTranslate(getTextMiddlePostion(stringBounder), dimStickman.getHeight())));
+ ug = ug.apply(new UTranslate(delta, 0));
+ } else {
+ textBlock.drawU(ug.apply(new UTranslate(getTextMiddlePostion(stringBounder), 0)));
+ ug = ug.apply(new UTranslate(delta, getTextHeight(stringBounder)));
+ }
+ stickman.drawU(ug);
+ }
+
+ private double getTextMiddlePostion(StringBounder stringBounder) {
+ return (getPreferredWidth(stringBounder) - getTextWidth(stringBounder)) / 2.0;
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ final Dimension2D dimStickman = stickman.calculateDimension(stringBounder);
+ return dimStickman.getHeight() + getTextHeight(stringBounder);
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ final Dimension2D dimStickman = stickman.calculateDimension(stringBounder);
+ return Math.max(dimStickman.getWidth(), getTextWidth(stringBounder));
+ }
+}
diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseArrow.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseArrow.java
new file mode 100644
index 0000000..01ac5a2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseArrow.java
@@ -0,0 +1,294 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin.rose;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.ArrowConfiguration;
+import net.sourceforge.plantuml.skin.ArrowDecoration;
+import net.sourceforge.plantuml.skin.ArrowDirection;
+import net.sourceforge.plantuml.skin.ArrowDressing;
+import net.sourceforge.plantuml.skin.ArrowHead;
+import net.sourceforge.plantuml.skin.ArrowPart;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ComponentRoseArrow extends AbstractComponentRoseArrow {
+
+ private final HorizontalAlignment messagePosition;
+ private final boolean niceArrow;
+
+ public ComponentRoseArrow(HtmlColor foregroundColor, FontConfiguration font, Display stringsToDisplay, ArrowConfiguration arrowConfiguration, HorizontalAlignment messagePosition, ISkinSimple spriteContainer,
+ HorizontalAlignment textHorizontalAlignment, double maxMessageSize, boolean niceArrow) {
+ super(foregroundColor, font, stringsToDisplay, arrowConfiguration, spriteContainer, textHorizontalAlignment, maxMessageSize);
+ this.messagePosition = messagePosition;
+ this.niceArrow = niceArrow;
+ }
+
+ public static final double spaceCrossX = 6;
+ public static final double diamCircle = 8;
+ public static final double thinCircle = 1.5;
+
+ @Override
+ public void drawInternalU(UGraphic ug, Area area) {
+ final Dimension2D dimensionToUse = area.getDimensionToUse();
+ final StringBounder stringBounder = ug.getStringBounder();
+ final int textHeight = (int) getTextHeight(stringBounder);
+ ug = ug.apply(new UChangeColor(getForegroundColor()));
+
+ final ArrowDressing dressing1 = getArrowConfiguration().getDressing1();
+ final ArrowDressing dressing2 = getArrowConfiguration().getDressing2();
+
+ double start = 0;
+ double len = dimensionToUse.getWidth() - 1;
+
+ final double pos1 = start + 1;
+ final double pos2 = len - 1;
+
+ if (getArrowConfiguration().getDecoration2() == ArrowDecoration.CIRCLE && dressing2.getHead() == ArrowHead.NONE) {
+ len -= diamCircle / 2;
+ }
+ if (getArrowConfiguration().getDecoration2() == ArrowDecoration.CIRCLE && dressing2.getHead() != ArrowHead.NONE) {
+ len -= diamCircle / 2 + thinCircle;
+ }
+
+ if (getArrowConfiguration().getDecoration1() == ArrowDecoration.CIRCLE && dressing1.getHead() == ArrowHead.NONE) {
+ start += diamCircle / 2;
+ len -= diamCircle / 2;
+ }
+ if (getArrowConfiguration().getDecoration1() == ArrowDecoration.CIRCLE
+ && dressing1.getHead() == ArrowHead.NORMAL) {
+ start += diamCircle + thinCircle;
+ len -= diamCircle + thinCircle;
+ }
+
+ drawDressing1(ug, pos1, dressing1, getArrowConfiguration().getDecoration1());
+ drawDressing2(ug, pos2, dressing2, getArrowConfiguration().getDecoration2());
+
+ if (dressing2.getPart() == ArrowPart.FULL && dressing2.getHead() == ArrowHead.NORMAL) {
+ len -= getArrowDeltaX() / 2;
+ }
+ if (dressing1.getPart() == ArrowPart.FULL && dressing1.getHead() == ArrowHead.NORMAL) {
+ start += getArrowDeltaX() / 2;
+ len -= getArrowDeltaX() / 2;
+ }
+
+ if (dressing2.getHead() == ArrowHead.CROSSX) {
+ len -= 2 * spaceCrossX;
+ }
+ if (dressing1.getHead() == ArrowHead.CROSSX) {
+ start += 2 * spaceCrossX;
+ len -= 2 * spaceCrossX;
+ }
+
+ if (getArrowConfiguration().isDotted()) {
+ ug = stroke(ug, 2, 2);
+ }
+ ug.apply(new UTranslate(start, textHeight)).draw(new ULine(len, 0));
+ if (getArrowConfiguration().isDotted()) {
+ ug = ug.apply(new UStroke());
+ }
+
+ final ArrowDirection direction2 = getDirection2();
+ final double textPos;
+ if (messagePosition == HorizontalAlignment.CENTER) {
+ final double textWidth = getTextBlock().calculateDimension(stringBounder).getWidth();
+ textPos = (dimensionToUse.getWidth() - textWidth) / 2;
+ } else if (messagePosition == HorizontalAlignment.RIGHT) {
+ final double textWidth = getTextBlock().calculateDimension(stringBounder).getWidth();
+ textPos = dimensionToUse.getWidth() - textWidth - getMarginX2()
+ - (direction2 == ArrowDirection.LEFT_TO_RIGHT_NORMAL ? getArrowDeltaX() : 0);
+ } else {
+ textPos = getMarginX1()
+ + (direction2 == ArrowDirection.RIGHT_TO_LEFT_REVERSE
+ || direction2 == ArrowDirection.BOTH_DIRECTION ? getArrowDeltaX() : 0);
+ }
+ getTextBlock().drawU(ug.apply(new UTranslate(textPos, 0)));
+ }
+
+ private void drawDressing1(UGraphic ug, double x, ArrowDressing dressing, ArrowDecoration decoration) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final int textHeight = (int) getTextHeight(stringBounder);
+
+ if (decoration == ArrowDecoration.CIRCLE) {
+ final UEllipse circle = new UEllipse(diamCircle, diamCircle);
+ ug.apply(new UStroke(thinCircle))
+ .apply(new UChangeColor(getForegroundColor()))
+ .apply(new UTranslate(x - diamCircle / 2 - thinCircle, textHeight - diamCircle / 2 - thinCircle / 2))
+ .draw(circle);
+ x += diamCircle / 2 + thinCircle;
+ }
+
+ if (dressing.getHead() == ArrowHead.ASYNC) {
+ if (dressing.getPart() != ArrowPart.BOTTOM_PART) {
+ ug.apply(new UTranslate(x - 1, textHeight)).draw(new ULine(getArrowDeltaX(), -getArrowDeltaY()));
+ }
+ if (dressing.getPart() != ArrowPart.TOP_PART) {
+ ug.apply(new UTranslate(x - 1, textHeight)).draw(new ULine(getArrowDeltaX(), getArrowDeltaY()));
+ }
+ } else if (dressing.getHead() == ArrowHead.CROSSX) {
+ ug = ug.apply(new UStroke(2));
+ ug.apply(new UTranslate(spaceCrossX, textHeight - getArrowDeltaX() / 2)).draw(
+ new ULine(getArrowDeltaX(), getArrowDeltaX()));
+ ug.apply(new UTranslate(spaceCrossX, textHeight + getArrowDeltaX() / 2)).draw(
+ new ULine(getArrowDeltaX(), -getArrowDeltaX()));
+ } else if (dressing.getHead() == ArrowHead.NORMAL) {
+ final UPolygon polygon = getPolygonReverse(dressing.getPart(), textHeight);
+ ug.apply(new UChangeBackColor(getForegroundColor())).apply(new UTranslate(x, 0)).draw(polygon);
+ }
+
+ }
+
+ private void drawDressing2(UGraphic ug, double x, ArrowDressing dressing, ArrowDecoration decoration) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final int textHeight = (int) getTextHeight(stringBounder);
+
+ if (decoration == ArrowDecoration.CIRCLE) {
+ ug = ug.apply(new UStroke(thinCircle)).apply(new UChangeColor(getForegroundColor()));
+ final UEllipse circle = new UEllipse(diamCircle, diamCircle);
+ ug.apply(new UTranslate(x - diamCircle / 2 + thinCircle, textHeight - diamCircle / 2 - thinCircle / 2))
+ .draw(circle);
+ ug = ug.apply(new UStroke());
+ x -= diamCircle / 2 + thinCircle;
+ }
+
+ if (dressing.getHead() == ArrowHead.ASYNC) {
+ if (dressing.getPart() != ArrowPart.BOTTOM_PART) {
+ ug.apply(new UTranslate(x, textHeight)).draw(new ULine(-getArrowDeltaX(), -getArrowDeltaY()));
+ }
+ if (dressing.getPart() != ArrowPart.TOP_PART) {
+ ug.apply(new UTranslate(x, textHeight)).draw(new ULine(-getArrowDeltaX(), getArrowDeltaY()));
+ }
+ } else if (dressing.getHead() == ArrowHead.CROSSX) {
+ ug = ug.apply(new UStroke(2));
+ ug.apply(new UTranslate(x - spaceCrossX - getArrowDeltaX(), textHeight - getArrowDeltaX() / 2)).draw(
+ new ULine(getArrowDeltaX(), getArrowDeltaX()));
+ ug.apply(new UTranslate(x - spaceCrossX - getArrowDeltaX(), textHeight + getArrowDeltaX() / 2)).draw(
+ new ULine(getArrowDeltaX(), -getArrowDeltaX()));
+ ug = ug.apply(new UStroke());
+ } else if (dressing.getHead() == ArrowHead.NORMAL) {
+ final UPolygon polygon = getPolygonNormal(dressing.getPart(), textHeight, x);
+ ug.apply(new UChangeBackColor(getForegroundColor())).draw(polygon);
+ }
+
+ }
+
+ private UPolygon getPolygonNormal(ArrowPart part, final int textHeight, final double x2) {
+ final UPolygon polygon = new UPolygon();
+ if (part == ArrowPart.TOP_PART) {
+ polygon.addPoint(x2 - getArrowDeltaX(), textHeight - getArrowDeltaY());
+ polygon.addPoint(x2, textHeight);
+ polygon.addPoint(x2 - getArrowDeltaX(), textHeight);
+ } else if (part == ArrowPart.BOTTOM_PART) {
+ polygon.addPoint(x2 - getArrowDeltaX(), textHeight + 1);
+ polygon.addPoint(x2, textHeight + 1);
+ polygon.addPoint(x2 - getArrowDeltaX(), textHeight + getArrowDeltaY() + 1);
+ } else {
+ polygon.addPoint(x2 - getArrowDeltaX(), textHeight - getArrowDeltaY());
+ polygon.addPoint(x2, textHeight);
+ polygon.addPoint(x2 - getArrowDeltaX(), textHeight + getArrowDeltaY());
+ if (niceArrow) {
+ polygon.addPoint(x2 - getArrowDeltaX() + 4, textHeight);
+ }
+ }
+ return polygon;
+ }
+
+ private UPolygon getPolygonReverse(ArrowPart part, final int textHeight) {
+ final UPolygon polygon = new UPolygon();
+ if (part == ArrowPart.TOP_PART) {
+ polygon.addPoint(getArrowDeltaX(), textHeight - getArrowDeltaY());
+ polygon.addPoint(0, textHeight);
+ polygon.addPoint(getArrowDeltaX(), textHeight);
+ } else if (part == ArrowPart.BOTTOM_PART) {
+ polygon.addPoint(getArrowDeltaX(), textHeight + 1);
+ polygon.addPoint(0, textHeight + 1);
+ polygon.addPoint(getArrowDeltaX(), textHeight + getArrowDeltaY() + 1);
+ } else {
+ polygon.addPoint(getArrowDeltaX(), textHeight - getArrowDeltaY());
+ polygon.addPoint(0, textHeight);
+ polygon.addPoint(getArrowDeltaX(), textHeight + getArrowDeltaY());
+ if (niceArrow) {
+ polygon.addPoint(getArrowDeltaX() - 4, textHeight);
+ }
+ }
+ return polygon;
+ }
+
+ public Point2D getStartPoint(StringBounder stringBounder, Dimension2D dimensionToUse) {
+ final int textHeight = (int) getTextHeight(stringBounder);
+ if (getDirection2() == ArrowDirection.LEFT_TO_RIGHT_NORMAL) {
+ return new Point2D.Double(getPaddingX(), textHeight + getPaddingY());
+ }
+ return new Point2D.Double(dimensionToUse.getWidth() + getPaddingX(), textHeight + getPaddingY());
+ }
+
+ public Point2D getEndPoint(StringBounder stringBounder, Dimension2D dimensionToUse) {
+ final int textHeight = (int) getTextHeight(stringBounder);
+ if (getDirection2() == ArrowDirection.LEFT_TO_RIGHT_NORMAL) {
+ return new Point2D.Double(dimensionToUse.getWidth() + getPaddingX(), textHeight + getPaddingY());
+ }
+ return new Point2D.Double(getPaddingX(), textHeight + getPaddingY());
+ }
+
+ final private ArrowDirection getDirection2() {
+ return getArrowConfiguration().getArrowDirection();
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return getTextHeight(stringBounder) + getArrowDeltaY() + 2 * getPaddingY();
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return getTextWidth(stringBounder) + getArrowDeltaX();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseBoundary.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseBoundary.java
new file mode 100644
index 0000000..a107d07
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseBoundary.java
@@ -0,0 +1,100 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin.rose;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.SymbolContext;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.skin.AbstractTextualComponent;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.svek.Boundary;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ComponentRoseBoundary extends AbstractTextualComponent {
+
+ private final TextBlock stickman;
+ private final boolean head;
+
+ public ComponentRoseBoundary(SymbolContext biColor, FontConfiguration font, Display stringsToDisplay, boolean head,
+ ISkinSimple spriteContainer, UFont fontForStereotype, HtmlColor htmlColorForStereotype) {
+ super(stringsToDisplay, font, HorizontalAlignment.CENTER, 3, 3, 0, spriteContainer, 0, false,
+ fontForStereotype, htmlColorForStereotype);
+ this.head = head;
+ this.stickman = new Boundary(biColor);
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, Area area) {
+ final TextBlock textBlock = getTextBlock();
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D dimStickman = stickman.calculateDimension(stringBounder);
+ final double delta = (getPreferredWidth(stringBounder) - dimStickman.getWidth()) / 2;
+
+ if (head) {
+ textBlock.drawU(ug.apply(new UTranslate(getTextMiddlePostion(stringBounder), dimStickman.getHeight())));
+ ug = ug.apply(new UTranslate(delta, 0));
+ } else {
+ textBlock.drawU(ug.apply(new UTranslate(getTextMiddlePostion(stringBounder), 0)));
+ ug = ug.apply(new UTranslate(delta, getTextHeight(stringBounder)));
+ }
+ stickman.drawU(ug);
+ }
+
+ private double getTextMiddlePostion(StringBounder stringBounder) {
+ return (getPreferredWidth(stringBounder) - getTextWidth(stringBounder)) / 2.0;
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ final Dimension2D dimStickman = stickman.calculateDimension(stringBounder);
+ return dimStickman.getHeight() + getTextHeight(stringBounder);
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ final Dimension2D dimStickman = stickman.calculateDimension(stringBounder);
+ return Math.max(dimStickman.getWidth(), getTextWidth(stringBounder));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseControl.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseControl.java
new file mode 100644
index 0000000..2ea4182
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseControl.java
@@ -0,0 +1,100 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin.rose;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.SymbolContext;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.skin.AbstractTextualComponent;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.svek.Control;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ComponentRoseControl extends AbstractTextualComponent {
+
+ private final TextBlock stickman;
+ private final boolean head;
+
+ public ComponentRoseControl(SymbolContext biColor, FontConfiguration font, Display stringsToDisplay, boolean head,
+ ISkinSimple spriteContainer, UFont fontForStereotype, HtmlColor htmlColorForStereotype) {
+ super(stringsToDisplay, font, HorizontalAlignment.CENTER, 3, 3, 0, spriteContainer, 0, false,
+ fontForStereotype, htmlColorForStereotype);
+ this.head = head;
+ this.stickman = new Control(biColor);
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, Area area) {
+ final TextBlock textBlock = getTextBlock();
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D dimStickman = stickman.calculateDimension(stringBounder);
+ final double delta = (getPreferredWidth(stringBounder) - dimStickman.getWidth()) / 2;
+
+ if (head) {
+ textBlock.drawU(ug.apply(new UTranslate(getTextMiddlePostion(stringBounder), dimStickman.getHeight())));
+ ug = ug.apply(new UTranslate(delta, 0));
+ } else {
+ textBlock.drawU(ug.apply(new UTranslate(getTextMiddlePostion(stringBounder), 0)));
+ ug = ug.apply(new UTranslate(delta, getTextHeight(stringBounder)));
+ }
+ stickman.drawU(ug);
+ }
+
+ private double getTextMiddlePostion(StringBounder stringBounder) {
+ return (getPreferredWidth(stringBounder) - getTextWidth(stringBounder)) / 2.0;
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ final Dimension2D dimStickman = stickman.calculateDimension(stringBounder);
+ return dimStickman.getHeight() + getTextHeight(stringBounder);
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ final Dimension2D dimStickman = stickman.calculateDimension(stringBounder);
+ return Math.max(dimStickman.getWidth(), getTextWidth(stringBounder));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseDatabase.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseDatabase.java
new file mode 100644
index 0000000..4c18cef
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseDatabase.java
@@ -0,0 +1,106 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin.rose;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.SymbolContext;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.graphic.USymbol;
+import net.sourceforge.plantuml.skin.AbstractTextualComponent;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ComponentRoseDatabase extends AbstractTextualComponent {
+
+ private final TextBlock stickman;
+ private final boolean head;
+
+ public ComponentRoseDatabase(SymbolContext biColor, FontConfiguration font, Display stringsToDisplay, boolean head,
+ ISkinSimple spriteContainer, UFont fontForStereotype, HtmlColor htmlColorForStereotype) {
+ super(stringsToDisplay, font, HorizontalAlignment.CENTER, 3, 3, 0, spriteContainer, 0, false,
+ fontForStereotype, htmlColorForStereotype);
+ this.head = head;
+
+ final SymbolContext symbolContext = new SymbolContext(biColor.getBackColor(), biColor.getForeColor())
+ .withStroke(new UStroke(1.5)).withShadow(biColor.getDeltaShadow() > 0);
+ this.stickman = USymbol.DATABASE.asSmall(TextBlockUtils.empty(16, 17), TextBlockUtils.empty(0, 0),
+ symbolContext);
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, Area area) {
+ final TextBlock textBlock = getTextBlock();
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D dimStickman = stickman.calculateDimension(stringBounder);
+ final double delta = (getPreferredWidth(stringBounder) - dimStickman.getWidth()) / 2;
+
+ if (head) {
+ textBlock.drawU(ug.apply(new UTranslate(getTextMiddlePostion(stringBounder), dimStickman.getHeight())));
+ ug = ug.apply(new UTranslate(delta, 0));
+ } else {
+ textBlock.drawU(ug.apply(new UTranslate(getTextMiddlePostion(stringBounder), 0)));
+ ug = ug.apply(new UTranslate(delta, getTextHeight(stringBounder)));
+ }
+ stickman.drawU(ug);
+ }
+
+ private double getTextMiddlePostion(StringBounder stringBounder) {
+ return (getPreferredWidth(stringBounder) - getTextWidth(stringBounder)) / 2.0;
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ final Dimension2D dimStickman = stickman.calculateDimension(stringBounder);
+ return dimStickman.getHeight() + getTextHeight(stringBounder);
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ final Dimension2D dimStickman = stickman.calculateDimension(stringBounder);
+ return Math.max(dimStickman.getWidth(), getTextWidth(stringBounder));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseDelayLine.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseDelayLine.java
new file mode 100644
index 0000000..90ad857
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseDelayLine.java
@@ -0,0 +1,75 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin.rose;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.AbstractComponent;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.ugraphic.UAntiAliasing;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ComponentRoseDelayLine extends AbstractComponent {
+
+ private final HtmlColor color;
+
+ public ComponentRoseDelayLine(HtmlColor color) {
+ this.color = color;
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, Area area) {
+ final Dimension2D dimensionToUse = area.getDimensionToUse();
+ ug = stroke(ug, 1, 4).apply(new UChangeColor(color));
+ final int x = (int) (dimensionToUse.getWidth() / 2);
+ ug.apply(UAntiAliasing.ANTI_ALIASING_OFF).apply(new UTranslate(x, 0)).draw(new ULine(0, dimensionToUse.getHeight()));
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return 20;
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return 1;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseDelayText.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseDelayText.java
new file mode 100644
index 0000000..8bc81bd
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseDelayText.java
@@ -0,0 +1,81 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin.rose;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.cucadiagram.Display;
+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.skin.AbstractTextualComponent;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ComponentRoseDelayText extends AbstractTextualComponent {
+
+ public ComponentRoseDelayText(FontConfiguration font, Display stringsToDisplay, ISkinSimple spriteContainer) {
+ super(stringsToDisplay, font, HorizontalAlignment.CENTER, 0, 0, 4,
+ spriteContainer, 0, false, null, null);
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, Area area) {
+ final Dimension2D dimensionToUse = area.getDimensionToUse();
+ final TextBlock textBlock = getTextBlock();
+ final StringBounder stringBounder = ug.getStringBounder();
+ final double textWidth = getTextWidth(stringBounder);
+ final double textHeight = getTextHeight(stringBounder);
+
+ final double xpos = (dimensionToUse.getWidth() - textWidth) / 2;
+ final double ypos = (dimensionToUse.getHeight() - textHeight) / 2;
+
+ textBlock.drawU(ug.apply(new UTranslate(xpos, (ypos + getMarginY()))));
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return getTextHeight(stringBounder) + 20;
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return getPureTextWidth(stringBounder);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseDestroy.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseDestroy.java
new file mode 100644
index 0000000..810599e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseDestroy.java
@@ -0,0 +1,75 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin.rose;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.AbstractComponent;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ComponentRoseDestroy extends AbstractComponent {
+
+ private final HtmlColor foregroundColor;
+
+ public ComponentRoseDestroy(HtmlColor foregroundColor) {
+ this.foregroundColor = foregroundColor;
+ }
+
+ private final int crossSize = 9;
+
+ @Override
+ protected void drawInternalU(UGraphic ug, Area area) {
+ ug = ug.apply(new UStroke(2)).apply(new UChangeColor(foregroundColor));
+
+ ug.draw(new ULine(2 * crossSize, 2 * crossSize));
+ ug.apply(new UTranslate(0, 2 * crossSize)).draw(new ULine(2 * crossSize, -2 * crossSize));
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return crossSize * 2;
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return crossSize * 2;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseDivider.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseDivider.java
new file mode 100644
index 0000000..b1e8a37
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseDivider.java
@@ -0,0 +1,139 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin.rose;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.skin.AbstractTextualComponent;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ComponentRoseDivider extends AbstractTextualComponent {
+
+ // private final int outMargin = 5;
+ private final HtmlColor background;
+ private final boolean empty;
+ private final boolean withShadow;
+ private final UStroke stroke;
+
+ public ComponentRoseDivider(FontConfiguration font, HtmlColor background, Display stringsToDisplay,
+ ISkinSimple spriteContainer, boolean withShadow, UStroke stroke) {
+ super(stringsToDisplay, font, HorizontalAlignment.CENTER, 4, 4, 4,
+ spriteContainer, 0, false, null, null);
+ this.background = background;
+ this.empty = stringsToDisplay.get(0).length() == 0;
+ this.withShadow = withShadow;
+ this.stroke = stroke;
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, Area area) {
+ final Dimension2D dimensionToUse = area.getDimensionToUse();
+
+ ug = ug.apply(new UChangeBackColor(background));
+ if (empty) {
+ drawSep(ug.apply(new UTranslate(0, dimensionToUse.getHeight() / 2)), dimensionToUse.getWidth());
+ } else {
+ final TextBlock textBlock = getTextBlock();
+ final StringBounder stringBounder = ug.getStringBounder();
+ final double textWidth = getTextWidth(stringBounder);
+ final double textHeight = getTextHeight(stringBounder);
+ final double deltaX = 6;
+ final double xpos = (dimensionToUse.getWidth() - textWidth - deltaX) / 2;
+ final double ypos = (dimensionToUse.getHeight() - textHeight) / 2;
+
+ drawSep(ug.apply(new UTranslate(0, dimensionToUse.getHeight() / 2)), dimensionToUse.getWidth());
+
+ ug = ug.apply(new UChangeColor(HtmlColorUtils.BLACK));
+ ug = ug.apply(stroke);
+ final URectangle rect = new URectangle(textWidth + deltaX, textHeight);
+ if (withShadow) {
+ rect.setDeltaShadow(4);
+ }
+ ug.apply(new UTranslate(xpos, ypos)).draw(rect);
+ textBlock.drawU(ug.apply(new UTranslate(xpos + deltaX, ypos + getMarginY())));
+
+ // drawSep(ug.apply(new UTranslate(xpos + deltaX + textWidth + stroke.getThickness() + , dimensionToUse
+ // .getHeight() / 2)), 10);
+ }
+ }
+
+ private void drawSep(UGraphic ug, double width) {
+ ug = ug.apply(new UChangeColor(background));
+ drawRectLong(ug.apply(new UTranslate(0, -1)), width);
+ drawDoubleLine(ug, width);
+ }
+
+ private void drawRectLong(UGraphic ug, double width) {
+ final URectangle rectLong = new URectangle(width, 3);
+ if (withShadow) {
+ rectLong.setDeltaShadow(2);
+ }
+ ug = ug.apply(new UStroke());
+ ug.draw(rectLong);
+ }
+
+ private void drawDoubleLine(UGraphic ug, final double width) {
+ ug = ug.apply(new UStroke(stroke.getThickness() / 2)).apply(new UChangeColor(HtmlColorUtils.BLACK));
+ final ULine line = new ULine(width, 0);
+ ug.apply(new UTranslate(0, -1)).draw(line);
+ ug.apply(new UTranslate(0, 2)).draw(line);
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return getTextHeight(stringBounder) + 20;
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return getTextWidth(stringBounder) + 30;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseEnglober.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseEnglober.java
new file mode 100644
index 0000000..0e296b4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseEnglober.java
@@ -0,0 +1,86 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin.rose;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.SymbolContext;
+import net.sourceforge.plantuml.skin.AbstractTextualComponent;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ComponentRoseEnglober extends AbstractTextualComponent {
+
+ private final SymbolContext symbolContext;
+
+ public ComponentRoseEnglober(SymbolContext symbolContext, Display strings, FontConfiguration font, ISkinSimple spriteContainer) {
+ super(strings, font, HorizontalAlignment.CENTER, 3, 3, 1, spriteContainer, 0, false, null, null);
+ this.symbolContext = symbolContext;
+ }
+
+ @Override
+ protected void drawBackgroundInternalU(UGraphic ug, Area area) {
+ final Dimension2D dimensionToUse = area.getDimensionToUse();
+ ug = symbolContext.apply(ug);
+ ug.draw(new URectangle(dimensionToUse.getWidth(), dimensionToUse.getHeight()));
+ final double xpos = (dimensionToUse.getWidth() - getPureTextWidth(ug.getStringBounder())) / 2;
+ getTextBlock().drawU(ug.apply(new UTranslate(xpos, 0)));
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, Area area) {
+ // ug.getParam().setColor(Color.RED);
+ // ug.getParam().setBackcolor(Color.YELLOW);
+ // ug.draw(0, 0, new URectangle(dimensionToUse.getWidth(),
+ // dimensionToUse.getHeight()));
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return getTextHeight(stringBounder) + 3;
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return getTextWidth(stringBounder);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseEntity.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseEntity.java
new file mode 100644
index 0000000..e0b3d2e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseEntity.java
@@ -0,0 +1,100 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin.rose;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.SymbolContext;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.skin.AbstractTextualComponent;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.svek.EntityDomain;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ComponentRoseEntity extends AbstractTextualComponent {
+
+ private final TextBlock stickman;
+ private final boolean head;
+
+ public ComponentRoseEntity(SymbolContext biColor, FontConfiguration font, Display stringsToDisplay, boolean head,
+ ISkinSimple spriteContainer, UFont fontForStereotype, HtmlColor htmlColorForStereotype) {
+ super(stringsToDisplay, font, HorizontalAlignment.CENTER, 3, 3, 0, spriteContainer, 0, false,
+ fontForStereotype, htmlColorForStereotype);
+ this.head = head;
+ this.stickman = new EntityDomain(biColor);
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, Area area) {
+ final TextBlock textBlock = getTextBlock();
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D dimStickman = stickman.calculateDimension(stringBounder);
+ final double delta = (getPreferredWidth(stringBounder) - dimStickman.getWidth()) / 2;
+
+ if (head) {
+ textBlock.drawU(ug.apply(new UTranslate(getTextMiddlePostion(stringBounder), dimStickman.getHeight())));
+ ug = ug.apply(new UTranslate(delta, 0));
+ } else {
+ textBlock.drawU(ug.apply(new UTranslate(getTextMiddlePostion(stringBounder), 0)));
+ ug = ug.apply(new UTranslate(delta, getTextHeight(stringBounder)));
+ }
+ stickman.drawU(ug);
+ }
+
+ private double getTextMiddlePostion(StringBounder stringBounder) {
+ return (getPreferredWidth(stringBounder) - getTextWidth(stringBounder)) / 2.0;
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ final Dimension2D dimStickman = stickman.calculateDimension(stringBounder);
+ return dimStickman.getHeight() + getTextHeight(stringBounder);
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ final Dimension2D dimStickman = stickman.calculateDimension(stringBounder);
+ return Math.max(dimStickman.getWidth(), getTextWidth(stringBounder));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingElse.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingElse.java
new file mode 100644
index 0000000..0a3421f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingElse.java
@@ -0,0 +1,96 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin.rose;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.AbstractTextualComponent;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ComponentRoseGroupingElse extends AbstractTextualComponent {
+
+ private final HtmlColor groupBorder;
+ private final HtmlColor backgroundColor;
+
+ // private final UStroke stroke;
+
+ public ComponentRoseGroupingElse(HtmlColor groupBorder, FontConfiguration smallFont, CharSequence comment,
+ ISkinSimple spriteContainer, HtmlColor backgroundColor) {
+ super(comment == null ? null : "[" + comment + "]", smallFont, HorizontalAlignment.LEFT, 5, 5, 1,
+ spriteContainer, 0, null, null);
+ this.groupBorder = groupBorder;
+ this.backgroundColor = backgroundColor;
+ // this.stroke = stroke;
+ }
+
+ @Override
+ protected void drawBackgroundInternalU(UGraphic ug, Area area) {
+ final Dimension2D dimensionToUse = area.getDimensionToUse();
+ final URectangle rect = new URectangle(dimensionToUse.getWidth(), dimensionToUse.getHeight());
+ ug.apply(new UChangeColor(null)).apply(new UChangeBackColor(backgroundColor)).draw(rect);
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, Area area) {
+ final Dimension2D dimensionToUse = area.getDimensionToUse();
+ ug = stroke(ug, 2, 2).apply(new UChangeColor(groupBorder));
+ ug.apply(new UTranslate(0, 1)).draw(new ULine(dimensionToUse.getWidth(), 0));
+ ug = ug.apply(new UStroke());
+ getTextBlock().drawU(ug.apply(new UTranslate(getMarginX1(), getMarginY())));
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return getTextHeight(stringBounder);
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return getTextWidth(stringBounder);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingHeader.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingHeader.java
new file mode 100644
index 0000000..6944322
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingHeader.java
@@ -0,0 +1,162 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin.rose;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.SymbolContext;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.skin.AbstractTextualComponent;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ComponentRoseGroupingHeader extends AbstractTextualComponent {
+
+ private final int cornersize = 10;
+ private final int commentMargin = 0; // 8;
+
+ private final TextBlock commentTextBlock;
+
+ private final HtmlColor background;
+ private final SymbolContext symbolContext;
+
+ public ComponentRoseGroupingHeader(HtmlColor background, SymbolContext symbolContext, FontConfiguration bigFont, UFont smallFont,
+ Display strings, ISkinSimple spriteContainer) {
+ super(strings.get(0), bigFont, HorizontalAlignment.LEFT, 15, 30, 1, spriteContainer, 0, null, null);
+ this.symbolContext = symbolContext;
+ this.background = background;
+ if (strings.size() == 1 || strings.get(1) == null) {
+ this.commentTextBlock = null;
+ } else {
+ final Display display = Display.getWithNewlines("[" + strings.get(1) + "]");
+ this.commentTextBlock = TextBlockUtils.create(display, new FontConfiguration(smallFont, bigFont.getColor(),
+ bigFont.getHyperlinkColor(), bigFont.useUnderlineForHyperlink()), HorizontalAlignment.LEFT,
+ spriteContainer);
+ }
+ if (this.background == null) {
+ throw new IllegalArgumentException();
+ }
+
+ }
+
+ private double getSuppHeightForComment(StringBounder stringBounder) {
+ if (commentTextBlock == null) {
+ return 0;
+ }
+ final double height = commentTextBlock.calculateDimension(stringBounder).getHeight();
+ if (height > 15) {
+ return height - 15;
+ }
+ return 0;
+
+ }
+
+ @Override
+ final public double getPreferredWidth(StringBounder stringBounder) {
+ final double sup;
+ if (commentTextBlock == null) {
+ sup = commentMargin * 2;
+ } else {
+ final Dimension2D size = commentTextBlock.calculateDimension(stringBounder);
+ sup = getMarginX1() + commentMargin + size.getWidth();
+
+ }
+ return getTextWidth(stringBounder) + sup;
+ }
+
+ @Override
+ final public double getPreferredHeight(StringBounder stringBounder) {
+ return getTextHeight(stringBounder) + 2 * getPaddingY() + getSuppHeightForComment(stringBounder);
+ }
+
+ @Override
+ protected void drawBackgroundInternalU(UGraphic ug, Area area) {
+ final Dimension2D dimensionToUse = area.getDimensionToUse();
+ ug = symbolContext.applyStroke(ug).apply(new UChangeColor(symbolContext.getForeColor()));
+ final URectangle rect = new URectangle(dimensionToUse.getWidth(), dimensionToUse.getHeight());
+ rect.setDeltaShadow(symbolContext.getDeltaShadow());
+ ug.apply(new UChangeBackColor(background)).draw(rect);
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, Area area) {
+ final Dimension2D dimensionToUse = area.getDimensionToUse();
+ ug = symbolContext.applyStroke(ug).apply(new UChangeColor(symbolContext.getForeColor()));
+ final URectangle rect = new URectangle(dimensionToUse.getWidth(), dimensionToUse.getHeight());
+ ug.draw(rect);
+
+ final StringBounder stringBounder = ug.getStringBounder();
+ final int textWidth = (int) getTextWidth(stringBounder);
+ final int textHeight = (int) getTextHeight(stringBounder);
+
+ final UPolygon polygon = new UPolygon();
+ polygon.addPoint(0, 0);
+ polygon.addPoint(textWidth, 0);
+
+ polygon.addPoint(textWidth, textHeight - cornersize);
+ polygon.addPoint(textWidth - cornersize, textHeight);
+
+ polygon.addPoint(0, textHeight);
+ polygon.addPoint(0, 0);
+
+ symbolContext.applyColors(ug).draw(polygon);
+
+ ug = ug.apply(new UStroke());
+
+ getTextBlock().drawU(ug.apply(new UTranslate(getMarginX1(), getMarginY())));
+
+ if (commentTextBlock != null) {
+ final int x1 = getMarginX1() + textWidth;
+ final int y2 = getMarginY() + 1;
+
+ commentTextBlock.drawU(ug.apply(new UTranslate(x1 + commentMargin, y2)));
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingSpace.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingSpace.java
new file mode 100644
index 0000000..6243331
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingSpace.java
@@ -0,0 +1,71 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin.rose;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.Context2D;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class ComponentRoseGroupingSpace implements Component {
+
+ private final double space;
+
+ public ComponentRoseGroupingSpace(double space) {
+ this.space = space;
+ }
+
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return 0;
+ }
+
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return space;
+ }
+
+ public void drawU(UGraphic ug, Area area, Context2D context) {
+ }
+
+ public final Dimension2D getPreferredDimension(StringBounder stringBounder) {
+ final double w = getPreferredWidth(stringBounder);
+ final double h = getPreferredHeight(stringBounder);
+ return new Dimension2DDouble(w, h);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseLine.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseLine.java
new file mode 100644
index 0000000..30abb6e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseLine.java
@@ -0,0 +1,84 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin.rose;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.AbstractComponent;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ComponentRoseLine extends AbstractComponent {
+
+ private final HtmlColor color;
+ private final boolean continueLine;
+ private final UStroke stroke;
+
+ public ComponentRoseLine(HtmlColor color, boolean continueLine, UStroke stroke) {
+ this.color = color;
+ this.continueLine = continueLine;
+ this.stroke = stroke;
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, Area area) {
+ final Dimension2D dimensionToUse = area.getDimensionToUse();
+ ug = ug.apply(new UChangeColor(color));
+ if (continueLine) {
+ ug = ug.apply(new UStroke());
+ } else {
+ ug = stroke(ug, 5, 5, stroke.getThickness());
+ }
+ final int x = (int) (dimensionToUse.getWidth() / 2);
+ ug.apply(new UTranslate(x, 0)).draw(new ULine(0, dimensionToUse.getHeight()));
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return 20;
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return 1;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNewpage.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNewpage.java
new file mode 100644
index 0000000..2ecac3a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNewpage.java
@@ -0,0 +1,72 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin.rose;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.AbstractComponent;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+
+public class ComponentRoseNewpage extends AbstractComponent {
+
+ private final HtmlColor foregroundColor;
+
+ public ComponentRoseNewpage(HtmlColor foregroundColor) {
+ this.foregroundColor = foregroundColor;
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, Area area) {
+ final Dimension2D dimensionToUse = area.getDimensionToUse();
+ ug = stroke(ug, 2, 2).apply(new UChangeColor(foregroundColor));
+ ug.draw(new ULine(dimensionToUse.getWidth(), 0));
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return 1;
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return 0;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNote.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNote.java
new file mode 100644
index 0000000..56ee046
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNote.java
@@ -0,0 +1,136 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin.rose;
+
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.creole.Stencil;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.SymbolContext;
+import net.sourceforge.plantuml.skin.AbstractTextualComponent;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UGraphicStencil;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+final public class ComponentRoseNote extends AbstractTextualComponent implements Stencil {
+
+ private final int cornersize = 10;
+ private final double paddingX;
+ private final double paddingY;
+ private final SymbolContext symbolContext;
+
+ public ComponentRoseNote(SymbolContext symbolContext, FontConfiguration font, Display strings, double paddingX, double paddingY,
+ ISkinSimple spriteContainer) {
+ super(strings, font, HorizontalAlignment.LEFT, 6, 15, 5, spriteContainer, 0, true, null, null);
+ this.paddingX = paddingX;
+ this.paddingY = paddingY;
+ this.symbolContext = symbolContext;
+ }
+
+ @Override
+ final public double getPreferredWidth(StringBounder stringBounder) {
+ final double result = getTextWidth(stringBounder) + 2 * getPaddingX() + symbolContext.getDeltaShadow();
+ return result;
+ }
+
+ @Override
+ final public double getPreferredHeight(StringBounder stringBounder) {
+ return getTextHeight(stringBounder) + 2 * getPaddingY() + symbolContext.getDeltaShadow();
+ }
+
+ @Override
+ public double getPaddingX() {
+ return paddingX;
+ }
+
+ @Override
+ public double getPaddingY() {
+ return paddingY;
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, Area area) {
+
+ final StringBounder stringBounder = ug.getStringBounder();
+ final int textHeight = (int) getTextHeight(stringBounder);
+
+ int x2 = (int) getTextWidth(stringBounder);
+ final double diffX = area.getDimensionToUse().getWidth() - getPreferredWidth(stringBounder);
+ if (diffX < 0) {
+ throw new IllegalArgumentException();
+ }
+ if (area.getDimensionToUse().getWidth() > getPreferredWidth(stringBounder)) {
+ x2 = (int) (area.getDimensionToUse().getWidth() - 2 * getPaddingX());
+ }
+
+ final UPolygon polygon = new UPolygon();
+ polygon.addPoint(0, 0);
+ polygon.addPoint(0, textHeight);
+ polygon.addPoint(x2, textHeight);
+ polygon.addPoint(x2, cornersize);
+ polygon.addPoint(x2 - cornersize, 0);
+ polygon.addPoint(0, 0);
+ polygon.setDeltaShadow(symbolContext.getDeltaShadow());
+
+ ug = symbolContext.apply(ug);
+ ug.draw(polygon);
+
+ ug.apply(new UTranslate(x2 - cornersize, 0)).draw(new ULine(0, cornersize));
+ ug.apply(new UTranslate(x2, cornersize)).draw(new ULine(-cornersize, 0));
+ UGraphic ug2 = new UGraphicStencil(ug, this, new UStroke());
+ ug2 = ug2.apply(new UTranslate(getMarginX1() + diffX / 2, getMarginY()));
+
+ getTextBlock().drawU(ug2);
+
+ }
+
+ public double getStartingX(StringBounder stringBounder, double y) {
+ return 0;
+ }
+
+ public double getEndingX(StringBounder stringBounder, double y) {
+ return getTextWidth(stringBounder);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNoteBox.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNoteBox.java
new file mode 100644
index 0000000..cac5ef9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNoteBox.java
@@ -0,0 +1,104 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin.rose;
+
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.SymbolContext;
+import net.sourceforge.plantuml.skin.AbstractTextualComponent;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+final public class ComponentRoseNoteBox extends AbstractTextualComponent {
+
+ private final SymbolContext symbolContext;
+
+ public ComponentRoseNoteBox(SymbolContext symbolContext, FontConfiguration font, Display strings,
+ ISkinSimple spriteContainer) {
+ super(strings, font, HorizontalAlignment.LEFT, 4, 4, 4, spriteContainer, 0, false, null, null);
+ this.symbolContext = symbolContext;
+ }
+
+ @Override
+ final public double getPreferredWidth(StringBounder stringBounder) {
+ final double result = getTextWidth(stringBounder) + 2 * getPaddingX();
+ return result;
+ }
+
+ @Override
+ final public double getPreferredHeight(StringBounder stringBounder) {
+ return getTextHeight(stringBounder) + 2 * getPaddingY();
+ }
+
+ @Override
+ public double getPaddingX() {
+ return 5;
+ }
+
+ @Override
+ public double getPaddingY() {
+ return 5;
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, Area area) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final int textHeight = (int) getTextHeight(stringBounder);
+
+ int x2 = (int) getTextWidth(stringBounder);
+ final double diffX = area.getDimensionToUse().getWidth() - getPreferredWidth(stringBounder);
+ if (diffX < 0) {
+ throw new IllegalArgumentException();
+ }
+ if (area.getDimensionToUse().getWidth() > getPreferredWidth(stringBounder)) {
+ x2 = (int) (area.getDimensionToUse().getWidth() - 2 * getPaddingX());
+ }
+
+ ug = symbolContext.apply(ug);
+ final URectangle rect = new URectangle(x2, textHeight);
+ rect.setDeltaShadow(symbolContext.getDeltaShadow());
+ ug.draw(rect);
+ ug = ug.apply(new UStroke());
+
+ getTextBlock().drawU(ug.apply(new UTranslate(getMarginX1() + diffX / 2, getMarginY())));
+
+ }
+}
diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNoteHexagonal.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNoteHexagonal.java
new file mode 100644
index 0000000..b6505cc
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNoteHexagonal.java
@@ -0,0 +1,115 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin.rose;
+
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.SymbolContext;
+import net.sourceforge.plantuml.skin.AbstractTextualComponent;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+final public class ComponentRoseNoteHexagonal extends AbstractTextualComponent {
+
+ private final int cornersize = 10;
+ private final SymbolContext symbolContext;
+
+
+ public ComponentRoseNoteHexagonal(SymbolContext symbolContext, FontConfiguration font, Display strings,
+ ISkinSimple spriteContainer) {
+ super(strings, font, HorizontalAlignment.LEFT, 12, 12, 4, spriteContainer, 0, false, null, null);
+ this.symbolContext = symbolContext;
+ }
+
+ @Override
+ final public double getPreferredWidth(StringBounder stringBounder) {
+ final double result = getTextWidth(stringBounder) + 2 * getPaddingX();
+ return result;
+ }
+
+ @Override
+ final public double getPreferredHeight(StringBounder stringBounder) {
+ return getTextHeight(stringBounder) + 2 * getPaddingY();
+ }
+
+ @Override
+ public double getPaddingX() {
+ return 5;
+ }
+
+ @Override
+ public double getPaddingY() {
+ return 5;
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, Area area) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final int textHeight = (int) getTextHeight(stringBounder);
+
+ int x2 = (int) getTextWidth(stringBounder);
+ final double diffX = area.getDimensionToUse().getWidth() - getPreferredWidth(stringBounder);
+ if (diffX < 0) {
+ throw new IllegalArgumentException();
+ }
+ if (area.getDimensionToUse().getWidth() > getPreferredWidth(stringBounder)) {
+ x2 = (int) (area.getDimensionToUse().getWidth() - 2 * getPaddingX());
+ }
+
+ final UPolygon polygon = new UPolygon();
+ polygon.addPoint(cornersize, 0);
+ polygon.addPoint(x2 - cornersize, 0);
+ polygon.addPoint(x2, textHeight / 2);
+ polygon.addPoint(x2 - cornersize, textHeight);
+ polygon.addPoint(cornersize, textHeight);
+ polygon.addPoint(0, textHeight / 2);
+ polygon.addPoint(cornersize, 0);
+
+ ug = symbolContext.apply(ug);
+ polygon.setDeltaShadow(symbolContext.getDeltaShadow());
+ ug.draw(polygon);
+ ug = ug.apply(new UStroke());
+
+ getTextBlock().drawU(ug.apply(new UTranslate(getMarginX1() + diffX / 2, getMarginY())));
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseParticipant.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseParticipant.java
new file mode 100644
index 0000000..b9cb2dd
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseParticipant.java
@@ -0,0 +1,98 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin.rose;
+
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.SymbolContext;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.skin.AbstractTextualComponent;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ComponentRoseParticipant extends AbstractTextualComponent {
+
+ private final HtmlColor back;
+ private final HtmlColor foregroundColor;
+ private final double deltaShadow;
+ private final double roundCorner;
+ private final UStroke stroke;
+
+ public ComponentRoseParticipant(SymbolContext biColor, FontConfiguration font, Display stringsToDisplay,
+ ISkinSimple spriteContainer, double roundCorner, UFont fontForStereotype,
+ HtmlColor htmlColorForStereotype) {
+ super(stringsToDisplay, font, HorizontalAlignment.CENTER, 7, 7, 7, spriteContainer, 0, false,
+ fontForStereotype, htmlColorForStereotype);
+ this.back = biColor.getBackColor();
+ this.roundCorner = roundCorner;
+ this.deltaShadow = biColor.getDeltaShadow();
+ this.foregroundColor = biColor.getForeColor();
+ this.stroke = biColor.getStroke();
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, Area area) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ ug = ug.apply(new UChangeBackColor(back)).apply(new UChangeColor(foregroundColor));
+ ug = ug.apply(stroke);
+ final URectangle rect = new URectangle(getTextWidth(stringBounder), getTextHeight(stringBounder), roundCorner,
+ roundCorner);
+ rect.setDeltaShadow(deltaShadow);
+ ug.draw(rect);
+ ug = ug.apply(new UStroke());
+ final TextBlock textBlock = getTextBlock();
+ textBlock.drawU(ug.apply(new UTranslate(getMarginX1(), getMarginY())));
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return getTextHeight(stringBounder) + deltaShadow + 1;
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return getTextWidth(stringBounder) + deltaShadow;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseReference.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseReference.java
new file mode 100644
index 0000000..25cbc61
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseReference.java
@@ -0,0 +1,143 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin.rose;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.SymbolContext;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.skin.AbstractTextualComponent;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ComponentRoseReference extends AbstractTextualComponent {
+
+ private final HtmlColor background;
+ private final int cornersize = 10;
+ private final TextBlock textHeader;
+ private final double heightFooter = 5;
+ private final double xMargin = 2;
+ private final HorizontalAlignment position;
+ private final SymbolContext symbolContext;
+
+ public ComponentRoseReference(FontConfiguration font, SymbolContext symbolContext, FontConfiguration header,
+ Display stringsToDisplay, HorizontalAlignment position, ISkinSimple spriteContainer, HtmlColor background) {
+ super(stringsToDisplay.subList(1, stringsToDisplay.size()), font, HorizontalAlignment.LEFT, 4, 4, 4,
+ spriteContainer, 0, false, null, null);
+ this.position = position;
+ this.symbolContext = symbolContext;
+ this.background = background;
+
+ this.textHeader = TextBlockUtils.create(stringsToDisplay.subList(0, 1), header, HorizontalAlignment.LEFT,
+ spriteContainer);
+
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, Area area) {
+ final Dimension2D dimensionToUse = area.getDimensionToUse();
+ final StringBounder stringBounder = ug.getStringBounder();
+ final int textHeaderWidth = (int) (getHeaderWidth(stringBounder));
+ final int textHeaderHeight = (int) (getHeaderHeight(stringBounder));
+
+ final URectangle rect = new URectangle(
+ dimensionToUse.getWidth() - xMargin * 2 - symbolContext.getDeltaShadow(), dimensionToUse.getHeight()
+ - heightFooter);
+ rect.setDeltaShadow(symbolContext.getDeltaShadow());
+ ug = symbolContext.withBackColor(background).apply(ug);
+ ug.apply(new UTranslate(xMargin, 0)).draw(rect);
+
+ final UPolygon polygon = new UPolygon();
+ polygon.addPoint(0, 0);
+ polygon.addPoint(textHeaderWidth, 0);
+
+ polygon.addPoint(textHeaderWidth, textHeaderHeight - cornersize);
+ polygon.addPoint(textHeaderWidth - cornersize, textHeaderHeight);
+
+ polygon.addPoint(0, textHeaderHeight);
+ polygon.addPoint(0, 0);
+
+ ug = symbolContext.apply(ug);
+ ug.apply(new UTranslate(xMargin, 0)).draw(polygon);
+
+ ug = ug.apply(new UStroke());
+
+ textHeader.drawU(ug.apply(new UTranslate(15, 2)));
+ final double textPos;
+ if (position == HorizontalAlignment.CENTER) {
+ final double textWidth = getTextBlock().calculateDimension(stringBounder).getWidth();
+ textPos = (dimensionToUse.getWidth() - textWidth) / 2;
+ } else if (position == HorizontalAlignment.RIGHT) {
+ final double textWidth = getTextBlock().calculateDimension(stringBounder).getWidth();
+ textPos = dimensionToUse.getWidth() - textWidth - getMarginX2() - xMargin;
+ } else {
+ textPos = getMarginX1() + xMargin;
+ }
+ getTextBlock().drawU(ug.apply(new UTranslate(textPos, (getMarginY() + textHeaderHeight))));
+ }
+
+ private double getHeaderHeight(StringBounder stringBounder) {
+ final Dimension2D headerDim = textHeader.calculateDimension(stringBounder);
+ return headerDim.getHeight() + 2 * 1;
+ }
+
+ private double getHeaderWidth(StringBounder stringBounder) {
+ final Dimension2D headerDim = textHeader.calculateDimension(stringBounder);
+ return headerDim.getWidth() + 30 + 15;
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return getTextHeight(stringBounder) + getHeaderHeight(stringBounder) + heightFooter;
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return Math.max(getTextWidth(stringBounder), getHeaderWidth(stringBounder)) + xMargin * 2
+ + symbolContext.getDeltaShadow();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseSelfArrow.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseSelfArrow.java
new file mode 100644
index 0000000..85058d4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseSelfArrow.java
@@ -0,0 +1,191 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin.rose;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.ArrowConfiguration;
+import net.sourceforge.plantuml.skin.ArrowDecoration;
+import net.sourceforge.plantuml.skin.ArrowHead;
+import net.sourceforge.plantuml.skin.ArrowPart;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ComponentRoseSelfArrow extends AbstractComponentRoseArrow {
+
+ private final double arrowWidth = 45;
+ private final boolean niceArrow;
+
+ public ComponentRoseSelfArrow(HtmlColor foregroundColor, FontConfiguration font, Display stringsToDisplay,
+ ArrowConfiguration arrowConfiguration, ISkinSimple spriteContainer, double maxMessageSize,
+ boolean niceArrow) {
+ super(foregroundColor, font, stringsToDisplay, arrowConfiguration, spriteContainer, HorizontalAlignment.LEFT,
+ maxMessageSize);
+ this.niceArrow = niceArrow;
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, Area area) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final double textHeight = getTextHeight(stringBounder);
+
+ ug = ug.apply(new UChangeColor(getForegroundColor()));
+ final double xRight = arrowWidth - 3;
+
+ if (getArrowConfiguration().isDotted()) {
+ ug = stroke(ug, 2, 2);
+ }
+
+ double x1 = area.getDeltaX1() < 0 ? area.getDeltaX1() : 0;
+ double x2 = area.getDeltaX1() > 0 ? -area.getDeltaX1() : 0 + 1;
+
+ final double textAndArrowHeight = textHeight + getArrowOnlyHeight(stringBounder);
+ final UEllipse circle = new UEllipse(ComponentRoseArrow.diamCircle, ComponentRoseArrow.diamCircle);
+ if (getArrowConfiguration().getDecoration1() == ArrowDecoration.CIRCLE) {
+ ug.apply(new UStroke(ComponentRoseArrow.thinCircle))
+ .apply(new UChangeColor(getForegroundColor()))
+ .apply(new UTranslate(x1 + 1 - ComponentRoseArrow.diamCircle / 2 - ComponentRoseArrow.thinCircle,
+ textHeight - ComponentRoseArrow.diamCircle / 2 - ComponentRoseArrow.thinCircle / 2))
+ .draw(circle);
+ x1 += ComponentRoseArrow.diamCircle / 2;
+ }
+ if (getArrowConfiguration().getDecoration2() == ArrowDecoration.CIRCLE) {
+ ug.apply(new UStroke(ComponentRoseArrow.thinCircle))
+ .apply(new UChangeColor(getForegroundColor()))
+ .apply(new UTranslate(x2 - ComponentRoseArrow.diamCircle / 2 - ComponentRoseArrow.thinCircle,
+ textAndArrowHeight - ComponentRoseArrow.diamCircle / 2 - ComponentRoseArrow.thinCircle / 2))
+ .draw(circle);
+ x2 += ComponentRoseArrow.diamCircle / 2;
+ }
+ final boolean hasFinalCrossX = getArrowConfiguration().getDressing2().getHead() == ArrowHead.CROSSX;
+ if (hasFinalCrossX) {
+ x2 += 2 * ComponentRoseArrow.spaceCrossX;
+ }
+
+ final double arrowHeight = textAndArrowHeight - textHeight;
+ ug.apply(new UTranslate(x1, textHeight)).draw(new ULine(xRight - x1, 0));
+ ug.apply(new UTranslate(xRight, textHeight)).draw(new ULine(0, arrowHeight));
+ ug.apply(new UTranslate(x2, textAndArrowHeight)).draw(new ULine(xRight - x2, 0));
+
+ if (getArrowConfiguration().isDotted()) {
+ ug = ug.apply(new UStroke());
+ }
+
+ if (getArrowConfiguration().isAsync()) {
+ if (getArrowConfiguration().getPart() != ArrowPart.BOTTOM_PART) {
+ ug.apply(new UTranslate(x2, textAndArrowHeight)).draw(new ULine(getArrowDeltaX(), -getArrowDeltaY()));
+ }
+ if (getArrowConfiguration().getPart() != ArrowPart.TOP_PART) {
+ ug.apply(new UTranslate(x2, textAndArrowHeight)).draw(new ULine(getArrowDeltaX(), getArrowDeltaY()));
+ }
+ } else if (hasFinalCrossX) {
+ ug = ug.apply(new UStroke(2));
+ ug.apply(
+ new UTranslate(ComponentRoseArrow.spaceCrossX, textHeight - getArrowDeltaX() / 2
+ + getArrowOnlyHeight(stringBounder))).draw(new ULine(getArrowDeltaX(), getArrowDeltaX()));
+ ug.apply(
+ new UTranslate(ComponentRoseArrow.spaceCrossX, textHeight + getArrowDeltaX() / 2
+ + getArrowOnlyHeight(stringBounder))).draw(new ULine(getArrowDeltaX(), -getArrowDeltaX()));
+
+ } else {
+ final UPolygon polygon = getPolygon(textAndArrowHeight);
+ ug.apply(new UChangeBackColor(getForegroundColor())).apply(new UTranslate(x2, 0)).draw(polygon);
+
+ }
+
+ getTextBlock().drawU(ug.apply(new UTranslate(getMarginX1(), 0)));
+ }
+
+ private UPolygon getPolygon(final double textAndArrowHeight) {
+ final UPolygon polygon = new UPolygon();
+ if (getArrowConfiguration().getPart() == ArrowPart.TOP_PART) {
+ polygon.addPoint(getArrowDeltaX(), textAndArrowHeight - getArrowDeltaY());
+ polygon.addPoint(0, textAndArrowHeight);
+ polygon.addPoint(getArrowDeltaX(), textAndArrowHeight);
+ } else if (getArrowConfiguration().getPart() == ArrowPart.BOTTOM_PART) {
+ polygon.addPoint(getArrowDeltaX(), textAndArrowHeight);
+ polygon.addPoint(0, textAndArrowHeight);
+ polygon.addPoint(getArrowDeltaX(), textAndArrowHeight + getArrowDeltaY());
+ } else {
+ polygon.addPoint(getArrowDeltaX(), textAndArrowHeight - getArrowDeltaY());
+ polygon.addPoint(0, textAndArrowHeight);
+ polygon.addPoint(getArrowDeltaX(), textAndArrowHeight + getArrowDeltaY());
+ if (niceArrow) {
+ polygon.addPoint(getArrowDeltaX() - 4, textAndArrowHeight);
+ }
+ }
+ return polygon;
+ }
+
+ public Point2D getStartPoint(StringBounder stringBounder, Dimension2D dimensionToUse) {
+ final int textHeight = (int) getTextHeight(stringBounder);
+ return new Point2D.Double(getPaddingX(), textHeight + getPaddingY());
+ }
+
+ public Point2D getEndPoint(StringBounder stringBounder, Dimension2D dimensionToUse) {
+ final int textHeight = (int) getTextHeight(stringBounder);
+ final int textAndArrowHeight = (int) (textHeight + getArrowOnlyHeight(stringBounder));
+ return new Point2D.Double(getPaddingX(), textAndArrowHeight + getPaddingY());
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return getTextHeight(stringBounder) + getArrowDeltaY() + getArrowOnlyHeight(stringBounder) + 2 * getPaddingY();
+ }
+
+ private double getArrowOnlyHeight(StringBounder stringBounder) {
+ return 13;
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return Math.max(getTextWidth(stringBounder), arrowWidth);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseTitle.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseTitle.java
new file mode 100644
index 0000000..da21aa8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseTitle.java
@@ -0,0 +1,73 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin.rose;
+
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.cucadiagram.Display;
+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.skin.AbstractTextualComponent;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ComponentRoseTitle extends AbstractTextualComponent {
+
+ private final int outMargin = 5;
+
+ public ComponentRoseTitle(FontConfiguration font, Display stringsToDisplay, ISkinSimple spriteContainer) {
+ super(stringsToDisplay, font, HorizontalAlignment.CENTER, 7, 7, 7,
+ spriteContainer, 0, false, null, null);
+ }
+
+ @Override
+ protected void drawInternalU(UGraphic ug, Area area) {
+ final TextBlock textBlock = getTextBlock();
+ textBlock.drawU(ug.apply(new UTranslate(outMargin + getMarginX1(), getMarginY())));
+ }
+
+ @Override
+ public double getPreferredHeight(StringBounder stringBounder) {
+ return getTextHeight(stringBounder);
+ }
+
+ @Override
+ public double getPreferredWidth(StringBounder stringBounder) {
+ return getTextWidth(stringBounder) + outMargin * 2;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/skin/rose/Rose.java b/src/net/sourceforge/plantuml/skin/rose/Rose.java
new file mode 100644
index 0000000..f8782fe
--- /dev/null
+++ b/src/net/sourceforge/plantuml/skin/rose/Rose.java
@@ -0,0 +1,307 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.skin.rose;
+
+import net.sourceforge.plantuml.AlignParam;
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.LineParam;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.SymbolContext;
+import net.sourceforge.plantuml.skin.ArrowConfiguration;
+import net.sourceforge.plantuml.skin.ArrowDirection;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.Skin;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+
+public class Rose implements Skin {
+
+ final private double paddingX = 5;
+ final private double paddingY = 5;
+
+ public HtmlColor getFontColor(ISkinParam skin, FontParam fontParam) {
+ return skin.getFontHtmlColor(fontParam, null);
+ }
+
+ public HtmlColor getHtmlColor(ISkinParam param, ColorParam color) {
+ return getHtmlColor(param, color, null);
+ }
+
+ public HtmlColor getHtmlColor(ISkinParam param, ColorParam color, Stereotype stereotype) {
+ HtmlColor result = param.getHtmlColor(color, stereotype, false);
+ if (result == null) {
+ result = color.getDefaultValue();
+ if (result == null) {
+ throw new IllegalArgumentException();
+ }
+ }
+ return result;
+ }
+
+ private FontConfiguration getUFont2(ISkinParam param, FontParam fontParam) {
+ final UFont font = param.getFont(fontParam, null, false);
+ final HtmlColor fontColor = getFontColor(param, fontParam);
+ return new FontConfiguration(font, fontColor, param.getHyperlinkColor(), param.useUnderlineForHyperlink());
+ }
+
+ public Component createComponent(ComponentType type, ArrowConfiguration config, ISkinParam param,
+ Display stringsToDisplay) {
+ final UFont fontGrouping = param.getFont(FontParam.SEQUENCE_GROUP, null, false);
+
+ final UFont newFontForStereotype = param.getFont(FontParam.SEQUENCE_STEREOTYPE, null, false);
+
+ if (type.isArrow()) {
+ // if (param.maxMessageSize() > 0) {
+ // final FontConfiguration fc = new FontConfiguration(fontArrow, HtmlColorUtils.BLACK);
+ // stringsToDisplay = DisplayUtils.breakLines(stringsToDisplay, fc, param, param.maxMessageSize());
+ // }
+ final HtmlColor sequenceArrow = config.getColor() == null ? getHtmlColor(param, ColorParam.sequenceArrow)
+ : config.getColor();
+ if (config.getArrowDirection() == ArrowDirection.SELF) {
+ return new ComponentRoseSelfArrow(sequenceArrow, getUFont2(param, FontParam.SEQUENCE_ARROW),
+ stringsToDisplay, config, param, param.maxMessageSize(), param.strictUmlStyle() == false);
+ }
+ final HorizontalAlignment messageHorizontalAlignment = param
+ .getHorizontalAlignment(AlignParam.SEQUENCE_MESSAGE_ALIGN);
+ final HorizontalAlignment textHorizontalAlignment = param
+ .getHorizontalAlignment(AlignParam.SEQUENCE_MESSAGETEXT_ALIGN);
+ return new ComponentRoseArrow(sequenceArrow, getUFont2(param, FontParam.SEQUENCE_ARROW), stringsToDisplay,
+ config, messageHorizontalAlignment, param, textHorizontalAlignment, param.maxMessageSize(),
+ param.strictUmlStyle() == false);
+ }
+ if (type == ComponentType.PARTICIPANT_HEAD) {
+ return new ComponentRoseParticipant(getSymbolContext(param, ColorParam.participantBorder), getUFont2(param,
+ FontParam.PARTICIPANT), stringsToDisplay, param, param.getRoundCorner(), newFontForStereotype,
+ getFontColor(param, FontParam.SEQUENCE_STEREOTYPE));
+ }
+ if (type == ComponentType.PARTICIPANT_TAIL) {
+ return new ComponentRoseParticipant(getSymbolContext(param, ColorParam.participantBorder), getUFont2(param,
+ FontParam.PARTICIPANT), stringsToDisplay, param, param.getRoundCorner(), newFontForStereotype,
+ getFontColor(param, FontParam.SEQUENCE_STEREOTYPE));
+ }
+ if (type == ComponentType.PARTICIPANT_LINE) {
+ final HtmlColor borderColor = getHtmlColor(param, ColorParam.sequenceLifeLineBorder);
+ return new ComponentRoseLine(borderColor, false, getStroke(param, LineParam.sequenceLifeLineBorder, 1));
+ }
+ if (type == ComponentType.CONTINUE_LINE) {
+ final HtmlColor borderColor = getHtmlColor(param, ColorParam.sequenceLifeLineBorder);
+ return new ComponentRoseLine(borderColor, true, getStroke(param, LineParam.sequenceLifeLineBorder, 1.5));
+ }
+ if (type == ComponentType.ACTOR_HEAD) {
+ return new ComponentRoseActor(getSymbolContext(param, ColorParam.actorBorder), getUFont2(param,
+ FontParam.ACTOR), stringsToDisplay, true, param, newFontForStereotype, getFontColor(param,
+ FontParam.SEQUENCE_STEREOTYPE));
+ }
+ if (type == ComponentType.ACTOR_TAIL) {
+ return new ComponentRoseActor(getSymbolContext(param, ColorParam.actorBorder), getUFont2(param,
+ FontParam.ACTOR), stringsToDisplay, false, param, newFontForStereotype, getFontColor(param,
+ FontParam.SEQUENCE_STEREOTYPE));
+ }
+ if (type == ComponentType.BOUNDARY_HEAD) {
+ return new ComponentRoseBoundary(getSymbolContext(param, ColorParam.actorBorder), getUFont2(param,
+ FontParam.ACTOR), stringsToDisplay, true, param, newFontForStereotype, getFontColor(param,
+ FontParam.SEQUENCE_STEREOTYPE));
+ }
+ if (type == ComponentType.BOUNDARY_TAIL) {
+ return new ComponentRoseBoundary(getSymbolContext(param, ColorParam.actorBorder), getUFont2(param,
+ FontParam.ACTOR), stringsToDisplay, false, param, newFontForStereotype, getFontColor(param,
+ FontParam.SEQUENCE_STEREOTYPE));
+ }
+ if (type == ComponentType.CONTROL_HEAD) {
+ return new ComponentRoseControl(getSymbolContext(param, ColorParam.actorBorder), getUFont2(param,
+ FontParam.ACTOR), stringsToDisplay, true, param, newFontForStereotype, getFontColor(param,
+ FontParam.SEQUENCE_STEREOTYPE));
+ }
+ if (type == ComponentType.CONTROL_TAIL) {
+ return new ComponentRoseControl(getSymbolContext(param, ColorParam.actorBorder), getUFont2(param,
+ FontParam.ACTOR), stringsToDisplay, false, param, newFontForStereotype, getFontColor(param,
+ FontParam.SEQUENCE_STEREOTYPE));
+ }
+ if (type == ComponentType.ENTITY_HEAD) {
+ return new ComponentRoseEntity(getSymbolContext(param, ColorParam.actorBorder), getUFont2(param,
+ FontParam.ACTOR), stringsToDisplay, true, param, newFontForStereotype, getFontColor(param,
+ FontParam.SEQUENCE_STEREOTYPE));
+ }
+ if (type == ComponentType.ENTITY_TAIL) {
+ return new ComponentRoseEntity(getSymbolContext(param, ColorParam.actorBorder), getUFont2(param,
+ FontParam.ACTOR), stringsToDisplay, false, param, newFontForStereotype, getFontColor(param,
+ FontParam.SEQUENCE_STEREOTYPE));
+ }
+ if (type == ComponentType.DATABASE_HEAD) {
+ return new ComponentRoseDatabase(getSymbolContext(param, ColorParam.actorBorder), getUFont2(param,
+ FontParam.ACTOR), stringsToDisplay, true, param, newFontForStereotype, getFontColor(param,
+ FontParam.SEQUENCE_STEREOTYPE));
+ }
+ if (type == ComponentType.DATABASE_TAIL) {
+ return new ComponentRoseDatabase(getSymbolContext(param, ColorParam.actorBorder), getUFont2(param,
+ FontParam.ACTOR), stringsToDisplay, false, param, newFontForStereotype, getFontColor(param,
+ FontParam.SEQUENCE_STEREOTYPE));
+ }
+ if (type == ComponentType.NOTE) {
+ return new ComponentRoseNote(getSymbolContext(param, ColorParam.noteBorder), getUFont2(param,
+ FontParam.NOTE), stringsToDisplay, paddingX, paddingY, param);
+ }
+ if (type == ComponentType.NOTE_HEXAGONAL) {
+ return new ComponentRoseNoteHexagonal(getSymbolContext(param, ColorParam.noteBorder), getUFont2(param,
+ FontParam.NOTE), stringsToDisplay, param);
+ }
+ if (type == ComponentType.NOTE_BOX) {
+ return new ComponentRoseNoteBox(getSymbolContext(param, ColorParam.noteBorder), getUFont2(param,
+ FontParam.NOTE), stringsToDisplay, param);
+ }
+ if (type == ComponentType.GROUPING_HEADER) {
+ return new ComponentRoseGroupingHeader(param.getBackgroundColor(), getSymbolContext(param,
+ ColorParam.sequenceGroupBorder), getUFont2(param, FontParam.SEQUENCE_GROUP_HEADER), fontGrouping,
+ stringsToDisplay, param);
+ }
+ if (type == ComponentType.GROUPING_ELSE) {
+ return new ComponentRoseGroupingElse(getHtmlColor(param, ColorParam.sequenceGroupBorder), getUFont2(param,
+ FontParam.SEQUENCE_GROUP), stringsToDisplay.get(0), param, param.getBackgroundColor());
+ }
+ if (type == ComponentType.GROUPING_SPACE) {
+ return new ComponentRoseGroupingSpace(7);
+ }
+ if (type == ComponentType.ALIVE_BOX_CLOSE_CLOSE) {
+ return new ComponentRoseActiveLine(getSymbolContext(param, ColorParam.sequenceLifeLineBorder), true, true);
+ }
+ if (type == ComponentType.ALIVE_BOX_CLOSE_OPEN) {
+ return new ComponentRoseActiveLine(getSymbolContext(param, ColorParam.sequenceLifeLineBorder), true, false);
+ }
+ if (type == ComponentType.ALIVE_BOX_OPEN_CLOSE) {
+ return new ComponentRoseActiveLine(getSymbolContext(param, ColorParam.sequenceLifeLineBorder), false, true);
+ }
+ if (type == ComponentType.ALIVE_BOX_OPEN_OPEN) {
+ return new ComponentRoseActiveLine(getSymbolContext(param, ColorParam.sequenceLifeLineBorder), false, false);
+ }
+ if (type == ComponentType.DELAY_LINE) {
+ return new ComponentRoseDelayLine(getHtmlColor(param, ColorParam.sequenceLifeLineBorder));
+ }
+ if (type == ComponentType.DELAY_TEXT) {
+ return new ComponentRoseDelayText(getUFont2(param, FontParam.SEQUENCE_DELAY), stringsToDisplay, param);
+ }
+ if (type == ComponentType.DESTROY) {
+ return new ComponentRoseDestroy(getHtmlColor(param, ColorParam.sequenceLifeLineBorder));
+ }
+ if (type == ComponentType.NEWPAGE) {
+ return new ComponentRoseNewpage(getFontColor(param, FontParam.SEQUENCE_GROUP));
+ }
+ if (type == ComponentType.DIVIDER) {
+ return new ComponentRoseDivider(getUFont2(param, FontParam.SEQUENCE_DIVIDER), getHtmlColor(param,
+ ColorParam.sequenceDividerBackground), stringsToDisplay, param, deltaShadow(param) > 0, getStroke(
+ param, LineParam.sequenceDividerBorder, 2));
+ }
+ if (type == ComponentType.REFERENCE) {
+ return new ComponentRoseReference(getUFont2(param, FontParam.SEQUENCE_REFERENCE), getSymbolContext(param,
+ ColorParam.sequenceReferenceBorder), getUFont2(param, FontParam.SEQUENCE_GROUP_HEADER),
+ stringsToDisplay, param.getHorizontalAlignment(AlignParam.SEQUENCE_REFERENCE_ALIGN), param,
+ getHtmlColor(param, ColorParam.sequenceReferenceBackground));
+ }
+ if (type == ComponentType.TITLE) {
+ return new ComponentRoseTitle(getUFont2(param, FontParam.SEQUENCE_TITLE), stringsToDisplay, param);
+ }
+ if (type == ComponentType.SIGNATURE) {
+ return new ComponentRoseTitle(fontGrouping.toFont2(HtmlColorUtils.BLACK, param.useUnderlineForHyperlink(),
+ param.getHyperlinkColor()), Display.create("This skin was created ", "in April 2009."), param);
+ }
+ if (type == ComponentType.ENGLOBER) {
+ return new ComponentRoseEnglober(getSymbolContext(param, ColorParam.sequenceBoxBorder), stringsToDisplay,
+ getUFont2(param, FontParam.SEQUENCE_BOX), param);
+ }
+
+ return null;
+ }
+
+ private double deltaShadow(ISkinParam param) {
+ return param.shadowing() ? 4.0 : 0;
+ }
+
+ private SymbolContext getSymbolContext(ISkinParam param, ColorParam color) {
+ if (color == ColorParam.participantBorder) {
+ return new SymbolContext(getHtmlColor(param, ColorParam.participantBackground), getHtmlColor(param,
+ ColorParam.participantBorder)).withStroke(
+ getStroke(param, LineParam.sequenceParticipantBorder, 1.5)).withDeltaShadow(deltaShadow(param));
+ }
+ if (color == ColorParam.actorBorder) {
+ return new SymbolContext(getHtmlColor(param, ColorParam.actorBackground), getHtmlColor(param,
+ ColorParam.actorBorder)).withStroke(getStroke(param, LineParam.sequenceActorBorder, 2))
+ .withDeltaShadow(deltaShadow(param));
+ }
+ if (color == ColorParam.sequenceLifeLineBorder) {
+ return new SymbolContext(getHtmlColor(param, ColorParam.sequenceLifeLineBackground), getHtmlColor(param,
+ ColorParam.sequenceLifeLineBorder)).withDeltaShadow(deltaShadow(param));
+ }
+ if (color == ColorParam.noteBorder) {
+ return new SymbolContext(getHtmlColor(param, ColorParam.noteBackground), getHtmlColor(param,
+ ColorParam.noteBorder)).withStroke(getStroke(param, LineParam.noteBorder, 1)).withDeltaShadow(
+ deltaShadow(param));
+ }
+ if (color == ColorParam.sequenceGroupBorder) {
+ return new SymbolContext(getHtmlColor(param, ColorParam.sequenceGroupBackground), getHtmlColor(param,
+ ColorParam.sequenceGroupBorder)).withStroke(getStroke(param, LineParam.sequenceGroupBorder, 2))
+ .withDeltaShadow(deltaShadow(param));
+ }
+ if (color == ColorParam.sequenceBoxBorder) {
+ return new SymbolContext(getHtmlColor(param, ColorParam.sequenceBoxBackground), getHtmlColor(param,
+ ColorParam.sequenceBoxBorder));
+ }
+ if (color == ColorParam.sequenceReferenceBorder) {
+ return new SymbolContext(getHtmlColor(param, ColorParam.sequenceReferenceHeaderBackground), getHtmlColor(
+ param, ColorParam.sequenceReferenceBorder)).withStroke(
+ getStroke(param, LineParam.sequenceReferenceBorder, 2)).withDeltaShadow(deltaShadow(param));
+ }
+ throw new IllegalArgumentException();
+ }
+
+ static public UStroke getStroke(ISkinParam param, LineParam lineParam, double defaultValue) {
+ final UStroke result = param.getThickness(lineParam, null);
+ if (result == null) {
+ return new UStroke(defaultValue);
+ }
+ return result;
+ }
+
+ public Object getProtocolVersion() {
+ return 1;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/statediagram/StateDiagram.java b/src/net/sourceforge/plantuml/statediagram/StateDiagram.java
new file mode 100644
index 0000000..6d147af
--- /dev/null
+++ b/src/net/sourceforge/plantuml/statediagram/StateDiagram.java
@@ -0,0 +1,216 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.statediagram;
+
+import net.sourceforge.plantuml.UmlDiagramType;
+import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.EntityUtils;
+import net.sourceforge.plantuml.cucadiagram.GroupType;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.IGroup;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+import net.sourceforge.plantuml.cucadiagram.Rankdir;
+import net.sourceforge.plantuml.graphic.USymbol;
+import net.sourceforge.plantuml.utils.UniqueSequence;
+
+public class StateDiagram extends AbstractEntityDiagram {
+
+ public boolean checkConcurrentStateOk(Code code) {
+ if (leafExist(code) == false) {
+ return true;
+ }
+ final IEntity existing = this.getLeafsget(code);
+ if (getCurrentGroup().getGroupType() == GroupType.CONCURRENT_STATE
+ && getCurrentGroup() != existing.getParentContainer()) {
+ return false;
+ }
+ if (existing.getParentContainer().getGroupType() == GroupType.CONCURRENT_STATE
+ && getCurrentGroup() != existing.getParentContainer()) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public IEntity getOrCreateLeaf(Code code, LeafType type, USymbol symbol) {
+ if (checkConcurrentStateOk(code) == false) {
+ throw new IllegalStateException("Concurrent State " + code);
+ }
+ if (type == null) {
+ if (code.getFullName().startsWith("[*]")) {
+ throw new IllegalArgumentException();
+ }
+ if (isGroup(code)) {
+ return getGroup(code);
+ }
+ return getOrCreateLeafDefault(code, LeafType.STATE, null);
+ }
+ return getOrCreateLeafDefault(code, type, symbol);
+ }
+
+ public IEntity getStart() {
+ final IGroup g = getCurrentGroup();
+ if (EntityUtils.groupRoot(g)) {
+ return getOrCreateLeaf(Code.of("*start"), LeafType.CIRCLE_START, null);
+ }
+ return getOrCreateLeaf(Code.of("*start*" + g.getCode().getFullName()), LeafType.CIRCLE_START, null);
+ }
+
+ public IEntity getEnd() {
+ final IGroup p = getCurrentGroup();
+ if (EntityUtils.groupRoot(p)) {
+ return getOrCreateLeaf(Code.of("*end"), LeafType.CIRCLE_END, null);
+ }
+ return getOrCreateLeaf(Code.of("*end*" + p.getCode().getFullName()), LeafType.CIRCLE_END, null);
+ }
+
+ public IEntity getHistorical() {
+ final IGroup g = getCurrentGroup();
+ if (EntityUtils.groupRoot(g)) {
+ return getOrCreateLeaf(Code.of("*historical"), LeafType.PSEUDO_STATE, null);
+ }
+ return getOrCreateLeaf(Code.of("*historical*" + g.getCode().getFullName()), LeafType.PSEUDO_STATE, null);
+ }
+
+ public IEntity getHistorical(Code codeGroup) {
+ final IEntity g = getOrCreateGroup(codeGroup, Display.getWithNewlines(codeGroup), GroupType.STATE,
+ getRootGroup());
+ final IEntity result = getOrCreateLeaf(Code.of("*historical*" + g.getCode().getFullName()),
+ LeafType.PSEUDO_STATE, null);
+ endGroup();
+ return result;
+ }
+
+ public boolean concurrentState(char direction) {
+ final IGroup cur = getCurrentGroup();
+ // printlink("BEFORE");
+ if (EntityUtils.groupRoot(cur) == false && cur.getGroupType() == GroupType.CONCURRENT_STATE) {
+ super.endGroup();
+ }
+ getCurrentGroup().setConcurrentSeparator(direction);
+ final IGroup conc1 = getOrCreateGroup(UniqueSequence.getCode("CONC"), Display.create(""),
+ GroupType.CONCURRENT_STATE, getCurrentGroup());
+ if (EntityUtils.groupRoot(cur) == false && cur.getGroupType() == GroupType.STATE) {
+ cur.moveEntitiesTo(conc1);
+ super.endGroup();
+ getOrCreateGroup(UniqueSequence.getCode("CONC"), Display.create(""), GroupType.CONCURRENT_STATE,
+ getCurrentGroup());
+ }
+ // printlink("AFTER");
+ return true;
+ }
+
+ // private void printlink(String comment) {
+ // Log.println("COMMENT="+comment);
+ // for (Link l : getLinks()) {
+ // Log.println(l);
+ // }
+ // }
+
+ @Override
+ public void endGroup() {
+ final IGroup cur = getCurrentGroup();
+ if (EntityUtils.groupRoot(cur) == false && cur.getGroupType() == GroupType.CONCURRENT_STATE) {
+ super.endGroup();
+ }
+ super.endGroup();
+ }
+
+ @Override
+ public UmlDiagramType getUmlDiagramType() {
+ return UmlDiagramType.STATE;
+ }
+
+ private boolean hideEmptyDescription = false;
+
+ public final void setHideEmptyDescription(boolean hideEmptyDescription) {
+ this.hideEmptyDescription = hideEmptyDescription;
+ }
+
+ public final boolean isHideEmptyDescriptionForState() {
+ return hideEmptyDescription;
+ }
+
+ // public Link isEntryPoint(IEntity ent) {
+ // final Stereotype stereotype = ent.getStereotype();
+ // if (stereotype == null) {
+ // return null;
+ // }
+ // final String label = stereotype.getLabel();
+ // if ("<<entrypoint>>".equalsIgnoreCase(label) == false) {
+ // return null;
+ // }
+ // Link inLink = null;
+ // Link outLink = null;
+ // for (Link link : getLinks()) {
+ // if (link.getEntity1() == ent) {
+ // if (outLink != null) {
+ // return null;
+ // }
+ // outLink = link;
+ // }
+ // if (link.getEntity2() == ent) {
+ // if (inLink != null) {
+ // return null;
+ // }
+ // inLink = link;
+ // }
+ // }
+ // if (inLink == null || outLink == null) {
+ // return null;
+ // }
+ // final Link result = Link.mergeForEntryPoint(inLink, outLink);
+ // result.setEntryPoint(ent.getContainer());
+ // return result;
+ // }
+ //
+ // public void manageExitAndEntryPoints() {
+ // for (IEntity ent : getEntities().values()) {
+ // final Link entryPointLink = isEntryPoint(ent);
+ // if (entryPointLink != null) {
+ // addLink(entryPointLink);
+ // for (Link link : new ArrayList<Link>(getLinks())) {
+ // if (link.contains(ent)) {
+ // removeLink(link);
+ // }
+ // }
+ // }
+ // }
+ //
+ // }
+
+}
diff --git a/src/net/sourceforge/plantuml/statediagram/StateDiagramFactory.java b/src/net/sourceforge/plantuml/statediagram/StateDiagramFactory.java
new file mode 100644
index 0000000..cb5e85e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/statediagram/StateDiagramFactory.java
@@ -0,0 +1,145 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.statediagram;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+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.note.FactoryNoteCommand;
+import net.sourceforge.plantuml.command.note.FactoryNoteOnEntityCommand;
+import net.sourceforge.plantuml.command.note.FactoryNoteOnLinkCommand;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexOr;
+import net.sourceforge.plantuml.cucadiagram.GroupType;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.IGroup;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.statediagram.command.CommandAddField;
+import net.sourceforge.plantuml.statediagram.command.CommandConcurrentState;
+import net.sourceforge.plantuml.statediagram.command.CommandCreatePackageState;
+import net.sourceforge.plantuml.statediagram.command.CommandCreateState;
+import net.sourceforge.plantuml.statediagram.command.CommandEndState;
+import net.sourceforge.plantuml.statediagram.command.CommandHideEmptyDescription;
+import net.sourceforge.plantuml.statediagram.command.CommandLinkState;
+
+public class StateDiagramFactory extends UmlDiagramFactory {
+
+ @Override
+ public StateDiagram createEmptyDiagram() {
+ return new StateDiagram();
+ }
+
+ @Override
+ protected List<Command> createCommands() {
+ final List<Command> cmds = new ArrayList<Command>();
+ cmds.add(new CommandFootboxIgnored());
+ cmds.add(new CommandRankDir());
+ cmds.add(new CommandCreateState());
+ // addCommand(new CommandLinkState());
+ cmds.add(new CommandLinkState());
+ cmds.add(new CommandCreatePackageState());
+ cmds.add(new CommandEndState());
+ cmds.add(new CommandAddField());
+ cmds.add(new CommandConcurrentState());
+
+ final FactoryNoteOnEntityCommand factoryNoteOnEntityCommand = new FactoryNoteOnEntityCommand(new RegexOr(
+ "ENTITY", new RegexLeaf("[\\p{L}0-9_.]+"), //
+ new RegexLeaf("[%g][^%g]+[%g]") //
+ ));
+ cmds.add(factoryNoteOnEntityCommand.createMultiLine());
+
+ cmds.add(new CommandHideEmptyDescription());
+
+ cmds.add(factoryNoteOnEntityCommand.createSingleLine());
+ final FactoryNoteOnLinkCommand factoryNoteOnLinkCommand = new FactoryNoteOnLinkCommand();
+ cmds.add(factoryNoteOnLinkCommand.createSingleLine());
+ cmds.add(factoryNoteOnLinkCommand.createMultiLine());
+ cmds.add(new CommandUrl());
+
+ final FactoryNoteCommand factoryNoteCommand = new FactoryNoteCommand();
+ cmds.add(factoryNoteCommand.createSingleLine());
+ cmds.add(factoryNoteCommand.createMultiLine());
+
+ addCommonCommands(cmds);
+
+ return cmds;
+ }
+
+ @Override
+ public String checkFinalError(AbstractPSystem sys) {
+ final StateDiagram system = (StateDiagram) sys;
+
+ for (Link link : system.getLinks()) {
+ final IGroup parent1 = getGroupParentIfItIsConcurrentState(link.getEntity1());
+ final IGroup parent2 = getGroupParentIfItIsConcurrentState(link.getEntity2());
+ if (isCompatible(parent1, parent2) == false) {
+ return "State within concurrent state cannot be linked out of this concurrent state (between "
+ + link.getEntity1().getCode().getFullName() + " and "
+ + link.getEntity2().getCode().getFullName() + ")";
+ }
+ }
+ return super.checkFinalError(system);
+ }
+
+ private boolean isCompatible(IGroup parent1, IGroup parent2) {
+ if (parent1 == null && parent2 == null) {
+ return true;
+ }
+ if (parent1 != null ^ parent2 != null) {
+ return false;
+ }
+ assert parent1 != null && parent2 != null;
+ return parent1 == parent2;
+ }
+
+ private IGroup getGroupParentIfItIsConcurrentState(IEntity ent) {
+ IGroup parent = ent.getParentContainer();
+ while (parent != null) {
+ if (parent.getGroupType() == GroupType.CONCURRENT_STATE) {
+ return parent;
+ }
+ parent = parent.getParentContainer();
+ }
+ return null;
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/statediagram/command/CommandAddField.java b/src/net/sourceforge/plantuml/statediagram/command/CommandAddField.java
new file mode 100644
index 0000000..71cc0a5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/statediagram/command/CommandAddField.java
@@ -0,0 +1,74 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.statediagram.command;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexOr;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.statediagram.StateDiagram;
+
+public class CommandAddField extends SingleLineCommand2<StateDiagram> {
+
+ public CommandAddField() {
+ super(getRegexConcat());
+ }
+
+ private static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexOr( //
+ new RegexLeaf("CODE3", "([\\p{L}0-9_.]+)"), //
+ new RegexLeaf("CODE4", "[%g]([^%g]+)[%g]")), //
+ new RegexLeaf("[%s]*:[%s]*"), //
+ new RegexLeaf("FIELD", "(.*)"), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(StateDiagram diagram, RegexResult arg) {
+ final String code = arg.getLazzy("CODE", 0);
+ final String field = arg.get("FIELD", 0);
+
+ final IEntity entity = diagram.getOrCreateLeaf(Code.of(code), null, null);
+
+ entity.addFieldOrMethod(field);
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/statediagram/command/CommandConcurrentState.java b/src/net/sourceforge/plantuml/statediagram/command/CommandConcurrentState.java
new file mode 100644
index 0000000..79fb65c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/statediagram/command/CommandConcurrentState.java
@@ -0,0 +1,57 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.statediagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.statediagram.StateDiagram;
+
+public class CommandConcurrentState extends SingleLineCommand<StateDiagram> {
+
+ public CommandConcurrentState() {
+ super("(?i)^(--+|\\|\\|+)$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(StateDiagram diagram, List<String> arg) {
+ if (diagram.concurrentState(arg.get(0).charAt(0))) {
+ return CommandExecutionResult.ok();
+ }
+ return CommandExecutionResult.error("Error 42");
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/statediagram/command/CommandCreatePackageState.java b/src/net/sourceforge/plantuml/statediagram/command/CommandCreatePackageState.java
new file mode 100644
index 0000000..e785453
--- /dev/null
+++ b/src/net/sourceforge/plantuml/statediagram/command/CommandCreatePackageState.java
@@ -0,0 +1,115 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.statediagram.command;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
+import net.sourceforge.plantuml.classdiagram.command.CommandCreateClassMultilines;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexOr;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.GroupType;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.IGroup;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.statediagram.StateDiagram;
+
+public class CommandCreatePackageState extends SingleLineCommand2<StateDiagram> {
+
+ public CommandCreatePackageState() {
+ super(getRegexConcat());
+ }
+
+ private static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^state[%s]+"), //
+ new RegexOr(//
+ new RegexConcat(//
+ new RegexLeaf("CODE1", "([\\p{L}0-9_.]+)[%s]+"), //
+ new RegexLeaf("DISPLAY1", "as[%s]+[%g]([^%g]+)[%g]")), //
+ new RegexConcat(//
+ new RegexLeaf("DISPLAY2", "(?:[%g]([^%g]+)[%g][%s]+as[%s]+)?"), //
+ new RegexLeaf("CODE2", "([\\p{L}0-9_.]+)"))), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("COLOR", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("LINECOLOR", "(?:##(?:\\[(dotted|dashed|bold)\\])?(\\w+)?)?"), //
+ new RegexLeaf("(?:[%s]*\\{|[%s]+begin)$"));
+ }
+
+ private String getNotNull(RegexResult arg, String v1, String v2) {
+ if (arg.get(v1, 0) == null) {
+ return arg.get(v2, 0);
+ }
+ return arg.get(v1, 0);
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(StateDiagram diagram, RegexResult arg) {
+ final IGroup currentPackage = diagram.getCurrentGroup();
+ final Code code = Code.of(getNotNull(arg, "CODE1", "CODE2"));
+ String display = getNotNull(arg, "DISPLAY1", "DISPLAY2");
+ if (display == null) {
+ display = code.getFullName();
+ }
+ final IEntity p = diagram.getOrCreateGroup(code, Display.getWithNewlines(display), GroupType.STATE,
+ currentPackage);
+ final String stereotype = arg.get("STEREOTYPE", 0);
+ if (stereotype != null) {
+ p.setStereotype(new Stereotype(stereotype));
+ }
+ final String urlString = arg.get("URL", 0);
+ if (urlString != null) {
+ final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
+ final Url url = urlBuilder.getUrl(urlString);
+ p.addUrl(url);
+ }
+ p.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0)));
+ p.setSpecificLineColor(diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("LINECOLOR", 1)));
+ CommandCreateClassMultilines.applyStroke(p, arg.get("LINECOLOR", 0));
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/statediagram/command/CommandCreateState.java b/src/net/sourceforge/plantuml/statediagram/command/CommandCreateState.java
new file mode 100644
index 0000000..ef288d3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/statediagram/command/CommandCreateState.java
@@ -0,0 +1,141 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.statediagram.command;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
+import net.sourceforge.plantuml.classdiagram.command.CommandCreateClassMultilines;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexOr;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.statediagram.StateDiagram;
+
+public class CommandCreateState extends SingleLineCommand2<StateDiagram> {
+
+ public CommandCreateState() {
+ super(getRegexConcat());
+ }
+
+ private static RegexConcat getRegexConcat() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ new RegexLeaf("(?:state[%s]+)"), //
+ new RegexOr(//
+ new RegexConcat(//
+ new RegexLeaf("CODE1", "([\\p{L}0-9_.]+)"), //
+ new RegexLeaf("[%s]+as[%s]+"), //
+ new RegexLeaf("DISPLAY1", "[%g]([^%g]+)[%g]")), //
+ new RegexConcat(//
+ new RegexLeaf("DISPLAY2", "[%g]([^%g]+)[%g]"), //
+ new RegexLeaf("[%s]+as[%s]+"), //
+ new RegexLeaf("CODE2", "([\\p{L}0-9_.]+)")), //
+ new RegexLeaf("CODE3", "([\\p{L}0-9_.]+)"), //
+ new RegexLeaf("CODE4", "[%g]([^%g]+)[%g]")), //
+
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("COLOR", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("LINECOLOR", "(?:##(?:\\[(dotted|dashed|bold)\\])?(\\w+)?)?"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("ADDFIELD", "(?::[%s]*(.*))?"), //
+ new RegexLeaf("$"));
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(StateDiagram diagram, RegexResult arg) {
+ final Code code = Code.of(arg.getLazzy("CODE", 0));
+ String display = arg.getLazzy("DISPLAY", 0);
+ if (display == null) {
+ display = code.getFullName();
+ }
+ final String stereotype = arg.get("STEREOTYPE", 0);
+ final LeafType type = getTypeFromStereotype(stereotype);
+ if (diagram.checkConcurrentStateOk(code) == false) {
+ return CommandExecutionResult.error("The state " + code.getFullName()
+ + " has been created in a concurrent state : it cannot be used here.");
+ }
+ final IEntity ent = diagram.getOrCreateLeaf(code, type, null);
+ ent.setDisplay(Display.getWithNewlines(display));
+
+ if (stereotype != null) {
+ ent.setStereotype(new Stereotype(stereotype));
+ }
+ final String urlString = arg.get("URL", 0);
+ if (urlString != null) {
+ final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
+ final Url url = urlBuilder.getUrl(urlString);
+ ent.addUrl(url);
+ }
+ ent.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0)));
+ ent.setSpecificLineColor(diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("LINECOLOR", 1)));
+ CommandCreateClassMultilines.applyStroke(ent, arg.get("LINECOLOR", 0));
+
+ final String addFields = arg.get("ADDFIELD", 0);
+ if (addFields != null) {
+ ent.addFieldOrMethod(addFields);
+ }
+ return CommandExecutionResult.ok();
+ }
+
+ private LeafType getTypeFromStereotype(String stereotype) {
+ if ("<<choice>>".equalsIgnoreCase(stereotype)) {
+ return LeafType.STATE_CHOICE;
+ }
+ if ("<<fork>>".equalsIgnoreCase(stereotype)) {
+ return LeafType.STATE_FORK_JOIN;
+ }
+ if ("<<join>>".equalsIgnoreCase(stereotype)) {
+ return LeafType.STATE_FORK_JOIN;
+ }
+ if ("<<end>>".equalsIgnoreCase(stereotype)) {
+ return LeafType.CIRCLE_END;
+ }
+ return null;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/statediagram/command/CommandEndState.java b/src/net/sourceforge/plantuml/statediagram/command/CommandEndState.java
new file mode 100644
index 0000000..edae33f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/statediagram/command/CommandEndState.java
@@ -0,0 +1,60 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.statediagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.statediagram.StateDiagram;
+
+public class CommandEndState extends SingleLineCommand<StateDiagram> {
+
+ public CommandEndState() {
+ super("(?i)^(end[%s]?state|\\})$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(StateDiagram diagram, List<String> arg) {
+ final IEntity currentPackage = diagram.getCurrentGroup();
+ if (currentPackage == null) {
+ return CommandExecutionResult.error("No inner state defined");
+ }
+ diagram.endGroup();
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/statediagram/command/CommandHideEmptyDescription.java b/src/net/sourceforge/plantuml/statediagram/command/CommandHideEmptyDescription.java
new file mode 100644
index 0000000..ea895c1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/statediagram/command/CommandHideEmptyDescription.java
@@ -0,0 +1,55 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.statediagram.command;
+
+import java.util.List;
+
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand;
+import net.sourceforge.plantuml.statediagram.StateDiagram;
+
+public class CommandHideEmptyDescription extends SingleLineCommand<StateDiagram> {
+
+ public CommandHideEmptyDescription() {
+ super("(?i)^(hide|show)[%s]+empty[%s]+description$");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(StateDiagram diagram, List<String> arg) {
+ diagram.setHideEmptyDescription(arg.get(0).equalsIgnoreCase("hide"));
+ return CommandExecutionResult.ok();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/statediagram/command/CommandLinkState.java b/src/net/sourceforge/plantuml/statediagram/command/CommandLinkState.java
new file mode 100644
index 0000000..414cbf4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/statediagram/command/CommandLinkState.java
@@ -0,0 +1,219 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.statediagram.command;
+
+import net.sourceforge.plantuml.Direction;
+import net.sourceforge.plantuml.classdiagram.command.CommandLinkClass;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.SingleLineCommand2;
+import net.sourceforge.plantuml.command.regex.RegexConcat;
+import net.sourceforge.plantuml.command.regex.RegexLeaf;
+import net.sourceforge.plantuml.command.regex.RegexResult;
+import net.sourceforge.plantuml.cucadiagram.Code;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.cucadiagram.LinkDecor;
+import net.sourceforge.plantuml.cucadiagram.LinkType;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.statediagram.StateDiagram;
+import net.sourceforge.plantuml.StringUtils;
+
+public class CommandLinkState extends SingleLineCommand2<StateDiagram> {
+
+ public CommandLinkState() {
+ super(getRegex());
+ }
+
+ static RegexConcat getRegex() {
+ return new RegexConcat(new RegexLeaf("^"), //
+ getStatePattern("ENT1"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexConcat(
+ //
+ new RegexLeaf("ARROW_CROSS_START", "(x)?"), //
+ new RegexLeaf("ARROW_BODY1", "(-+)"), //
+ new RegexLeaf("ARROW_STYLE1",
+ "(?:\\[((?:#\\w+|dotted|dashed|bold|hidden)(?:,#\\w+|,dotted|,dashed|,bold|,hidden)*)\\])?"), //
+ new RegexLeaf("ARROW_DIRECTION", "(left|right|up|down|le?|ri?|up?|do?)?"), //
+ new RegexLeaf("ARROW_STYLE2",
+ "(?:\\[((?:#\\w+|dotted|dashed|bold|hidden)(?:,#\\w+|,dotted|,dashed|,bold|,hidden)*)\\])?"), //
+ new RegexLeaf("ARROW_BODY2", "(-*)"), //
+ new RegexLeaf("\\>"), //
+ new RegexLeaf("ARROW_CIRCLE_END", "(o[%s]+)?")), //
+ new RegexLeaf("[%s]*"), //
+ getStatePattern("ENT2"), //
+ new RegexLeaf("[%s]*"), //
+ new RegexLeaf("LABEL", "(?::[%s]*([^%g]+))?"), //
+ new RegexLeaf("$"));
+ }
+
+ private static RegexLeaf getStatePattern(String name) {
+ return new RegexLeaf(
+ name,
+ "([\\p{L}0-9_.]+|[\\p{L}0-9_.]+\\[H\\]|\\[\\*\\]|\\[H\\]|(?:==+)(?:[\\p{L}0-9_.]+)(?:==+))[%s]*(\\<\\<.*\\>\\>)?[%s]*(#\\w+)?");
+ }
+
+ @Override
+ protected CommandExecutionResult executeArg(StateDiagram diagram, RegexResult arg) {
+ final String ent1 = arg.get("ENT1", 0);
+ final String ent2 = arg.get("ENT2", 0);
+
+ final IEntity cl1 = getEntityStart(diagram, ent1);
+ if (cl1 == null) {
+ return CommandExecutionResult.error("The state " + ent1
+ + " has been created in a concurrent state : it cannot be used here.");
+ }
+ final IEntity cl2 = getEntityEnd(diagram, ent2);
+ if (cl2 == null) {
+ return CommandExecutionResult.error("The state " + ent2
+ + " has been created in a concurrent state : it cannot be used here.");
+ }
+
+ if (arg.get("ENT1", 1) != null) {
+ cl1.setStereotype(new Stereotype(arg.get("ENT1", 1)));
+ }
+ if (arg.get("ENT1", 2) != null) {
+ cl1.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("ENT1", 2)));
+ }
+ if (arg.get("ENT2", 1) != null) {
+ cl2.setStereotype(new Stereotype(arg.get("ENT2", 1)));
+ }
+ if (arg.get("ENT2", 2) != null) {
+ cl2.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("ENT2", 2)));
+ }
+
+ String queue = arg.get("ARROW_BODY1", 0) + arg.get("ARROW_BODY2", 0);
+ final Direction dir = getDirection(arg);
+
+ if (dir == Direction.LEFT || dir == Direction.RIGHT) {
+ queue = "-";
+ }
+
+ final int lenght = queue.length();
+
+ final boolean crossStart = arg.get("ARROW_CROSS_START", 0) != null;
+ final boolean circleEnd = arg.get("ARROW_CIRCLE_END", 0) != null;
+ final LinkType linkType = new LinkType(circleEnd ? LinkDecor.ARROW_AND_CIRCLE : LinkDecor.ARROW,
+ crossStart ? LinkDecor.CIRCLE_CROSS : LinkDecor.NONE);
+
+ Link link = new Link(cl1, cl2, linkType, Display.getWithNewlines(arg.get("LABEL", 0)), lenght);
+ if (dir == Direction.LEFT || dir == Direction.UP) {
+ link = link.getInv();
+ }
+ CommandLinkClass.applyStyle(arg.getLazzy("ARROW_STYLE", 0), link);
+ diagram.addLink(link);
+
+ return CommandExecutionResult.ok();
+ }
+
+ // public static void applyStyle(String arrowStyle, Link link) {
+ // if (arrowStyle == null) {
+ // return;
+ // }
+ // final StringTokenizer st = new StringTokenizer(arrowStyle, ",");
+ // while (st.hasMoreTokens()) {
+ // final String s = st.nextToken();
+ // if (s.equalsIgnoreCase("dashed")) {
+ // link.goDashed();
+ // } else if (s.equalsIgnoreCase("bold")) {
+ // link.goBold();
+ // } else if (s.equalsIgnoreCase("dotted")) {
+ // link.goDotted();
+ // } else if (s.equalsIgnoreCase("hidden")) {
+ // link.goHidden();
+ // } else {
+ // link.setSpecificColor(s);
+ // }
+ // }
+ // }
+
+ private Direction getDirection(RegexResult arg) {
+ final String arrowDirection = arg.get("ARROW_DIRECTION", 0);
+ if (arrowDirection != null) {
+ return StringUtils.getQueueDirection(arrowDirection);
+ }
+ return null;
+ }
+
+ private IEntity getEntityStart(StateDiagram system, String code) {
+ if (code.startsWith("[*]")) {
+ return system.getStart();
+ }
+ if (code.equalsIgnoreCase("[H]")) {
+ return system.getHistorical();
+ }
+ if (code.endsWith("[H]")) {
+ return system.getHistorical(Code.of(code.substring(0, code.length() - 3)));
+ }
+ if (code.startsWith("=") && code.endsWith("=")) {
+ code = removeEquals(code);
+ return system.getOrCreateLeaf(Code.of(code), LeafType.SYNCHRO_BAR, null);
+ }
+ if (system.checkConcurrentStateOk(Code.of(code)) == false) {
+ return null;
+ }
+ return system.getOrCreateLeaf(Code.of(code), null, null);
+ }
+
+ private String removeEquals(String code) {
+ while (code.startsWith("=")) {
+ code = code.substring(1);
+ }
+ while (code.endsWith("=")) {
+ code = code.substring(0, code.length() - 1);
+ }
+ return code;
+ }
+
+ private IEntity getEntityEnd(StateDiagram system, String code) {
+ if (code.startsWith("[*]")) {
+ return system.getEnd();
+ }
+ if (code.endsWith("[H]")) {
+ return system.getHistorical(Code.of(code.substring(0, code.length() - 3)));
+ }
+ if (code.startsWith("=") && code.endsWith("=")) {
+ code = removeEquals(code);
+ return system.getOrCreateLeaf(Code.of(code), LeafType.SYNCHRO_BAR, null);
+ }
+ if (system.checkConcurrentStateOk(Code.of(code)) == false) {
+ return null;
+ }
+ return system.getOrCreateLeaf(Code.of(code), null, null);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/suggest/SuggestEngine.java b/src/net/sourceforge/plantuml/suggest/SuggestEngine.java
new file mode 100644
index 0000000..3e76844
--- /dev/null
+++ b/src/net/sourceforge/plantuml/suggest/SuggestEngine.java
@@ -0,0 +1,181 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.suggest;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.command.Command;
+import net.sourceforge.plantuml.command.CommandControl;
+import net.sourceforge.plantuml.command.CommandExecutionResult;
+import net.sourceforge.plantuml.command.ProtectedCommand;
+import net.sourceforge.plantuml.command.UmlDiagramFactory;
+import net.sourceforge.plantuml.core.UmlSource;
+import net.sourceforge.plantuml.utils.StartUtils;
+
+final public class SuggestEngine {
+
+ private final UmlDiagramFactory systemFactory;
+
+ private final Iterator<String> it;
+ private final String startLine;
+
+ private String current = "";
+ private String previous = "";
+
+ public SuggestEngine(UmlSource source, UmlDiagramFactory systemFactory) {
+ this.systemFactory = systemFactory;
+ this.it = source.iterator();
+ startLine = next();
+ if (StartUtils.isArobaseStartDiagram(startLine) == false) {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ private boolean hasNext() {
+ return it.hasNext();
+ }
+
+ private String next() {
+ // nb++;
+ this.previous = this.current;
+ this.current = it.next();
+ return current;
+ }
+
+ public SuggestEngineResult tryToSuggest(AbstractPSystem system) {
+ return executeUmlCommand(system);
+ }
+
+ private SuggestEngineResult executeUmlCommand(AbstractPSystem system) {
+ // systemFactory.init(startLine);
+ while (hasNext()) {
+ final String s = next();
+ if (StartUtils.isArobaseEndDiagram(s)) {
+ return SuggestEngineResult.SYNTAX_OK;
+ }
+ final SuggestEngineResult check = checkAndCorrect(s);
+ if (check.getStatus() != SuggestEngineStatus.SYNTAX_OK) {
+ return check;
+ }
+ final CommandControl commandControl = systemFactory.isValid(Arrays.asList(s));
+ if (commandControl == CommandControl.OK_PARTIAL) {
+ final boolean ok = manageMultiline(s);
+ if (ok == false) {
+ return SuggestEngineResult.CANNOT_CORRECT;
+ }
+ } else if (commandControl == CommandControl.OK) {
+// final Command cmd = new ProtectedCommand(systemFactory.createCommand(Arrays.asList(s)));
+// final CommandExecutionResult result = cmd.execute(system, Arrays.asList(s));
+// if (result.isOk() == false) {
+// return SuggestEngineResult.CANNOT_CORRECT;
+// }
+ } else {
+ assert false;
+ }
+ }
+ throw new IllegalStateException();
+ }
+
+ private boolean manageMultiline(final String init) {
+ final List<String> lines = new ArrayList<String>();
+ lines.add(init);
+ while (hasNext()) {
+ final String s = next();
+ if (StartUtils.isArobaseEndDiagram(s)) {
+ return false;
+ }
+ lines.add(s);
+ final CommandControl commandControl = systemFactory.isValid(lines);
+ if (commandControl == CommandControl.NOT_OK) {
+ throw new IllegalStateException();
+ }
+ if (commandControl == CommandControl.OK) {
+ // final Command cmd = systemFactory.createCommand(lines);
+ // return cmd.execute(lines).isOk();
+ return true;
+ }
+ }
+ return false;
+
+ }
+
+ SuggestEngineResult checkAndCorrect(final String incorrectLine) {
+ final CommandControl commandControl = systemFactory.isValid(Arrays.asList(incorrectLine));
+ if (commandControl != CommandControl.NOT_OK) {
+ return SuggestEngineResult.SYNTAX_OK;
+ }
+
+ if (incorrectLine.trim().startsWith("{")
+ && systemFactory.isValid(Arrays.asList(previous + " {")) != CommandControl.NOT_OK) {
+ return new SuggestEngineResult(previous + " {");
+ }
+
+ final Collection<Iterator<String>> all = new ArrayList<Iterator<String>>();
+ all.add(new VariatorRemoveOneChar(incorrectLine));
+ all.add(new VariatorSwapLetter(incorrectLine));
+ // all.add(new VariatorAddOneCharBetweenWords(incorrectLine, ':'));
+ all.add(new VariatorAddOneCharBetweenWords(incorrectLine, '-'));
+ all.add(new VariatorAddOneCharBetweenWords(incorrectLine, ' '));
+ // all.add(new VariatorAddTwoChar(incorrectLine, '\"'));
+
+ for (Iterator<String> it : all) {
+ final SuggestEngineResult result = tryThis(it);
+ if (result != null) {
+ return result;
+ }
+ }
+ return SuggestEngineResult.CANNOT_CORRECT;
+ }
+
+ private SuggestEngineResult tryThis(Iterator<String> it) {
+ while (it.hasNext()) {
+ final String newS = it.next();
+ if (newS.trim().length() == 0) {
+ continue;
+ }
+ final CommandControl commandControl = systemFactory.isValid(Arrays.asList(newS));
+ if (commandControl != CommandControl.NOT_OK) {
+ return new SuggestEngineResult(newS);
+ }
+ }
+ return null;
+
+ }
+}
diff --git a/src/net/sourceforge/plantuml/suggest/SuggestEngineResult.java b/src/net/sourceforge/plantuml/suggest/SuggestEngineResult.java
new file mode 100644
index 0000000..ea7cd37
--- /dev/null
+++ b/src/net/sourceforge/plantuml/suggest/SuggestEngineResult.java
@@ -0,0 +1,96 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.suggest;
+
+
+public class SuggestEngineResult {
+
+ private final SuggestEngineStatus status;
+ private final String suggestedLine;
+
+ public static final SuggestEngineResult CANNOT_CORRECT = new SuggestEngineResult(SuggestEngineStatus.CANNOT_CORRECT);
+ public static final SuggestEngineResult SYNTAX_OK = new SuggestEngineResult(SuggestEngineStatus.SYNTAX_OK);
+
+ private SuggestEngineResult(SuggestEngineStatus status) {
+ if (status == SuggestEngineStatus.ONE_SUGGESTION) {
+ throw new IllegalArgumentException();
+ }
+ this.status = status;
+ this.suggestedLine = null;
+ }
+
+ @Override
+ public String toString() {
+ return status + " " + suggestedLine;
+ }
+
+ @Override
+ public int hashCode() {
+ return status.hashCode() + (suggestedLine == null ? 0 : suggestedLine.hashCode());
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ final SuggestEngineResult this2 = (SuggestEngineResult) obj;
+ return status.equals(this2.status) && sameString(suggestedLine, this2.suggestedLine);
+ }
+
+ private static boolean sameString(String a, String b) {
+ if (a == null && b == null) {
+ return true;
+ }
+ if (a != null || b != null) {
+ return false;
+ }
+ return a.equals(b);
+ }
+
+ public SuggestEngineResult(String suggestedLine) {
+ if (suggestedLine.trim().length() == 0) {
+ throw new IllegalArgumentException();
+ }
+ this.status = SuggestEngineStatus.ONE_SUGGESTION;
+ this.suggestedLine = suggestedLine;
+ }
+
+ public final SuggestEngineStatus getStatus() {
+ return status;
+ }
+
+ public final String getSuggestedLine() {
+ return suggestedLine;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/suggest/SuggestEngineStatus.java b/src/net/sourceforge/plantuml/suggest/SuggestEngineStatus.java
new file mode 100644
index 0000000..7d47486
--- /dev/null
+++ b/src/net/sourceforge/plantuml/suggest/SuggestEngineStatus.java
@@ -0,0 +1,40 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.suggest;
+
+public enum SuggestEngineStatus {
+ SYNTAX_OK, CANNOT_CORRECT, ONE_SUGGESTION
+
+}
diff --git a/src/net/sourceforge/plantuml/suggest/Variator.java b/src/net/sourceforge/plantuml/suggest/Variator.java
new file mode 100644
index 0000000..600eb1c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/suggest/Variator.java
@@ -0,0 +1,42 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.suggest;
+
+public interface Variator {
+
+ String getData();
+ void nextStep();
+
+}
diff --git a/src/net/sourceforge/plantuml/suggest/VariatorAddOneChar.java b/src/net/sourceforge/plantuml/suggest/VariatorAddOneChar.java
new file mode 100644
index 0000000..68585b3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/suggest/VariatorAddOneChar.java
@@ -0,0 +1,63 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.suggest;
+
+public class VariatorAddOneChar extends VariatorIteratorAdaptor {
+
+ private final String data;
+ private final char toAdd;
+ private int i;
+
+ public VariatorAddOneChar(String data, char toAdd) {
+ this.data = data;
+ this.toAdd = toAdd;
+ }
+
+ @Override
+ Variator getVariator() {
+ return new Variator() {
+ public String getData() {
+ if (i > data.length()) {
+ return null;
+ }
+ return data.substring(0, i) + toAdd + data.substring(i);
+ }
+
+ public void nextStep() {
+ i++;
+ }
+ };
+ }
+}
diff --git a/src/net/sourceforge/plantuml/suggest/VariatorAddOneCharBetweenWords.java b/src/net/sourceforge/plantuml/suggest/VariatorAddOneCharBetweenWords.java
new file mode 100644
index 0000000..35b900d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/suggest/VariatorAddOneCharBetweenWords.java
@@ -0,0 +1,77 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.suggest;
+
+public class VariatorAddOneCharBetweenWords extends VariatorIteratorAdaptor {
+
+ private final String data;
+ private final char toAdd;
+ private int i;
+
+ public VariatorAddOneCharBetweenWords(String data, char toAdd) {
+ this.data = data;
+ this.toAdd = toAdd;
+ i++;
+ ensureBetweenWords();
+ }
+
+ private void ensureBetweenWords() {
+ while (i < data.length() && inWord()) {
+ i++;
+ }
+
+ }
+
+ private boolean inWord() {
+ return Character.isLetterOrDigit(data.charAt(i - 1)) && Character.isLetterOrDigit(data.charAt(i));
+ }
+
+ @Override
+ Variator getVariator() {
+ return new Variator() {
+ public String getData() {
+ if (i > data.length() - 1) {
+ return null;
+ }
+ return data.substring(0, i) + toAdd + data.substring(i);
+ }
+
+ public void nextStep() {
+ i++;
+ ensureBetweenWords();
+ }
+ };
+ }
+}
diff --git a/src/net/sourceforge/plantuml/suggest/VariatorAddTwoChar.java b/src/net/sourceforge/plantuml/suggest/VariatorAddTwoChar.java
new file mode 100644
index 0000000..d875cf4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/suggest/VariatorAddTwoChar.java
@@ -0,0 +1,68 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.suggest;
+
+public class VariatorAddTwoChar extends VariatorIteratorAdaptor {
+
+ private final String data;
+ private final char toAdd;
+ private int i;
+ private int j = 1;
+
+ public VariatorAddTwoChar(String data, char toAdd) {
+ this.data = data;
+ this.toAdd = toAdd;
+ }
+
+ @Override
+ Variator getVariator() {
+ return new Variator() {
+ public String getData() {
+ if (i >= data.length()) {
+ return null;
+ }
+ return data.substring(0, i) + toAdd + data.substring(i, j) + toAdd + data.substring(j);
+ }
+
+ public void nextStep() {
+ j++;
+ if (j > data.length()) {
+ i++;
+ j = i + 1;
+ }
+ }
+ };
+ }
+}
diff --git a/src/net/sourceforge/plantuml/suggest/VariatorIteratorAdaptor.java b/src/net/sourceforge/plantuml/suggest/VariatorIteratorAdaptor.java
new file mode 100644
index 0000000..cada29e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/suggest/VariatorIteratorAdaptor.java
@@ -0,0 +1,67 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.suggest;
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+public abstract class VariatorIteratorAdaptor implements Iterator<String> {
+
+ private final Variator variator;
+
+ abstract Variator getVariator();
+
+ public VariatorIteratorAdaptor() {
+ this.variator = getVariator();
+ }
+
+ public boolean hasNext() {
+ return variator.getData() != null;
+ }
+
+ public String next() {
+ final String result = variator.getData();
+ if (result == null) {
+ throw new NoSuchElementException();
+ }
+ this.variator.nextStep();
+ return result;
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/suggest/VariatorRemoveOneChar.java b/src/net/sourceforge/plantuml/suggest/VariatorRemoveOneChar.java
new file mode 100644
index 0000000..49f7377
--- /dev/null
+++ b/src/net/sourceforge/plantuml/suggest/VariatorRemoveOneChar.java
@@ -0,0 +1,61 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.suggest;
+
+public class VariatorRemoveOneChar extends VariatorIteratorAdaptor {
+
+ private final String data;
+ private int i;
+
+ public VariatorRemoveOneChar(String data) {
+ this.data = data;
+ }
+
+ @Override
+ Variator getVariator() {
+ return new Variator() {
+ public String getData() {
+ if (i >= data.length()) {
+ return null;
+ }
+ return data.substring(0, i) + data.substring(i + 1);
+ }
+
+ public void nextStep() {
+ i++;
+ }
+ };
+ }
+}
diff --git a/src/net/sourceforge/plantuml/suggest/VariatorSwapChar.java b/src/net/sourceforge/plantuml/suggest/VariatorSwapChar.java
new file mode 100644
index 0000000..563b880
--- /dev/null
+++ b/src/net/sourceforge/plantuml/suggest/VariatorSwapChar.java
@@ -0,0 +1,61 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.suggest;
+
+public class VariatorSwapChar extends VariatorIteratorAdaptor {
+
+ private final String data;
+ private int i;
+
+ public VariatorSwapChar(String data) {
+ this.data = data;
+ }
+
+ @Override
+ Variator getVariator() {
+ return new Variator() {
+ public String getData() {
+ if (i >= data.length() - 1) {
+ return null;
+ }
+ return data.substring(0, i) + data.charAt(i + 1) + data.charAt(i) + data.substring(i + 2);
+ }
+
+ public void nextStep() {
+ i++;
+ }
+ };
+ }
+}
diff --git a/src/net/sourceforge/plantuml/suggest/VariatorSwapLetter.java b/src/net/sourceforge/plantuml/suggest/VariatorSwapLetter.java
new file mode 100644
index 0000000..caec47a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/suggest/VariatorSwapLetter.java
@@ -0,0 +1,75 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.suggest;
+
+public class VariatorSwapLetter extends VariatorIteratorAdaptor {
+
+ private final String data;
+ private int i;
+
+ public VariatorSwapLetter(String data) {
+ this.data = data;
+ ensureTwoLetters();
+ }
+
+ private void ensureTwoLetters() {
+ while (i < data.length() - 1 && areTwoLetters() == false) {
+ i++;
+ }
+
+ }
+
+ private boolean areTwoLetters() {
+ return Character.isLetter(data.charAt(i)) && Character.isLetter(data.charAt(i + 1));
+
+ }
+
+ @Override
+ Variator getVariator() {
+ return new Variator() {
+ public String getData() {
+ if (i >= data.length() - 1) {
+ return null;
+ }
+ return data.substring(0, i) + data.charAt(i + 1) + data.charAt(i) + data.substring(i + 2);
+ }
+
+ public void nextStep() {
+ i++;
+ ensureTwoLetters();
+ }
+ };
+ }
+}
diff --git a/src/net/sourceforge/plantuml/svek/AbstractEntityImage.java b/src/net/sourceforge/plantuml/svek/AbstractEntityImage.java
new file mode 100644
index 0000000..5dcf477
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/AbstractEntityImage.java
@@ -0,0 +1,75 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+
+public abstract class AbstractEntityImage implements IEntityImage {
+
+ private final IEntity entity;
+ private final ISkinParam skinParam;
+
+ public AbstractEntityImage(IEntity entity, ISkinParam skinParam) {
+ if (entity == null) {
+ throw new IllegalArgumentException("entity null");
+ }
+ this.entity = entity;
+ this.skinParam = skinParam;
+ }
+
+ public boolean isHidden() {
+ return entity.isHidden();
+ }
+
+ protected final IEntity getEntity() {
+ return entity;
+ }
+
+ protected final ISkinParam getSkinParam() {
+ return skinParam;
+ }
+
+ public final HtmlColor getBackcolor() {
+ return null;
+ }
+
+ protected final Stereotype getStereo() {
+ return entity.getStereotype();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/AbstractExtremityFactory.java b/src/net/sourceforge/plantuml/svek/AbstractExtremityFactory.java
new file mode 100644
index 0000000..47a1f8a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/AbstractExtremityFactory.java
@@ -0,0 +1,51 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.svek.extremity.ExtremityFactory;
+
+public abstract class AbstractExtremityFactory implements ExtremityFactory {
+
+ protected double atan2(Point2D p1, Point2D p0) {
+ double a = Math.atan2(p1.getY() - p0.getY(), p1.getX() - p0.getX());
+ if (a < 0) {
+ a += Math.PI * 2;
+ }
+ return a;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/ArithmeticStrategy.java b/src/net/sourceforge/plantuml/svek/ArithmeticStrategy.java
new file mode 100644
index 0000000..589a2fb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/ArithmeticStrategy.java
@@ -0,0 +1,43 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+public interface ArithmeticStrategy {
+
+ void eat(double v);
+
+ double getResult();
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/ArithmeticStrategyMax.java b/src/net/sourceforge/plantuml/svek/ArithmeticStrategyMax.java
new file mode 100644
index 0000000..8641146
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/ArithmeticStrategyMax.java
@@ -0,0 +1,51 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+public class ArithmeticStrategyMax implements ArithmeticStrategy {
+
+ private double max;
+
+ public void eat(double v) {
+ if (v > max) {
+ max = v;
+ }
+ }
+
+ public double getResult() {
+ return max;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/ArithmeticStrategySum.java b/src/net/sourceforge/plantuml/svek/ArithmeticStrategySum.java
new file mode 100644
index 0000000..bddc8d5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/ArithmeticStrategySum.java
@@ -0,0 +1,49 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+public class ArithmeticStrategySum implements ArithmeticStrategy {
+
+ private double sum;
+
+ public void eat(double v) {
+ sum += v;
+ }
+
+ public double getResult() {
+ return sum;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/Bibliotekon.java b/src/net/sourceforge/plantuml/svek/Bibliotekon.java
new file mode 100644
index 0000000..3c3eaaa
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/Bibliotekon.java
@@ -0,0 +1,184 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.IGroup;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.cucadiagram.Link;
+
+public class Bibliotekon {
+
+ private final List<Cluster> allCluster = new ArrayList<Cluster>();
+
+ private final Map<ILeaf, Shape> shapeMap = new LinkedHashMap<ILeaf, Shape>();;
+
+ private final List<Line> lines0 = new ArrayList<Line>();
+ private final List<Line> lines1 = new ArrayList<Line>();
+ private final List<Line> allLines = new ArrayList<Line>();
+
+ public void putShape(ILeaf ent, Shape shape) {
+ shapeMap.put(ent, shape);
+ }
+
+ public Cluster getCluster(IGroup ent) {
+ for (Cluster cl : allCluster) {
+ if (cl.getGroup() == ent) {
+ return cl;
+ }
+ }
+ return null;
+ }
+
+ public void addLine(Line line) {
+ allLines.add(line);
+ if (first(line)) {
+ if (line.hasNoteLabelText()) {
+ // lines0.add(0, line);
+ for (int i = 0; i < lines0.size(); i++) {
+ final Line other = lines0.get(i);
+ if (other.hasNoteLabelText() == false && line.sameConnections(other)) {
+ lines0.add(i, line);
+ return;
+ }
+ }
+ lines0.add(line);
+ } else {
+ lines0.add(line);
+ }
+ } else {
+ lines1.add(line);
+ }
+ }
+
+ private static boolean first(Line line) {
+ final int length = line.getLength();
+ if (length == 1) {
+ return true;
+ }
+ return false;
+ }
+
+ public void addCluster(Cluster current) {
+ allCluster.add(current);
+ }
+
+ public Shape getShape(IEntity ent) {
+ return shapeMap.get(ent);
+ }
+
+ public String getShapeUid(ILeaf ent) {
+ final Shape result = getShape(ent);
+ if (result != null) {
+ String uid = result.getUid();
+ if (result.isShielded()) {
+ uid = uid + ":h";
+ }
+ return uid;
+ }
+ assert result == null;
+ if (ent.isGroup()) {
+ for (IEntity i : shapeMap.keySet()) {
+ if (ent.getCode().equals(i.getCode())) {
+ return getShape(i).getUid();
+ }
+ }
+ return Cluster.getSpecialPointId(ent);
+ }
+ throw new IllegalStateException();
+ }
+
+ public String getWarningOrError(int warningOrError) {
+ final StringBuilder sb = new StringBuilder();
+ for (Map.Entry<ILeaf, Shape> ent : shapeMap.entrySet()) {
+ final Shape sh = ent.getValue();
+ final double maxX = sh.getMinX() + sh.getWidth();
+ if (maxX > warningOrError) {
+ final IEntity entity = ent.getKey();
+ sb.append(entity.getCode() + " is overpassing the width limit.");
+ sb.append("\n");
+ }
+
+ }
+ return sb.length() == 0 ? "" : sb.toString();
+ }
+
+ public List<Line> allLines() {
+ return Collections.unmodifiableList(allLines);
+ }
+
+ public List<Line> lines0() {
+ return Collections.unmodifiableList(lines0);
+ }
+
+ public List<Line> lines1() {
+ return Collections.unmodifiableList(lines1);
+ }
+
+ public List<Cluster> allCluster() {
+ return Collections.unmodifiableList(allCluster);
+ }
+
+ public Collection<Shape> allShapes() {
+ return Collections.unmodifiableCollection(shapeMap.values());
+ }
+
+ public List<Line> getAllLineConnectedTo(IEntity leaf) {
+ final List<Line> result = new ArrayList<Line>();
+ for (Line line : allLines) {
+ if (line.isLinkFromOrTo(leaf)) {
+ result.add(line);
+ }
+ }
+ return Collections.unmodifiableList(result);
+ }
+
+ public Line getLine(Link link) {
+ for (Line line : allLines) {
+ if (line.isLink(link)) {
+ return line;
+ }
+ }
+ throw new IllegalArgumentException();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/Boundary.java b/src/net/sourceforge/plantuml/svek/Boundary.java
new file mode 100644
index 0000000..278c522
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/Boundary.java
@@ -0,0 +1,102 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.SymbolContext;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class Boundary implements TextBlock {
+
+ private final double margin = 4;
+
+ private final double radius = 12;
+ private final double left = 17;
+
+ private final SymbolContext symbolContext;
+
+ public Boundary(SymbolContext symbolContext) {
+ this.symbolContext = symbolContext;
+ }
+
+ public void drawU(UGraphic ug) {
+ double x = 0;
+ double y = 0;
+ x += margin;
+ y += margin;
+ ug = symbolContext.apply(ug);
+ final UEllipse circle = new UEllipse(radius * 2, radius * 2);
+ circle.setDeltaShadow(symbolContext.getDeltaShadow());
+
+ final UPath path1 = new UPath();
+ path1.moveTo(0, 0);
+ path1.lineTo(0, radius * 2);
+ path1.setDeltaShadow(symbolContext.getDeltaShadow());
+
+ final UPath path = new UPath();
+ path.moveTo(0, 0);
+ path.lineTo(0, radius * 2);
+ path.moveTo(0, radius);
+ path.lineTo(left, radius);
+ path.setDeltaShadow(symbolContext.getDeltaShadow());
+ ug.apply(new UTranslate(x, y)).draw(path);
+
+ // final ULine line1 = new ULine(0, radius * 2);
+ // line1.setDeltaShadow(deltaShadow);
+ // ug.apply(new UTranslate(x, y)).draw(line1);
+ // final ULine line2 = new ULine(left, 0);
+ // line2.setDeltaShadow(deltaShadow);
+ // ug.apply(new UTranslate(x, y + radius)).draw(line2);
+
+ ug.apply(new UTranslate(x + left, y)).draw(circle);
+
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(radius * 2 + left + 2 * margin, radius * 2 + 2 * margin);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/CircleAndArrow.java b/src/net/sourceforge/plantuml/svek/CircleAndArrow.java
new file mode 100644
index 0000000..1c37040
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/CircleAndArrow.java
@@ -0,0 +1,99 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class CircleAndArrow implements UDrawable {
+
+ private final AffineTransform at;
+ private final AffineTransform at2;
+ private int radius;
+ private final Point2D center;
+ private final Point2D p1;
+ private final Point2D p2;
+ private Point2D p3;
+ private Point2D p4;
+
+ public CircleAndArrow(Point2D p1, Point2D p2) {
+ this.center = new Point2D.Double((p1.getX() + p2.getX()) / 2, (p1.getY() + p2.getY()) / 2);
+ at = AffineTransform.getTranslateInstance(-center.getX(), -center.getY());
+ at2 = AffineTransform.getTranslateInstance(center.getX(), center.getY());
+ radius = (int) (p1.distance(p2) / 2);
+ if (radius % 2 == 0) {
+ radius--;
+ }
+ this.p1 = putOnCircle(p1);
+ this.p2 = putOnCircle(p2);
+
+ this.p3 = at.transform(this.p1, null);
+ this.p3 = new Point2D.Double(p3.getY(), -p3.getX());
+ this.p3 = at2.transform(p3, null);
+
+ this.p4 = at.transform(this.p2, null);
+ this.p4 = new Point2D.Double(p4.getY(), -p4.getX());
+ this.p4 = at2.transform(p4, null);
+ }
+
+ private Point2D putOnCircle(Point2D p) {
+ p = at.transform(p, null);
+ final double coef = p.distance(new Point2D.Double()) / radius;
+ p = new Point2D.Double(p.getX() / coef, p.getY() / coef);
+ return at2.transform(p, null);
+ }
+
+ public void drawU(UGraphic ug) {
+ final UShape circle = new UEllipse(radius * 2, radius * 2);
+ ug.apply(new UTranslate(center.getX() - radius, center.getY() - radius)).draw(circle);
+ // drawLine(ug, x, y, p1, p2);
+ // drawLine(ug, x, y, p3, p4);
+ }
+
+ static private void drawLine(UGraphic ug, double x, double y, Point2D p1, Point2D p2) {
+ final double dx = p2.getX() - p1.getX();
+ final double dy = p2.getY() - p1.getY();
+ ug.apply(new UTranslate(x + p1.getX(), y + p1.getY())).draw(new ULine(dx, dy));
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/CircleInterface2.java b/src/net/sourceforge/plantuml/svek/CircleInterface2.java
new file mode 100644
index 0000000..715be88
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/CircleInterface2.java
@@ -0,0 +1,84 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class CircleInterface2 implements TextBlock {
+
+ private final double margin = 1;
+
+ private final double radius = 8;
+
+ private final HtmlColor backgroundColor;
+ private final HtmlColor foregroundColor;
+ private final float thickness = 2;
+
+ private final double deltaShadow;
+
+ public CircleInterface2(HtmlColor backgroundColor, HtmlColor foregroundColor, double deltaShadow) {
+ this.backgroundColor = backgroundColor;
+ this.foregroundColor = foregroundColor;
+ this.deltaShadow = deltaShadow;
+ }
+
+ public void drawU(UGraphic ug) {
+ double x = 0;
+ double y = 0;
+ x += margin;
+ y += margin;
+ ug = ug.apply(new UStroke(thickness)).apply(new UChangeBackColor(backgroundColor))
+ .apply(new UChangeColor(foregroundColor));
+ final UEllipse circle = new UEllipse(radius * 2, radius * 2);
+ circle.setDeltaShadow(deltaShadow);
+ ug.apply(new UTranslate(x, y)).draw(circle);
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(radius * 2 + 2 * margin, radius * 2 + 2 * margin);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/Cluster.java b/src/net/sourceforge/plantuml/svek/Cluster.java
new file mode 100644
index 0000000..6ccd02d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/Cluster.java
@@ -0,0 +1,868 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.LineParam;
+import net.sourceforge.plantuml.UmlDiagramType;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.cucadiagram.EntityPosition;
+import net.sourceforge.plantuml.cucadiagram.EntityUtils;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.IGroup;
+import net.sourceforge.plantuml.cucadiagram.Member;
+import net.sourceforge.plantuml.cucadiagram.MethodsOrFieldsArea;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.cucadiagram.dot.DotData;
+import net.sourceforge.plantuml.cucadiagram.dot.GraphvizVersion;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorTransparent;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockEmpty;
+import net.sourceforge.plantuml.graphic.TextBlockWidth;
+import net.sourceforge.plantuml.graphic.USymbol;
+import net.sourceforge.plantuml.posimo.Moveable;
+import net.sourceforge.plantuml.skin.rose.Rose;
+import net.sourceforge.plantuml.svek.image.EntityImageState;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.utils.UniqueSequence;
+
+public class Cluster implements Moveable {
+
+ private final Cluster parent;
+ private final IGroup group;
+ private final List<Shape> shapes = new ArrayList<Shape>();
+ private final List<Cluster> children = new ArrayList<Cluster>();
+ private final int color;
+ private final int colorTitle;
+ private final ISkinParam skinParam;
+
+ private int titleAndAttributeWidth;
+ private int titleAndAttributeHeight;
+ private TextBlock ztitle;
+ private TextBlock zstereo;
+
+ private double xTitle;
+ private double yTitle;
+
+ private double minX;
+ private double minY;
+ private double maxX;
+ private double maxY;
+
+ public void moveSvek(double deltaX, double deltaY) {
+ this.xTitle += deltaX;
+ this.minX += deltaX;
+ this.maxX += deltaX;
+ this.yTitle += deltaY;
+ this.minY += deltaY;
+ this.maxY += deltaY;
+
+ }
+
+ private boolean hasEntryOrExitPoint() {
+ for (Shape sh : shapes) {
+ if (sh.getEntityPosition() != EntityPosition.NORMAL) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public Cluster(ColorSequence colorSequence, ISkinParam skinParam, IGroup root) {
+ this(null, root, colorSequence, skinParam);
+ }
+
+ private ColorParam border;
+
+ private Cluster(Cluster parent, IGroup group, ColorSequence colorSequence, ISkinParam skinParam) {
+ if (group == null) {
+ throw new IllegalStateException();
+ }
+ this.parent = parent;
+ this.group = group;
+ if (group.getUSymbol() != null) {
+ border = group.getUSymbol().getColorParamBorder();
+ }
+ this.color = colorSequence.getValue();
+ this.colorTitle = colorSequence.getValue();
+ this.skinParam = skinParam;
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + " " + group;
+ }
+
+ public final Cluster getParent() {
+ return parent;
+ }
+
+ public void addShape(Shape sh) {
+ if (sh == null) {
+ throw new IllegalArgumentException();
+ }
+ this.shapes.add(sh);
+ sh.setCluster(this);
+ }
+
+ public final List<Shape> getShapes() {
+ return Collections.unmodifiableList(shapes);
+ }
+
+ private List<Shape> getShapesOrderedTop(Collection<Line> lines) {
+ final List<Shape> firsts = new ArrayList<Shape>();
+ final Set<String> tops = new HashSet<String>();
+ final Map<String, Shape> shs = new HashMap<String, Shape>();
+
+ for (final Iterator<Shape> it = shapes.iterator(); it.hasNext();) {
+ final Shape sh = it.next();
+ shs.put(sh.getUid(), sh);
+ if (sh.isTop() && sh.getEntityPosition() == EntityPosition.NORMAL) {
+ firsts.add(sh);
+ tops.add(sh.getUid());
+ }
+ }
+
+ for (Line l : lines) {
+ if (tops.contains(l.getStartUid())) {
+ final Shape sh = shs.get(l.getEndUid());
+ if (sh != null && sh.getEntityPosition() == EntityPosition.NORMAL) {
+ firsts.add(0, sh);
+ }
+ }
+
+ if (l.isInverted()) {
+ final Shape sh = shs.get(l.getStartUid());
+ if (sh != null && sh.getEntityPosition() == EntityPosition.NORMAL) {
+ firsts.add(0, sh);
+ }
+ }
+ }
+
+ return firsts;
+ }
+
+ private List<Shape> getShapesEntryExit(EntityPosition position) {
+ final List<Shape> result = new ArrayList<Shape>();
+
+ for (final Iterator<Shape> it = shapes.iterator(); it.hasNext();) {
+ final Shape sh = it.next();
+ if (sh.getEntityPosition() == position) {
+ result.add(sh);
+ }
+ }
+ return result;
+ }
+
+ private List<Shape> getShapesOrderedWithoutTop(Collection<Line> lines) {
+ final List<Shape> all = new ArrayList<Shape>(shapes);
+ final Set<String> tops = new HashSet<String>();
+ final Map<String, Shape> shs = new HashMap<String, Shape>();
+
+ for (final Iterator<Shape> it = all.iterator(); it.hasNext();) {
+ final Shape sh = it.next();
+ if (sh.getEntityPosition() != EntityPosition.NORMAL) {
+ it.remove();
+ continue;
+ }
+ shs.put(sh.getUid(), sh);
+ if (sh.isTop()) {
+ tops.add(sh.getUid());
+ it.remove();
+ }
+ }
+
+ for (Line l : lines) {
+ if (tops.contains(l.getStartUid())) {
+ final Shape sh = shs.get(l.getEndUid());
+ if (sh != null) {
+ all.remove(sh);
+ }
+ }
+
+ if (l.isInverted()) {
+ final Shape sh = shs.get(l.getStartUid());
+ if (sh != null) {
+ all.remove(sh);
+ }
+ }
+ }
+
+ return all;
+ }
+
+ public final List<Cluster> getChildren() {
+ return Collections.unmodifiableList(children);
+ }
+
+ public Cluster createChild(IGroup g, int titleAndAttributeWidth, int titleAndAttributeHeight, TextBlock title,
+ TextBlock stereo, ColorSequence colorSequence, ISkinParam skinParam) {
+ final Cluster child = new Cluster(this, g, colorSequence, skinParam);
+ child.titleAndAttributeWidth = titleAndAttributeWidth;
+ child.titleAndAttributeHeight = titleAndAttributeHeight;
+ child.ztitle = title;
+ child.zstereo = stereo;
+ this.children.add(child);
+ return child;
+ }
+
+ public final IGroup getGroup() {
+ return group;
+ }
+
+ public final int getTitleAndAttributeWidth() {
+ return titleAndAttributeWidth;
+ }
+
+ public final int getTitleAndAttributeHeight() {
+ return titleAndAttributeHeight;
+ }
+
+ public double getWidth() {
+ return maxX - minX;
+ }
+
+ public double getMinX() {
+ return minX;
+ }
+
+ public ClusterPosition getClusterPosition() {
+ return new ClusterPosition(minX, minY, maxX, maxY);
+ }
+
+ public void setTitlePosition(double x, double y) {
+ this.xTitle = x;
+ this.yTitle = y;
+ }
+
+ private static HtmlColor getColor(ColorParam colorParam, ISkinParam skinParam) {
+ return new Rose().getHtmlColor(skinParam, colorParam);
+ }
+
+ public void drawU(UGraphic ug, DotData dotData, UStroke stroke) {
+ HtmlColor borderColor;
+ if (dotData.getUmlDiagramType() == UmlDiagramType.STATE) {
+ borderColor = getColor(ColorParam.stateBorder, dotData.getSkinParam());
+ } else {
+ borderColor = getColor(ColorParam.packageBorder, dotData.getSkinParam());
+ }
+
+ final Url url = group.getUrl99();
+ if (url != null) {
+ ug.startUrl(url);
+ }
+ try {
+ if (hasEntryOrExitPoint()) {
+ manageEntryExitPoint(dotData, ug.getStringBounder());
+ }
+ if (skinParam.useSwimlanes(dotData.getUmlDiagramType())) {
+ drawSwinLinesState(ug, borderColor, dotData);
+ return;
+ }
+ final boolean isState = dotData.getUmlDiagramType() == UmlDiagramType.STATE;
+ if (isState) {
+ if (group.getSpecificLineStroke() != null) {
+ stroke = group.getSpecificLineStroke();
+ }
+ if (group.getSpecificLineColor() != null) {
+ borderColor = group.getSpecificLineColor();
+ }
+ drawUState(ug, borderColor, dotData, stroke);
+ return;
+ }
+ PackageStyle style = group.getPackageStyle();
+ if (style == null) {
+ style = dotData.getSkinParam().getPackageStyle();
+ }
+ if (border != null) {
+ final HtmlColor tmp = dotData.getSkinParam().getHtmlColor(border, null, false);
+ if (tmp != null) {
+ borderColor = tmp;
+ }
+ }
+
+ if (ztitle != null || zstereo != null) {
+ final HtmlColor stateBack = getStateBackColor(getBackColor(), dotData.getSkinParam(),
+ group.getStereotype());
+ final ClusterDecoration decoration = new ClusterDecoration(style, group.getUSymbol(), ztitle, zstereo,
+ stateBack, minX, minY, maxX, maxY, getStroke(dotData.getSkinParam(), group.getStereotype()));
+ decoration.drawU(ug, borderColor, dotData.getSkinParam().shadowing());
+ return;
+ }
+ final URectangle rect = new URectangle(maxX - minX, maxY - minY);
+ if (dotData.getSkinParam().shadowing()) {
+ rect.setDeltaShadow(3.0);
+ }
+ final HtmlColor stateBack = getStateBackColor(getBackColor(), dotData.getSkinParam(), group.getStereotype());
+ ug = ug.apply(new UChangeBackColor(stateBack)).apply(new UChangeColor(borderColor));
+ ug.apply(new UStroke(2)).apply(new UTranslate(minX, minY)).draw(rect);
+
+ } finally {
+ if (url != null) {
+ ug.closeAction();
+ }
+ }
+
+ }
+
+ private UStroke getStroke(ISkinParam skinParam, Stereotype stereo) {
+ UStroke stroke = skinParam.getThickness(LineParam.packageBorder, stereo);
+ if (stroke == null) {
+ stroke = new UStroke(2.0);
+ }
+ return stroke;
+ }
+
+ private void manageEntryExitPoint(DotData dotData, StringBounder stringBounder) {
+ final Collection<ClusterPosition> insides = new ArrayList<ClusterPosition>();
+ final List<Point2D> points = new ArrayList<Point2D>();
+ for (Shape sh : shapes) {
+ if (sh.getEntityPosition() == EntityPosition.NORMAL) {
+ insides.add(sh.getClusterPosition());
+ } else {
+ points.add(sh.getClusterPosition().getPointCenter());
+ }
+ }
+ for (Cluster in : children) {
+ insides.add(in.getClusterPosition());
+ }
+ final FrontierCalculator frontierCalculator = new FrontierCalculator(getClusterPosition(), insides, points);
+ if (titleAndAttributeHeight > 0 && titleAndAttributeWidth > 0) {
+ frontierCalculator.ensureMinWidth(titleAndAttributeWidth + 10);
+ }
+ final ClusterPosition forced = frontierCalculator.getSuggestedPosition();
+ xTitle += ((forced.getMinX() - minX) + (forced.getMaxX() - maxX)) / 2;
+ minX = forced.getMinX();
+ minY = forced.getMinY();
+ maxX = forced.getMaxX();
+ maxY = forced.getMaxY();
+ yTitle = minY + IEntityImage.MARGIN;
+ final double widthTitle = ztitle.calculateDimension(stringBounder).getWidth();
+ xTitle = minX + ((maxX - minX - widthTitle) / 2);
+ }
+
+ private void drawSwinLinesState(UGraphic ug, HtmlColor borderColor, DotData dotData) {
+ if (ztitle != null) {
+ ztitle.drawU(ug.apply(new UTranslate(xTitle, 0)));
+ }
+ final ULine line = new ULine(0, maxY - minY);
+ ug = ug.apply(new UChangeColor(borderColor));
+ ug.apply(new UTranslate(minX, 0)).draw(line);
+ ug.apply(new UTranslate(maxX, 0)).draw(line);
+
+ }
+
+ private HtmlColor getColor(DotData dotData, ColorParam colorParam, Stereotype stereo) {
+ return new Rose().getHtmlColor(dotData.getSkinParam(), colorParam, stereo);
+ }
+
+ private void drawUState(UGraphic ug, HtmlColor borderColor, DotData dotData, UStroke stroke) {
+ final Dimension2D total = new Dimension2DDouble(maxX - minX, maxY - minY);
+ final double suppY;
+ if (ztitle == null) {
+ suppY = 0;
+ } else {
+ suppY = ztitle.calculateDimension(ug.getStringBounder()).getHeight() + IEntityImage.MARGIN
+ + IEntityImage.MARGIN_LINE;
+ }
+
+ HtmlColor stateBack = getBackColor();
+ if (stateBack == null) {
+ stateBack = getColor(dotData, ColorParam.stateBackground, group.getStereotype());
+ }
+ final HtmlColor background = getColor(dotData, ColorParam.background, null);
+ final TextBlockWidth attribute = getTextBlockAttribute(dotData);
+ final double attributeHeight = attribute.calculateDimension(ug.getStringBounder()).getHeight();
+ final RoundedContainer r = new RoundedContainer(total, suppY, attributeHeight
+ + (attributeHeight > 0 ? IEntityImage.MARGIN : 0), borderColor, stateBack, background, stroke);
+ r.drawU(ug.apply(new UTranslate(minX, minY)), dotData.getSkinParam().shadowing());
+
+ if (ztitle != null) {
+ ztitle.drawU(ug.apply(new UTranslate(xTitle, yTitle)));
+ }
+
+ if (attributeHeight > 0) {
+ attribute.asTextBlock(total.getWidth()).drawU(
+ ug.apply(new UTranslate(minX + IEntityImage.MARGIN, minY + suppY + IEntityImage.MARGIN / 2.0)));
+ }
+
+ final Stereotype stereotype = group.getStereotype();
+ final boolean withSymbol = stereotype != null && stereotype.isWithOOSymbol();
+ if (withSymbol) {
+ EntityImageState.drawSymbol(ug.apply(new UChangeColor(borderColor)), maxX, maxY);
+ }
+
+ }
+
+ private TextBlockWidth getTextBlockAttribute(DotData dotData) {
+ final TextBlockWidth attribute;
+ final List<Member> members = group.getFieldsToDisplay();
+ if (members.size() == 0) {
+ attribute = new TextBlockEmpty();
+ } else {
+ attribute = new MethodsOrFieldsArea(members, FontParam.STATE_ATTRIBUTE, dotData.getSkinParam());
+ }
+ return attribute;
+ }
+
+ public void setPosition(double minX, double minY, double maxX, double maxY) {
+ this.minX = minX;
+ this.maxX = maxX;
+ this.minY = minY;
+ this.maxY = maxY;
+
+ }
+
+ private boolean isThereALinkFromOrToGroup(Collection<Line> lines) {
+ for (Line line : lines) {
+ if (line.isLinkFromOrTo(group)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void printCluster1(StringBuilder sb, Collection<Line> lines) {
+ for (Shape sh : getShapesOrderedTop(lines)) {
+ sh.appendShape(sb);
+ }
+ }
+
+ private List<IShapePseudo> addProtection(List<Shape> entries, double width) {
+ final List<IShapePseudo> result = new ArrayList<IShapePseudo>();
+ result.add(entries.get(0));
+ for (int i = 1; i < entries.size(); i++) {
+ result.add(new ShapePseudoImpl("psd" + UniqueSequence.getValue(), width, 5));
+ result.add(entries.get(i));
+ }
+ return result;
+ }
+
+ private double getMaxWidthFromLabelForEntryExit(List<Shape> entries, StringBounder stringBounder) {
+ double result = -Double.MAX_VALUE;
+ for (Shape shape : entries) {
+ final double w = getMaxWidthFromLabelForEntryExit(shape, stringBounder);
+ if (w > result) {
+ result = w;
+ }
+ }
+ return result;
+ }
+
+ private double getMaxWidthFromLabelForEntryExit(Shape shape, StringBounder stringBounder) {
+ return shape.getMaxWidthFromLabelForEntryExit(stringBounder);
+ }
+
+ public void printClusterEntryExit(StringBuilder sb, StringBounder stringBounder) {
+ // final List<? extends IShapePseudo> entries = getShapesEntryExit(EntityPosition.ENTRY_POINT);
+ final List<Shape> shapesEntryExitList = getShapesEntryExit(EntityPosition.ENTRY_POINT);
+ final double maxWith = getMaxWidthFromLabelForEntryExit(shapesEntryExitList, stringBounder);
+ final double naturalSpace = 70;
+ final List<? extends IShapePseudo> entries;
+ if (maxWith > naturalSpace) {
+ entries = addProtection(shapesEntryExitList, maxWith - naturalSpace);
+ } else {
+ entries = shapesEntryExitList;
+ }
+ if (entries.size() > 0) {
+ sb.append("{rank=source;");
+ for (IShapePseudo sh : entries) {
+ sb.append(sh.getUid() + ";");
+ }
+ sb.append("}");
+ for (IShapePseudo sh : entries) {
+ sh.appendShape(sb);
+ }
+ }
+ final List<Shape> exits = getShapesEntryExit(EntityPosition.EXIT_POINT);
+ if (exits.size() > 0) {
+ sb.append("{rank=sink;");
+ for (Shape sh : exits) {
+ sb.append(sh.getUid() + ";");
+ }
+ sb.append("}");
+ for (Shape sh : exits) {
+ sh.appendShape(sb);
+ }
+ }
+ }
+
+ public boolean printCluster2(StringBuilder sb, Collection<Line> lines, StringBounder stringBounder,
+ DotMode dotMode, GraphvizVersion graphvizVersion, UmlDiagramType type) {
+ // Log.println("Cluster::printCluster " + this);
+
+ boolean added = false;
+ for (Shape sh : getShapesOrderedWithoutTop(lines)) {
+ sh.appendShape(sb);
+ added = true;
+ }
+
+ if (dotMode != DotMode.NO_LEFT_RIGHT) {
+ appendRankSame(sb, lines);
+ }
+
+ for (Cluster child : getChildren()) {
+ child.printInternal(sb, lines, stringBounder, dotMode, graphvizVersion, type);
+ }
+
+ return added;
+ }
+
+ private void appendRankSame(StringBuilder sb, Collection<Line> lines) {
+ for (String same : getRankSame(lines)) {
+ sb.append(same);
+ SvekUtils.println(sb);
+ }
+ }
+
+ private Set<String> getRankSame(Collection<Line> lines) {
+ final Set<String> rankSame = new HashSet<String>();
+ for (Line l : lines) {
+ if (l.hasEntryPoint()) {
+ continue;
+ }
+ final String startUid = l.getStartUid();
+ final String endUid = l.getEndUid();
+ if (isInCluster(startUid) && isInCluster(endUid)) {
+ final String same = l.rankSame();
+ if (same != null) {
+ rankSame.add(same);
+ }
+ }
+ }
+ return rankSame;
+ }
+
+ public void fillRankMin(Set<String> rankMin) {
+ for (Shape sh : getShapes()) {
+ if (sh.isTop()) {
+ rankMin.add(sh.getUid());
+ }
+ }
+
+ for (Cluster child : getChildren()) {
+ child.fillRankMin(rankMin);
+ }
+ }
+
+ private boolean isInCluster(String uid) {
+ for (Shape sh : shapes) {
+ if (sh.getUid().equals(uid)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public String getClusterId() {
+ return "cluster" + color;
+ }
+
+ public static String getSpecialPointId(IEntity group) {
+ return CENTER_ID + group.getUid();
+ }
+
+ public final static String CENTER_ID = "za";
+
+ private boolean protection0(UmlDiagramType type) {
+ if (skinParam.useSwimlanes(type)) {
+ return false;
+ }
+ return true;
+ }
+
+ private boolean protection1(UmlDiagramType type) {
+ if (group.getUSymbol() == USymbol.NODE) {
+ return true;
+ }
+ if (skinParam.useSwimlanes(type)) {
+ return false;
+ }
+ return true;
+ }
+
+ public String getMinPoint(UmlDiagramType type) {
+ if (skinParam.useSwimlanes(type)) {
+ return "minPoint" + color;
+ }
+ return null;
+ }
+
+ public String getMaxPoint(UmlDiagramType type) {
+ if (skinParam.useSwimlanes(type)) {
+ return "maxPoint" + color;
+ }
+ return null;
+ }
+
+ private String getSourceInPoint(UmlDiagramType type) {
+ if (skinParam.useSwimlanes(type)) {
+ return "sourceIn" + color;
+ }
+ return null;
+ }
+
+ private String getSinkInPoint(UmlDiagramType type) {
+ if (skinParam.useSwimlanes(type)) {
+ return "sinkIn" + color;
+ }
+ return null;
+ }
+
+ private void printInternal(StringBuilder sb, Collection<Line> lines, StringBounder stringBounder, DotMode dotMode,
+ GraphvizVersion graphvizVersion, UmlDiagramType type) {
+ final boolean thereALinkFromOrToGroup2 = isThereALinkFromOrToGroup(lines);
+ boolean thereALinkFromOrToGroup1 = thereALinkFromOrToGroup2;
+ final boolean useProtectionWhenThereALinkFromOrToGroup = graphvizVersion
+ .useProtectionWhenThereALinkFromOrToGroup();
+ if (useProtectionWhenThereALinkFromOrToGroup == false) {
+ thereALinkFromOrToGroup1 = false;
+ }
+ // final boolean thereALinkFromOrToGroup1 = false;
+ if (thereALinkFromOrToGroup1) {
+ subgraphCluster(sb, "a");
+ }
+ final boolean hasEntryOrExitPoint = hasEntryOrExitPoint();
+ if (hasEntryOrExitPoint) {
+ for (Line line : lines) {
+ if (line.isLinkFromOrTo(group)) {
+ line.setProjectionCluster(this);
+ }
+ }
+ }
+ boolean protection0 = protection0(type);
+ boolean protection1 = protection1(type);
+ if (hasEntryOrExitPoint || useProtectionWhenThereALinkFromOrToGroup == false) {
+ protection0 = false;
+ protection1 = false;
+ }
+ if (protection0) {
+ subgraphCluster(sb, "p0");
+ }
+ sb.append("subgraph " + getClusterId() + " {");
+ sb.append("style=solid;");
+ sb.append("color=\"" + StringUtils.getAsHtml(color) + "\";");
+
+ final boolean isLabel = getTitleAndAttributeHeight() > 0 && getTitleAndAttributeWidth() > 0;
+ final String label;
+ if (isLabel) {
+ final StringBuilder sblabel = new StringBuilder("<");
+ Line.appendTable(sblabel, getTitleAndAttributeWidth(), getTitleAndAttributeHeight() - 5, colorTitle);
+ sblabel.append(">");
+ label = sblabel.toString();
+ } else {
+ label = "\"\"";
+ }
+
+ if (hasEntryOrExitPoint) {
+ printClusterEntryExit(sb, stringBounder);
+ subgraphCluster(sb, "ee", label);
+ } else {
+ sb.append("label=" + label + ";");
+ SvekUtils.println(sb);
+ }
+
+ // if (hasEntryOrExitPoint) {
+ // printClusterEntryExit(sb);
+ // subgraphCluster(sb, "ee");
+ // }
+
+ if (thereALinkFromOrToGroup2) {
+ sb.append(getSpecialPointId(group) + " [shape=point,width=.01,label=\"\"];");
+ }
+ if (thereALinkFromOrToGroup1) {
+ subgraphCluster(sb, "i");
+ }
+ if (protection1) {
+ subgraphCluster(sb, "p1");
+ }
+ if (skinParam.useSwimlanes(type)) {
+ sb.append("{rank = source; ");
+ sb.append(getSourceInPoint(type));
+ sb.append(" [shape=point,width=.01,label=\"\"];");
+ sb.append(getMinPoint(type) + "->" + getSourceInPoint(type) + " [weight=999];");
+ sb.append("}");
+ SvekUtils.println(sb);
+ sb.append("{rank = sink; ");
+ sb.append(getSinkInPoint(type));
+ sb.append(" [shape=point,width=.01,label=\"\"];");
+ sb.append("}");
+ sb.append(getSinkInPoint(type) + "->" + getMaxPoint(type) + " [weight=999];");
+ SvekUtils.println(sb);
+ }
+ SvekUtils.println(sb);
+ printCluster1(sb, lines);
+ final boolean added = printCluster2(sb, lines, stringBounder, dotMode, graphvizVersion, type);
+ if (hasEntryOrExitPoint && added == false) {
+ final String empty = "empty" + color;
+ sb.append(empty + " [shape=point,width=.01,label=\"\"];");
+ }
+ sb.append("}");
+ if (protection1) {
+ sb.append("}");
+ }
+ if (thereALinkFromOrToGroup1) {
+ sb.append("}");
+ sb.append("}");
+ }
+ if (hasEntryOrExitPoint) {
+ sb.append("}");
+ }
+ if (protection0) {
+ sb.append("}");
+ }
+ SvekUtils.println(sb);
+ }
+
+ private void subgraphCluster(StringBuilder sb, String id) {
+ subgraphCluster(sb, id, "\"\"");
+ }
+
+ private void subgraphCluster(StringBuilder sb, String id, String label) {
+ final String uid = getClusterId() + id;
+ sb.append("subgraph " + uid + " {");
+ sb.append("label=" + label + ";");
+ }
+
+ public int getColor() {
+ return color;
+ }
+
+ public int getTitleColor() {
+ return colorTitle;
+ }
+
+ private final HtmlColor getBackColor() {
+ if (EntityUtils.groupRoot(group)) {
+ return null;
+ }
+ final HtmlColor result = group.getSpecificBackColor();
+ if (result != null) {
+ return result;
+ }
+ final Stereotype stereo = group.getStereotype();
+ final USymbol sym = group.getUSymbol() == null ? USymbol.PACKAGE : group.getUSymbol();
+ final ColorParam backparam = sym.getColorParamBack();
+ final HtmlColor c1 = skinParam.getHtmlColor(backparam, stereo, false);
+ if (c1 != null) {
+ return c1;
+ }
+ if (parent == null) {
+ return null;
+ }
+ return parent.getBackColor();
+ }
+
+ public boolean isClusterOf(IEntity ent) {
+ if (ent.isGroup() == false) {
+ return false;
+ }
+ return group == ent;
+ }
+
+ public static HtmlColor getStateBackColor(HtmlColor stateBack, ISkinParam skinParam, Stereotype stereotype) {
+ if (stateBack == null) {
+ stateBack = skinParam.getHtmlColor(ColorParam.packageBackground, stereotype, false);
+ }
+ if (stateBack == null) {
+ stateBack = skinParam.getHtmlColor(ColorParam.background, stereotype, false);
+ }
+ if (stateBack == null /* || stateBack instanceof HtmlColorTransparent */) {
+ stateBack = new HtmlColorTransparent();
+ }
+ return stateBack;
+ }
+
+ public double checkFolderPosition(Point2D pt, StringBounder stringBounder) {
+ if (getClusterPosition().isPointJustUpper(pt)) {
+ if (ztitle == null) {
+ return 0;
+ }
+ final Dimension2D dimTitle = ztitle.calculateDimension(stringBounder);
+
+ if (pt.getX() < getClusterPosition().getMinX() + dimTitle.getWidth()) {
+ return 0;
+ }
+
+ return getClusterPosition().getMinY() - pt.getY() + dimTitle.getHeight();
+ }
+ return 0;
+ }
+
+ // public Point2D projection(double x, double y) {
+ // final double v1 = Math.abs(minX - x);
+ // final double v2 = Math.abs(maxX - x);
+ // final double v3 = Math.abs(minY - y);
+ // final double v4 = Math.abs(maxY - y);
+ // if (v1 <= v2 && v1 <= v3 && v1 <= v4) {
+ // return new Point2D.Double(minX, y);
+ // }
+ // if (v2 <= v1 && v2 <= v3 && v2 <= v4) {
+ // return new Point2D.Double(maxX, y);
+ // }
+ // if (v3 <= v1 && v3 <= v2 && v3 <= v4) {
+ // return new Point2D.Double(x, minY);
+ // }
+ // if (v4 <= v1 && v4 <= v1 && v4 <= v3) {
+ // return new Point2D.Double(x, maxY);
+ // }
+ // throw new IllegalStateException();
+ // }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/ClusterDecoration.java b/src/net/sourceforge/plantuml/svek/ClusterDecoration.java
new file mode 100644
index 0000000..88191e0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/ClusterDecoration.java
@@ -0,0 +1,235 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.SymbolContext;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.graphic.USymbol;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ClusterDecoration {
+
+ private final UStroke defaultStroke;// = new UStroke(2);
+ final private PackageStyle style;
+ final private USymbol symbol;
+ final private TextBlock title;
+ final private TextBlock stereo;
+ final private HtmlColor stateBack;
+
+ final private double minX;
+ final private double minY;
+ final private double maxX;
+ final private double maxY;
+
+ public ClusterDecoration(PackageStyle style, USymbol symbol, TextBlock title, TextBlock stereo,
+ HtmlColor stateBack, double minX, double minY, double maxX, double maxY, UStroke stroke) {
+ this.symbol = symbol;
+ this.style = style;
+ this.stereo = stereo;
+ this.title = title;
+ this.stateBack = stateBack;
+ this.minX = minX;
+ this.minY = minY;
+ this.maxX = maxX;
+ this.maxY = maxY;
+ this.defaultStroke = stroke;
+ // if (stateBack instanceof HtmlColorTransparent) {
+ // throw new UnsupportedOperationException();
+ // }
+ }
+
+ public void drawU(UGraphic ug, HtmlColor borderColor, boolean shadowing) {
+ if (symbol != null) {
+ final SymbolContext symbolContext = new SymbolContext(stateBack, borderColor).withShadow(shadowing)
+ .withStroke(defaultStroke);
+ symbol.asBig(title, stereo, maxX - minX, maxY - minY, symbolContext).drawU(
+ ug.apply(new UTranslate(minX, minY)));
+ // ug.getParam().resetStroke();
+ return;
+ }
+ if (style == PackageStyle.NODE) {
+ drawWithTitleNode(ug, borderColor, shadowing);
+ } else if (style == PackageStyle.CARD) {
+ drawWithTitleCard(ug, borderColor, shadowing);
+ } else if (style == PackageStyle.DATABASE) {
+ drawWithTitleDatabase(ug, borderColor, shadowing);
+ } else if (style == PackageStyle.CLOUD) {
+ drawWithTitleCloud(ug, borderColor, shadowing);
+ } else if (style == PackageStyle.FRAME) {
+ drawWithTitleFrame(ug, borderColor, shadowing);
+ } else if (style == PackageStyle.RECT) {
+ drawWithTitleRect(ug, borderColor, shadowing);
+ } else {
+ drawWithTitleFolder(ug, borderColor, shadowing);
+ }
+ }
+
+ // Cloud
+ private void drawWithTitleCloud(UGraphic ug, HtmlColor borderColor, boolean shadowing) {
+ final Dimension2D dimTitle = title.calculateDimension(ug.getStringBounder());
+ final double width = maxX - minX;
+ final double height = maxY - minY;
+ ug = ug.apply(new UChangeBackColor(stateBack)).apply(new UChangeColor(borderColor));
+ ug = ug.apply(defaultStroke);
+ PackageStyle.CLOUD.drawU(ug.apply(new UTranslate(minX, minY)), new Dimension2DDouble(width, height), dimTitle,
+ shadowing);
+ ug = ug.apply(new UStroke());
+ title.drawU(ug.apply(new UTranslate(minX + (width - dimTitle.getWidth()) / 2, minY + 10)));
+
+ }
+
+ // Database
+ private void drawWithTitleDatabase(UGraphic ug, HtmlColor borderColor, boolean shadowing) {
+ final Dimension2D dimTitle = title.calculateDimension(ug.getStringBounder());
+ final double width = maxX - minX;
+ final double height = maxY - minY;
+ ug = ug.apply(defaultStroke);
+ ug = ug.apply(new UChangeBackColor(stateBack)).apply(new UChangeColor(borderColor));
+ PackageStyle.DATABASE.drawU(ug.apply(new UTranslate(minX, minY - 10)),
+ new Dimension2DDouble(width, height + 10), dimTitle, shadowing);
+ ug = ug.apply(new UStroke());
+ title.drawU(ug.apply(new UTranslate(minX + marginTitleX1, minY + 10)));
+
+ }
+
+ // Corner
+ private void drawWithTitleFrame(UGraphic ug, HtmlColor borderColor, boolean shadowing) {
+ final Dimension2D dimTitle = title.calculateDimension(ug.getStringBounder());
+ final double width = maxX - minX;
+ final double height = maxY - minY;
+ ug = ug.apply(new UChangeBackColor(stateBack)).apply(new UChangeColor(borderColor));
+ ug = ug.apply(defaultStroke);
+ PackageStyle.FRAME.drawU(ug.apply(new UTranslate(minX, minY)), new Dimension2DDouble(width, height), dimTitle,
+ shadowing);
+ ug = ug.apply(new UStroke());
+ title.drawU(ug.apply(new UTranslate(minX + marginTitleX1, minY)));
+
+ }
+
+ // Card
+ private void drawWithTitleCard(UGraphic ug, HtmlColor borderColor, boolean shadowing) {
+ final double width = maxX - minX;
+ final double height = maxY - minY;
+ final SymbolContext ctx = new SymbolContext(stateBack, borderColor).withStroke(defaultStroke).withShadow(
+ shadowing);
+ USymbol.CARD.asBig(title, TextBlockUtils.empty(0, 0), width + 10, height, ctx).drawU(
+ ug.apply(new UTranslate(minX, minY)));
+ }
+
+ // Node
+ private void drawWithTitleNode(UGraphic ug, HtmlColor borderColor, boolean shadowing) {
+ final double width = maxX - minX;
+ final double height = maxY - minY;
+ final SymbolContext ctx = new SymbolContext(stateBack, borderColor).withStroke(defaultStroke).withShadow(
+ shadowing);
+ USymbol.NODE.asBig(title, TextBlockUtils.empty(0, 0), width + 10, height, ctx).drawU(
+ ug.apply(new UTranslate(minX, minY)));
+ }
+
+ // Folder
+ private UPolygon getSpecificFrontierForFolder(StringBounder stringBounder) {
+ final double width = maxX - minX;
+ final double height = maxY - minY;
+ final Dimension2D dimTitle = title.calculateDimension(stringBounder);
+ final double wtitle = dimTitle.getWidth() + marginTitleX1 + marginTitleX2;
+ final double htitle = dimTitle.getHeight() + marginTitleY1 + marginTitleY2;
+ final UPolygon shape = new UPolygon();
+ shape.addPoint(0, 0);
+ shape.addPoint(wtitle, 0);
+ shape.addPoint(wtitle + marginTitleX3, htitle);
+ shape.addPoint(width, htitle);
+ shape.addPoint(width, height);
+ shape.addPoint(0, height);
+ shape.addPoint(0, 0);
+ return shape;
+ }
+
+ private void drawWithTitleFolder(UGraphic ug, HtmlColor borderColor, boolean shadowing) {
+ final Dimension2D dimTitle = title.calculateDimension(ug.getStringBounder());
+ final double wtitle = dimTitle.getWidth() + marginTitleX1 + marginTitleX2;
+ final double htitle = dimTitle.getHeight() + marginTitleY1 + marginTitleY2;
+ final UPolygon shape = getSpecificFrontierForFolder(ug.getStringBounder());
+ if (shadowing) {
+ shape.setDeltaShadow(3.0);
+ }
+
+ ug = ug.apply(new UChangeBackColor(stateBack)).apply(new UChangeColor(borderColor));
+ ug = ug.apply(defaultStroke);
+ ug.apply(new UTranslate(minX, minY)).draw(shape);
+ ug.apply(new UTranslate(minX, minY + htitle)).draw(new ULine(wtitle + marginTitleX3, 0));
+ ug = ug.apply(new UStroke());
+ title.drawU(ug.apply(new UTranslate(minX + marginTitleX1, minY + marginTitleY1)));
+ }
+
+ // Rect
+ private void drawWithTitleRect(UGraphic ug, HtmlColor borderColor, boolean shadowing) {
+ final Dimension2D dimTitle = title.calculateDimension(ug.getStringBounder());
+ final double width = maxX - minX;
+ final double height = maxY - minY;
+ final URectangle shape = new URectangle(width, height);
+ if (shadowing) {
+ shape.setDeltaShadow(3.0);
+ }
+
+ ug = ug.apply(new UChangeBackColor(stateBack)).apply(new UChangeColor(borderColor));
+ ug = ug.apply(defaultStroke);
+
+ ug.apply(new UTranslate(minX, minY)).draw(shape);
+ ug = ug.apply(new UStroke());
+ final double deltax = width - dimTitle.getWidth();
+ title.drawU(ug.apply(new UTranslate(minX + deltax / 2, minY + 5)));
+ }
+
+ public final static int marginTitleX1 = 3;
+ public final static int marginTitleX2 = 3;
+ public final static int marginTitleX3 = 7;
+ public final static int marginTitleY0 = 0;
+ public final static int marginTitleY1 = 3;
+ public final static int marginTitleY2 = 3;
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/ClusterPosition.java b/src/net/sourceforge/plantuml/svek/ClusterPosition.java
new file mode 100644
index 0000000..63bb9a1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/ClusterPosition.java
@@ -0,0 +1,191 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+import java.awt.geom.CubicCurve2D;
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.posimo.BezierUtils;
+
+public class ClusterPosition {
+
+ private final double minX;
+ private final double minY;
+ private final double maxX;
+ private final double maxY;
+
+ public ClusterPosition(double minX, double minY, double maxX, double maxY) {
+ this.minX = minX;
+ this.minY = minY;
+ this.maxX = maxX;
+ this.maxY = maxY;
+ }
+
+ public boolean contains(double x, double y) {
+ return x >= minX && x < maxX && y >= minY && y < maxY;
+ }
+
+ public ClusterPosition merge(ClusterPosition other) {
+ return new ClusterPosition(Math.min(this.minX, other.minX), Math.min(this.minY, other.minY), Math.max(
+ this.maxX, other.maxX), Math.max(this.maxY, other.maxY));
+ }
+
+ public ClusterPosition merge(Point2D point) {
+ final double x = point.getX();
+ final double y = point.getY();
+ return new ClusterPosition(Math.min(this.minX, x), Math.min(this.minY, y), Math.max(this.maxX, x), Math.max(
+ this.maxY, y));
+ }
+
+ public boolean contains(Point2D p) {
+ return contains(p.getX(), p.getY());
+ }
+
+ @Override
+ public String toString() {
+ return "minX=" + minX + " maxX=" + maxX + " minY=" + minY + " maxY=" + maxY;
+ }
+
+ public final double getMinX() {
+ return minX;
+ }
+
+ public final double getMinY() {
+ return minY;
+ }
+
+ public final double getMaxX() {
+ return maxX;
+ }
+
+ public final double getMaxY() {
+ return maxY;
+ }
+
+ public PointDirected getIntersection(CubicCurve2D.Double bez) {
+ if (contains(bez.x1, bez.y1) == contains(bez.x2, bez.y2)) {
+ return null;
+ }
+ final double dist = bez.getP1().distance(bez.getP2());
+ if (dist < 2) {
+ final double angle = BezierUtils.getStartingAngle(bez);
+ return new PointDirected(bez.getP1(), angle);
+ }
+ final CubicCurve2D.Double left = new CubicCurve2D.Double();
+ final CubicCurve2D.Double right = new CubicCurve2D.Double();
+ bez.subdivide(left, right);
+ final PointDirected int1 = getIntersection(left);
+ if (int1 != null) {
+ return int1;
+ }
+ final PointDirected int2 = getIntersection(right);
+ if (int2 != null) {
+ return int2;
+ }
+ throw new IllegalStateException();
+ }
+
+ public Point2D getPointCenter() {
+ return new Point2D.Double((minX + maxX) / 2, (minY + maxY) / 2);
+ }
+
+ public ClusterPosition withMinX(double d) {
+ return new ClusterPosition(d, minY, maxX, maxY);
+ }
+
+ public ClusterPosition withMaxX(double d) {
+ return new ClusterPosition(minX, minY, d, maxY);
+ }
+
+ public ClusterPosition addMaxX(double d) {
+ return new ClusterPosition(minX, minY, maxX + d, maxY);
+ }
+
+ public ClusterPosition addMaxY(double d) {
+ return new ClusterPosition(minX, minY, maxX, maxY + d);
+ }
+
+ public ClusterPosition addMinX(double d) {
+ return new ClusterPosition(minX + d, minY, maxX, maxY);
+ }
+
+ public ClusterPosition addMinY(double d) {
+ return new ClusterPosition(minX, minY + d, maxX, maxY);
+ }
+
+ public ClusterPosition withMinY(double d) {
+ return new ClusterPosition(minX, d, maxX, maxY);
+ }
+
+ public ClusterPosition withMaxY(double d) {
+ return new ClusterPosition(minX, minY, maxX, d);
+ }
+
+ public Point2D getProjectionOnFrontier(Point2D pt) {
+ final double x = pt.getX();
+ final double y = pt.getY();
+ if (x > maxX && y >= minY && y <= maxY) {
+ return new Point2D.Double(maxX - 1, y);
+ }
+ if (x < minX && y >= minY && y <= maxY) {
+ return new Point2D.Double(minX + 1, y);
+ }
+ if (y > maxY && x >= minX && x <= maxX) {
+ return new Point2D.Double(x, maxY - 1);
+ }
+ if (y < minY && x >= minX && x <= maxX) {
+ return new Point2D.Double(x, minY + 1);
+ }
+ return new Point2D.Double(x, y);
+ }
+
+ public ClusterPosition delta(double m1, double m2) {
+ return new ClusterPosition(minX, minY, maxX + m1, maxY + m2);
+ }
+
+ public Dimension2D getDimension() {
+ return new Dimension2DDouble(maxX - minX, maxY - minY);
+ }
+
+ public boolean isPointJustUpper(Point2D pt) {
+ if (pt.getX() >= minX && pt.getX() <= maxX && pt.getY() <= minY) {
+ return true;
+ }
+ return false;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/ColorSequence.java b/src/net/sourceforge/plantuml/svek/ColorSequence.java
new file mode 100644
index 0000000..73c4b89
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/ColorSequence.java
@@ -0,0 +1,47 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+public class ColorSequence {
+
+ private final AtomicInteger cpt = new AtomicInteger(1);
+
+ public int getValue() {
+ return cpt.addAndGet(1);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/ConditionStyle.java b/src/net/sourceforge/plantuml/svek/ConditionStyle.java
new file mode 100644
index 0000000..38e12aa
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/ConditionStyle.java
@@ -0,0 +1,53 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+import java.util.EnumSet;
+
+public enum ConditionStyle {
+
+ DIAMOND, INSIDE, FOO1;
+
+ public static ConditionStyle fromString(String value) {
+ for (ConditionStyle p : EnumSet.allOf(ConditionStyle.class)) {
+ if (p.toString().equalsIgnoreCase(value)) {
+ return p;
+ }
+ }
+ return null;
+ }
+
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/Control.java b/src/net/sourceforge/plantuml/svek/Control.java
new file mode 100644
index 0000000..77589f4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/Control.java
@@ -0,0 +1,92 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.SymbolContext;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class Control implements TextBlock {
+
+ private final double margin = 4;
+
+ private final double radius = 12;
+ private final SymbolContext symbolContext;
+
+ public Control(SymbolContext symbolContext) {
+ this.symbolContext = symbolContext;
+ }
+
+ public void drawU(UGraphic ug) {
+ double x = 0;
+ double y = 0;
+ x += margin;
+ y += margin;
+ ug = symbolContext.apply(ug);
+ final UEllipse circle = new UEllipse(radius * 2, radius * 2);
+ circle.setDeltaShadow(symbolContext.getDeltaShadow());
+ ug.apply(new UTranslate(x, y)).draw(circle);
+ ug = ug.apply(new UStroke());
+
+ ug = ug.apply(new UChangeBackColor(symbolContext.getForeColor()));
+ final UPolygon polygon = new UPolygon();
+ polygon.addPoint(0, 0);
+ final int xAile = 6;
+ final int yOuverture = 5;
+ polygon.addPoint(xAile, -yOuverture);
+ final int xContact = 4;
+ polygon.addPoint(xContact, 0);
+ polygon.addPoint(xAile, yOuverture);
+ polygon.addPoint(0, 0);
+
+ ug.apply(new UTranslate(x + radius - xContact, y)).draw(polygon);
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(radius * 2 + 2 * margin, radius * 2 + 2 * margin);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/CucaDiagramFileMaker.java b/src/net/sourceforge/plantuml/svek/CucaDiagramFileMaker.java
new file mode 100644
index 0000000..a25cfa4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/CucaDiagramFileMaker.java
@@ -0,0 +1,48 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.List;
+
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.core.ImageData;
+
+public interface CucaDiagramFileMaker {
+
+ public ImageData createFile(OutputStream os, List<String> dotStrings, FileFormatOption fileFormatOption)
+ throws IOException;
+}
diff --git a/src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek.java b/src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek.java
new file mode 100644
index 0000000..81fca4e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek.java
@@ -0,0 +1,238 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+import java.awt.Color;
+import java.awt.geom.Dimension2D;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.EmptyImageBuilder;
+import net.sourceforge.plantuml.FileFormat;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.Scale;
+import net.sourceforge.plantuml.UmlDiagramType;
+import net.sourceforge.plantuml.activitydiagram3.ftile.EntityImageLegend;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.cucadiagram.dot.CucaDiagramSimplifierActivity;
+import net.sourceforge.plantuml.cucadiagram.dot.CucaDiagramSimplifierState;
+import net.sourceforge.plantuml.cucadiagram.dot.DotData;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.StringBounderUtils;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.ugraphic.ImageBuilder;
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public final class CucaDiagramFileMakerSvek implements CucaDiagramFileMaker {
+
+ private final CucaDiagram diagram;
+
+ static private final StringBounder stringBounder;
+
+ static {
+ final EmptyImageBuilder builder = new EmptyImageBuilder(10, 10, Color.WHITE);
+ stringBounder = StringBounderUtils.asStringBounder(builder.getGraphics2D());
+ }
+
+ public CucaDiagramFileMakerSvek(CucaDiagram diagram) throws IOException {
+ this.diagram = diagram;
+ }
+
+ public ImageData createFile(OutputStream os, List<String> dotStrings, FileFormatOption fileFormatOption)
+ throws IOException {
+ try {
+ return createFileInternal(os, dotStrings, fileFormatOption);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ throw new IOException(e);
+ }
+ }
+
+ private CucaDiagramFileMakerSvek2 buildCucaDiagramFileMakerSvek2(DotMode dotMode) {
+ final DotData dotData = new DotData(diagram.getEntityFactory().getRootGroup(), getOrderedLinks(),
+ diagram.getLeafsvalues(), diagram.getUmlDiagramType(), diagram.getSkinParam(), diagram, diagram,
+ diagram.getColorMapper(), diagram.getEntityFactory(), diagram.isHideEmptyDescriptionForState(),
+ dotMode, diagram.getNamespaceSeparator(), diagram.getPragma());
+ final CucaDiagramFileMakerSvek2 svek2 = new CucaDiagramFileMakerSvek2(dotData, diagram.getEntityFactory(),
+ diagram.getSource(), diagram.getPragma());
+ return svek2;
+
+ }
+
+ private ImageData createFileInternal(OutputStream os, List<String> dotStrings, FileFormatOption fileFormatOption)
+ throws IOException, InterruptedException {
+ if (diagram.getUmlDiagramType() == UmlDiagramType.ACTIVITY) {
+ new CucaDiagramSimplifierActivity(diagram, dotStrings);
+ } else if (diagram.getUmlDiagramType() == UmlDiagramType.STATE) {
+ new CucaDiagramSimplifierState(diagram, dotStrings);
+ }
+
+ CucaDiagramFileMakerSvek2 svek2 = buildCucaDiagramFileMakerSvek2(DotMode.NORMAL);
+ TextBlockBackcolored result = svek2.createFile(diagram.getDotStringSkek());
+ if (result instanceof GraphvizCrash) {
+ svek2 = buildCucaDiagramFileMakerSvek2(DotMode.NO_LEFT_RIGHT);
+ result = svek2.createFile(diagram.getDotStringSkek());
+ }
+ result = addLegend(result);
+ result = addTitle(result);
+ result = addHeaderAndFooter(result);
+
+ final FileFormat fileFormat = fileFormatOption.getFileFormat();
+
+ final String widthwarning = diagram.getSkinParam().getValue("widthwarning");
+ if (widthwarning != null && widthwarning.matches("\\d+")) {
+ this.warningOrError = svek2.getBibliotekon().getWarningOrError(Integer.parseInt(widthwarning));
+ } else {
+ this.warningOrError = null;
+ }
+ final Dimension2D dim = result.calculateDimension(stringBounder);
+ final double scale = getScale(fileFormatOption, dim);
+
+ final ImageBuilder imageBuilder = new ImageBuilder(diagram.getSkinParam().getColorMapper(), scale,
+ result.getBackcolor(), fileFormatOption.isWithMetadata() ? diagram.getMetadata() : null,
+ warningOrError, 0, 10, diagram.getAnimation(), diagram.getSkinParam().handwritten());
+ imageBuilder.addUDrawable(result);
+ return imageBuilder.writeImageTOBEMOVED(fileFormat, os);
+
+ }
+
+ private List<Link> getOrderedLinks() {
+ final List<Link> result = new ArrayList<Link>();
+ for (Link l : diagram.getLinks()) {
+ addLinkNew(result, l);
+ }
+ return result;
+ }
+
+ private void addLinkNew(List<Link> result, Link link) {
+ for (int i = 0; i < result.size(); i++) {
+ final Link other = result.get(i);
+ if (other.sameConnections(link)) {
+ while (i < result.size() && result.get(i).sameConnections(link)) {
+ i++;
+ }
+ if (i == result.size()) {
+ result.add(link);
+ } else {
+ result.add(i, link);
+ }
+ return;
+ }
+ }
+ result.add(link);
+ }
+
+ private String warningOrError;
+
+ private String getWarningOrError() {
+ return warningOrError;
+ }
+
+ private TextBlockBackcolored addHeaderAndFooter(TextBlockBackcolored original) {
+ final Display footer = diagram.getFooter();
+ final Display header = diagram.getHeader();
+ if (footer == null && header == null) {
+ return original;
+ }
+ final TextBlock textFooter = footer == null ? null : TextBlockUtils.create(footer, new FontConfiguration(
+ getFont(FontParam.FOOTER), getFontColor(FontParam.FOOTER, null), diagram.getSkinParam()
+ .getHyperlinkColor(), diagram.getSkinParam().useUnderlineForHyperlink()), diagram
+ .getFooterAlignment(), diagram.getSkinParam());
+ final TextBlock textHeader = header == null ? null : TextBlockUtils.create(header, new FontConfiguration(
+ getFont(FontParam.HEADER), getFontColor(FontParam.HEADER, null), diagram.getSkinParam()
+ .getHyperlinkColor(), diagram.getSkinParam().useUnderlineForHyperlink()), diagram
+ .getHeaderAlignment(), diagram.getSkinParam());
+
+ return new DecorateEntityImage(original, textHeader, diagram.getHeaderAlignment(), textFooter,
+ diagram.getFooterAlignment());
+ }
+
+ private TextBlockBackcolored addTitle(TextBlockBackcolored original) {
+ final Display title = diagram.getTitle();
+ if (title == null) {
+ return original;
+ }
+ final TextBlock text = TextBlockUtils.create(title, new FontConfiguration(getFont(FontParam.TITLE),
+ getFontColor(FontParam.TITLE, null), diagram.getSkinParam().getHyperlinkColor(), diagram.getSkinParam()
+ .useUnderlineForHyperlink()), HorizontalAlignment.CENTER, diagram.getSkinParam());
+
+ return DecorateEntityImage.addTop(original, text, HorizontalAlignment.CENTER);
+ }
+
+ private TextBlockBackcolored addLegend(TextBlockBackcolored original) {
+ final Display legend = diagram.getLegend();
+ if (legend == null) {
+ return original;
+ }
+ final TextBlock text = EntityImageLegend.create(legend, diagram.getSkinParam());
+
+ return DecorateEntityImage.add(original, text, diagram.getLegendAlignment(),
+ diagram.getLegendVerticalAlignment());
+ }
+
+ private final UFont getFont(FontParam fontParam) {
+ final ISkinParam skinParam = diagram.getSkinParam();
+ return skinParam.getFont(fontParam, null, false);
+ }
+
+ private final HtmlColor getFontColor(FontParam fontParam, Stereotype stereo) {
+ final ISkinParam skinParam = diagram.getSkinParam();
+ return skinParam.getFontHtmlColor(fontParam, stereo);
+ }
+
+ private double getScale(FileFormatOption fileFormatOption, final Dimension2D dim) {
+ final double scale;
+ final Scale diagScale = diagram.getScale();
+ if (diagScale == null) {
+ scale = diagram.getDpiFactor(fileFormatOption);
+ } else {
+ scale = diagScale.getScale(dim.getWidth(), dim.getHeight());
+ }
+ return scale;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek2.java b/src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek2.java
new file mode 100644
index 0000000..58083da
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek2.java
@@ -0,0 +1,579 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+import java.awt.Color;
+import java.awt.geom.Dimension2D;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.EmptyImageBuilder;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.Log;
+import net.sourceforge.plantuml.OptionFlags;
+import net.sourceforge.plantuml.Pragma;
+import net.sourceforge.plantuml.SkinParamForecolored;
+import net.sourceforge.plantuml.SkinParamSameClassWidth;
+import net.sourceforge.plantuml.UmlDiagramType;
+import net.sourceforge.plantuml.core.UmlSource;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.EntityPortion;
+import net.sourceforge.plantuml.cucadiagram.EntityPosition;
+import net.sourceforge.plantuml.cucadiagram.GroupType;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.IGroup;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.cucadiagram.Member;
+import net.sourceforge.plantuml.cucadiagram.MethodsOrFieldsArea;
+import net.sourceforge.plantuml.cucadiagram.PortionShower;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.cucadiagram.UnparsableGraphvizException;
+import net.sourceforge.plantuml.cucadiagram.dot.DotData;
+import net.sourceforge.plantuml.cucadiagram.dot.GraphvizVersion;
+import net.sourceforge.plantuml.cucadiagram.dot.Neighborhood;
+import net.sourceforge.plantuml.cucadiagram.entity.EntityFactory;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.GraphicStrings;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.StringBounderUtils;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockEmpty;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.graphic.TextBlockWidth;
+import net.sourceforge.plantuml.graphic.USymbol;
+import net.sourceforge.plantuml.graphic.USymbolInterface;
+import net.sourceforge.plantuml.svek.image.EntityImageActivity;
+import net.sourceforge.plantuml.svek.image.EntityImageArcCircle;
+import net.sourceforge.plantuml.svek.image.EntityImageAssociation;
+import net.sourceforge.plantuml.svek.image.EntityImageAssociationPoint;
+import net.sourceforge.plantuml.svek.image.EntityImageBranch;
+import net.sourceforge.plantuml.svek.image.EntityImageCircleEnd;
+import net.sourceforge.plantuml.svek.image.EntityImageCircleStart;
+import net.sourceforge.plantuml.svek.image.EntityImageClass;
+import net.sourceforge.plantuml.svek.image.EntityImageComponent;
+import net.sourceforge.plantuml.svek.image.EntityImageEmptyPackage2;
+import net.sourceforge.plantuml.svek.image.EntityImageGroup;
+import net.sourceforge.plantuml.svek.image.EntityImageLollipopInterface;
+import net.sourceforge.plantuml.svek.image.EntityImageLollipopInterfaceEye1;
+import net.sourceforge.plantuml.svek.image.EntityImageLollipopInterfaceEye2;
+import net.sourceforge.plantuml.svek.image.EntityImageNote;
+import net.sourceforge.plantuml.svek.image.EntityImageObject;
+import net.sourceforge.plantuml.svek.image.EntityImagePseudoState;
+import net.sourceforge.plantuml.svek.image.EntityImageState;
+import net.sourceforge.plantuml.svek.image.EntityImageState2;
+import net.sourceforge.plantuml.svek.image.EntityImageStateBorder;
+import net.sourceforge.plantuml.svek.image.EntityImageStateEmptyDescription;
+import net.sourceforge.plantuml.svek.image.EntityImageSynchroBar;
+import net.sourceforge.plantuml.svek.image.EntityImageUseCase;
+
+public final class CucaDiagramFileMakerSvek2 {
+
+ private final ColorSequence colorSequence = new ColorSequence();
+
+ private final DotData dotData;
+ private final EntityFactory entityFactory;
+ private final UmlSource source;
+ private final Pragma pragma;
+
+ static private final StringBounder stringBounder;
+
+ static {
+ final EmptyImageBuilder builder = new EmptyImageBuilder(10, 10, Color.WHITE);
+ stringBounder = StringBounderUtils.asStringBounder(builder.getGraphics2D());
+ }
+
+ public CucaDiagramFileMakerSvek2(DotData dotData, EntityFactory entityFactory, UmlSource source, Pragma pragma) {
+ this.dotData = dotData;
+ this.entityFactory = entityFactory;
+ this.source = source;
+ this.pragma = pragma;
+ }
+
+ private DotStringFactory dotStringFactory;
+
+ public Bibliotekon getBibliotekon() {
+ return dotStringFactory.getBibliotekon();
+ }
+
+ public IEntityImage createFileForConcurrentState() {
+ return new CucaDiagramFileMakerSvek2InternalImage(dotData.getLeafs(), dotData.getTopParent()
+ .getConcurrentSeparator(), dotData.getSkinParam(), dotData.getSkinParam().getBackgroundColor());
+
+ }
+
+ public IEntityImage createFile(String... dotStrings) {
+
+ dotData.removeIrrelevantSametail();
+ dotStringFactory = new DotStringFactory(colorSequence, stringBounder, dotData);
+
+ printGroups(dotData.getRootGroup());
+ printEntities(getUnpackagedEntities());
+
+
+ for (Link link : dotData.getLinks()) {
+ if (link.isRemoved()) {
+ continue;
+ }
+ try {
+ final String shapeUid1 = getBibliotekon().getShapeUid((ILeaf) link.getEntity1());
+ final String shapeUid2 = getBibliotekon().getShapeUid((ILeaf) link.getEntity2());
+
+ String ltail = null;
+ if (shapeUid1.startsWith(Cluster.CENTER_ID)) {
+ // final Group g1 = ((IEntityMutable)
+ // link.getEntity1()).getContainerOrEquivalent();
+ ltail = getCluster2((IEntity) link.getEntity1()).getClusterId();
+ }
+ String lhead = null;
+ if (shapeUid2.startsWith(Cluster.CENTER_ID)) {
+ // final Group g2 = ((IEntityMutable)
+ // link.getEntity2()).getContainerOrEquivalent();
+ lhead = getCluster2((IEntity) link.getEntity2()).getClusterId();
+ }
+ final ISkinParam skinParam = dotData.getSkinParam();
+ final FontConfiguration labelFont = new FontConfiguration(skinParam.getFont(FontParam.GENERIC_ARROW,
+ null, false), skinParam.getFontHtmlColor(FontParam.GENERIC_ARROW, null),
+ skinParam.getHyperlinkColor(), skinParam.useUnderlineForHyperlink());
+
+ final Line line = new Line(shapeUid1, shapeUid2, link, colorSequence, ltail, lhead, skinParam,
+ stringBounder, labelFont, getBibliotekon(), dotStringFactory.getGraphvizVersion(),
+ dotData.getPragma());
+
+ getBibliotekon().addLine(line);
+
+ if (link.getEntity1().isGroup() == false && link.getEntity1().getEntityType() == LeafType.NOTE
+ && onlyOneLink(link.getEntity1())) {
+ final Shape shape = getBibliotekon().getShape(link.getEntity1());
+ ((EntityImageNote) shape.getImage()).setOpaleLine(line, shape);
+ line.setOpale(true);
+ } else if (link.getEntity2().isGroup() == false && link.getEntity2().getEntityType() == LeafType.NOTE
+ && onlyOneLink(link.getEntity2())) {
+ final Shape shape = getBibliotekon().getShape(link.getEntity2());
+ ((EntityImageNote) shape.getImage()).setOpaleLine(line, shape);
+ line.setOpale(true);
+ }
+ } catch (IllegalStateException e) {
+ e.printStackTrace();
+ }
+ }
+
+ if (dotStringFactory.illegalDotExe()) {
+ return error(dotStringFactory.getDotExe());
+ }
+
+ final boolean trace = OptionFlags.getInstance().isKeepTmpFiles() || OptionFlags.TRACE_DOT || isSvekTrace();
+ final String svg;
+ try {
+ svg = dotStringFactory.getSvg(trace, dotStrings);
+ } catch (IOException e) {
+ return new GraphvizCrash(source.getPlainString());
+ }
+ if (svg.length() == 0) {
+ return new GraphvizCrash(source.getPlainString());
+ }
+ final String graphvizVersion = extractGraphvizVersion(svg);
+ try {
+ final ClusterPosition position = dotStringFactory.solve(svg).delta(10, 10);
+ final double minY = position.getMinY();
+ final double minX = position.getMinX();
+ if (minX > 0 || minY > 0) {
+ throw new IllegalStateException();
+ }
+ final SvekResult result = new SvekResult(position, dotData, dotStringFactory);
+ result.moveSvek(6 - minX, -minY);
+ return result;
+ } catch (Exception e) {
+ Log.error("Exception " + e);
+ throw new UnparsableGraphvizException(e, graphvizVersion, svg, source.getPlainString());
+ }
+
+ }
+
+ private boolean isSvekTrace() {
+ final String value = pragma.getValue("svek_trace");
+ return "true".equalsIgnoreCase(value) || "on".equalsIgnoreCase(value);
+ }
+
+ private String extractGraphvizVersion(String svg) {
+ final Pattern pGraph = Pattern.compile("(?mi)!-- generated by graphviz(.*)");
+ final Matcher mGraph = pGraph.matcher(svg);
+ if (mGraph.find()) {
+ return mGraph.group(1).trim();
+ }
+ return null;
+ }
+
+ private boolean onlyOneLink(IEntity ent) {
+ int nb = 0;
+ for (Link link : dotData.getLinks()) {
+ if (link.isInvis()) {
+ continue;
+ }
+ if (link.contains(ent)) {
+ nb++;
+ }
+ if (nb > 1) {
+ return false;
+ }
+ }
+ return nb == 1;
+ }
+
+ // private Cluster getCluster(IEntity g) {
+ // for (Cluster cl : getBibliotekon().allCluster()) {
+ // if (cl.getGroup() == g) {
+ // return cl;
+ // }
+ // }
+ // throw new IllegalArgumentException(g.toString());
+ // }
+
+ private Cluster getCluster2(IEntity entityMutable) {
+ for (Cluster cl : getBibliotekon().allCluster()) {
+ if (entityMutable == cl.getGroup()) {
+ return cl;
+ }
+ }
+ throw new IllegalArgumentException();
+ }
+
+ private IEntityImage error(File dotExe) {
+
+ final List<String> msg = new ArrayList<String>();
+ msg.add("Dot Executable: " + dotExe);
+ if (dotExe != null) {
+ if (dotExe.exists() == false) {
+ msg.add("File does not exist");
+ } else if (dotExe.isDirectory()) {
+ msg.add("It should be an executable, not a directory");
+ } else if (dotExe.isFile() == false) {
+ msg.add("Not a valid file");
+ } else if (dotExe.canRead() == false) {
+ msg.add("File cannot be read");
+ }
+ }
+ msg.add("Cannot find Graphviz. You should try");
+ msg.add(" ");
+ msg.add("@startuml");
+ msg.add("testdot");
+ msg.add("@enduml");
+ msg.add(" ");
+ msg.add(" or ");
+ msg.add(" ");
+ msg.add("java -jar plantuml.jar -testdot");
+ msg.add(" ");
+ return GraphicStrings.createDefault(msg, false);
+ }
+
+ private void printEntities(Collection<ILeaf> entities2) {
+ for (ILeaf ent : entities2) {
+ if (ent.isRemoved()) {
+ continue;
+ }
+ printEntity(ent);
+ }
+ }
+
+ private void printEntity(ILeaf ent) {
+ if (ent.isRemoved()) {
+ throw new IllegalStateException();
+ }
+ final IEntityImage image = printEntityInternal(ent);
+ final Dimension2D dim = image.calculateDimension(stringBounder);
+ final Shape shape = new Shape(image, image.getShapeType(), dim.getWidth(), dim.getHeight(), colorSequence,
+ ent.isTop(), image.getShield(), ent.getEntityPosition());
+ dotStringFactory.addShape(shape);
+ getBibliotekon().putShape(ent, shape);
+ }
+
+ private IEntityImage printEntityInternal(ILeaf ent) {
+ if (ent.isRemoved()) {
+ throw new IllegalStateException();
+ }
+ if (ent.getSvekImage() == null) {
+ ISkinParam skinParam = dotData.getSkinParam();
+ if (dotData.getSkinParam().sameClassWidth()) {
+ final double width = getMaxWidth();
+ skinParam = new SkinParamSameClassWidth(dotData.getSkinParam(), width);
+ }
+
+ return createEntityImageBlock(ent, skinParam, dotData.isHideEmptyDescriptionForState(), dotData,
+ getBibliotekon(), dotStringFactory.getGraphvizVersion(), dotData.getUmlDiagramType());
+ }
+ return ent.getSvekImage();
+ }
+
+ private double getMaxWidth() {
+ double result = 0;
+ for (ILeaf ent : dotData.getLeafs()) {
+ if (ent.getEntityType().isLikeClass() == false) {
+ continue;
+ }
+ final IEntityImage im = new EntityImageClass(dotStringFactory.getGraphvizVersion(), ent,
+ dotData.getSkinParam(), dotData);
+ final double w = im.calculateDimension(stringBounder).getWidth();
+ if (w > result) {
+ result = w;
+ }
+ }
+ return result;
+ }
+
+ public static IEntityImage createEntityImageBlock(ILeaf leaf, ISkinParam skinParam,
+ boolean isHideEmptyDescriptionForState, PortionShower portionShower, Bibliotekon bibliotekon,
+ GraphvizVersion graphvizVersion, UmlDiagramType umlDiagramType) {
+ if (leaf.isRemoved()) {
+ throw new IllegalStateException();
+ }
+ if (leaf.getEntityType().isLikeClass()) {
+ final EntityImageClass entityImageClass = new EntityImageClass(graphvizVersion, (ILeaf) leaf, skinParam,
+ portionShower);
+ final Neighborhood neighborhood = leaf.getNeighborhood();
+ if (neighborhood != null) {
+ return new EntityImageProtected(entityImageClass, 20, neighborhood, bibliotekon);
+ }
+ return entityImageClass;
+ }
+ if (leaf.getEntityType() == LeafType.NOTE) {
+ return new EntityImageNote(leaf, skinParam);
+ }
+ if (leaf.getEntityType() == LeafType.ACTIVITY) {
+ return new EntityImageActivity(leaf, skinParam, bibliotekon);
+ }
+ if (leaf.getEntityType() == LeafType.STATE) {
+ if (leaf.getEntityPosition() != EntityPosition.NORMAL) {
+ final Cluster stateParent = bibliotekon.getCluster(leaf.getParentContainer());
+ return new EntityImageStateBorder(leaf, skinParam, stateParent, bibliotekon);
+ }
+ if (isHideEmptyDescriptionForState && leaf.getFieldsToDisplay().size() == 0) {
+ return new EntityImageStateEmptyDescription(leaf, skinParam);
+ }
+ if (leaf.getStereotype() != null && "<<sdlreceive>>".equals(leaf.getStereotype().getLabel(false))) {
+ return new EntityImageState2(leaf, skinParam);
+ }
+ return new EntityImageState(leaf, skinParam);
+
+ }
+ if (leaf.getEntityType() == LeafType.CIRCLE_START) {
+ ColorParam param = ColorParam.activityStart;
+ if (umlDiagramType == UmlDiagramType.STATE) {
+ param = ColorParam.stateStart;
+ }
+ return new EntityImageCircleStart(leaf, skinParam, param);
+ }
+ if (leaf.getEntityType() == LeafType.CIRCLE_END) {
+ ColorParam param = ColorParam.activityEnd;
+ if (umlDiagramType == UmlDiagramType.STATE) {
+ param = ColorParam.stateEnd;
+ }
+ return new EntityImageCircleEnd(leaf, skinParam, param);
+ }
+ if (leaf.getEntityType() == LeafType.BRANCH || leaf.getEntityType() == LeafType.STATE_CHOICE) {
+ return new EntityImageBranch(leaf, skinParam);
+ }
+ if (leaf.getEntityType() == LeafType.LOLLIPOP) {
+ return new EntityImageLollipopInterface(leaf, skinParam);
+ }
+ if (leaf.getEntityType() == LeafType.DESCRIPTION) {
+ if (OptionFlags.USE_INTERFACE_EYE1 && leaf.getUSymbol() instanceof USymbolInterface) {
+ return new EntityImageLollipopInterfaceEye1(leaf, skinParam, bibliotekon);
+ } else if (OptionFlags.USE_INTERFACE_EYE2 && leaf.getUSymbol() instanceof USymbolInterface) {
+ return new EntityImageLollipopInterfaceEye2(leaf, skinParam, portionShower);
+ } else {
+ return new EntityImageComponent(leaf, skinParam, portionShower);
+ }
+ }
+ if (leaf.getEntityType() == LeafType.USECASE) {
+ return new EntityImageUseCase(leaf, skinParam);
+ }
+ // if (leaf.getEntityType() == LeafType.CIRCLE_INTERFACE) {
+ // return new EntityImageCircleInterface(leaf, skinParam);
+ // }
+ if (leaf.getEntityType() == LeafType.OBJECT) {
+ return new EntityImageObject(leaf, skinParam);
+ }
+ if (leaf.getEntityType() == LeafType.SYNCHRO_BAR || leaf.getEntityType() == LeafType.STATE_FORK_JOIN) {
+ return new EntityImageSynchroBar(leaf, skinParam);
+ }
+ if (leaf.getEntityType() == LeafType.ARC_CIRCLE) {
+ return new EntityImageArcCircle(leaf, skinParam);
+ }
+ if (leaf.getEntityType() == LeafType.POINT_FOR_ASSOCIATION) {
+ return new EntityImageAssociationPoint(leaf, skinParam);
+ }
+ if (leaf.isGroup()) {
+ return new EntityImageGroup(leaf, skinParam);
+ }
+ if (leaf.getEntityType() == LeafType.EMPTY_PACKAGE) {
+ if (leaf.getUSymbol() != null) {
+ return new EntityImageComponent(leaf, new SkinParamForecolored(skinParam, HtmlColorUtils.BLACK),
+ portionShower);
+ }
+ return new EntityImageEmptyPackage2(leaf, skinParam);
+ }
+ if (leaf.getEntityType() == LeafType.ASSOCIATION) {
+ return new EntityImageAssociation(leaf, skinParam);
+ }
+ if (leaf.getEntityType() == LeafType.PSEUDO_STATE) {
+ return new EntityImagePseudoState(leaf, skinParam);
+ }
+ throw new UnsupportedOperationException(leaf.getEntityType().toString());
+ }
+
+ private Collection<ILeaf> getUnpackagedEntities() {
+ final List<ILeaf> result = new ArrayList<ILeaf>();
+ for (ILeaf ent : dotData.getLeafs()) {
+ if (dotData.getTopParent() == ent.getParentContainer()) {
+ result.add(ent);
+ }
+ }
+ return result;
+ }
+
+ private void printGroups(IGroup parent) {
+ for (IGroup g : dotData.getGroupHierarchy().getChildrenGroups(parent)) {
+ if (g.isRemoved()) {
+ continue;
+ }
+ if (dotData.isEmpty(g) && g.getGroupType() == GroupType.PACKAGE) {
+ final ILeaf folder = entityFactory.createLeaf(g.getCode(), g.getDisplay(), LeafType.EMPTY_PACKAGE,
+ g.getParentContainer(), null, dotData.getNamespaceSeparator());
+ final USymbol symbol = g.getUSymbol();
+ folder.setUSymbol(symbol);
+ if (g.getSpecificBackColor() == null) {
+ final ColorParam param = symbol == null ? ColorParam.packageBackground : symbol.getColorParamBack();
+ final HtmlColor c1 = dotData.getSkinParam().getHtmlColor(param, g.getStereotype(), false);
+ folder.setSpecificBackcolor(c1 == null ? dotData.getSkinParam().getBackgroundColor() : c1);
+ } else {
+ folder.setSpecificBackcolor(g.getSpecificBackColor());
+ }
+ printEntity(folder);
+ } else {
+ printGroup(g);
+ }
+ }
+ }
+
+ private void printGroup(IGroup g) {
+ if (g.getGroupType() == GroupType.CONCURRENT_STATE) {
+ return;
+ }
+ int titleAndAttributeWidth = 0;
+ int titleAndAttributeHeight = 0;
+
+ final TextBlock title = getTitleBlock(g);
+ final TextBlock stereo = getStereoBlock(g);
+ final TextBlock stereoAndTitle = TextBlockUtils.mergeTB(stereo, title, HorizontalAlignment.CENTER);
+ final Dimension2D dimLabel = stereoAndTitle.calculateDimension(stringBounder);
+ if (dimLabel.getWidth() > 0) {
+ final List<Member> members = ((IEntity) g).getFieldsToDisplay();
+ final TextBlockWidth attribute;
+ if (members.size() == 0) {
+ attribute = new TextBlockEmpty();
+ } else {
+ attribute = new MethodsOrFieldsArea(members, FontParam.STATE_ATTRIBUTE, dotData.getSkinParam());
+ }
+ final Dimension2D dimAttribute = attribute.calculateDimension(stringBounder);
+ final double attributeHeight = dimAttribute.getHeight();
+ final double attributeWidth = dimAttribute.getWidth();
+ final double marginForFields = attributeHeight > 0 ? IEntityImage.MARGIN : 0;
+ final USymbol uSymbol = g.getUSymbol();
+ final int suppHeightBecauseOfShape = uSymbol == null ? 0 : uSymbol.suppHeightBecauseOfShape();
+ final int suppWidthBecauseOfShape = uSymbol == null ? 0 : uSymbol.suppWidthBecauseOfShape();
+
+ titleAndAttributeWidth = (int) Math.max(dimLabel.getWidth(), attributeWidth) + suppWidthBecauseOfShape;
+ titleAndAttributeHeight = (int) (dimLabel.getHeight() + attributeHeight + marginForFields + suppHeightBecauseOfShape);
+ }
+
+ dotStringFactory.openCluster(g, titleAndAttributeWidth, titleAndAttributeHeight, title, stereo);
+ this.printEntities(g.getLeafsDirect());
+
+ printGroups(g);
+
+ dotStringFactory.closeCluster();
+ }
+
+ private TextBlock getTitleBlock(IGroup g) {
+ final Display label = g.getDisplay();
+ final Stereotype stereotype2 = g.getStereotype();
+
+ if (label == null) {
+ return TextBlockUtils.empty(0, 0);
+ }
+
+ final FontParam fontParam = g.getTitleFontParam();
+ return TextBlockUtils.create(label,
+ new FontConfiguration(dotData.getSkinParam().getFont(fontParam, stereotype2, true), dotData
+ .getSkinParam().getFontHtmlColor(fontParam, stereotype2), dotData.getSkinParam()
+ .getHyperlinkColor(), dotData.getSkinParam().useUnderlineForHyperlink()),
+ HorizontalAlignment.CENTER, dotData.getSkinParam());
+ }
+
+ private TextBlock getStereoBlock(IGroup g) {
+ if (g.getStereotype() == null) {
+ return TextBlockUtils.empty(0, 0);
+ }
+ final List<String> stereos = g.getStereotype().getLabels(dotData.getSkinParam().useGuillemet());
+ if (stereos == null) {
+ return TextBlockUtils.empty(0, 0);
+ }
+ final boolean show = dotData.showPortion(EntityPortion.STEREOTYPE, g);
+ if (show == false) {
+ return TextBlockUtils.empty(0, 0);
+ }
+
+ final Stereotype stereotype2 = g.getStereotype();
+
+ final FontParam fontParam = FontParam.COMPONENT_STEREOTYPE;
+ return TextBlockUtils.create(Display.create(stereos),
+ new FontConfiguration(dotData.getSkinParam().getFont(fontParam, stereotype2, false), dotData
+ .getSkinParam().getFontHtmlColor(fontParam, stereotype2), dotData.getSkinParam()
+ .getHyperlinkColor(), dotData.getSkinParam().useUnderlineForHyperlink()),
+ HorizontalAlignment.CENTER, dotData.getSkinParam());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek2InternalImage.java b/src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek2InternalImage.java
new file mode 100644
index 0000000..d7d4ee3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek2InternalImage.java
@@ -0,0 +1,160 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+import java.awt.geom.Dimension2D;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.rose.Rose;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public final class CucaDiagramFileMakerSvek2InternalImage implements IEntityImage {
+
+ private final List<IEntityImage> inners = new ArrayList<IEntityImage>();
+ private final Separator separator;
+ private final ISkinParam skinParam;
+ private final HtmlColor backColor;
+
+ static enum Separator {
+ VERTICAL, HORIZONTAL;
+
+ static Separator fromChar(char sep) {
+ if (sep == '|') {
+ return VERTICAL;
+ }
+ if (sep == '-') {
+ return HORIZONTAL;
+ }
+ throw new IllegalArgumentException();
+ }
+
+ UTranslate move(Dimension2D dim) {
+ if (this == VERTICAL) {
+ return new UTranslate(dim.getWidth(), 0);
+ }
+ return new UTranslate(0, dim.getHeight());
+ }
+
+ Dimension2D add(Dimension2D orig, Dimension2D other) {
+ if (this == VERTICAL) {
+ return new Dimension2DDouble(orig.getWidth() + other.getWidth(), Math.max(orig.getHeight(),
+ other.getHeight()));
+ }
+ return new Dimension2DDouble(Math.max(orig.getWidth(), other.getWidth()), orig.getHeight()
+ + other.getHeight());
+ }
+
+ void drawSeparator(UGraphic ug, Dimension2D dimTotal) {
+ final double THICKNESS_BORDER = 1.5;
+ final int DASH = 8;
+ ug = ug.apply(new UStroke(DASH, 10, THICKNESS_BORDER));
+ if (this == VERTICAL) {
+ ug.draw(new ULine(0, dimTotal.getHeight() + DASH));
+ } else {
+ ug.draw(new ULine(dimTotal.getWidth() + DASH, 0));
+ }
+
+ }
+ }
+
+ private HtmlColor getColor(ColorParam colorParam) {
+ return new Rose().getHtmlColor(skinParam, colorParam);
+ }
+
+ public CucaDiagramFileMakerSvek2InternalImage(Collection<ILeaf> leafs, char concurrentSeparator,
+ ISkinParam skinParam, HtmlColor backColor) {
+ this.separator = Separator.fromChar(concurrentSeparator);
+ this.skinParam = skinParam;
+ this.backColor = backColor;
+ for (ILeaf inner : leafs) {
+ inners.add(inner.getSvekImage());
+ }
+ }
+
+ public void drawU(UGraphic ug) {
+ final HtmlColor dotColor = getColor(ColorParam.stateBorder);
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D dimTotal = calculateDimension(stringBounder);
+
+ for (int i = 0; i < inners.size(); i++) {
+ final IEntityImage inner = inners.get(i);
+ inner.drawU(ug);
+ final Dimension2D dim = inner.calculateDimension(stringBounder);
+ ug = ug.apply(separator.move(dim));
+ if (i < inners.size() - 1) {
+ separator.drawSeparator(ug.apply(new UChangeColor(dotColor)), dimTotal);
+ }
+ }
+
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ Dimension2D result = new Dimension2DDouble(0, 0);
+ for (IEntityImage inner : inners) {
+ final Dimension2D dim = inner.calculateDimension(stringBounder);
+ result = separator.add(result, dim);
+ }
+ return result;
+ }
+
+ public HtmlColor getBackcolor() {
+ return backColor;
+ }
+
+ public boolean isHidden() {
+ return false;
+ }
+
+ public int getShield() {
+ return 0;
+ }
+
+ public ShapeType getShapeType() {
+ return ShapeType.RECTANGLE;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/svek/DecorateEntityImage.java b/src/net/sourceforge/plantuml/svek/DecorateEntityImage.java
new file mode 100644
index 0000000..6bf5c2c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/DecorateEntityImage.java
@@ -0,0 +1,156 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.VerticalAlignment;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class DecorateEntityImage implements TextBlockBackcolored {
+
+ private final TextBlock original;
+ private final HorizontalAlignment horizontal1;
+ private final TextBlock text1;
+ private final HorizontalAlignment horizontal2;
+ private final TextBlock text2;
+
+ private double deltaX;
+ private double deltaY;
+
+ public static DecorateEntityImage addTop(TextBlock original, TextBlock text, HorizontalAlignment horizontal) {
+ return new DecorateEntityImage(original, text, horizontal, null, null);
+ }
+
+ public static DecorateEntityImage addBottom(TextBlock original, TextBlock text, HorizontalAlignment horizontal) {
+ return new DecorateEntityImage(original, null, null, text, horizontal);
+ }
+
+ public static DecorateEntityImage add(TextBlock original, TextBlock text, HorizontalAlignment horizontal,
+ VerticalAlignment verticalAlignment) {
+ if (verticalAlignment == VerticalAlignment.TOP) {
+ return addTop(original, text, horizontal);
+ }
+ return addBottom(original, text, horizontal);
+ }
+
+ public DecorateEntityImage(TextBlock original, TextBlock text1, HorizontalAlignment horizontal1, TextBlock text2,
+ HorizontalAlignment horizontal2) {
+ this.original = original;
+ this.horizontal1 = horizontal1;
+ this.text1 = text1;
+ this.horizontal2 = horizontal2;
+ this.text2 = text2;
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D dimOriginal = original.calculateDimension(stringBounder);
+ final Dimension2D dimText1 = getTextDim(text1, stringBounder);
+ final Dimension2D dimText2 = getTextDim(text2, stringBounder);
+ final Dimension2D dimTotal = calculateDimension(stringBounder);
+
+ final double yImage = dimText1.getHeight();
+ final double yText2 = yImage + dimOriginal.getHeight();
+
+ final double xImage = (dimTotal.getWidth() - dimOriginal.getWidth()) / 2;
+
+ if (text1 != null) {
+ final double xText1 = getTextX(dimText1, dimTotal, horizontal1);
+ text1.drawU(ug.apply(new UTranslate(xText1, 0)));
+ }
+ original.drawU(ug.apply(new UTranslate(xImage, yImage)));
+ deltaX = xImage;
+ deltaY = yImage;
+ if (text2 != null) {
+ final double xText2 = getTextX(dimText2, dimTotal, horizontal2);
+ text2.drawU(ug.apply(new UTranslate(xText2, yText2)));
+ }
+ }
+
+ private Dimension2D getTextDim(TextBlock text, StringBounder stringBounder) {
+ if (text == null) {
+ return new Dimension2DDouble(0, 0);
+ }
+ return text.calculateDimension(stringBounder);
+ }
+
+ private double getTextX(final Dimension2D dimText, final Dimension2D dimTotal, HorizontalAlignment h) {
+ if (h == HorizontalAlignment.CENTER) {
+ return (dimTotal.getWidth() - dimText.getWidth()) / 2;
+ } else if (h == HorizontalAlignment.LEFT) {
+ return 0;
+ } else if (h == HorizontalAlignment.RIGHT) {
+ return dimTotal.getWidth() - dimText.getWidth();
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public HtmlColor getBackcolor() {
+ if (original instanceof TextBlockBackcolored) {
+ return ((TextBlockBackcolored) original).getBackcolor();
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dimOriginal = original.calculateDimension(stringBounder);
+ final Dimension2D dimText = Dimension2DDouble.mergeTB(getTextDim(text1, stringBounder),
+ getTextDim(text2, stringBounder));
+ return Dimension2DDouble.mergeTB(dimOriginal, dimText);
+ }
+
+ public final double getDeltaX() {
+ if (original instanceof DecorateEntityImage) {
+ return deltaX + ((DecorateEntityImage) original).deltaX;
+ }
+ return deltaX;
+ }
+
+ public final double getDeltaY() {
+ if (original instanceof DecorateEntityImage) {
+ return deltaY + ((DecorateEntityImage) original).deltaY;
+ }
+ return deltaY;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/DecorateEntityImage3.java b/src/net/sourceforge/plantuml/svek/DecorateEntityImage3.java
new file mode 100644
index 0000000..fd7870e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/DecorateEntityImage3.java
@@ -0,0 +1,66 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class DecorateEntityImage3 implements TextBlockBackcolored {
+
+ private final TextBlock original;
+ private final HtmlColor color;
+
+ public DecorateEntityImage3(TextBlock original, HtmlColor color) {
+ this.original = original;
+ this.color = color;
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return original.calculateDimension(stringBounder);
+ }
+
+ public void drawU(UGraphic ug) {
+ original.drawU(ug);
+ }
+
+ public HtmlColor getBackcolor() {
+ return color;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/DecorateTextBlock.java b/src/net/sourceforge/plantuml/svek/DecorateTextBlock.java
new file mode 100644
index 0000000..fa4a722
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/DecorateTextBlock.java
@@ -0,0 +1,136 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class DecorateTextBlock implements TextBlock {
+
+ private final TextBlock original;
+ private final HorizontalAlignment horizontal1;
+ private final TextBlock text1;
+ private final HorizontalAlignment horizontal2;
+ private final TextBlock text2;
+
+ private double deltaX;
+ private double deltaY;
+
+ public DecorateTextBlock(TextBlock original, TextBlock text, HorizontalAlignment horizontal) {
+ this(original, text, horizontal, null, null);
+ }
+
+ public DecorateTextBlock(TextBlock original, TextBlock text1, HorizontalAlignment horizontal1, TextBlock text2,
+ HorizontalAlignment horizontal2) {
+ this.original = original;
+ this.horizontal1 = horizontal1;
+ this.text1 = text1;
+ this.horizontal2 = horizontal2;
+ this.text2 = text2;
+ }
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D dimOriginal = original.calculateDimension(stringBounder);
+ final Dimension2D dimText1 = getTextDim(text1, stringBounder);
+ final Dimension2D dimText2 = getTextDim(text2, stringBounder);
+ final Dimension2D dimTotal = calculateDimension(stringBounder);
+
+ final double yText1 = 0;
+ final double yImage = yText1 + dimText1.getHeight();
+ final double yText2 = yImage + dimOriginal.getHeight();
+
+ final double xImage = (dimTotal.getWidth() - dimOriginal.getWidth()) / 2;
+
+ if (text1 != null) {
+ final double xText1 = getTextX(dimText1, dimTotal, horizontal1);
+ text1.drawU(ug.apply(new UTranslate(xText1, yText1)));
+ }
+ original.drawU(ug.apply(new UTranslate(xImage, yImage)));
+ deltaX = xImage;
+ deltaY = yImage;
+ if (text2 != null) {
+ final double xText2 = getTextX(dimText2, dimTotal, horizontal2);
+ text2.drawU(ug.apply(new UTranslate(xText2, yText2)));
+ }
+ }
+
+ private Dimension2D getTextDim(TextBlock text, StringBounder stringBounder) {
+ if (text == null) {
+ return new Dimension2DDouble(0, 0);
+ }
+ return text.calculateDimension(stringBounder);
+ }
+
+ private double getTextX(final Dimension2D dimText, final Dimension2D dimTotal, HorizontalAlignment h) {
+ if (h == HorizontalAlignment.CENTER) {
+ return (dimTotal.getWidth() - dimText.getWidth()) / 2;
+ } else if (h == HorizontalAlignment.LEFT) {
+ return 0;
+ } else if (h == HorizontalAlignment.RIGHT) {
+ return dimTotal.getWidth() - dimText.getWidth();
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dimOriginal = original.calculateDimension(stringBounder);
+ final Dimension2D dimText = Dimension2DDouble.mergeTB(getTextDim(text1, stringBounder),
+ getTextDim(text2, stringBounder));
+ return Dimension2DDouble.mergeTB(dimOriginal, dimText);
+ }
+
+ private double getDeltaX() {
+ if (original instanceof DecorateTextBlock) {
+ return deltaX + ((DecorateTextBlock) original).deltaX;
+ }
+ return deltaX;
+ }
+
+ private double getDeltaY() {
+ if (original instanceof DecorateTextBlock) {
+ return deltaY + ((DecorateTextBlock) original).deltaY;
+ }
+ return deltaY;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/DotMode.java b/src/net/sourceforge/plantuml/svek/DotMode.java
new file mode 100644
index 0000000..988c79d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/DotMode.java
@@ -0,0 +1,40 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+public enum DotMode {
+ NORMAL, NO_LEFT_RIGHT
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/DotStringFactory.java b/src/net/sourceforge/plantuml/svek/DotStringFactory.java
new file mode 100644
index 0000000..4dc92d9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/DotStringFactory.java
@@ -0,0 +1,423 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+import java.awt.geom.Point2D;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.Log;
+import net.sourceforge.plantuml.UmlDiagramType;
+import net.sourceforge.plantuml.cucadiagram.IGroup;
+import net.sourceforge.plantuml.cucadiagram.Rankdir;
+import net.sourceforge.plantuml.cucadiagram.dot.DotData;
+import net.sourceforge.plantuml.cucadiagram.dot.Graphviz;
+import net.sourceforge.plantuml.cucadiagram.dot.GraphvizUtils;
+import net.sourceforge.plantuml.cucadiagram.dot.GraphvizVersion;
+import net.sourceforge.plantuml.cucadiagram.dot.GraphvizVersions;
+import net.sourceforge.plantuml.cucadiagram.dot.ProcessState;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.posimo.Moveable;
+import net.sourceforge.plantuml.StringUtils;
+
+public class DotStringFactory implements Moveable {
+
+ private final Bibliotekon bibliotekon = new Bibliotekon();
+
+ final private Set<String> rankMin = new HashSet<String>();
+
+ private final ColorSequence colorSequence;
+ private final Cluster root;
+
+ private Cluster current;
+ private final DotData dotData;
+
+ private final StringBounder stringBounder;
+
+ public DotStringFactory(ColorSequence colorSequence, StringBounder stringBounder, DotData dotData) {
+ this.colorSequence = colorSequence;
+ this.dotData = dotData;
+ this.stringBounder = stringBounder;
+ this.root = new Cluster(colorSequence, dotData.getSkinParam(), dotData.getRootGroup());
+ this.current = root;
+ }
+
+ public void addShape(Shape shape) {
+ current.addShape(shape);
+ }
+
+ private void printMinRanking(StringBuilder sb) {
+ if (rankMin.size() == 0) {
+ return;
+ }
+ sb.append("{ rank = min;");
+ for (String id : rankMin) {
+ sb.append(id);
+ sb.append(";");
+ }
+ sb.append("}");
+
+ }
+
+ private double getHorizontalDzeta() {
+ double max = 0;
+ for (Line l : bibliotekon.allLines()) {
+ final double c = l.getHorizontalDzeta(stringBounder);
+ if (c > max) {
+ max = c;
+ }
+ }
+ return max / 10;
+ }
+
+ private double getVerticalDzeta() {
+ double max = 0;
+ for (Line l : bibliotekon.allLines()) {
+ final double c = l.getVerticalDzeta(stringBounder);
+ if (c > max) {
+ max = c;
+ }
+ }
+ return max / 10;
+ }
+
+ String createDotString(String... dotStrings) {
+ final StringBuilder sb = new StringBuilder();
+
+ double nodesep = getHorizontalDzeta();
+ if (nodesep < getMinNodeSep()) {
+ nodesep = getMinNodeSep();
+ }
+ if (dotData.getSkinParam().getNodesep() != 0) {
+ nodesep = dotData.getSkinParam().getNodesep();
+ }
+ final String nodesepInches = SvekUtils.pixelToInches(nodesep);
+ // Log.println("nodesep=" + nodesepInches);
+ double ranksep = getVerticalDzeta();
+ if (ranksep < getMinRankSep()) {
+ ranksep = getMinRankSep();
+ }
+ if (dotData.getSkinParam().getRanksep() != 0) {
+ ranksep = dotData.getSkinParam().getRanksep();
+ }
+ final String ranksepInches = SvekUtils.pixelToInches(ranksep);
+ // Log.println("ranksep=" + ranksepInches);
+ sb.append("digraph unix {");
+ SvekUtils.println(sb);
+
+ for (String s : dotStrings) {
+ if (s.startsWith("ranksep")) {
+ sb.append("ranksep=" + ranksepInches + ";");
+ } else if (s.startsWith("nodesep")) {
+ sb.append("nodesep=" + nodesepInches + ";");
+ } else {
+ sb.append(s);
+ }
+ SvekUtils.println(sb);
+ }
+ // sb.append("newrank=true;");
+ // SvekUtils.println(sb);
+ sb.append("remincross=true;");
+ SvekUtils.println(sb);
+ sb.append("searchsize=500;");
+ SvekUtils.println(sb);
+ sb.append("compound=true;");
+ SvekUtils.println(sb);
+
+ if (dotData.getSkinParam().getRankdir() == Rankdir.LEFT_TO_RIGHT) {
+ sb.append("rankdir=LR;");
+ SvekUtils.println(sb);
+ }
+
+ manageMinMaxCluster(sb);
+
+ root.printCluster1(sb, bibliotekon.allLines());
+ for (Line line : bibliotekon.lines0()) {
+ line.appendLine(sb);
+ }
+ root.fillRankMin(rankMin);
+ root.printCluster2(sb, bibliotekon.allLines(), stringBounder, dotData.getDotMode(), getGraphvizVersion(), dotData.getUmlDiagramType());
+ printMinRanking(sb);
+
+ for (Line line : bibliotekon.lines1()) {
+ line.appendLine(sb);
+ }
+ SvekUtils.println(sb);
+ sb.append("}");
+
+ return sb.toString();
+ }
+
+ private void manageMinMaxCluster(final StringBuilder sb) {
+ final List<String> minPointCluster = new ArrayList<String>();
+ final List<String> maxPointCluster = new ArrayList<String>();
+ for (Cluster cluster : bibliotekon.allCluster()) {
+ final String minPoint = cluster.getMinPoint(dotData.getUmlDiagramType());
+ if (minPoint != null) {
+ minPointCluster.add(minPoint);
+ }
+ final String maxPoint = cluster.getMaxPoint(dotData.getUmlDiagramType());
+ if (maxPoint != null) {
+ maxPointCluster.add(maxPoint);
+ }
+ }
+ if (minPointCluster.size() > 0) {
+ sb.append("{rank=min;");
+ for (String s : minPointCluster) {
+ sb.append(s);
+ sb.append(" [shape=point,width=.01,label=\"\"]");
+ sb.append(";");
+ }
+ sb.append("}");
+ SvekUtils.println(sb);
+ }
+ if (maxPointCluster.size() > 0) {
+ sb.append("{rank=max;");
+ for (String s : maxPointCluster) {
+ sb.append(s);
+ sb.append(" [shape=point,width=.01,label=\"\"]");
+ sb.append(";");
+ }
+ sb.append("}");
+ SvekUtils.println(sb);
+ }
+ }
+
+ private int getMinRankSep() {
+ if (dotData.getUmlDiagramType() == UmlDiagramType.ACTIVITY) {
+ // return 29;
+ return 40;
+ }
+ return 60;
+ }
+
+ private int getMinNodeSep() {
+ if (dotData.getUmlDiagramType() == UmlDiagramType.ACTIVITY) {
+ // return 15;
+ return 20;
+ }
+ return 35;
+ }
+
+ public GraphvizVersion getGraphvizVersion() {
+ final Graphviz graphviz = GraphvizUtils.create("foo;", "svg");
+ final File f = graphviz.getDotExe();
+ return GraphvizVersions.getInstance().getVersion(f);
+ }
+
+ public String getSvg(boolean trace, String... dotStrings) throws IOException {
+ final String dotString = createDotString(dotStrings);
+
+ if (trace) {
+ Log.info("Creating temporary file svek.dot");
+ SvekUtils.traceDotString(dotString);
+ }
+
+ final Graphviz graphviz = GraphvizUtils.create(dotString, "svg");
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final ProcessState state = graphviz.createFile3(baos);
+ baos.close();
+ if (state.differs(ProcessState.TERMINATED_OK())) {
+ throw new IllegalStateException("Timeout4 " + state, state.getCause());
+ }
+ final byte[] result = baos.toByteArray();
+ final String s = new String(result, "UTF-8");
+
+ if (trace) {
+ Log.info("Creating temporary file svek.svg");
+ SvekUtils.traceSvgString(s);
+ }
+
+ return s;
+ }
+
+ public boolean illegalDotExe() {
+ final Graphviz graphviz = GraphvizUtils.create(null, "svg");
+ final File dotExe = graphviz.getDotExe();
+ return dotExe == null || dotExe.isFile() == false || dotExe.canRead() == false;
+ }
+
+ public File getDotExe() {
+ final Graphviz graphviz = GraphvizUtils.create(null, "svg");
+ return graphviz.getDotExe();
+ }
+
+ public ClusterPosition solve(String svg) throws IOException, InterruptedException {
+ if (svg.length() == 0) {
+ throw new EmptySvgException();
+ }
+
+ final Pattern pGraph = Pattern.compile("(?m)\\<svg\\s+width=\"(\\d+)pt\"\\s+height=\"(\\d+)pt\"");
+ final Matcher mGraph = pGraph.matcher(svg);
+ if (mGraph.find() == false) {
+ throw new IllegalStateException();
+ }
+ final int fullWidth = Integer.parseInt(mGraph.group(1));
+ final int fullHeight = Integer.parseInt(mGraph.group(2));
+
+ final MinFinder corner1 = new MinFinder();
+
+ for (Shape sh : bibliotekon.allShapes()) {
+ int idx = svg.indexOf("<title>" + sh.getUid() + "</title>");
+ if (sh.getType() == ShapeType.RECTANGLE || sh.getType() == ShapeType.DIAMOND) {
+ final List<Point2D.Double> points = SvekUtils.extractPointsList(svg, idx, fullHeight);
+ final double minX = SvekUtils.getMinX(points);
+ final double minY = SvekUtils.getMinY(points);
+ corner1.manage(minX, minY);
+ sh.moveSvek(minX, minY);
+ } else if (sh.getType() == ShapeType.ROUND_RECTANGLE) {
+ final int idx2 = svg.indexOf("d=\"", idx + 1);
+ idx = svg.indexOf("points=\"", idx + 1);
+ final List<Point2D.Double> points;
+ if (idx2 != -1 && (idx == -1 || idx2 < idx)) {
+ // GraphViz 2.30
+ points = SvekUtils.extractD(svg, idx2, fullHeight);
+ } else {
+ points = SvekUtils.extractPointsList(svg, idx, fullHeight);
+ for (int i = 0; i < 3; i++) {
+ idx = svg.indexOf("points=\"", idx + 1);
+ points.addAll(SvekUtils.extractPointsList(svg, idx, fullHeight));
+ }
+ }
+ final double minX = SvekUtils.getMinX(points);
+ final double minY = SvekUtils.getMinY(points);
+ corner1.manage(minX, minY);
+ sh.moveSvek(minX, minY);
+ } else if (sh.getType() == ShapeType.OCTAGON) {
+ idx = svg.indexOf("points=\"", idx + 1);
+ final List<Point2D.Double> points = SvekUtils.extractPointsList(svg, idx, fullHeight);
+ final double minX = SvekUtils.getMinX(points);
+ final double minY = SvekUtils.getMinY(points);
+ corner1.manage(minX, minY);
+ sh.moveSvek(minX, minY);
+ sh.setOctagon(minX, minY, points);
+ } else if (sh.getType() == ShapeType.CIRCLE || sh.getType() == ShapeType.CIRCLE_IN_RECT
+ || sh.getType() == ShapeType.OVAL) {
+ final double cx = SvekUtils.getValue(svg, idx, "cx");
+ final double cy = SvekUtils.getValue(svg, idx, "cy") + fullHeight;
+ final double rx = SvekUtils.getValue(svg, idx, "rx");
+ final double ry = SvekUtils.getValue(svg, idx, "ry");
+ sh.moveSvek(cx - rx, cy - ry);
+ } else {
+ throw new IllegalStateException(sh.getType().toString() + " " + sh.getUid());
+ }
+ }
+
+ for (Cluster cluster : bibliotekon.allCluster()) {
+ int idx = getClusterIndex(svg, cluster.getColor());
+ final List<Point2D.Double> points = SvekUtils.extractPointsList(svg, idx, fullHeight);
+ final double minX = SvekUtils.getMinX(points);
+ final double minY = SvekUtils.getMinY(points);
+ final double maxX = SvekUtils.getMaxX(points);
+ final double maxY = SvekUtils.getMaxY(points);
+ cluster.setPosition(minX, minY, maxX, maxY);
+ corner1.manage(minX, minY);
+
+ if (cluster.getTitleAndAttributeWidth() == 0 || cluster.getTitleAndAttributeHeight() == 0) {
+ continue;
+ }
+ idx = getClusterIndex(svg, cluster.getTitleColor());
+ final List<Point2D.Double> pointsTitle = SvekUtils.extractPointsList(svg, idx, fullHeight);
+ final double minXtitle = SvekUtils.getMinX(pointsTitle);
+ final double minYtitle = SvekUtils.getMinY(pointsTitle);
+ cluster.setTitlePosition(minXtitle, minYtitle);
+ }
+
+ for (Line line : bibliotekon.allLines()) {
+ line.solveLine(svg, fullHeight, corner1);
+ }
+
+ for (Line line : bibliotekon.allLines()) {
+ line.manageCollision(bibliotekon.allShapes());
+ }
+ corner1.manage(0, 0);
+ return new ClusterPosition(corner1.getMinX(), corner1.getMinY(), fullWidth, fullHeight);
+ // return new ClusterPosition(0, 0, fullWidth, fullHeight);
+ }
+
+ private int getClusterIndex(final String svg, int colorInt) {
+ final String colorString = StringUtils.goLowerCase(StringUtils.getAsHtml(colorInt));
+ final String keyTitle1 = "=\"" + colorString + "\"";
+ int idx = svg.indexOf(keyTitle1);
+ if (idx == -1) {
+ final String keyTitle2 = "stroke:" + colorString + ";";
+ idx = svg.indexOf(keyTitle2);
+ }
+ if (idx == -1) {
+ throw new IllegalStateException("Cannot find color " + colorString);
+ }
+ return idx;
+ }
+
+ public void openCluster(IGroup g, int titleAndAttributeWidth, int titleAndAttributeHeight, TextBlock title,
+ TextBlock stereo) {
+ this.current = current.createChild(g, titleAndAttributeWidth, titleAndAttributeHeight, title, stereo,
+ colorSequence, dotData.getSkinParam());
+ bibliotekon.addCluster(this.current);
+ }
+
+ public void closeCluster() {
+ if (current.getParent() == null) {
+ throw new IllegalStateException();
+ }
+ this.current = current.getParent();
+ }
+
+ public void moveSvek(double deltaX, double deltaY) {
+ for (Shape sh : bibliotekon.allShapes()) {
+ sh.moveSvek(deltaX, deltaY);
+ }
+ for (Line line : bibliotekon.allLines()) {
+ line.moveSvek(deltaX, deltaY);
+ }
+ for (Cluster cl : bibliotekon.allCluster()) {
+ cl.moveSvek(deltaX, deltaY);
+ }
+
+ }
+
+ public final Bibliotekon getBibliotekon() {
+ return bibliotekon;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/EmptySvgException.java b/src/net/sourceforge/plantuml/svek/EmptySvgException.java
new file mode 100644
index 0000000..f15c6b2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/EmptySvgException.java
@@ -0,0 +1,39 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+public class EmptySvgException extends RuntimeException {
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/EntityDomain.java b/src/net/sourceforge/plantuml/svek/EntityDomain.java
new file mode 100644
index 0000000..a47bc47
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/EntityDomain.java
@@ -0,0 +1,76 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.SymbolContext;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class EntityDomain implements TextBlock {
+
+ private final double margin = 4;
+
+ private final double radius = 12;
+ private final double suppY = 2;
+ private final SymbolContext symbolContext;
+
+ public EntityDomain(SymbolContext symbolContext) {
+ this.symbolContext = symbolContext;
+ }
+
+ public void drawU(UGraphic ug) {
+ double x = 0;
+ double y = 0;
+ x += margin;
+ y += margin;
+ ug = symbolContext.apply(ug);
+ final UEllipse circle = new UEllipse(radius * 2, radius * 2);
+ circle.setDeltaShadow(symbolContext.getDeltaShadow());
+ ug.apply(new UTranslate(x, y)).draw(circle);
+ ug.apply(new UTranslate(x, y + 2 * radius + suppY)).draw(new ULine(2 * radius, 0));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(radius * 2 + 2 * margin, radius * 2 + 2 * margin);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/EntityImageProtected.java b/src/net/sourceforge/plantuml/svek/EntityImageProtected.java
new file mode 100644
index 0000000..16216ca
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/EntityImageProtected.java
@@ -0,0 +1,89 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.cucadiagram.dot.Neighborhood;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class EntityImageProtected implements IEntityImage, Untranslated {
+
+ private final IEntityImage orig;
+ private final double border;
+ private final Bibliotekon bibliotekon;
+ private final Neighborhood neighborhood;
+
+ public EntityImageProtected(IEntityImage orig, double border, Neighborhood neighborhood, Bibliotekon bibliotekon) {
+ this.orig = orig;
+ this.border = border;
+ this.bibliotekon = bibliotekon;
+ this.neighborhood = neighborhood;
+ }
+
+ public boolean isHidden() {
+ return orig.isHidden();
+ }
+
+ public HtmlColor getBackcolor() {
+ return orig.getBackcolor();
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return Dimension2DDouble.delta(orig.calculateDimension(stringBounder), 2 * border);
+ }
+
+ public void drawU(UGraphic ug) {
+ orig.drawU(ug.apply(new UTranslate(border, border)));
+ }
+
+ public void drawUntranslated(UGraphic ug, double minX, double minY) {
+ final Dimension2D dim = orig.calculateDimension(ug.getStringBounder());
+ neighborhood.drawU(ug, minX + border, minY + border, bibliotekon, dim);
+ }
+
+ public ShapeType getShapeType() {
+ return orig.getShapeType();
+ }
+
+ public int getShield() {
+ return orig.getShield();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/FrontierCalculator.java b/src/net/sourceforge/plantuml/svek/FrontierCalculator.java
new file mode 100644
index 0000000..ad6573b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/FrontierCalculator.java
@@ -0,0 +1,164 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+import java.awt.geom.Point2D;
+import java.util.Collection;
+
+import net.sourceforge.plantuml.svek.image.EntityImageStateBorder;
+
+public class FrontierCalculator {
+
+ private static final double DELTA = 3 * EntityImageStateBorder.RADIUS;
+ private ClusterPosition core;
+ private final ClusterPosition initial;
+
+ public FrontierCalculator(final ClusterPosition initial, Collection<ClusterPosition> insides,
+ Collection<Point2D> points) {
+ this.initial = initial;
+ for (ClusterPosition in : insides) {
+ if (core == null) {
+ core = in;
+ } else {
+ core = core.merge(in);
+ }
+ }
+ if (core == null) {
+ final Point2D center = initial.getPointCenter();
+ core = new ClusterPosition(center.getX() - 1, center.getY() - 1, center.getX() + 1, center.getY() + 1);
+ }
+ for (Point2D p : points) {
+ core = core.merge(p);
+ }
+ boolean touchMinX = false;
+ boolean touchMaxX = false;
+ boolean touchMinY = false;
+ boolean touchMaxY = false;
+ for (Point2D p : points) {
+ if (p.getX() == core.getMinX()) {
+ touchMinX = true;
+ }
+ if (p.getX() == core.getMaxX()) {
+ touchMaxX = true;
+ }
+ if (p.getY() == core.getMinY()) {
+ touchMinY = true;
+ }
+ if (p.getY() == core.getMaxY()) {
+ touchMaxY = true;
+ }
+ }
+ if (touchMinX == false) {
+ core = core.withMinX(initial.getMinX());
+ }
+ if (touchMaxX == false) {
+ core = core.withMaxX(initial.getMaxX());
+ }
+ if (touchMinY == false) {
+ core = core.withMinY(initial.getMinY());
+ }
+ if (touchMaxY == false) {
+ core = core.withMaxY(initial.getMaxY());
+ }
+ boolean pushMinX = false;
+ boolean pushMaxX = false;
+ boolean pushMinY = false;
+ boolean pushMaxY = false;
+ for (Point2D p : points) {
+ if (p.getY() == core.getMinY() || p.getY() == core.getMaxY()) {
+ if (Math.abs(p.getX() - core.getMaxX()) < DELTA) {
+ pushMaxX = true;
+ }
+ if (Math.abs(p.getX() - core.getMinX()) < DELTA) {
+ pushMinX = true;
+ }
+ }
+ if (p.getX() == core.getMinX() || p.getX() == core.getMaxX()) {
+ if (Math.abs(p.getY() - core.getMaxY()) < DELTA) {
+ pushMaxY = true;
+ }
+ if (Math.abs(p.getY() - core.getMinY()) < DELTA) {
+ pushMinY = true;
+ }
+ }
+ }
+ for (Point2D p : points) {
+// if (p.getX() == core.getMinX() && (p.getY() == core.getMinY() || p.getY() == core.getMaxY())) {
+// pushMinX = false;
+// }
+// if (p.getX() == core.getMaxX() && (p.getY() == core.getMinY() || p.getY() == core.getMaxY())) {
+// pushMaxX = false;
+// }
+ if (p.getY() == core.getMinY() && (p.getX() == core.getMinX() || p.getX() == core.getMaxX())) {
+ pushMinY = false;
+ }
+ if (p.getY() == core.getMaxY() && (p.getX() == core.getMinX() || p.getX() == core.getMaxX())) {
+ pushMaxY = false;
+ }
+ }
+ if (pushMaxX) {
+ core = core.addMaxX(DELTA);
+ }
+ if (pushMinX) {
+ core = core.addMinX(-DELTA);
+ }
+ if (pushMaxY) {
+ core = core.addMaxY(DELTA);
+ }
+ if (pushMinY) {
+ core = core.addMinY(-DELTA);
+ }
+ }
+
+ public ClusterPosition getSuggestedPosition() {
+ return core;
+ }
+
+ public void ensureMinWidth(double minWidth) {
+ final double delta = core.getMaxX() - core.getMinX() - minWidth;
+ if (delta < 0) {
+ double newMinX = core.getMinX() + delta / 2;
+ double newMaxX = core.getMaxX() - delta / 2;
+ final double error = newMinX - initial.getMinX();
+ if (error < 0) {
+ newMinX -= error;
+ newMaxX -= error;
+ }
+ core = core.withMinX(newMinX);
+ core = core.withMaxX(newMaxX);
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/GraphvizCrash.java b/src/net/sourceforge/plantuml/svek/GraphvizCrash.java
new file mode 100644
index 0000000..62ca64f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/GraphvizCrash.java
@@ -0,0 +1,154 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+import java.awt.Font;
+import java.awt.geom.Dimension2D;
+import java.awt.image.BufferedImage;
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.cucadiagram.dot.GraphvizUtils;
+import net.sourceforge.plantuml.flashcode.FlashCodeFactory;
+import net.sourceforge.plantuml.flashcode.FlashCodeUtils;
+import net.sourceforge.plantuml.fun.IconLoader;
+import net.sourceforge.plantuml.graphic.GraphicPosition;
+import net.sourceforge.plantuml.graphic.GraphicStrings;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.QuoteUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UAntiAliasing;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UImage;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+import net.sourceforge.plantuml.version.Version;
+
+public class GraphvizCrash implements IEntityImage {
+
+ private static final UFont font = new UFont("SansSerif", Font.PLAIN, 12);
+
+ private final GraphicStrings graphicStrings;
+ private final BufferedImage flashCode;
+
+ public GraphvizCrash(String text) {
+ final FlashCodeUtils utils = FlashCodeFactory.getFlashCodeUtils();
+ flashCode = utils.exportFlashcode(text);
+ this.graphicStrings = new GraphicStrings(init(), font, HtmlColorUtils.BLACK, HtmlColorUtils.WHITE,
+ UAntiAliasing.ANTI_ALIASING_ON, IconLoader.getRandom(), GraphicPosition.BACKGROUND_CORNER_TOP_RIGHT);
+ }
+
+ private List<String> init() {
+ final List<String> strings = new ArrayList<String>();
+ strings.add("An error has occured!");
+ final String quote = QuoteUtils.getSomeQuote();
+ strings.add("<i>" + quote);
+ strings.add(" ");
+ strings.add("For some reason, dot/Graphviz has crashed.");
+ strings.add("This has been generated with PlantUML (" + Version.versionString() + ").");
+ strings.add(" ");
+ addProperties(strings);
+ strings.add(" ");
+ try {
+ final String dotVersion = GraphvizUtils.dotVersion();
+ strings.add("Default dot version: " + dotVersion);
+ } catch (Throwable e) {
+ strings.add("Cannot determine dot version: " + e.toString());
+ }
+ strings.add(" ");
+ strings.add("You should send this diagram and this image to <b>plantuml@gmail.com</b> to solve this issue.");
+ strings.add("You can try to turn arround this issue by simplifing your diagram.");
+ if (flashCode != null) {
+ addDecodeHint(strings);
+ }
+
+ return strings;
+ }
+
+ public static void addDecodeHint(final List<String> strings) {
+ strings.add(" ");
+ strings.add(" Diagram source: (Use http://zxing.org/w/decode.jspx to decode the flashcode)");
+ }
+
+ public static void addProperties(final List<String> strings) {
+ addTextProperty(strings, "os.version");
+ addTextProperty(strings, "os.name");
+ addTextProperty(strings, "java.vm.vendor");
+ addTextProperty(strings, "java.vm.version");
+ addTextProperty(strings, "java.version");
+ addTextProperty(strings, "user.language");
+ }
+
+ private static void addTextProperty(final List<String> strings, String prop) {
+ strings.add(prop + ": " + System.getProperty(prop));
+ }
+
+ public boolean isHidden() {
+ return false;
+ }
+
+ public HtmlColor getBackcolor() {
+ return HtmlColorUtils.WHITE;
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ Dimension2D result = graphicStrings.calculateDimension(stringBounder);
+ if (flashCode != null) {
+ result = Dimension2DDouble.mergeTB(result,
+ new Dimension2DDouble(flashCode.getWidth(), flashCode.getHeight()));
+ }
+ return result;
+ }
+
+ public void drawU(UGraphic ug) {
+ graphicStrings.drawU(ug);
+ if (flashCode != null) {
+ final double h = graphicStrings.calculateDimension(ug.getStringBounder()).getHeight();
+ ug = ug.apply(new UTranslate(0, h));
+ ug.draw(new UImage(flashCode));
+ }
+ }
+
+ public ShapeType getShapeType() {
+ return ShapeType.RECTANGLE;
+ }
+
+ public int getShield() {
+ return 0;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/GroupPngMakerActivity.java b/src/net/sourceforge/plantuml/svek/GroupPngMakerActivity.java
new file mode 100644
index 0000000..a2f447a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/GroupPngMakerActivity.java
@@ -0,0 +1,140 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
+import net.sourceforge.plantuml.cucadiagram.EntityUtils;
+import net.sourceforge.plantuml.cucadiagram.GroupHierarchy;
+import net.sourceforge.plantuml.cucadiagram.GroupType;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.IGroup;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.cucadiagram.dot.DotData;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.skin.rose.Rose;
+import net.sourceforge.plantuml.svek.image.EntityImageState;
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public final class GroupPngMakerActivity {
+
+ private final CucaDiagram diagram;
+ private final IGroup group;
+
+ class InnerGroupHierarchy implements GroupHierarchy {
+
+ public Collection<IGroup> getChildrenGroups(IGroup parent) {
+ if (EntityUtils.groupRoot(parent)) {
+ return diagram.getChildrenGroups(group);
+ }
+ return diagram.getChildrenGroups(parent);
+ }
+
+ public boolean isEmpty(IGroup g) {
+ return diagram.isEmpty(g);
+ }
+
+ }
+
+ public GroupPngMakerActivity(CucaDiagram diagram, IGroup group) {
+ this.diagram = diagram;
+ this.group = group;
+ }
+
+ private List<Link> getPureInnerLinks() {
+ final List<Link> result = new ArrayList<Link>();
+ for (Link link : diagram.getLinks()) {
+ final IEntity e1 = (IEntity) link.getEntity1();
+ final IEntity e2 = (IEntity) link.getEntity2();
+ if (e1.getParentContainer() == group && e1.isGroup() == false && e2.getParentContainer() == group
+ && e2.isGroup() == false) {
+ result.add(link);
+ }
+ }
+ return result;
+ }
+
+ public IEntityImage getImage() throws IOException, InterruptedException {
+ // final List<? extends CharSequence> display = group.getDisplay();
+ // final TextBlock title = TextBlockUtils.create(display, new FontConfiguration(
+ // getFont(FontParam.STATE), HtmlColorUtils.BLACK), HorizontalAlignment.CENTER, diagram.getSkinParam());
+
+ if (group.size() == 0) {
+ return new EntityImageState(group, diagram.getSkinParam());
+ }
+ final List<Link> links = getPureInnerLinks();
+ final ISkinParam skinParam = diagram.getSkinParam();
+ // if (OptionFlags.PBBACK && group.getSpecificBackColor() != null) {
+ // skinParam = new SkinParamBackcolored(skinParam, null, group.getSpecificBackColor());
+ // }
+ final DotData dotData = new DotData(group, links, group.getLeafsDirect(), diagram.getUmlDiagramType(),
+ skinParam, new InnerGroupHierarchy(), diagram.getColorMapper(), diagram.getEntityFactory(), false,
+ DotMode.NORMAL, diagram.getNamespaceSeparator(), diagram.getPragma());
+
+ final CucaDiagramFileMakerSvek2 svek2 = new CucaDiagramFileMakerSvek2(dotData, diagram.getEntityFactory(),
+ diagram.getSource(), diagram.getPragma());
+
+ if (group.getGroupType() == GroupType.INNER_ACTIVITY) {
+ final Stereotype stereo = group.getStereotype();
+ final HtmlColor borderColor = getColor(ColorParam.activityBorder, stereo);
+ final HtmlColor backColor = group.getSpecificBackColor() == null ? getColor(ColorParam.background, stereo)
+ : group.getSpecificBackColor();
+ return new InnerActivity(svek2.createFile(), borderColor, backColor, skinParam.shadowing());
+ }
+
+ throw new UnsupportedOperationException(group.getGroupType().toString());
+
+ }
+
+ private UFont getFont(FontParam fontParam) {
+ final ISkinParam skinParam = diagram.getSkinParam();
+ return skinParam.getFont(fontParam, null, false);
+ }
+
+ private final Rose rose = new Rose();
+
+ protected final HtmlColor getColor(ColorParam colorParam, Stereotype stereo) {
+ final ISkinParam skinParam = diagram.getSkinParam();
+ return rose.getHtmlColor(skinParam, colorParam, stereo);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/svek/GroupPngMakerState.java b/src/net/sourceforge/plantuml/svek/GroupPngMakerState.java
new file mode 100644
index 0000000..c9ded6d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/GroupPngMakerState.java
@@ -0,0 +1,198 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.EntityUtils;
+import net.sourceforge.plantuml.cucadiagram.GroupHierarchy;
+import net.sourceforge.plantuml.cucadiagram.GroupType;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.IGroup;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.cucadiagram.Member;
+import net.sourceforge.plantuml.cucadiagram.MethodsOrFieldsArea;
+import net.sourceforge.plantuml.cucadiagram.Rankdir;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.cucadiagram.dot.DotData;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockEmpty;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.graphic.TextBlockWidth;
+import net.sourceforge.plantuml.skin.rose.Rose;
+import net.sourceforge.plantuml.svek.image.EntityImageState;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+
+public final class GroupPngMakerState {
+
+ private final CucaDiagram diagram;
+ private final IGroup group;
+
+ class InnerGroupHierarchy implements GroupHierarchy {
+
+ public Collection<IGroup> getChildrenGroups(IGroup parent) {
+ if (EntityUtils.groupRoot(parent)) {
+ return diagram.getChildrenGroups(group);
+ }
+ return diagram.getChildrenGroups(parent);
+ }
+
+ public boolean isEmpty(IGroup g) {
+ return diagram.isEmpty(g);
+ }
+
+ }
+
+ public GroupPngMakerState(CucaDiagram diagram, IGroup group) {
+ this.diagram = diagram;
+ this.group = group;
+ if (group.isGroup() == false) {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ private List<Link> getPureInnerLinks() {
+ final List<Link> result = new ArrayList<Link>();
+ for (Link link : diagram.getLinks()) {
+ if (EntityUtils.isPureInnerLink12(group, link)) {
+ result.add(link);
+ }
+ }
+ return result;
+ }
+
+ public IEntityImage getImage() {
+ final Display display = group.getDisplay();
+ final ISkinParam skinParam = diagram.getSkinParam();
+ final TextBlock title = TextBlockUtils.create(display, new FontConfiguration(getFont(FontParam.STATE),
+ HtmlColorUtils.BLACK, skinParam.getHyperlinkColor(), skinParam.useUnderlineForHyperlink()),
+ HorizontalAlignment.CENTER, diagram.getSkinParam());
+
+ if (group.size() == 0) {
+ return new EntityImageState(group, diagram.getSkinParam());
+ }
+ final List<Link> links = getPureInnerLinks();
+
+ // boolean hasVerticalLine = false;
+ // for (ILeaf leaf : group.getLeafsDirect()) {
+ // if (leaf.getEntityType() == LeafType.STATE_CONCURRENT) {
+ // hasVerticalLine = true;
+ // }
+ // }
+
+ final DotData dotData = new DotData(group, links, group.getLeafsDirect(), diagram.getUmlDiagramType(),
+ skinParam, new InnerGroupHierarchy(), diagram.getColorMapper(), diagram.getEntityFactory(),
+ diagram.isHideEmptyDescriptionForState(), DotMode.NORMAL, diagram.getNamespaceSeparator(),
+ diagram.getPragma());
+
+ final CucaDiagramFileMakerSvek2 svek2 = new CucaDiagramFileMakerSvek2(dotData, diagram.getEntityFactory(),
+ diagram.getSource(), diagram.getPragma());
+ UStroke stroke = group.getSpecificLineStroke();
+ if (stroke == null) {
+ stroke = new UStroke(1.5);
+ }
+
+ if (group.getGroupType() == GroupType.CONCURRENT_STATE) {
+ // return new InnerStateConcurrent(svek2.createFile());
+ return svek2.createFile();
+ } else if (group.getGroupType() == GroupType.STATE) {
+ HtmlColor borderColor = group.getSpecificLineColor();
+ if (borderColor == null) {
+ borderColor = getColor(ColorParam.stateBorder, group.getStereotype());
+ }
+ final Stereotype stereo = group.getStereotype();
+ final HtmlColor backColor = group.getSpecificBackColor() == null ? getColor(ColorParam.stateBackground,
+ stereo) : group.getSpecificBackColor();
+ final List<Member> members = ((IEntity) group).getFieldsToDisplay();
+ final TextBlockWidth attribute;
+ if (members.size() == 0) {
+ attribute = new TextBlockEmpty();
+ } else {
+ attribute = new MethodsOrFieldsArea(members, FontParam.STATE_ATTRIBUTE, diagram.getSkinParam());
+ }
+
+ final Stereotype stereotype = group.getStereotype();
+ final boolean withSymbol = stereotype != null && stereotype.isWithOOSymbol();
+
+ final boolean containsOnlyConcurrentStates = containsOnlyConcurrentStates(dotData);
+ final IEntityImage image = containsOnlyConcurrentStates ? svek2.createFileForConcurrentState() : svek2
+ .createFile();
+ return new InnerStateAutonom(image, title, attribute, borderColor, backColor, skinParam.shadowing(),
+ group.getUrl99(), withSymbol, stroke);
+ }
+
+ throw new UnsupportedOperationException(group.getGroupType().toString());
+
+ }
+
+ private boolean containsOnlyConcurrentStates(DotData dotData) {
+ for (ILeaf leaf : dotData.getLeafs()) {
+ if (leaf instanceof IGroup == false) {
+ return false;
+ }
+ if (((IGroup) leaf).getEntityType() != LeafType.STATE_CONCURRENT) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private UFont getFont(FontParam fontParam) {
+ final ISkinParam skinParam = diagram.getSkinParam();
+ return skinParam.getFont(fontParam, null, false);
+ }
+
+ private final Rose rose = new Rose();
+
+ protected final HtmlColor getColor(ColorParam colorParam, Stereotype stereo) {
+ final ISkinParam skinParam = diagram.getSkinParam();
+ return rose.getHtmlColor(skinParam, colorParam, stereo);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/svek/HeaderLayout.java b/src/net/sourceforge/plantuml/svek/HeaderLayout.java
new file mode 100644
index 0000000..c20d995
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/HeaderLayout.java
@@ -0,0 +1,119 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockEmpty;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+import net.sourceforge.plantuml.utils.MathUtils;
+
+public class HeaderLayout {
+
+ final private TextBlock name;
+ final private TextBlock stereo;
+ final private TextBlock generic;
+ final private TextBlock circledCharacter;
+
+ public HeaderLayout(TextBlock circledCharacter, TextBlock stereo, TextBlock name, TextBlock generic) {
+ this.circledCharacter = protectAgaintNull(circledCharacter);
+ this.stereo = protectAgaintNull(stereo);
+ this.name = protectAgaintNull(name);
+ this.generic = protectAgaintNull(generic);
+ }
+
+ private static TextBlock protectAgaintNull(TextBlock block) {
+ if (block == null) {
+ return new TextBlockEmpty();
+ }
+ return block;
+ }
+
+ public Dimension2D getDimension(StringBounder stringBounder) {
+ final Dimension2D nameDim = name.calculateDimension(stringBounder);
+ final Dimension2D genericDim = generic.calculateDimension(stringBounder);
+ final Dimension2D stereoDim = stereo.calculateDimension(stringBounder);
+ final Dimension2D circleDim = circledCharacter.calculateDimension(stringBounder);
+
+ final double width = circleDim.getWidth() + Math.max(stereoDim.getWidth(), nameDim.getWidth())
+ + genericDim.getWidth();
+ final double height = MathUtils.max(circleDim.getHeight(), stereoDim.getHeight() + nameDim.getHeight() + 10,
+ genericDim.getHeight());
+ return new Dimension2DDouble(width, height);
+ }
+
+ public void drawU(UGraphic ug, double width, double height) {
+
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D nameDim = name.calculateDimension(stringBounder);
+ final Dimension2D genericDim = generic.calculateDimension(stringBounder);
+ final Dimension2D stereoDim = stereo.calculateDimension(stringBounder);
+ final Dimension2D circleDim = circledCharacter.calculateDimension(stringBounder);
+
+ final double widthStereoAndName = Math.max(stereoDim.getWidth(), nameDim.getWidth());
+ final double suppWith = width - circleDim.getWidth() - widthStereoAndName - genericDim.getWidth();
+ assert suppWith >= 0;
+
+ final double h2 = Math.min(circleDim.getWidth() / 4, suppWith * 0.1);
+ final double h1 = (suppWith - h2) / 2;
+ assert h1 >= 0;
+ assert h2 >= 0;
+
+ final double xCircle = h1;
+ final double yCircle = (height - circleDim.getHeight()) / 2;
+ circledCharacter.drawU(ug.apply(new UTranslate(xCircle, yCircle)));
+
+ final double diffHeight = height - stereoDim.getHeight() - nameDim.getHeight();
+ final double xStereo = circleDim.getWidth() + (widthStereoAndName - stereoDim.getWidth()) / 2 + h1 + h2;
+ final double yStereo = diffHeight / 2;
+ stereo.drawU(ug.apply(new UTranslate(xStereo, yStereo)));
+
+ final double xName = circleDim.getWidth() + (widthStereoAndName - nameDim.getWidth()) / 2 + h1 + h2;
+ final double yName = diffHeight / 2 + stereoDim.getHeight();
+ name.drawU(ug.apply(new UTranslate(xName, yName)));
+
+ if (genericDim.getWidth() > 0) {
+ final double delta = 4;
+ final double xGeneric = width - genericDim.getWidth() + delta;
+ final double yGeneric = -delta;
+ generic.drawU(ug.apply(new UTranslate(xGeneric, yGeneric)));
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/IEntityImage.java b/src/net/sourceforge/plantuml/svek/IEntityImage.java
new file mode 100644
index 0000000..3eea03a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/IEntityImage.java
@@ -0,0 +1,49 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+import net.sourceforge.plantuml.Hideable;
+
+public interface IEntityImage extends Hideable, TextBlockBackcolored {
+
+ public static final int CORNER = 25;
+ public static final int MARGIN = 5;
+ public static final int MARGIN_LINE = 5;
+
+ ShapeType getShapeType();
+
+ int getShield();
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/IShapePseudo.java b/src/net/sourceforge/plantuml/svek/IShapePseudo.java
new file mode 100644
index 0000000..e4cd3df
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/IShapePseudo.java
@@ -0,0 +1,43 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+public interface IShapePseudo {
+
+ String getUid();
+
+ void appendShape(StringBuilder sb);
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/InnerActivity.java b/src/net/sourceforge/plantuml/svek/InnerActivity.java
new file mode 100644
index 0000000..8ea3257
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/InnerActivity.java
@@ -0,0 +1,99 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+
+public final class InnerActivity implements IEntityImage {
+
+ private final IEntityImage im;
+ private final HtmlColor borderColor;
+ private final boolean shadowing;
+ private final HtmlColor backColor;
+
+ public InnerActivity(final IEntityImage im, HtmlColor borderColor, HtmlColor backColor, boolean shadowing) {
+ this.im = im;
+ this.backColor = backColor;
+ this.borderColor = borderColor;
+ this.shadowing = shadowing;
+ }
+
+ public final static double THICKNESS_BORDER = 1.5;
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D total = calculateDimension(ug.getStringBounder());
+
+ ug = ug.apply(new UChangeBackColor(backColor)).apply(new UChangeColor(borderColor))
+ .apply(new UStroke(THICKNESS_BORDER));
+ final URectangle rect = new URectangle(total.getWidth(), total.getHeight(), IEntityImage.CORNER,
+ IEntityImage.CORNER);
+ if (shadowing) {
+ rect.setDeltaShadow(4);
+ }
+ ug.draw(rect);
+ ug = ug.apply(new UStroke());
+ im.drawU(ug);
+ }
+
+ public HtmlColor getBackcolor() {
+ return im.getBackcolor();
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D img = im.calculateDimension(stringBounder);
+ return img;
+ }
+
+ public ShapeType getShapeType() {
+ return ShapeType.ROUND_RECTANGLE;
+ }
+
+ public int getShield() {
+ return 0;
+ }
+
+ public boolean isHidden() {
+ return im.isHidden();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/InnerStateAutonom.java b/src/net/sourceforge/plantuml/svek/InnerStateAutonom.java
new file mode 100644
index 0000000..95521cb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/InnerStateAutonom.java
@@ -0,0 +1,148 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockWidth;
+import net.sourceforge.plantuml.svek.image.EntityImageState;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public final class InnerStateAutonom implements IEntityImage {
+
+ private final IEntityImage im;
+ private final TextBlock title;
+ private final TextBlockWidth attribute;
+ private final HtmlColor borderColor;
+ private final HtmlColor backColor;
+ private final boolean shadowing;
+ private final Url url;
+ private final boolean withSymbol;
+ private final UStroke stroke;
+
+ public InnerStateAutonom(final IEntityImage im, final TextBlock title, TextBlockWidth attribute,
+ HtmlColor borderColor, HtmlColor backColor, boolean shadowing, Url url, boolean withSymbol, UStroke stroke) {
+ this.im = im;
+ this.withSymbol = withSymbol;
+ this.title = title;
+ this.borderColor = borderColor;
+ this.backColor = backColor;
+ this.shadowing = shadowing;
+ this.attribute = attribute;
+ this.url = url;
+ this.stroke = stroke;
+ }
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D text = title.calculateDimension(ug.getStringBounder());
+ final Dimension2D attr = attribute.calculateDimension(ug.getStringBounder());
+ final Dimension2D total = calculateDimension(ug.getStringBounder());
+ final double marginForFields = attr.getHeight() > 0 ? IEntityImage.MARGIN : 0;
+
+ final double titreHeight = IEntityImage.MARGIN + text.getHeight() + IEntityImage.MARGIN_LINE;
+ final RoundedContainer r = new RoundedContainer(total, titreHeight, attr.getHeight() + marginForFields,
+ borderColor, backColor, im.getBackcolor(), stroke);
+
+ if (url != null) {
+ ug.startUrl(url);
+ }
+
+ r.drawU(ug, shadowing);
+ title.drawU(ug.apply(new UTranslate((total.getWidth() - text.getWidth()) / 2, IEntityImage.MARGIN)));
+ attribute.asTextBlock(total.getWidth()).drawU(
+ ug.apply(new UTranslate(0 + IEntityImage.MARGIN, IEntityImage.MARGIN + text.getHeight()
+ + IEntityImage.MARGIN)));
+
+ final double spaceYforURL = getSpaceYforURL(ug.getStringBounder());
+ im.drawU(ug.apply(new UTranslate(IEntityImage.MARGIN, spaceYforURL)));
+
+ if (withSymbol) {
+ EntityImageState.drawSymbol(ug.apply(new UChangeColor(borderColor)), total.getWidth(), total.getHeight());
+
+ }
+
+ if (url != null) {
+ ug.closeAction();
+ }
+ }
+
+ private double getSpaceYforURL(StringBounder stringBounder) {
+ final Dimension2D text = title.calculateDimension(stringBounder);
+ final Dimension2D attr = attribute.calculateDimension(stringBounder);
+ final double marginForFields = attr.getHeight() > 0 ? IEntityImage.MARGIN : 0;
+ final double titreHeight = IEntityImage.MARGIN + text.getHeight() + IEntityImage.MARGIN_LINE;
+ final double suppY = titreHeight + marginForFields + attr.getHeight();
+ return suppY + IEntityImage.MARGIN_LINE;
+ }
+
+ public HtmlColor getBackcolor() {
+ return null;
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D img = im.calculateDimension(stringBounder);
+ final Dimension2D text = title.calculateDimension(stringBounder);
+ final Dimension2D attr = attribute.calculateDimension(stringBounder);
+
+ final Dimension2D dim = Dimension2DDouble.mergeTB(text, attr, img);
+ final double marginForFields = attr.getHeight() > 0 ? IEntityImage.MARGIN : 0;
+
+ final Dimension2D result = Dimension2DDouble.delta(dim, IEntityImage.MARGIN * 2 + 2 * IEntityImage.MARGIN_LINE
+ + marginForFields);
+
+ return result;
+ }
+
+ public ShapeType getShapeType() {
+ return ShapeType.ROUND_RECTANGLE;
+ }
+
+ public int getShield() {
+ return 0;
+ }
+
+ public boolean isHidden() {
+ return im.isHidden();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/Line.java b/src/net/sourceforge/plantuml/svek/Line.java
new file mode 100644
index 0000000..51ca366
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/Line.java
@@ -0,0 +1,849 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.util.Collection;
+import java.util.List;
+
+import net.sourceforge.plantuml.Direction;
+import net.sourceforge.plantuml.Hideable;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.Log;
+import net.sourceforge.plantuml.Pragma;
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.command.Position;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.IGroup;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.cucadiagram.LinkArrow;
+import net.sourceforge.plantuml.cucadiagram.LinkDecor;
+import net.sourceforge.plantuml.cucadiagram.LinkHat;
+import net.sourceforge.plantuml.cucadiagram.LinkMiddleDecor;
+import net.sourceforge.plantuml.cucadiagram.LinkType;
+import net.sourceforge.plantuml.cucadiagram.dot.GraphvizVersion;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockArrow;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.graphic.USymbolFolder;
+import net.sourceforge.plantuml.graphic.VerticalAlignment;
+import net.sourceforge.plantuml.posimo.BezierUtils;
+import net.sourceforge.plantuml.posimo.DotPath;
+import net.sourceforge.plantuml.posimo.Moveable;
+import net.sourceforge.plantuml.posimo.Positionable;
+import net.sourceforge.plantuml.posimo.PositionableUtils;
+import net.sourceforge.plantuml.svek.SvekUtils.PointListIterator;
+import net.sourceforge.plantuml.svek.extremity.ExtremityFactory;
+import net.sourceforge.plantuml.svek.image.EntityImageNoteLink;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class Line implements Moveable, Hideable {
+
+ private final String ltail;
+ private final String lhead;
+ private final Link link;
+
+ private final String startUid;
+ private final String endUid;
+
+ private final TextBlock startTailText;
+ private final TextBlock endHeadText;
+ private final TextBlock noteLabelText;
+
+ private final int lineColor;
+ private final int noteLabelColor;
+ private final int startTailColor;
+ private final int endHeadColor;
+
+ private final StringBounder stringBounder;
+ private final Bibliotekon bibliotekon;
+
+ private DotPath dotPath;
+
+ private Positionable startTailLabelXY;
+ private Positionable endHeadLabelXY;
+ private Positionable noteLabelXY;
+
+ private UDrawable extremity2;
+ private UDrawable extremity1;
+
+ private double dx;
+ private double dy;
+
+ private boolean opale;
+ private Cluster projectionCluster;
+ private final GraphvizVersion graphvizVersion;
+
+ private final Pragma pragma;
+
+ // private GraphvizVersion getGraphvizVersion() {
+ // if (pragma.isDefine("graphviz")==false) {
+ // return GraphvizVersion.COMMON;
+ // }
+ // final String value = pragma.getValue("graphviz");
+ // if ("2.34".equals(value)) {
+ // return GraphvizVersion.V2_34_0;
+ // }
+ // return GraphvizVersion.COMMON;
+ // }
+
+ @Override
+ public String toString() {
+ return super.toString() + " color=" + lineColor;
+ }
+
+ class DirectionalTextBlock implements TextBlock {
+
+ private final TextBlock right;
+ private final TextBlock left;
+ private final TextBlock up;
+ private final TextBlock down;
+
+ DirectionalTextBlock(TextBlock right, TextBlock left, TextBlock up, TextBlock down) {
+ this.right = right;
+ this.left = left;
+ this.up = up;
+ this.down = down;
+ }
+
+ public void drawU(UGraphic ug) {
+ Direction dir = getDirection();
+ if (getLinkArrow() == LinkArrow.BACKWARD) {
+ dir = dir.getInv();
+ }
+ switch (dir) {
+ case RIGHT:
+ right.drawU(ug);
+ break;
+ case LEFT:
+ left.drawU(ug);
+ break;
+ case UP:
+ up.drawU(ug);
+ break;
+ case DOWN:
+ down.drawU(ug);
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return right.calculateDimension(stringBounder);
+ }
+
+ private Direction getDirection() {
+ if (isAutolink()) {
+ final double startAngle = dotPath.getStartAngle();
+ return Direction.LEFT;
+ }
+ final Point2D start = dotPath.getStartPoint();
+ final Point2D end = dotPath.getEndPoint();
+ final double ang = Math.atan2(end.getX() - start.getX(), end.getY() - start.getY());
+ if (ang > -Math.PI / 4 && ang < Math.PI / 4) {
+ return Direction.DOWN;
+ }
+ if (ang > Math.PI * 3 / 4 || ang < -Math.PI * 3 / 4) {
+ return Direction.UP;
+ }
+ return end.getX() > start.getX() ? Direction.RIGHT : Direction.LEFT;
+ }
+
+ }
+
+ // private boolean projectionStart() {
+ // return startUid.startsWith(Cluster.CENTER_ID);
+ // }
+
+ public Line(String startUid, String endUid, Link link, ColorSequence colorSequence, String ltail, String lhead,
+ ISkinParam skinParam, StringBounder stringBounder, FontConfiguration labelFont, Bibliotekon bibliotekon,
+ GraphvizVersion graphvizVersion, Pragma pragma) {
+ if (startUid == null || endUid == null || link == null) {
+ throw new IllegalArgumentException();
+ }
+ this.graphvizVersion = graphvizVersion;
+ this.pragma = pragma;
+ this.bibliotekon = bibliotekon;
+ this.stringBounder = stringBounder;
+ this.link = link;
+ this.startUid = startUid;
+ this.endUid = endUid;
+ this.ltail = ltail;
+ this.lhead = lhead;
+
+ this.lineColor = colorSequence.getValue();
+ this.noteLabelColor = colorSequence.getValue();
+ this.startTailColor = colorSequence.getValue();
+ this.endHeadColor = colorSequence.getValue();
+
+ final TextBlock labelOnly;
+ if (link.getLabel() == null) {
+ if (getLinkArrow() == LinkArrow.NONE) {
+ labelOnly = null;
+ } else {
+ final TextBlockArrow right = new TextBlockArrow(Direction.RIGHT, labelFont);
+ final TextBlockArrow left = new TextBlockArrow(Direction.LEFT, labelFont);
+ final TextBlockArrow up = new TextBlockArrow(Direction.UP, labelFont);
+ final TextBlockArrow down = new TextBlockArrow(Direction.DOWN, labelFont);
+ labelOnly = new DirectionalTextBlock(right, left, up, down);
+ }
+ } else {
+ final double marginLabel = startUid.equals(endUid) ? 6 : 1;
+ final TextBlock label = TextBlockUtils.withMargin(
+ TextBlockUtils.create(link.getLabel(), labelFont, skinParam.getDefaultTextAlignment(), skinParam),
+ marginLabel, marginLabel);
+ if (getLinkArrow() == LinkArrow.NONE) {
+ labelOnly = label;
+ } else {
+ TextBlock right = new TextBlockArrow(Direction.RIGHT, labelFont);
+ right = TextBlockUtils.mergeLR(label, right, VerticalAlignment.CENTER);
+ TextBlock left = new TextBlockArrow(Direction.LEFT, labelFont);
+ left = TextBlockUtils.mergeLR(left, label, VerticalAlignment.CENTER);
+ TextBlock up = new TextBlockArrow(Direction.UP, labelFont);
+ up = TextBlockUtils.mergeTB(up, label, HorizontalAlignment.CENTER);
+ TextBlock down = new TextBlockArrow(Direction.DOWN, labelFont);
+ down = TextBlockUtils.mergeTB(label, down, HorizontalAlignment.CENTER);
+ labelOnly = new DirectionalTextBlock(right, left, up, down);
+ }
+ }
+
+ final TextBlock noteOnly;
+ if (link.getNote() == null) {
+ noteOnly = null;
+ } else {
+ noteOnly = new EntityImageNoteLink(link.getNote(), link.getNoteColor(), skinParam);
+ }
+
+ if (labelOnly != null && noteOnly != null) {
+ if (link.getNotePosition() == Position.LEFT) {
+ noteLabelText = TextBlockUtils.mergeLR(noteOnly, labelOnly, VerticalAlignment.CENTER);
+ } else if (link.getNotePosition() == Position.RIGHT) {
+ noteLabelText = TextBlockUtils.mergeLR(labelOnly, noteOnly, VerticalAlignment.CENTER);
+ } else if (link.getNotePosition() == Position.TOP) {
+ noteLabelText = TextBlockUtils.mergeTB(noteOnly, labelOnly, HorizontalAlignment.CENTER);
+ } else {
+ noteLabelText = TextBlockUtils.mergeTB(labelOnly, noteOnly, HorizontalAlignment.CENTER);
+ }
+ } else if (labelOnly != null) {
+ noteLabelText = labelOnly;
+ } else if (noteOnly != null) {
+ noteLabelText = noteOnly;
+ } else {
+ noteLabelText = null;
+ }
+
+ if (link.getQualifier1() == null) {
+ startTailText = null;
+ } else {
+ startTailText = TextBlockUtils.create(Display.getWithNewlines(link.getQualifier1()), labelFont,
+ HorizontalAlignment.CENTER, skinParam);
+ }
+
+ if (link.getQualifier2() == null) {
+ endHeadText = null;
+ } else {
+ endHeadText = TextBlockUtils.create(Display.getWithNewlines(link.getQualifier2()), labelFont,
+ HorizontalAlignment.CENTER, skinParam);
+ }
+
+ }
+
+ public boolean hasNoteLabelText() {
+ return noteLabelText != null;
+ }
+
+ private LinkArrow getLinkArrow() {
+ return link.getLinkArrow();
+ }
+
+ public void appendLine(StringBuilder sb) {
+ // Log.println("inverted=" + isInverted());
+ // if (isInverted()) {
+ // sb.append(endUid);
+ // sb.append("->");
+ // sb.append(startUid);
+ // } else {
+ sb.append(startUid);
+ sb.append("->");
+ sb.append(endUid);
+ // }
+ sb.append("[");
+ final LinkType linkType = link.getType();
+ String decoration = linkType.getSpecificDecorationSvek();
+ if (decoration.endsWith(",") == false) {
+ decoration += ",";
+ }
+ sb.append(decoration);
+
+ int length = link.getLength();
+ // if (graphvizVersion == GraphvizVersion.V2_34_0 && length == 1) {
+ // length = 2;
+ // }
+ if (pragma.horizontalLineBetweenDifferentPackageAllowed() || link.isInvis() || length != 1) {
+ sb.append("minlen=" + (length - 1));
+ sb.append(",");
+ }
+ sb.append("color=\"" + StringUtils.getAsHtml(lineColor) + "\"");
+ if (noteLabelText != null) {
+ sb.append(",");
+ sb.append("label=<");
+ appendTable(sb, noteLabelText.calculateDimension(stringBounder), noteLabelColor);
+ sb.append(">");
+ // sb.append(",labelfloat=true");
+ }
+
+ if (startTailText != null) {
+ sb.append(",");
+ sb.append("taillabel=<");
+ appendTable(sb, startTailText.calculateDimension(stringBounder), startTailColor);
+ sb.append(">");
+ // sb.append(",labelangle=0");
+ }
+ if (endHeadText != null) {
+ sb.append(",");
+ sb.append("headlabel=<");
+ appendTable(sb, endHeadText.calculateDimension(stringBounder), endHeadColor);
+ sb.append(">");
+ // sb.append(",labelangle=0");
+ }
+
+ if (ltail != null) {
+ sb.append(",");
+ sb.append("ltail=");
+ sb.append(ltail);
+ }
+ if (lhead != null) {
+ sb.append(",");
+ sb.append("lhead=");
+ sb.append(lhead);
+ }
+ if (link.isInvis()) {
+ sb.append(",");
+ sb.append("style=invis");
+ }
+
+ if (link.isConstraint() == false || link.hasTwoEntryPointsSameContainer()) {
+ sb.append(",constraint=false");
+ }
+
+ if (link.getSametail() != null) {
+ sb.append(",sametail=" + link.getSametail());
+ }
+
+ sb.append("];");
+ SvekUtils.println(sb);
+ }
+
+ public String rankSame() {
+ // if (graphvizVersion == GraphvizVersion.V2_34_0) {
+ // return null;
+ // }
+ if (pragma.horizontalLineBetweenDifferentPackageAllowed() == false && link.getLength() == 1) {
+ return "{rank=same; " + getStartUid() + "; " + getEndUid() + "}";
+ }
+ return null;
+ }
+
+ public static void appendTable(StringBuilder sb, Dimension2D dim, int col) {
+ final int w = (int) dim.getWidth();
+ final int h = (int) dim.getHeight();
+ appendTable(sb, w, h, col);
+ }
+
+ public static void appendTable(StringBuilder sb, int w, int h, int col) {
+ sb.append("<TABLE ");
+ sb.append("BGCOLOR=\"" + StringUtils.getAsHtml(col) + "\" ");
+ sb.append("FIXEDSIZE=\"TRUE\" WIDTH=\"" + w + "\" HEIGHT=\"" + h + "\">");
+ sb.append("<TR");
+ sb.append(">");
+ sb.append("<TD");
+ // sb.append(" FIXEDSIZE=\"TRUE\" WIDTH=\"" + 0 + "\" HEIGHT=\"" + 0 +
+ // "\"");
+ sb.append(">");
+ sb.append("</TD>");
+ sb.append("</TR>");
+ sb.append("</TABLE>");
+ }
+
+ public final String getStartUid() {
+ if (startUid.endsWith(":h")) {
+ return startUid.substring(0, startUid.length() - 2);
+ }
+ return startUid;
+ }
+
+ public final String getEndUid() {
+ if (endUid.endsWith(":h")) {
+ return endUid.substring(0, endUid.length() - 2);
+ }
+ return endUid;
+ }
+
+ public UDrawable getExtremity(LinkHat hat, LinkDecor decor, PointListIterator pointListIterator) {
+ final ExtremityFactory extremityFactory = decor.getExtremityFactory();
+
+ if (extremityFactory != null) {
+ final List<Point2D.Double> points = pointListIterator.next();
+ final Point2D p0 = points.get(0);
+ final Point2D p1 = points.get(1);
+ final Point2D p2 = points.get(2);
+ return extremityFactory.createUDrawable(p0, p1, p2);
+ } else if (decor != LinkDecor.NONE) {
+ final UShape sh = new UPolygon(pointListIterator.next());
+ return new UDrawable() {
+ public void drawU(UGraphic ug) {
+ ug.draw(sh);
+ }
+ };
+ }
+ return null;
+
+ }
+
+ public void solveLine(final String svg, final int fullHeight, MinFinder corner1) {
+ if (this.link.isInvis()) {
+ return;
+ }
+
+ int idx = getIndexFromColor(svg, this.lineColor);
+ if (idx == -1) {
+ return;
+ // throw new IllegalStateException();
+ }
+ idx = svg.indexOf("d=\"", idx);
+ if (idx == -1) {
+ throw new IllegalStateException();
+ }
+ final int end = svg.indexOf("\"", idx + 3);
+ final String path = svg.substring(idx + 3, end);
+ dotPath = new DotPath(path, fullHeight);
+
+ final PointListIterator pointListIterator = new PointListIterator(svg.substring(end), fullHeight);
+
+ final LinkType linkType = link.getType();
+ this.extremity2 = getExtremity(linkType.getHat2(), linkType.getDecor2(), pointListIterator);
+ this.extremity1 = getExtremity(linkType.getHat1(), linkType.getDecor1(), pointListIterator);
+
+ if (this.noteLabelText != null) {
+ final Point2D pos = getXY(svg, this.noteLabelColor, fullHeight);
+ if (pos != null) {
+ corner1.manage(pos);
+ this.noteLabelXY = TextBlockUtils.asPositionable(noteLabelText, stringBounder, pos);
+ }
+ }
+
+ if (this.startTailText != null) {
+ final Point2D pos = getXY(svg, this.startTailColor, fullHeight);
+ if (pos != null) {
+ corner1.manage(pos);
+ this.startTailLabelXY = TextBlockUtils.asPositionable(startTailText, stringBounder, pos);
+ }
+ }
+
+ if (this.endHeadText != null) {
+ final Point2D pos = getXY(svg, this.endHeadColor, fullHeight);
+ if (pos != null) {
+ corner1.manage(pos);
+ this.endHeadLabelXY = TextBlockUtils.asPositionable(endHeadText, stringBounder, pos);
+ }
+ }
+
+ if (isOpalisable() == false) {
+ setOpale(false);
+ }
+ }
+
+ private boolean isOpalisable() {
+ return dotPath.getBeziers().size() <= 1;
+ }
+
+ private Point2D.Double getXY(String svg, int color, int height) {
+ final int idx = getIndexFromColor(svg, color);
+ if (idx == -1) {
+ return null;
+ }
+ return SvekUtils.getMinXY(SvekUtils.extractPointsList(svg, idx, height));
+
+ }
+
+ private int getIndexFromColor(String svg, int color) {
+ String s = "stroke=\"" + StringUtils.goLowerCase(StringUtils.getAsHtml(color)) + "\"";
+ int idx = svg.indexOf(s);
+ if (idx != -1) {
+ return idx;
+ }
+ s = ";stroke:" + StringUtils.goLowerCase(StringUtils.getAsHtml(color)) + ";";
+ idx = svg.indexOf(s);
+ if (idx != -1) {
+ return idx;
+ }
+ s = "fill=\"" + StringUtils.goLowerCase(StringUtils.getAsHtml(color)) + "\"";
+ idx = svg.indexOf(s);
+ if (idx != -1) {
+ return idx;
+ }
+ Log.info("Cannot find color=" + color + " " + StringUtils.goLowerCase(StringUtils.getAsHtml(color)));
+ return -1;
+
+ }
+
+ public void drawU(UGraphic ug, HtmlColor color) {
+ if (opale) {
+ return;
+ }
+
+ double x = 0;
+ double y = 0;
+ final Url url = link.getUrl();
+ if (url != null) {
+ ug.startUrl(url);
+ }
+
+ if (link.isAutoLinkOfAGroup()) {
+ final Cluster cl = bibliotekon.getCluster((IGroup) link.getEntity1());
+ x += cl.getWidth();
+ x -= dotPath.getStartPoint().getX() - cl.getMinX();
+ }
+
+ x += dx;
+ y += dy;
+
+ if (link.isInvis()) {
+ return;
+ }
+ if (this.link.getSpecificColor() != null) {
+ color = this.link.getSpecificColor();
+ }
+
+ ug = ug.apply(new UChangeBackColor(null)).apply(new UChangeColor(color));
+ final LinkType linkType = link.getType();
+ ug = ug.apply(linkType.getStroke());
+ double moveStartX = 0;
+ double moveStartY = 0;
+ double moveEndX = 0;
+ double moveEndY = 0;
+ if (projectionCluster != null && link.getEntity1() == projectionCluster.getGroup()) {
+ final DotPath copy = new DotPath(dotPath);
+ final Point2D start = copy.getStartPoint();
+ final Point2D proj = projectionCluster.getClusterPosition().getProjectionOnFrontier(start);
+ moveStartX = proj.getX() - start.getX();
+ moveStartY = proj.getY() - start.getY();
+ copy.forceStartPoint(proj.getX(), proj.getY());
+ ug.apply(new UTranslate(x, y)).draw(copy);
+ } else if (projectionCluster != null && link.getEntity2() == projectionCluster.getGroup()) {
+ final DotPath copy = new DotPath(dotPath);
+ final Point2D end = copy.getEndPoint();
+ final Point2D proj = projectionCluster.getClusterPosition().getProjectionOnFrontier(end);
+ moveEndX = proj.getX() - end.getX();
+ moveEndY = proj.getY() - end.getY();
+ copy.forceEndPoint(proj.getX(), proj.getY());
+ ug.apply(new UTranslate(x, y)).draw(copy);
+ } else {
+ if (dotPath == null) {
+ Log.info("DotPath is null for " + this);
+ return;
+ }
+ DotPath todraw = dotPath;
+ if (link.getEntity2().isGroup() && link.getEntity2().getUSymbol() instanceof USymbolFolder) {
+ final Cluster endCluster = bibliotekon.getCluster((IGroup) link.getEntity2());
+ if (endCluster != null) {
+ final double deltaFolderH = endCluster.checkFolderPosition(dotPath.getEndPoint(),
+ ug.getStringBounder());
+ todraw = new DotPath(dotPath);
+ todraw.moveEndPoint(0, deltaFolderH);
+ moveEndY = deltaFolderH;
+ }
+ }
+
+ ug.apply(new UTranslate(x, y)).draw(todraw);
+ }
+
+ ug = ug.apply(new UStroke()).apply(new UChangeColor(color));
+
+ if (this.extremity1 != null) {
+ if (linkType.getDecor1().isFill()) {
+ ug = ug.apply(new UChangeBackColor(color));
+ } else {
+ ug = ug.apply(new UChangeBackColor(null));
+ }
+ this.extremity1.drawU(ug.apply(new UTranslate(x + moveEndX, y + moveEndY)));
+ }
+ if (this.extremity2 != null) {
+ if (linkType.getDecor2().isFill()) {
+ ug = ug.apply(new UChangeBackColor(color));
+ } else {
+ ug = ug.apply(new UChangeBackColor(null));
+ }
+ this.extremity2.drawU(ug.apply(new UTranslate(x + moveStartX, y + moveStartY)));
+ }
+ if (this.noteLabelText != null && this.noteLabelXY != null) {
+ this.noteLabelText.drawU(ug.apply(new UTranslate(x + this.noteLabelXY.getPosition().getX(), y
+ + this.noteLabelXY.getPosition().getY())));
+ }
+ if (this.startTailText != null) {
+ this.startTailText.drawU(ug.apply(new UTranslate(x + this.startTailLabelXY.getPosition().getX(), y
+ + this.startTailLabelXY.getPosition().getY())));
+ }
+ if (this.endHeadText != null) {
+ this.endHeadText.drawU(ug.apply(new UTranslate(x + this.endHeadLabelXY.getPosition().getX(), y
+ + this.endHeadLabelXY.getPosition().getY())));
+ }
+
+ if (linkType.getMiddleDecor() != LinkMiddleDecor.NONE) {
+ final PointAndAngle middle = dotPath.getMiddle();
+ final double angleRad = middle.getAngle();
+ final double angleDeg = -angleRad * 180.0 / Math.PI;
+ final UDrawable mi = linkType.getMiddleDecor().getMiddleFactory().createUDrawable(angleDeg - 45);
+ mi.drawU(ug.apply(new UTranslate(x + middle.getX(), y + middle.getY())));
+ }
+
+ if (url != null) {
+ ug.closeAction();
+ }
+ }
+
+ public boolean isInverted() {
+ return link.isInverted();
+ }
+
+ private double getDecorDzeta() {
+ final LinkType linkType = link.getType();
+ final int size1 = linkType.getDecor1().getMargin();
+ final int size2 = linkType.getDecor2().getMargin();
+ return size1 + size2;
+ }
+
+ public double getHorizontalDzeta(StringBounder stringBounder) {
+ if (startUid.equals(endUid)) {
+ return getDecorDzeta();
+ }
+ final ArithmeticStrategy strategy;
+ if (isHorizontal()) {
+ strategy = new ArithmeticStrategySum();
+ } else {
+ return 0;
+ }
+ if (noteLabelText != null) {
+ strategy.eat(noteLabelText.calculateDimension(stringBounder).getWidth());
+ }
+ if (startTailText != null) {
+ strategy.eat(startTailText.calculateDimension(stringBounder).getWidth());
+ }
+ if (endHeadText != null) {
+ strategy.eat(endHeadText.calculateDimension(stringBounder).getWidth());
+ }
+ return strategy.getResult() + getDecorDzeta();
+ }
+
+ private boolean isHorizontal() {
+ return link.getLength() == 1;
+ }
+
+ public double getVerticalDzeta(StringBounder stringBounder) {
+ if (startUid.equals(endUid)) {
+ return getDecorDzeta();
+ }
+ if (isHorizontal()) {
+ return 0;
+ }
+ final ArithmeticStrategy strategy = new ArithmeticStrategySum();
+ if (noteLabelText != null) {
+ strategy.eat(noteLabelText.calculateDimension(stringBounder).getHeight());
+ }
+ if (startTailText != null) {
+ strategy.eat(startTailText.calculateDimension(stringBounder).getHeight());
+ }
+ if (endHeadText != null) {
+ strategy.eat(endHeadText.calculateDimension(stringBounder).getHeight());
+ }
+ return strategy.getResult() + getDecorDzeta();
+ }
+
+ public void manageCollision(Collection<Shape> allShapes) {
+
+ for (Shape sh : allShapes) {
+ final Positionable cl = PositionableUtils.addMargin(sh, 8, 8);
+ if (startTailText != null && startTailLabelXY != null && PositionableUtils.intersect(cl, startTailLabelXY)) {
+ startTailLabelXY = PositionableUtils.moveAwayFrom(cl, startTailLabelXY);
+ }
+ if (endHeadText != null && endHeadLabelXY != null && PositionableUtils.intersect(cl, endHeadLabelXY)) {
+ endHeadLabelXY = PositionableUtils.moveAwayFrom(cl, endHeadLabelXY);
+ }
+ }
+
+ // final Positionable start = getStartTailPositionnable();
+ // if (start != null) {
+ // for (Shape sh : allShapes) {
+ // if (cut(start, sh)) {
+ // avoid(startTailLabelXY, start, sh);
+ // }
+ // }
+ // }
+ //
+ // final Positionable end = getEndHeadPositionnable();
+ // if (end != null) {
+ // for (Shape sh : allShapes) {
+ // if (cut(end, sh)) {
+ // avoid(endHeadLabelXY, end, sh);
+ // }
+ // }
+ // }
+
+ }
+
+ private void avoid(Point2D.Double move, Positionable pos, Shape sh) {
+ final Oscillator oscillator = new Oscillator();
+ final Point2D.Double orig = new Point2D.Double(move.x, move.y);
+ while (cut(pos, sh)) {
+ final Point2D.Double m = oscillator.nextPosition();
+ move.setLocation(orig.x + m.x, orig.y + m.y);
+ }
+ }
+
+ private boolean cut(Positionable pos, Shape sh) {
+ return BezierUtils.intersect(pos, sh) || tooClose(pos);
+ }
+
+ private boolean tooClose(Positionable pos) {
+ final double dist = dotPath.getMinDist(BezierUtils.getCenter(pos));
+ final Dimension2D dim = pos.getSize();
+ // Log.println("dist=" + dist);
+ return dist < (dim.getWidth() / 2 + 2) || dist < (dim.getHeight() / 2 + 2);
+ }
+
+ public void moveSvek(double deltaX, double deltaY) {
+ this.dx += deltaX;
+ this.dy += deltaY;
+ }
+
+ public final DotPath getDotPath() {
+ final DotPath result = new DotPath(dotPath);
+ result.moveSvek(dx, dy);
+ return result;
+ }
+
+ public int getLength() {
+ return link.getLength();
+ }
+
+ public void setOpale(boolean opale) {
+ this.link.setOpale(opale);
+ this.opale = opale;
+
+ }
+
+ public boolean isOpale() {
+ return opale;
+ }
+
+ public boolean isHorizontalSolitary() {
+ return link.isHorizontalSolitary();
+ }
+
+ public boolean isLinkFromOrTo(IEntity group) {
+ return link.getEntity1() == group || link.getEntity2() == group;
+ }
+
+ public boolean hasEntryPoint() {
+ return link.hasEntryPoint();
+ }
+
+ public void setProjectionCluster(Cluster cluster) {
+ this.projectionCluster = cluster;
+
+ }
+
+ public boolean isHidden() {
+ return link.isHidden();
+ }
+
+ public boolean sameConnections(Line other) {
+ return link.sameConnections(other.link);
+ }
+
+ private boolean isAutolink() {
+ return link.getEntity1() == link.getEntity2();
+ }
+
+ public Point2D getMyPoint(IEntity entity) {
+ if (link.getEntity1() == entity) {
+ return moveDelta(dotPath.getStartPoint());
+ }
+ if (link.getEntity2() == entity) {
+ return moveDelta(dotPath.getEndPoint());
+ }
+ throw new IllegalArgumentException();
+ }
+
+ private Point2D moveDelta(Point2D pt) {
+ return new Point2D.Double(pt.getX() + dx, pt.getY() + dy);
+ }
+
+ public boolean isLink(Link link) {
+ return this.link == link;
+ }
+
+ public Point2D getStartContactPoint() {
+ final Point2D start = dotPath.getStartPoint();
+ if (start == null) {
+ return null;
+ }
+ return new Point2D.Double(dx + start.getX(), dy + start.getY());
+ }
+
+ public Point2D getEndContactPoint() {
+ final Point2D end = dotPath.getEndPoint();
+ if (end == null) {
+ return null;
+ }
+ return new Point2D.Double(dx + end.getX(), dy + end.getY());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/MinFinder.java b/src/net/sourceforge/plantuml/svek/MinFinder.java
new file mode 100644
index 0000000..6305c9c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/MinFinder.java
@@ -0,0 +1,77 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+import java.awt.geom.Point2D;
+
+public class MinFinder {
+
+ private double minX = Double.MAX_VALUE;
+ private double minY = Double.MAX_VALUE;
+
+ public void manage(double x, double y) {
+ if (x < minX) {
+ minX = x;
+ }
+ if (y < minY) {
+ minY = y;
+ }
+ }
+
+ public void manage(Point2D p) {
+ if (p == null) {
+ throw new IllegalArgumentException();
+ }
+ manage(p.getX(), p.getY());
+ }
+
+ public void manage(MinFinder other) {
+ manage(other.minX, other.minY);
+ }
+
+ @Override
+ public String toString() {
+ return "minX=" + minX + " minY=" + minY;
+ }
+
+ public double getMinX() {
+ return minX;
+ }
+
+ public double getMinY() {
+ return minY;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/Oscillator.java b/src/net/sourceforge/plantuml/svek/Oscillator.java
new file mode 100644
index 0000000..579c066
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/Oscillator.java
@@ -0,0 +1,88 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+import java.awt.geom.Point2D;
+
+public class Oscillator {
+
+ private int n = 3;
+ private int i = 0;
+ private char seg = 'A';
+
+ private int x = -1;
+ private int y = -1;
+
+ public Point2D.Double nextPosition() {
+ assert n % 2 == 1;
+ final int halfN = (n - 1) / 2;
+ final Point2D.Double result = new Point2D.Double(x, y);
+ i++;
+ if (seg == 'A') {
+ x++;
+ if (x > halfN) {
+ seg = 'B';
+ x = halfN;
+ y = -halfN + 1;
+ }
+ } else if (seg == 'B') {
+ y++;
+ if (y > halfN) {
+ seg = 'C';
+ x = halfN - 1;
+ y = halfN;
+ }
+ } else if (seg == 'C') {
+ x--;
+ if (x < -halfN) {
+ seg = 'D';
+ x = -halfN;
+ y = halfN - 1;
+ }
+ } else if (seg == 'D') {
+ y--;
+ if (y == -halfN) {
+ n += 2;
+ i = 0;
+ x = -((n - 1) / 2);
+ y = x;
+ seg = 'A';
+ }
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ return result;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/svek/PackageStyle.java b/src/net/sourceforge/plantuml/svek/PackageStyle.java
new file mode 100644
index 0000000..67ff0e3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/PackageStyle.java
@@ -0,0 +1,294 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+import java.awt.geom.Dimension2D;
+import java.util.EnumSet;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public enum PackageStyle {
+
+ FOLDER, RECT, NODE, FRAME, CLOUD, DATABASE, AGENT, STORAGE, COMPONENT1, COMPONENT2, ARTIFACT, CARD;
+
+ public static PackageStyle fromString(String value) {
+ for (PackageStyle p : EnumSet.allOf(PackageStyle.class)) {
+ if (p.toString().equalsIgnoreCase(value)) {
+ return p;
+ }
+ }
+ return null;
+ }
+
+ public void drawU(UGraphic ug, Dimension2D dim, Dimension2D titleDim, boolean shadowing) {
+ if (titleDim == null) {
+ titleDim = new Dimension2DDouble(0, 0);
+ }
+ final double width = dim.getWidth();
+ final double height = dim.getHeight();
+ if (this == DATABASE) {
+ drawDatabase(ug, width, height, shadowing);
+ } else if (this == FOLDER) {
+ drawFolder(ug, width, height, shadowing);
+ } else if (this == FRAME) {
+ drawFrame(ug, width, height, titleDim, shadowing);
+ } else if (this == CLOUD) {
+ drawCloud(ug, width, height, shadowing);
+ } else if (this == RECT) {
+ drawRect(ug, width, height, shadowing);
+ } else if (this == COMPONENT1) {
+ drawComponent1(ug, width, height, shadowing);
+ } else if (this == COMPONENT2) {
+ drawComponent2(ug, width, height, shadowing);
+ } else if (this == STORAGE) {
+ drawStorage(ug, width, height, shadowing);
+ } else if (this == AGENT) {
+ drawRect(ug, width, height, shadowing);
+ } else if (this == ARTIFACT) {
+ drawArtifact(ug, width, height, shadowing);
+ } else {
+ // drawNode(ug, xTheoricalPosition, yTheoricalPosition, width, height, shadowing);
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ private void drawArtifact(UGraphic ug, double width, double height, boolean shadowing) {
+
+ final UPolygon polygon = new UPolygon();
+ polygon.addPoint(0, 0);
+ polygon.addPoint(0, height);
+ polygon.addPoint(width, height);
+ final int cornersize = 10;
+ polygon.addPoint(width, cornersize);
+ polygon.addPoint(width - cornersize, 0);
+ polygon.addPoint(0, 0);
+ if (shadowing) {
+ polygon.setDeltaShadow(3.0);
+ }
+ ug.draw(polygon);
+ ug.apply(new UTranslate(width - cornersize, 0)).draw(new ULine(0, cornersize));
+ ug.apply(new UTranslate(width, cornersize)).draw(new ULine(-cornersize, 0));
+ }
+
+ private void drawStorage(UGraphic ug, double width, double height, boolean shadowing) {
+ final URectangle shape = new URectangle(width, height, 70, 70);
+ if (shadowing) {
+ shape.setDeltaShadow(3.0);
+ }
+ ug.draw(shape);
+ }
+
+ private void drawComponent1(UGraphic ug, double widthTotal, double heightTotal, boolean shadowing) {
+
+ final URectangle form = new URectangle(widthTotal, heightTotal);
+ if (shadowing) {
+ form.setDeltaShadow(4);
+ }
+
+ final UShape small = new URectangle(10, 5);
+
+ ug.draw(form);
+
+ // UML 1 Component Notation
+ ug.apply(new UTranslate(-5, 5)).draw(small);
+ ug.apply(new UTranslate(-5, heightTotal - 10)).draw(small);
+ }
+
+ private void drawComponent2(UGraphic ug, double widthTotal, double heightTotal, boolean shadowing) {
+
+ final URectangle form = new URectangle(widthTotal, heightTotal);
+ if (shadowing) {
+ form.setDeltaShadow(4);
+ }
+
+ final UShape small = new URectangle(15, 10);
+ final UShape tiny = new URectangle(4, 2);
+
+ ug.draw(form);
+
+ // UML 2 Component Notation
+ ug.apply(new UTranslate(widthTotal - 20, 5)).draw(small);
+ ug.apply(new UTranslate(widthTotal - 22, 7)).draw(tiny);
+ ug.apply(new UTranslate(widthTotal - 22, 11)).draw(tiny);
+ }
+
+ private void drawRect(UGraphic ug, double width, double height, boolean shadowing) {
+ final URectangle shape = new URectangle(width, height);
+ if (shadowing) {
+ shape.setDeltaShadow(3.0);
+ }
+ ug.draw(shape);
+ }
+
+ private void drawCloud(UGraphic ug, double width, double height, boolean shadowing) {
+ final UPath shape = getSpecificFrontierForCloud(width, height);
+ if (shadowing) {
+ shape.setDeltaShadow(3.0);
+ }
+ ug.apply(new UTranslate(3, -3)).draw(shape);
+ }
+
+ private UPath getSpecificFrontierForCloud(double width, double height) {
+ final UPath path = new UPath();
+ path.moveTo(0, 10);
+ double x = 0;
+ for (int i = 0; i < width - 9; i += 10) {
+ path.cubicTo(i, -3 + 10, 2 + i, -5 + 10, 5 + i, -5 + 10);
+ path.cubicTo(8 + i, -5 + 10, 10 + i, -3 + 10, 10 + i, 10);
+ x = i + 10;
+ }
+ double y = 0;
+ for (int j = 10; j < height - 9; j += 10) {
+ path.cubicTo(x + 3, j, x + 5, 2 + j, x + 5, 5 + j);
+ path.cubicTo(x + 5, 8 + j, x + 3, 10 + j, x, 10 + j);
+ y = j + 10;
+ }
+ for (int i = 0; i < width - 9; i += 10) {
+ path.cubicTo(x - i, y + 3, x - 3 - i, y + 5, x - 5 - i, y + 5);
+ path.cubicTo(x - 8 - i, y + 5, x - 10 - i, y + 3, x - 10 - i, y);
+ }
+ for (int j = 0; j < height - 9 - 10; j += 10) {
+ path.cubicTo(-3, y - j, -5, y - 2 - j, -5, y - 5 - j);
+ path.cubicTo(-5, y - 8 - j, -3, y - 10 - j, 0, y - 10 - j);
+ }
+ return path;
+ }
+
+ private void drawFrame(UGraphic ug, double width, double height, Dimension2D dimTitle, boolean shadowing) {
+ final URectangle shape = new URectangle(width, height);
+ if (shadowing) {
+ shape.setDeltaShadow(3.0);
+ }
+
+ ug.draw(shape);
+
+ final double textWidth;
+ final double textHeight;
+ final int cornersize;
+ if (dimTitle.getWidth() == 0) {
+ textWidth = width / 3;
+ textHeight = 12;
+ cornersize = 7;
+ } else {
+ textWidth = dimTitle.getWidth() + 10;
+ textHeight = dimTitle.getHeight() + 3;
+ cornersize = 10;
+ }
+
+ final UPath polygon = new UPath();
+ polygon.moveTo(textWidth, 1);
+
+ polygon.lineTo(textWidth, textHeight - cornersize);
+ polygon.lineTo(textWidth - cornersize, textHeight);
+
+ polygon.lineTo(0, textHeight);
+ ug.draw(polygon);
+
+ }
+
+ private void drawFolder(UGraphic ug, double width, double height, boolean shadowing) {
+ final double wtitle = Math.max(30, width / 4);
+ final UPolygon shape = new UPolygon();
+ shape.addPoint(0, 0);
+ shape.addPoint(wtitle, 0);
+ final double htitle = 10;
+ final double marginTitleX3 = 7;
+ shape.addPoint(wtitle + marginTitleX3, htitle);
+ shape.addPoint(width, htitle);
+ shape.addPoint(width, height);
+ shape.addPoint(0, height);
+ shape.addPoint(0, 0);
+ if (shadowing) {
+ shape.setDeltaShadow(3.0);
+ }
+ ug.draw(shape);
+ ug.apply(new UTranslate(0, htitle)).draw(new ULine(wtitle + marginTitleX3, 0));
+ }
+
+ private void drawDatabase(UGraphic ug, double width, double height, boolean shadowing) {
+ final UPath shape = new UPath();
+ if (shadowing) {
+ shape.setDeltaShadow(3.0);
+ }
+ shape.moveTo(0, 10);
+ shape.cubicTo(10, 0, width / 2 - 10, 0, width / 2, 0);
+ shape.cubicTo(width / 2 + 10, 0, width - 10, 0, width, 10);
+ shape.lineTo(width, height - 10);
+ shape.cubicTo(width - 10, height, width / 2 - 10, height, width / 2, height);
+ shape.cubicTo(width / 2 + 10, height, 10, height, 0, height - 10);
+ shape.lineTo(0, 10);
+
+ ug.draw(shape);
+
+ final UPath closing = new UPath();
+ closing.moveTo(0, 10);
+ closing.cubicTo(10, 20, width / 2 - 10, 20, width / 2, 20);
+ closing.cubicTo(width / 2 + 10, 20, width - 10, 20, width, 10);
+
+ ug.draw(closing);
+
+ }
+
+ private void drawNode(UGraphic ug, double xTheoricalPosition, double yTheoricalPosition, double width,
+ double height, boolean shadowing) {
+ final UPolygon shape = new UPolygon();
+ shape.addPoint(0, 10);
+ shape.addPoint(10, 0);
+ shape.addPoint(width, 0);
+ shape.addPoint(width, height - 10);
+ shape.addPoint(width - 10, height);
+ shape.addPoint(0, height);
+ shape.addPoint(0, 10);
+ if (shadowing) {
+ shape.setDeltaShadow(2);
+ }
+ ug.apply(new UTranslate(xTheoricalPosition, yTheoricalPosition)).draw(shape);
+
+ ug.apply(new UTranslate(xTheoricalPosition + width - 10, yTheoricalPosition + 10)).draw(new ULine(9, -9));
+ final UPath path = new UPath();
+ path.moveTo(0, 0);
+ path.lineTo(width - 10, 0);
+ path.lineTo(width - 10, height - 10);
+ ug.apply(new UTranslate(xTheoricalPosition, yTheoricalPosition + 10)).draw(path);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/PointAndAngle.java b/src/net/sourceforge/plantuml/svek/PointAndAngle.java
new file mode 100644
index 0000000..2fc8860
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/PointAndAngle.java
@@ -0,0 +1,65 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+import java.awt.geom.Point2D;
+
+public class PointAndAngle {
+
+ private final Point2D pt;
+ private final double angle;
+
+ public PointAndAngle(Point2D pt, double angle) {
+ this.pt = pt;
+ this.angle = angle;
+ }
+
+ public Point2D getPt() {
+ return pt;
+ }
+
+ public double getAngle() {
+ return angle;
+ }
+
+ public double getX() {
+ return pt.getX();
+ }
+
+ public double getY() {
+ return pt.getY();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/PointDirected.java b/src/net/sourceforge/plantuml/svek/PointDirected.java
new file mode 100644
index 0000000..810444b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/PointDirected.java
@@ -0,0 +1,59 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+import java.awt.geom.Point2D;
+
+public class PointDirected {
+
+ final private double x;
+ final private double y;
+ final private double angle;
+
+ public PointDirected(Point2D p, double angle) {
+ this.x = p.getX();
+ this.y = p.getY();
+ this.angle = angle;
+ }
+
+ public final Point2D getPoint2D() {
+ return new Point2D.Double(x, y);
+ }
+
+ public final double getAngle() {
+ return angle;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/RoundedContainer.java b/src/net/sourceforge/plantuml/svek/RoundedContainer.java
new file mode 100644
index 0000000..a2e19d4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/RoundedContainer.java
@@ -0,0 +1,99 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public final class RoundedContainer {
+
+ private final Dimension2D dim;
+ private final double titleHeight;
+ private final double attributeHeight;
+ private final HtmlColor borderColor;
+ private final HtmlColor backColor;
+ private final HtmlColor imgBackcolor;
+ private final UStroke stroke;
+
+ public RoundedContainer(Dimension2D dim, double titleHeight, double attributeHeight, HtmlColor borderColor,
+ HtmlColor backColor, HtmlColor imgBackcolor, UStroke stroke) {
+ this.dim = dim;
+ this.imgBackcolor = imgBackcolor;
+ this.titleHeight = titleHeight;
+ this.borderColor = borderColor;
+ this.backColor = backColor;
+ this.attributeHeight = attributeHeight;
+ this.stroke = stroke;
+ }
+
+ public void drawU(UGraphic ug, boolean shadowing) {
+
+ ug = ug.apply(new UChangeBackColor(backColor)).apply(new UChangeColor(borderColor));
+ final URectangle rect = new URectangle(dim.getWidth(), dim.getHeight(), IEntityImage.CORNER,
+ IEntityImage.CORNER);
+ if (shadowing) {
+ rect.setDeltaShadow(3.0);
+ }
+ ug.apply(stroke).draw(rect);
+
+ final double yLine = titleHeight + attributeHeight;
+
+ ug = ug.apply(new UChangeBackColor(imgBackcolor));
+
+ final double thickness = stroke.getThickness();
+
+ final URectangle inner = new URectangle(dim.getWidth() - 4 * thickness, dim.getHeight() - titleHeight - 4
+ * thickness - attributeHeight, IEntityImage.CORNER, IEntityImage.CORNER);
+ ug.apply(new UChangeColor(imgBackcolor)).apply(new UTranslate(2 * thickness, yLine + 2 * thickness))
+ .draw(inner);
+
+ if (titleHeight > 0) {
+ ug.apply(stroke).apply(new UTranslate(0, yLine)).draw(new ULine(dim.getWidth(), 0));
+ }
+
+ if (attributeHeight > 0) {
+ ug.apply(stroke).apply(new UTranslate(0, yLine - attributeHeight)).draw(new ULine(dim.getWidth(), 0));
+ }
+
+ }
+}
diff --git a/src/net/sourceforge/plantuml/svek/Shape.java b/src/net/sourceforge/plantuml/svek/Shape.java
new file mode 100644
index 0000000..71340fa
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/Shape.java
@@ -0,0 +1,264 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.util.List;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.Hideable;
+import net.sourceforge.plantuml.cucadiagram.EntityPosition;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.posimo.Positionable;
+import net.sourceforge.plantuml.svek.image.EntityImageStateBorder;
+import net.sourceforge.plantuml.ugraphic.Shadowable;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.StringUtils;
+
+public class Shape implements Positionable, IShapePseudo, Hideable {
+
+ private final ShapeType type;
+ private final double width;
+ private final double height;
+
+ private final String uid;
+ private final int color;
+
+ private double minX;
+ private double minY;
+ private final int shield;
+
+ private final EntityPosition entityPosition;
+ private final IEntityImage image;
+
+ public EntityPosition getEntityPosition() {
+ return entityPosition;
+ }
+
+ private Cluster cluster;
+
+ private final boolean top;
+
+ public final Cluster getCluster() {
+ return cluster;
+ }
+
+ public final void setCluster(Cluster cluster) {
+ this.cluster = cluster;
+ }
+
+ public Shape(IEntityImage image, ShapeType type, double width, double height, ColorSequence colorSequence,
+ boolean top, int shield, EntityPosition entityPosition) {
+ this.entityPosition = entityPosition;
+ this.image = image;
+ this.top = top;
+ this.type = type;
+ this.width = width;
+ this.height = height;
+ this.color = colorSequence.getValue();
+ this.uid = String.format("sh%04d", color);
+ this.shield = shield;
+ if (shield > 0 && type != ShapeType.RECTANGLE) {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ public final ShapeType getType() {
+ return type;
+ }
+
+ public final double getWidth() {
+ return width;
+ }
+
+ public final double getHeight() {
+ return height;
+ }
+
+ public void appendShape(StringBuilder sb) {
+ if (type == ShapeType.RECTANGLE && shield > 0) {
+ appendHtml(sb);
+ return;
+ }
+ sb.append(uid);
+ sb.append(" [");
+ appendShapeInternal(sb);
+ sb.append(",");
+ sb.append("label=\"\"");
+ sb.append(",");
+ sb.append("width=" + SvekUtils.pixelToInches(getWidth()));
+ sb.append(",");
+ sb.append("height=" + SvekUtils.pixelToInches(getHeight()));
+ sb.append(",");
+ sb.append("color=\"" + StringUtils.getAsHtml(color) + "\"");
+ sb.append("];");
+ SvekUtils.println(sb);
+ }
+
+ private void appendHtml(StringBuilder sb) {
+ sb.append(uid);
+ sb.append(" [");
+ sb.append("shape=plaintext,");
+ sb.append("label=<");
+ appendLabelHtml(sb);
+ sb.append(">");
+ sb.append("];");
+ SvekUtils.println(sb);
+
+ }
+
+ private void appendLabelHtml(StringBuilder sb) {
+ // Log.println("shield=" + shield);
+ sb.append("<TABLE BORDER=\"0\" CELLBORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"0\">");
+ sb.append("<TR>");
+ appendTd(sb);
+ appendTd(sb, shield, shield);
+ appendTd(sb);
+ sb.append("</TR>");
+ sb.append("<TR>");
+ appendTd(sb, shield, shield);
+ sb.append("<TD BGCOLOR=\"" + StringUtils.getAsHtml(color) + "\"");
+ sb.append(" FIXEDSIZE=\"TRUE\" WIDTH=\"" + getWidth() + "\" HEIGHT=\"" + getHeight() + "\"");
+ sb.append(" PORT=\"h\">");
+ sb.append("</TD>");
+ appendTd(sb, shield, shield);
+ sb.append("</TR>");
+ sb.append("<TR>");
+ appendTd(sb);
+ appendTd(sb, shield, shield);
+ appendTd(sb);
+ sb.append("</TR>");
+ sb.append("</TABLE>");
+ }
+
+ private void appendTd(StringBuilder sb, int w, int h) {
+ sb.append("<TD");
+ sb.append(" FIXEDSIZE=\"TRUE\" WIDTH=\"" + w + "\" HEIGHT=\"" + h + "\"");
+ sb.append(">");
+ sb.append("</TD>");
+ }
+
+ private void appendTd(StringBuilder sb) {
+ sb.append("<TD>");
+ sb.append("</TD>");
+ }
+
+ private void appendShapeInternal(StringBuilder sb) {
+ if (type == ShapeType.RECTANGLE && shield > 0) {
+ throw new UnsupportedOperationException();
+ } else if (type == ShapeType.RECTANGLE) {
+ sb.append("shape=rect");
+ } else if (type == ShapeType.OCTAGON) {
+ sb.append("shape=octagon");
+ } else if (type == ShapeType.DIAMOND) {
+ sb.append("shape=diamond");
+ } else if (type == ShapeType.CIRCLE) {
+ sb.append("shape=circle");
+ } else if (type == ShapeType.CIRCLE_IN_RECT) {
+ sb.append("shape=circle");
+ } else if (type == ShapeType.OVAL) {
+ sb.append("shape=ellipse");
+ } else if (type == ShapeType.ROUND_RECTANGLE) {
+ sb.append("shape=rect,style=rounded");
+ } else {
+ throw new IllegalStateException(type.toString());
+ }
+ }
+
+ public final String getUid() {
+ if (uid == null) {
+ throw new IllegalStateException();
+ }
+ return uid;
+ }
+
+ public final double getMinX() {
+ return minX;
+ }
+
+ public final double getMinY() {
+ return minY;
+ }
+
+ public IEntityImage getImage() {
+ return image;
+ }
+
+ public final boolean isTop() {
+ return top;
+ }
+
+ public Point2D getPosition() {
+ return new Point2D.Double(minX, minY);
+ }
+
+ public Dimension2D getSize() {
+ return new Dimension2DDouble(width, height);
+ }
+
+ public ClusterPosition getClusterPosition() {
+ return new ClusterPosition(minX, minY, minX + width, minY + height);
+ }
+
+ public boolean isShielded() {
+ return shield > 0;
+ }
+
+ public void moveSvek(double deltaX, double deltaY) {
+ this.minX += deltaX;
+ this.minY += deltaY;
+ }
+
+ public double getMaxWidthFromLabelForEntryExit(StringBounder stringBounder) {
+ final EntityImageStateBorder im = (EntityImageStateBorder) image;
+ return im.getMaxWidthFromLabelForEntryExit(stringBounder);
+ }
+
+ public boolean isHidden() {
+ return image.isHidden();
+ }
+
+ private Shadowable octagon;
+
+ public void setOctagon(double minX, double minY, List<Point2D.Double> points) {
+ this.octagon = new UPolygon(points).translate(-minX, -minY);
+ }
+
+ public Shadowable getOctagon() {
+ return octagon;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/ShapePseudoImpl.java b/src/net/sourceforge/plantuml/svek/ShapePseudoImpl.java
new file mode 100644
index 0000000..e5b03af
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/ShapePseudoImpl.java
@@ -0,0 +1,60 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+public class ShapePseudoImpl implements IShapePseudo {
+
+ private final String uid;
+ private final double width;
+ private final double height;
+
+ public ShapePseudoImpl(String uid, double width, double height) {
+ this.uid = uid;
+ this.width = width;
+ this.height = height;
+ }
+
+ public String getUid() {
+ return uid;
+ }
+
+ public void appendShape(StringBuilder sb) {
+ sb.append(uid + " [shape=rect,label=\"\"");
+ sb.append(",width=" + SvekUtils.pixelToInches(width));
+ sb.append(",height=" + SvekUtils.pixelToInches(height));
+ sb.append("];");
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/ShapeType.java b/src/net/sourceforge/plantuml/svek/ShapeType.java
new file mode 100644
index 0000000..7164467
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/ShapeType.java
@@ -0,0 +1,41 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+public enum ShapeType {
+
+ RECTANGLE, ROUND_RECTANGLE, CIRCLE, CIRCLE_IN_RECT, OVAL, DIAMOND, OCTAGON
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/SingleStrategy.java b/src/net/sourceforge/plantuml/svek/SingleStrategy.java
new file mode 100644
index 0000000..f1ac568
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/SingleStrategy.java
@@ -0,0 +1,87 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.cucadiagram.LinkDecor;
+import net.sourceforge.plantuml.cucadiagram.LinkType;
+
+public enum SingleStrategy {
+
+ SQUARRE, HLINE, VLINE;
+
+ public Collection<Link> generateLinks(List<ILeaf> standalones) {
+ return putInSquare(standalones);
+ }
+
+ private Collection<Link> putInSquare(List<ILeaf> standalones) {
+ final List<Link> result = new ArrayList<Link>();
+ final LinkType linkType = new LinkType(LinkDecor.NONE, LinkDecor.NONE).getInvisible();
+ final int branch = computeBranch(standalones.size());
+ int headBranch = 0;
+ for (int i = 1; i < standalones.size(); i++) {
+ final int dist = i - headBranch;
+ final IEntity ent2 = standalones.get(i);
+ final Link link;
+ if (dist == branch) {
+ final IEntity ent1 = standalones.get(headBranch);
+ link = new Link(ent1, ent2, linkType, null, 2);
+ headBranch = i;
+ } else {
+ final IEntity ent1 = standalones.get(i - 1);
+ link = new Link(ent1, ent2, linkType, null, 1);
+ }
+ result.add(link);
+ }
+ return Collections.unmodifiableCollection(result);
+ }
+
+ static int computeBranch(int size) {
+ final double sqrt = Math.sqrt(size);
+ final int r = (int) sqrt;
+ if (r * r == size) {
+ return r;
+ }
+ return r + 1;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/SvekResult.java b/src/net/sourceforge/plantuml/svek/SvekResult.java
new file mode 100644
index 0000000..803d6d7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/SvekResult.java
@@ -0,0 +1,134 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.UmlDiagramType;
+import net.sourceforge.plantuml.cucadiagram.dot.DotData;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.posimo.Moveable;
+import net.sourceforge.plantuml.skin.rose.Rose;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UHidden;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public final class SvekResult implements IEntityImage, Moveable {
+
+ private final Rose rose = new Rose();
+
+ private ClusterPosition dim;
+ private final DotData dotData;
+ private final DotStringFactory dotStringFactory;
+
+ public SvekResult(ClusterPosition dim, DotData dotData, DotStringFactory dotStringFactory) {
+ this.dim = dim;
+ this.dotData = dotData;
+ this.dotStringFactory = dotStringFactory;
+ }
+
+ public void drawU(UGraphic ug) {
+
+ for (Cluster cluster : dotStringFactory.getBibliotekon().allCluster()) {
+ cluster.drawU(ug, dotData, new UStroke(1.5));
+ }
+
+ final HtmlColor color = rose.getHtmlColor(dotData.getSkinParam(), getArrowColorParam(), null);
+
+ for (Shape shape : dotStringFactory.getBibliotekon().allShapes()) {
+ final double minX = shape.getMinX();
+ final double minY = shape.getMinY();
+ final UGraphic ug2 = shape.isHidden() ? ug.apply(UHidden.HIDDEN) : ug;
+ final IEntityImage image = shape.getImage();
+ image.drawU(ug2.apply(new UTranslate(minX, minY)));
+ if (image instanceof Untranslated) {
+ ((Untranslated) image).drawUntranslated(ug.apply(new UChangeColor(color)), minX, minY);
+ }
+ // shape.getImage().drawNeighborhood(ug2, minX, minY);
+ }
+
+ for (Line line : dotStringFactory.getBibliotekon().allLines()) {
+ final UGraphic ug2 = line.isHidden() ? ug.apply(UHidden.HIDDEN) : ug;
+ line.drawU(ug2, color);
+ }
+
+ }
+
+ private ColorParam getArrowColorParam() {
+ if (dotData.getUmlDiagramType() == UmlDiagramType.CLASS) {
+ return ColorParam.classArrow;
+ } else if (dotData.getUmlDiagramType() == UmlDiagramType.OBJECT) {
+ return ColorParam.objectArrow;
+ } else if (dotData.getUmlDiagramType() == UmlDiagramType.DESCRIPTION) {
+ return ColorParam.usecaseArrow;
+ } else if (dotData.getUmlDiagramType() == UmlDiagramType.ACTIVITY) {
+ return ColorParam.activityArrow;
+ } else if (dotData.getUmlDiagramType() == UmlDiagramType.STATE) {
+ return ColorParam.stateArrow;
+ }
+ throw new IllegalStateException();
+ }
+
+ public HtmlColor getBackcolor() {
+ return dotData.getSkinParam().getBackgroundColor();
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return dim.getDimension();
+ }
+
+ public ShapeType getShapeType() {
+ return ShapeType.RECTANGLE;
+ }
+
+ public int getShield() {
+ return 0;
+ }
+
+ public void moveSvek(double deltaX, double deltaY) {
+ dotStringFactory.moveSvek(deltaX, deltaY);
+ dim = dim.delta(deltaX > 0 ? deltaX : 0, deltaY > 0 ? deltaY : 0);
+ }
+
+ public boolean isHidden() {
+ return false;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/SvekUtils.java b/src/net/sourceforge/plantuml/svek/SvekUtils.java
new file mode 100644
index 0000000..e1868c2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/SvekUtils.java
@@ -0,0 +1,196 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+import java.awt.geom.Point2D;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.StringTokenizer;
+
+import net.sourceforge.plantuml.Log;
+
+public class SvekUtils {
+
+ static public void traceSvgString(String svg) throws IOException {
+ traceString(new File("svek.svg"), svg);
+ }
+
+ static public void traceDotString(String dot) throws IOException {
+ traceString(new File("svek.dot"), dot);
+ }
+
+ static private void traceString(final File f, String svg) throws IOException {
+ PrintWriter pw = null;
+ try {
+ pw = new PrintWriter(new FileWriter(f));
+ pw.print(svg);
+ Log.info("Creating file " + f);
+ } finally {
+ if (pw != null) {
+ pw.close();
+ }
+ }
+ }
+
+ static class PointListIterator implements Iterator<List<Point2D.Double>> {
+
+ private final String text;
+ private final double yDelta;
+ private int pos = 0;
+
+ public PointListIterator(String text, double yDelta) {
+ this.text = text;
+ this.yDelta = yDelta;
+ }
+
+ public boolean hasNext() {
+ return true;
+ }
+
+ public List<Point2D.Double> next() {
+ final List<Point2D.Double> result = extractPointsList(text, pos, yDelta);
+ pos = text.indexOf(pointsString, pos) + pointsString.length() + 1;
+ return result;
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+
+ }
+
+ final private static String pointsString = "points=\"";
+
+ public static List<Point2D.Double> extractPointsList(final String svg, final int starting, double yDelta) {
+ final int p2 = svg.indexOf(pointsString, starting);
+ final int p3 = svg.indexOf("\"", p2 + pointsString.length());
+ final String points = svg.substring(p2 + pointsString.length(), p3);
+ final List<Point2D.Double> pointsList = getPoints(points, yDelta);
+ return pointsList;
+ }
+
+ public static List<Point2D.Double> extractD(final String svg, final int starting, double yDelta) {
+ final int p2 = svg.indexOf("d=\"", starting);
+ final int p3 = svg.indexOf("\"", p2 + "d=\"".length());
+ final String points = svg.substring(p2 + "d=\"".length(), p3);
+ final List<Point2D.Double> pointsList = getPoints(points, yDelta);
+ return pointsList;
+ }
+
+ static public double getValue(String svg, int starting, String varName) {
+ final String varNameString = varName + "=\"";
+ int p1 = svg.indexOf(varNameString, starting);
+ if (p1 == -1) {
+ throw new IllegalStateException();
+ }
+ p1 += varNameString.length();
+ final int p2 = svg.indexOf('\"', p1);
+ return Double.parseDouble(svg.substring(p1, p2));
+
+ }
+
+ public static double getMaxX(List<Point2D.Double> points) {
+ double result = points.get(0).x;
+ for (int i = 1; i < points.size(); i++) {
+ if (points.get(i).x > result) {
+ result = points.get(i).x;
+ }
+ }
+ return result;
+ }
+
+ public static double getMinX(List<Point2D.Double> points) {
+ double result = points.get(0).x;
+ for (int i = 1; i < points.size(); i++) {
+ if (points.get(i).x < result) {
+ result = points.get(i).x;
+ }
+ }
+ return result;
+ }
+
+ public static Point2D.Double getMinXY(List<Point2D.Double> points) {
+ return new Point2D.Double(getMinX(points), getMinY(points));
+ }
+
+ public static double getMaxY(List<Point2D.Double> points) {
+ double result = points.get(0).y;
+ for (int i = 1; i < points.size(); i++) {
+ if (points.get(i).y > result) {
+ result = points.get(i).y;
+ }
+ }
+ return result;
+ }
+
+ public static double getMinY(List<Point2D.Double> points) {
+ double result = points.get(0).y;
+ for (int i = 1; i < points.size(); i++) {
+ if (points.get(i).y < result) {
+ result = points.get(i).y;
+ }
+ }
+ return result;
+ }
+
+ static private List<Point2D.Double> getPoints(String points, double yDelta) {
+ final List<Point2D.Double> result = new ArrayList<Point2D.Double>();
+ final StringTokenizer st = new StringTokenizer(points, " MC");
+ while (st.hasMoreTokens()) {
+ final String t = st.nextToken();
+ final StringTokenizer st2 = new StringTokenizer(t, ",");
+ final double x = Double.parseDouble(st2.nextToken());
+ final double y = Double.parseDouble(st2.nextToken()) + yDelta;
+ result.add(new Point2D.Double(x, y));
+ }
+ return result;
+ }
+
+ public static void println(StringBuilder sb) {
+ sb.append('\n');
+ }
+
+ public static String pixelToInches(double pixel) {
+ final double v = pixel / 72.0;
+ return String.format(Locale.US, "%6.6f", v);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/TextBlockBackcolored.java b/src/net/sourceforge/plantuml/svek/TextBlockBackcolored.java
new file mode 100644
index 0000000..0d8bf50
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/TextBlockBackcolored.java
@@ -0,0 +1,44 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.TextBlock;
+
+public interface TextBlockBackcolored extends TextBlock {
+
+ HtmlColor getBackcolor();
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/UGraphicForSnake.java b/src/net/sourceforge/plantuml/svek/UGraphicForSnake.java
new file mode 100644
index 0000000..2df1061
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/UGraphicForSnake.java
@@ -0,0 +1,143 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.activitydiagram3.ftile.Snake;
+import net.sourceforge.plantuml.graphic.UGraphicDelegator;
+import net.sourceforge.plantuml.ugraphic.UChange;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class UGraphicForSnake extends UGraphicDelegator {
+
+ private final double dx;
+ private final double dy;
+ private final List<PendingSnake> snakes;
+
+ public UTranslate getTranslation() {
+ return new UTranslate(dx, dy);
+ }
+
+ static class PendingSnake {
+ private final Snake snake;
+ private final UGraphic ug;
+ private final double dx;
+ private final double dy;
+
+ private PendingSnake(Snake snake, UGraphic ug, double dx, double dy) {
+ this.snake = snake;
+ this.ug = ug;
+ this.dx = dx;
+ this.dy = dy;
+ }
+
+ public void drawInternal() {
+ snake.drawInternal(ug);
+ }
+
+ @Override
+ public String toString() {
+ return "dx=" + dx + " dy=" + dy + " " + snake.move(dx, dy).toString();
+ }
+
+ public PendingSnake merge(PendingSnake newItem) {
+// if (snake.isMergeable() == false || newItem.snake.isMergeable() == false) {
+// return null;
+// }
+ final Snake s1 = snake.move(dx, dy);
+ final Snake s2 = newItem.snake.move(newItem.dx, newItem.dy);
+ final Snake merge = s1.merge(s2);
+ if (merge == null) {
+ return null;
+ }
+ return new PendingSnake(merge.move(-dx, -dy), ug, dx, dy);
+ }
+ }
+
+ public UGraphicForSnake(UGraphic ug) {
+ this(ug, 0, 0, new ArrayList<PendingSnake>());
+ }
+
+ private UGraphicForSnake(UGraphic ug, double dx, double dy, List<PendingSnake> snakes) {
+ super(ug);
+ this.dx = dx;
+ this.dy = dy;
+ this.snakes = snakes;
+ }
+
+ public void draw(UShape shape) {
+ if (shape instanceof Snake) {
+ final Snake snake = (Snake) shape;
+ addPendingSnake(snake);
+ } else {
+ getUg().draw(shape);
+ }
+ }
+
+ private void addPendingSnake(final Snake snake) {
+ final PendingSnake newItem = new PendingSnake(snake, getUg(), dx, dy);
+ for (int pos = 0; pos < snakes.size(); pos++) {
+ final PendingSnake merge = snakes.get(pos).merge(newItem);
+ if (merge != null) {
+ snakes.set(pos, merge);
+ return;
+ }
+ }
+ snakes.add(newItem);
+ }
+
+ @Override
+ public void flushUg() {
+ for (PendingSnake snake : snakes) {
+ snake.drawInternal();
+ }
+ snakes.clear();
+ }
+
+ public UGraphic apply(UChange change) {
+ double newdx = dx;
+ double newdy = dy;
+ if (change instanceof UTranslate) {
+ newdx += ((UTranslate) change).getDx();
+ newdy += ((UTranslate) change).getDy();
+ }
+ return new UGraphicForSnake(getUg().apply(change), newdx, newdy, snakes);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/Untranslated.java b/src/net/sourceforge/plantuml/svek/Untranslated.java
new file mode 100644
index 0000000..bfcb915
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/Untranslated.java
@@ -0,0 +1,43 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek;
+
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public interface Untranslated extends IEntityImage {
+
+ public void drawUntranslated(UGraphic ug, double minX, double minY);
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/extremity/Extremity.java b/src/net/sourceforge/plantuml/svek/extremity/Extremity.java
new file mode 100644
index 0000000..e05b8e7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/extremity/Extremity.java
@@ -0,0 +1,69 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.extremity;
+
+import net.sourceforge.plantuml.graphic.UDrawable;
+
+abstract class Extremity implements UDrawable {
+
+
+ protected double manageround(double angle) {
+ final double deg = angle * 180.0 / Math.PI;
+ if (isCloseToo(0, deg)) {
+ return 0;
+ }
+ if (isCloseToo(90, deg)) {
+ return 90.0 * Math.PI / 180.0;
+ }
+ if (isCloseToo(180, deg)) {
+ return 180.0 * Math.PI / 180.0;
+ }
+ if (isCloseToo(270, deg)) {
+ return 270.0 * Math.PI / 180.0;
+ }
+ if (isCloseToo(360, deg)) {
+ return 0;
+ }
+ return angle;
+ }
+
+ private boolean isCloseToo(double value, double variable) {
+ if (Math.abs(value - variable) < 0.05) {
+ return true;
+ }
+ return false;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityArrow.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityArrow.java
new file mode 100644
index 0000000..f355ff9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityArrow.java
@@ -0,0 +1,76 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.extremity;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class ExtremityArrow extends Extremity {
+
+ private UPolygon polygon = new UPolygon();
+ private final ULine line;
+ private final Point2D contact;
+
+ public ExtremityArrow(Point2D p1, double angle, Point2D center) {
+ angle = manageround(angle);
+ polygon.addPoint(0, 0);
+ final int xAile = 9;
+ final int yOuverture = 4;
+ polygon.addPoint(-xAile, -yOuverture);
+ final int xContact = 5;
+ polygon.addPoint(-xContact, 0);
+ polygon.addPoint(-xAile, yOuverture);
+ polygon.addPoint(0, 0);
+ polygon.rotate(angle + Math.PI / 2);
+ polygon = polygon.translate(p1.getX(), p1.getY());
+ contact = new Point2D.Double(p1.getX() - xContact * Math.cos(angle + Math.PI / 2), p1.getY() - xContact
+ * Math.sin(angle + Math.PI / 2));
+ this.line = new ULine(center.getX() - contact.getX(), center.getY() - contact.getY());
+ }
+
+ public void drawU(UGraphic ug) {
+ ug = ug.apply(new UChangeBackColor(ug.getParam().getColor()));
+ ug.draw(polygon);
+ if (line.getLength() > 2) {
+ ug.apply(new UTranslate(contact.getX(), contact.getY())).draw(line);
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityArrowAndCircle.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityArrowAndCircle.java
new file mode 100644
index 0000000..2066d84
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityArrowAndCircle.java
@@ -0,0 +1,78 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.extremity;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class ExtremityArrowAndCircle extends Extremity {
+
+ private UPolygon polygon = new UPolygon();
+ // private final ULine line;
+ private final Point2D contact;
+ private final Point2D dest;
+ private final double radius = 5;
+
+ public ExtremityArrowAndCircle(Point2D p1, double angle, Point2D center) {
+ angle = manageround(angle);
+ polygon.addPoint(0, 0);
+ this.dest = new Point2D.Double(p1.getX(), p1.getY());
+ final int xAile = 9;
+ final int yOuverture = 4;
+ polygon.addPoint(-xAile, -yOuverture);
+ final int xContact = 5;
+ polygon.addPoint(-xContact, 0);
+ polygon.addPoint(-xAile, yOuverture);
+ polygon.addPoint(0, 0);
+ polygon.rotate(angle + Math.PI / 2);
+ polygon = polygon.translate(p1.getX() + radius * Math.sin(angle), p1.getY() - radius * Math.cos(angle));
+ contact = new Point2D.Double(p1.getX() - xContact * Math.cos(angle + Math.PI / 2), p1.getY() - xContact
+ * Math.sin(angle + Math.PI / 2));
+ // this.line = new ULine(center.getX() - contact.getX(), center.getY() - contact.getY());
+ }
+
+ public void drawU(UGraphic ug) {
+ ug.apply(new UChangeBackColor(ug.getParam().getColor())).draw(polygon);
+ ug.apply(new UStroke(1.5)).apply(new UChangeBackColor(HtmlColorUtils.WHITE)).apply(new UTranslate(dest.getX() - radius, dest.getY() - radius)).draw(new UEllipse(radius * 2, radius * 2));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityCircle.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityCircle.java
new file mode 100644
index 0000000..55300cc
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityCircle.java
@@ -0,0 +1,59 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.extremity;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class ExtremityCircle extends Extremity {
+
+ private final Point2D dest;
+ private final double radius = 6;
+
+ public ExtremityCircle(Point2D p1) {
+ this.dest = new Point2D.Double(p1.getX(), p1.getY());
+ }
+
+ public void drawU(UGraphic ug) {
+ ug.apply(new UStroke(1.5)).apply(new UChangeBackColor(HtmlColorUtils.WHITE)).apply(new UTranslate(dest.getX() - radius, dest.getY() - radius)).draw(new UEllipse(radius * 2, radius * 2));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityCircleConnect.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityCircleConnect.java
new file mode 100644
index 0000000..ad27333
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityCircleConnect.java
@@ -0,0 +1,84 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.extremity;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class ExtremityCircleConnect extends Extremity {
+
+ private final double px;
+ private final double py;
+ private final Point2D dest;
+ private final double radius = 6;
+ private final double radius2 = 10;
+ private final double ortho;
+
+ public ExtremityCircleConnect(Point2D p1, double ortho) {
+ this.px = p1.getX() - radius;
+ this.py = p1.getY() - radius;
+ this.dest = new Point2D.Double(p1.getX(), p1.getY());
+ this.ortho = ortho;
+ }
+
+ public void drawU(UGraphic ug) {
+ ug = ug.apply(new UStroke(1.5)).apply(new UChangeBackColor(HtmlColorUtils.WHITE));
+ ug.apply(new UTranslate(dest.getX() - radius, dest.getY() - radius)).draw(new UEllipse(radius * 2, radius * 2));
+
+ final double deg = -ortho * 180 / Math.PI + 90 - 45;
+ final UEllipse arc1 = new UEllipse(2 * radius2, 2 * radius2, deg, 90);
+ ug.apply(new UTranslate(dest.getX() - radius2, dest.getY() - radius2)).draw(arc1);
+ }
+
+ // private Point2D getPointOnCircle(double angle) {
+ // final double x = px + radius + radius2 * Math.cos(angle);
+ // final double y = py + radius + radius2 * Math.sin(angle);
+ // return new Point2D.Double(x, y);
+ // }
+ //
+ // static private void drawLine(UGraphic ug, double x, double y, Point2D p1, Point2D p2) {
+ // final double dx = p2.getX() - p1.getX();
+ // final double dy = p2.getY() - p1.getY();
+ // ug.draw(x + p1.getX(), y + p1.getY(), new ULine(dx, dy));
+ //
+ // }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityCircleCross.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityCircleCross.java
new file mode 100644
index 0000000..c83beb8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityCircleCross.java
@@ -0,0 +1,80 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.extremity;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class ExtremityCircleCross extends Extremity {
+
+ private final double px;
+ private final double py;
+ private final Point2D dest;
+ private final double radius = 7;
+
+ public ExtremityCircleCross(Point2D p1) {
+ this.px = p1.getX() - radius;
+ this.py = p1.getY() - radius;
+ this.dest = new Point2D.Double(p1.getX(), p1.getY());
+ }
+
+ public void drawU(UGraphic ug) {
+ ug = ug.apply(new UChangeBackColor(HtmlColorUtils.WHITE));
+ ug.apply(new UStroke(1.5)).apply(new UTranslate(dest.getX() - radius, dest.getY() - radius)).draw(new UEllipse(radius * 2, radius * 2));
+ drawLine(ug, 0, 0, getPointOnCircle(Math.PI / 4), getPointOnCircle(Math.PI + Math.PI / 4));
+ drawLine(ug, 0, 0, getPointOnCircle(-Math.PI / 4), getPointOnCircle(Math.PI - Math.PI / 4));
+ }
+
+ private Point2D getPointOnCircle(double angle) {
+ final double x = px + radius + radius * Math.cos(angle);
+ final double y = py + radius + radius * Math.sin(angle);
+ return new Point2D.Double(x, y);
+ }
+
+ static private void drawLine(UGraphic ug, double x, double y, Point2D p1, Point2D p2) {
+ final double dx = p2.getX() - p1.getX();
+ final double dy = p2.getY() - p1.getY();
+ ug.apply(new UTranslate(x + p1.getX(), y + p1.getY())).draw(new ULine(dx, dy));
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityDiamond.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityDiamond.java
new file mode 100644
index 0000000..1d7a8d2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityDiamond.java
@@ -0,0 +1,69 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.extremity;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+
+class ExtremityDiamond extends Extremity {
+
+ private UPolygon polygon = new UPolygon();
+ private final boolean fill;
+
+ public ExtremityDiamond(Point2D p1, double angle, boolean fill) {
+ this.fill = fill;
+ angle = manageround(angle);
+ polygon.addPoint(0, 0);
+ final int xAile = 6;
+ final int yOuverture = 4;
+ polygon.addPoint(-xAile, -yOuverture);
+ polygon.addPoint(-xAile * 2, 0);
+ polygon.addPoint(-xAile, yOuverture);
+ polygon.addPoint(0, 0);
+ polygon.rotate(angle + Math.PI / 2);
+ polygon = polygon.translate(p1.getX(), p1.getY());
+ }
+
+ public void drawU(UGraphic ug) {
+ if (fill) {
+ ug = ug.apply(new UChangeBackColor(ug.getParam().getColor()));
+ }
+ ug.draw(polygon);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactory.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactory.java
new file mode 100644
index 0000000..00dbbb1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactory.java
@@ -0,0 +1,45 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.extremity;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.graphic.UDrawable;
+
+public interface ExtremityFactory {
+
+ public UDrawable createUDrawable(Point2D p0, Point2D p1, Point2D p2);
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryArrow.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryArrow.java
new file mode 100644
index 0000000..3788900
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryArrow.java
@@ -0,0 +1,49 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.extremity;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.svek.AbstractExtremityFactory;
+
+public class ExtremityFactoryArrow extends AbstractExtremityFactory implements ExtremityFactory {
+
+ public UDrawable createUDrawable(Point2D p0, Point2D p1, Point2D p2) {
+ final double ortho = atan2(p0, p2);
+ final Point2D center = new Point2D.Double((p0.getX() + p2.getX()) / 2, (p0.getY() + p2.getY()) / 2);
+ return new ExtremityArrow(p1, ortho, center);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryArrowAndCircle.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryArrowAndCircle.java
new file mode 100644
index 0000000..9e465e5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryArrowAndCircle.java
@@ -0,0 +1,49 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.extremity;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.svek.AbstractExtremityFactory;
+
+public class ExtremityFactoryArrowAndCircle extends AbstractExtremityFactory implements ExtremityFactory {
+
+ public UDrawable createUDrawable(Point2D p0, Point2D p1, Point2D p2) {
+ final double ortho = atan2(p0, p2);
+ final Point2D center = new Point2D.Double((p0.getX() + p2.getX()) / 2, (p0.getY() + p2.getY()) / 2);
+ return new ExtremityArrowAndCircle(p1, ortho, center);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryCircle.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryCircle.java
new file mode 100644
index 0000000..bc88051
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryCircle.java
@@ -0,0 +1,49 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.extremity;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.svek.AbstractExtremityFactory;
+
+public class ExtremityFactoryCircle extends AbstractExtremityFactory implements ExtremityFactory {
+
+ public UDrawable createUDrawable(Point2D p0, Point2D p1, Point2D p2) {
+ // final double ortho = atan2(p0, p2);
+ return new ExtremityCircle(p1);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryCircleConnect.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryCircleConnect.java
new file mode 100644
index 0000000..d145662
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryCircleConnect.java
@@ -0,0 +1,49 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.extremity;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.svek.AbstractExtremityFactory;
+
+public class ExtremityFactoryCircleConnect extends AbstractExtremityFactory implements ExtremityFactory {
+
+ public UDrawable createUDrawable(Point2D p0, Point2D p1, Point2D p2) {
+ final double ortho = atan2(p0, p2);
+ return new ExtremityCircleConnect(p1, ortho);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryCircleCross.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryCircleCross.java
new file mode 100644
index 0000000..d678f0b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryCircleCross.java
@@ -0,0 +1,49 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.extremity;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.svek.AbstractExtremityFactory;
+
+public class ExtremityFactoryCircleCross extends AbstractExtremityFactory implements ExtremityFactory {
+
+ public UDrawable createUDrawable(Point2D p0, Point2D p1, Point2D p2) {
+ // final double ortho = atan2(p0, p2);
+ return new ExtremityCircleCross(p1);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryDiamond.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryDiamond.java
new file mode 100644
index 0000000..8b3effa
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryDiamond.java
@@ -0,0 +1,54 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.extremity;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.svek.AbstractExtremityFactory;
+
+public class ExtremityFactoryDiamond extends AbstractExtremityFactory implements ExtremityFactory {
+
+ private final boolean fill;
+
+ public ExtremityFactoryDiamond(boolean fill) {
+ this.fill = fill;
+ }
+ public UDrawable createUDrawable(Point2D p0, Point2D p1, Point2D p2) {
+ final double ortho = atan2(p0, p2);
+ return new ExtremityDiamond(p1, ortho, fill);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryParenthesis.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryParenthesis.java
new file mode 100644
index 0000000..78e00cf
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryParenthesis.java
@@ -0,0 +1,54 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.extremity;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.OptionFlags;
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.svek.AbstractExtremityFactory;
+
+public class ExtremityFactoryParenthesis extends AbstractExtremityFactory implements ExtremityFactory {
+
+ public UDrawable createUDrawable(Point2D p0, Point2D p1, Point2D p2) {
+ final double ortho = atan2(p0, p2);
+ if (OptionFlags.USE_INTERFACE_EYE2) {
+ final Point2D center = new Point2D.Double((p0.getX() + p2.getX()) / 2, (p0.getY() + p2.getY()) / 2);
+ return new ExtremityParenthesis2(center, ortho, p1);
+ }
+ return new ExtremityParenthesis(p1, ortho);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryPlus.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryPlus.java
new file mode 100644
index 0000000..ff5bf90
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryPlus.java
@@ -0,0 +1,49 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.extremity;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.svek.AbstractExtremityFactory;
+
+public class ExtremityFactoryPlus extends AbstractExtremityFactory implements ExtremityFactory {
+
+ public UDrawable createUDrawable(Point2D p0, Point2D p1, Point2D p2) {
+ final double ortho = atan2(p0, p2);
+ return new ExtremityPlus(p1, ortho);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactorySquarre.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactorySquarre.java
new file mode 100644
index 0000000..f55138e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactorySquarre.java
@@ -0,0 +1,49 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.extremity;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.svek.AbstractExtremityFactory;
+
+public class ExtremityFactorySquarre extends AbstractExtremityFactory implements ExtremityFactory {
+
+ public UDrawable createUDrawable(Point2D p0, Point2D p1, Point2D p2) {
+ // final double ortho = atan2(p0, p2);
+ return new ExtremitySquarre(p1);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryTriangle.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryTriangle.java
new file mode 100644
index 0000000..a5e18a3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryTriangle.java
@@ -0,0 +1,50 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.extremity;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.svek.AbstractExtremityFactory;
+
+public class ExtremityFactoryTriangle extends AbstractExtremityFactory implements ExtremityFactory {
+
+
+ public UDrawable createUDrawable(Point2D p0, Point2D p1, Point2D p2) {
+ final double ortho = atan2(p0, p2);
+ return new ExtremityTriangle(p1, ortho, true);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityParenthesis.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityParenthesis.java
new file mode 100644
index 0000000..523d1cc
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityParenthesis.java
@@ -0,0 +1,63 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.extremity;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class ExtremityParenthesis extends Extremity {
+
+ private final Point2D dest;
+ private final double radius2 = 9;
+ private final double ortho;
+
+ private final double ang = 70;
+
+ public ExtremityParenthesis(Point2D p1, double ortho) {
+ this.dest = new Point2D.Double(p1.getX(), p1.getY());
+ this.ortho = ortho;
+ }
+
+ public void drawU(UGraphic ug) {
+ final double deg = -ortho * 180 / Math.PI + 90 - ang;
+ final UEllipse arc1 = new UEllipse(2 * radius2, 2 * radius2, deg, 2 * ang);
+ ug.apply(new UStroke(1.5)).apply(new UTranslate(dest.getX() - radius2, dest.getY() - radius2)).draw(arc1);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityParenthesis2.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityParenthesis2.java
new file mode 100644
index 0000000..00c82ce
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityParenthesis2.java
@@ -0,0 +1,84 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.extremity;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.svek.image.EntityImageLollipopInterfaceEye2;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class ExtremityParenthesis2 extends Extremity {
+
+ private final Point2D contact;
+ private final Point2D center;
+
+ private final double ortho;
+ private final double ang = 30;
+
+ public ExtremityParenthesis2(Point2D contact, double ortho, Point2D p1) {
+ this.contact = new Point2D.Double(contact.getX(), contact.getY());
+ this.ortho = ortho;
+ final double dx = p1.getX() - contact.getX();
+ final double dy = p1.getY() - contact.getY();
+ final double distance1 = Math.round(contact.distance(p1));
+ // System.err.println("distance=" + distance1);
+ final double len = Math.round(distance1 + EntityImageLollipopInterfaceEye2.SIZE / 2);
+ this.center = new Point2D.Double(contact.getX() + dx / distance1 * len, contact.getY() + dy / distance1 * len);
+ }
+
+ public void drawU(UGraphic ug) {
+ final double deg = -ortho * 180 / Math.PI + 90 - ang;
+ // final Point2D other = new Point2D.Double(contact.getX() + 10 * Math.cos(deg), contact.getY() + 10
+ // * Math.sin(deg));
+ // final ULine line = new ULine(1, 1);
+ // ug.apply(new UChangeColor(HtmlColorUtils.GREEN)).apply(new UTranslate(contact.getX(), contact.getY()))
+ // .draw(line);
+ // ug.apply(new UChangeColor(HtmlColorUtils.BLACK)).apply(new UTranslate(center.getX(),
+ // center.getY())).draw(line);
+ // // final UEllipse arc1 = new UEllipse(2 * radius2, 2 * radius2, deg, 2 * ang);
+ // // ug.apply(new UStroke(1.5)).apply(new UTranslate(dest.getX() - radius2, dest.getY() - radius2)).draw(arc1);
+ //
+ final double size = Math.round(contact.distance(center));
+ // System.err.println("size=" + size);
+ final UEllipse circle = new UEllipse(size * 2, size * 2, deg, 2 * ang);
+ ug.apply(new UTranslate(center.getX() - size, center.getY() - size)).draw(circle);
+
+ }
+}
diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityPlus.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityPlus.java
new file mode 100644
index 0000000..520091c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityPlus.java
@@ -0,0 +1,80 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.extremity;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class ExtremityPlus extends Extremity {
+
+ private final UEllipse circle;
+ private final double px;
+ private final double py;
+ private final double radius = 8;
+ private final double angle;
+
+ public ExtremityPlus(Point2D p1, double angle) {
+ this.angle = angle;
+ this.circle = new UEllipse(2 * radius, 2 * radius);
+ this.px = p1.getX() - radius + radius * Math.sin(angle);
+ this.py = p1.getY() - radius - radius * Math.cos(angle);
+ }
+
+ public void drawU(UGraphic ug) {
+ ug.apply(new UChangeBackColor(HtmlColorUtils.WHITE)).apply(new UTranslate(px + 0, py + 0)).draw(circle);
+ drawLine(ug, 0, 0, getPointOnCircle(angle - Math.PI / 2), getPointOnCircle(angle + Math.PI / 2));
+ drawLine(ug, 0, 0, getPointOnCircle(angle), getPointOnCircle(angle + Math.PI));
+ }
+
+ private Point2D getPointOnCircle(double angle) {
+ final double x = px + radius + radius * Math.cos(angle);
+ final double y = py + radius + radius * Math.sin(angle);
+ return new Point2D.Double(x, y);
+ }
+
+ static private void drawLine(UGraphic ug, double x, double y, Point2D p1, Point2D p2) {
+ final double dx = p2.getX() - p1.getX();
+ final double dy = p2.getY() - p1.getY();
+ ug.apply(new UTranslate(x + p1.getX(), y + p1.getY())).draw(new ULine(dx, dy));
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremitySquarre.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremitySquarre.java
new file mode 100644
index 0000000..56c567b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremitySquarre.java
@@ -0,0 +1,59 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.extremity;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class ExtremitySquarre extends Extremity {
+
+ private final Point2D dest;
+ private final double radius = 5;
+
+ public ExtremitySquarre(Point2D p1) {
+ this.dest = new Point2D.Double(p1.getX(), p1.getY());
+ }
+
+ public void drawU(UGraphic ug) {
+ ug.apply(new UStroke(1.5)).apply(new UChangeBackColor(HtmlColorUtils.WHITE)).apply(new UTranslate(dest.getX() - radius, dest.getY() - radius)).draw(new URectangle(radius * 2, radius * 2));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityStateLine1.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityStateLine1.java
new file mode 100644
index 0000000..5405b12
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityStateLine1.java
@@ -0,0 +1,93 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.extremity;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class ExtremityStateLine1 extends Extremity {
+
+ private UPolygon polygon = new UPolygon();
+ private final Point2D dest;
+ private final double radius = 7;
+ private final double angle;
+
+ public ExtremityStateLine1(double angle, Point2D center) {
+ this.angle = manageround(angle);
+ polygon.addPoint(0, 0);
+ this.dest = new Point2D.Double(center.getX(), center.getY());
+ final int xAile = 9;
+ final int yOuverture = 4;
+ polygon.addPoint(-xAile, -yOuverture);
+ final int xContact = 5;
+ polygon.addPoint(-xContact, 0);
+ polygon.addPoint(-xAile, yOuverture);
+ polygon.addPoint(0, 0);
+ polygon.rotate(this.angle);
+ polygon = polygon.translate(center.getX(), center.getY());
+ }
+
+ public void drawU(UGraphic ug) {
+ ug.apply(new UChangeBackColor(ug.getParam().getColor())).apply(new UTranslate(-radius * Math.cos(angle), -radius * Math.sin(angle))).draw(polygon);
+ ug = ug.apply(new UChangeBackColor(HtmlColorUtils.WHITE));
+ ug.apply(new UStroke(1.5)).apply(new UTranslate(dest.getX() - radius, dest.getY() - radius)).draw(new UEllipse(radius * 2, radius * 2));
+ drawLine(ug, getPointOnCircle(dest.getX(), dest.getY(), Math.PI / 4),
+ getPointOnCircle(dest.getX(), dest.getY(), Math.PI + Math.PI / 4));
+ drawLine(ug, getPointOnCircle(dest.getX(), dest.getY(), -Math.PI / 4),
+ getPointOnCircle(dest.getX(), dest.getY(), Math.PI - Math.PI / 4));
+ }
+
+ private Point2D getPointOnCircle(double centerX, double centerY, double angle) {
+ final double x = centerX + radius * Math.cos(angle);
+ final double y = centerY + radius * Math.sin(angle);
+ return new Point2D.Double(x, y);
+ }
+
+ static private void drawLine(UGraphic ug, Point2D p1, Point2D p2) {
+ final double dx = p2.getX() - p1.getX();
+ final double dy = p2.getY() - p1.getY();
+ ug.apply(new UTranslate(p1.getX(), p1.getY())).draw(new ULine(dx, dy));
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityStateLine2.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityStateLine2.java
new file mode 100644
index 0000000..0b9af5f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityStateLine2.java
@@ -0,0 +1,74 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.extremity;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class ExtremityStateLine2 extends Extremity {
+
+ private UPolygon polygon = new UPolygon();
+ private final Point2D dest;
+ private final double radius = 5;
+ private final double angle;
+
+ public ExtremityStateLine2(double angle, Point2D center) {
+ this.angle = manageround(angle);
+ polygon.addPoint(0, 0);
+ this.dest = new Point2D.Double(center.getX(), center.getY());
+ final int xAile = 9;
+ final int yOuverture = 4;
+ polygon.addPoint(-xAile, -yOuverture);
+ final int xContact = 5;
+ polygon.addPoint(-xContact, 0);
+ polygon.addPoint(-xAile, yOuverture);
+ polygon.addPoint(0, 0);
+ polygon.rotate(this.angle);
+ polygon = polygon.translate(center.getX(), center.getY());
+ }
+
+ public void drawU(UGraphic ug) {
+ ug.apply(new UChangeBackColor(ug.getParam().getColor())).apply(new UTranslate(-radius * Math.cos(angle), -radius * Math.sin(angle))).draw(polygon);
+ ug.apply(new UStroke(1.5)).apply(new UChangeBackColor(HtmlColorUtils.WHITE)).apply(new UTranslate(dest.getX() - radius, dest.getY() - radius)).draw(new UEllipse(radius * 2, radius * 2));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityTriangle.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityTriangle.java
new file mode 100644
index 0000000..33a2eb0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityTriangle.java
@@ -0,0 +1,68 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.extremity;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+
+class ExtremityTriangle extends Extremity {
+
+ private UPolygon polygon = new UPolygon();
+ private final boolean fill;
+
+ public ExtremityTriangle(Point2D p1, double angle, boolean fill) {
+ this.fill = fill;
+ angle = manageround(angle);
+ polygon.addPoint(0, 0);
+ final int xAile = 8;
+ final int yOuverture = 3;
+ polygon.addPoint(-xAile, -yOuverture);
+ polygon.addPoint(-xAile, yOuverture);
+ polygon.addPoint(0, 0);
+ polygon.rotate(angle + Math.PI / 2);
+ polygon = polygon.translate(p1.getX(), p1.getY());
+ }
+
+ public void drawU(UGraphic ug) {
+ if (fill) {
+ ug = ug.apply(new UChangeBackColor(ug.getParam().getColor()));
+ }
+ ug.draw(polygon);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/extremity/MiddleCircle.java b/src/net/sourceforge/plantuml/svek/extremity/MiddleCircle.java
new file mode 100644
index 0000000..7be7dac
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/extremity/MiddleCircle.java
@@ -0,0 +1,53 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.extremity;
+
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class MiddleCircle extends Extremity {
+
+ private final double radius = 6;
+ private final UEllipse circle = new UEllipse(2 * radius, 2 * radius);
+
+ public void drawU(UGraphic ug) {
+ ug.apply(new UChangeBackColor(HtmlColorUtils.WHITE)).apply(new UStroke(1.5)).apply(new UTranslate(-radius, -radius)).draw(circle);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/extremity/MiddleCircleCircled.java b/src/net/sourceforge/plantuml/svek/extremity/MiddleCircleCircled.java
new file mode 100644
index 0000000..cabf357
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/extremity/MiddleCircleCircled.java
@@ -0,0 +1,80 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.extremity;
+
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class MiddleCircleCircled extends Extremity {
+
+ private final double angle;
+ private final MiddleCircleCircledMode mode;
+ private final double radius1 = 6;
+ private final UEllipse circle = new UEllipse(2 * radius1, 2 * radius1);
+
+ private final double radius2 = 10;
+ private final UEllipse bigcircle = new UEllipse(2 * radius2, 2 * radius2);
+
+ public MiddleCircleCircled(double angle, MiddleCircleCircledMode mode) {
+ this.angle = angle;
+ this.mode = mode;
+ }
+
+ public void drawU(UGraphic ug) {
+ ug = ug.apply(new UChangeBackColor(HtmlColorUtils.WHITE));
+ if (mode == MiddleCircleCircledMode.BOTH) {
+ ug.apply(new UChangeColor(HtmlColorUtils.WHITE)).apply(new UTranslate(-radius2, -radius2)).draw(bigcircle);
+ }
+
+ ug = ug.apply(new UStroke(1.5));
+
+ final double d = 0;
+ if (mode == MiddleCircleCircledMode.MODE1 || mode == MiddleCircleCircledMode.BOTH) {
+ final UEllipse arc1 = new UEllipse(2 * radius2, 2 * radius2, angle, 90);
+ ug.apply(new UTranslate(-radius2 + d, -radius2 + d)).draw(arc1);
+ }
+ if (mode == MiddleCircleCircledMode.MODE2 || mode == MiddleCircleCircledMode.BOTH) {
+ final UEllipse arc2 = new UEllipse(2 * radius2, 2 * radius2, angle + 180, 90);
+ ug.apply(new UTranslate(-radius2 + d, -radius2 + d)).draw(arc2);
+ }
+ ug.apply(new UTranslate(-radius1, -radius1)).draw(circle);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/extremity/MiddleCircleCircledMode.java b/src/net/sourceforge/plantuml/svek/extremity/MiddleCircleCircledMode.java
new file mode 100644
index 0000000..d658f44
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/extremity/MiddleCircleCircledMode.java
@@ -0,0 +1,41 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.extremity;
+
+public enum MiddleCircleCircledMode {
+
+ BOTH, MODE1, MODE2
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/extremity/MiddleFactory.java b/src/net/sourceforge/plantuml/svek/extremity/MiddleFactory.java
new file mode 100644
index 0000000..4b583d7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/extremity/MiddleFactory.java
@@ -0,0 +1,43 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.extremity;
+
+import net.sourceforge.plantuml.graphic.UDrawable;
+
+public interface MiddleFactory {
+
+ public UDrawable createUDrawable(double angle);
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/extremity/MiddleFactoryCircle.java b/src/net/sourceforge/plantuml/svek/extremity/MiddleFactoryCircle.java
new file mode 100644
index 0000000..9168cb0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/extremity/MiddleFactoryCircle.java
@@ -0,0 +1,45 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.extremity;
+
+import net.sourceforge.plantuml.graphic.UDrawable;
+
+public class MiddleFactoryCircle implements MiddleFactory {
+
+ public UDrawable createUDrawable(double angle) {
+ return new MiddleCircle();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/extremity/MiddleFactoryCircleCircled.java b/src/net/sourceforge/plantuml/svek/extremity/MiddleFactoryCircleCircled.java
new file mode 100644
index 0000000..9e64ae9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/extremity/MiddleFactoryCircleCircled.java
@@ -0,0 +1,51 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.extremity;
+
+import net.sourceforge.plantuml.graphic.UDrawable;
+
+public class MiddleFactoryCircleCircled implements MiddleFactory {
+
+ private final MiddleCircleCircledMode mode;
+
+ public MiddleFactoryCircleCircled(MiddleCircleCircledMode mode) {
+ this.mode = mode;
+ }
+
+ public UDrawable createUDrawable(double angle) {
+ return new MiddleCircleCircled(angle, mode);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/image/Circle.java b/src/net/sourceforge/plantuml/svek/image/Circle.java
new file mode 100644
index 0000000..a4a12fd
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/image/Circle.java
@@ -0,0 +1,97 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.image;
+
+import java.awt.geom.Point2D;
+
+public class Circle {
+
+ private Point2D center;
+
+ private double radius;
+
+ public Circle() {
+ this(new Point2D.Double());
+ }
+
+ public Circle(Point2D center) {
+ this.center = center;
+ this.radius = 0;
+ }
+
+ public Circle(Point2D p1, Point2D p2) {
+ center = new Point2D.Double((p1.getX() + p2.getX()) / 2, (p1.getY() + p2.getY()) / 2);
+ radius = p1.distance(center);
+ }
+
+ public static Circle getCircle(Point2D p1, Point2D p2, Point2D p3) {
+ if (p3.getY() != p2.getY()) {
+ return new Circle(p1, p2, p3);
+ }
+ return new Circle(p2, p1, p3);
+ }
+
+
+ private Circle(Point2D p1, Point2D p2, Point2D p3) {
+ final double num1 = p3.getX() * p3.getX() * (p1.getY() - p2.getY())
+ + (p1.getX() * p1.getX() + (p1.getY() - p2.getY()) * (p1.getY() - p3.getY())) * (p2.getY() - p3.getY())
+ + p2.getX() * p2.getX() * (-p1.getY() + p3.getY());
+ final double den1 = 2 * (p3.getX() * (p1.getY() - p2.getY()) + p1.getX() * (p2.getY() - p3.getY()) + p2.getX()
+ * (-p1.getY() + p3.getY()));
+ final double x = num1 / den1;
+ final double den2 = p3.getY() - p2.getY();
+ final double y = (p2.getY() + p3.getY()) / 2 - (p3.getX() - p2.getX()) / den2
+ * (x - (p2.getX() + p3.getX()) / 2);
+ center = new Point2D.Double(x, y);
+ radius = center.distance(p1);
+ }
+
+ public Point2D getCenter() {
+ return center;
+ }
+
+ public double getRadius() {
+ return radius;
+ }
+
+ public boolean isOutside(Point2D point) {
+ final double d = center.distance(point);
+ if (d > radius) {
+ return true;
+ }
+ return false;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/image/ConnectedCircle.java b/src/net/sourceforge/plantuml/svek/image/ConnectedCircle.java
new file mode 100644
index 0000000..298eed2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/image/ConnectedCircle.java
@@ -0,0 +1,86 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.image;
+
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class ConnectedCircle implements UDrawable {
+
+ private final double radius;
+ private final List<Double> angles = new ArrayList<Double>();
+ private final List<Point2D> points = new ArrayList<Point2D>();
+
+ public ConnectedCircle(double radius) {
+ this.radius = radius;
+ }
+
+ public void drawU(UGraphic ug) {
+ final UEllipse circle = new UEllipse(2 * radius, 2 * radius);
+ // ug.draw(circle);
+ for (Double angle : angles) {
+ final double delta = 30;
+ final UEllipse part = new UEllipse(2 * radius, 2 * radius, angle - delta, 2 * delta);
+ ug.draw(part);
+ }
+ ug = ug.apply(new UChangeColor(HtmlColorUtils.GREEN)).apply(new UChangeBackColor(HtmlColorUtils.GREEN));
+ for (Point2D pt : points) {
+ final UTranslate tr = new UTranslate(pt);
+ // ug.apply(tr).draw(new UEllipse(2, 2));
+ }
+
+ }
+
+ public void addSecondaryConnection(Point2D pt) {
+ points.add(pt);
+ // double angle = Math.atan2(pt.getY() - radius, pt.getX() - radius);
+ // double angle = Math.atan2(pt.getX() - radius, pt.getY() - radius);
+ double angle = Math.atan2(radius - pt.getY(), pt.getX() - radius);
+ angle = angle * 180.0 / Math.PI;
+ System.err.println("pt1=" + pt + " " + angle);
+ angles.add(angle);
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/image/ContainingEllipse.java b/src/net/sourceforge/plantuml/svek/image/ContainingEllipse.java
new file mode 100644
index 0000000..50ea71a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/image/ContainingEllipse.java
@@ -0,0 +1,88 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.image;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+
+public class ContainingEllipse {
+
+ private final SmallestEnclosingCircle sec = new SmallestEnclosingCircle();
+ private final YTransformer ytransformer;
+
+ @Override
+ public String toString() {
+ return "ContainingEllipse " + getWidth() + " " + getHeight();
+ }
+
+ public ContainingEllipse(double coefY) {
+ ytransformer = new YTransformer(coefY);
+ }
+
+ public void append(Point2D pt) {
+ pt = ytransformer.getReversePoint2D(pt);
+ sec.append(pt);
+ }
+
+ public void append(double x, double y) {
+ append(new Point2D.Double(x, y));
+ }
+
+ public double getWidth() {
+ return 2 * sec.getCircle().getRadius();
+ }
+
+ public double getHeight() {
+ return 2 * sec.getCircle().getRadius() * ytransformer.getAlpha();
+ }
+
+ public Point2D getCenter() {
+ return ytransformer.getPoint2D(sec.getCircle().getCenter());
+ }
+
+ public UEllipse asUEllipse() {
+ final UEllipse ellipse = new UEllipse(getWidth(), getHeight());
+ ellipse.setDeltaShadow(deltaShadow);
+ return ellipse;
+ }
+
+ private double deltaShadow;
+
+ public void setDeltaShadow(double deltaShadow) {
+ this.deltaShadow = deltaShadow;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageActivity.java b/src/net/sourceforge/plantuml/svek/image/EntityImageActivity.java
new file mode 100644
index 0000000..f918a56
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/image/EntityImageActivity.java
@@ -0,0 +1,159 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.image;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.SkinParamUtils;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.svek.AbstractEntityImage;
+import net.sourceforge.plantuml.svek.Bibliotekon;
+import net.sourceforge.plantuml.svek.Shape;
+import net.sourceforge.plantuml.svek.ShapeType;
+import net.sourceforge.plantuml.ugraphic.Shadowable;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class EntityImageActivity extends AbstractEntityImage {
+
+ public static final int CORNER = 25;
+ final private TextBlock desc;
+ final private static int MARGIN = 10;
+ final private Url url;
+ private final Bibliotekon bibliotekon;
+
+ public EntityImageActivity(ILeaf entity, ISkinParam skinParam, Bibliotekon bibliotekon) {
+ super(entity, skinParam);
+ this.bibliotekon = bibliotekon;
+ final Stereotype stereotype = entity.getStereotype();
+
+ this.desc = TextBlockUtils.create(entity.getDisplay(),
+ new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), FontParam.ACTIVITY, stereotype), SkinParamUtils.getFontColor(getSkinParam(), FontParam.ACTIVITY, stereotype),
+ getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()),
+ HorizontalAlignment.CENTER, skinParam);
+ this.url = entity.getUrl99();
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dim = desc.calculateDimension(stringBounder);
+ return Dimension2DDouble.delta(dim, MARGIN * 2);
+ }
+
+ final public void drawU(UGraphic ug) {
+ if (url != null) {
+ ug.startUrl(url);
+ }
+ if (getShapeType() == ShapeType.ROUND_RECTANGLE) {
+ ug = drawNormal(ug);
+ } else if (getShapeType() == ShapeType.OCTAGON) {
+ ug = drawOctagon(ug);
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ if (url != null) {
+ ug.closeAction();
+ }
+ }
+
+ private UGraphic drawOctagon(UGraphic ug) {
+ final Shape shape = bibliotekon.getShape(getEntity());
+ final Shadowable octagon = shape.getOctagon();
+ if (getSkinParam().shadowing()) {
+ octagon.setDeltaShadow(4);
+ }
+ ug = applyColors(ug);
+ ug.apply(new UStroke(1.5)).draw(octagon);
+ desc.drawU(ug.apply(new UTranslate(MARGIN, MARGIN)));
+ return ug;
+
+ }
+
+ private UGraphic drawNormal(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D dimTotal = calculateDimension(stringBounder);
+
+ final double widthTotal = dimTotal.getWidth();
+ final double heightTotal = dimTotal.getHeight();
+ final Shadowable rect = new URectangle(widthTotal, heightTotal, CORNER, CORNER);
+ if (getSkinParam().shadowing()) {
+ rect.setDeltaShadow(4);
+ }
+
+ ug = applyColors(ug);
+ ug.apply(new UStroke(1.5)).draw(rect);
+
+ desc.drawU(ug.apply(new UTranslate(MARGIN, MARGIN)));
+ return ug;
+ }
+
+ private UGraphic applyColors(UGraphic ug) {
+ ug = ug.apply(new UChangeColor(SkinParamUtils.getColor(getSkinParam(), ColorParam.activityBorder, getStereo())));
+ HtmlColor backcolor = getEntity().getSpecificBackColor();
+ if (backcolor == null) {
+ backcolor = SkinParamUtils.getColor(getSkinParam(), ColorParam.activityBackground, getStereo());
+ }
+ ug = ug.apply(new UChangeBackColor(backcolor));
+ return ug;
+ }
+
+ public ShapeType getShapeType() {
+ final Stereotype stereotype = getStereo();
+ if (getSkinParam().useOctagonForActivity(stereotype)) {
+ return ShapeType.OCTAGON;
+ }
+ return ShapeType.ROUND_RECTANGLE;
+ }
+
+ public int getShield() {
+ return 0;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageArcCircle.java b/src/net/sourceforge/plantuml/svek/image/EntityImageArcCircle.java
new file mode 100644
index 0000000..c023fce
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/image/EntityImageArcCircle.java
@@ -0,0 +1,124 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.image;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.SkinParamUtils;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+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;
+import net.sourceforge.plantuml.svek.AbstractEntityImage;
+import net.sourceforge.plantuml.svek.ShapeType;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class EntityImageArcCircle extends AbstractEntityImage {
+
+ // private static final int SIZE = 16;
+
+ private final TextBlock name;
+ private final TextBlock stereo;
+
+ public EntityImageArcCircle(ILeaf entity, ISkinParam skinParam) {
+ super(entity, skinParam);
+
+ final Stereotype stereotype = entity.getStereotype();
+
+ this.name = TextBlockUtils.create(
+ entity.getDisplay(),
+ new FontConfiguration(SkinParamUtils.getFont(getSkinParam(),
+ FontParam.COMPONENT, stereotype), SkinParamUtils.getFontColor(getSkinParam(),
+ FontParam.COMPONENT, stereotype), getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.CENTER, skinParam);
+
+ if (stereotype == null || stereotype.getLabel(false) == null) {
+ this.stereo = null;
+ } else {
+ this.stereo = TextBlockUtils.create(
+ Display.getWithNewlines(stereotype.getLabel(getSkinParam().useGuillemet())),
+ new FontConfiguration(SkinParamUtils.getFont(getSkinParam(),
+ FontParam.COMPONENT_STEREOTYPE, stereotype), SkinParamUtils.getFontColor(getSkinParam(),
+ FontParam.COMPONENT_STEREOTYPE, null), getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.CENTER, skinParam);
+ }
+
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dimName = name.calculateDimension(stringBounder);
+ final Dimension2D dimStereo = getStereoDimension(stringBounder);
+ // final Dimension2D circle = new Dimension2DDouble(SIZE, SIZE);
+ return Dimension2DDouble.mergeTB(dimStereo, dimName);
+ }
+
+ private Dimension2D getStereoDimension(StringBounder stringBounder) {
+ if (stereo == null) {
+ return new Dimension2DDouble(0, 0);
+ }
+ return stereo.calculateDimension(stringBounder);
+ }
+
+ final public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D dimStereo = getStereoDimension(stringBounder);
+ final Dimension2D dimTotal = calculateDimension(stringBounder);
+ final Dimension2D dimName = name.calculateDimension(stringBounder);
+
+ final double nameX = (dimTotal.getWidth() - dimName.getWidth()) / 2;
+ final double nameY = dimStereo.getHeight();
+ name.drawU(ug.apply(new UTranslate(nameX, nameY)));
+
+ if (stereo != null) {
+ final double stereoX = (dimTotal.getWidth() - dimStereo.getWidth()) / 2;
+ stereo.drawU(ug.apply(new UTranslate(stereoX, 0)));
+ }
+ }
+
+ public ShapeType getShapeType() {
+ return ShapeType.RECTANGLE;
+ }
+
+ public int getShield() {
+ return 0;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageAssociation.java b/src/net/sourceforge/plantuml/svek/image/EntityImageAssociation.java
new file mode 100644
index 0000000..a8c4d98
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/image/EntityImageAssociation.java
@@ -0,0 +1,89 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.image;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.SkinParamUtils;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.svek.AbstractEntityImage;
+import net.sourceforge.plantuml.svek.ShapeType;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+
+public class EntityImageAssociation extends AbstractEntityImage {
+
+ final private static int SIZE = 12;
+
+ public EntityImageAssociation(ILeaf entity, ISkinParam skinParam) {
+ super(entity, skinParam);
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(SIZE * 2, SIZE * 2);
+ }
+
+ final public void drawU(UGraphic ug) {
+ final UPolygon diams = new UPolygon();
+ if (getSkinParam().shadowing()) {
+ diams.setDeltaShadow(5);
+ }
+ diams.addPoint(SIZE, 0);
+ diams.addPoint(SIZE * 2, SIZE);
+ diams.addPoint(SIZE, SIZE * 2);
+ diams.addPoint(0, SIZE);
+ diams.addPoint(SIZE, 0);
+
+ ug.apply(new UChangeColor(SkinParamUtils.getColor(getSkinParam(), ColorParam.classBorder, getStereo())))
+ .apply(new UChangeBackColor(SkinParamUtils.getColor(getSkinParam(), ColorParam.classBackground,
+ getStereo()))).apply(new UStroke(1.5)).draw(diams);
+ }
+
+ public ShapeType getShapeType() {
+ return ShapeType.DIAMOND;
+ }
+
+ public int getShield() {
+ return 0;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageAssociationPoint.java b/src/net/sourceforge/plantuml/svek/image/EntityImageAssociationPoint.java
new file mode 100644
index 0000000..607174f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/image/EntityImageAssociationPoint.java
@@ -0,0 +1,77 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.image;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.svek.AbstractEntityImage;
+import net.sourceforge.plantuml.svek.ShapeType;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class EntityImageAssociationPoint extends AbstractEntityImage {
+
+ private static final int SIZE = 4;
+
+ public EntityImageAssociationPoint(ILeaf entity, ISkinParam skinParam) {
+ super(entity, skinParam);
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(SIZE, SIZE);
+ }
+
+ final public void drawU(UGraphic ug) {
+ final UShape circle = new UEllipse(SIZE, SIZE);
+ ug.apply(new UChangeColor(null)).apply(new UChangeBackColor(HtmlColorUtils.BLACK)).draw(circle);
+ }
+
+ public ShapeType getShapeType() {
+ return ShapeType.CIRCLE;
+ }
+
+ public int getShield() {
+ return 0;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageBranch.java b/src/net/sourceforge/plantuml/svek/image/EntityImageBranch.java
new file mode 100644
index 0000000..9d4987d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/image/EntityImageBranch.java
@@ -0,0 +1,89 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.image;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.SkinParamUtils;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.svek.AbstractEntityImage;
+import net.sourceforge.plantuml.svek.ShapeType;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+
+public class EntityImageBranch extends AbstractEntityImage {
+
+ final private static int SIZE = 12;
+
+ public EntityImageBranch(ILeaf entity, ISkinParam skinParam) {
+ super(entity, skinParam);
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(SIZE * 2, SIZE * 2);
+ }
+
+ final public void drawU(UGraphic ug) {
+ final UPolygon diams = new UPolygon();
+ if (getSkinParam().shadowing()) {
+ diams.setDeltaShadow(5);
+ }
+ diams.addPoint(SIZE, 0);
+ diams.addPoint(SIZE * 2, SIZE);
+ diams.addPoint(SIZE, SIZE * 2);
+ diams.addPoint(0, SIZE);
+ diams.addPoint(SIZE, 0);
+
+ ug.apply(new UChangeColor(SkinParamUtils.getColor(getSkinParam(), ColorParam.activityBorder, getStereo())))
+ .apply(new UChangeBackColor(SkinParamUtils.getColor(getSkinParam(), ColorParam.activityBackground,
+ getStereo()))).apply(new UStroke(1.5)).draw(diams);
+ }
+
+ public ShapeType getShapeType() {
+ return ShapeType.DIAMOND;
+ }
+
+ public int getShield() {
+ return 0;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageCircleEnd.java b/src/net/sourceforge/plantuml/svek/image/EntityImageCircleEnd.java
new file mode 100644
index 0000000..4005d98
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/image/EntityImageCircleEnd.java
@@ -0,0 +1,91 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.image;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.SkinParamUtils;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.svek.AbstractEntityImage;
+import net.sourceforge.plantuml.svek.ShapeType;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class EntityImageCircleEnd extends AbstractEntityImage {
+
+ private static final int SIZE = 20;
+ private final ColorParam param;
+
+ public EntityImageCircleEnd(ILeaf entity, ISkinParam skinParam, ColorParam param) {
+ super(entity, skinParam);
+ this.param = param;
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(SIZE, SIZE);
+ }
+
+ final public void drawU(UGraphic ug) {
+ final UEllipse circle = new UEllipse(SIZE, SIZE);
+ if (getSkinParam().shadowing()) {
+ circle.setDeltaShadow(3);
+ }
+ ug.apply(new UChangeBackColor(null))
+ .apply(new UChangeColor(SkinParamUtils.getColor(getSkinParam(), param, getStereo())))
+ .draw(circle);
+
+ final double delta = 4;
+ final UShape circleSmall = new UEllipse(SIZE - delta * 2, SIZE - delta * 2);
+ ug.apply(new UChangeBackColor(SkinParamUtils.getColor(getSkinParam(), param, getStereo())))
+ .apply(new UChangeColor(null)).apply(new UTranslate(delta + 0.5, delta + 0.5)).draw(circleSmall);
+ }
+
+ public ShapeType getShapeType() {
+ return ShapeType.CIRCLE;
+ }
+
+ public int getShield() {
+ return 0;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageCircleStart.java b/src/net/sourceforge/plantuml/svek/image/EntityImageCircleStart.java
new file mode 100644
index 0000000..fa4c1bf
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/image/EntityImageCircleStart.java
@@ -0,0 +1,83 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.image;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.SkinParamUtils;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.svek.AbstractEntityImage;
+import net.sourceforge.plantuml.svek.ShapeType;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class EntityImageCircleStart extends AbstractEntityImage {
+
+ private static final int SIZE = 20;
+ private final ColorParam colorParam; // = ColorParam.activityStart;
+
+ public EntityImageCircleStart(ILeaf entity, ISkinParam skinParam, ColorParam colorParam) {
+ super(entity, skinParam);
+ this.colorParam = colorParam;
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(SIZE, SIZE);
+ }
+
+ final public void drawU(UGraphic ug) {
+ final UEllipse circle = new UEllipse(SIZE, SIZE);
+ if (getSkinParam().shadowing()) {
+ circle.setDeltaShadow(3);
+ }
+ ug.apply(new UChangeBackColor(SkinParamUtils.getColor(getSkinParam(), colorParam, getStereo())))
+ .apply(new UChangeColor(null)).draw(circle);
+ }
+
+ public ShapeType getShapeType() {
+ return ShapeType.CIRCLE;
+ }
+
+ public int getShield() {
+ return 0;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageClass.java b/src/net/sourceforge/plantuml/svek/image/EntityImageClass.java
new file mode 100644
index 0000000..8329cb3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/image/EntityImageClass.java
@@ -0,0 +1,209 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.image;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.LineConfigurable;
+import net.sourceforge.plantuml.LineParam;
+import net.sourceforge.plantuml.SkinParamUtils;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.creole.Stencil;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.cucadiagram.PortionShower;
+import net.sourceforge.plantuml.cucadiagram.dot.GraphvizVersion;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.svek.AbstractEntityImage;
+import net.sourceforge.plantuml.svek.ShapeType;
+import net.sourceforge.plantuml.ugraphic.Shadowable;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UGraphicStencil;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class EntityImageClass extends AbstractEntityImage implements Stencil {
+
+ final private TextBlock body;
+ final private int shield;
+ final private EntityImageClassHeader2 header;
+ final private Url url;
+ final private TextBlock mouseOver;
+ final private double roundCorner;
+
+ final private LineConfigurable lineConfig;
+
+ public EntityImageClass(GraphvizVersion version, ILeaf entity, ISkinParam skinParam, PortionShower portionShower) {
+ super(entity, skinParam);
+ this.lineConfig = entity;
+ this.roundCorner = skinParam.getRoundCorner();
+ this.shield = version != null && version.useShield() && entity.hasNearDecoration() ? 16 : 0;
+ this.body = entity.getBody(portionShower).asTextBlock(FontParam.CLASS_ATTRIBUTE, skinParam);
+
+ header = new EntityImageClassHeader2(entity, skinParam, portionShower);
+ this.url = entity.getUrl99();
+ if (entity.getMouseOver() == null) {
+ this.mouseOver = null;
+ } else {
+ this.mouseOver = entity.getMouseOver().asTextBlock(FontParam.CLASS_ATTRIBUTE, skinParam);
+ }
+
+ }
+
+ // private int marginEmptyFieldsOrMethod = 13;
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dimHeader = header.calculateDimension(stringBounder);
+ final Dimension2D dimBody = body == null ? new Dimension2DDouble(0, 0) : body.calculateDimension(stringBounder);
+ double width = Math.max(dimBody.getWidth(), dimHeader.getWidth());
+ if (width < getSkinParam().minClassWidth()) {
+ width = getSkinParam().minClassWidth();
+ }
+ final double height = dimBody.getHeight() + dimHeader.getHeight();
+ return new Dimension2DDouble(width, height);
+ }
+
+ final public void drawU(UGraphic ug) {
+ if (url != null) {
+ ug.startUrl(url);
+ }
+ drawInternal(ug);
+ if (mouseOver != null) {
+ // final UGroup g = ug.createGroup();
+ // ug = ug.apply(new UChangeBackColor(SkinParamUtils.getColor(getSkinParam(), ColorParam.classBackground,
+ // getStereo())));
+ // final Dimension2D dim = mouseOver.calculateDimension(ug.getStringBounder());
+ // final Shadowable rect = new URectangle(dim.getWidth(), dim.getHeight());
+ // if (getSkinParam().shadowing()) {
+ // rect.setDeltaShadow(4);
+ // }
+ //
+ // final HtmlColor classBorder = SkinParamUtils.getColor(getSkinParam(), ColorParam.classBorder,
+ // getStereo());
+ // ug = ug.apply(
+ // new UChangeBackColor(SkinParamUtils.getColor(getSkinParam(), ColorParam.classBackground,
+ // getStereo()))).apply(new UChangeColor(classBorder));
+ //
+ // final double x = 30;
+ // final double y = 30;
+ // // ug.getParam().setStroke(new UStroke(1.5));
+ // // g.draw(x, y, rect);
+ // // ug.getParam().resetStroke();
+ // final UGraphic ug2 = new UGraphicHorizontalLine(ug, x, x + dim.getWidth(), getStroke());
+ // mouseOver.drawUNewWayINLINED(ug2.apply(new UTranslate(x, y)));
+ // g.close();
+ }
+
+ if (url != null) {
+ ug.closeAction();
+ }
+ }
+
+ private void drawInternal(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D dimTotal = calculateDimension(stringBounder);
+ final Dimension2D dimHeader = header.calculateDimension(stringBounder);
+
+ final double widthTotal = dimTotal.getWidth();
+ final double heightTotal = dimTotal.getHeight();
+ final Shadowable rect = new URectangle(widthTotal, heightTotal, roundCorner, roundCorner);
+ if (getSkinParam().shadowing()) {
+ rect.setDeltaShadow(4);
+ }
+
+ HtmlColor classBorder = lineConfig.getSpecificLineColor();
+ if (classBorder == null) {
+ classBorder = SkinParamUtils.getColor(getSkinParam(), ColorParam.classBorder, getStereo());
+ }
+ ug = ug.apply(new UChangeColor(classBorder));
+ HtmlColor backcolor = getEntity().getSpecificBackColor();
+ if (backcolor == null) {
+ backcolor = SkinParamUtils.getColor(getSkinParam(), ColorParam.classBackground, getStereo());
+ }
+ ug = ug.apply(new UChangeBackColor(backcolor));
+
+ final UStroke stroke = getStroke();
+ ug.apply(stroke).draw(rect);
+
+ final HtmlColor headerBackcolor = getSkinParam().getHtmlColor(ColorParam.classHeaderBackground, getStereo(), false);
+ if (headerBackcolor != null) {
+ final Shadowable rect2 = new URectangle(widthTotal, dimHeader.getHeight());
+ ug.apply(new UChangeBackColor(headerBackcolor)).apply(stroke).draw(rect2);
+ }
+ header.drawU(ug, dimTotal.getWidth(), dimHeader.getHeight());
+
+ if (body != null) {
+ final UGraphic ug2 = new UGraphicStencil(ug, this, stroke);
+ body.drawU(ug2.apply(new UTranslate(0, dimHeader.getHeight())));
+ }
+ }
+
+ private UStroke getStroke() {
+ UStroke stroke = lineConfig.getSpecificLineStroke();
+ if (stroke == null) {
+ stroke = getSkinParam().getThickness(LineParam.classBorder, getStereo());
+ }
+ if (stroke == null) {
+ stroke = new UStroke(1.5);
+ }
+ return stroke;
+ }
+
+ public ShapeType getShapeType() {
+ return ShapeType.RECTANGLE;
+ }
+
+ public int getShield() {
+ return shield;
+ }
+
+ public double getStartingX(StringBounder stringBounder, double y) {
+ return 0;
+ }
+
+ public double getEndingX(StringBounder stringBounder, double y) {
+ return calculateDimension(stringBounder).getWidth();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageClassHeader2.java b/src/net/sourceforge/plantuml/svek/image/EntityImageClassHeader2.java
new file mode 100644
index 0000000..eedca73
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/image/EntityImageClassHeader2.java
@@ -0,0 +1,185 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.image;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.SkinParamUtils;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.EntityPortion;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.cucadiagram.LeafType;
+import net.sourceforge.plantuml.cucadiagram.PortionShower;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.graphic.CircledCharacter;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockGeneric;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.svek.AbstractEntityImage;
+import net.sourceforge.plantuml.svek.HeaderLayout;
+import net.sourceforge.plantuml.svek.ShapeType;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class EntityImageClassHeader2 extends AbstractEntityImage {
+
+ final private HeaderLayout headerLayout;
+
+ public EntityImageClassHeader2(ILeaf entity, ISkinParam skinParam, PortionShower portionShower) {
+ super(entity, skinParam);
+
+ final boolean italic = entity.getEntityType() == LeafType.ABSTRACT_CLASS
+ || entity.getEntityType() == LeafType.INTERFACE;
+
+ final HtmlColor color = SkinParamUtils.getFontColor(getSkinParam(), FontParam.CLASS, getStereo());
+ final Stereotype stereotype = entity.getStereotype();
+ final String generic = entity.getGeneric();
+ FontConfiguration fontConfigurationName = new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), FontParam.CLASS, stereotype),
+ color, getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink());
+ if (italic) {
+ fontConfigurationName = fontConfigurationName.italic();
+ }
+ final TextBlock name = TextBlockUtils.withMargin(TextBlockUtils.create(entity.getDisplay(),
+ fontConfigurationName, HorizontalAlignment.CENTER, skinParam), 3, 3, 0, 0);
+
+ final TextBlock stereo;
+ if (stereotype == null || stereotype.getLabel(false) == null
+ || portionShower.showPortion(EntityPortion.STEREOTYPE, entity) == false) {
+ stereo = null;
+ } else {
+ stereo = TextBlockUtils.withMargin(TextBlockUtils.create(
+ Display.create(stereotype.getLabels(skinParam.useGuillemet())),
+ new FontConfiguration(SkinParamUtils.getFont(getSkinParam(),
+ FontParam.CLASS_STEREOTYPE, stereotype), SkinParamUtils.getFontColor(getSkinParam(),
+ FontParam.CLASS_STEREOTYPE, stereotype), getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.CENTER, skinParam), 1, 0);
+ }
+
+ TextBlock genericBlock;
+ if (generic == null) {
+ genericBlock = null;
+ } else {
+ genericBlock = TextBlockUtils.create(
+ Display.getWithNewlines(generic),
+ new FontConfiguration(SkinParamUtils.getFont(getSkinParam(),
+ FontParam.CLASS_STEREOTYPE, stereotype), SkinParamUtils.getFontColor(getSkinParam(),
+ FontParam.CLASS_STEREOTYPE, stereotype), skinParam.getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.CENTER, skinParam);
+ genericBlock = TextBlockUtils.withMargin(genericBlock, 1, 1);
+ final HtmlColor classBackground = SkinParamUtils
+ .getColor(getSkinParam(), ColorParam.background, stereotype);
+ // final HtmlColor classBorder = getColor(ColorParam.classBorder, stereotype);
+ final HtmlColor classBorder = SkinParamUtils.getFontColor(getSkinParam(), FontParam.CLASS_STEREOTYPE,
+ stereotype);
+ genericBlock = new TextBlockGeneric(genericBlock, classBackground, classBorder);
+ genericBlock = TextBlockUtils.withMargin(genericBlock, 1, 1);
+ }
+
+ final TextBlock circledCharacter;
+ if (portionShower.showPortion(EntityPortion.CIRCLED_CHARACTER, (ILeaf) getEntity())) {
+ circledCharacter = TextBlockUtils.withMargin(getCircledCharacter(entity, skinParam), 4, 0, 5, 5);
+ } else {
+ circledCharacter = null;
+ }
+ this.headerLayout = new HeaderLayout(circledCharacter, stereo, name, genericBlock);
+ }
+
+ private TextBlock getCircledCharacter(ILeaf entity, ISkinParam skinParam) {
+ final Stereotype stereotype = entity.getStereotype();
+ if (stereotype != null && stereotype.getSprite() != null) {
+ return skinParam.getSprite(stereotype.getSprite()).asTextBlock(stereotype.getHtmlColor());
+ }
+ final UFont font = SkinParamUtils.getFont(getSkinParam(), FontParam.CIRCLED_CHARACTER, null);
+ final HtmlColor classBorder = SkinParamUtils.getColor(getSkinParam(), ColorParam.classBorder, stereotype);
+ if (stereotype != null && stereotype.getCharacter() != 0) {
+ return new CircledCharacter(stereotype.getCharacter(), getSkinParam().getCircledCharacterRadius(), font,
+ stereotype.getHtmlColor(), classBorder, SkinParamUtils.getFontColor(getSkinParam(),
+ FontParam.CIRCLED_CHARACTER, null));
+ }
+ if (entity.getEntityType() == LeafType.ANNOTATION) {
+ return new CircledCharacter('@', getSkinParam().getCircledCharacterRadius(), font, SkinParamUtils.getColor(
+ getSkinParam(), ColorParam.stereotypeABackground, stereotype), classBorder,
+ SkinParamUtils.getFontColor(getSkinParam(), FontParam.CIRCLED_CHARACTER, null));
+ }
+ if (entity.getEntityType() == LeafType.ABSTRACT_CLASS) {
+ return new CircledCharacter('A', getSkinParam().getCircledCharacterRadius(), font, SkinParamUtils.getColor(
+ getSkinParam(), ColorParam.stereotypeABackground, stereotype), classBorder,
+ SkinParamUtils.getFontColor(getSkinParam(), FontParam.CIRCLED_CHARACTER, null));
+ }
+ if (entity.getEntityType() == LeafType.CLASS) {
+ return new CircledCharacter('C', getSkinParam().getCircledCharacterRadius(), font, SkinParamUtils.getColor(
+ getSkinParam(), ColorParam.stereotypeCBackground, stereotype), classBorder,
+ SkinParamUtils.getFontColor(getSkinParam(), FontParam.CIRCLED_CHARACTER, null));
+ }
+ if (entity.getEntityType() == LeafType.INTERFACE) {
+ return new CircledCharacter('I', getSkinParam().getCircledCharacterRadius(), font, SkinParamUtils.getColor(
+ getSkinParam(), ColorParam.stereotypeIBackground, stereotype), classBorder,
+ SkinParamUtils.getFontColor(getSkinParam(), FontParam.CIRCLED_CHARACTER, null));
+ }
+ if (entity.getEntityType() == LeafType.ENUM) {
+ return new CircledCharacter('E', getSkinParam().getCircledCharacterRadius(), font, SkinParamUtils.getColor(
+ getSkinParam(), ColorParam.stereotypeEBackground, stereotype), classBorder,
+ SkinParamUtils.getFontColor(getSkinParam(), FontParam.CIRCLED_CHARACTER, null));
+ }
+ assert false;
+ return null;
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return headerLayout.getDimension(stringBounder);
+ }
+
+ final public void drawU(UGraphic ug) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void drawU(UGraphic ug, double width, double height) {
+ headerLayout.drawU(ug, width, height);
+ }
+
+ public ShapeType getShapeType() {
+ return ShapeType.RECTANGLE;
+ }
+
+ public int getShield() {
+ return 0;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageComponent.java b/src/net/sourceforge/plantuml/svek/image/EntityImageComponent.java
new file mode 100644
index 0000000..1bc8db7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/image/EntityImageComponent.java
@@ -0,0 +1,129 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.image;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.SkinParamUtils;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.cucadiagram.BodyEnhanced;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.EntityPortion;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.cucadiagram.PortionShower;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.SymbolContext;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.graphic.USymbol;
+import net.sourceforge.plantuml.svek.AbstractEntityImage;
+import net.sourceforge.plantuml.svek.ShapeType;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+
+public class EntityImageComponent extends AbstractEntityImage {
+
+ final private Url url;
+
+ private final TextBlock asSmall;
+
+ public EntityImageComponent(ILeaf entity, ISkinParam skinParam, PortionShower portionShower) {
+ super(entity, skinParam);
+ final Stereotype stereotype = entity.getStereotype();
+ final USymbol symbol = entity.getUSymbol() == null ? (skinParam.useUml2ForComponent() ? USymbol.COMPONENT2
+ : USymbol.COMPONENT1) : entity.getUSymbol();
+ if (symbol == null) {
+ throw new IllegalArgumentException();
+ }
+
+ final TextBlock desc = entity.getDisplay().isWhite() ? TextBlockUtils.empty(0, 0) : new BodyEnhanced(
+ entity.getDisplay(), symbol.getFontParam(), skinParam, HorizontalAlignment.CENTER, stereotype,
+ symbol.manageHorizontalLine(), false);
+
+ this.url = entity.getUrl99();
+
+ HtmlColor backcolor = getEntity().getSpecificBackColor();
+ if (backcolor == null) {
+ backcolor = SkinParamUtils.getColor(getSkinParam(), symbol.getColorParamBack(), getStereo());
+ }
+ // backcolor = HtmlColorUtils.BLUE;
+ final HtmlColor forecolor = SkinParamUtils.getColor(getSkinParam(), symbol.getColorParamBorder(), getStereo());
+ final SymbolContext ctx = new SymbolContext(backcolor, forecolor).withStroke(new UStroke(1.5)).withShadow(
+ getSkinParam().shadowing2(symbol.getSkinParameter()));
+
+ TextBlock stereo = TextBlockUtils.empty(0, 0);
+
+ if (stereotype != null && stereotype.getLabel(false) != null
+ && portionShower.showPortion(EntityPortion.STEREOTYPE, entity)) {
+ stereo = TextBlockUtils.create(
+ Display.getWithNewlines(stereotype.getLabel(getSkinParam().useGuillemet())),
+ new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), symbol.getFontParamStereotype(),
+ stereotype), SkinParamUtils.getFontColor(getSkinParam(), symbol.getFontParamStereotype(),
+ null), getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()),
+ HorizontalAlignment.CENTER, skinParam);
+ }
+
+ asSmall = symbol.asSmall(desc, stereo, ctx);
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return asSmall.calculateDimension(stringBounder);
+ }
+
+ final public void drawU(UGraphic ug) {
+ if (url != null) {
+ ug.startUrl(url);
+ }
+ asSmall.drawU(ug);
+
+ if (url != null) {
+ ug.closeAction();
+ }
+ }
+
+ public ShapeType getShapeType() {
+ return ShapeType.RECTANGLE;
+ }
+
+ public int getShield() {
+ return 0;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageEmptyPackage2.java b/src/net/sourceforge/plantuml/svek/image/EntityImageEmptyPackage2.java
new file mode 100644
index 0000000..6ece031
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/image/EntityImageEmptyPackage2.java
@@ -0,0 +1,117 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.image;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.LineParam;
+import net.sourceforge.plantuml.SkinParamUtils;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.svek.AbstractEntityImage;
+import net.sourceforge.plantuml.svek.Cluster;
+import net.sourceforge.plantuml.svek.ClusterDecoration;
+import net.sourceforge.plantuml.svek.ShapeType;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+
+public class EntityImageEmptyPackage2 extends AbstractEntityImage {
+
+ final private TextBlock desc;
+ final private static int MARGIN = 10;
+ final private HtmlColor specificBackColor;
+ final private ISkinParam skinParam;
+ final private Stereotype stereotype;
+
+ public EntityImageEmptyPackage2(ILeaf entity, ISkinParam skinParam) {
+ super(entity, skinParam);
+ this.skinParam = skinParam;
+ this.specificBackColor = entity.getSpecificBackColor();
+ this.stereotype = entity.getStereotype();
+ this.desc = TextBlockUtils.create(entity.getDisplay(),
+ new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), FontParam.PACKAGE, stereotype),
+ SkinParamUtils.getFontColor(getSkinParam(), FontParam.PACKAGE, stereotype), getSkinParam()
+ .getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()),
+ HorizontalAlignment.CENTER, skinParam);
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dim = desc.calculateDimension(stringBounder);
+ return Dimension2DDouble.delta(dim, MARGIN * 2, MARGIN * 2 + dim.getHeight() * 2);
+ }
+
+ private UStroke getStroke() {
+ UStroke stroke = getSkinParam().getThickness(LineParam.packageBorder, getStereo());
+ if (stroke == null) {
+ stroke = new UStroke(2.0);
+ }
+ return stroke;
+ }
+
+ final public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D dimTotal = calculateDimension(stringBounder);
+
+ final double widthTotal = dimTotal.getWidth();
+ final double heightTotal = dimTotal.getHeight();
+
+ final HtmlColor stateBack = Cluster.getStateBackColor(specificBackColor, skinParam, stereotype);
+
+ final ClusterDecoration decoration = new ClusterDecoration(getSkinParam().getPackageStyle(), null, desc,
+ TextBlockUtils.empty(0, 0), stateBack, 0, 0, widthTotal, heightTotal, getStroke());
+
+ decoration.drawU(ug, SkinParamUtils.getColor(getSkinParam(), ColorParam.packageBorder, getStereo()),
+ getSkinParam().shadowing());
+ }
+
+ public ShapeType getShapeType() {
+ return ShapeType.RECTANGLE;
+ }
+
+ public int getShield() {
+ return 0;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageGroup.java b/src/net/sourceforge/plantuml/svek/image/EntityImageGroup.java
new file mode 100644
index 0000000..d5110b4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/image/EntityImageGroup.java
@@ -0,0 +1,73 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.image;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.svek.AbstractEntityImage;
+import net.sourceforge.plantuml.svek.ShapeType;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class EntityImageGroup extends AbstractEntityImage {
+
+ // final private TextBlock desc;
+ // final private static int MARGIN = 10;
+
+ public EntityImageGroup(ILeaf entity, ISkinParam skinParam) {
+ super(entity, skinParam);
+ // this.desc = TextBlockUtils.create(StringUtils.getWithNewlines(entity.getDisplay()), new FontConfiguration(
+ // getFont(FontParam.ACTIVITY), HtmlColorUtils.BLACK), HorizontalAlignment.CENTER);
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(30, 30);
+ }
+
+ final public void drawU(UGraphic ug) {
+ }
+
+ public ShapeType getShapeType() {
+ return ShapeType.RECTANGLE;
+ }
+
+ public int getShield() {
+ return 0;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterface.java b/src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterface.java
new file mode 100644
index 0000000..910b7c8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterface.java
@@ -0,0 +1,116 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.image;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.SkinParamUtils;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+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;
+import net.sourceforge.plantuml.svek.AbstractEntityImage;
+import net.sourceforge.plantuml.svek.ShapeType;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class EntityImageLollipopInterface extends AbstractEntityImage {
+
+ private static final int SIZE = 10;
+ private final TextBlock desc;
+ final private Url url;
+
+ public EntityImageLollipopInterface(ILeaf entity, ISkinParam skinParam) {
+ super(entity, skinParam);
+ final Stereotype stereotype = entity.getStereotype();
+ this.desc = TextBlockUtils.create(
+ entity.getDisplay(),
+ new FontConfiguration(SkinParamUtils.getFont(getSkinParam(),
+ FontParam.CLASS, stereotype), SkinParamUtils.getFontColor(getSkinParam(), FontParam.CLASS,
+ stereotype), getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.CENTER, skinParam);
+ this.url = entity.getUrl99();
+
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(SIZE, SIZE);
+ }
+
+ final public void drawU(UGraphic ug) {
+ final UEllipse circle = new UEllipse(SIZE, SIZE);
+ if (getSkinParam().shadowing()) {
+ circle.setDeltaShadow(4);
+ }
+ ug = ug.apply(
+ new UChangeBackColor(SkinParamUtils.getColor(getSkinParam(), ColorParam.classBackground, getStereo())))
+ .apply(new UChangeColor(SkinParamUtils.getColor(getSkinParam(), ColorParam.classBorder, getStereo())));
+ if (url != null) {
+ ug.startUrl(url);
+ }
+ ug.apply(new UStroke(1.5)).draw(circle);
+
+ final Dimension2D dimDesc = desc.calculateDimension(ug.getStringBounder());
+ final double widthDesc = dimDesc.getWidth();
+ // final double totalWidth = Math.max(widthDesc, SIZE);
+
+ final double x = SIZE / 2 - widthDesc / 2;
+ final double y = SIZE;
+ desc.drawU(ug.apply(new UTranslate(x, y)));
+ if (url != null) {
+ ug.closeAction();
+ }
+ }
+
+ public ShapeType getShapeType() {
+ return ShapeType.CIRCLE_IN_RECT;
+ }
+
+ public int getShield() {
+ return 0;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterfaceEye1.java b/src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterfaceEye1.java
new file mode 100644
index 0000000..74fa248
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterfaceEye1.java
@@ -0,0 +1,140 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.image;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.util.List;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.SkinParamUtils;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+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;
+import net.sourceforge.plantuml.svek.AbstractEntityImage;
+import net.sourceforge.plantuml.svek.Bibliotekon;
+import net.sourceforge.plantuml.svek.Line;
+import net.sourceforge.plantuml.svek.ShapeType;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class EntityImageLollipopInterfaceEye1 extends AbstractEntityImage {
+
+ private static final int SIZE = 24;
+ private final TextBlock desc;
+ private final Bibliotekon bibliotekon;
+ final private Url url;
+
+ public EntityImageLollipopInterfaceEye1(ILeaf entity, ISkinParam skinParam, Bibliotekon bibliotekon) {
+ super(entity, skinParam);
+ this.bibliotekon = bibliotekon;
+ final Stereotype stereotype = entity.getStereotype();
+ this.desc = TextBlockUtils.create(
+ entity.getDisplay(),
+ new FontConfiguration(SkinParamUtils.getFont(getSkinParam(),
+ FontParam.CLASS, stereotype), SkinParamUtils.getFontColor(getSkinParam(), FontParam.CLASS,
+ stereotype), getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.CENTER, skinParam);
+ this.url = entity.getUrl99();
+
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(SIZE, SIZE);
+ }
+
+ final public void drawU(UGraphic ug) {
+ ug = ug.apply(new UChangeColor(SkinParamUtils.getColor(getSkinParam(), ColorParam.classBorder, getStereo())));
+ ug = ug.apply(new UChangeBackColor(SkinParamUtils.getColor(getSkinParam(), ColorParam.classBackground,
+ getStereo())));
+ if (url != null) {
+ ug.startUrl(url);
+ }
+ final double sizeSmall = 14;
+ final double diff = (SIZE - sizeSmall) / 2;
+ final UEllipse circle1 = new UEllipse(sizeSmall, sizeSmall);
+ if (getSkinParam().shadowing()) {
+ // circle.setDeltaShadow(4);
+ }
+ ug.apply(new UStroke(1.5)).apply(new UTranslate(diff, diff)).draw(circle1);
+ ug = ug.apply(new UChangeBackColor(null));
+
+ Point2D pos = bibliotekon.getShape(getEntity()).getPosition();
+
+ final List<Line> lines = bibliotekon.getAllLineConnectedTo(getEntity());
+ final UTranslate reverse = new UTranslate(pos).reverse();
+ final ConnectedCircle connectedCircle = new ConnectedCircle(SIZE / 2);
+ for (Line line : lines) {
+ Point2D pt = line.getMyPoint(getEntity());
+ pt = reverse.getTranslated(pt);
+ connectedCircle.addSecondaryConnection(pt);
+
+ }
+ // connectedCircle.drawU(ug.apply(new UStroke(1.5)));
+ connectedCircle.drawU(ug);
+
+ //
+ // final Dimension2D dimDesc = desc.calculateDimension(ug.getStringBounder());
+ // final double widthDesc = dimDesc.getWidth();
+ // // final double totalWidth = Math.max(widthDesc, SIZE);
+ //
+ // final double x = SIZE / 2 - widthDesc / 2;
+ // final double y = SIZE;
+ // desc.drawU(ug.apply(new UTranslate(x, y)));
+ if (url != null) {
+ ug.closeAction();
+ }
+ }
+
+ public ShapeType getShapeType() {
+ return ShapeType.CIRCLE;
+ }
+
+ public int getShield() {
+ return 0;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterfaceEye2.java b/src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterfaceEye2.java
new file mode 100644
index 0000000..451dc39
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/image/EntityImageLollipopInterfaceEye2.java
@@ -0,0 +1,146 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.image;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.SkinParamUtils;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.cucadiagram.BodyEnhanced;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.EntityPortion;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.cucadiagram.PortionShower;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.SymbolContext;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.graphic.USymbol;
+import net.sourceforge.plantuml.svek.AbstractEntityImage;
+import net.sourceforge.plantuml.svek.ShapeType;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class EntityImageLollipopInterfaceEye2 extends AbstractEntityImage {
+
+ public static final double SIZE = 14;
+ private final TextBlock desc;
+ private final TextBlock stereo;
+ private final SymbolContext ctx;
+ final private Url url;
+
+ public EntityImageLollipopInterfaceEye2(ILeaf entity, ISkinParam skinParam, PortionShower portionShower) {
+ super(entity, skinParam);
+ final Stereotype stereotype = entity.getStereotype();
+
+ final USymbol symbol = entity.getUSymbol() == null ? (skinParam.useUml2ForComponent() ? USymbol.COMPONENT2
+ : USymbol.COMPONENT1) : entity.getUSymbol();
+ if (symbol == null) {
+ throw new IllegalArgumentException();
+ }
+
+ this.desc = new BodyEnhanced(entity.getDisplay(), symbol.getFontParam(), skinParam, HorizontalAlignment.CENTER,
+ stereotype, symbol.manageHorizontalLine(), false);
+
+ this.url = entity.getUrl99();
+
+ HtmlColor backcolor = getEntity().getSpecificBackColor();
+ if (backcolor == null) {
+ backcolor = SkinParamUtils.getColor(getSkinParam(), symbol.getColorParamBack(), getStereo());
+ }
+ // backcolor = HtmlColorUtils.BLUE;
+ final HtmlColor forecolor = SkinParamUtils.getColor(getSkinParam(), symbol.getColorParamBorder(), getStereo());
+ this.ctx = new SymbolContext(backcolor, forecolor).withStroke(new UStroke(1.5)).withShadow(
+ getSkinParam().shadowing());
+
+ if (stereotype != null && stereotype.getLabel(false) != null
+ && portionShower.showPortion(EntityPortion.STEREOTYPE, entity)) {
+ stereo = TextBlockUtils.create(
+ Display.getWithNewlines(stereotype.getLabel(getSkinParam().useGuillemet())),
+ new FontConfiguration(SkinParamUtils.getFont(getSkinParam(),
+ symbol.getFontParamStereotype(), stereotype), SkinParamUtils.getFontColor(getSkinParam(),
+ symbol.getFontParamStereotype(), null), getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.CENTER, skinParam);
+ } else {
+ stereo = TextBlockUtils.empty(0, 0);
+ }
+
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(SIZE, SIZE);
+ }
+
+ final public void drawU(UGraphic ug) {
+ if (url != null) {
+ ug.startUrl(url);
+ }
+ final UEllipse circle = new UEllipse(SIZE, SIZE);
+ if (getSkinParam().shadowing()) {
+ circle.setDeltaShadow(4);
+ }
+ ctx.apply(ug).draw(circle);
+
+ final Dimension2D dimDesc = desc.calculateDimension(ug.getStringBounder());
+ final double x1 = SIZE / 2 - dimDesc.getWidth() / 2;
+ final double y1 = SIZE * 1.4;
+ desc.drawU(ug.apply(new UTranslate(x1, y1)));
+
+ final Dimension2D dimStereo = stereo.calculateDimension(ug.getStringBounder());
+ final double x2 = SIZE / 2 - dimStereo.getWidth() / 2;
+ final double y2 = -dimStereo.getHeight();
+ stereo.drawU(ug.apply(new UTranslate(x2, y2)));
+
+ if (url != null) {
+ ug.closeAction();
+ }
+ }
+
+ public ShapeType getShapeType() {
+ return ShapeType.CIRCLE;
+ }
+
+ public int getShield() {
+ return 0;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageNote.java b/src/net/sourceforge/plantuml/svek/image/EntityImageNote.java
new file mode 100644
index 0000000..64c0995
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/image/EntityImageNote.java
@@ -0,0 +1,279 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.image;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Line2D;
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.Direction;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.SkinParamBackcolored;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.creole.Stencil;
+import net.sourceforge.plantuml.cucadiagram.BodyEnhanced2;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.graph2.GeomUtils;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockEmpty;
+import net.sourceforge.plantuml.posimo.DotPath;
+import net.sourceforge.plantuml.skin.rose.Rose;
+import net.sourceforge.plantuml.svek.AbstractEntityImage;
+import net.sourceforge.plantuml.svek.Line;
+import net.sourceforge.plantuml.svek.Shape;
+import net.sourceforge.plantuml.svek.ShapeType;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UGraphicStencil;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class EntityImageNote extends AbstractEntityImage implements Stencil {
+
+ private final int cornersize = 10;
+ private final HtmlColor noteBackgroundColor;
+ private final HtmlColor borderColor;
+ private final int marginX1 = 6;
+ private final int marginX2 = 15;
+ private final int marginY = 5;
+ private final boolean withShadow;
+ private final ISkinParam skinParam;
+
+ private final TextBlock textBlock;
+
+ public EntityImageNote(ILeaf entity, ISkinParam skinParam) {
+ super(entity, getSkin(skinParam, entity));
+ this.skinParam = skinParam;
+
+ this.withShadow = skinParam.shadowing();
+ final Display strings = entity.getDisplay();
+
+ final Rose rose = new Rose();
+
+ if (entity.getSpecificBackColor() == null) {
+ noteBackgroundColor = rose.getHtmlColor(skinParam, ColorParam.noteBackground);
+ } else {
+ noteBackgroundColor = entity.getSpecificBackColor();
+ }
+ borderColor = rose.getHtmlColor(skinParam, ColorParam.noteBorder);
+ final HtmlColor fontColor = rose.getFontColor(skinParam, FontParam.NOTE);
+ final UFont fontNote = skinParam.getFont(FontParam.NOTE, null, false);
+
+ if (strings.size() == 1 && strings.get(0).length() == 0) {
+ textBlock = new TextBlockEmpty();
+ } else {
+ textBlock = new BodyEnhanced2(strings, FontParam.NOTE, skinParam, HorizontalAlignment.LEFT,
+ new FontConfiguration(fontNote, fontColor, skinParam.getHyperlinkColor(),
+ skinParam.useUnderlineForHyperlink()));
+ }
+ }
+
+ private static ISkinParam getSkin(ISkinParam skinParam, IEntity entity) {
+ final Stereotype stereotype = entity.getStereotype();
+ HtmlColor back = entity.getSpecificBackColor();
+ if (back != null) {
+ return new SkinParamBackcolored(skinParam, back);
+ }
+ back = getColorStatic(skinParam, ColorParam.noteBackground, stereotype);
+ if (back != null) {
+ return new SkinParamBackcolored(skinParam, back);
+ }
+ return skinParam;
+ }
+
+ private static HtmlColor getColorStatic(ISkinParam skinParam, ColorParam colorParam, Stereotype stereo) {
+ final Rose rose = new Rose();
+ return rose.getHtmlColor(skinParam, colorParam, stereo);
+ }
+
+ final public double getPreferredWidth(StringBounder stringBounder) {
+ final double result = getTextWidth(stringBounder);
+ return result;
+ }
+
+ final public double getPreferredHeight(StringBounder stringBounder) {
+ return getTextHeight(stringBounder);
+ }
+
+ private Dimension2D getSize(StringBounder stringBounder, final TextBlock textBlock) {
+ return textBlock.calculateDimension(stringBounder);
+ }
+
+ final protected double getTextHeight(StringBounder stringBounder) {
+ final TextBlock textBlock = getTextBlock();
+ final Dimension2D size = getSize(stringBounder, textBlock);
+ return size.getHeight() + 2 * marginY;
+ }
+
+ final protected TextBlock getTextBlock() {
+ return textBlock;
+ }
+
+ final protected double getPureTextWidth(StringBounder stringBounder) {
+ final TextBlock textBlock = getTextBlock();
+ final Dimension2D size = getSize(stringBounder, textBlock);
+ return size.getWidth();
+ }
+
+ final public double getTextWidth(StringBounder stringBounder) {
+ return getPureTextWidth(stringBounder) + marginX1 + marginX2;
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final double height = getPreferredHeight(stringBounder);
+ final double width = getPreferredWidth(stringBounder);
+ return new Dimension2DDouble(width, height);
+ }
+
+ final public void drawU(UGraphic ug) {
+ final Url url = getEntity().getUrl99();
+ if (url != null) {
+ ug.startUrl(url);
+ }
+ final UGraphic ug2 = new UGraphicStencil(ug, this, new UStroke());
+ if (opaleLine == null || opaleLine.isOpale() == false) {
+ drawNormal(ug2);
+ } else {
+ final StringBounder stringBounder = ug.getStringBounder();
+ DotPath path = opaleLine.getDotPath();
+ path.moveSvek(-shape.getMinX(), -shape.getMinY());
+ Point2D p1 = path.getStartPoint();
+ Point2D p2 = path.getEndPoint();
+ final double textWidth = getTextWidth(stringBounder);
+ final double textHeight = getTextHeight(stringBounder);
+ final Point2D center = new Point2D.Double(textWidth / 2, textHeight / 2);
+ if (p1.distance(center) > p2.distance(center)) {
+ path = path.reverse();
+ p1 = path.getStartPoint();
+ p2 = path.getEndPoint();
+ }
+ final Direction strategy = getOpaleStrategy(textWidth, textHeight, p1);
+ final Point2D pp1 = path.getStartPoint();
+ final Point2D pp2 = path.getEndPoint();
+ final Opale opale = new Opale(borderColor, noteBackgroundColor, textBlock, skinParam.shadowing(), true);
+ opale.setOpale(strategy, pp1, pp2);
+ opale.drawU(ug2);
+ }
+ if (url != null) {
+ ug.closeAction();
+ }
+ }
+
+ private void drawNormal(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final UPolygon polygon = getPolygonNormal(stringBounder);
+ if (withShadow) {
+ polygon.setDeltaShadow(4);
+ }
+ ug = ug.apply(new UChangeBackColor(noteBackgroundColor)).apply(new UChangeColor(borderColor));
+ ug.draw(polygon);
+
+ ug.apply(new UTranslate(getTextWidth(stringBounder) - cornersize, 0)).draw(new ULine(0, cornersize));
+ ug.apply(new UTranslate(getTextWidth(stringBounder), cornersize)).draw(new ULine(-cornersize, 0));
+ getTextBlock().drawU(ug.apply(new UTranslate(marginX1, marginY)));
+ }
+
+ private UPolygon getPolygonNormal(final StringBounder stringBounder) {
+ final UPolygon polygon = new UPolygon();
+ polygon.addPoint(0, 0);
+ polygon.addPoint(0, getTextHeight(stringBounder));
+ polygon.addPoint(getTextWidth(stringBounder), getTextHeight(stringBounder));
+ polygon.addPoint(getTextWidth(stringBounder), cornersize);
+ polygon.addPoint(getTextWidth(stringBounder) - cornersize, 0);
+ polygon.addPoint(0, 0);
+ return polygon;
+ }
+
+ private Direction getOpaleStrategy(double width, double height, Point2D pt) {
+ final double d1 = GeomUtils.getOrthoDistance(new Line2D.Double(width, 0, width, height), pt);
+ final double d2 = GeomUtils.getOrthoDistance(new Line2D.Double(0, height, width, height), pt);
+ final double d3 = GeomUtils.getOrthoDistance(new Line2D.Double(0, 0, 0, height), pt);
+ final double d4 = GeomUtils.getOrthoDistance(new Line2D.Double(0, 0, width, 0), pt);
+ if (d3 <= d1 && d3 <= d2 && d3 <= d4) {
+ return Direction.LEFT;
+ }
+ if (d1 <= d2 && d1 <= d3 && d1 <= d4) {
+ return Direction.RIGHT;
+ }
+ if (d4 <= d1 && d4 <= d2 && d4 <= d3) {
+ return Direction.UP;
+ }
+ if (d2 <= d1 && d2 <= d3 && d2 <= d4) {
+ return Direction.DOWN;
+ }
+ return null;
+
+ }
+
+ public ShapeType getShapeType() {
+ return ShapeType.RECTANGLE;
+ }
+
+ public int getShield() {
+ return 0;
+ }
+
+ private Line opaleLine;
+ private Shape shape;
+
+ public void setOpaleLine(Line line, Shape shape) {
+ this.opaleLine = line;
+ this.shape = shape;
+
+ }
+
+ public double getStartingX(StringBounder stringBounder, double y) {
+ return 0;
+ }
+
+ public double getEndingX(StringBounder stringBounder, double y) {
+ return calculateDimension(stringBounder).getWidth();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageNoteLink.java b/src/net/sourceforge/plantuml/svek/image/EntityImageNoteLink.java
new file mode 100644
index 0000000..ff3e6d7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/image/EntityImageNoteLink.java
@@ -0,0 +1,90 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.image;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.SkinParamBackcolored;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.skin.Area;
+import net.sourceforge.plantuml.skin.Component;
+import net.sourceforge.plantuml.skin.ComponentType;
+import net.sourceforge.plantuml.skin.SimpleContext2D;
+import net.sourceforge.plantuml.skin.rose.Rose;
+import net.sourceforge.plantuml.svek.IEntityImage;
+import net.sourceforge.plantuml.svek.ShapeType;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class EntityImageNoteLink implements IEntityImage {
+
+ private final Component comp;
+
+ public EntityImageNoteLink(Display note, HtmlColor htmlColor, ISkinParam skinParam) {
+ final Rose skin = new Rose();
+ comp = skin.createComponent(ComponentType.NOTE, null, new SkinParamBackcolored(skinParam, htmlColor), note);
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final double height = comp.getPreferredHeight(stringBounder);
+ final double width = comp.getPreferredWidth(stringBounder);
+ return new Dimension2DDouble(width, height);
+ }
+
+ public void drawU(UGraphic ug) {
+ comp.drawU(ug, new Area(calculateDimension(ug.getStringBounder())), new SimpleContext2D(false));
+ }
+
+
+ public ShapeType getShapeType() {
+ return ShapeType.RECTANGLE;
+ }
+
+ public HtmlColor getBackcolor() {
+ return null;
+ }
+
+ public int getShield() {
+ return 0;
+ }
+
+ public boolean isHidden() {
+ return false;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageObject.java b/src/net/sourceforge/plantuml/svek/image/EntityImageObject.java
new file mode 100644
index 0000000..adbe934
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/image/EntityImageObject.java
@@ -0,0 +1,223 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.image;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.LineConfigurable;
+import net.sourceforge.plantuml.LineParam;
+import net.sourceforge.plantuml.SkinParamUtils;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.creole.Stencil;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.EntityPortion;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.cucadiagram.PortionShower;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockEmpty;
+import net.sourceforge.plantuml.graphic.TextBlockLineBefore;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.svek.AbstractEntityImage;
+import net.sourceforge.plantuml.svek.ShapeType;
+import net.sourceforge.plantuml.ugraphic.PlacementStrategyY1Y2;
+import net.sourceforge.plantuml.ugraphic.Shadowable;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UGraphicStencil;
+import net.sourceforge.plantuml.ugraphic.ULayoutGroup;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class EntityImageObject extends AbstractEntityImage implements Stencil {
+
+ final private TextBlock name;
+ final private TextBlock stereo;
+ final private TextBlock fields;
+ final private Url url;
+ final private double roundCorner;
+
+ final private LineConfigurable lineConfig;
+
+ public EntityImageObject(ILeaf entity, ISkinParam skinParam) {
+ super(entity, skinParam);
+ this.lineConfig = entity;
+ final Stereotype stereotype = entity.getStereotype();
+ this.roundCorner = skinParam.getRoundCorner();
+ this.name = TextBlockUtils.withMargin(TextBlockUtils.create(
+ entity.getDisplay(),
+ new FontConfiguration(SkinParamUtils.getFont(getSkinParam(),
+ FontParam.OBJECT, stereotype), SkinParamUtils.getFontColor(getSkinParam(), FontParam.OBJECT,
+ stereotype), getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.CENTER, skinParam), 2, 2);
+ if (stereotype == null || stereotype.getLabel(false) == null) {
+ this.stereo = null;
+ } else {
+ this.stereo = TextBlockUtils.create(
+ Display.getWithNewlines(stereotype.getLabel(getSkinParam().useGuillemet())),
+ new FontConfiguration(SkinParamUtils.getFont(getSkinParam(),
+ FontParam.OBJECT_STEREOTYPE, stereotype), SkinParamUtils.getFontColor(getSkinParam(),
+ FontParam.OBJECT_STEREOTYPE, stereotype), getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.CENTER, skinParam);
+ }
+
+ if (entity.getFieldsToDisplay().size() == 0) {
+ this.fields = new TextBlockLineBefore(new TextBlockEmpty(10, 16));
+ } else {
+ // this.fields =
+ // entity.getFieldsToDisplay().asTextBlock(FontParam.OBJECT_ATTRIBUTE,
+ // skinParam);
+ this.fields = entity.getBody(new PortionShower() {
+ public boolean showPortion(EntityPortion portion, IEntity entity) {
+ return true;
+ }
+ }).asTextBlock(FontParam.OBJECT_ATTRIBUTE, skinParam);
+
+ }
+ this.url = entity.getUrl99();
+
+ }
+
+ private int marginEmptyFieldsOrMethod = 13;
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dimTitle = getTitleDimension(stringBounder);
+ final Dimension2D dimFields = fields.calculateDimension(stringBounder);
+ final double width = Math.max(dimFields.getWidth(), dimTitle.getWidth() + 2 * xMarginCircle);
+
+ final double height = getMethodOrFieldHeight(dimFields) + dimTitle.getHeight();
+ return new Dimension2DDouble(width, height);
+ }
+
+ final public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D dimTotal = calculateDimension(stringBounder);
+ final Dimension2D dimTitle = getTitleDimension(stringBounder);
+
+ final double widthTotal = dimTotal.getWidth();
+ final double heightTotal = dimTotal.getHeight();
+ final Shadowable rect = new URectangle(widthTotal, heightTotal, roundCorner, roundCorner);
+ if (getSkinParam().shadowing()) {
+ rect.setDeltaShadow(4);
+ }
+
+ ug = ug.apply(new UChangeColor(SkinParamUtils.getColor(getSkinParam(), ColorParam.objectBorder, getStereo())));
+ HtmlColor backcolor = getEntity().getSpecificBackColor();
+ if (backcolor == null) {
+ backcolor = SkinParamUtils.getColor(getSkinParam(), ColorParam.objectBackground, getStereo());
+ }
+ ug = ug.apply(new UChangeBackColor(backcolor));
+ if (url != null) {
+ ug.startUrl(url);
+ }
+
+ final UStroke stroke = getStroke();
+ ug.apply(stroke).draw(rect);
+
+ final ULayoutGroup header = new ULayoutGroup(new PlacementStrategyY1Y2(ug.getStringBounder()));
+ if (stereo != null) {
+ header.add(stereo);
+ }
+ header.add(name);
+ header.drawU(ug, 0, 0, dimTotal.getWidth(), dimTitle.getHeight());
+
+ final UGraphic ug2 = new UGraphicStencil(ug, this, stroke);
+ fields.drawU(ug2.apply(new UTranslate(0, dimTitle.getHeight())));
+
+ if (url != null) {
+ ug.closeAction();
+ }
+ }
+
+ private UStroke getStroke() {
+ UStroke stroke = lineConfig.getSpecificLineStroke();
+ if (stroke == null) {
+ stroke = getSkinParam().getThickness(LineParam.objectBorder, getStereo());
+ }
+ if (stroke == null) {
+ stroke = new UStroke(1.5);
+ }
+ return stroke;
+ }
+
+ private double getMethodOrFieldHeight(final Dimension2D dim) {
+ final double fieldsHeight = dim.getHeight();
+ if (fieldsHeight == 0) {
+ return marginEmptyFieldsOrMethod;
+ }
+ return fieldsHeight;
+ }
+
+ private int xMarginCircle = 5;
+
+ private Dimension2D getTitleDimension(StringBounder stringBounder) {
+ return getNameAndSteretypeDimension(stringBounder);
+ }
+
+ private Dimension2D getNameAndSteretypeDimension(StringBounder stringBounder) {
+ final Dimension2D nameDim = name.calculateDimension(stringBounder);
+ final Dimension2D stereoDim = stereo == null ? new Dimension2DDouble(0, 0) : stereo
+ .calculateDimension(stringBounder);
+ final Dimension2D nameAndStereo = new Dimension2DDouble(Math.max(nameDim.getWidth(), stereoDim.getWidth()),
+ nameDim.getHeight() + stereoDim.getHeight());
+ return nameAndStereo;
+ }
+
+ public ShapeType getShapeType() {
+ return ShapeType.RECTANGLE;
+ }
+
+ public int getShield() {
+ return 0;
+ }
+
+ public double getStartingX(StringBounder stringBounder, double y) {
+ return 0;
+ }
+
+ public double getEndingX(StringBounder stringBounder, double y) {
+ return calculateDimension(stringBounder).getWidth();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImagePseudoState.java b/src/net/sourceforge/plantuml/svek/image/EntityImagePseudoState.java
new file mode 100644
index 0000000..e50ad6e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/image/EntityImagePseudoState.java
@@ -0,0 +1,110 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.image;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.SkinParamUtils;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+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;
+import net.sourceforge.plantuml.svek.AbstractEntityImage;
+import net.sourceforge.plantuml.svek.ShapeType;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class EntityImagePseudoState extends AbstractEntityImage {
+
+ private static final int SIZE = 22;
+ private final TextBlock desc;
+
+ public EntityImagePseudoState(ILeaf entity, ISkinParam skinParam) {
+ super(entity, skinParam);
+ final Stereotype stereotype = entity.getStereotype();
+ this.desc = TextBlockUtils.create(Display.create("H"),
+ new FontConfiguration(SkinParamUtils.getFont(getSkinParam(),
+ FontParam.STATE, stereotype), SkinParamUtils.getFontColor(getSkinParam(), FontParam.STATE,
+ stereotype), getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()),
+ HorizontalAlignment.CENTER, skinParam);
+
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(SIZE, SIZE);
+ }
+
+ final public void drawU(UGraphic ug) {
+ final UEllipse circle = new UEllipse(SIZE, SIZE);
+ if (getSkinParam().shadowing()) {
+ circle.setDeltaShadow(4);
+ }
+ ug = ug.apply(new UStroke(1.5));
+ ug = ug.apply(
+ new UChangeBackColor(SkinParamUtils.getColor(getSkinParam(), ColorParam.stateBackground, getStereo())))
+ .apply(new UChangeColor(SkinParamUtils.getColor(getSkinParam(), ColorParam.stateBorder, getStereo())));
+ ug.draw(circle);
+ ug = ug.apply(new UStroke());
+
+ final Dimension2D dimDesc = desc.calculateDimension(ug.getStringBounder());
+ final double widthDesc = dimDesc.getWidth();
+ final double heightDesc = dimDesc.getHeight();
+
+ final double x = (SIZE - widthDesc) / 2;
+ final double y = (SIZE - heightDesc) / 2;
+ desc.drawU(ug.apply(new UTranslate(x, y)));
+ }
+
+ public ShapeType getShapeType() {
+ return ShapeType.CIRCLE;
+ }
+
+ public int getShield() {
+ return 0;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageState.java b/src/net/sourceforge/plantuml/svek/image/EntityImageState.java
new file mode 100644
index 0000000..ea5041f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/image/EntityImageState.java
@@ -0,0 +1,201 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.image;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.LineConfigurable;
+import net.sourceforge.plantuml.SkinParamUtils;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.Member;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.svek.AbstractEntityImage;
+import net.sourceforge.plantuml.svek.ShapeType;
+import net.sourceforge.plantuml.ugraphic.Shadowable;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class EntityImageState extends AbstractEntityImage {
+
+ final private TextBlock desc;
+ final private TextBlock fields;
+ final private Url url;
+
+ final private static int MIN_WIDTH = 50;
+ final private static int MIN_HEIGHT = 50;
+
+ final private boolean withSymbol;
+
+ final static private double smallRadius = 3;
+ final static private double smallLine = 3;
+ final static private double smallMarginX = 7;
+ final static private double smallMarginY = 4;
+
+ final private LineConfigurable lineConfig;
+
+ public EntityImageState(IEntity entity, ISkinParam skinParam) {
+ super(entity, skinParam);
+ this.lineConfig = entity;
+ final Stereotype stereotype = entity.getStereotype();
+ this.withSymbol = stereotype != null && stereotype.isWithOOSymbol();
+
+ this.desc = TextBlockUtils.create(
+ entity.getDisplay(),
+ new FontConfiguration(SkinParamUtils.getFont(getSkinParam(),
+ FontParam.STATE, stereotype), SkinParamUtils.getFontColor(getSkinParam(), FontParam.STATE,
+ stereotype), getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.CENTER, skinParam);
+
+ Display list = Display.empty();
+ for (Member att : entity.getFieldsToDisplay()) {
+ list = list.addAll(Display.getWithNewlines(att.getDisplay(true)));
+ }
+
+ this.url = entity.getUrl99();
+
+ this.fields = TextBlockUtils.create(
+ list,
+ new FontConfiguration(SkinParamUtils.getFont(getSkinParam(),
+ FontParam.STATE_ATTRIBUTE, stereotype), SkinParamUtils.getFontColor(getSkinParam(),
+ FontParam.STATE_ATTRIBUTE, stereotype), getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.LEFT, skinParam);
+
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dim = Dimension2DDouble.mergeTB(desc.calculateDimension(stringBounder),
+ fields.calculateDimension(stringBounder));
+ double heightSymbol = 0;
+ if (withSymbol) {
+ heightSymbol += 2 * smallRadius + smallMarginY;
+ }
+ final Dimension2D result = Dimension2DDouble.delta(dim, MARGIN * 2 + 2 * MARGIN_LINE + heightSymbol);
+ return Dimension2DDouble.atLeast(result, MIN_WIDTH, MIN_HEIGHT);
+ }
+
+ final public void drawU(UGraphic ug) {
+ if (url != null) {
+ ug.startUrl(url);
+ }
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D dimTotal = calculateDimension(stringBounder);
+ final Dimension2D dimDesc = desc.calculateDimension(stringBounder);
+
+ final double widthTotal = dimTotal.getWidth();
+ final double heightTotal = dimTotal.getHeight();
+ final Shadowable rect = new URectangle(widthTotal, heightTotal, CORNER, CORNER);
+ if (getSkinParam().shadowing()) {
+ rect.setDeltaShadow(4);
+ }
+
+ HtmlColor classBorder = lineConfig.getSpecificLineColor();
+ if (classBorder == null) {
+ classBorder = SkinParamUtils.getColor(getSkinParam(), ColorParam.stateBorder, getStereo());
+ }
+ ug = ug.apply(getStroke()).apply(new UChangeColor(classBorder));
+ HtmlColor backcolor = getEntity().getSpecificBackColor();
+ if (backcolor == null) {
+ backcolor = SkinParamUtils.getColor(getSkinParam(), ColorParam.stateBackground, getStereo());
+ }
+ ug = ug.apply(new UChangeBackColor(backcolor));
+
+ ug.draw(rect);
+
+ final double yLine = MARGIN + dimDesc.getHeight() + MARGIN_LINE;
+ ug.apply(new UTranslate(0, yLine)).draw(new ULine(widthTotal, 0));
+
+ ug = ug.apply(new UStroke());
+
+ if (withSymbol) {
+ final double xSymbol = dimTotal.getWidth();
+ final double ySymbol = dimTotal.getHeight();
+ drawSymbol(ug, xSymbol, ySymbol);
+ }
+
+ final double xDesc = (widthTotal - dimDesc.getWidth()) / 2;
+ final double yDesc = MARGIN;
+ desc.drawU(ug.apply(new UTranslate(xDesc, yDesc)));
+
+ final double xFields = MARGIN;
+ final double yFields = yLine + MARGIN_LINE;
+ fields.drawU(ug.apply(new UTranslate(xFields, yFields)));
+
+ if (url != null) {
+ ug.closeAction();
+ }
+ }
+
+ private UStroke getStroke() {
+ UStroke stroke = lineConfig.getSpecificLineStroke();
+ if (stroke == null) {
+ stroke = new UStroke(1.5);
+ }
+ return stroke;
+ }
+
+ public static void drawSymbol(UGraphic ug, double xSymbol, double ySymbol) {
+ xSymbol -= 4 * smallRadius + smallLine + smallMarginX;
+ ySymbol -= 2 * smallRadius + smallMarginY;
+ final UEllipse small = new UEllipse(2 * smallRadius, 2 * smallRadius);
+ ug.apply(new UTranslate(xSymbol, ySymbol)).draw(small);
+ ug.apply(new UTranslate(xSymbol + smallLine + 2 * smallRadius, ySymbol)).draw(small);
+ ug.apply(new UTranslate(xSymbol + 2 * smallRadius, ySymbol + smallLine)).draw(new ULine(smallLine, 0));
+ }
+
+ public ShapeType getShapeType() {
+ return ShapeType.ROUND_RECTANGLE;
+ }
+
+ public int getShield() {
+ return 0;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageState2.java b/src/net/sourceforge/plantuml/svek/image/EntityImageState2.java
new file mode 100644
index 0000000..de9ac78
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/image/EntityImageState2.java
@@ -0,0 +1,123 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.image;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.LineConfigurable;
+import net.sourceforge.plantuml.SkinParamUtils;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.cucadiagram.BodyEnhanced;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.Member;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.SymbolContext;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.graphic.USymbol;
+import net.sourceforge.plantuml.svek.AbstractEntityImage;
+import net.sourceforge.plantuml.svek.ShapeType;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+
+public class EntityImageState2 extends AbstractEntityImage {
+
+ final private Url url;
+
+ final private LineConfigurable lineConfig;
+
+ private final TextBlock asSmall;
+
+ public EntityImageState2(IEntity entity, ISkinParam skinParam) {
+ super(entity, skinParam);
+ this.lineConfig = entity;
+ final Stereotype stereotype = entity.getStereotype();
+
+ Display list = Display.empty();
+ for (Member att : entity.getFieldsToDisplay()) {
+ list = list.addAll(Display.getWithNewlines(att.getDisplay(true)));
+ }
+
+ final USymbol symbol = USymbol.FRAME;
+
+ HtmlColor backcolor = getEntity().getSpecificBackColor();
+ if (backcolor == null) {
+ backcolor = SkinParamUtils.getColor(getSkinParam(), symbol.getColorParamBack(), getStereo());
+ }
+ // backcolor = HtmlColorUtils.BLUE;
+ final HtmlColor forecolor = SkinParamUtils.getColor(getSkinParam(), symbol.getColorParamBorder(), getStereo());
+
+ final SymbolContext ctx = new SymbolContext(backcolor, forecolor).withStroke(new UStroke(1.5)).withShadow(
+ getSkinParam().shadowing());
+
+ this.url = entity.getUrl99();
+ TextBlock stereo = TextBlockUtils.empty(0, 0);
+
+ final TextBlock desc = new BodyEnhanced(entity.getDisplay(), symbol.getFontParam(), skinParam,
+ HorizontalAlignment.CENTER, stereotype, symbol.manageHorizontalLine(), false);
+
+ asSmall = symbol.asSmall(desc, stereo, ctx);
+
+ }
+
+ public ShapeType getShapeType() {
+ return ShapeType.RECTANGLE;
+ }
+
+ public int getShield() {
+ return 0;
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return asSmall.calculateDimension(stringBounder);
+ }
+
+ final public void drawU(UGraphic ug) {
+ if (url != null) {
+ ug.startUrl(url);
+ }
+ asSmall.drawU(ug);
+
+ if (url != null) {
+ ug.closeAction();
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageStateBorder.java b/src/net/sourceforge/plantuml/svek/image/EntityImageStateBorder.java
new file mode 100644
index 0000000..a5d2217
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/image/EntityImageStateBorder.java
@@ -0,0 +1,165 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.image;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.SkinParamUtils;
+import net.sourceforge.plantuml.cucadiagram.EntityPosition;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.svek.AbstractEntityImage;
+import net.sourceforge.plantuml.svek.Bibliotekon;
+import net.sourceforge.plantuml.svek.Cluster;
+import net.sourceforge.plantuml.svek.Shape;
+import net.sourceforge.plantuml.svek.ShapeType;
+import net.sourceforge.plantuml.ugraphic.Shadowable;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class EntityImageStateBorder extends AbstractEntityImage {
+
+ public static final double RADIUS = 6;
+ private final TextBlock desc;
+ private final Cluster stateParent;
+ private final EntityPosition entityPosition;
+ private final Bibliotekon bibliotekon;
+
+ public EntityImageStateBorder(ILeaf leaf, ISkinParam skinParam, Cluster stateParent, final Bibliotekon bibliotekon) {
+ super(leaf, skinParam);
+ this.bibliotekon = bibliotekon;
+
+ this.entityPosition = leaf.getEntityPosition();
+ if (entityPosition == EntityPosition.NORMAL) {
+ throw new IllegalArgumentException();
+ }
+ this.stateParent = stateParent;
+ final Stereotype stereotype = leaf.getStereotype();
+
+ this.desc = TextBlockUtils.create(leaf.getDisplay(),
+ new FontConfiguration(SkinParamUtils.getFont(getSkinParam(), FontParam.STATE, stereotype), SkinParamUtils.getFontColor(getSkinParam(), FontParam.STATE, stereotype),
+ getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()),
+ HorizontalAlignment.CENTER, skinParam);
+ }
+
+ private boolean upPosition() {
+ final Point2D clusterCenter = stateParent.getClusterPosition().getPointCenter();
+ final Shape sh = bibliotekon.getShape(getEntity());
+ return sh.getMinY() < clusterCenter.getY();
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(RADIUS * 2, RADIUS * 2);
+ }
+
+ public double getMaxWidthFromLabelForEntryExit(StringBounder stringBounder) {
+ final Dimension2D dimDesc = desc.calculateDimension(stringBounder);
+ return dimDesc.getWidth();
+ }
+
+ final public void drawU(UGraphic ug) {
+ final Shadowable circle = new UEllipse(RADIUS * 2, RADIUS * 2);
+ // if (getSkinParam().shadowing()) {
+ // circle.setDeltaShadow(4);
+ // }
+
+ double y = 0;
+ final Dimension2D dimDesc = desc.calculateDimension(ug.getStringBounder());
+ final double x = 0 - (dimDesc.getWidth() - 2 * RADIUS) / 2;
+ if (upPosition()) {
+ y -= 2 * RADIUS + dimDesc.getHeight();
+ } else {
+ y += 2 * RADIUS;
+ }
+ desc.drawU(ug.apply(new UTranslate(x, y)));
+
+ ug = ug.apply(new UStroke(1.5)).apply(
+ new UChangeColor(SkinParamUtils.getColor(getSkinParam(), ColorParam.stateBorder, getStereo())));
+ HtmlColor backcolor = getEntity().getSpecificBackColor();
+ if (backcolor == null) {
+ backcolor = SkinParamUtils.getColor(getSkinParam(), ColorParam.stateBackground, getStereo());
+ }
+ ug = ug.apply(new UChangeBackColor(backcolor));
+
+ ug.draw(circle);
+ if (entityPosition == EntityPosition.EXIT_POINT) {
+ final double xc = 0 + RADIUS + .5;
+ final double yc = 0 + RADIUS + .5;
+ final double radius = RADIUS - .5;
+ drawLine(ug, getPointOnCircle(xc, yc, Math.PI / 4, radius),
+ getPointOnCircle(xc, yc, Math.PI + Math.PI / 4, radius));
+ drawLine(ug, getPointOnCircle(xc, yc, -Math.PI / 4, radius),
+ getPointOnCircle(xc, yc, Math.PI - Math.PI / 4, radius));
+ }
+ }
+
+ private Point2D getPointOnCircle(double xc, double yc, double angle, double radius) {
+ final double x = xc + radius * Math.cos(angle);
+ final double y = yc + radius * Math.sin(angle);
+ return new Point2D.Double(x, y);
+ }
+
+ static private void drawLine(UGraphic ug, Point2D p1, Point2D p2) {
+ final double dx = p2.getX() - p1.getX();
+ final double dy = p2.getY() - p1.getY();
+ ug.apply(new UTranslate(p1.getX(), p1.getY())).draw(new ULine(dx, dy));
+
+ }
+
+ public ShapeType getShapeType() {
+ return ShapeType.CIRCLE;
+ }
+
+ public int getShield() {
+ return 0;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageStateEmptyDescription.java b/src/net/sourceforge/plantuml/svek/image/EntityImageStateEmptyDescription.java
new file mode 100644
index 0000000..b0eedec
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/image/EntityImageStateEmptyDescription.java
@@ -0,0 +1,138 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.image;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.SkinParamUtils;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.Member;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.svek.AbstractEntityImage;
+import net.sourceforge.plantuml.svek.ShapeType;
+import net.sourceforge.plantuml.ugraphic.Shadowable;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class EntityImageStateEmptyDescription extends AbstractEntityImage {
+
+ final private TextBlock desc;
+ final private Url url;
+
+ final private static int MIN_WIDTH = 50;
+ final private static int MIN_HEIGHT = 40;
+
+ public EntityImageStateEmptyDescription(IEntity entity, ISkinParam skinParam) {
+ super(entity, skinParam);
+ final Stereotype stereotype = entity.getStereotype();
+
+ this.desc = TextBlockUtils.create(
+ entity.getDisplay(),
+ new FontConfiguration(SkinParamUtils.getFont(getSkinParam(),
+ FontParam.STATE, stereotype), SkinParamUtils.getFontColor(getSkinParam(), FontParam.STATE,
+ stereotype), getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.CENTER, skinParam);
+
+ Display list = Display.empty();
+ for (Member att : entity.getFieldsToDisplay()) {
+ list = list.addAll(Display.getWithNewlines(att.getDisplay(true)));
+ }
+
+ this.url = entity.getUrl99();
+
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dim = desc.calculateDimension(stringBounder);
+ final Dimension2D result = Dimension2DDouble.delta(dim, MARGIN * 2);
+ return Dimension2DDouble.atLeast(result, MIN_WIDTH, MIN_HEIGHT);
+ }
+
+ final public void drawU(UGraphic ug) {
+ if (url != null) {
+ ug.startUrl(url);
+ }
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D dimTotal = calculateDimension(stringBounder);
+ final Dimension2D dimDesc = desc.calculateDimension(stringBounder);
+
+ final double widthTotal = dimTotal.getWidth();
+ final double heightTotal = dimTotal.getHeight();
+ final Shadowable rect = new URectangle(widthTotal, heightTotal, CORNER, CORNER);
+ if (getSkinParam().shadowing()) {
+ rect.setDeltaShadow(4);
+ }
+
+ ug = ug.apply(new UStroke(1.5)).apply(
+ new UChangeColor(SkinParamUtils.getColor(getSkinParam(), ColorParam.stateBorder, getStereo())));
+ HtmlColor backcolor = getEntity().getSpecificBackColor();
+ if (backcolor == null) {
+ backcolor = SkinParamUtils.getColor(getSkinParam(), ColorParam.stateBackground, getStereo());
+ }
+ ug = ug.apply(new UChangeBackColor(backcolor));
+ ug.draw(rect);
+ final double xDesc = (widthTotal - dimDesc.getWidth()) / 2;
+ final double yDesc = (heightTotal - dimDesc.getHeight()) / 2;
+ desc.drawU(ug.apply(new UTranslate(xDesc, yDesc)));
+
+ if (url != null) {
+ ug.closeAction();
+ }
+ }
+
+ public ShapeType getShapeType() {
+ return ShapeType.ROUND_RECTANGLE;
+ }
+
+ public int getShield() {
+ return 0;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageSynchroBar.java b/src/net/sourceforge/plantuml/svek/image/EntityImageSynchroBar.java
new file mode 100644
index 0000000..b252672
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/image/EntityImageSynchroBar.java
@@ -0,0 +1,86 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.image;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.SkinParamUtils;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.cucadiagram.Rankdir;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.svek.AbstractEntityImage;
+import net.sourceforge.plantuml.svek.ShapeType;
+import net.sourceforge.plantuml.ugraphic.Shadowable;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+
+public class EntityImageSynchroBar extends AbstractEntityImage {
+
+ public EntityImageSynchroBar(ILeaf entity, ISkinParam skinParam) {
+ super(entity, skinParam);
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ if (getSkinParam().getRankdir() == Rankdir.LEFT_TO_RIGHT) {
+ return new Dimension2DDouble(8, 80);
+ }
+ return new Dimension2DDouble(80, 8);
+ }
+
+ final public void drawU(UGraphic ug) {
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ final Shadowable rect = new URectangle(dim.getWidth(), dim.getHeight());
+ if (getSkinParam().shadowing()) {
+ rect.setDeltaShadow(4);
+ }
+ ug.apply(new UChangeColor(null))
+ .apply(new UChangeBackColor(SkinParamUtils
+ .getColor(getSkinParam(), ColorParam.activityBar, getStereo()))).draw(rect);
+ }
+
+ public ShapeType getShapeType() {
+ return ShapeType.RECTANGLE;
+ }
+
+ public int getShield() {
+ return 0;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageUseCase.java b/src/net/sourceforge/plantuml/svek/image/EntityImageUseCase.java
new file mode 100644
index 0000000..2170946
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/image/EntityImageUseCase.java
@@ -0,0 +1,193 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.image;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.SkinParamUtils;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.creole.Stencil;
+import net.sourceforge.plantuml.cucadiagram.BodyEnhanced;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.ILeaf;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HorizontalAlignment;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.svek.AbstractEntityImage;
+import net.sourceforge.plantuml.svek.ShapeType;
+import net.sourceforge.plantuml.ugraphic.AbstractUGraphicHorizontalLine;
+import net.sourceforge.plantuml.ugraphic.TextBlockInEllipse;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UHorizontalLine;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class EntityImageUseCase extends AbstractEntityImage {
+
+ final private TextBlock desc;
+
+ final private Url url;
+
+ static private final UStroke stroke = new UStroke(1.5);
+
+ public EntityImageUseCase(ILeaf entity, ISkinParam skinParam) {
+ super(entity, skinParam);
+ final Stereotype stereotype = entity.getStereotype();
+
+ final TextBlock tmp = new BodyEnhanced(entity.getDisplay(), FontParam.USECASE, skinParam,
+ HorizontalAlignment.CENTER, stereotype, true, false);
+
+ if (stereotype == null || stereotype.getLabel(false) == null) {
+ this.desc = tmp;
+ } else {
+ final TextBlock stereo = TextBlockUtils.create(
+ Display.getWithNewlines(stereotype.getLabel(getSkinParam().useGuillemet())),
+ new FontConfiguration(SkinParamUtils.getFont(getSkinParam(),
+ FontParam.ACTOR_STEREOTYPE, stereotype), SkinParamUtils.getFontColor(getSkinParam(),
+ FontParam.ACTOR_STEREOTYPE, null), getSkinParam().getHyperlinkColor(), getSkinParam().useUnderlineForHyperlink()), HorizontalAlignment.CENTER, skinParam);
+ this.desc = TextBlockUtils.mergeTB(stereo, tmp, HorizontalAlignment.CENTER);
+ }
+ this.url = entity.getUrl99();
+
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new TextBlockInEllipse(desc, stringBounder).calculateDimension(stringBounder);
+ }
+
+ final public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final TextBlockInEllipse ellipse = new TextBlockInEllipse(desc, stringBounder);
+ if (getSkinParam().shadowing()) {
+ ellipse.setDeltaShadow(3);
+ }
+
+ if (url != null) {
+ ug.startUrl(url);
+ }
+
+ ug = ug.apply(stroke).apply(
+ new UChangeColor(SkinParamUtils.getColor(getSkinParam(), ColorParam.usecaseBorder, getStereo())));
+ HtmlColor backcolor = getEntity().getSpecificBackColor();
+ if (backcolor == null) {
+ backcolor = SkinParamUtils.getColor(getSkinParam(), ColorParam.usecaseBackground, getStereo());
+ }
+ ug = ug.apply(new UChangeBackColor(backcolor));
+ final UGraphic ug2 = new MyUGraphicEllipse(ug, 0, 0, ellipse.getUEllipse());
+
+ ellipse.drawU(ug2);
+
+ if (url != null) {
+ ug.closeAction();
+ }
+ }
+
+ public ShapeType getShapeType() {
+ return ShapeType.OVAL;
+ }
+
+ public int getShield() {
+ return 0;
+ }
+
+ static class MyUGraphicEllipse extends AbstractUGraphicHorizontalLine {
+
+ private final double startingX;
+ private final double yTheoricalPosition;
+ private final UEllipse ellipse;
+
+ @Override
+ protected AbstractUGraphicHorizontalLine copy(UGraphic ug) {
+ return new MyUGraphicEllipse(ug, startingX, yTheoricalPosition, ellipse);
+ }
+
+ MyUGraphicEllipse(UGraphic ug, double startingX, double yTheoricalPosition, UEllipse ellipse) {
+ super(ug);
+ this.startingX = startingX;
+ this.ellipse = ellipse;
+ this.yTheoricalPosition = yTheoricalPosition;
+ }
+
+ private double getNormalized(double y) {
+ if (y < yTheoricalPosition) {
+ throw new IllegalArgumentException();
+ }
+ y = y - yTheoricalPosition;
+ if (y > ellipse.getHeight()) {
+ throw new IllegalArgumentException();
+ }
+ return y;
+ }
+
+ private double getStartingXInternal(double y) {
+ return startingX + ellipse.getStartingX(getNormalized(y));
+ }
+
+ private double getEndingXInternal(double y) {
+ return startingX + ellipse.getEndingX(getNormalized(y));
+ }
+
+ private Stencil getStencil2(UTranslate translate) {
+ final double dy = translate.getDy();
+ return new Stencil() {
+
+ public double getStartingX(StringBounder stringBounder, double y) {
+ return getStartingXInternal(y + dy);
+ }
+
+ public double getEndingX(StringBounder stringBounder, double y) {
+ return getEndingXInternal(y + dy);
+ }
+ };
+ }
+
+ @Override
+ protected void drawHline(UGraphic ug, UHorizontalLine line, UTranslate translate) {
+ line.drawLineInternal(ug.apply(translate), getStencil2(translate), 0, stroke);
+ }
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/image/Footprint.java b/src/net/sourceforge/plantuml/svek/image/Footprint.java
new file mode 100644
index 0000000..f913a43
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/image/Footprint.java
@@ -0,0 +1,178 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.image;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+import net.sourceforge.plantuml.ugraphic.UChange;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UHorizontalLine;
+import net.sourceforge.plantuml.ugraphic.UImage;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UParamNull;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+import net.sourceforge.plantuml.ugraphic.UText;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class Footprint {
+
+ private final StringBounder stringBounder;
+
+ public Footprint(StringBounder stringBounder) {
+ this.stringBounder = stringBounder;
+
+ }
+
+ class MyUGraphic implements UGraphic {
+
+ private final UTranslate translate;
+ private final List<Point2D.Double> all;
+
+ private MyUGraphic(List<Point2D.Double> all, UTranslate translate) {
+ this.all = all;
+ this.translate = translate;
+ }
+
+ public boolean isSpecialTxt() {
+ return false;
+ }
+
+ public MyUGraphic() {
+ this(new ArrayList<Point2D.Double>(), new UTranslate());
+ }
+
+ public UGraphic apply(UChange change) {
+ if (change instanceof UTranslate) {
+ return new MyUGraphic(all, translate.compose((UTranslate) change));
+ } else if (change instanceof UStroke || change instanceof UChangeColor) {
+ return new MyUGraphic(all, translate);
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ public StringBounder getStringBounder() {
+ return stringBounder;
+ }
+
+ public UParam getParam() {
+ return new UParamNull();
+ }
+
+ public void draw(UShape shape) {
+ final double x = translate.getDx();
+ final double y = translate.getDy();
+ if (shape instanceof UText) {
+ drawText(x, y, (UText) shape);
+ } else if (shape instanceof UHorizontalLine) {
+ // Definitively a Horizontal line
+ } else if (shape instanceof ULine) {
+ // Probably a Horizontal line
+ } else if (shape instanceof UImage) {
+ drawImage(x, y, (UImage) shape);
+ } else {
+ throw new UnsupportedOperationException(shape.getClass().toString());
+ }
+ }
+
+ public ColorMapper getColorMapper() {
+ return new ColorMapperIdentity();
+ }
+
+ public void startUrl(Url url) {
+ }
+
+ public void closeAction() {
+ }
+
+ private void addPoint(double x, double y) {
+ all.add(new Point2D.Double(x, y));
+ }
+
+ private void drawText(double x, double y, UText text) {
+ final Dimension2D dim = stringBounder.calculateDimension(text.getFontConfiguration().getFont(),
+ text.getText());
+ y -= dim.getHeight() - 1.5;
+ addPoint(x, y);
+ addPoint(x, y + dim.getHeight());
+ addPoint(x + dim.getWidth(), y);
+ addPoint(x + dim.getWidth(), y + dim.getHeight());
+ }
+
+ private void drawImage(double x, double y, UImage image) {
+ addPoint(x, y);
+ addPoint(x, y + image.getHeight());
+ addPoint(x + image.getWidth(), y);
+ addPoint(x + image.getWidth(), y + image.getHeight());
+ }
+
+ public void flushUg() {
+ }
+
+ }
+
+ public ContainingEllipse getEllipse(UDrawable drawable, double alpha) {
+ final MyUGraphic ug = new MyUGraphic();
+ drawable.drawU(ug);
+ final List<Point2D.Double> all = ug.all;
+ final ContainingEllipse circle = new ContainingEllipse(alpha);
+ for (Point2D pt : all) {
+ circle.append(pt);
+ }
+ return circle;
+ }
+
+ // public void drawDebug(UGraphic ug, double dx, double dy, TextBlock text) {
+ // final MyUGraphic mug = new MyUGraphic();
+ // text.drawU(mug, dx, dy);
+ // for (Point2D pt : mug.all) {
+ // ug.draw(pt.getX(), pt.getY(), new URectangle(1, 1));
+ // }
+ //
+ // }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/image/Opale.java b/src/net/sourceforge/plantuml/svek/image/Opale.java
new file mode 100644
index 0000000..5e207a6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/image/Opale.java
@@ -0,0 +1,220 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.image;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.Direction;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+import net.sourceforge.plantuml.utils.MathUtils;
+
+public class Opale implements TextBlock {
+
+ private final int cornersize = 10;
+ private final HtmlColor noteBackgroundColor;
+ private final HtmlColor borderColor;
+ private final int marginX1 = 6;
+ private final int marginX2 = 15;
+ private final int marginY = 5;
+ private final boolean withShadow;
+ private Direction strategy;
+ private Point2D pp1;
+ private Point2D pp2;
+ private final boolean withLink;
+
+ private final TextBlock textBlock;
+
+ public Opale(HtmlColor borderColor, HtmlColor noteBackgroundColor, TextBlock textBlock, boolean withShadow,
+ boolean withLink) {
+ this.noteBackgroundColor = noteBackgroundColor;
+ this.withLink = withLink;
+
+ this.withShadow = withShadow;
+ this.borderColor = borderColor;
+ this.textBlock = textBlock;
+ }
+
+ public void setOpale(Direction strategy, Point2D pp1, Point2D pp2) {
+ this.strategy = strategy;
+ this.pp1 = pp1;
+ this.pp2 = pp2;
+ }
+
+ final private double getWidth(StringBounder stringBounder) {
+ return textBlock.calculateDimension(stringBounder).getWidth() + marginX1 + marginX2;
+ }
+
+ final private double getHeight(StringBounder stringBounder) {
+ final Dimension2D size = textBlock.calculateDimension(stringBounder);
+ return size.getHeight() + 2 * marginY;
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final double height = getHeight(stringBounder);
+ final double width = getWidth(stringBounder);
+ return new Dimension2DDouble(width, height);
+ }
+
+ final public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+
+ final UPolygon polygon = getPolygonNormal(stringBounder);
+ if (withShadow) {
+ polygon.setDeltaShadow(4);
+ }
+ ug = ug.apply(new UChangeBackColor(noteBackgroundColor)).apply(new UChangeColor(borderColor));
+ ug.draw(polygon);
+
+ if (withLink) {
+ final UShape polygonOpale;
+ if (strategy == Direction.LEFT) {
+ polygonOpale = getPolygonLeft(stringBounder, pp1, pp2);
+ } else if (strategy == Direction.RIGHT) {
+ polygonOpale = getPolygonRight(stringBounder, pp1, pp2);
+ } else if (strategy == Direction.UP) {
+ polygonOpale = getPolygonUp(stringBounder, pp1, pp2);
+ } else if (strategy == Direction.DOWN) {
+ polygonOpale = getPolygonDown(stringBounder, pp1, pp2);
+ } else {
+ throw new IllegalArgumentException();
+ }
+ ug.draw(polygonOpale);
+ }
+ ug.apply(new UTranslate(getWidth(stringBounder) - cornersize, 0)).draw(new ULine(0, cornersize));
+ ug.apply(new UTranslate(getWidth(stringBounder), cornersize)).draw(new ULine(-cornersize, 0));
+ textBlock.drawU(ug.apply(new UTranslate(marginX1, marginY)));
+ }
+
+ private UPolygon getPolygonNormal(final StringBounder stringBounder) {
+ final UPolygon polygon = new UPolygon();
+ polygon.addPoint(0, 0);
+ polygon.addPoint(0, getHeight(stringBounder));
+ polygon.addPoint(getWidth(stringBounder), getHeight(stringBounder));
+ polygon.addPoint(getWidth(stringBounder), cornersize);
+ polygon.addPoint(getWidth(stringBounder) - cornersize, 0);
+ polygon.addPoint(0, 0);
+ return polygon;
+ }
+
+ private final double delta = 4;
+
+ private UPolygon getPolygonLeft(final StringBounder stringBounder, final Point2D pp1, final Point2D pp2) {
+ final UPolygon polygon = new UPolygon();
+ polygon.addPoint(0, 0);
+
+ double y1 = pp1.getY() - delta;
+ y1 = MathUtils.limitation(y1, 0, getHeight(stringBounder) - 2 * delta);
+ polygon.addPoint(0, y1);
+ polygon.addPoint(pp2.getX(), pp2.getY());
+ polygon.addPoint(0, y1 + 2 * delta);
+
+ polygon.addPoint(0, getHeight(stringBounder));
+ polygon.addPoint(getWidth(stringBounder), getHeight(stringBounder));
+ polygon.addPoint(getWidth(stringBounder), cornersize);
+ polygon.addPoint(getWidth(stringBounder) - cornersize, 0);
+ polygon.addPoint(0, 0);
+ return polygon;
+ }
+
+ private UPolygon getPolygonRight(final StringBounder stringBounder, final Point2D pp1, final Point2D pp2) {
+ final UPolygon polygon = new UPolygon();
+ polygon.addPoint(0, 0);
+ polygon.addPoint(0, getHeight(stringBounder));
+ polygon.addPoint(getWidth(stringBounder), getHeight(stringBounder));
+
+ double y1 = pp1.getY() - delta;
+ y1 = MathUtils.limitation(y1, cornersize, getHeight(stringBounder) - 2 * delta);
+ polygon.addPoint(getWidth(stringBounder), y1 + 2 * delta);
+ polygon.addPoint(pp2.getX(), pp2.getY());
+ polygon.addPoint(getWidth(stringBounder), y1);
+
+ polygon.addPoint(getWidth(stringBounder), cornersize);
+ polygon.addPoint(getWidth(stringBounder) - cornersize, 0);
+ polygon.addPoint(0, 0);
+ return polygon;
+ }
+
+ private UPolygon getPolygonUp(final StringBounder stringBounder, final Point2D pp1, final Point2D pp2) {
+ final UPolygon polygon = new UPolygon();
+ polygon.addPoint(0, 0);
+ polygon.addPoint(0, getHeight(stringBounder));
+ polygon.addPoint(getWidth(stringBounder), getHeight(stringBounder));
+ polygon.addPoint(getWidth(stringBounder), cornersize);
+ polygon.addPoint(getWidth(stringBounder) - cornersize, 0);
+
+ double x1 = pp1.getX() - delta;
+ x1 = MathUtils.limitation(x1, 0, getWidth(stringBounder) - cornersize);
+ polygon.addPoint(x1 + 2 * delta, 0);
+ polygon.addPoint(pp2.getX(), pp2.getY());
+
+ polygon.addPoint(x1, 0);
+ polygon.addPoint(0, 0);
+ return polygon;
+ }
+
+ private UPolygon getPolygonDown(final StringBounder stringBounder, final Point2D pp1, final Point2D pp2) {
+ final UPolygon polygon = new UPolygon();
+ polygon.addPoint(0, 0);
+ polygon.addPoint(0, getHeight(stringBounder));
+
+ double x1 = pp1.getX() - delta;
+ x1 = MathUtils.limitation(x1, 0, getWidth(stringBounder));
+ polygon.addPoint(x1, getHeight(stringBounder));
+ polygon.addPoint(pp2.getX(), pp2.getY());
+ polygon.addPoint(x1 + 2 * delta, getHeight(stringBounder));
+
+ polygon.addPoint(getWidth(stringBounder), getHeight(stringBounder));
+ polygon.addPoint(getWidth(stringBounder), cornersize);
+ polygon.addPoint(getWidth(stringBounder) - cornersize, 0);
+ polygon.addPoint(0, 0);
+ return polygon;
+ }
+
+ public final int getMarginX1() {
+ return marginX1;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/image/SmallestEnclosingCircle.java b/src/net/sourceforge/plantuml/svek/image/SmallestEnclosingCircle.java
new file mode 100644
index 0000000..9adf31c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/image/SmallestEnclosingCircle.java
@@ -0,0 +1,83 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.image;
+
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+import java.util.List;
+
+public class SmallestEnclosingCircle {
+
+ private final List<Point2D> all = new ArrayList<Point2D>();
+ private Circle lastSolution;
+
+ public void append(Point2D pt) {
+ all.add(pt);
+ this.lastSolution = null;
+ }
+
+ public Circle getCircle() {
+ if (lastSolution == null) {
+ lastSolution = findSec(all.size(), all, 0, new ArrayList<Point2D>(all));
+ }
+ return lastSolution;
+ }
+
+ private Circle findSec(int n, List<Point2D> p, int m, List<Point2D> b) {
+ Circle sec = new Circle();
+
+ // Compute the Smallest Enclosing Circle defined by B
+ if (m == 1) {
+ sec = new Circle(b.get(0));
+ } else if (m == 2) {
+ sec = new Circle(b.get(0), b.get(1));
+ } else if (m == 3) {
+ return Circle.getCircle(b.get(0), b.get(1), b.get(2));
+ }
+
+ // Check if all the points in p are enclosed
+ for (int i = 0; i < n; i++) {
+ if (sec.isOutside(p.get(i))) {
+ // Compute B <--- B union P[i].
+ b.set(m, p.get(i));
+ // Recurse
+ sec = findSec(i, p, m + 1, b);
+ }
+ }
+
+ return sec;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svek/image/YTransformer.java b/src/net/sourceforge/plantuml/svek/image/YTransformer.java
new file mode 100644
index 0000000..1d49cdb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svek/image/YTransformer.java
@@ -0,0 +1,59 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svek.image;
+
+import java.awt.geom.Point2D;
+
+public class YTransformer {
+
+ private final double alpha;
+
+ public YTransformer(double alpha) {
+ this.alpha = alpha;
+ }
+
+ public Point2D getPoint2D(Point2D pt) {
+ return new Point2D.Double(pt.getX(), pt.getY() * alpha);
+ }
+
+ public Point2D getReversePoint2D(Point2D pt) {
+ return new Point2D.Double(pt.getX(), pt.getY() / alpha);
+ }
+
+ public double getAlpha() {
+ return alpha;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svg/SvgData.java b/src/net/sourceforge/plantuml/svg/SvgData.java
new file mode 100644
index 0000000..5f2759b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svg/SvgData.java
@@ -0,0 +1,143 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svg;
+
+import java.util.StringTokenizer;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public final class SvgData {
+
+ private String svg;
+ private double startX;
+ private double startY;
+ private double width;
+ private double height;
+
+ public static SvgData fromGraphViz(String s) {
+ return new SvgData(removeSvgXmlHeader1(s));
+ }
+
+ private SvgData(String svg) {
+ this.svg = svg;
+ init();
+ }
+
+ private SvgData() {
+ }
+
+ private static String removeSvgXmlHeader1(String svg) {
+ final String newString = "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">";
+ svg = svg.replaceFirst("(?i)<svg[^>]*>", newString);
+ return svg;
+ }
+
+ public SvgData mutateFromSvgTitler(String newSvg, double suppHeight, double suppWidth) {
+ final SvgData result = new SvgData();
+ result.svg = newSvg;
+ result.startX = this.startX - suppWidth / 2;
+ result.startY = this.startY;
+ result.width = this.width + suppWidth;
+ result.height = this.height + suppHeight;
+ return result;
+ }
+
+ public final String getSvg() {
+ return modifiedSvgXmlHeader();
+ }
+
+ private void init() {
+ final Pattern p = Pattern.compile("(?i)<polygon\\s+[^>]*points=\"([^\"]+)\"");
+ final Matcher m = p.matcher(svg);
+ double minX = Double.MAX_VALUE;
+ double minY = Double.MAX_VALUE;
+ double maxX = -Double.MAX_VALUE;
+ double maxY = -Double.MAX_VALUE;
+ if (m.find() == false) {
+ return;
+ }
+ final String points = m.group(1);
+ final StringTokenizer st = new StringTokenizer(points, " ");
+ while (st.hasMoreTokens()) {
+ final String token = st.nextToken();
+ final StringTokenizer st2 = new StringTokenizer(token, ",");
+ final double x = Double.parseDouble(st2.nextToken().trim());
+ final double y = Double.parseDouble(st2.nextToken().trim());
+ if (x < minX) {
+ minX = x;
+ }
+ if (y < minY) {
+ minY = y;
+ }
+ if (x > maxX) {
+ maxX = x;
+ }
+ if (y > maxY) {
+ maxY = y;
+ }
+ }
+
+ this.width = maxX - minX;
+ this.height = maxY - minY;
+ }
+
+ private String modifiedSvgXmlHeader() {
+ final StringBuilder newString = new StringBuilder(
+ "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" ");
+ newString.append("style=\"width:");
+ newString.append(Math.round(getWidth()));
+ newString.append(";height:");
+ newString.append(Math.round(getHeight()));
+ newString.append(";\" ");
+ newString.append("width=\"" + Math.round(getWidth()) + "pt\" ");
+ newString.append("height=\"" + Math.round(getHeight()) + "pt\" ");
+ newString.append("viewBox=\"" + Math.round(startX) + " " + Math.round(startY) + " " + Math.round(getWidth()) + " "
+ + Math.round(getHeight()) + "\"");
+ // newString.append("viewBox=\"" + Math.round(minX) + " " +
+ // Math.round(minY) + " " + Math.round(getWidth()) + " "
+ // + Math.round(getHeight()) + "\"");
+ newString.append(">");
+ return svg.replaceFirst("(?i)<svg[^>]*>", newString.toString());
+ }
+
+ public double getWidth() {
+ return width;
+ }
+
+ public double getHeight() {
+ return height;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/svg/SvgGraphics.java b/src/net/sourceforge/plantuml/svg/SvgGraphics.java
new file mode 100644
index 0000000..7f3ffe2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/svg/SvgGraphics.java
@@ -0,0 +1,699 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.svg;
+
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.imageio.ImageIO;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import net.sourceforge.plantuml.Log;
+import net.sourceforge.plantuml.code.Base64Coder;
+import net.sourceforge.plantuml.eps.EpsGraphics;
+import net.sourceforge.plantuml.graphic.HtmlColorGradient;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.USegment;
+import net.sourceforge.plantuml.ugraphic.USegmentType;
+import net.sourceforge.plantuml.StringUtils;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+public class SvgGraphics {
+
+ // http://tutorials.jenkov.com/svg/index.html
+ // http://www.svgbasics.com/
+ // http://apike.ca/prog_svg_text.html
+ // http://www.w3.org/TR/SVG11/shapes.html
+ // http://en.wikipedia.org/wiki/Scalable_Vector_Graphics
+
+ // Animation:
+ // http://srufaculty.sru.edu/david.dailey/svg/
+ // Shadow:
+ // http://www.svgbasics.com/filters3.html
+ // http://www.w3schools.com/svg/svg_feoffset.asp
+ // http://www.adobe.com/svg/demos/samples.html
+
+ final private Document document;
+ final private Element root;
+ final private Element defs;
+ final private Element gRoot;
+
+ private String fill = "black";
+ private String stroke = "black";
+ private String strokeWidth;
+ private String strokeDasharray = null;
+ private final String backcolor;
+
+ private int maxX = 10;
+ private int maxY = 10;
+
+ private final double scale;
+
+ final protected void ensureVisible(double x, double y) {
+ if (x > maxX) {
+ maxX = (int) (x + 1);
+ }
+ if (y > maxY) {
+ maxY = (int) (y + 1);
+ }
+ }
+
+ public SvgGraphics(double scale) {
+ this(null, scale);
+ }
+
+ public SvgGraphics(String backcolor, double scale) {
+ try {
+ this.scale = scale;
+ this.document = getDocument();
+ this.backcolor = backcolor;
+
+ this.root = getRootNode();
+
+ // Create a node named defs, which will be the parent
+ // for a pair of linear gradient definitions.
+ defs = simpleElement("defs");
+ gRoot = simpleElement("g");
+ strokeWidth = "" + scale;
+ } catch (ParserConfigurationException e) {
+ e.printStackTrace();
+ throw new IllegalStateException(e);
+ }
+ }
+
+ private Element pendingBackground;
+
+ public void paintBackcolorGradient(ColorMapper mapper, HtmlColorGradient gr) {
+ final String id = createSvgGradient(StringUtils.getAsHtml(mapper.getMappedColor(gr.getColor1())),
+ StringUtils.getAsHtml(mapper.getMappedColor(gr.getColor2())), gr.getPolicy());
+ setFillColor("url(#" + id + ")");
+ setStrokeColor(null);
+ pendingBackground = createRectangleInternal(0, 0, 0, 0);
+ getG().appendChild(pendingBackground);
+ }
+
+ // This method returns a reference to a simple XML
+ // element node that has no attributes.
+ private Element simpleElement(String type) {
+ final Element theElement = (Element) document.createElement(type);
+ root.appendChild(theElement);
+ return theElement;
+ }
+
+ private Document getDocument() throws ParserConfigurationException {
+ final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+
+ final DocumentBuilder builder = factory.newDocumentBuilder();
+ final Document document = builder.newDocument();
+ document.setXmlStandalone(true);
+ return document;
+ }
+
+ // This method returns a reference to a root node that
+ // has already been appended to the document.
+ private Element getRootNode() {
+ // Create the root node named svg and append it to
+ // the document.
+ final Element svg = (Element) document.createElement("svg");
+ document.appendChild(svg);
+
+ // Set some attributes on the root node that are
+ // required for proper rendering. Note that the
+ // approach used here is somewhat different from the
+ // approach used in the earlier program named Svg01,
+ // particularly with regard to the style.
+ svg.setAttribute("xmlns", "http://www.w3.org/2000/svg");
+ svg.setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
+ svg.setAttribute("version", "1.1");
+
+ return svg;
+ }
+
+ public void svgEllipse(double x, double y, double xRadius, double yRadius, double deltaShadow) {
+ manageShadow(deltaShadow);
+ if (hidden == false) {
+ final Element elt = (Element) document.createElement("ellipse");
+ elt.setAttribute("cx", format(x));
+ elt.setAttribute("cy", format(y));
+ elt.setAttribute("rx", format(xRadius));
+ elt.setAttribute("ry", format(yRadius));
+ elt.setAttribute("fill", fill);
+ elt.setAttribute("style", getStyle());
+ if (deltaShadow > 0) {
+ elt.setAttribute("filter", "url(#f1)");
+ }
+ getG().appendChild(elt);
+ }
+ ensureVisible(x + xRadius + deltaShadow * 2, y + yRadius + deltaShadow * 2);
+ }
+
+ public void svgArcEllipse(double rx, double ry, double x1, double y1, double x2, double y2) {
+ if (hidden == false) {
+ final String path = "M" + format(x1) + "," + format(y1) + " A" + format(rx) + "," + format(ry) + " 0 0 0 "
+ + format(x2) + " " + format(y2);
+ final Element elt = (Element) document.createElement("path");
+ elt.setAttribute("d", path);
+ elt.setAttribute("fill", fill);
+ elt.setAttribute("style", getStyle());
+ getG().appendChild(elt);
+ }
+ ensureVisible(x1, y1);
+ ensureVisible(x2, y2);
+ }
+
+ private Map<List<Object>, String> gradients = new HashMap<List<Object>, String>();
+
+ public String createSvgGradient(String color1, String color2, char policy) {
+ final List<Object> key = Arrays.asList((Object) color1, color2, policy);
+ String id = gradients.get(key);
+ if (id == null) {
+ final Element elt = (Element) document.createElement("linearGradient");
+ if (policy == '|') {
+ elt.setAttribute("x1", "0%");
+ elt.setAttribute("y1", "50%");
+ elt.setAttribute("x2", "100%");
+ elt.setAttribute("y2", "50%");
+ } else if (policy == '\\') {
+ elt.setAttribute("x1", "0%");
+ elt.setAttribute("y1", "100%");
+ elt.setAttribute("x2", "100%");
+ elt.setAttribute("y2", "0%");
+ } else if (policy == '-') {
+ elt.setAttribute("x1", "50%");
+ elt.setAttribute("y1", "0%");
+ elt.setAttribute("x2", "50%");
+ elt.setAttribute("y2", "100%");
+ } else {
+ elt.setAttribute("x1", "0%");
+ elt.setAttribute("y1", "0%");
+ elt.setAttribute("x2", "100%");
+ elt.setAttribute("y2", "100%");
+ }
+ id = "gr" + gradients.size();
+ gradients.put(key, id);
+ elt.setAttribute("id", id);
+
+ final Element stop1 = (Element) document.createElement("stop");
+ stop1.setAttribute("stop-color", color1);
+ stop1.setAttribute("offset", "0%");
+ final Element stop2 = (Element) document.createElement("stop");
+ stop2.setAttribute("stop-color", color2);
+ stop2.setAttribute("offset", "100%");
+
+ elt.appendChild(stop1);
+ elt.appendChild(stop2);
+ defs.appendChild(elt);
+ }
+ return id;
+ }
+
+ public final void setFillColor(String fill) {
+ this.fill = fill == null ? "none" : fill;
+ }
+
+ public final void setStrokeColor(String stroke) {
+ this.stroke = stroke == null ? "none" : stroke;
+ }
+
+ public final void setStrokeWidth(double strokeWidth, String strokeDasharray) {
+ this.strokeWidth = "" + (scale * strokeWidth);
+ this.strokeDasharray = strokeDasharray;
+ }
+
+ public void closeLink() {
+ final Element element = pendingLink2.get(0);
+ pendingLink2.remove(0);
+ getG().appendChild(element);
+ }
+
+ private final List<Element> pendingLink2 = new ArrayList<Element>();
+
+ public void openLink(String url, String title) {
+ if (url == null) {
+ throw new IllegalArgumentException();
+ }
+
+ pendingLink2.add(0, (Element) document.createElement("a"));
+ pendingLink2.get(0).setAttribute("xlink:href", url);
+ if (title == null) {
+ pendingLink2.get(0).setAttribute("xlink:title", url);
+ } else {
+ pendingLink2.get(0).setAttribute("xlink:title", title);
+ }
+ }
+
+ public final Element getG() {
+ if (pendingLink2.size() == 0) {
+ return gRoot;
+ }
+ return pendingLink2.get(0);
+ }
+
+ public void svgRectangle(double x, double y, double width, double height, double rx, double ry, double deltaShadow) {
+ if (height <= 0 || width <= 0) {
+ throw new IllegalArgumentException();
+ }
+ manageShadow(deltaShadow);
+ if (hidden == false) {
+ final Element elt = createRectangleInternal(x, y, width, height);
+ if (deltaShadow > 0) {
+ elt.setAttribute("filter", "url(#f1)");
+ }
+ if (rx > 0 && ry > 0) {
+ elt.setAttribute("rx", format(rx));
+ elt.setAttribute("ry", format(ry));
+ }
+
+ getG().appendChild(elt);
+ }
+ ensureVisible(x + width + 2 * deltaShadow, y + height + 2 * deltaShadow);
+ }
+
+ private Element createRectangleInternal(double x, double y, double width, double height) {
+ final Element elt = (Element) document.createElement("rect");
+ elt.setAttribute("x", format(x));
+ elt.setAttribute("y", format(y));
+ elt.setAttribute("width", format(width));
+ elt.setAttribute("height", format(height));
+ elt.setAttribute("fill", fill);
+ elt.setAttribute("style", getStyle());
+ return elt;
+ }
+
+ public void svgLine(double x1, double y1, double x2, double y2, double deltaShadow) {
+ manageShadow(deltaShadow);
+ if (hidden == false) {
+ final Element elt = (Element) document.createElement("line");
+ elt.setAttribute("x1", format(x1));
+ elt.setAttribute("y1", format(y1));
+ elt.setAttribute("x2", format(x2));
+ elt.setAttribute("y2", format(y2));
+ elt.setAttribute("style", getStyle());
+ if (deltaShadow > 0) {
+ elt.setAttribute("filter", "url(#f1)");
+ }
+ getG().appendChild(elt);
+ }
+ ensureVisible(x1 + 2 * deltaShadow, y1 + 2 * deltaShadow);
+ ensureVisible(x2 + 2 * deltaShadow, y2 + 2 * deltaShadow);
+ }
+
+ private String getStyle() {
+ return getStyleInternal(stroke, strokeWidth, strokeDasharray);
+ }
+
+ private static String getStyleInternal(String color, String strokeWidth, String strokeDasharray) {
+ final StringBuilder style = new StringBuilder("stroke: " + color + "; stroke-width: " + strokeWidth + ";");
+ if (strokeDasharray != null) {
+ style.append(" stroke-dasharray: " + strokeDasharray + ";");
+ }
+ return style.toString();
+ }
+
+ public void svgPolygon(double deltaShadow, double... points) {
+ manageShadow(deltaShadow);
+ if (hidden == false) {
+ final Element elt = (Element) document.createElement("polygon");
+ final StringBuilder sb = new StringBuilder();
+ for (double coord : points) {
+ if (sb.length() > 0) {
+ sb.append(",");
+ }
+ sb.append(format(coord));
+ }
+ elt.setAttribute("points", sb.toString());
+ elt.setAttribute("fill", fill);
+ elt.setAttribute("style", getStyle());
+ if (deltaShadow > 0) {
+ elt.setAttribute("filter", "url(#f1)");
+ }
+ getG().appendChild(elt);
+ }
+
+ for (int i = 0; i < points.length; i += 2) {
+ ensureVisible(points[i] + 2 * deltaShadow, points[i + 1] + 2 * deltaShadow);
+ }
+
+ }
+
+ public void text(String text, double x, double y, String fontFamily, int fontSize, String fontWeight,
+ String fontStyle, String textDecoration, double textLength, Map<String, String> attributes) {
+ if (hidden == false) {
+ final Element elt = (Element) document.createElement("text");
+ elt.setAttribute("x", format(x));
+ elt.setAttribute("y", format(y));
+ elt.setAttribute("fill", fill);
+ elt.setAttribute("font-size", format(fontSize));
+ // elt.setAttribute("text-anchor", "middle");
+ elt.setAttribute("lengthAdjust", "spacingAndGlyphs");
+ elt.setAttribute("textLength", format(textLength));
+ if (fontWeight != null) {
+ elt.setAttribute("font-weight", fontWeight);
+ }
+ if (fontStyle != null) {
+ elt.setAttribute("font-style", fontStyle);
+ }
+ if (textDecoration != null) {
+ elt.setAttribute("text-decoration", textDecoration);
+ }
+ if (fontFamily != null) {
+ elt.setAttribute("font-family", fontFamily);
+ }
+ for (Map.Entry<String, String> ent : attributes.entrySet()) {
+ elt.setAttribute(ent.getKey(), ent.getValue());
+ }
+ elt.setTextContent(text);
+ getG().appendChild(elt);
+
+ if (textDecoration != null && textDecoration.contains("underline")) {
+ final double delta = 2;
+ final Element elt2 = (Element) document.createElement("line");
+ elt2.setAttribute("x1", format(x));
+ elt2.setAttribute("y1", format(y + delta));
+ elt2.setAttribute("x2", format(x + textLength));
+ elt2.setAttribute("y2", format(y + delta));
+ elt2.setAttribute("style", getStyleInternal(fill, "1.0", null));
+ getG().appendChild(elt2);
+ }
+
+ }
+ ensureVisible(x, y);
+ ensureVisible(x + textLength, y);
+ }
+
+ public final Element getDefs() {
+ return defs;
+ }
+
+ private Transformer getTransformer() throws TransformerException {
+ // Get a TransformerFactory object.
+ final TransformerFactory xformFactory = TransformerFactory.newInstance();
+ // try {
+ // final Class<?> factoryClass = Class
+ // .forName("com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl");
+ // xformFactory = (TransformerFactory) factoryClass.newInstance();
+ // } catch (Exception e) {
+ // xformFactory = TransformerFactory.newInstance();
+ // }
+ Log.info("TransformerFactory=" + xformFactory.getClass());
+
+ // Get an XSL Transformer object.
+ final Transformer transformer = xformFactory.newTransformer();
+ Log.info("Transformer=" + transformer.getClass());
+
+ // // Sets the standalone property in the first line of
+ // // the output file.
+ transformer.setOutputProperty(OutputKeys.STANDALONE, "yes");
+ //
+ // Properties proprietes = new Properties();
+ // proprietes.put("standalone", "yes");
+ // transformer.setOutputProperties(proprietes);
+ //
+ // transformer.setParameter(OutputKeys.STANDALONE, "yes");
+
+ return transformer;
+ }
+
+ public void createXml(OutputStream os) throws TransformerException, IOException {
+ if (images.size() == 0) {
+ createXmlInternal(os);
+ return;
+ }
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ createXmlInternal(baos);
+ String s = new String(baos.toByteArray());
+ for (Map.Entry<String, String> ent : images.entrySet()) {
+ final String k = "\\<" + ent.getKey() + "/\\>";
+ s = s.replaceAll(k, ent.getValue());
+ }
+ os.write(s.getBytes());
+ }
+
+ private void createXmlInternal(OutputStream os) throws TransformerException {
+ // // Add lines
+ // for (Line l : lines) {
+ // l.drawNow();
+ // }
+
+ // Get a DOMSource object that represents the
+ // Document object
+ final DOMSource source = new DOMSource(document);
+
+ final int maxXscaled = (int) (maxX * scale);
+ final int maxYscaled = (int) (maxY * scale);
+ String style = "width:" + maxXscaled + "px;height:" + maxYscaled + "px;";
+ if (backcolor != null) {
+ style += "background:" + backcolor + ";";
+ }
+ root.setAttribute("style", style);
+ root.setAttribute("width", format(maxX) + "px");
+ root.setAttribute("height", format(maxY) + "px");
+ root.setAttribute("viewBox", "0 0 " + maxXscaled + " " + maxYscaled);
+
+ if (pendingBackground != null) {
+ pendingBackground.setAttribute("width", format(maxX));
+ pendingBackground.setAttribute("height", format(maxY));
+
+ }
+
+ // Get a StreamResult object that points to the
+ // screen. Then transform the DOM sending XML to
+ // the screen.
+ final StreamResult scrResult = new StreamResult(os);
+ getTransformer().transform(source, scrResult);
+ }
+
+ public void svgPath(double x, double y, UPath path, double deltaShadow) {
+ manageShadow(deltaShadow);
+ ensureVisible(x, y);
+ final StringBuilder sb = new StringBuilder();
+ for (USegment seg : path) {
+ final USegmentType type = seg.getSegmentType();
+ final double coord[] = seg.getCoord();
+ if (type == USegmentType.SEG_MOVETO) {
+ sb.append("M" + format(coord[0] + x) + "," + format(coord[1] + y) + " ");
+ ensureVisible(coord[0] + x + 2 * deltaShadow, coord[1] + y + 2 * deltaShadow);
+ } else if (type == USegmentType.SEG_LINETO) {
+ sb.append("L" + format(coord[0] + x) + "," + format(coord[1] + y) + " ");
+ ensureVisible(coord[0] + x + 2 * deltaShadow, coord[1] + y + 2 * deltaShadow);
+ } else if (type == USegmentType.SEG_QUADTO) {
+ sb.append("Q" + format(coord[0] + x) + "," + format(coord[1] + y) + " " + format(coord[2] + x) + ","
+ + format(coord[3] + y) + " ");
+ ensureVisible(coord[0] + x + 2 * deltaShadow, coord[1] + y + 2 * deltaShadow);
+ ensureVisible(coord[2] + x + 2 * deltaShadow, coord[3] + y + 2 * deltaShadow);
+ } else if (type == USegmentType.SEG_CUBICTO) {
+ sb.append("C" + format(coord[0] + x) + "," + format(coord[1] + y) + " " + format(coord[2] + x) + ","
+ + format(coord[3] + y) + " " + format(coord[4] + x) + "," + format(coord[5] + y) + " ");
+ ensureVisible(coord[0] + x + 2 * deltaShadow, coord[1] + y + 2 * deltaShadow);
+ ensureVisible(coord[2] + x + 2 * deltaShadow, coord[3] + y + 2 * deltaShadow);
+ ensureVisible(coord[4] + x + 2 * deltaShadow, coord[5] + y + 2 * deltaShadow);
+ } else if (type == USegmentType.SEG_ARCTO) {
+ sb.append("A" + format(coord[0]) + "," + format(coord[1]) + " " + format(coord[2]) + ","
+ + format(coord[3]) + " " + format(coord[4]) + "," + format(coord[5] + x) + ","
+ + format(coord[6] + y) + " ");
+ ensureVisible(coord[5] + coord[0] + x + 2 * deltaShadow, coord[6] + coord[1] + y + 2 * deltaShadow);
+ } else if (type == USegmentType.SEG_CLOSE) {
+ // Nothing
+ } else {
+ Log.println("unknown " + seg);
+ }
+
+ }
+ if (hidden == false) {
+ final Element elt = (Element) document.createElement("path");
+ elt.setAttribute("d", sb.toString());
+ elt.setAttribute("style", getStyle());
+ elt.setAttribute("fill", fill);
+ if (deltaShadow > 0) {
+ elt.setAttribute("filter", "url(#f1)");
+ }
+ getG().appendChild(elt);
+ }
+ }
+
+ private StringBuilder currentPath = null;
+
+ public void newpath() {
+ currentPath = new StringBuilder();
+
+ }
+
+ public void moveto(double x, double y) {
+ currentPath.append("M" + format(x) + "," + format(y) + " ");
+ ensureVisible(x, y);
+ }
+
+ public void lineto(double x, double y) {
+ currentPath.append("L" + format(x) + "," + format(y) + " ");
+ ensureVisible(x, y);
+ }
+
+ public void closepath() {
+ currentPath.append("Z ");
+
+ }
+
+ public void curveto(double x1, double y1, double x2, double y2, double x3, double y3) {
+ currentPath.append("C" + format(x1) + "," + format(y1) + " " + format(x2) + "," + format(y2) + " " + format(x3)
+ + "," + format(y3) + " ");
+ ensureVisible(x1, y1);
+ ensureVisible(x2, y2);
+ ensureVisible(x3, y3);
+
+ }
+
+ public void quadto(double x1, double y1, double x2, double y2) {
+ currentPath.append("Q" + format(x1) + "," + format(y1) + " " + format(x2) + "," + format(y2) + " ");
+ ensureVisible(x1, y1);
+ ensureVisible(x2, y2);
+ }
+
+ private String format(double x) {
+ return EpsGraphics.format(x * scale);
+ }
+
+ public void fill(int windingRule) {
+ if (hidden == false) {
+ final Element elt = (Element) document.createElement("path");
+ elt.setAttribute("d", currentPath.toString());
+ // elt elt.setAttribute("style", getStyle());
+ getG().appendChild(elt);
+ }
+ currentPath = null;
+
+ }
+
+ public void svgImage(BufferedImage image, double x, double y) throws IOException {
+ if (hidden == false) {
+ final Element elt = (Element) document.createElement("image");
+ elt.setAttribute("width", format(image.getWidth()));
+ elt.setAttribute("height", format(image.getHeight()));
+ elt.setAttribute("x", format(x));
+ elt.setAttribute("y", format(y));
+ final String s = toBase64(image);
+ elt.setAttribute("xlink:href", "data:image/png;base64," + s);
+ getG().appendChild(elt);
+ }
+ ensureVisible(x, y);
+ ensureVisible(x + image.getWidth(), y + image.getHeight());
+ }
+
+ private final Map<String, String> images = new HashMap<String, String>();
+
+ public void svgImage(String svg, double x, double y) {
+ if (svg.startsWith("<svg>") == false) {
+ throw new IllegalArgumentException();
+ }
+ if (hidden == false) {
+ final String pos = "<svg x=\"" + format(x) + "\" y=\"" + format(y) + "\">";
+ svg = pos + svg.substring(5);
+ // System.err.println("svg=" + svg);
+ // System.err.println("x=" + x);
+ // System.err.println("y=" + y);
+ final String key = "imagesvginlined" + images.size();
+ final Element elt = (Element) document.createElement(key);
+ getG().appendChild(elt);
+ images.put(key, svg);
+ }
+ ensureVisible(x, y);
+ }
+
+ private String toBase64(BufferedImage image) throws IOException {
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ImageIO.write(image, "png", baos);
+ final byte data[] = baos.toByteArray();
+ return new String(Base64Coder.encode(data));
+ }
+
+ // Shadow
+
+ private boolean withShadow = false;
+
+ private void manageShadow(double deltaShadow) {
+ if (deltaShadow != 0) {
+ if (withShadow == false) {
+ // <filter id="f1" x="0" y="0" width="120%" height="120%">
+ final Element filter = (Element) document.createElement("filter");
+ filter.setAttribute("id", "f1");
+ filter.setAttribute("x", "-1");
+ filter.setAttribute("y", "-1");
+ filter.setAttribute("width", "300%");
+ filter.setAttribute("height", "300%");
+ addFilter(filter, "feGaussianBlur", "result", "blurOut", "stdDeviation", "" + (2 * scale));
+ addFilter(filter, "feColorMatrix", "type", "matrix", "in", "blurOut", "result", "blurOut2", "values",
+ "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .4 0");
+ addFilter(filter, "feOffset", "result", "blurOut3", "in", "blurOut2", "dx", "" + (4 * scale), "dy", ""
+ + (4 * scale));
+ addFilter(filter, "feBlend", "in", "SourceGraphic", "in2", "blurOut3", "mode", "normal");
+ defs.appendChild(filter);
+
+ }
+ withShadow = true;
+ }
+ }
+
+ private void addFilter(Element filter, String name, String... data) {
+ final Element elt = (Element) document.createElement(name);
+ for (int i = 0; i < data.length; i += 2) {
+ elt.setAttribute(data[i], data[i + 1]);
+ }
+ filter.appendChild(elt);
+ }
+
+ private boolean hidden;
+
+ public void setHidden(boolean hidden) {
+ this.hidden = hidden;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/swing/AboutWindow.java b/src/net/sourceforge/plantuml/swing/AboutWindow.java
new file mode 100644
index 0000000..0d671bf
--- /dev/null
+++ b/src/net/sourceforge/plantuml/swing/AboutWindow.java
@@ -0,0 +1,154 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.swing;
+
+import java.awt.BorderLayout;
+import java.awt.Font;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.List;
+
+import javax.swing.BorderFactory;
+import javax.swing.ImageIcon;
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JEditorPane;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.WindowConstants;
+import javax.swing.border.BevelBorder;
+import javax.swing.border.CompoundBorder;
+
+import net.sourceforge.plantuml.version.PSystemVersion;
+import net.sourceforge.plantuml.version.Version;
+
+class AboutWindow extends JFrame {
+
+ /*
+ * - the PlantUML version - the Dot version - the PlantUML authors - the PlantUML license
+ */
+ public AboutWindow() {
+ super();
+ setIconImage(PSystemVersion.getPlantumlSmallIcon2());
+
+ this.setTitle("About PlantUML (" + Version.versionString() + ")");
+
+ final JPanel panel1 = new JPanel(new GridLayout(2, 1));
+ panel1.add(getInfoVersion());
+ panel1.add(getInfoAuthors());
+
+ getContentPane().add(getNorthLabel(), BorderLayout.NORTH);
+ getContentPane().add(panel1, BorderLayout.CENTER);
+ getContentPane().add(getSouthLabel(), BorderLayout.SOUTH);
+
+ pack();
+ this.setLocationRelativeTo(this.getParent());
+ setVisible(true);
+ setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
+ }
+
+ private JComponent getNorthLabel() {
+ final JLabel text = new JLabel("PlantUML (" + Version.versionString() + ")");
+ final Font font = text.getFont().deriveFont(Font.BOLD, (float) 20.0);
+ text.setFont(font);
+ final JPanel ptext = new JPanel();
+ ptext.add(text);
+
+ final JLabel icon = new JLabel(new ImageIcon(PSystemVersion.getPlantumlImage()));
+
+ final JPanel result = new JPanel(new BorderLayout());
+ result.add(ptext, BorderLayout.CENTER);
+ result.add(icon, BorderLayout.EAST);
+
+ return result;
+ }
+
+ private JComponent getSouthLabel() {
+ final JPanel result = new JPanel();
+ final JButton license = new JButton("License");
+ license.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent ae) {
+ new LicenseWindow();
+ }
+ });
+ final JButton ok = new JButton("OK");
+ ok.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent ae) {
+ dispose();
+ }
+ });
+ result.add(license);
+ result.add(ok);
+ return result;
+ }
+
+ private JComponent getInfoVersion() {
+ final PSystemVersion p1 = PSystemVersion.createShowVersion();
+ return getJComponent(skip(p1.getLines()));
+ }
+
+ private JComponent getInfoAuthors() {
+ final PSystemVersion p1 = PSystemVersion.createShowAuthors();
+ return getJComponent(skip(p1.getLines()));
+ }
+
+ private List<String> skip(List<String> lines) {
+ return lines.subList(2, lines.size());
+ }
+
+ private JComponent getJComponent(List<String> lines) {
+ final StringBuilder sb = new StringBuilder("<html>");
+ for (String s : lines) {
+ sb.append(s + "</b></i></u>");
+ sb.append("<br>");
+ }
+ sb.append("</html>");
+ final JEditorPane text = new JEditorPane("text/html", sb.toString());
+ text.setEditable(false);
+ CompoundBorder border = new CompoundBorder(BorderFactory.createEtchedBorder(BevelBorder.RAISED),
+ BorderFactory.createEmptyBorder(5, 5, 5, 5));
+ border = new CompoundBorder(BorderFactory.createMatteBorder(5, 5, 5, 5, getBackground()), border);
+ text.setBorder(border);
+
+ return text;
+ }
+
+ public static void main(String arg[]) {
+ new AboutWindow();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/swing/ImageHelper.java b/src/net/sourceforge/plantuml/swing/ImageHelper.java
new file mode 100644
index 0000000..10a8111
--- /dev/null
+++ b/src/net/sourceforge/plantuml/swing/ImageHelper.java
@@ -0,0 +1,173 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.swing;
+
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.RenderingHints;
+import java.awt.Transparency;
+import java.awt.image.BufferedImage;
+
+/**
+ * A collection of methods to help with processing images. A majority of this code was originally found online.
+ */
+public class ImageHelper {
+ /**
+ * Returns a scaled instance of a {@code BufferedImage}.
+ *
+ * Modified from: https://today.java.net/pub/a/today/2007/04/03/perils-of-image-getscaledinstance.html
+ *
+ * @param img
+ * the original image to be scaled
+ * @param targetDim
+ * the desired dimensions of the scaled instance, in pixels
+ * @param hint
+ * RenderingHints used when scaling the image
+ * @param higherQuality
+ * if true, this method will use a multi-step scaling technique that provides higher quality than the
+ * usual one-step technique (only useful in downscaling cases, targetDim is smaller than the original
+ * dimensions, and generally only when the {@code BILINEAR} hint is specified)
+ * @return a scaled version of the original {@code BufferedImage}
+ */
+ public static BufferedImage getScaledInstance(BufferedImage img, Dimension targetDim, RenderingHints hints,
+ boolean higherQuality) {
+ final int targetWidth = targetDim.width;
+ final int targetHeight = targetDim.height;
+ final int type = (img.getTransparency() == Transparency.OPAQUE) ? BufferedImage.TYPE_INT_RGB
+ : BufferedImage.TYPE_INT_ARGB;
+ BufferedImage ret = (BufferedImage) img;
+ int w;
+ int h;
+ if (higherQuality) {
+ // Use multi-step technique: start with original size, then
+ // scale down in multiple passes with drawImage()
+ // until the target size is reached
+ w = img.getWidth();
+ h = img.getHeight();
+ } else {
+ // Use one-step technique: scale directly from original
+ // size to target size with a single drawImage() call
+ w = targetWidth;
+ h = targetHeight;
+ }
+
+ do {
+ if (higherQuality && w > targetWidth) {
+ w /= 2;
+ if (w < targetWidth) {
+ w = targetWidth;
+ }
+ }
+
+ if (higherQuality && h > targetHeight) {
+ h /= 2;
+ if (h < targetHeight) {
+ h = targetHeight;
+ }
+ }
+
+ final BufferedImage tmp = new BufferedImage(w, h, type);
+ final Graphics2D g2 = tmp.createGraphics();
+ g2.setRenderingHints(hints);
+ g2.drawImage(ret, 0, 0, w, h, null);
+ g2.dispose();
+
+ ret = tmp;
+ } while (w != targetWidth || h != targetHeight);
+
+ return ret;
+ }
+
+ /**
+ * Converts an Image to a BufferedImage.
+ *
+ * From: http://stackoverflow.com/questions/13605248/java-converting-image-to-bufferedimage
+ */
+ public static BufferedImage toBufferedImage(Image img) {
+ if (img instanceof BufferedImage) {
+ return (BufferedImage) img;
+ }
+ // Create a buffered image with transparency
+ final BufferedImage bimage = new BufferedImage(img.getWidth(null), img.getHeight(null),
+ BufferedImage.TYPE_INT_ARGB);
+
+ // Draw the image on to the buffered image
+ final Graphics2D bGr = bimage.createGraphics();
+ bGr.drawImage(img, 0, 0, null);
+ bGr.dispose();
+
+ return bimage;
+ }
+
+ /**
+ * Calculates the dimensions of a scaled image given the dimensions of an image and the area it is to be drawn in
+ * while preserving aspect ratio.
+ *
+ * From: http://stackoverflow.com/questions/10245220/java-image-resize-maintain-aspect-ratio
+ *
+ * @param imgSize
+ * dimensions of the original image.
+ * @param boundary
+ * dimensions of the area the image is to be drawn in.
+ */
+ public static Dimension getScaledDimension(Dimension imgSize, Dimension boundary) {
+
+ final int originalWidth = imgSize.width;
+ final int originaHeight = imgSize.height;
+ final int boundWidth = boundary.width;
+ final int boundHeight = boundary.height;
+ int newWidth = originalWidth;
+ int newHeight = originaHeight;
+
+ // first check if we need to scale width
+ if (originalWidth > boundWidth) {
+ // scale width to fit
+ newWidth = boundWidth;
+ // scale height to maintain aspect ratio
+ newHeight = (newWidth * originaHeight) / originalWidth;
+ }
+
+ // then check if we need to scale even with the new height
+ if (newHeight > boundHeight) {
+ // scale height to fit instead
+ newHeight = boundHeight;
+ // scale width to maintain aspect ratio
+ newWidth = (newHeight * originalWidth) / originaHeight;
+ }
+
+ return new Dimension(newWidth, newHeight);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/swing/ImageWindow2.java b/src/net/sourceforge/plantuml/swing/ImageWindow2.java
new file mode 100644
index 0000000..65e923d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/swing/ImageWindow2.java
@@ -0,0 +1,289 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.swing;
+
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.awt.Image;
+import java.awt.RenderingHints;
+import java.awt.Toolkit;
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.Transferable;
+import java.awt.datatransfer.UnsupportedFlavorException;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.prefs.Preferences;
+
+import javax.imageio.ImageIO;
+import javax.swing.ImageIcon;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.ListModel;
+import javax.swing.WindowConstants;
+
+import net.sourceforge.plantuml.FileFormat;
+import net.sourceforge.plantuml.GeneratedImage;
+import net.sourceforge.plantuml.graphic.GraphicStrings;
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+import net.sourceforge.plantuml.ugraphic.ImageBuilder;
+import net.sourceforge.plantuml.version.PSystemVersion;
+
+class ImageWindow2 extends JFrame {
+
+ final private static Preferences prefs = Preferences.userNodeForPackage(ImageWindow2.class);
+ final private static String KEY_ZOOM_FIT = "zoomfit";
+
+ private SimpleLine2 simpleLine2;
+ final private JScrollPane scrollPane;
+ private final JButton next = new JButton("Next");
+ private final JButton copy = new JButton("Copy");
+ private final JButton previous = new JButton("Previous");
+ private final JCheckBox zoomFitButt = new JCheckBox("Zoom fit");
+
+ private final ListModel listModel;
+ private int index;
+
+ private enum SizeMode {
+ FULL_SIZE, ZOOM_FIT
+ };
+
+ private SizeMode sizeMode = SizeMode.FULL_SIZE;
+
+ public ImageWindow2(SimpleLine2 simpleLine, final MainWindow2 main, ListModel listModel, int index) {
+ super(simpleLine.toString());
+ setIconImage(PSystemVersion.getPlantumlSmallIcon2());
+ this.simpleLine2 = simpleLine;
+ this.listModel = listModel;
+ this.index = index;
+
+ final JPanel north = new JPanel();
+ north.add(previous);
+ north.add(copy);
+ north.add(next);
+ north.add(zoomFitButt);
+ copy.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent ae) {
+ copy();
+ }
+ });
+ next.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent ae) {
+ next();
+ }
+ });
+ previous.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent ae) {
+ previous();
+ }
+ });
+ zoomFitButt.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent ae) {
+ zoomFit();
+ }
+ });
+
+ scrollPane = new JScrollPane(buildScrollablePicture());
+ getContentPane().add(north, BorderLayout.NORTH);
+ getContentPane().add(scrollPane, BorderLayout.CENTER);
+ setSize(640, 400);
+ this.setLocationRelativeTo(this.getParent());
+ setVisible(true);
+ setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
+ this.addWindowListener(new WindowAdapter() {
+ @Override
+ public void windowClosing(WindowEvent e) {
+ super.windowClosing(e);
+ main.closing(ImageWindow2.this);
+ }
+ });
+
+ this.addComponentListener(new java.awt.event.ComponentAdapter() {
+ public void componentResized(java.awt.event.ComponentEvent e) {
+ super.componentResized(e);
+ refreshImage();
+ }
+ });
+
+ final boolean zoomChecked = prefs.getBoolean(KEY_ZOOM_FIT, false);
+ zoomFitButt.setSelected(zoomChecked);
+ if (zoomChecked) {
+ sizeMode = SizeMode.ZOOM_FIT;
+ }
+
+ }
+
+ private void next() {
+ index++;
+ updateSimpleLine();
+ }
+
+ private void previous() {
+ index--;
+ updateSimpleLine();
+ }
+
+ private void zoomFit() {
+ final boolean selected = zoomFitButt.isSelected();
+ prefs.putBoolean(KEY_ZOOM_FIT, selected);
+ if (selected) {
+ sizeMode = SizeMode.ZOOM_FIT;
+ } else {
+ sizeMode = SizeMode.FULL_SIZE;
+ }
+ refreshImage();
+ }
+
+ private void updateSimpleLine() {
+ if (index < 0) {
+ index = 0;
+ }
+ if (index > listModel.getSize() - 1) {
+ index = listModel.getSize() - 1;
+ }
+ simpleLine2 = (SimpleLine2) listModel.getElementAt(index);
+ setTitle(simpleLine2.toString());
+ refreshImage();
+ }
+
+ private ScrollablePicture buildScrollablePicture() {
+ final GeneratedImage generatedImage = simpleLine2.getGeneratedImage();
+ if (generatedImage == null) {
+ return null;
+ }
+ final File png = generatedImage.getPngFile();
+ BufferedImage image = null;
+ try {
+ image = ImageIO.read(new File(png.getAbsolutePath()));
+ if (sizeMode == SizeMode.ZOOM_FIT) {
+ final Dimension imageDim = new Dimension(image.getWidth(), image.getHeight());
+ final Dimension newImgDim = ImageHelper
+ .getScaledDimension(imageDim, scrollPane.getViewport().getSize());
+ final RenderingHints hints = new RenderingHints(RenderingHints.KEY_INTERPOLATION,
+ RenderingHints.VALUE_INTERPOLATION_BILINEAR);
+ hints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ hints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
+ image = ImageHelper.getScaledInstance(image, newImgDim, hints, true);
+ }
+ } catch (IOException ex) {
+ final String msg = "Error reading file: " + ex.toString();
+ final GraphicStrings error = GraphicStrings.createDefault(Arrays.asList(msg), false);
+ final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, error.getBackcolor(),
+ null, null, 0, 0, null, false);
+ imageBuilder.addUDrawable(error);
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try {
+ imageBuilder.writeImageTOBEMOVED(FileFormat.PNG, baos);
+ baos.close();
+ image = ImageIO.read(new ByteArrayInputStream(baos.toByteArray()));
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ final ImageIcon imageIcon = new ImageIcon(image, simpleLine2.toString());
+ final ScrollablePicture scrollablePicture = new ScrollablePicture(imageIcon, 1);
+ return scrollablePicture;
+ }
+
+ private void copy() {
+ final GeneratedImage generatedImage = simpleLine2.getGeneratedImage();
+ if (generatedImage == null) {
+ return;
+ }
+ final File png = generatedImage.getPngFile();
+ final Image image = Toolkit.getDefaultToolkit().createImage(png.getAbsolutePath());
+ final ImageSelection imgSel = new ImageSelection(image);
+ Toolkit.getDefaultToolkit().getSystemClipboard().setContents(imgSel, null);
+ }
+
+ public SimpleLine2 getSimpleLine() {
+ return simpleLine2;
+ }
+
+ public void refreshImage() {
+ scrollPane.setViewportView(buildScrollablePicture());
+ force();
+ }
+
+ private void force() {
+ // setVisible(true);
+ repaint();
+ // validate();
+ // getContentPane().validate();
+ // getContentPane().setVisible(true);
+ // getContentPane().repaint();
+ // scrollPane.validate();
+ // scrollPane.setVisible(true);
+ // scrollPane.repaint();
+ }
+
+}
+
+// This class is used to hold an image while on the clipboard.
+class ImageSelection implements Transferable {
+ private Image image;
+
+ public ImageSelection(Image image) {
+ this.image = image;
+ }
+
+ // Returns supported flavors
+ public DataFlavor[] getTransferDataFlavors() {
+ return new DataFlavor[] { DataFlavor.imageFlavor };
+ }
+
+ // Returns true if flavor is supported
+ public boolean isDataFlavorSupported(DataFlavor flavor) {
+ return DataFlavor.imageFlavor.equals(flavor);
+ }
+
+ // Returns image
+ public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
+ if (!DataFlavor.imageFlavor.equals(flavor)) {
+ throw new UnsupportedFlavorException(flavor);
+ }
+ return image;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/swing/LicenseWindow.java b/src/net/sourceforge/plantuml/swing/LicenseWindow.java
new file mode 100644
index 0000000..726db0f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/swing/LicenseWindow.java
@@ -0,0 +1,142 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.swing;
+
+import java.awt.BorderLayout;
+import java.awt.Font;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.BorderFactory;
+import javax.swing.ImageIcon;
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JEditorPane;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.WindowConstants;
+import javax.swing.border.BevelBorder;
+import javax.swing.border.CompoundBorder;
+
+import net.sourceforge.plantuml.version.License;
+import net.sourceforge.plantuml.version.PSystemVersion;
+import net.sourceforge.plantuml.version.Version;
+
+class LicenseWindow extends JFrame {
+
+ /*
+ * - the PlantUML version - the Dot version - the PlantUML authors - the PlantUML license
+ */
+ public LicenseWindow() {
+ super();
+ setIconImage(PSystemVersion.getPlantumlSmallIcon2());
+
+ this.setTitle("Licence PlantUML (" + Version.versionString() + ")");
+
+ getContentPane().add(getNorthLabel(), BorderLayout.NORTH);
+ final List<String> list = new ArrayList<String>(License.getCurrent().getText());
+ getContentPane().add(getJComponent(list), BorderLayout.CENTER);
+ getContentPane().add(getSouthLabel(), BorderLayout.SOUTH);
+
+ setSize(800, 600);
+ this.setLocationRelativeTo(this.getParent());
+ setVisible(true);
+ setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
+ }
+
+ private JComponent getNorthLabel() {
+ final JLabel text = new JLabel("PlantUML (" + Version.versionString() + ")");
+ final Font font = text.getFont().deriveFont(Font.BOLD, (float) 20.0);
+ text.setFont(font);
+ final JPanel ptext = new JPanel();
+ ptext.add(text);
+
+ final JLabel icon = new JLabel(new ImageIcon(PSystemVersion.getPlantumlImage()));
+
+ final JPanel result = new JPanel(new BorderLayout());
+ result.add(ptext, BorderLayout.CENTER);
+ result.add(icon, BorderLayout.EAST);
+
+ return result;
+ }
+
+ private JComponent getSouthLabel() {
+ final JPanel result = new JPanel();
+ final JButton ok = new JButton("OK");
+ ok.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent ae) {
+ dispose();
+ }
+ });
+ result.add(ok);
+ return result;
+ }
+
+ private JComponent getJComponent(List<String> lines) {
+ final StringBuilder sb = new StringBuilder("<html>");
+ for (String s : lines) {
+ sb.append(s + "</b></i></u>");
+ sb.append("<br>");
+ }
+ sb.append("</html>");
+ final JEditorPane text = new JEditorPane("text/html", sb.toString());
+ text.setEditable(false);
+ CompoundBorder border = new CompoundBorder(BorderFactory.createEtchedBorder(BevelBorder.RAISED),
+ BorderFactory.createEmptyBorder(5, 5, 5, 5));
+ border = new CompoundBorder(BorderFactory.createMatteBorder(5, 5, 5, 5, getBackground()), border);
+
+ text.setBorder(border);
+
+ final JScrollPane jScrollPane = new JScrollPane(text, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
+ JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
+
+ javax.swing.SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ jScrollPane.getVerticalScrollBar().setValue(0);
+ }
+ });
+
+ return jScrollPane;
+ }
+
+ public static void main(String arg[]) {
+ new LicenseWindow();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/swing/MainWindow2.java b/src/net/sourceforge/plantuml/swing/MainWindow2.java
new file mode 100644
index 0000000..52fa147
--- /dev/null
+++ b/src/net/sourceforge/plantuml/swing/MainWindow2.java
@@ -0,0 +1,406 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.swing;
+
+import java.awt.BorderLayout;
+import java.awt.Frame;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Vector;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.prefs.Preferences;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.swing.BorderFactory;
+import javax.swing.JButton;
+import javax.swing.JFileChooser;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JList;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+import javax.swing.ListModel;
+import javax.swing.SwingUtilities;
+import javax.swing.Timer;
+import javax.swing.border.CompoundBorder;
+
+import net.sourceforge.plantuml.DirWatcher2;
+import net.sourceforge.plantuml.GeneratedImage;
+import net.sourceforge.plantuml.Log;
+import net.sourceforge.plantuml.Option;
+import net.sourceforge.plantuml.version.PSystemVersion;
+
+public class MainWindow2 extends JFrame {
+
+ final private static Preferences prefs = Preferences.userNodeForPackage(MainWindow2.class);
+ final private static String KEY_DIR = "cur";
+ final private static String KEY_PATTERN = "pat";
+
+ private final JList jList1 = new JList();
+ private final JScrollPane scrollPane;
+ private final JButton changeDirButton = new JButton("Change Directory");
+ private final JTextField extensions = new JTextField();
+ private final int period = 300;
+
+ final private List<SimpleLine2> currentDirectoryListing2 = new ArrayList<SimpleLine2>();
+ final private Set<ImageWindow2> openWindows2 = new HashSet<ImageWindow2>();
+ final private Option option;
+
+ private DirWatcher2 dirWatcher;
+
+ private String getExtensions() {
+ return prefs.get(KEY_PATTERN, getDefaultFileExtensions());
+ }
+
+ private String getDefaultFileExtensions() {
+ return "txt, tex, java, htm, html, c, h, cpp, apt, pu";
+ }
+
+ private void changeExtensions(String ext) {
+ if (ext.equals(getExtensions())) {
+ return;
+ }
+ final Pattern p = Pattern.compile("\\w+");
+ final Matcher m = p.matcher(ext);
+ final StringBuilder sb = new StringBuilder();
+
+ while (m.find()) {
+ final String value = m.group();
+ if (sb.length() > 0) {
+ sb.append(", ");
+ }
+ sb.append(value);
+
+ }
+ ext = sb.toString();
+ if (ext.length() == 0) {
+ ext = getDefaultFileExtensions();
+ }
+ extensions.setText(ext);
+ prefs.put(KEY_PATTERN, ext);
+ changeDir(dirWatcher.getDir());
+ }
+
+ private String getRegexpPattern(String ext) {
+ final Pattern p = Pattern.compile("\\w+");
+ final Matcher m = p.matcher(ext);
+ final StringBuilder filePattern = new StringBuilder("(?i)^.*\\.(");
+
+ while (m.find()) {
+ final String value = m.group();
+ if (filePattern.toString().endsWith("(") == false) {
+ filePattern.append("|");
+ }
+ filePattern.append(value);
+ }
+ if (filePattern.toString().endsWith("(") == false) {
+ filePattern.append(")$");
+ return filePattern.toString();
+ }
+ return Option.getPattern();
+ }
+
+ public MainWindow2(Option option, File arg) {
+ super(getDirectory(arg).getAbsolutePath());
+ final File dir = getDirectory(arg);
+ setIconImage(PSystemVersion.getPlantumlSmallIcon2());
+ this.option = option;
+ dirWatcher = new DirWatcher2(dir, option, getRegexpPattern(getExtensions()));
+
+ Log.info("Showing MainWindow");
+ scrollPane = new JScrollPane(jList1);
+ scrollPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+
+ final JPanel south = new JPanel(new BorderLayout());
+ final JLabel labelFileExtensions = new JLabel("File extensions: ");
+ extensions.setText(getExtensions());
+
+ labelFileExtensions.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
+ CompoundBorder border = BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10),
+ BorderFactory.createEtchedBorder());
+ border = BorderFactory.createCompoundBorder(border, BorderFactory.createEmptyBorder(5, 5, 5, 5));
+ south.setBorder(border);
+ south.add(labelFileExtensions, BorderLayout.WEST);
+ south.add(extensions, BorderLayout.CENTER);
+
+ south.add(changeDirButton, BorderLayout.SOUTH);
+
+ getContentPane().add(south, BorderLayout.SOUTH);
+ getContentPane().add(scrollPane, BorderLayout.CENTER);
+
+ final MouseListener mouseListener = new MouseAdapter() {
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ try {
+ if (e.getClickCount() == 2) {
+ final int index = jList1.locationToIndex(e.getPoint());
+ doubleClick((SimpleLine2) jList1.getModel().getElementAt(index), jList1.getModel(), index);
+ }
+ } catch (Exception ex) {
+
+ }
+ }
+ };
+ jList1.addMouseListener(mouseListener);
+ changeDirButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ System.err.println("Opening Directory Window");
+ displayDialogChangeDir();
+ }
+ });
+ jList1.addKeyListener(new KeyAdapter() {
+ @Override
+ public void keyPressed(KeyEvent e) {
+ if (e.getKeyCode() == KeyEvent.VK_ENTER) {
+ final int index = jList1.getSelectedIndex();
+ doubleClick((SimpleLine2) jList1.getModel().getElementAt(index), jList1.getModel(), index);
+ }
+ }
+
+ });
+
+ extensions.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ changeExtensions(extensions.getText());
+ }
+ });
+ extensions.addFocusListener(new FocusListener() {
+
+ public void focusGained(FocusEvent e) {
+ }
+
+ public void focusLost(FocusEvent e) {
+ changeExtensions(extensions.getText());
+ }
+ });
+
+ final JMenuBar menuBar = new JMenuBar();
+ final JMenu mFile = new JMenu("File");
+ menuBar.add(mFile);
+ setJMenuBar(menuBar);
+
+ final JMenuItem sprite = new JMenuItem("Open Sprite Window");
+ mFile.add(sprite);
+ sprite.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ new SpriteWindow();
+ }
+ });
+
+ final JMenuItem about = new JMenuItem("About");
+ mFile.add(about);
+ about.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ new AboutWindow();
+ }
+ });
+
+ final JMenuItem exit = new JMenuItem("Exit");
+ mFile.add(exit);
+ exit.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ System.exit(0);
+ }
+ });
+
+ setSize(640, 400);
+ this.setLocationRelativeTo(this.getParent());
+ setVisible(true);
+ setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+ startTimer();
+ }
+
+ private static File getDirectory(File arg) {
+ if (arg != null && arg.exists() && arg.isDirectory()) {
+ return arg;
+ }
+ return new File(prefs.get(KEY_DIR, "."));
+ }
+
+ private void startTimer() {
+ Log.info("Init done");
+ final Timer timer = new Timer(period, new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ tick();
+ }
+ });
+ timer.setInitialDelay(0);
+ timer.start();
+ Log.info("Timer started");
+ }
+
+ private void displayDialogChangeDir() {
+ final JFileChooser chooser = new JFileChooser();
+ chooser.setDialogType(JFileChooser.CUSTOM_DIALOG);
+ chooser.setDialogTitle("Directory to watch:");
+ chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+ chooser.setAcceptAllFileFilterUsed(false);
+ final String currentPath = prefs.get(KEY_DIR, ".");
+ chooser.setCurrentDirectory(new File(currentPath));
+ Log.info("Showing OpenDialog");
+ final int returnVal = chooser.showOpenDialog(this);
+ Log.info("Closing OpenDialog");
+ if (returnVal == JFileChooser.APPROVE_OPTION) {
+ final File dir = chooser.getSelectedFile();
+ changeDir(dir);
+ }
+
+ }
+
+ private void changeDir(File dir) {
+ prefs.put(KEY_DIR, dir.getAbsolutePath());
+ dirWatcher.cancel();
+ dirWatcher = new DirWatcher2(dir, option, getRegexpPattern(getExtensions()));
+ setTitle(dir.getAbsolutePath());
+ Log.info("Creating DirWatcher");
+ currentDirectoryListing2.clear();
+ jList1.setListData(new Vector<SimpleLine2>(currentDirectoryListing2));
+ jList1.setVisible(true);
+ }
+
+ private void doubleClick(SimpleLine2 simpleLine, ListModel listModel, int index) {
+ for (ImageWindow2 win : openWindows2) {
+ if (win.getSimpleLine().equals(simpleLine)) {
+ win.setVisible(true);
+ win.setExtendedState(Frame.NORMAL);
+ return;
+ }
+ }
+ if (simpleLine.getGeneratedImage() != null) {
+ openWindows2.add(new ImageWindow2(simpleLine, this, listModel, index));
+ }
+ }
+
+ private void tick() {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ try {
+ final boolean changed = refreshDir();
+ if (changed) {
+ jList1.setListData(new Vector<SimpleLine2>(currentDirectoryListing2));
+ jList1.setVisible(true);
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ } catch (ExecutionException e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ }
+
+ private boolean refreshDir() throws IOException, InterruptedException, ExecutionException {
+ final Map<File, Future<List<GeneratedImage>>> createdFiles2 = dirWatcher.buildCreatedFiles();
+ boolean changed = false;
+
+ for (Map.Entry<File, Future<List<GeneratedImage>>> ent : createdFiles2.entrySet()) {
+ final File file = ent.getKey();
+ removeAllThatUseThisFile(file);
+ final Future<List<GeneratedImage>> future = ent.getValue();
+ final SimpleLine2 simpleLine = new SimpleLine2(file, null, future);
+ currentDirectoryListing2.add(simpleLine);
+ changed = true;
+ }
+
+ for (SimpleLine2 line : new ArrayList<SimpleLine2>(currentDirectoryListing2)) {
+ if (line.pendingAndFinished()) {
+ currentDirectoryListing2.remove(line);
+ changed = true;
+ final Future<List<GeneratedImage>> future = line.getFuture();
+ for (GeneratedImage im : future.get()) {
+ mayRefreshImageWindow(im.getPngFile());
+ final SimpleLine2 simpleLine = new SimpleLine2(line.getFile(), im, null);
+ currentDirectoryListing2.add(simpleLine);
+ }
+ }
+ }
+ Collections.sort(currentDirectoryListing2);
+ return changed;
+ }
+
+ private void removeAllThatUseThisFile(File file) {
+ for (final Iterator<SimpleLine2> it = currentDirectoryListing2.iterator(); it.hasNext();) {
+ final SimpleLine2 line = it.next();
+ if (line.getFile().equals(file)) {
+ it.remove();
+ }
+ }
+ }
+
+ private void mayRefreshImageWindow(File pngFile) {
+ for (ImageWindow2 win : openWindows2) {
+ if (win.getSimpleLine().getGeneratedImage() == null) {
+ continue;
+ }
+ if (pngFile.equals(win.getSimpleLine().getGeneratedImage().getPngFile())) {
+ win.refreshImage();
+ }
+ }
+
+ }
+
+ public void closing(ImageWindow2 imageWindow) {
+ final boolean ok = openWindows2.remove(imageWindow);
+ if (ok == false) {
+ throw new IllegalStateException();
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/swing/ScrollablePicture.java b/src/net/sourceforge/plantuml/swing/ScrollablePicture.java
new file mode 100644
index 0000000..babb3c1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/swing/ScrollablePicture.java
@@ -0,0 +1,130 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.swing;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Rectangle;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseMotionListener;
+
+import javax.swing.ImageIcon;
+import javax.swing.JLabel;
+import javax.swing.Scrollable;
+import javax.swing.SwingConstants;
+
+class ScrollablePicture extends JLabel implements Scrollable, MouseMotionListener {
+
+ private int maxUnitIncrement = 1;
+ private boolean missingPicture = false;
+
+ public ScrollablePicture(ImageIcon i, int m) {
+ super(i);
+ if (i == null) {
+ missingPicture = true;
+ setText("No picture found.");
+ setHorizontalAlignment(CENTER);
+ setOpaque(true);
+ setBackground(Color.white);
+ }
+ maxUnitIncrement = m;
+
+ // Let the user scroll by dragging to outside the window.
+ setAutoscrolls(true); // enable synthetic drag events
+ addMouseMotionListener(this); // handle mouse drags
+ }
+
+ // Methods required by the MouseMotionListener interface:
+ public void mouseMoved(MouseEvent e) {
+ }
+
+ public void mouseDragged(MouseEvent e) {
+ // The user is dragging us, so scroll!
+ Rectangle r = new Rectangle(e.getX(), e.getY(), 1, 1);
+ scrollRectToVisible(r);
+ }
+
+ @Override
+ public Dimension getPreferredSize() {
+ if (missingPicture) {
+ return new Dimension(320, 480);
+ } else {
+ return super.getPreferredSize();
+ }
+ }
+
+ public Dimension getPreferredScrollableViewportSize() {
+ return getPreferredSize();
+ }
+
+ public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) {
+ // Get the current position.
+ int currentPosition = 0;
+ if (orientation == SwingConstants.HORIZONTAL) {
+ currentPosition = visibleRect.x;
+ } else {
+ currentPosition = visibleRect.y;
+ }
+
+ // Return the number of pixels between currentPosition
+ // and the nearest tick mark in the indicated direction.
+ if (direction < 0) {
+ int newPosition = currentPosition - (currentPosition / maxUnitIncrement) * maxUnitIncrement;
+ return (newPosition == 0) ? maxUnitIncrement : newPosition;
+ } else {
+ return ((currentPosition / maxUnitIncrement) + 1) * maxUnitIncrement - currentPosition;
+ }
+ }
+
+ public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction) {
+ if (orientation == SwingConstants.HORIZONTAL) {
+ return visibleRect.width - maxUnitIncrement;
+ } else {
+ return visibleRect.height - maxUnitIncrement;
+ }
+ }
+
+ public boolean getScrollableTracksViewportWidth() {
+ return false;
+ }
+
+ public boolean getScrollableTracksViewportHeight() {
+ return false;
+ }
+
+ public void setMaxUnitIncrement(int pixels) {
+ maxUnitIncrement = pixels;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/swing/SimpleLine2.java b/src/net/sourceforge/plantuml/swing/SimpleLine2.java
new file mode 100644
index 0000000..cc2e500
--- /dev/null
+++ b/src/net/sourceforge/plantuml/swing/SimpleLine2.java
@@ -0,0 +1,86 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.swing;
+
+import java.io.File;
+import java.util.List;
+import java.util.concurrent.Future;
+
+import net.sourceforge.plantuml.GeneratedImage;
+
+class SimpleLine2 implements Comparable<SimpleLine2> {
+
+ private final File file;
+ private final GeneratedImage generatedImage;
+ private final Future<List<GeneratedImage>> future;
+
+ public SimpleLine2(File file, GeneratedImage generatedImage, Future<List<GeneratedImage>> future) {
+ this.generatedImage = generatedImage;
+ this.file = file;
+ this.future = future;
+ }
+
+ public File getFile() {
+ return file;
+ }
+
+ public boolean pendingAndFinished() {
+ return generatedImage == null && future.isDone();
+ }
+
+ @Override
+ public String toString() {
+ if (generatedImage == null) {
+ return file.getName() + " (...pending...)";
+ }
+ final StringBuilder sb = new StringBuilder(generatedImage.getPngFile().getName());
+ sb.append(" ");
+ sb.append(generatedImage.getDescription());
+ return sb.toString();
+ }
+
+ public Future<List<GeneratedImage>> getFuture() {
+ return future;
+ }
+
+ public int compareTo(SimpleLine2 other) {
+ return toString().compareTo(other.toString());
+ }
+
+ public GeneratedImage getGeneratedImage() {
+ return generatedImage;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/swing/SpriteWindow.java b/src/net/sourceforge/plantuml/swing/SpriteWindow.java
new file mode 100644
index 0000000..c414286
--- /dev/null
+++ b/src/net/sourceforge/plantuml/swing/SpriteWindow.java
@@ -0,0 +1,164 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.swing;
+
+import java.awt.BorderLayout;
+import java.awt.Font;
+import java.awt.Toolkit;
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.Transferable;
+import java.awt.datatransfer.UnsupportedFlavorException;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+
+import javax.swing.JFrame;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.SwingUtilities;
+import javax.swing.Timer;
+
+import net.sourceforge.plantuml.Log;
+import net.sourceforge.plantuml.ugraphic.SpriteGrayLevel;
+import net.sourceforge.plantuml.ugraphic.SpriteUtils;
+import net.sourceforge.plantuml.version.PSystemVersion;
+
+public class SpriteWindow extends JFrame {
+
+ // private final JButton encode = new JButton("Encode");
+ private final JTextArea area = new JTextArea();
+
+ public SpriteWindow() {
+ super("SpriteWindows");
+ setIconImage(PSystemVersion.getPlantumlSmallIcon2());
+ // encode.addActionListener(new ActionListener() {
+ // public void actionPerformed(ActionEvent ae) {
+ // encode();
+ // }
+ // });
+
+ area.setFont(new Font("Courier", Font.PLAIN, 14));
+ area.setText("Copy an image to the clipboard.\nIt will be converted inside this window.\n");
+
+ final JScrollPane scroll = new JScrollPane(area);
+
+ // getContentPane().add(encode, BorderLayout.SOUTH);
+ getContentPane().add(scroll, BorderLayout.CENTER);
+ setSize(400, 320);
+ setVisible(true);
+ setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+ startTimer();
+ }
+
+ private void startTimer() {
+ Log.info("Init done");
+ final Timer timer = new Timer(10000, new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ tick();
+ }
+ });
+ timer.setInitialDelay(0);
+ timer.start();
+ Log.info("Timer started");
+ }
+
+ private void tick() {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ encode();
+ }
+ });
+ }
+
+ private void encode() {
+ final BufferedImage img = getClipboard();
+ if (img == null) {
+ return;
+ }
+ final StringBuilder sb = new StringBuilder();
+ encode(img, SpriteGrayLevel.GRAY_16, sb);
+ encodeCompressed(img, SpriteGrayLevel.GRAY_16, sb);
+ encode(img, SpriteGrayLevel.GRAY_8, sb);
+ encodeCompressed(img, SpriteGrayLevel.GRAY_8, sb);
+ encode(img, SpriteGrayLevel.GRAY_4, sb);
+ encodeCompressed(img, SpriteGrayLevel.GRAY_4, sb);
+ printData(sb.toString());
+ }
+
+ private void encodeCompressed(BufferedImage img, SpriteGrayLevel level, StringBuilder sb) {
+ sb.append("\n");
+ sb.append(SpriteUtils.encodeCompressed(img, "demo", level));
+
+ }
+
+ private void encode(BufferedImage img, SpriteGrayLevel level, StringBuilder sb) {
+ sb.append("\n");
+ sb.append(SpriteUtils.encode(img, "demo", level));
+ }
+
+ private String last;
+
+ private void printData(final String s) {
+ if (s.equals(last) == false) {
+ area.setText(s);
+ last = s;
+ }
+ }
+
+ public static BufferedImage getClipboard() {
+ final Transferable t = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
+
+ try {
+ if (t != null && t.isDataFlavorSupported(DataFlavor.imageFlavor)) {
+ final BufferedImage text = (BufferedImage) t.getTransferData(DataFlavor.imageFlavor);
+ return text;
+ }
+
+ } catch (UnsupportedFlavorException e) {
+ Log.error(e.toString());
+ } catch (IOException e) {
+ Log.error(e.toString());
+ }
+ return null;
+ }
+
+ public static void main(String[] args) {
+ new SpriteWindow();
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/syntax/LanguageDescriptor.java b/src/net/sourceforge/plantuml/syntax/LanguageDescriptor.java
new file mode 100644
index 0000000..fb269f8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/syntax/LanguageDescriptor.java
@@ -0,0 +1,165 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.syntax;
+
+import java.io.PrintStream;
+import java.util.Collection;
+import java.util.Set;
+import java.util.TreeSet;
+
+import net.sourceforge.plantuml.SkinParam;
+import net.sourceforge.plantuml.graphic.HtmlColorSetSimple;
+
+public class LanguageDescriptor {
+
+ private final Set<String> type = new TreeSet<String>();
+ private final Set<String> keyword = new TreeSet<String>();
+ private final Set<String> preproc = new TreeSet<String>();
+
+ public LanguageDescriptor() {
+
+ type.add("actor");
+ type.add("participant");
+ type.add("usecase");
+ type.add("class");
+ type.add("interface");
+ type.add("abstract");
+ type.add("enum");
+ type.add("component");
+ type.add("state");
+ type.add("object");
+ type.add("artifact");
+ type.add("folder");
+ type.add("rect");
+ type.add("node");
+ type.add("frame");
+ type.add("cloud");
+ type.add("database");
+ type.add("storage");
+ type.add("agent");
+ type.add("boundary");
+ type.add("control");
+ type.add("entity");
+ type.add("card");
+
+ keyword.add("@startuml");
+ keyword.add("@enduml");
+ keyword.add("as");
+ keyword.add("also");
+ keyword.add("autonumber");
+ keyword.add("title");
+ keyword.add("newpage");
+ keyword.add("box");
+ keyword.add("alt");
+ keyword.add("else");
+ keyword.add("opt");
+ keyword.add("loop");
+ keyword.add("par");
+ keyword.add("break");
+ keyword.add("critical");
+ keyword.add("note");
+ keyword.add("group");
+ keyword.add("left");
+ keyword.add("right");
+ keyword.add("of");
+ keyword.add("on");
+ keyword.add("link");
+ keyword.add("over");
+ keyword.add("end");
+ keyword.add("activate");
+ keyword.add("deactivate");
+ keyword.add("destroy");
+ keyword.add("create");
+ keyword.add("footbox");
+ keyword.add("hide");
+ keyword.add("show");
+ keyword.add("skinparam");
+ keyword.add("skin");
+ keyword.add("top");
+ keyword.add("bottom");
+ keyword.add("top to bottom direction");
+ keyword.add("package");
+ keyword.add("namespace");
+ keyword.add("page");
+ keyword.add("up");
+ keyword.add("down");
+ keyword.add("if");
+ keyword.add("else");
+ keyword.add("elseif");
+ keyword.add("endif");
+ keyword.add("partition");
+ keyword.add("footer");
+ keyword.add("header");
+ keyword.add("center");
+ keyword.add("rotate");
+ keyword.add("ref");
+ keyword.add("return");
+ keyword.add("is");
+ keyword.add("repeat");
+ keyword.add("start");
+ keyword.add("stop");
+ keyword.add("while");
+ keyword.add("endwhile");
+ keyword.add("fork");
+ keyword.add("again");
+ keyword.add("kill");
+
+ preproc.add("!include");
+ preproc.add("!define");
+ preproc.add("!undef");
+ preproc.add("!ifdef");
+ preproc.add("!endif");
+ preproc.add("!ifndef");
+ }
+
+ public void print(PrintStream ps) {
+ print(ps, "type", type);
+ print(ps, "keyword", keyword);
+ print(ps, "preprocessor", preproc);
+ print(ps, "skinparameter", SkinParam.getPossibleValues());
+ print(ps, "color", new HtmlColorSetSimple().names());
+ ps.println(";EOF");
+ }
+
+ private static void print(PrintStream ps, String name, Collection<String> data) {
+ ps.println(";"+name);
+ ps.println(";" + data.size());
+ for (String k : data) {
+ ps.println(k);
+ }
+ ps.println();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/syntax/SyntaxChecker.java b/src/net/sourceforge/plantuml/syntax/SyntaxChecker.java
new file mode 100644
index 0000000..21ae703
--- /dev/null
+++ b/src/net/sourceforge/plantuml/syntax/SyntaxChecker.java
@@ -0,0 +1,152 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.syntax;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import net.sourceforge.plantuml.BlockUml;
+import net.sourceforge.plantuml.ErrorUml;
+import net.sourceforge.plantuml.OptionFlags;
+import net.sourceforge.plantuml.PSystemError;
+import net.sourceforge.plantuml.SourceStringReader;
+import net.sourceforge.plantuml.UmlDiagram;
+import net.sourceforge.plantuml.core.Diagram;
+import net.sourceforge.plantuml.preproc.Defines;
+
+public class SyntaxChecker {
+
+ public static SyntaxResult checkSyntax(List<String> source) {
+ final StringBuilder sb = new StringBuilder();
+ for (String s : source) {
+ sb.append(s);
+ sb.append("\n");
+ }
+ return checkSyntax(sb.toString());
+ }
+
+ public static SyntaxResult checkSyntax(String source) {
+ OptionFlags.getInstance().setQuiet(true);
+ final SyntaxResult result = new SyntaxResult();
+
+ if (source.startsWith("@startuml\n") == false) {
+ result.setError(true);
+ result.setErrorLinePosition(0);
+ result.addErrorText("No @startuml found");
+ result.setSuggest(Arrays.asList("Did you mean:", "@startuml"));
+ return result;
+ }
+ if (source.endsWith("@enduml\n") == false && source.endsWith("@enduml") == false) {
+ result.setError(true);
+ result.setErrorLinePosition(lastLineNumber(source));
+ result.addErrorText("No @enduml found");
+ result.setSuggest(Arrays.asList("Did you mean:", "@enduml"));
+ return result;
+ }
+ final SourceStringReader sourceStringReader = new SourceStringReader(new Defines(), source,
+ Collections.<String> emptyList());
+
+ final List<BlockUml> blocks = sourceStringReader.getBlocks();
+ if (blocks.size() == 0) {
+ result.setError(true);
+ result.setErrorLinePosition(lastLineNumber(source));
+ result.addErrorText("No @enduml found");
+ result.setSuggest(Arrays.asList("Did you mean:", "@enduml"));
+ return result;
+ }
+ final Diagram system = blocks.get(0).getDiagram();
+ result.setCmapData(system.hasUrl());
+ if (system instanceof UmlDiagram) {
+ result.setUmlDiagramType(((UmlDiagram) system).getUmlDiagramType());
+ result.setDescription(system.getDescription().getDescription());
+ } else if (system instanceof PSystemError) {
+ result.setError(true);
+ final PSystemError sys = (PSystemError) system;
+ result.setErrorLinePosition(sys.getHigherErrorPosition());
+ for (ErrorUml er : sys.getErrorsUml()) {
+ result.addErrorText(er.getError());
+ }
+ result.setSuggest(sys.getSuggest());
+ } else {
+ result.setDescription(system.getDescription().getDescription());
+ }
+ return result;
+ }
+
+ public static SyntaxResult checkSyntaxFair(String source) {
+ final SyntaxResult result = new SyntaxResult();
+ final SourceStringReader sourceStringReader = new SourceStringReader(new Defines(), source,
+ Collections.<String> emptyList());
+
+ final List<BlockUml> blocks = sourceStringReader.getBlocks();
+ if (blocks.size() == 0) {
+ result.setError(true);
+ result.setErrorLinePosition(lastLineNumber(source));
+ result.addErrorText("No @enduml found");
+ result.setSuggest(Arrays.asList("Did you mean:", "@enduml"));
+ return result;
+ }
+
+ final Diagram system = blocks.get(0).getDiagram();
+ result.setCmapData(system.hasUrl());
+ if (system instanceof UmlDiagram) {
+ result.setUmlDiagramType(((UmlDiagram) system).getUmlDiagramType());
+ result.setDescription(system.getDescription().getDescription());
+ } else if (system instanceof PSystemError) {
+ result.setError(true);
+ final PSystemError sys = (PSystemError) system;
+ result.setErrorLinePosition(sys.getHigherErrorPosition());
+ for (ErrorUml er : sys.getErrorsUml()) {
+ result.addErrorText(er.getError());
+ }
+ result.setSystemError(sys);
+ result.setSuggest(sys.getSuggest());
+ } else {
+ result.setDescription(system.getDescription().getDescription());
+ }
+ return result;
+ }
+
+ private static int lastLineNumber(String source) {
+ int result = 0;
+ for (int i = 0; i < source.length(); i++) {
+ if (source.charAt(i) == '\n') {
+ result++;
+ }
+ }
+ return result;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/syntax/SyntaxResult.java b/src/net/sourceforge/plantuml/syntax/SyntaxResult.java
new file mode 100644
index 0000000..27ca296
--- /dev/null
+++ b/src/net/sourceforge/plantuml/syntax/SyntaxResult.java
@@ -0,0 +1,127 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.syntax;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.TreeSet;
+
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.PSystemError;
+import net.sourceforge.plantuml.UmlDiagramType;
+
+public class SyntaxResult {
+
+ private UmlDiagramType umlDiagramType;
+ private boolean isError;
+ private String description;
+ private int errorLinePosition;
+ private Collection<String> errors = new TreeSet<String>();
+ private List<String> suggest;
+ private boolean hasCmapData;
+ private PSystemError systemError;
+
+ public UmlDiagramType getUmlDiagramType() {
+ return umlDiagramType;
+ }
+
+ public boolean isError() {
+ return isError;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public int getErrorLinePosition() {
+ return errorLinePosition;
+ }
+
+ public List<String> getSuggest() {
+ return suggest;
+ }
+
+ public Collection<String> getErrors() {
+ return Collections.unmodifiableCollection(errors);
+ }
+
+ public void setUmlDiagramType(UmlDiagramType umlDiagramType) {
+ this.umlDiagramType = umlDiagramType;
+ }
+
+ public void setError(boolean isError) {
+ this.isError = isError;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public void setErrorLinePosition(int errorLinePosition) {
+ this.errorLinePosition = errorLinePosition;
+ }
+
+ public void addErrorText(String error) {
+ this.errors.add(error);
+ }
+
+ public void setSuggest(List<String> suggest) {
+ this.suggest = suggest;
+ }
+
+ public final boolean hasCmapData() {
+ return hasCmapData;
+ }
+
+ public final void setCmapData(boolean hasCmapData) {
+ this.hasCmapData = hasCmapData;
+ }
+
+ public void setSystemError(PSystemError systemError) {
+ this.systemError = systemError;
+ }
+
+ public void generateDiagramDescriptionForError(OutputStream os, FileFormatOption fileFormatOption)
+ throws IOException {
+ if (systemError == null) {
+ throw new IllegalStateException();
+ }
+ systemError.exportDiagram(os, 0, fileFormatOption);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/telnet/AcceptTelnetClient.java b/src/net/sourceforge/plantuml/telnet/AcceptTelnetClient.java
new file mode 100644
index 0000000..111c632
--- /dev/null
+++ b/src/net/sourceforge/plantuml/telnet/AcceptTelnetClient.java
@@ -0,0 +1,91 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.telnet;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.net.Socket;
+
+import net.sourceforge.plantuml.FileFormat;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.Log;
+import net.sourceforge.plantuml.SourceStringReader;
+
+class AcceptTelnetClient extends Thread {
+ final private Socket clientSocket;
+ final private BufferedReader br;
+ final private OutputStream os;
+
+ AcceptTelnetClient(Socket socket) throws Exception {
+ clientSocket = socket;
+ System.out.println("Client Connected ...");
+ br = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
+ os = clientSocket.getOutputStream();
+
+ start();
+ }
+
+ public String runInternal() throws IOException {
+ final StringBuilder sb = new StringBuilder();
+ while (true) {
+ final String s = br.readLine();
+ if (s == null) {
+ return sb.toString();
+ }
+ Log.println("S=" + s);
+ sb.append(s);
+ sb.append('\n');
+ if (s.equalsIgnoreCase("@enduml")) {
+ return sb.toString();
+ }
+ }
+ }
+
+ public void run() {
+ try {
+ final String uml = runInternal();
+ Log.println("UML=" + uml);
+ final SourceStringReader s = new SourceStringReader(uml);
+ s.generateImage(os, new FileFormatOption(FileFormat.ATXT));
+ os.close();
+ br.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ }
+}
diff --git a/src/net/sourceforge/plantuml/telnet/TelnetServer.java b/src/net/sourceforge/plantuml/telnet/TelnetServer.java
new file mode 100644
index 0000000..9dd9841
--- /dev/null
+++ b/src/net/sourceforge/plantuml/telnet/TelnetServer.java
@@ -0,0 +1,49 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.telnet;
+
+import java.net.ServerSocket;
+import java.net.Socket;
+
+public class TelnetServer {
+ public static void main(String args[]) throws Exception {
+ final ServerSocket server = new ServerSocket(4242);
+ while (true) {
+ final Socket socket = server.accept();
+ new AcceptTelnetClient(socket);
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/tikz/TikzGraphics.java b/src/net/sourceforge/plantuml/tikz/TikzGraphics.java
new file mode 100644
index 0000000..5cbf18e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/tikz/TikzGraphics.java
@@ -0,0 +1,302 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.tikz;
+
+import java.awt.Color;
+import java.awt.geom.PathIterator;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import net.sourceforge.plantuml.Log;
+import net.sourceforge.plantuml.eps.EpsGraphics;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.USegment;
+import net.sourceforge.plantuml.ugraphic.USegmentType;
+import net.sourceforge.plantuml.version.Version;
+
+public class TikzGraphics {
+
+ // https://www.sharelatex.com/blog/2013/08/27/tikz-series-pt1.html
+ // http://cremeronline.com/LaTeX/minimaltikz.pdf
+
+ private final List<String> cmd = new ArrayList<String>();
+
+ private Color color = Color.BLACK;
+ private Color fillcolor = Color.BLACK;
+ private double thickness = 1.0;
+ private String dash = null;
+
+ private final Map<Color, String> colornames = new LinkedHashMap<Color, String>();
+
+ private String getColorName(Color c) {
+ if (c.equals(Color.WHITE)) {
+ return "white";
+ }
+ if (c.equals(Color.BLACK)) {
+ return "black";
+ }
+ final String result = colornames.get(c);
+ if (result == null) {
+ throw new IllegalArgumentException();
+ }
+ return result;
+ }
+
+ public void createData(OutputStream os) throws IOException {
+ out(os, "\\documentclass{article}");
+ out(os, "\\usepackage{tikz}");
+ out(os, "\\usepackage{aeguill}");
+ // out(os, "\\usetikzlibrary{trees}");
+ out(os, "\\begin{document}");
+ out(os, "% generated by Plantuml " + Version.versionString(10));
+ for (Map.Entry<Color, String> ent : colornames.entrySet()) {
+ out(os, definecolor(ent.getValue(), ent.getKey()));
+
+ }
+ out(os, "\\begin{tikzpicture}[yscale=-1]");
+ for (String s : cmd) {
+ out(os, s);
+ }
+ out(os, "\\end{tikzpicture}");
+ out(os, "\\end{document}");
+ }
+
+ private String definecolor(String name, Color color) {
+ return "\\definecolor{" + name + "}{RGB}{" + color.getRed() + "," + color.getGreen() + "," + color.getBlue()
+ + "}";
+ }
+
+ public void rectangle(double x, double y, double width, double height) {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("\\draw[");
+ if (color != null) {
+ sb.append("color=" + getColorName(color) + ",");
+ }
+ if (fillcolor != null) {
+ sb.append("fill=" + getColorName(fillcolor) + ",");
+ if (color == null) {
+ sb.append("color=" + getColorName(fillcolor) + ",");
+ }
+ }
+ sb.append("line width=" + thickness + "pt] ");
+ sb.append(couple(x, y) + " rectangle " + couple(x + width, y + height));
+ sb.append(";");
+ cmd.add(sb.toString());
+ }
+
+ private String couple(double x, double y) {
+ return "(" + format(x) + "pt," + format(y) + "pt)";
+ }
+
+ private String format(double x) {
+ return EpsGraphics.format(x);
+ }
+
+ private void out(OutputStream os, String s) throws IOException {
+ os.write(s.getBytes());
+ os.write("\n".getBytes());
+ }
+
+ public void text(double x, double y, String text) {
+ final String s = "\\node at " + couple(x, y) + "[below right]{" + protectText(text) + "};";
+ cmd.add(s);
+ }
+
+ private String protectText(String text) {
+ text = text.replaceAll("_", "\\\\_");
+ text = text.replaceAll("\u00AB", "\\\\guillemotleft ");
+ text = text.replaceAll("\u00BB", "\\\\guillemotright ");
+ text = text.replaceAll("<", "\\\\textless ");
+ text = text.replaceAll(">", "\\\\textgreater ");
+ return text;
+ }
+
+ public void line(double x1, double y1, double x2, double y2) {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("\\draw[");
+ if (color != null) {
+ sb.append("color=" + getColorName(color) + ",");
+ }
+ sb.append("line width=" + thickness + "pt");
+ if (dash != null) {
+ sb.append(",dash pattern=" + dash);
+ }
+ sb.append("] ");
+ sb.append(couple(x1, y1));
+ sb.append(" -- ");
+ sb.append(couple(x2, y2));
+ sb.append(";");
+ cmd.add(sb.toString());
+ }
+
+ public void polygon(double[] points) {
+ final StringBuilder sb = new StringBuilder("\\draw[");
+ if (color != null) {
+ sb.append("color=" + getColorName(color) + ",");
+ }
+ if (fillcolor != null) {
+ sb.append("fill=" + getColorName(fillcolor) + ",");
+ }
+ sb.append("line width=" + thickness + "pt]");
+ sb.append(" ");
+ for (int i = 0; i < points.length; i += 2) {
+ sb.append(couple(points[i], points[i + 1]));
+ sb.append(" -- ");
+ }
+ sb.append("cycle;");
+ cmd.add(sb.toString());
+ }
+
+ public void upath(double x, double y, UPath path) {
+ final StringBuilder sb = new StringBuilder("\\draw[color=" + getColorName(color) + ",line width=" + thickness
+ + "pt] ");
+ for (USegment seg : path) {
+ final USegmentType type = seg.getSegmentType();
+ final double coord[] = seg.getCoord();
+ if (type == USegmentType.SEG_MOVETO) {
+ sb.append(couple(coord[0] + x, coord[1] + y));
+ } else if (type == USegmentType.SEG_LINETO) {
+ sb.append(" -- ");
+ sb.append(couple(coord[0] + x, coord[1] + y));
+ } else if (type == USegmentType.SEG_QUADTO) {
+ throw new UnsupportedOperationException();
+ } else if (type == USegmentType.SEG_CUBICTO) {
+ // curvetoNoMacro(coord[0] + x, coord[1] + y, coord[2] + x, coord[3] + y, coord[4] + x, coord[5] + y);
+ sb.append(" ..controls ");
+ sb.append(couple(coord[0] + x, coord[1] + y));
+ sb.append(" and ");
+ sb.append(couple(coord[2] + x, coord[3] + y));
+ sb.append(" .. ");
+ sb.append(couple(coord[4] + x, coord[5] + y));
+ } else if (type == USegmentType.SEG_CLOSE) {
+ // Nothing
+ } else {
+ Log.println("unknown " + seg);
+ }
+ }
+ sb.append(";");
+ cmd.add(sb.toString());
+ }
+
+ public void ellipse(double x, double y, double width, double height) {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("\\draw[");
+ if (color != null) {
+ sb.append("color=" + getColorName(color) + ",");
+ }
+ if (fillcolor != null) {
+ sb.append("fill=" + getColorName(fillcolor) + ",");
+ }
+ sb.append("line width=" + thickness + "pt] " + couple(x, y) + " ellipse (" + format(width) + "pt and "
+ + format(height) + "pt);");
+ cmd.add(sb.toString());
+ }
+
+ public void drawPathIterator(double x, double y, PathIterator path) {
+ final StringBuilder sb = new StringBuilder("\\draw[color=" + getColorName(color) + ",fill="
+ + getColorName(color) + "] ");
+ final double coord[] = new double[6];
+ while (path.isDone() == false) {
+ final int code = path.currentSegment(coord);
+ if (code == PathIterator.SEG_MOVETO) {
+ sb.append(couple(coord[0] + x, coord[1] + y));
+ } else if (code == PathIterator.SEG_LINETO) {
+ sb.append(" -- ");
+ sb.append(couple(coord[0] + x, coord[1] + y));
+ } else if (code == PathIterator.SEG_CLOSE) {
+ sb.append(";");
+ cmd.add(sb.toString());
+ sb.setLength(0);
+ sb.append("\\draw ");
+ } else if (code == PathIterator.SEG_CUBICTO) {
+ sb.append(" ..controls ");
+ sb.append(couple(coord[0] + x, coord[1] + y));
+ sb.append(" and ");
+ sb.append(couple(coord[2] + x, coord[3] + y));
+ sb.append(" .. ");
+ sb.append(couple(coord[4] + x, coord[5] + y));
+ } else if (code == PathIterator.SEG_QUADTO) {
+ sb.append(" ..controls ");
+ sb.append(couple(coord[0] + x, coord[1] + y));
+ sb.append(" .. ");
+ sb.append(couple(coord[2] + x, coord[3] + y));
+ } else {
+ throw new UnsupportedOperationException("code=" + code);
+ }
+
+ path.next();
+ }
+
+ // eps.fill(path.getWindingRule());
+
+ }
+
+ public void setFillColor(Color c) {
+ // if (c == null) {
+ // c = Color.WHITE;
+ // }
+ this.fillcolor = c;
+ addColor(c);
+ }
+
+ public void setStrokeColor(Color c) {
+ // if (c == null) {
+ // throw new IllegalArgumentException();
+ // }
+ this.color = c;
+ addColor(c);
+ }
+
+ private void addColor(Color c) {
+ if (c == null) {
+ return;
+ }
+ if (colornames.containsKey(c)) {
+ return;
+ }
+ final String name = "plantucolor" + String.format("%04d", colornames.size());
+ colornames.put(c, name);
+ }
+
+ public void setStrokeWidth(double thickness, String dash) {
+ this.thickness = thickness;
+ this.dash = dash;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/AbstractCommonUGraphic.java b/src/net/sourceforge/plantuml/ugraphic/AbstractCommonUGraphic.java
new file mode 100644
index 0000000..5c0de1b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/AbstractCommonUGraphic.java
@@ -0,0 +1,150 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+
+public abstract class AbstractCommonUGraphic implements UGraphic {
+
+ private UStroke stroke = new UStroke();
+ private UPattern pattern = UPattern.FULL;
+ private boolean hidden = false;
+ private HtmlColor backColor = null;
+ private HtmlColor color = null;
+
+ private UTranslate translate = new UTranslate();
+
+ private final ColorMapper colorMapper;
+ private UClip clip;
+ private double scale = 1;
+
+ public UGraphic apply(UChange change) {
+ final AbstractCommonUGraphic copy = copyUGraphic();
+ if (change instanceof UTranslate) {
+ copy.translate = ((UTranslate) change).scaled(scale).compose(copy.translate);
+ } else if (change instanceof UClip) {
+ copy.clip = (UClip) change;
+ copy.clip = copy.clip.translate(getTranslateX(), getTranslateY());
+ } else if (change instanceof UStroke) {
+ copy.stroke = (UStroke) change;
+ } else if (change instanceof UPattern) {
+ copy.pattern = (UPattern) change;
+ } else if (change instanceof UHidden) {
+ copy.hidden = change == UHidden.HIDDEN;
+ } else if (change instanceof UChangeBackColor) {
+ copy.backColor = ((UChangeBackColor) change).getBackColor();
+ } else if (change instanceof UChangeColor) {
+ copy.color = ((UChangeColor) change).getColor();
+ } else if (change instanceof UScale) {
+ final double factor = ((UScale) change).getScale();
+ copy.scale = scale * factor;
+ }
+ return copy;
+ }
+
+ final public UClip getClip() {
+ return clip;
+ }
+
+ public AbstractCommonUGraphic(ColorMapper colorMapper) {
+ this.colorMapper = colorMapper;
+ }
+
+ protected AbstractCommonUGraphic(AbstractCommonUGraphic other) {
+ this.colorMapper = other.colorMapper;
+ this.translate = other.translate;
+ this.clip = other.clip;
+
+ this.stroke = other.stroke;
+ this.pattern = other.pattern;
+ this.hidden = other.hidden;
+ this.color = other.color;
+ this.backColor = other.backColor;
+ this.scale = other.scale;
+ }
+
+ protected abstract AbstractCommonUGraphic copyUGraphic();
+
+ final public UParam getParam() {
+ return new UParam() {
+
+ public boolean isHidden() {
+ return hidden;
+ }
+
+ public UStroke getStroke() {
+ return stroke;
+ }
+
+ public HtmlColor getColor() {
+ return color;
+ }
+
+ public HtmlColor getBackcolor() {
+ return backColor;
+ }
+
+ public UPattern getPattern() {
+ return pattern;
+ }
+
+ public double getScale() {
+ return scale;
+ }
+ };
+ }
+
+ final protected double getTranslateX() {
+ return translate.getDx();
+ }
+
+ final protected double getTranslateY() {
+ return translate.getDy();
+ }
+
+ final public ColorMapper getColorMapper() {
+ return new ColorMapperTransparentWrapper(colorMapper);
+ }
+
+ public void flushUg() {
+
+ }
+
+ public boolean isSpecialTxt() {
+ return false;
+ }
+
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/AbstractPlacementStrategy.java b/src/net/sourceforge/plantuml/ugraphic/AbstractPlacementStrategy.java
new file mode 100644
index 0000000..760246b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/AbstractPlacementStrategy.java
@@ -0,0 +1,114 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.awt.geom.Dimension2D;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+
+public abstract class AbstractPlacementStrategy implements PlacementStrategy {
+
+ private final StringBounder stringBounder;
+ private final Map<TextBlock, Dimension2D> dimensions = new LinkedHashMap<TextBlock, Dimension2D>();
+
+ public AbstractPlacementStrategy(StringBounder stringBounder) {
+ this.stringBounder = stringBounder;
+ }
+
+ public void add(TextBlock block) {
+ this.dimensions.put(block, block.calculateDimension(stringBounder));
+ }
+
+ protected Map<TextBlock, Dimension2D> getDimensions() {
+ return dimensions;
+ }
+
+ protected double getSumWidth() {
+ return getSumWidth(dimensions.values().iterator());
+ }
+
+ protected double getSumHeight() {
+ return getSumHeight(dimensions.values().iterator());
+ }
+
+ protected double getMaxHeight() {
+ return getMaxHeight(dimensions.values().iterator());
+ }
+
+ protected double getMaxWidth() {
+ return getMaxWidth(dimensions.values().iterator());
+ }
+
+ protected double getSumWidth(Iterator<Dimension2D> it) {
+ double result = 0;
+ while (it.hasNext()) {
+ result += it.next().getWidth();
+ }
+ return result;
+ }
+
+ protected double getSumHeight(Iterator<Dimension2D> it) {
+ double result = 0;
+ while (it.hasNext()) {
+ result += it.next().getHeight();
+ }
+ return result;
+ }
+
+ protected double getMaxWidth(Iterator<Dimension2D> it) {
+ double result = 0;
+ while (it.hasNext()) {
+ result = Math.max(result, it.next().getWidth());
+ }
+ return result;
+ }
+
+ protected double getMaxHeight(Iterator<Dimension2D> it) {
+ double result = 0;
+ while (it.hasNext()) {
+ result = Math.max(result, it.next().getHeight());
+ }
+ return result;
+ }
+
+ protected final StringBounder getStringBounder() {
+ return stringBounder;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/AbstractShadowable.java b/src/net/sourceforge/plantuml/ugraphic/AbstractShadowable.java
new file mode 100644
index 0000000..693bf64
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/AbstractShadowable.java
@@ -0,0 +1,49 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+abstract class AbstractShadowable implements Shadowable {
+
+ private double deltaShadow;
+
+ public double getDeltaShadow() {
+ return deltaShadow;
+ }
+
+ public void setDeltaShadow(double deltaShadow) {
+ this.deltaShadow = deltaShadow;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/AbstractUGraphic.java b/src/net/sourceforge/plantuml/ugraphic/AbstractUGraphic.java
new file mode 100644
index 0000000..0db6067
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/AbstractUGraphic.java
@@ -0,0 +1,97 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public abstract class AbstractUGraphic<O> extends AbstractCommonUGraphic {
+
+ private final O g2d;
+
+ private final Map<Class<? extends UShape>, UDriver<O>> drivers = new HashMap<Class<? extends UShape>, UDriver<O>>();
+
+ public AbstractUGraphic(ColorMapper colorMapper, O g2d) {
+ super(colorMapper);
+ this.g2d = g2d;
+ }
+
+ protected AbstractUGraphic(AbstractUGraphic<O> other) {
+ super(other);
+ this.g2d = other.g2d;
+ // this.drivers.putAll(other.drivers);
+ }
+
+ protected final O getGraphicObject() {
+ return g2d;
+ }
+
+ protected boolean manageHiddenAutomatically() {
+ return true;
+ }
+
+ final protected void registerDriver(Class<? extends UShape> cl, UDriver<O> driver) {
+ this.drivers.put(cl, driver);
+ }
+
+ public final void draw(UShape shape) {
+ if (shape instanceof UEmpty) {
+ return;
+ }
+ final UDriver<O> driver = drivers.get(shape.getClass());
+ if (driver == null) {
+ throw new UnsupportedOperationException(shape.getClass().toString() + " " + this.getClass());
+ }
+ if (getParam().isHidden() && manageHiddenAutomatically()) {
+ return;
+ }
+ beforeDraw();
+ if (shape instanceof Scalable) {
+ final double scale = getParam().getScale();
+ shape = ((Scalable) shape).getScaled(scale);
+ driver.draw(shape, getTranslateX(), getTranslateY(), getColorMapper(), getParam(), g2d);
+ } else {
+ driver.draw(shape, getTranslateX(), getTranslateY(), getColorMapper(), getParam(), g2d);
+ }
+ afterDraw();
+ }
+
+ protected void beforeDraw() {
+ }
+
+ protected void afterDraw() {
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/AbstractUGraphicHorizontalLine.java b/src/net/sourceforge/plantuml/ugraphic/AbstractUGraphicHorizontalLine.java
new file mode 100644
index 0000000..54739f6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/AbstractUGraphicHorizontalLine.java
@@ -0,0 +1,74 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import net.sourceforge.plantuml.graphic.UGraphicDelegator;
+
+public abstract class AbstractUGraphicHorizontalLine extends UGraphicDelegator {
+
+ private UTranslate translate = new UTranslate();
+
+ public UGraphic apply(UChange change) {
+ final AbstractUGraphicHorizontalLine result;
+ if (change instanceof UTranslate) {
+ result = copy(getUg());
+ result.translate = this.translate.compose((UTranslate) change);
+ } else {
+ result = copy(getUg().apply(change));
+ result.translate = this.translate;
+ }
+ return result;
+ }
+
+ protected abstract AbstractUGraphicHorizontalLine copy(UGraphic ug);
+
+ protected AbstractUGraphicHorizontalLine(UGraphic ug) {
+ super(ug);
+ }
+
+ protected abstract void drawHline(UGraphic ug, UHorizontalLine line, UTranslate translate);
+
+ public void draw(UShape shape) {
+ if (shape instanceof UHorizontalLine) {
+ drawHline(getUg(), (UHorizontalLine) shape, new UTranslate(0, translate.getDy()));
+ } else {
+ getUg().apply(translate).draw(shape);
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/ClipContainer.java b/src/net/sourceforge/plantuml/ugraphic/ClipContainer.java
new file mode 100644
index 0000000..e8d460b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/ClipContainer.java
@@ -0,0 +1,39 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+public interface ClipContainer {
+ public UClip getClip();
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/ColorChangerMonochrome.java b/src/net/sourceforge/plantuml/ugraphic/ColorChangerMonochrome.java
new file mode 100644
index 0000000..a1754c7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/ColorChangerMonochrome.java
@@ -0,0 +1,48 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.awt.Color;
+
+public class ColorChangerMonochrome {
+
+ public Color getChangedColor(Color color) {
+ if (color==null) {
+ return null;
+ }
+ final int grayScale = (int) (color.getRed() * .3 + color.getGreen() * .59 + color.getBlue() * .11);
+ return new Color(grayScale, grayScale, grayScale);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/ColorMapper.java b/src/net/sourceforge/plantuml/ugraphic/ColorMapper.java
new file mode 100644
index 0000000..0154e03
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/ColorMapper.java
@@ -0,0 +1,44 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.awt.Color;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+
+public interface ColorMapper {
+
+ Color getMappedColor(HtmlColor color);
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/ColorMapperIdentity.java b/src/net/sourceforge/plantuml/ugraphic/ColorMapperIdentity.java
new file mode 100644
index 0000000..0aa7765
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/ColorMapperIdentity.java
@@ -0,0 +1,59 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.awt.Color;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorSimple;
+import net.sourceforge.plantuml.graphic.HtmlColorTransparent;
+import net.sourceforge.plantuml.graphic.HtmlColorUserDef;
+
+public class ColorMapperIdentity implements ColorMapper {
+
+ public Color getMappedColor(HtmlColor color) {
+ if (color == null) {
+ return null;
+ }
+ if (color instanceof HtmlColorTransparent) {
+ throw new UnsupportedOperationException();
+ }
+ if (color instanceof HtmlColorUserDef) {
+ // Impact on JCCKIT
+ return Color.WHITE;
+ }
+ return ((HtmlColorSimple) color).getColor999();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/ColorMapperMonochrome.java b/src/net/sourceforge/plantuml/ugraphic/ColorMapperMonochrome.java
new file mode 100644
index 0000000..d2a0e2b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/ColorMapperMonochrome.java
@@ -0,0 +1,51 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.awt.Color;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+
+public class ColorMapperMonochrome implements ColorMapper {
+
+ public Color getMappedColor(HtmlColor htmlColor) {
+ if (htmlColor == null) {
+ return null;
+ }
+ final Color color = new ColorMapperIdentity().getMappedColor(htmlColor);
+ final int grayScale = (int) (color.getRed() * .3 + color.getGreen() * .59 + color.getBlue() * .11);
+ return new Color(grayScale, grayScale, grayScale);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/ColorMapperTransparentWrapper.java b/src/net/sourceforge/plantuml/ugraphic/ColorMapperTransparentWrapper.java
new file mode 100644
index 0000000..954b783
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/ColorMapperTransparentWrapper.java
@@ -0,0 +1,63 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.awt.Color;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorTransparent;
+
+public class ColorMapperTransparentWrapper implements ColorMapper {
+
+ private final ColorMapper mapper;
+
+ public ColorMapperTransparentWrapper(ColorMapper mapper) {
+ if (mapper == null) {
+ throw new IllegalArgumentException();
+ }
+ this.mapper = mapper;
+ }
+
+ public Color getMappedColor(HtmlColor color) {
+ if (color == null) {
+ return null;
+ }
+ if (color instanceof HtmlColorTransparent) {
+ return Color.WHITE;
+ }
+ return mapper.getMappedColor(color);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/CompressionTransform.java b/src/net/sourceforge/plantuml/ugraphic/CompressionTransform.java
new file mode 100644
index 0000000..9f8268b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/CompressionTransform.java
@@ -0,0 +1,66 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.util.List;
+
+public class CompressionTransform {
+
+ private final List<Slot> all;
+
+ public CompressionTransform(SlotSet slotSet) {
+ this.all = slotSet.getSlots();
+ }
+
+ public double transform(double v) {
+ return v - getCompressDelta(v);
+ }
+
+ private double getCompressDelta(double v) {
+ double result = 0;
+ for (Slot s : all) {
+ if (s.getStart() > v) {
+ continue;
+ }
+ if (v > s.getEnd()) {
+ result += s.size();
+ } else {
+ result += v - s.getStart();
+ }
+ }
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/FontChecker.java b/src/net/sourceforge/plantuml/ugraphic/FontChecker.java
new file mode 100644
index 0000000..c234d28
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/FontChecker.java
@@ -0,0 +1,246 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.awt.Font;
+import java.awt.GraphicsEnvironment;
+import java.awt.Shape;
+import java.awt.font.TextLayout;
+import java.awt.geom.PathIterator;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.imageio.ImageIO;
+import javax.xml.transform.TransformerException;
+
+import net.sourceforge.plantuml.FileFormat;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.svg.SvgGraphics;
+
+public class FontChecker {
+
+ final private UFont font;
+ private static final Set<String> SQUARRE = new HashSet<String>(Arrays.asList("MI=I=XM=I=IX",
+ "MI=I=XM=I=IXMI=I=XM=I=IX"));
+
+ public FontChecker(UFont font) {
+ this.font = font;
+ }
+
+ public boolean isCharOk(char c) {
+ return SQUARRE.contains(getCharDesc(c)) == false;
+ }
+
+ static private String getType(int type, double oldX, double oldY, double x, double y) {
+ if (type == PathIterator.SEG_CLOSE) {
+ return "X";
+ }
+ if (type == PathIterator.SEG_LINETO) {
+ if (oldX == x) {
+ return "I";
+ }
+ if (oldY == y) {
+ return "=";
+ }
+ return "L";
+ }
+ if (type == PathIterator.SEG_MOVETO) {
+ return "M";
+ }
+ if (type == PathIterator.SEG_QUADTO) {
+ return "Q";
+ }
+ if (type == PathIterator.SEG_CUBICTO) {
+ return "C";
+ }
+ throw new IllegalArgumentException();
+ }
+
+ public String getCharDesc(char c) {
+ final TextLayout t = new TextLayout("" + c, font.getFont(), TextBlockUtils.getFontRenderContext());
+ final Shape sh = t.getOutline(null);
+ final double current[] = new double[6];
+ final PathIterator it = sh.getPathIterator(null);
+ int sum = 0;
+ final StringBuilder result = new StringBuilder();
+ while (it.isDone() == false) {
+ final double oldX = current[0];
+ final double oldY = current[1];
+ final int nb = it.currentSegment(current);
+ sum += nb;
+ result.append(getType(nb, oldX, oldY, current[0], current[1]));
+ it.next();
+ }
+ return result.toString();
+ }
+
+ public String getCharDescVerbose(char c) {
+ final TextLayout t = new TextLayout("" + c, font.getFont(), TextBlockUtils.getFontRenderContext());
+ final Shape sh = t.getOutline(null);
+ final double current[] = new double[6];
+ final PathIterator it = sh.getPathIterator(null);
+ int sum = 0;
+ final StringBuilder result = new StringBuilder();
+ while (it.isDone() == false) {
+ final double oldX = current[0];
+ final double oldY = current[1];
+ final int nb = it.currentSegment(current);
+ sum += nb;
+ result.append(getType(nb, oldX, oldY, current[0], current[1]));
+ appendValue(result, current);
+ it.next();
+ }
+ return result.toString();
+ }
+
+ private void appendValue(StringBuilder result, double[] current) {
+ for (double v : current) {
+ final int i = (int) (v * 100);
+ result.append(i);
+ result.append(":");
+ }
+
+ }
+
+ public void printChar(final PrintWriter pw, char c) throws IOException, TransformerException {
+ pw.println("<p>");
+ final int ascii = (int) c;
+ pw.println(ascii + " - " + Integer.toHexString(ascii) + " - ");
+ pw.println("&#" + ascii + ";");
+ final String svg = getSvgImage(c);
+ pw.println(svg);
+ }
+
+ private String getSvgImage(char c) throws IOException, TransformerException {
+ final SvgGraphics svg = new SvgGraphics(1.0);
+ svg.setStrokeColor("black");
+ svg.svgImage(getBufferedImage(c), 0, 0);
+ final ByteArrayOutputStream os = new ByteArrayOutputStream();
+ svg.createXml(os);
+ os.close();
+ return new String(os.toByteArray());
+ }
+
+ public BufferedImage getBufferedImage(final char c) throws IOException {
+ assert c != '\t';
+ final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1, null, null, null, 0, 0, null, false);
+ final double dim = 20;
+ imageBuilder.addUDrawable(new UDrawable() {
+ public void drawU(UGraphic ug) {
+ ug = ug.apply(new UChangeColor(HtmlColorUtils.BLACK));
+ ug.draw(new URectangle(dim - 1, dim - 1));
+ if (ug instanceof UGraphic2) {
+ ug = (UGraphic2) ug.apply(new UTranslate(dim / 3, 2 * dim / 3));
+ final UText text = new UText("" + c, new FontConfiguration(font, HtmlColorUtils.BLACK,
+ HtmlColorUtils.BLUE, true));
+ ug.draw(text);
+ }
+ }
+ });
+ final ByteArrayOutputStream os = new ByteArrayOutputStream();
+ imageBuilder.writeImageTOBEMOVED(FileFormat.PNG, os);
+ os.close();
+ return ImageIO.read(new ByteArrayInputStream(os.toByteArray()));
+ }
+
+ // public BufferedImage getBufferedImageOld(char c) throws IOException {
+ // final double dim = 20;
+ // UGraphic2 ug = new FileFormatOption(FileFormat.PNG).createUGraphic(new Dimension2DDouble(dim, dim));
+ // ug = (UGraphic2) ug.apply(new UChangeColor(HtmlColorUtils.BLACK));
+ // ug.draw(new URectangle(dim - 1, dim - 1));
+ // ug = (UGraphic2) ug.apply(new UTranslate(dim / 3, 2 * dim / 3));
+ // final UText text = new UText("" + c, new FontConfiguration(font, HtmlColorUtils.BLACK));
+ // ug.draw(text);
+ // final ByteArrayOutputStream os = new ByteArrayOutputStream();
+ // ug.writeImageTOBEMOVED(os, null, 96);
+ // os.close();
+ // return ImageIO.read(new ByteArrayInputStream(os.toByteArray()));
+ // }
+
+ public static void main(String[] args) throws IOException, TransformerException {
+
+ final String name = args[0];
+ final int size = Integer.parseInt(args[1]);
+ final int v1 = Integer.parseInt(args[2]);
+ final int v2 = Integer.parseInt(args[3]);
+ final File f = new File("fontchecker-" + name + "-" + v1 + "-" + v2 + ".html");
+
+ final FontChecker fc = new FontChecker(new UFont(name, Font.PLAIN, size));
+ final PrintWriter pw = new PrintWriter(f);
+ pw.println("<html>");
+ pw.println("<h1>PROBLEM</h1>");
+ for (int i = v1; i <= v2; i++) {
+ final char c = (char) i;
+ final boolean ok = fc.isCharOk(c);
+ if (ok == false) {
+ fc.printChar(pw, c);
+ pw.println("</p>");
+ }
+ }
+ pw.println("<h1>OK</h1>");
+ final String allFontNames[] = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
+ for (int i = v1; i <= v2; i++) {
+ final char c = (char) i;
+ final boolean ok = fc.isCharOk(c);
+ if (ok) {
+ fc.printChar(pw, c);
+ final String desc = fc.getCharDescVerbose(c);
+ for (String n : allFontNames) {
+ final FontChecker other = new FontChecker(new UFont(n, Font.PLAIN, size));
+ final String descOther = other.getCharDescVerbose(c);
+ if (desc.equals(descOther)) {
+ pw.println("&nbsp;");
+ pw.println(n);
+ }
+ }
+ pw.println("</p>");
+
+ }
+ }
+ pw.println("</html>");
+ pw.close();
+
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java b/src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java
new file mode 100644
index 0000000..57fd164
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java
@@ -0,0 +1,304 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Dimension2D;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Set;
+
+import javax.imageio.ImageIO;
+import javax.swing.ImageIcon;
+
+import net.sourceforge.plantuml.AnimatedGifEncoder;
+import net.sourceforge.plantuml.CMapData;
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.EmptyImageBuilder;
+import net.sourceforge.plantuml.FileFormat;
+import net.sourceforge.plantuml.FileUtils;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.anim.AffineTransformation;
+import net.sourceforge.plantuml.anim.Animation;
+import net.sourceforge.plantuml.api.ImageDataComplex;
+import net.sourceforge.plantuml.api.ImageDataSimple;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.eps.EpsStrategy;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorGradient;
+import net.sourceforge.plantuml.graphic.HtmlColorSimple;
+import net.sourceforge.plantuml.graphic.HtmlColorTransparent;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.mjpeg.MJPEGGenerator;
+import net.sourceforge.plantuml.ugraphic.eps.UGraphicEps;
+import net.sourceforge.plantuml.ugraphic.g2d.UGraphicG2d;
+import net.sourceforge.plantuml.ugraphic.hand.UGraphicHandwritten;
+import net.sourceforge.plantuml.ugraphic.html5.UGraphicHtml5;
+import net.sourceforge.plantuml.ugraphic.svg.UGraphicSvg;
+import net.sourceforge.plantuml.ugraphic.tikz.UGraphicTikz;
+import net.sourceforge.plantuml.ugraphic.visio.UGraphicVdx;
+import net.sourceforge.plantuml.StringUtils;
+
+public class ImageBuilder {
+
+ private final ColorMapper colorMapper;
+ private final double dpiFactor;
+ private final HtmlColor mybackcolor;
+ private final String metadata;
+ private final String warningOrError;
+ private final double margin1;
+ private final double margin2;
+ private final Animation affineTransformations;
+ private final boolean useHandwritten;
+
+ // private final AffineTransform affineTransform;
+ // private final boolean withMetadata;
+ // private final boolean useRedForError;
+
+ private UDrawable udrawable;
+
+ public ImageBuilder(ColorMapper colorMapper, double dpiFactor, HtmlColor mybackcolor, String metadata,
+ String warningOrError, double margin1, double margin2, Animation affineTransformations,
+ boolean useHandwritten) {
+ this.colorMapper = colorMapper;
+ this.dpiFactor = dpiFactor;
+ this.mybackcolor = mybackcolor;
+ this.metadata = metadata;
+ this.warningOrError = warningOrError;
+ this.margin1 = margin1;
+ this.margin2 = margin2;
+ this.affineTransformations = affineTransformations;
+ this.useHandwritten = useHandwritten;
+ }
+
+ public void addUDrawable(UDrawable udrawable) {
+ this.udrawable = udrawable;
+ }
+
+ public ImageData writeImageTOBEMOVED(FileFormat fileFormat, OutputStream os) throws IOException {
+ if (fileFormat == FileFormat.MJPEG) {
+ return writeImageMjpeg(os);
+ } else if (fileFormat == FileFormat.ANIMATED_GIF) {
+ return writeImageAnimatedGif(os);
+ }
+ return writeImageTOBEMOVED(fileFormat, os, affineTransformations);
+ }
+
+ private ImageData writeImageTOBEMOVED(FileFormat fileFormat, OutputStream os, Animation affineTransforms)
+ throws IOException {
+ final LimitFinder limitFinder = new LimitFinder(TextBlockUtils.getDummyStringBounder(), true);
+ udrawable.drawU(limitFinder);
+ Dimension2D dim = new Dimension2DDouble(limitFinder.getMaxX() + 1 + margin1 + margin2, limitFinder.getMaxY()
+ + 1 + margin1 + margin2);
+ double dx = 0;
+ double dy = 0;
+ if (affineTransforms != null) {
+ final MinMax minmax = affineTransformations.getMinMax(dim);
+ affineTransforms.setDimension(dim);
+ dim = minmax.getDimension();
+ dx = -minmax.getMinX();
+ dy = -minmax.getMinY();
+ }
+
+ final UGraphic2 ug = createUGraphic(fileFormat, dim, affineTransforms, dx, dy);
+ udrawable.drawU(handwritten(ug.apply(new UTranslate(margin1, margin1))));
+ ug.writeImageTOBEMOVED(os, metadata, 96);
+ os.flush();
+
+ if (ug instanceof UGraphicG2d) {
+ final Set<Url> 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);
+ }
+
+ private UGraphic handwritten(UGraphic ug) {
+ if (useHandwritten) {
+ return new UGraphicHandwritten(ug);
+ }
+ return ug;
+ }
+
+ private ImageData writeImageMjpeg(OutputStream os) throws IOException {
+
+ final LimitFinder limitFinder = new LimitFinder(TextBlockUtils.getDummyStringBounder(), true);
+ udrawable.drawU(limitFinder);
+ final Dimension2D dim = new Dimension2DDouble(limitFinder.getMaxX() + 1 + margin1 + margin2,
+ limitFinder.getMaxY() + 1 + margin1 + margin2);
+
+ final File f = new File("c:/tmp.avi");
+
+ final int nbframe = 100;
+
+ final MJPEGGenerator m = new MJPEGGenerator(f, getAviImage(null).getWidth(null), getAviImage(null).getHeight(
+ null), 12.0, nbframe);
+ for (int i = 0; i < nbframe; i++) {
+ // AffineTransform at = AffineTransform.getRotateInstance(1.0);
+ AffineTransform at = AffineTransform.getTranslateInstance(dim.getWidth() / 2, dim.getHeight() / 2);
+ at.rotate(90.0 * Math.PI / 180.0 * i / 100);
+ at.translate(-dim.getWidth() / 2, -dim.getHeight() / 2);
+ // final AffineTransform at = AffineTransform.getTranslateInstance(i, 0);
+ // final ImageIcon ii = new ImageIcon(getAviImage(at));
+ // m.addImage(ii.getImage());
+ throw new UnsupportedOperationException();
+ }
+ m.finishAVI();
+
+ FileUtils.copyToStream(f, os);
+
+ return new ImageDataSimple(dim);
+
+ }
+
+ private ImageData writeImageAnimatedGif(OutputStream os) throws IOException {
+
+ final LimitFinder limitFinder = new LimitFinder(TextBlockUtils.getDummyStringBounder(), true);
+ udrawable.drawU(limitFinder);
+ final Dimension2D dim = new Dimension2DDouble(limitFinder.getMaxX() + 1 + margin1 + margin2,
+ limitFinder.getMaxY() + 1 + margin1 + margin2);
+
+ final MinMax minmax = affineTransformations.getMinMax(dim);
+
+ final AnimatedGifEncoder e = new AnimatedGifEncoder();
+ // e.setQuality(1);
+ e.setRepeat(0);
+ e.start(os);
+ // e.setDelay(1000); // 1 frame per sec
+ // e.setDelay(100); // 10 frame per sec
+ e.setDelay(60); // 16 frame per sec
+ // e.setDelay(50); // 20 frame per sec
+
+ for (AffineTransformation at : affineTransformations.getAll()) {
+ final ImageIcon ii = new ImageIcon(getAviImage(at));
+ e.addFrame((BufferedImage) ii.getImage());
+ }
+ e.finish();
+ return new ImageDataSimple(dim);
+
+ }
+
+ private Image getAviImage(AffineTransformation affineTransform) throws IOException {
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ writeImageTOBEMOVED(FileFormat.PNG, baos, Animation.singleton(affineTransform));
+ baos.close();
+
+ final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+ final Image im = ImageIO.read(bais);
+ bais.close();
+ return im;
+ }
+
+ private UGraphic2 createUGraphic(FileFormat fileFormat, final Dimension2D dim, Animation affineTransforms,
+ double dx, double dy) {
+ switch (fileFormat) {
+ case PNG:
+ return createUGraphicPNG(colorMapper, dpiFactor, dim, mybackcolor, affineTransforms, dx, dy);
+ case SVG:
+ return createUGraphicSVG(colorMapper, dpiFactor, dim, mybackcolor);
+ case EPS:
+ return new UGraphicEps(colorMapper, EpsStrategy.getDefault2());
+ case EPS_TEXT:
+ return new UGraphicEps(colorMapper, EpsStrategy.WITH_MACRO_AND_TEXT);
+ case HTML5:
+ return new UGraphicHtml5(colorMapper);
+ case VDX:
+ return new UGraphicVdx(colorMapper);
+ case LATEX:
+ return new UGraphicTikz(colorMapper);
+ default:
+ throw new UnsupportedOperationException(fileFormat.toString());
+ }
+ }
+
+ private UGraphic2 createUGraphicSVG(ColorMapper colorMapper, double scale, Dimension2D dim, HtmlColor mybackcolor) {
+ Color backColor = Color.WHITE;
+ if (mybackcolor instanceof HtmlColorSimple) {
+ backColor = colorMapper.getMappedColor(mybackcolor);
+ }
+ final UGraphicSvg ug;
+ if (mybackcolor instanceof HtmlColorGradient) {
+ ug = new UGraphicSvg(colorMapper, (HtmlColorGradient) mybackcolor, false, scale);
+ } else if (backColor == null || backColor.equals(Color.WHITE)) {
+ ug = new UGraphicSvg(colorMapper, false, scale);
+ } else {
+ ug = new UGraphicSvg(colorMapper, StringUtils.getAsHtml(backColor), false, scale);
+ }
+ return ug;
+
+ }
+
+ private UGraphic2 createUGraphicPNG(ColorMapper colorMapper, double dpiFactor, final Dimension2D dim,
+ HtmlColor mybackcolor, Animation affineTransforms, double dx, double dy) {
+ Color backColor = Color.WHITE;
+ if (mybackcolor instanceof HtmlColorSimple) {
+ backColor = colorMapper.getMappedColor(mybackcolor);
+ } else if (mybackcolor instanceof HtmlColorTransparent) {
+ 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((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());
+ final BufferedImage im = ((UGraphicG2d) ug).getBufferedImage();
+ if (mybackcolor instanceof HtmlColorGradient) {
+ ug.apply(new UChangeBackColor(mybackcolor)).draw(new URectangle(im.getWidth(), im.getHeight()));
+ }
+
+ return ug;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/InflaterSet.java b/src/net/sourceforge/plantuml/ugraphic/InflaterSet.java
new file mode 100644
index 0000000..64cc1b1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/InflaterSet.java
@@ -0,0 +1,68 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class InflaterSet {
+
+ static class Inflater {
+ private final double start;
+ private final double size;
+
+ private Inflater(double start, double size) {
+ this.start = start;
+ this.size = size;
+ }
+ }
+
+ private final List<Inflater> all = new ArrayList<Inflater>();
+
+ public void addInflater(double start, double size) {
+ all.add(new Inflater(start, size));
+ }
+
+ public double inflate(double v) {
+ double result = v;
+ for (Inflater in : all) {
+ if (v > in.start) {
+ result += in.size;
+ }
+ }
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/LimitFinder.java b/src/net/sourceforge/plantuml/ugraphic/LimitFinder.java
new file mode 100644
index 0000000..b1034aa
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/LimitFinder.java
@@ -0,0 +1,228 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.posimo.DotPath;
+
+public class LimitFinder implements UGraphic {
+
+ public boolean isSpecialTxt() {
+ return false;
+ }
+
+ public UGraphic apply(UChange change) {
+ if (change instanceof UTranslate) {
+ return new LimitFinder(stringBounder, minmax, translate.compose((UTranslate) change), clip);
+ } else if (change instanceof UStroke) {
+ return new LimitFinder(this);
+ } else if (change instanceof UChangeBackColor) {
+ return new LimitFinder(this);
+ } else if (change instanceof UChangeColor) {
+ return new LimitFinder(this);
+ } else if (change instanceof UHidden) {
+ return new LimitFinder(this);
+ } else if (change instanceof UAntiAliasing) {
+ return new LimitFinder(this);
+ } else if (change instanceof UClip) {
+ final LimitFinder copy = new LimitFinder(this);
+ copy.clip = (UClip) change;
+ copy.clip = copy.clip.translate(translate);
+ return copy;
+ }
+ throw new UnsupportedOperationException(change.getClass().toString());
+ }
+
+ private final StringBounder stringBounder;
+ private final UTranslate translate;
+ private final MinMaxMutable minmax;
+ private UClip clip;
+
+ public LimitFinder(StringBounder stringBounder, boolean initToZero) {
+ this(stringBounder, MinMaxMutable.getEmpty(initToZero), new UTranslate(), null);
+ }
+
+ private LimitFinder(StringBounder stringBounder, MinMaxMutable minmax, UTranslate translate, UClip clip) {
+ this.stringBounder = stringBounder;
+ this.minmax = minmax;
+ this.translate = translate;
+ this.clip = clip;
+ }
+
+ private LimitFinder(LimitFinder other) {
+ this(other.stringBounder, other.minmax, other.translate, other.clip);
+ }
+
+ public StringBounder getStringBounder() {
+ return stringBounder;
+ }
+
+ public UParam getParam() {
+ return new UParamNull();
+ }
+
+ private void addPoint(double x, double y) {
+ if (clip == null || clip.isInside(x, y)) {
+ minmax.addPoint(x, y);
+ }
+ }
+
+ public void draw(UShape shape) {
+ final double x = translate.getDx();
+ final double y = translate.getDy();
+ if (shape instanceof UText) {
+ drawText(x, y, (UText) shape);
+ } else if (shape instanceof ULine) {
+ drawULine(x, y, (ULine) shape);
+ } else if (shape instanceof UEllipse) {
+ drawEllipse(x, y, (UEllipse) shape);
+ } else if (shape instanceof UPolygon) {
+ drawUPolygon(x, y, (UPolygon) shape);
+ } else if (shape instanceof UPath) {
+ drawUPath(x, y, (UPath) shape);
+ } else if (shape instanceof URectangle) {
+ drawRectangle(x, y, (URectangle) shape);
+ } else if (shape instanceof DotPath) {
+ drawDotPath(x, y, (DotPath) shape);
+ } else if (shape instanceof UImage) {
+ drawImage(x, y, (UImage) shape);
+ } else if (shape instanceof UEmpty) {
+ drawEmpty(x, y, (UEmpty) shape);
+ } else if (shape instanceof TextBlock) {
+ final TextBlock tb = (TextBlock) shape;
+ tb.drawU(this);
+ } else if (shape instanceof UCenteredCharacter) {
+ // To be done
+ } else if (shape instanceof UPixel) {
+ addPoint(x, y);
+ } else {
+ throw new UnsupportedOperationException(shape.getClass().getName());
+ }
+ }
+
+ private void drawEmpty(double x, double y, UEmpty shape) {
+ addPoint(x, y);
+ addPoint(x + shape.getWidth(), y + shape.getHeight());
+ }
+
+ private void drawUPath(double x, double y, UPath shape) {
+ addPoint(x + shape.getMinX(), y + shape.getMinY());
+ addPoint(x + shape.getMaxX(), y + shape.getMaxY());
+ }
+
+ private void drawUPolygon(double x, double y, UPolygon shape) {
+ if (shape.getPoints().size() == 0) {
+ return;
+ }
+ addPoint(x + shape.getMinX(), y + shape.getMinY());
+ addPoint(x + shape.getMaxX(), y + shape.getMaxY());
+ }
+
+ private void drawULine(double x, double y, ULine shape) {
+ addPoint(x, y);
+ addPoint(x + shape.getDX(), y + shape.getDY());
+ }
+
+ private void drawRectangle(double x, double y, URectangle shape) {
+ addPoint(x, y);
+ addPoint(x + shape.getWidth(), y + shape.getHeight());
+ }
+
+ private void drawDotPath(double x, double y, DotPath shape) {
+ final MinMax shapeMinMax = shape.getMinMax();
+ addPoint(x + shapeMinMax.getMinX(), y + shapeMinMax.getMinY());
+ addPoint(x + shapeMinMax.getMaxX(), y + shapeMinMax.getMaxY());
+ }
+
+ private void drawImage(double x, double y, UImage shape) {
+ addPoint(x, y);
+ addPoint(x + shape.getWidth(), y + shape.getHeight());
+ }
+
+ private void drawEllipse(double x, double y, UEllipse shape) {
+ addPoint(x, y);
+ addPoint(x + shape.getWidth(), y + shape.getHeight());
+ }
+
+ private void drawText(double x, double y, UText text) {
+ final Dimension2D dim = stringBounder.calculateDimension(text.getFontConfiguration().getFont(), text.getText());
+ y -= dim.getHeight() - 1.5;
+ addPoint(x, y);
+ addPoint(x, y + dim.getHeight());
+ addPoint(x + dim.getWidth(), y);
+ addPoint(x + dim.getWidth(), y + dim.getHeight());
+ }
+
+ public ColorMapper getColorMapper() {
+ return new ColorMapperIdentity();
+ }
+
+ public void startUrl(Url url) {
+ }
+
+ public void closeAction() {
+ }
+
+ public double getMaxX() {
+ return minmax.getMaxX();
+ }
+
+ public double getMaxY() {
+ return minmax.getMaxY();
+ }
+
+ public double getMinX() {
+ return minmax.getMinX();
+ }
+
+ public double getMinY() {
+ return minmax.getMinY();
+ }
+
+ public MinMax getMinMax() {
+ if (minmax.isInfinity()) {
+ return MinMax.getEmpty(true);
+ }
+ return MinMax.fromMutable(minmax);
+ }
+
+ public void flushUg() {
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/MinMax.java b/src/net/sourceforge/plantuml/ugraphic/MinMax.java
new file mode 100644
index 0000000..a8dec9d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/MinMax.java
@@ -0,0 +1,135 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+
+public class MinMax {
+
+ private final double maxX;
+ private final double maxY;
+ private final double minX;
+ private final double minY;
+
+ public static MinMax getEmpty(boolean initToZero) {
+ if (initToZero) {
+ return new MinMax(0, 0, 0, 0);
+ }
+ return new MinMax(Double.MAX_VALUE, Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE);
+ }
+
+ @Override
+ public String toString() {
+ return "(" + minX + "," + minY + ")->(" + maxX + "," + maxY + ")";
+ }
+
+ public static MinMax fromMutable(MinMaxMutable minmax) {
+ return new MinMax(minmax.getMinX(), minmax.getMinY(), minmax.getMaxX(), minmax.getMaxY());
+ }
+
+ private MinMax(double minX, double minY, double maxX, double maxY) {
+ this.minX = minX;
+ this.minY = minY;
+ this.maxX = maxX;
+ this.maxY = maxY;
+ }
+
+ public MinMax addPoint(Point2D pt) {
+ return addPoint(pt.getX(), pt.getY());
+ }
+
+ public MinMax addPoint(double x, double y) {
+ return new MinMax(Math.min(x, minX), Math.min(y, minY), Math.max(x, maxX), Math.max(y, maxY));
+ }
+
+ public MinMax addMinMax(MinMax other) {
+ return new MinMax(Math.min(other.minX, minX), Math.min(other.minY, minY), Math.max(other.maxX, maxX), Math.max(other.maxY, maxY));
+ }
+
+ public static MinMax fromMax(double maxX, double maxY) {
+ return MinMax.getEmpty(true).addPoint(maxX, maxY);
+ }
+
+ public static MinMax fromDim(Dimension2D dim) {
+ return fromMax(dim.getWidth(), dim.getHeight());
+ }
+
+ public final double getMaxX() {
+ return maxX;
+ }
+
+ public final double getMaxY() {
+ return maxY;
+ }
+
+ public final double getMinX() {
+ return minX;
+ }
+
+ public final double getMinY() {
+ return minY;
+ }
+
+ public double getHeight() {
+ return maxY - minY;
+ }
+
+ public double getWidth() {
+ return maxX - minX;
+ }
+
+ public Dimension2D getDimension() {
+ return new Dimension2DDouble(maxX - minX, maxY - minY);
+ }
+
+ public void drawGrey(UGraphic ug) {
+ final HtmlColor color = HtmlColorUtils.GRAY;
+ ug = ug.apply(new UChangeColor(color)).apply(new UChangeBackColor(color));
+ ug = ug.apply(new UTranslate(minX, minY));
+ ug.draw(new URectangle(getWidth(), getHeight()));
+ }
+
+ public MinMax translate(UTranslate translate) {
+ final double dx = translate.getDx();
+ final double dy = translate.getDy();
+ return new MinMax(minX + dx, minY + dy, maxX + dx, maxY + dy);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/MinMaxMutable.java b/src/net/sourceforge/plantuml/ugraphic/MinMaxMutable.java
new file mode 100644
index 0000000..3c45961
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/MinMaxMutable.java
@@ -0,0 +1,104 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+
+public class MinMaxMutable {
+
+ private double maxX;
+ private double maxY;
+ private double minX;
+ private double minY;
+
+ public static MinMaxMutable getEmpty(boolean initToZero) {
+ if (initToZero) {
+ return new MinMaxMutable(0, 0, 0, 0);
+ }
+ return new MinMaxMutable(Double.MAX_VALUE, Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE);
+ }
+
+ public boolean isInfinity() {
+ return minX == Double.MAX_VALUE;
+ }
+
+ @Override
+ public String toString() {
+ return "X=" + minX + " " + maxX + " Y=" + minY + " " + maxY;
+ }
+
+ private MinMaxMutable(double minX, double minY, double maxX, double maxY) {
+ this.minX = minX;
+ this.minY = minY;
+ this.maxX = maxX;
+ this.maxY = maxY;
+ }
+
+ public void addPoint(double x, double y) {
+ this.maxX = Math.max(x, maxX);
+ this.maxY = Math.max(y, maxY);
+ this.minX = Math.min(x, minX);
+ this.minY = Math.min(y, minY);
+ }
+
+ public static MinMaxMutable fromMax(double maxX, double maxY) {
+ final MinMaxMutable result = MinMaxMutable.getEmpty(true);
+ result.addPoint(maxX, maxY);
+ return result;
+ }
+
+ public final double getMaxX() {
+ return maxX;
+ }
+
+ public final double getMaxY() {
+ return maxY;
+ }
+
+ public final double getMinX() {
+ return minX;
+ }
+
+ public final double getMinY() {
+ return minY;
+ }
+
+ public Dimension2D getDimension() {
+ return new Dimension2DDouble(maxX - minX, maxY - minY);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/PlacementStrategy.java b/src/net/sourceforge/plantuml/ugraphic/PlacementStrategy.java
new file mode 100644
index 0000000..55c7a22
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/PlacementStrategy.java
@@ -0,0 +1,48 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.awt.geom.Point2D;
+import java.util.Map;
+
+import net.sourceforge.plantuml.graphic.TextBlock;
+
+public interface PlacementStrategy {
+
+ public void add(TextBlock block);
+
+ public Map<TextBlock, Point2D> getPositions(double width, double height);
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/PlacementStrategyVisibility.java b/src/net/sourceforge/plantuml/ugraphic/PlacementStrategyVisibility.java
new file mode 100644
index 0000000..0ee98e7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/PlacementStrategyVisibility.java
@@ -0,0 +1,71 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+
+public class PlacementStrategyVisibility extends AbstractPlacementStrategy {
+
+ private final int col2;
+
+ public PlacementStrategyVisibility(StringBounder stringBounder, int col2) {
+ super(stringBounder);
+ this.col2 = col2;
+ }
+
+ public Map<TextBlock, Point2D> getPositions(double width, double height) {
+ final Map<TextBlock, Point2D> result = new LinkedHashMap<TextBlock, Point2D>();
+ double y = 0;
+ for (final Iterator<Map.Entry<TextBlock, Dimension2D>> it = getDimensions().entrySet().iterator(); it.hasNext();) {
+ final Map.Entry<TextBlock, Dimension2D> ent1 = it.next();
+ final Map.Entry<TextBlock, Dimension2D> ent2 = it.next();
+ final double height1 = ent1.getValue().getHeight();
+ final double height2 = ent2.getValue().getHeight();
+ final double maxHeight = Math.max(height1, height2);
+ result.put(ent1.getKey(), new Point2D.Double(0, 2 + y + (maxHeight - height1) / 2));
+ result.put(ent2.getKey(), new Point2D.Double(col2, y + (maxHeight - height2) / 2));
+ y += maxHeight;
+ }
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/PlacementStrategyX1X2.java b/src/net/sourceforge/plantuml/ugraphic/PlacementStrategyX1X2.java
new file mode 100644
index 0000000..fd29ef6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/PlacementStrategyX1X2.java
@@ -0,0 +1,66 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+
+public class PlacementStrategyX1X2 extends AbstractPlacementStrategy {
+
+ public PlacementStrategyX1X2(StringBounder stringBounder) {
+ super(stringBounder);
+ }
+
+ public Map<TextBlock, Point2D> getPositions(double width, double height) {
+ final double usedWidth = getSumWidth();
+ //double maxHeight = getMaxHeight();
+
+ final double space = (width - usedWidth) / (getDimensions().size() + 1);
+ final Map<TextBlock, Point2D> result = new LinkedHashMap<TextBlock, Point2D>();
+ double x = space;
+ for (Map.Entry<TextBlock, Dimension2D> ent : getDimensions().entrySet()) {
+ final double y = (height - ent.getValue().getHeight()) / 2;
+ result.put(ent.getKey(), new Point2D.Double(x, y));
+ x += ent.getValue().getWidth() + space;
+ }
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/PlacementStrategyX1Y2Y3.java b/src/net/sourceforge/plantuml/ugraphic/PlacementStrategyX1Y2Y3.java
new file mode 100644
index 0000000..e36e707
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/PlacementStrategyX1Y2Y3.java
@@ -0,0 +1,88 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+
+public class PlacementStrategyX1Y2Y3 extends AbstractPlacementStrategy {
+
+ public PlacementStrategyX1Y2Y3(StringBounder stringBounder) {
+ super(stringBounder);
+ }
+
+ public Map<TextBlock, Point2D> getPositions(double width, double height) {
+ final Dimension2D first = getDimensions().values().iterator().next();
+
+ final double maxWidthButFirst = getMaxWidth(butFirst());
+ final double sumHeightButFirst = getSumHeight(butFirst());
+
+ final double space = (width - first.getWidth() - maxWidthButFirst) / 3;
+
+ final Map<TextBlock, Point2D> result = new LinkedHashMap<TextBlock, Point2D>();
+ // double x = space * 2;
+
+ final Iterator<Map.Entry<TextBlock, Dimension2D>> it = getDimensions().entrySet().iterator();
+ final Map.Entry<TextBlock, Dimension2D> ent = it.next();
+ double y = (height - ent.getValue().getHeight()) / 2;
+ result.put(ent.getKey(), new Point2D.Double(space, y));
+
+ // x += ent.getValue().getWidth() + space;
+
+ y = (height - sumHeightButFirst) / 2;
+ while (it.hasNext()) {
+ final Map.Entry<TextBlock, Dimension2D> ent2 = it.next();
+ final TextBlock textBlock = ent2.getKey();
+ final Dimension2D dim = getDimensions().get(textBlock);
+ final double x = 2 * space + first.getWidth() + (maxWidthButFirst - dim.getWidth()) / 2;
+ result.put(textBlock, new Point2D.Double(x, y));
+ y += ent2.getValue().getHeight();
+ }
+ return result;
+ }
+
+ private Iterator<Dimension2D> butFirst() {
+ final Iterator<Dimension2D> iterator = getDimensions().values().iterator();
+ iterator.next();
+ return iterator;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/PlacementStrategyY1Y2.java b/src/net/sourceforge/plantuml/ugraphic/PlacementStrategyY1Y2.java
new file mode 100644
index 0000000..de64e95
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/PlacementStrategyY1Y2.java
@@ -0,0 +1,66 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+
+public class PlacementStrategyY1Y2 extends AbstractPlacementStrategy {
+
+ public PlacementStrategyY1Y2(StringBounder stringBounder) {
+ super(stringBounder);
+ }
+
+ public Map<TextBlock, Point2D> getPositions(double width, double height) {
+ final double usedHeight = getSumHeight();
+ //double maxWidth = getMaxWidth();
+
+ final double space = (height - usedHeight) / (getDimensions().size() + 1);
+ final Map<TextBlock, Point2D> result = new LinkedHashMap<TextBlock, Point2D>();
+ double y = space;
+ for (Map.Entry<TextBlock, Dimension2D> ent : getDimensions().entrySet()) {
+ final double x = (width - ent.getValue().getWidth()) / 2;
+ result.put(ent.getKey(), new Point2D.Double(x, y));
+ y += ent.getValue().getHeight() + space;
+ }
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/PlacementStrategyY1Y2Center.java b/src/net/sourceforge/plantuml/ugraphic/PlacementStrategyY1Y2Center.java
new file mode 100644
index 0000000..1e47e2d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/PlacementStrategyY1Y2Center.java
@@ -0,0 +1,66 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+
+public class PlacementStrategyY1Y2Center extends AbstractPlacementStrategy {
+
+ public PlacementStrategyY1Y2Center(StringBounder stringBounder) {
+ super(stringBounder);
+ }
+
+ public Map<TextBlock, Point2D> getPositions(double width, double height) {
+ final double usedHeight = getSumHeight();
+ // double maxWidth = getMaxWidth();
+
+ final double space = (height - usedHeight) / (getDimensions().size() + 1);
+ final Map<TextBlock, Point2D> result = new LinkedHashMap<TextBlock, Point2D>();
+ double y = space;
+ for (Map.Entry<TextBlock, Dimension2D> ent : getDimensions().entrySet()) {
+ final double x = (width - ent.getValue().getWidth()) / 2;
+ result.put(ent.getKey(), new Point2D.Double(x, y));
+ y += ent.getValue().getHeight() + space;
+ }
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/PlacementStrategyY1Y2Left.java b/src/net/sourceforge/plantuml/ugraphic/PlacementStrategyY1Y2Left.java
new file mode 100644
index 0000000..c80acc5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/PlacementStrategyY1Y2Left.java
@@ -0,0 +1,66 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+
+public class PlacementStrategyY1Y2Left extends AbstractPlacementStrategy {
+
+ public PlacementStrategyY1Y2Left(StringBounder stringBounder) {
+ super(stringBounder);
+ }
+
+ public Map<TextBlock, Point2D> getPositions(double width, double height) {
+ final double usedHeight = getSumHeight();
+ //double maxWidth = getMaxWidth();
+
+ final double space = (height - usedHeight) / (getDimensions().size() + 1);
+ final Map<TextBlock, Point2D> result = new LinkedHashMap<TextBlock, Point2D>();
+ double y = space;
+ for (Map.Entry<TextBlock, Dimension2D> ent : getDimensions().entrySet()) {
+ final double x = 0;
+ result.put(ent.getKey(), new Point2D.Double(x, y));
+ y += ent.getValue().getHeight() + space;
+ }
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/Scalable.java b/src/net/sourceforge/plantuml/ugraphic/Scalable.java
new file mode 100644
index 0000000..4aef956
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/Scalable.java
@@ -0,0 +1,40 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+public interface Scalable {
+
+ public UShape getScaled(double scale);
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/ShadowManager.java b/src/net/sourceforge/plantuml/ugraphic/ShadowManager.java
new file mode 100644
index 0000000..b7b9bb4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/ShadowManager.java
@@ -0,0 +1,78 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.awt.Color;
+
+public class ShadowManager {
+
+ // http://www.w3schools.com/svg/svg_feoffset.asp
+
+ private final int c1;
+ private final int c2;
+
+ public ShadowManager(int c1, int c2) {
+ this.c1 = c1;
+ this.c2 = c2;
+ }
+
+ public double[] getShadowDeltaPoints(double deltaShadow, double diff, double[] points) {
+ double cx = 0;
+ double cy = 0;
+ for (int i = 0; i < points.length; i += 2) {
+ cx += points[i];
+ cy += points[i + 1];
+ }
+ final int nbPoints = points.length / 2;
+
+ cx = cx / nbPoints;
+ cy = cy / nbPoints;
+
+ final double[] result = new double[points.length];
+ for (int i = 0; i < result.length; i += 2) {
+ final double diffx = points[i] > cx ? -diff : diff;
+ final double diffy = points[i + 1] > cy ? -diff : diff;
+ result[i] = points[i] + diffx + deltaShadow;
+ result[i + 1] = points[i + 1] + diffy + deltaShadow;
+ }
+ return result;
+ }
+
+ public Color getColor(double delta, double total) {
+ final int c = (int) (c2 + 1.0 * delta / total * (c1 - c2));
+ return new Color(c, c, c);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/Shadowable.java b/src/net/sourceforge/plantuml/ugraphic/Shadowable.java
new file mode 100644
index 0000000..a6ca149
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/Shadowable.java
@@ -0,0 +1,43 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+public interface Shadowable extends UShape {
+
+ public void setDeltaShadow(double deltaShadow);
+
+ public double getDeltaShadow();
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/Slot.java b/src/net/sourceforge/plantuml/ugraphic/Slot.java
new file mode 100644
index 0000000..6bdff47
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/Slot.java
@@ -0,0 +1,99 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+public class Slot implements Comparable<Slot> {
+
+ private final double start;
+ private final double end;
+
+ public Slot(double start, double end) {
+ if (start >= end) {
+ throw new IllegalArgumentException();
+ }
+ this.start = start;
+ this.end = end;
+ }
+
+ @Override
+ public String toString() {
+ return "(" + start + "," + end + ")";
+ }
+
+ public double getStart() {
+ return start;
+ }
+
+ public double getEnd() {
+ return end;
+ }
+
+ public double size() {
+ return end - start;
+ }
+
+ public boolean contains(double v) {
+ return v >= start && v <= end;
+ }
+
+ public boolean intersect(Slot other) {
+ return contains(other.start) || contains(other.end) || other.contains(start) || other.contains(end);
+ }
+
+ public Slot merge(Slot other) {
+ return new Slot(Math.min(start, other.start), Math.max(end, other.end));
+ }
+
+ public Slot intersect(double otherStart, double otherEnd) {
+ if (otherStart >= end) {
+ return null;
+ }
+ if (otherEnd <= start) {
+ return null;
+ }
+ return new Slot(Math.max(start, otherStart), Math.min(end, otherEnd));
+ }
+
+ public int compareTo(Slot other) {
+ if (this.start < other.start) {
+ return -1;
+ }
+ if (this.start > other.start) {
+ return 1;
+ }
+ return 0;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/SlotFinder.java b/src/net/sourceforge/plantuml/ugraphic/SlotFinder.java
new file mode 100644
index 0000000..8474246
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/SlotFinder.java
@@ -0,0 +1,140 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.graphic.StringBounder;
+
+public class SlotFinder implements UGraphic {
+
+ public boolean isSpecialTxt() {
+ return false;
+ }
+
+ public UGraphic apply(UChange change) {
+ if (change instanceof UTranslate) {
+ return new SlotFinder(stringBounder, yslot, translate.compose((UTranslate) change));
+ } else if (change instanceof UStroke) {
+ return new SlotFinder(this);
+ } else if (change instanceof UChangeBackColor) {
+ return new SlotFinder(this);
+ } else if (change instanceof UChangeColor) {
+ return new SlotFinder(this);
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ private final SlotSet yslot;
+ private final StringBounder stringBounder;
+ private final UTranslate translate;
+
+ public SlotFinder(StringBounder stringBounder) {
+ this(stringBounder, new SlotSet(), new UTranslate());
+ }
+
+ private SlotFinder(StringBounder stringBounder, SlotSet yslot, UTranslate translate) {
+ this.stringBounder = stringBounder;
+ this.yslot = yslot;
+ this.translate = translate;
+ }
+
+ private SlotFinder(SlotFinder other) {
+ this(other.stringBounder, other.yslot, other.translate);
+ }
+
+ public StringBounder getStringBounder() {
+ return stringBounder;
+ }
+
+ public UParam getParam() {
+ return new UParamNull();
+ }
+
+ public void draw(UShape shape) {
+ final double x = translate.getDx();
+ final double y = translate.getDy();
+ if (shape instanceof URectangle) {
+ drawRectangle(x, y, (URectangle) shape);
+ } else if (shape instanceof UPolygon) {
+ drawPolygon(x, y, (UPolygon) shape);
+ } else if (shape instanceof UEllipse) {
+ drawEllipse(x, y, (UEllipse) shape);
+ } else if (shape instanceof UText) {
+ drawText(x, y, (UText) shape);
+ } else if (shape instanceof UEmpty) {
+ drawEmpty(x, y, (UEmpty) shape);
+ }
+ }
+
+ private void drawEmpty(double x, double y, UEmpty shape) {
+ yslot.addSlot(y, y + shape.getHeight());
+ }
+
+ private void drawText(double x, double y, UText shape) {
+ final TextLimitFinder finder = new TextLimitFinder(stringBounder, false);
+ finder.apply(new UTranslate(x, y)).draw(shape);
+ yslot.addSlot(finder.getMinY(), finder.getMaxY());
+ }
+
+ private void drawEllipse(double x, double y, UEllipse shape) {
+ yslot.addSlot(y, y + shape.getHeight());
+ }
+
+ private void drawPolygon(double x, double y, UPolygon shape) {
+ yslot.addSlot(y + shape.getMinY(), y + shape.getMaxY());
+ }
+
+ private void drawRectangle(double x, double y, URectangle shape) {
+ yslot.addSlot(y, y + shape.getHeight());
+ }
+
+ public ColorMapper getColorMapper() {
+ return new ColorMapperIdentity();
+ }
+
+ public void startUrl(Url url) {
+ }
+
+ public void closeAction() {
+ }
+
+ public SlotSet getYSlotSet() {
+ return yslot;
+ }
+
+ public void flushUg() {
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/SlotFinderX.java b/src/net/sourceforge/plantuml/ugraphic/SlotFinderX.java
new file mode 100644
index 0000000..4b8889f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/SlotFinderX.java
@@ -0,0 +1,151 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.graphic.StringBounder;
+
+public class SlotFinderX implements UGraphic {
+
+ public boolean isSpecialTxt() {
+ return false;
+ }
+
+ public UGraphic apply(UChange change) {
+ if (change instanceof UTranslate) {
+ return new SlotFinderX(stringBounder, xslot, yslot, translate.compose((UTranslate) change));
+ } else if (change instanceof UStroke) {
+ return new SlotFinderX(this);
+ } else if (change instanceof UChangeBackColor) {
+ return new SlotFinderX(this);
+ } else if (change instanceof UChangeColor) {
+ return new SlotFinderX(this);
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ private final SlotSet xslot;
+ private final SlotSet yslot;
+ private final StringBounder stringBounder;
+ private final UTranslate translate;
+
+ public SlotFinderX(StringBounder stringBounder) {
+ this(stringBounder, new SlotSet(), new SlotSet(), new UTranslate());
+ }
+
+ private SlotFinderX(StringBounder stringBounder, SlotSet xslot, SlotSet yslot, UTranslate translate) {
+ this.stringBounder = stringBounder;
+ this.xslot = xslot;
+ this.yslot = yslot;
+ this.translate = translate;
+ }
+
+ private SlotFinderX(SlotFinderX other) {
+ this(other.stringBounder, other.xslot, other.yslot, other.translate);
+ }
+
+ public StringBounder getStringBounder() {
+ return stringBounder;
+ }
+
+ public UParam getParam() {
+ return new UParamNull();
+ }
+
+ public void draw(UShape shape) {
+ final double x = translate.getDx();
+ final double y = translate.getDy();
+ if (shape instanceof URectangle) {
+ drawRectangle(x, y, (URectangle) shape);
+ } else if (shape instanceof UPolygon) {
+ drawPolygon(x, y, (UPolygon) shape);
+ } else if (shape instanceof UEllipse) {
+ drawEllipse(x, y, (UEllipse) shape);
+ } else if (shape instanceof UText) {
+ drawText(x, y, (UText) shape);
+ } else if (shape instanceof UEmpty) {
+ drawEmpty(x, y, (UEmpty) shape);
+ }
+ }
+
+ private void drawEmpty(double x, double y, UEmpty shape) {
+ xslot.addSlot(x, x + shape.getWidth());
+ yslot.addSlot(y, y + shape.getHeight());
+ }
+
+ private void drawText(double x, double y, UText shape) {
+ final TextLimitFinder finder = new TextLimitFinder(stringBounder, false);
+ finder.apply(new UTranslate(x, y)).draw(shape);
+ xslot.addSlot(finder.getMinX(), finder.getMaxX());
+ yslot.addSlot(finder.getMinY(), finder.getMaxY());
+ }
+
+ private void drawEllipse(double x, double y, UEllipse shape) {
+ xslot.addSlot(x, x + shape.getWidth());
+ yslot.addSlot(y, y + shape.getHeight());
+ }
+
+ private void drawPolygon(double x, double y, UPolygon shape) {
+ xslot.addSlot(x + shape.getMinX(), x + shape.getMaxX());
+ yslot.addSlot(y + shape.getMinY(), y + shape.getMaxY());
+ }
+
+ private void drawRectangle(double x, double y, URectangle shape) {
+ xslot.addSlot(x, x + shape.getWidth());
+ yslot.addSlot(y, y + shape.getHeight());
+ }
+
+ public ColorMapper getColorMapper() {
+ return new ColorMapperIdentity();
+ }
+
+ public void startUrl(Url url) {
+ }
+
+ public void closeAction() {
+ }
+
+ public SlotSet getXSlotSet() {
+ return xslot;
+ }
+
+ public SlotSet getYSlotSet() {
+ return yslot;
+ }
+
+ public void flushUg() {
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/SlotSet.java b/src/net/sourceforge/plantuml/ugraphic/SlotSet.java
new file mode 100644
index 0000000..bf31fd9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/SlotSet.java
@@ -0,0 +1,121 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+public class SlotSet implements Iterable<Slot> {
+
+ private final List<Slot> all = new ArrayList<Slot>();
+
+ public SlotSet filter(double start, double end) {
+ final SlotSet result = new SlotSet();
+ for (Slot slot : all) {
+ final Slot intersec = slot.intersect(start, end);
+ if (intersec != null) {
+ result.all.add(intersec);
+ }
+ }
+ return result;
+ }
+
+ public void addAll(SlotSet other) {
+ this.all.addAll(other.all);
+ }
+
+ public void addSlot(double start, double end) {
+ final List<Slot> collisions = new ArrayList<Slot>();
+ Slot newSlot = new Slot(start, end);
+ for (final Iterator<Slot> it = all.iterator(); it.hasNext();) {
+ final Slot s = it.next();
+ if (s.intersect(newSlot)) {
+ it.remove();
+ collisions.add(s);
+ }
+ }
+ for (Slot s : collisions) {
+ newSlot = newSlot.merge(s);
+ }
+ all.add(newSlot);
+ }
+
+ public SlotSet smaller(double margin) {
+ final SlotSet result = new SlotSet();
+ for (Slot sl : all) {
+ if (sl.size() <= 2 * margin) {
+ continue;
+ }
+ result.addSlot(sl.getStart() + margin, sl.getEnd() - margin);
+ }
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return all.toString();
+ }
+
+ public List<Slot> getSlots() {
+ return Collections.unmodifiableList(all);
+ }
+
+ public Iterator<Slot> iterator() {
+ return getSlots().iterator();
+ }
+
+ public SlotSet reverse() {
+ final SlotSet result = new SlotSet();
+ Collections.sort(all);
+ Slot last = null;
+ for (Slot slot : all) {
+ if (last != null) {
+ result.addSlot(last.getEnd(), slot.getStart());
+ }
+ last = slot;
+ }
+ return result;
+ }
+
+ public void drawDebugX(UGraphic ug, double size) {
+ for (Slot slot : all) {
+ final URectangle rect = new URectangle(slot.getEnd() - slot.getStart(), size);
+ ug.apply(new UTranslate(slot.getStart(), 0)).draw(rect);
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/Sprite.java b/src/net/sourceforge/plantuml/ugraphic/Sprite.java
new file mode 100644
index 0000000..3e657db
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/Sprite.java
@@ -0,0 +1,44 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.TextBlock;
+
+public interface Sprite {
+
+ public TextBlock asTextBlock(final HtmlColor color);
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/SpriteGrayLevel.java b/src/net/sourceforge/plantuml/ugraphic/SpriteGrayLevel.java
new file mode 100644
index 0000000..d69f478
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/SpriteGrayLevel.java
@@ -0,0 +1,281 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.awt.Color;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.code.AsciiEncoder;
+import net.sourceforge.plantuml.code.CompressionZlib;
+
+public enum SpriteGrayLevel {
+
+ GRAY_16(16), GRAY_8(8), GRAY_4(4);
+
+ private final int nbColor;
+ private static final ColorChangerMonochrome mono = new ColorChangerMonochrome();
+
+ private SpriteGrayLevel(int nbColor) {
+ this.nbColor = nbColor;
+ }
+
+ public static SpriteGrayLevel get(int n) {
+ if (n == 4) {
+ return SpriteGrayLevel.GRAY_4;
+ }
+ if (n == 8) {
+ return SpriteGrayLevel.GRAY_8;
+ }
+ if (n == 16) {
+ return SpriteGrayLevel.GRAY_16;
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ public int getNbColor() {
+ return nbColor;
+ }
+
+ public List<String> encode(BufferedImage img) {
+ if (this == GRAY_16) {
+ return encode16(img);
+ }
+ if (this == GRAY_8) {
+ return encode8(img);
+ }
+ if (this == GRAY_4) {
+ return encode4(img);
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ private List<String> encode16(BufferedImage img) {
+ final int width = img.getWidth();
+ final int height = img.getHeight();
+ // final int type = img.getType();
+
+ final List<String> result = new ArrayList<String>();
+
+ for (int y = 0; y < height; y++) {
+ final StringBuilder sb = new StringBuilder();
+ for (int x = 0; x < width; x++) {
+ final int level = getGrayOn16(img, x, y);
+ final char code = "0123456789ABCDEF".charAt(level);
+ sb.append(code);
+ }
+ result.add(sb.toString());
+ }
+ return Collections.unmodifiableList(result);
+ }
+
+ private List<String> encode8(BufferedImage img) {
+ final int width = img.getWidth();
+ final int height = img.getHeight();
+ // final int type = img.getType();
+
+ final List<String> result = new ArrayList<String>();
+ final AsciiEncoder encoder = new AsciiEncoder();
+
+ for (int y = 0; y < height; y += 2) {
+ final StringBuilder sb = new StringBuilder();
+ for (int x = 0; x < width; x++) {
+ final int level1 = getGrayOn16(img, x, y) / 2;
+ assert level1 >= 0 && level1 <= 7;
+ final int level2 = getGrayOn16(img, x, y + 1) / 2;
+ assert level2 >= 0 && level2 <= 7;
+ final int v = level1 * 8 + level2;
+ sb.append(encoder.encode6bit((byte) v));
+ }
+ result.add(sb.toString());
+ }
+ return Collections.unmodifiableList(result);
+ }
+
+ private List<String> encode4(BufferedImage img) {
+ final int width = img.getWidth();
+ final int height = img.getHeight();
+ // final int type = img.getType();
+
+ final List<String> result = new ArrayList<String>();
+ final AsciiEncoder encoder = new AsciiEncoder();
+
+ for (int y = 0; y < height; y += 3) {
+ final StringBuilder sb = new StringBuilder();
+ for (int x = 0; x < width; x++) {
+ final int level1 = getGrayOn16(img, x, y) / 4;
+ assert level1 >= 0 && level1 <= 3;
+ final int level2 = getGrayOn16(img, x, y + 1) / 4;
+ assert level2 >= 0 && level2 <= 3;
+ final int level3 = getGrayOn16(img, x, y + 2) / 4;
+ assert level3 >= 0 && level3 <= 3;
+ final int v = level1 * 16 + level2 * 4 + level3;
+ sb.append(encoder.encode6bit((byte) v));
+ }
+ result.add(sb.toString());
+ }
+ return Collections.unmodifiableList(result);
+ }
+
+ private int getGrayOn16(BufferedImage img, int x, int y) {
+ if (x >= img.getWidth()) {
+ return 0;
+ }
+ if (y >= img.getHeight()) {
+ return 0;
+ }
+ final Color g = mono.getChangedColor(new Color(img.getRGB(x, y)));
+ final int grey = 255 - g.getRed();
+ return grey / 16;
+ }
+
+ public Sprite buildSprite(int width, int height, List<String> strings) {
+ if (this == SpriteGrayLevel.GRAY_16) {
+ return buildSprite16(strings);
+ }
+ if (this == SpriteGrayLevel.GRAY_8) {
+ return buildSprite8(width, height, strings);
+ }
+ if (this == SpriteGrayLevel.GRAY_4) {
+ return buildSprite4(width, height, strings);
+ }
+ throw new UnsupportedOperationException(toString());
+ }
+
+ private Sprite buildSprite16(List<String> strings) {
+ final SpriteMonochrome result = new SpriteMonochrome(strings.get(0).length(), strings.size(), 16);
+ for (int col = 0; col < result.getWidth(); col++) {
+ for (int line = 0; line < result.getHeight(); line++) {
+ if (col >= strings.get(line).length()) {
+ continue;
+ }
+ if (strings.get(line).charAt(col) != '0') {
+ final String s = "" + strings.get(line).charAt(col);
+ final int x = Integer.parseInt(StringUtils.goUpperCase(s), 16);
+ result.setPixel(col, line, x);
+ }
+ }
+ }
+ return result;
+ }
+
+ private Sprite buildSprite8(int width, int height, List<String> strings) {
+ final AsciiEncoder encoder = new AsciiEncoder();
+ final SpriteMonochrome result = new SpriteMonochrome(width, height, 8);
+ for (int col = 0; col < result.getWidth(); col++) {
+ for (int line = 0; line < strings.size(); line++) {
+ if (col >= strings.get(line).length()) {
+ continue;
+ }
+ final int v = encoder.decode6bit(strings.get(line).charAt(col));
+ final int w1 = v / 8;
+ final int w2 = v % 8;
+ result.setPixel(col, line * 2, w1);
+ result.setPixel(col, line * 2 + 1, w2);
+
+ }
+ }
+ return result;
+ }
+
+ private Sprite buildSprite4(int width, int height, List<String> strings) {
+ final AsciiEncoder encoder = new AsciiEncoder();
+ final SpriteMonochrome result = new SpriteMonochrome(width, height, 4);
+ for (int col = 0; col < result.getWidth(); col++) {
+ for (int line = 0; line < strings.size(); line++) {
+ if (col >= strings.get(line).length()) {
+ continue;
+ }
+ int v = encoder.decode6bit(strings.get(line).charAt(col));
+ final int w1 = v / 16;
+ v = v % 16;
+ final int w2 = v / 4;
+ final int w3 = v % 4;
+ result.setPixel(col, line * 3, w1);
+ result.setPixel(col, line * 3 + 1, w2);
+ result.setPixel(col, line * 3 + 2, w3);
+
+ }
+ }
+ return result;
+ }
+
+ public List<String> encodeZ(BufferedImage img) {
+ final int width = img.getWidth();
+ final int height = img.getHeight();
+ final byte raw[] = new byte[width * height];
+ final BufferedImage grayImg = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
+ int cpt = 0;
+ final int coef = 16 / nbColor;
+ for (int y = 0; y < height; y++) {
+ for (int x = 0; x < width; x++) {
+ final int color = getGrayOn16(img, x, y) / coef;
+ raw[cpt++] = (byte) color;
+ grayImg.setRGB(x, y, color * coef);
+ }
+ }
+ final byte[] comp = new CompressionZlib().compress(raw);
+ return cut(new AsciiEncoder().encode(comp));
+ }
+
+ private List<String> cut(String s) {
+ final List<String> result = new ArrayList<String>();
+ for (int i = 0; i < s.length(); i += 120) {
+ final int j = Math.min(i + 120, s.length());
+ result.add(s.substring(i, j));
+
+ }
+ return Collections.unmodifiableList(result);
+ }
+
+ public Sprite buildSpriteZ(int width, int height, String compressed) throws IOException {
+ final byte comp[] = new AsciiEncoder().decode(compressed);
+ final byte img[] = new CompressionZlib().decompress(comp);
+ final SpriteMonochrome result = new SpriteMonochrome(width, height, nbColor);
+ int cpt = 0;
+ for (int line = 0; line < result.getHeight(); line++) {
+ for (int col = 0; col < result.getWidth(); col++) {
+ result.setPixel(col, line, img[cpt++]);
+
+ }
+ }
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/SpriteImage.java b/src/net/sourceforge/plantuml/ugraphic/SpriteImage.java
new file mode 100644
index 0000000..1380e5d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/SpriteImage.java
@@ -0,0 +1,66 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.awt.geom.Dimension2D;
+import java.awt.image.BufferedImage;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+
+public class SpriteImage implements Sprite {
+
+ private final UImage img;
+
+ public SpriteImage(BufferedImage img) {
+ this.img = new UImage(img);
+ }
+
+ public TextBlock asTextBlock(final HtmlColor color) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ ug.draw(img);
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(img.getWidth(), img.getHeight());
+ }
+ };
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/SpriteMonochrome.java b/src/net/sourceforge/plantuml/ugraphic/SpriteMonochrome.java
new file mode 100644
index 0000000..4015d1e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/SpriteMonochrome.java
@@ -0,0 +1,119 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.awt.Color;
+import java.awt.geom.Dimension2D;
+import java.awt.image.BufferedImage;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorGradient;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+
+public class SpriteMonochrome implements Sprite {
+
+ private final int width;
+ private final int height;
+ private final int grayLevel;
+ private final int pixels[][];
+
+ SpriteMonochrome(int width, int height, int grayLevel) {
+ if (grayLevel != 2 && grayLevel != 4 && grayLevel != 8 && grayLevel != 16) {
+ throw new IllegalArgumentException();
+ }
+ this.width = width;
+ this.height = height;
+ this.grayLevel = grayLevel;
+ this.pixels = new int[height][width];
+ }
+
+ void setPixel(int x, int y, int level) {
+ if (x < 0 || x >= width) {
+ return;
+ }
+ if (y < 0 || y >= height) {
+ return;
+ }
+ if (level < 0 || level >= grayLevel) {
+ throw new IllegalArgumentException("level=" + level + " grayLevel=" + grayLevel);
+ }
+ pixels[y][x] = level;
+ }
+
+ public int getHeight() {
+ return height;
+ }
+
+ int getWidth() {
+ return width;
+ }
+
+ public UImage toUImage(ColorMapper colorMapper, HtmlColor backcolor, HtmlColor color) {
+ final BufferedImage im = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
+
+ if (backcolor == null) {
+ backcolor = HtmlColorUtils.WHITE;
+ }
+ if (color == null) {
+ backcolor = HtmlColorUtils.BLACK;
+ }
+ final HtmlColorGradient gradient = new HtmlColorGradient(backcolor, color, '\0');
+ for (int col = 0; col < width; col++) {
+ for (int line = 0; line < height; line++) {
+ final double coef = 1.0 * pixels[line][col] / (grayLevel - 1);
+ final Color c = gradient.getColor(colorMapper, coef);
+ im.setRGB(col, line, c.getRGB());
+ }
+ }
+ return new UImage(im);
+ }
+
+ public TextBlock asTextBlock(final HtmlColor color) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ ug.draw(toUImage(ug.getColorMapper(), ug.getParam().getBackcolor(), color));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(getWidth(), getHeight());
+ }
+ };
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/SpriteUtils.java b/src/net/sourceforge/plantuml/ugraphic/SpriteUtils.java
new file mode 100644
index 0000000..5871057
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/SpriteUtils.java
@@ -0,0 +1,76 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.awt.image.BufferedImage;
+import java.util.List;
+
+public class SpriteUtils {
+
+ private SpriteUtils() {
+ }
+
+ public static String encode(BufferedImage img, String name, SpriteGrayLevel level) {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("sprite $" + name + " [" + img.getWidth() + "x" + img.getHeight() + "/" + level.getNbColor()
+ + "] {\n");
+ final List<String> result = level.encode(img);
+ for (String s : result) {
+ sb.append(s);
+ sb.append("\n");
+ }
+ sb.append("}\n");
+ return sb.toString();
+ }
+
+ public static String encodeCompressed(BufferedImage img, String name, SpriteGrayLevel level) {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("sprite $" + name + " [" + img.getWidth() + "x" + img.getHeight() + "/" + level.getNbColor() + "z] ");
+ final List<String> list = level.encodeZ(img);
+ if (list.size() == 1) {
+ sb.append(list.get(0));
+ sb.append("\n");
+ } else {
+ sb.append("{\n");
+ for (String s : list) {
+ sb.append(s);
+ sb.append("\n");
+ }
+ sb.append("}\n");
+ }
+ return sb.toString();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/TextBlockInEllipse.java b/src/net/sourceforge/plantuml/ugraphic/TextBlockInEllipse.java
new file mode 100644
index 0000000..af93e63
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/TextBlockInEllipse.java
@@ -0,0 +1,87 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.svek.image.ContainingEllipse;
+import net.sourceforge.plantuml.svek.image.Footprint;
+
+public class TextBlockInEllipse implements TextBlock {
+
+ private final TextBlock text;
+ private final ContainingEllipse ellipse;
+
+ public TextBlockInEllipse(TextBlock text, StringBounder stringBounder) {
+ this.text = text;
+ final Dimension2D textDim = text.calculateDimension(stringBounder);
+ double alpha = textDim.getHeight() / textDim.getWidth();
+ if (alpha < .2) {
+ alpha = .2;
+ } else if (alpha > .8) {
+ alpha = .8;
+ }
+ final Footprint footprint = new Footprint(stringBounder);
+ ellipse = footprint.getEllipse(text, alpha);
+
+ }
+
+ public UEllipse getUEllipse() {
+ return ellipse.asUEllipse().bigger(6);
+ }
+
+ public void drawU(UGraphic ug) {
+ final UEllipse sh = getUEllipse();
+ final Point2D center = ellipse.getCenter();
+
+ final double dx = sh.getWidth() / 2 - center.getX();
+ final double dy = sh.getHeight() / 2 - center.getY();
+
+ ug.draw(sh);
+
+ text.drawU(ug.apply(new UTranslate(dx, (dy - 2))));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return getUEllipse().getDimension();
+ }
+
+ public void setDeltaShadow(double deltaShadow) {
+ ellipse.setDeltaShadow(deltaShadow);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/TextLimitFinder.java b/src/net/sourceforge/plantuml/ugraphic/TextLimitFinder.java
new file mode 100644
index 0000000..4e3a04f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/TextLimitFinder.java
@@ -0,0 +1,135 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.awt.geom.Dimension2D;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.graphic.StringBounder;
+
+public class TextLimitFinder implements UGraphic {
+
+ public boolean isSpecialTxt() {
+ return false;
+ }
+
+ public UGraphic apply(UChange change) {
+ if (change instanceof UTranslate) {
+ return new TextLimitFinder(stringBounder, minmax, translate.compose((UTranslate) change));
+ } else if (change instanceof UStroke) {
+ return new TextLimitFinder(this);
+ } else if (change instanceof UChangeBackColor) {
+ return new TextLimitFinder(this);
+ } else if (change instanceof UChangeColor) {
+ return new TextLimitFinder(this);
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ private final StringBounder stringBounder;
+ private final UTranslate translate;
+ private final MinMaxMutable minmax;
+
+ public TextLimitFinder(StringBounder stringBounder, boolean initToZero) {
+ this(stringBounder, MinMaxMutable.getEmpty(initToZero), new UTranslate());
+ }
+
+ private TextLimitFinder(StringBounder stringBounder, MinMaxMutable minmax, UTranslate translate) {
+ this.stringBounder = stringBounder;
+ this.minmax = minmax;
+ this.translate = translate;
+ }
+
+ private TextLimitFinder(TextLimitFinder other) {
+ this(other.stringBounder, other.minmax, other.translate);
+ }
+
+ public StringBounder getStringBounder() {
+ return stringBounder;
+ }
+
+ public UParam getParam() {
+ return new UParamNull();
+ }
+
+ public void draw(UShape shape) {
+ if (shape instanceof UText) {
+ final double x = translate.getDx();
+ final double y = translate.getDy();
+ drawText(x, y, (UText) shape);
+ }
+ }
+
+ public ColorMapper getColorMapper() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void startUrl(Url url) {
+ }
+
+ public void closeAction() {
+ }
+
+ private void drawText(double x, double y, UText text) {
+ final Dimension2D dim = stringBounder.calculateDimension(text.getFontConfiguration().getFont(), text.getText());
+ y -= dim.getHeight() - 1.5;
+ minmax.addPoint(x, y);
+ minmax.addPoint(x, y + dim.getHeight());
+ minmax.addPoint(x + dim.getWidth(), y);
+ minmax.addPoint(x + dim.getWidth(), y + dim.getHeight());
+ }
+
+ public double getMaxX() {
+ return minmax.getMaxX();
+ }
+
+ public double getMaxY() {
+ return minmax.getMaxY();
+ }
+
+ public double getMinX() {
+ return minmax.getMinX();
+ }
+
+ public double getMinY() {
+ return minmax.getMinY();
+ }
+
+ public void flushUg() {
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UAntiAliasing.java b/src/net/sourceforge/plantuml/ugraphic/UAntiAliasing.java
new file mode 100644
index 0000000..1b4c01c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UAntiAliasing.java
@@ -0,0 +1,53 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+
+public enum UAntiAliasing implements UChange {
+
+ ANTI_ALIASING_ON, ANTI_ALIASING_OFF;
+
+ public void apply(Graphics2D g2d) {
+ if (this == ANTI_ALIASING_ON) {
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ } else {
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
+ }
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UCenteredCharacter.java b/src/net/sourceforge/plantuml/ugraphic/UCenteredCharacter.java
new file mode 100644
index 0000000..6ed6abf
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UCenteredCharacter.java
@@ -0,0 +1,55 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+public class UCenteredCharacter implements UShape {
+
+ private final char c;
+ private final UFont font;
+
+ public UCenteredCharacter(char c, UFont font) {
+ this.c = c;
+ this.font = font;
+ }
+
+ public char getChar() {
+ return c;
+ }
+
+ public UFont getFont() {
+ return font;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UChange.java b/src/net/sourceforge/plantuml/ugraphic/UChange.java
new file mode 100644
index 0000000..ecc9e5c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UChange.java
@@ -0,0 +1,41 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+
+public interface UChange {
+
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UChangeBackColor.java b/src/net/sourceforge/plantuml/ugraphic/UChangeBackColor.java
new file mode 100644
index 0000000..b47460f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UChangeBackColor.java
@@ -0,0 +1,56 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+
+public class UChangeBackColor implements UChange {
+
+ private final HtmlColor color;
+
+ public UChangeBackColor(HtmlColor color) {
+ this.color = color;
+ }
+
+ public HtmlColor getBackColor() {
+ return color;
+ }
+
+ // private HtmlColor color = null;
+ // private HtmlColor backcolor = null;
+ // private UStroke stroke = new UStroke(1);
+ // private boolean hidden = false;
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UChangeColor.java b/src/net/sourceforge/plantuml/ugraphic/UChangeColor.java
new file mode 100644
index 0000000..8b312b8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UChangeColor.java
@@ -0,0 +1,50 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+
+public class UChangeColor implements UChange {
+
+ private final HtmlColor color;
+
+ public UChangeColor(HtmlColor color) {
+ this.color = color;
+ }
+
+ public HtmlColor getColor() {
+ return color;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UClip.java b/src/net/sourceforge/plantuml/ugraphic/UClip.java
new file mode 100644
index 0000000..9b738b4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UClip.java
@@ -0,0 +1,154 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.awt.geom.Line2D;
+import java.awt.geom.Rectangle2D;
+
+public class UClip implements UChange {
+
+ private final double x;
+ private final double y;
+ private final double width;
+ private final double height;
+
+ public UClip(double x, double y, double width, double height) {
+ this.x = x;
+ this.y = y;
+ this.width = width;
+ this.height = height;
+ }
+
+ @Override
+ public String toString() {
+ return "CLIP x=" + x + " y=" + y + " w=" + width + " h=" + height;
+ }
+
+ public UClip translate(double dx, double dy) {
+ return new UClip(x + dx, y + dy, width, height);
+ }
+
+ public UClip translate(UTranslate translate) {
+ return translate(translate.getDx(), translate.getDy());
+ }
+
+
+ public final double getX() {
+ return x;
+ }
+
+ public final double getY() {
+ return y;
+ }
+
+ public final double getWidth() {
+ return width;
+ }
+
+ public final double getHeight() {
+ return height;
+ }
+
+ public boolean isInside(double xp, double yp) {
+ if (xp < x) {
+ assert getClippedX(xp) != xp;
+ return false;
+ }
+ if (xp > x + width) {
+ assert getClippedX(xp) != xp;
+ return false;
+ }
+ if (yp < y) {
+ assert getClippedY(yp) != yp;
+ return false;
+ }
+ if (yp > y + height) {
+ assert getClippedY(yp) != yp;
+ return false;
+ }
+ assert getClippedX(xp) == xp;
+ assert getClippedY(yp) == yp;
+ return true;
+ }
+
+ public Rectangle2D.Double getClippedRectangle(Rectangle2D.Double r) {
+ return (Rectangle2D.Double) r.createIntersection(new Rectangle2D.Double(x, y, width, height));
+ }
+
+ public Line2D.Double getClippedLine(Line2D.Double line) {
+ if (isInside(line.x1, line.y1) && isInside(line.x2, line.y2)) {
+ return line;
+ }
+ if (isInside(line.x1, line.y1) == false && isInside(line.x2, line.y2) == false) {
+ return null;
+ }
+ if (line.x1 != line.x2 && line.y1 != line.y2) {
+ return null;
+ }
+ assert line.x1 == line.x2 || line.y1 == line.y2;
+ if (line.y1 == line.y2) {
+ final double newx1 = getClippedX(line.x1);
+ final double newx2 = getClippedX(line.x2);
+ return new Line2D.Double(newx1, line.y1, newx2, line.y2);
+ }
+ if (line.x1 == line.x2) {
+ final double newy1 = getClippedY(line.y1);
+ final double newy2 = getClippedY(line.y2);
+ return new Line2D.Double(line.x1, newy1, line.x2, newy2);
+ }
+ throw new IllegalStateException();
+ }
+
+ private double getClippedX(double xp) {
+ if (xp < x) {
+ return x;
+ }
+ if (xp > x + width) {
+ return x + width;
+ }
+ return xp;
+ }
+
+ private double getClippedY(double yp) {
+ if (yp < y) {
+ return y;
+ }
+ if (yp > y + height) {
+ return y + height;
+ }
+ return yp;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UDriver.java b/src/net/sourceforge/plantuml/ugraphic/UDriver.java
new file mode 100644
index 0000000..c7bff33
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UDriver.java
@@ -0,0 +1,40 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+public interface UDriver<O> {
+ public void draw(UShape shape, double x, double y, ColorMapper mapper, UParam param, O object);
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UEllipse.java b/src/net/sourceforge/plantuml/ugraphic/UEllipse.java
new file mode 100644
index 0000000..32990e7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UEllipse.java
@@ -0,0 +1,106 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+
+public class UEllipse extends AbstractShadowable implements Scalable {
+
+ private final double width;
+ private final double height;
+ private final double start;
+ private final double extend;
+
+ public UShape getScaled(double scale) {
+ if (scale == 1) {
+ return this;
+ }
+ final AbstractShadowable result = new UEllipse(width * scale, height * scale, start, extend);
+ result.setDeltaShadow(this.getDeltaShadow());
+ return result;
+ }
+
+ public UEllipse(double width, double height) {
+ this(width, height, 0, 0);
+ }
+
+ public UEllipse(double width, double height, double start, double extend) {
+ this.width = width;
+ this.height = height;
+ this.start = start;
+ this.extend = extend;
+ }
+
+ public double getWidth() {
+ return width;
+ }
+
+ public double getHeight() {
+ return height;
+ }
+
+ public final double getStart() {
+ return start;
+ }
+
+ public final double getExtend() {
+ return extend;
+ }
+
+ public Dimension2D getDimension() {
+ return new Dimension2DDouble(width, height);
+ }
+
+ public UEllipse bigger(double more) {
+ final UEllipse result = new UEllipse(width + more, height + more);
+ result.setDeltaShadow(getDeltaShadow());
+ return result;
+ }
+
+ public double getStartingX(double y) {
+ y = y / height * 2;
+ final double x = 1 - Math.sqrt(1 - (y - 1) * (y - 1));
+ return x * width / 2;
+ }
+
+ public double getEndingX(double y) {
+ y = y / height * 2;
+ final double x = 1 + Math.sqrt(1 - (y - 1) * (y - 1));
+ return x * width / 2;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UEmpty.java b/src/net/sourceforge/plantuml/ugraphic/UEmpty.java
new file mode 100644
index 0000000..d5b1fdf
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UEmpty.java
@@ -0,0 +1,58 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+public class UEmpty implements UShape {
+
+ private final double width;
+ private final double height;
+
+ public UEmpty(double width, double height) {
+ if (width == 0) {
+ throw new IllegalArgumentException();
+ }
+ this.width = width;
+ this.height = height;
+ }
+
+ public double getWidth() {
+ return width;
+ }
+
+ public double getHeight() {
+ return height;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UFont.java b/src/net/sourceforge/plantuml/ugraphic/UFont.java
new file mode 100644
index 0000000..d5aec22
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UFont.java
@@ -0,0 +1,154 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics2D;
+import java.awt.font.FontRenderContext;
+import java.awt.font.LineMetrics;
+
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+
+public class UFont {
+
+ private final Font font;
+ private final String family;
+
+ public UFont(String fontFamily, int fontStyle, int fontSize) {
+ this(new Font(fontFamily, fontStyle, fontSize), fontFamily);
+ }
+
+ private UFont(Font font, String family) {
+ this.font = font;
+ this.family = family;
+ }
+
+ public final Font getFont() {
+ return font;
+ }
+
+ public FontConfiguration toFont2(HtmlColor color, boolean useUnderlineForHyperlink, HtmlColor hyperlinkColor) {
+ return new FontConfiguration(this, color, hyperlinkColor, useUnderlineForHyperlink);
+ }
+
+ public UFont scaled(double scale) {
+ if (scale == 1) {
+ return this;
+ }
+ final float current = font.getSize2D();
+ return deriveSize((float) (current * scale));
+ }
+
+ public UFont deriveSize(float size) {
+ return new UFont(font.deriveFont(size), family);
+ }
+
+ public UFont deriveStyle(int style) {
+ return new UFont(font.deriveFont(style), family);
+ }
+
+ public int getStyle() {
+ return font.getStyle();
+ }
+
+ public int getSize() {
+ return font.getSize();
+ }
+
+ public double getSize2D() {
+ return font.getSize2D();
+ }
+
+ public boolean isBold() {
+ return font.isBold();
+ }
+
+ public boolean isItalic() {
+ return font.isItalic();
+ }
+
+ public String getFamily(UFontContext context) {
+ if (context == UFontContext.EPS) {
+ if (family == null) {
+ return "Times-Roman";
+ }
+ return font.getPSName();
+ }
+ if (context == UFontContext.SVG) {
+ if (family.equalsIgnoreCase("sansserif")) {
+ return "sans-serif";
+ }
+ return family;
+ }
+ return family;
+ }
+
+ @Override
+ public String toString() {
+ return font.toString()/* + " " + font.getPSName() */;
+ }
+
+ @Override
+ public int hashCode() {
+ return font.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof UFont == false) {
+ return false;
+ }
+ return this.font.equals(((UFont) obj).font);
+ }
+
+ @Deprecated
+ public static UFont getCurrentFont(Graphics2D g2d) {
+ // return new UFont(g2d.getFont(), g2d.getFont().getFontName());
+ throw new UnsupportedOperationException();
+ }
+
+ public LineMetrics getLineMetrics(Graphics2D gg, String text) {
+ final FontRenderContext frc = gg.getFontRenderContext();
+ return font.getLineMetrics(text, frc);
+ }
+
+ public FontMetrics getFontMetrics() {
+ return TextBlockUtils.getFontMetrics(getFont());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UFontContext.java b/src/net/sourceforge/plantuml/ugraphic/UFontContext.java
new file mode 100644
index 0000000..76f827e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UFontContext.java
@@ -0,0 +1,39 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+public enum UFontContext {
+ JAVA, EPS, SVG, DOT, SYSTEM, PNG
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UFontUser.java b/src/net/sourceforge/plantuml/ugraphic/UFontUser.java
new file mode 100644
index 0000000..6007947
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UFontUser.java
@@ -0,0 +1,39 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+public enum UFontUser {
+ JAVA, DOT
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UGraphic.java b/src/net/sourceforge/plantuml/ugraphic/UGraphic.java
new file mode 100644
index 0000000..a6c8d8b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UGraphic.java
@@ -0,0 +1,59 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.graphic.StringBounder;
+
+public interface UGraphic {
+
+ public StringBounder getStringBounder();
+
+ public UParam getParam();
+
+ public void draw(UShape shape);
+
+ public UGraphic apply(UChange change);
+
+ public ColorMapper getColorMapper();
+
+ public void startUrl(Url url);
+
+ public void closeAction();
+
+ public void flushUg();
+
+ public boolean isSpecialTxt();
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UGraphic2.java b/src/net/sourceforge/plantuml/ugraphic/UGraphic2.java
new file mode 100644
index 0000000..ed92e2a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UGraphic2.java
@@ -0,0 +1,43 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+public interface UGraphic2 extends UGraphic {
+
+ public void writeImageTOBEMOVED(OutputStream os, String metadata, int dpi) throws IOException;
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UGraphicCompress.java b/src/net/sourceforge/plantuml/ugraphic/UGraphicCompress.java
new file mode 100644
index 0000000..b9f9b09
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UGraphicCompress.java
@@ -0,0 +1,89 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import net.sourceforge.plantuml.graphic.UGraphicDelegator;
+
+public class UGraphicCompress extends UGraphicDelegator {
+
+ public UGraphic apply(UChange change) {
+ if (change instanceof UTranslate) {
+ return new UGraphicCompress(getUg(), compressionTransform, translate.compose((UTranslate) change));
+ } else if (change instanceof UStroke || change instanceof UChangeBackColor || change instanceof UChangeColor) {
+ return new UGraphicCompress(getUg().apply(change), compressionTransform, translate);
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ private final CompressionTransform compressionTransform;
+ private final UTranslate translate;
+
+ public UGraphicCompress(UGraphic ug, CompressionTransform compressionTransform) {
+ this(ug, compressionTransform, new UTranslate());
+ }
+
+ private UGraphicCompress(UGraphic ug, CompressionTransform compressionTransform, UTranslate translate) {
+ super(ug);
+ this.compressionTransform = compressionTransform;
+ this.translate = translate;
+ }
+
+ public void draw(UShape shape) {
+ final double x = translate.getDx();
+ final double y = translate.getDy();
+ if (shape instanceof ULine) {
+ drawLine(x, y, (ULine) shape);
+ } else {
+ getUg().apply(new UTranslate(x, ct(y))).draw(shape);
+ }
+ }
+
+ private void drawLine(double x, double y, ULine shape) {
+ drawLine(x, ct(y), x + shape.getDX(), ct(y + shape.getDY()));
+ }
+
+ private double ct(double v) {
+ return compressionTransform.transform(v);
+ }
+
+ private void drawLine(double x1, double y1, double x2, double y2) {
+ final double xmin = Math.min(x1, x2);
+ final double xmax = Math.max(x1, x2);
+ final double ymin = Math.min(y1, y2);
+ final double ymax = Math.max(y1, y2);
+ getUg().apply(new UTranslate(xmin, ymin)).draw(new ULine(xmax - xmin, ymax - ymin));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UGraphicCompress2.java b/src/net/sourceforge/plantuml/ugraphic/UGraphicCompress2.java
new file mode 100644
index 0000000..664f5ae
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UGraphicCompress2.java
@@ -0,0 +1,97 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import net.sourceforge.plantuml.activitydiagram3.ftile.Snake;
+import net.sourceforge.plantuml.graphic.UGraphicDelegator;
+
+public class UGraphicCompress2 extends UGraphicDelegator {
+
+ public UGraphic apply(UChange change) {
+ if (change instanceof UTranslate) {
+ return new UGraphicCompress2(getUg(), compressionTransform, translate.compose((UTranslate) change));
+ } else if (change instanceof UStroke || change instanceof UChangeBackColor || change instanceof UChangeColor) {
+ return new UGraphicCompress2(getUg().apply(change), compressionTransform, translate);
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ private final CompressionTransform compressionTransform;
+ private final UTranslate translate;
+
+ public UGraphicCompress2(UGraphic ug, CompressionTransform compressionTransform) {
+ this(ug, compressionTransform, new UTranslate());
+ }
+
+ private UGraphicCompress2(UGraphic ug, CompressionTransform compressionTransform, UTranslate translate) {
+ super(ug);
+ this.compressionTransform = compressionTransform;
+ this.translate = translate;
+ }
+
+ public void draw(UShape shape) {
+ final double x = translate.getDx();
+ final double y = translate.getDy();
+ if (shape instanceof ULine) {
+ drawLine(x, y, (ULine) shape);
+ } else if (shape instanceof Snake) {
+ drawSnake(x, y, (Snake) shape);
+ } else {
+ getUg().apply(new UTranslate(ct(x), y)).draw(shape);
+ }
+ }
+
+ private void drawSnake(double x, double y, Snake shape) {
+ final Snake transformed = shape.translate(new UTranslate(x, y)).transformX(compressionTransform);
+ getUg().draw(transformed);
+ }
+
+ private void drawLine(double x, double y, ULine shape) {
+ drawLine(ct(x), y, ct(x + shape.getDX()), y + shape.getDY());
+ }
+
+ private double ct(double v) {
+ return compressionTransform.transform(v);
+ }
+
+ private void drawLine(double x1, double y1, double x2, double y2) {
+ final double xmin = Math.min(x1, x2);
+ final double xmax = Math.max(x1, x2);
+ final double ymin = Math.min(y1, y2);
+ final double ymax = Math.max(y1, y2);
+ getUg().apply(new UTranslate(xmin, ymin)).draw(new ULine(xmax - xmin, ymax - ymin));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UGraphicFilter.java b/src/net/sourceforge/plantuml/ugraphic/UGraphicFilter.java
new file mode 100644
index 0000000..f6f7cc2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UGraphicFilter.java
@@ -0,0 +1,61 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import net.sourceforge.plantuml.graphic.UGraphicDelegator;
+
+public class UGraphicFilter extends UGraphicDelegator {
+
+ public UGraphic apply(UChange translate) {
+ throw new UnsupportedOperationException();
+ }
+
+ private final Collection<Class<? extends UShape>> toprint;
+
+ public UGraphicFilter(UGraphic ug, Class<? extends UShape>... toprint) {
+ super(ug);
+ this.toprint = Arrays.asList(toprint);
+ }
+
+ public void draw(UShape shape) {
+ if (toprint.contains(shape.getClass())) {
+ getUg().draw(shape);
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UGraphicNull.java b/src/net/sourceforge/plantuml/ugraphic/UGraphicNull.java
new file mode 100644
index 0000000..f1f665e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UGraphicNull.java
@@ -0,0 +1,76 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import net.sourceforge.plantuml.EnsureVisible;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+
+public class UGraphicNull extends AbstractUGraphic<String> implements EnsureVisible, UGraphic2 {
+
+ @Override
+ protected AbstractCommonUGraphic copyUGraphic() {
+ return new UGraphicNull(this);
+ }
+
+ private UGraphicNull(UGraphicNull other) {
+ super(other);
+ }
+
+ public UGraphicNull() {
+ super(new ColorMapperIdentity(), "foo");
+ }
+
+ public StringBounder getStringBounder() {
+ return TextBlockUtils.getDummyStringBounder();
+ }
+
+ public void startUrl(Url url) {
+ }
+
+ public void closeAction() {
+ }
+
+ public void writeImageTOBEMOVED(OutputStream os, String metadata, int dpi) throws IOException {
+ }
+
+ public void ensureVisible(double x, double y) {
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UGraphicStencil.java b/src/net/sourceforge/plantuml/ugraphic/UGraphicStencil.java
new file mode 100644
index 0000000..a68de23
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UGraphicStencil.java
@@ -0,0 +1,62 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import net.sourceforge.plantuml.creole.Stencil;
+
+public class UGraphicStencil extends AbstractUGraphicHorizontalLine {
+
+ private final Stencil stencil;
+ private final UStroke defaultStroke;
+
+ public UGraphicStencil(UGraphic ug, Stencil stencil, UStroke defaultStroke) {
+ super(ug);
+ this.stencil = stencil;
+ this.defaultStroke = defaultStroke;
+ }
+
+ @Override
+ protected AbstractUGraphicHorizontalLine copy(UGraphic ug) {
+ return new UGraphicStencil(ug, stencil, defaultStroke);
+ }
+
+ @Override
+ protected void drawHline(UGraphic ug, UHorizontalLine line, UTranslate translate) {
+ line.drawLineInternal(ug, stencil, translate.getDy(), defaultStroke);
+ // final UDrawable ud = stencil.convert(line, ug.getStringBounder());
+ // ud.drawU(ug.apply(translate));
+ // line.drawLine(ug.apply(translate), startingX, endingX, 0, defaultStroke);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UGraphicUtils.java b/src/net/sourceforge/plantuml/ugraphic/UGraphicUtils.java
new file mode 100644
index 0000000..6d35f62
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UGraphicUtils.java
@@ -0,0 +1,127 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.awt.Graphics2D;
+import java.awt.geom.Dimension2D;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import net.sourceforge.plantuml.EmptyImageBuilder;
+import net.sourceforge.plantuml.FileFormat;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.eps.EpsStrategy;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.png.PngIO;
+import net.sourceforge.plantuml.ugraphic.eps.UGraphicEps;
+import net.sourceforge.plantuml.ugraphic.g2d.UGraphicG2d;
+import net.sourceforge.plantuml.ugraphic.svg.UGraphicSvg;
+import net.sourceforge.plantuml.StringUtils;
+
+public abstract class UGraphicUtils {
+
+ public static UDrawable translate(final UDrawable d, final double dx, final double dy) {
+ return new UDrawable() {
+ public void drawU(UGraphic ug) {
+ d.drawU(ug.apply(new UTranslate(dx, dy)));
+ }
+ };
+
+ }
+
+ public static void writeImage(OutputStream os, String metadata, FileFormatOption fileFormatOption,
+ ColorMapper colorMapper, HtmlColor background, TextBlock image) throws IOException {
+ final FileFormat fileFormat = fileFormatOption.getFileFormat();
+ if (fileFormat == FileFormat.PNG) {
+ final BufferedImage im = createImage(colorMapper, background, image);
+ PngIO.write(im, os, fileFormatOption.isWithMetadata() ? metadata : null, 96);
+ } else if (fileFormat == FileFormat.SVG) {
+ final UGraphicSvg svg = new UGraphicSvg(colorMapper, StringUtils.getAsHtml(colorMapper
+ .getMappedColor(background)), false, 1.0);
+ image.drawU(svg);
+ svg.createXml(os);
+ } else if (fileFormat == FileFormat.EPS) {
+ final UGraphicEps ug = new UGraphicEps(colorMapper, EpsStrategy.getDefault2());
+ image.drawU(ug);
+ os.write(ug.getEPSCode().getBytes());
+ } else if (fileFormat == FileFormat.EPS_TEXT) {
+ final UGraphicEps ug = new UGraphicEps(colorMapper, EpsStrategy.WITH_MACRO_AND_TEXT);
+ image.drawU(ug);
+ os.write(ug.getEPSCode().getBytes());
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ private static BufferedImage createImage(ColorMapper colorMapper, HtmlColor background, TextBlock image) {
+ EmptyImageBuilder builder = new EmptyImageBuilder(10, 10, colorMapper.getMappedColor(background));
+ Graphics2D g2d = builder.getGraphics2D();
+
+ final UGraphicG2d tmp = new UGraphicG2d(colorMapper, g2d, 1.0);
+ final Dimension2D size = image.calculateDimension(tmp.getStringBounder());
+ g2d.dispose();
+
+ builder = new EmptyImageBuilder(size.getWidth(), size.getHeight(), colorMapper.getMappedColor(background));
+ final BufferedImage im = builder.getBufferedImage();
+ g2d = builder.getGraphics2D();
+
+ final UGraphicG2d ug = new UGraphicG2d(colorMapper, g2d, 1.0);
+ image.drawU(ug);
+ g2d.dispose();
+ return im;
+ }
+
+ // public static void writeImage(OutputStream os, UGraphic ug, String metadata, int dpi) throws IOException {
+ // if (ug instanceof UGraphicG2d) {
+ // final BufferedImage im = ((UGraphicG2d) ug).getBufferedImage();
+ // PngIO.write(im, os, metadata, dpi);
+ // } else if (ug instanceof UGraphicSvg) {
+ // final UGraphicSvg svg = (UGraphicSvg) ug;
+ // svg.createXml(os);
+ // } else if (ug instanceof UGraphicEps) {
+ // final UGraphicEps eps = (UGraphicEps) ug;
+ // os.write(eps.getEPSCode().getBytes());
+ // } else if (ug instanceof UGraphicHtml5) {
+ // final UGraphicHtml5 html5 = (UGraphicHtml5) ug;
+ // os.write(html5.generateHtmlCode().getBytes());
+ // } else {
+ // throw new UnsupportedOperationException();
+ // }
+ // }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UHidden.java b/src/net/sourceforge/plantuml/ugraphic/UHidden.java
new file mode 100644
index 0000000..3ab0698
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UHidden.java
@@ -0,0 +1,41 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+public enum UHidden implements UChange {
+
+ NORMAL_SHOWN, HIDDEN;
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UHorizontalLine.java b/src/net/sourceforge/plantuml/ugraphic/UHorizontalLine.java
new file mode 100644
index 0000000..f82749a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UHorizontalLine.java
@@ -0,0 +1,181 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.creole.Stencil;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+
+public class UHorizontalLine implements UShape {
+
+ private final double skipAtStart;
+ private final double skipAtEnd;
+ private final TextBlock title;
+ private final boolean blankTitle;
+ private final char style;
+
+ private UHorizontalLine(double skipAtStart, double skipAtEnd, TextBlock title, boolean blankTitle, char style) {
+ this.skipAtEnd = skipAtEnd;
+ this.skipAtStart = skipAtStart;
+ this.title = title;
+ this.blankTitle = blankTitle;
+ this.style = style;
+ }
+
+ public static UHorizontalLine infinite(double skipAtStart, double skipAtEnd, char style) {
+ return new UHorizontalLine(skipAtStart, skipAtEnd, null, false, style);
+ }
+
+ public static UHorizontalLine infinite(double skipAtStart, double skipAtEnd, TextBlock title, char style) {
+ return new UHorizontalLine(skipAtStart, skipAtEnd, title, false, style);
+ }
+
+ public boolean isDouble() {
+ return style == '=';
+ }
+
+ // static public UHorizontalLine infinite(UStroke stroke) {
+ // return new UHorizontalLine(0, 0, null, false, stroke);
+ // }
+
+ public void drawLineInternal(final UGraphic ug, Stencil stencil, double y, UStroke defaultStroke) {
+ stencil = addSkip(stencil);
+ final UStroke strokeToUse = style == '\0' ? defaultStroke : getStroke();
+ final UGraphic ugStroke = ug.apply(strokeToUse);
+ if (title == null) {
+ drawHLine(stencil, y, ugStroke);
+ return;
+ }
+ final Dimension2D dimTitle = title.calculateDimension(ug.getStringBounder());
+ drawHLine(firstHalf(stencil, dimTitle.getWidth()), y, ugStroke);
+ final double startingX = stencil.getStartingX(ug.getStringBounder(), y);
+ final double endingX = stencil.getEndingX(ug.getStringBounder(), y);
+ drawTitleInternal(ug, startingX, endingX, y, false);
+ drawHLine(secondHalf(stencil, dimTitle.getWidth()), y, ugStroke);
+ }
+
+ private Stencil addSkip(final Stencil stencil) {
+ return new Stencil() {
+ public double getStartingX(StringBounder stringBounder, double y) {
+ return stencil.getStartingX(stringBounder, y) + skipAtStart;
+ }
+
+ public double getEndingX(StringBounder stringBounder, double y) {
+ return stencil.getEndingX(stringBounder, y) - skipAtEnd;
+ }
+ };
+ }
+
+ private static Stencil firstHalf(final Stencil stencil, final double widthTitle) {
+ return new Stencil() {
+ public double getStartingX(StringBounder stringBounder, double y) {
+ return stencil.getStartingX(stringBounder, y);
+ }
+
+ public double getEndingX(StringBounder stringBounder, double y) {
+ final double start = stencil.getStartingX(stringBounder, y);
+ final double end = stencil.getEndingX(stringBounder, y);
+ final double len = (end - start - widthTitle) / 2;
+ return start + len;
+ }
+ };
+ }
+
+ private static Stencil secondHalf(final Stencil stencil, final double widthTitle) {
+ return new Stencil() {
+ public double getStartingX(StringBounder stringBounder, double y) {
+ final double start = stencil.getStartingX(stringBounder, y);
+ final double end = stencil.getEndingX(stringBounder, y);
+ final double len = (end - start - widthTitle) / 2;
+ return end - len;
+ }
+
+ public double getEndingX(StringBounder stringBounder, double y) {
+ return stencil.getEndingX(stringBounder, y);
+ }
+ };
+ }
+
+ private void drawHLine(Stencil stencil, double y, final UGraphic ug) {
+ drawSimpleHline(ug, stencil, y);
+ if (style == '=') {
+ drawSimpleHline(ug, stencil, y + 2);
+ }
+ }
+
+ private static void drawSimpleHline(UGraphic ug, Stencil stencil, double y) {
+ final double startingX = stencil.getStartingX(ug.getStringBounder(), y);
+ final double endingX = stencil.getEndingX(ug.getStringBounder(), y);
+ ug.apply(new UTranslate(startingX, y)).draw(new ULine(endingX - startingX, 0));
+ }
+
+ public void drawTitleInternal(UGraphic ug, double startingX, double endingX, double y, boolean clearArea) {
+ if (title == null || blankTitle) {
+ return;
+ }
+ final double widthToUse = endingX - startingX;
+ final Dimension2D dimTitle = title.calculateDimension(ug.getStringBounder());
+ final double space = (widthToUse - dimTitle.getWidth()) / 2;
+ final double x1 = startingX + space;
+ final double y1 = y - dimTitle.getHeight() / 2 - 0.5;
+ ug = ug.apply(new UTranslate(x1, y1));
+ if (clearArea) {
+ ug.apply(getStroke()).draw(new URectangle(dimTitle));
+ }
+ title.drawU(ug);
+ }
+
+ public void drawMe(UGraphic ug) {
+ ug.draw(this);
+ }
+
+ public UStroke getStroke() {
+ if (style == '\0') {
+ throw new IllegalStateException();
+ // return null;
+ } else if (style == '=') {
+ return new UStroke();
+ } else if (style == '.') {
+ return new UStroke(1, 2, 1);
+ } else if (style == '-') {
+ return new UStroke();
+ } else {
+ return new UStroke(1.5);
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UImage.java b/src/net/sourceforge/plantuml/ugraphic/UImage.java
new file mode 100644
index 0000000..20be1e9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UImage.java
@@ -0,0 +1,59 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.awt.image.BufferedImage;
+
+public class UImage implements UShape {
+
+ private final BufferedImage image;
+
+ public UImage(BufferedImage image) {
+ this.image = image;
+ }
+
+ public final BufferedImage getImage() {
+ return image;
+ }
+
+ public double getWidth() {
+ return image.getWidth();
+ }
+
+ public double getHeight() {
+ return image.getHeight();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UImageSvg.java b/src/net/sourceforge/plantuml/ugraphic/UImageSvg.java
new file mode 100644
index 0000000..d431a2f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UImageSvg.java
@@ -0,0 +1,78 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class UImageSvg implements UShape {
+
+ private final String svg;
+
+ public UImageSvg(String svg) {
+ if (svg.startsWith("<?xml")) {
+ final int idx = svg.indexOf("<svg");
+ svg = svg.substring(idx);
+ }
+ this.svg = svg;
+ }
+
+ public final String getSvg() {
+ if (svg.startsWith("<svg")) {
+ final int idx = svg.indexOf(">");
+ return "<svg>" + svg.substring(idx + 1);
+ }
+ return svg;
+ }
+
+ private int getData(String name) {
+ final Pattern p = Pattern.compile("(?i)" + name + "\\W+(\\d+)");
+ final Matcher m = p.matcher(svg);
+ if (m.find()) {
+ final String s = m.group(1);
+ return Integer.parseInt(s);
+ }
+ throw new IllegalStateException("Cannot find " + name);
+ }
+
+ public int getHeight() {
+ return getData("height");
+ }
+
+ public int getWidth() {
+ return getData("width");
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/ULayoutGroup.java b/src/net/sourceforge/plantuml/ugraphic/ULayoutGroup.java
new file mode 100644
index 0000000..9a9718c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/ULayoutGroup.java
@@ -0,0 +1,63 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.awt.geom.Point2D;
+import java.util.Map;
+
+import net.sourceforge.plantuml.graphic.TextBlock;
+
+public class ULayoutGroup {
+
+ private final PlacementStrategy placementStrategy;
+
+ public ULayoutGroup(PlacementStrategy placementStrategy) {
+ this.placementStrategy = placementStrategy;
+ }
+
+ public void drawU(UGraphic ug, double x, double y, double width, double height) {
+ for (Map.Entry<TextBlock, Point2D> ent : placementStrategy.getPositions(width, height).entrySet()) {
+ final TextBlock block = ent.getKey();
+ final Point2D pos = ent.getValue();
+ block.drawU(ug.apply(new UTranslate((x + pos.getX()), (y + pos.getY()))));
+ }
+ }
+
+ public void add(TextBlock block) {
+ placementStrategy.add(block);
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/ULine.java b/src/net/sourceforge/plantuml/ugraphic/ULine.java
new file mode 100644
index 0000000..23cf32e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/ULine.java
@@ -0,0 +1,73 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+public class ULine extends AbstractShadowable implements Scalable {
+
+ private final double dx;
+ private final double dy;
+
+ public UShape getScaled(double scale) {
+ if (scale == 1) {
+ return this;
+ }
+ final AbstractShadowable result = new ULine(dx * scale, dy * scale);
+ result.setDeltaShadow(this.getDeltaShadow());
+ return result;
+ }
+
+ public ULine(double dx, double dy) {
+ this.dx = dx;
+ this.dy = dy;
+ }
+
+ @Override
+ public String toString() {
+ return "ULine dx=" + dx + " dy=" + dy;
+ }
+
+ public double getDX() {
+ return dx;
+ }
+
+ public double getDY() {
+ return dy;
+ }
+
+ public double getLength() {
+ return Math.sqrt(dx * dx + dy * dy);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UMotif.java b/src/net/sourceforge/plantuml/ugraphic/UMotif.java
new file mode 100644
index 0000000..20094eb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UMotif.java
@@ -0,0 +1,169 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.awt.geom.CubicCurve2D;
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import net.sourceforge.plantuml.posimo.DotPath;
+
+public class UMotif {
+
+ private final List<Point2D> points = new ArrayList<Point2D>();
+
+ public UMotif(int... data) {
+ for (int i = 0; i < data.length; i += 2) {
+ points.add(new Point2D.Double(data[i], data[i + 1]));
+ }
+ }
+
+ public UMotif(String s) {
+ final Point2D last = new Point2D.Double();
+ for (int i = 0; i < s.length(); i++) {
+ final Point2D read = convertPoint(s.charAt(i));
+ last.setLocation(last.getX() + read.getX(), last.getY() + read.getY());
+ points.add(new Point2D.Double(last.getX(), last.getY()));
+ }
+ }
+
+ double getLength() {
+ return points.get(0).distance(points.get(points.size() - 1));
+ }
+
+ List<Point2D> getPoints() {
+ return Collections.unmodifiableList(points);
+ }
+
+ public DotPath getRectangle(double width, double height) {
+ final double len = getLength();
+ final int nb1 = (int) (width / len);
+ DotPath h1 = drawHorizontal(0, 0, nb1);
+ final int nb2 = (int) (height / len);
+ final DotPath v1 = drawVertical(h1.getEndPoint().getX(), h1.getEndPoint().getY(), nb2);
+ h1 = h1.addAfter(v1);
+ return h1;
+ }
+
+ static Point2D convertPoint(char c) {
+ final int v = convertFromChar(c);
+ final int x = v % 7;
+ final int y = v / 7;
+ return new Point2D.Double(x - 3, y - 3);
+ }
+
+ static int convertFromChar(char c) {
+ if (c >= 'A' && c <= 'Z') {
+ return c - 'A';
+ }
+ if (c >= 'a' && c <= 'w') {
+ return c - 'a' + 26;
+ }
+ throw new IllegalArgumentException();
+ }
+
+ // public void drawOld(UGraphic ug, double x, double y) {
+ // final UPath path = new UPath();
+ // path.add(new double[] { x, y }, USegmentType.SEG_MOVETO);
+ // for (Point2D p : points) {
+ // path.add(new double[] { x + p.getX(), y + p.getY() },
+ // USegmentType.SEG_LINETO);
+ // }
+ // ug.draw(0, 0, path);
+ // }
+
+ public void drawHorizontal(UGraphic ug, double x, double y, int nb) {
+ final DotPath path = drawHorizontal(x, y, nb);
+ ug.draw(path);
+ }
+
+ public void drawVertical(UGraphic ug, double x, double y, int nb) {
+ final DotPath path = drawVertical(x, y, nb);
+ ug.draw(path);
+ }
+
+ DotPath drawHorizontal(double x, double y, int nb) {
+ DotPath path = new DotPath();
+ for (int i = 0; i < nb; i++) {
+ path = addHorizontal(x, y, path);
+ x = path.getEndPoint().getX();
+ y = path.getEndPoint().getY();
+ }
+ return path;
+ }
+
+ DotPath drawVertical(double x, double y, int nb) {
+ DotPath path = new DotPath();
+ for (int i = 0; i < nb; i++) {
+ path = addVertical(x, y, path);
+ x = path.getEndPoint().getX();
+ y = path.getEndPoint().getY();
+ }
+ return path;
+ }
+
+ private DotPath addHorizontal(double x, double y, DotPath path) {
+ double lastx = 0;
+ double lasty = 0;
+ for (Point2D p : points) {
+ final double x1 = lastx + x;
+ final double y1 = lasty + y;
+ final double x2 = p.getX() + x;
+ final double y2 = p.getY() + y;
+ path = path.addAfter(new CubicCurve2D.Double(x1, y1, x1, y1, x2, y2, x2, y2));
+ lastx = p.getX();
+ lasty = p.getY();
+ }
+ return path;
+ }
+
+ private DotPath addVertical(double x, double y, DotPath path) {
+ double lastx = 0;
+ double lasty = 0;
+ for (Point2D p : points) {
+ final double x1 = lastx + x;
+ final double y1 = lasty + y;
+ final double x2 = p.getY() + x;
+ final double y2 = p.getX() + y;
+ path = path.addAfter(new CubicCurve2D.Double(x1, y1, x1, y1, x2, y2, x2, y2));
+ lastx = p.getY();
+ lasty = p.getX();
+ }
+ return path;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UParam.java b/src/net/sourceforge/plantuml/ugraphic/UParam.java
new file mode 100644
index 0000000..c13acda
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UParam.java
@@ -0,0 +1,52 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+
+public interface UParam {
+
+ public HtmlColor getColor();
+
+ public HtmlColor getBackcolor();
+
+ public UStroke getStroke();
+
+ public boolean isHidden();
+
+ public UPattern getPattern();
+
+ public double getScale();
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UParamNull.java b/src/net/sourceforge/plantuml/ugraphic/UParamNull.java
new file mode 100644
index 0000000..78c16b4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UParamNull.java
@@ -0,0 +1,66 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+
+public class UParamNull implements UParam {
+
+ public HtmlColor getColor() {
+ return null;
+ }
+
+ public HtmlColor getBackcolor() {
+ return null;
+ }
+
+ public UStroke getStroke() {
+ return new UStroke();
+ }
+
+ public boolean isHidden() {
+ return false;
+ }
+
+ public UPattern getPattern() {
+ return UPattern.FULL;
+ }
+
+ public double getScale() {
+ return 1;
+ }
+
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UPath.java b/src/net/sourceforge/plantuml/ugraphic/UPath.java
new file mode 100644
index 0000000..3bd6a98
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UPath.java
@@ -0,0 +1,143 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+public class UPath extends AbstractShadowable implements Iterable<USegment> {
+
+ private final List<USegment> segments = new ArrayList<USegment>();
+ private MinMax minmax = MinMax.getEmpty(false);
+
+ private boolean isOpenIconic;
+
+ public void add(double[] coord, USegmentType pathType) {
+ segments.add(new USegment(coord, pathType));
+ if (pathType == USegmentType.SEG_ARCTO) {
+ minmax = minmax.addPoint(coord[5], coord[6]);
+// minmax = minmax.addPoint(coord[5] + coord[0], coord[6] + coord[1]);
+// minmax = minmax.addPoint(coord[5] - coord[0], coord[6] - coord[1]);
+ } else {
+ for (int i = 0; i < coord.length; i += 2) {
+ minmax = minmax.addPoint(coord[i], coord[i + 1]);
+ }
+ }
+ }
+
+ public void moveTo(Point2D pt) {
+ moveTo(pt.getX(), pt.getY());
+ }
+
+ public void lineTo(Point2D pt) {
+ lineTo(pt.getX(), pt.getY());
+ }
+
+ public void moveTo(double x, double y) {
+ add(new double[] { x, y }, USegmentType.SEG_MOVETO);
+ }
+
+ public void lineTo(double x, double y) {
+ add(new double[] { x, y }, USegmentType.SEG_LINETO);
+ }
+
+ public void cubicTo(double ctrlx1, double ctrly1, double ctrlx2, double ctrly2, double x2, double y2) {
+ add(new double[] { ctrlx1, ctrly1, ctrlx2, ctrly2, x2, y2 }, USegmentType.SEG_CUBICTO);
+ }
+
+ public void quadTo(double ctrlx, double ctrly, double x2, double y2) {
+ add(new double[] { ctrlx, ctrly, ctrlx, ctrly, x2, y2 }, USegmentType.SEG_CUBICTO);
+ }
+
+ public void quadTo(Point2D ctrl, Point2D pt) {
+ quadTo(ctrl.getX(), ctrl.getY(), pt.getX(), pt.getY());
+ }
+
+ public void arcTo(double rx, double ry, double x_axis_rotation, double large_arc_flag, double sweep_flag, double x,
+ double y) {
+ add(new double[] { rx, ry, x_axis_rotation, large_arc_flag, sweep_flag, x, y }, USegmentType.SEG_ARCTO);
+ // lineTo(x, y);
+ }
+
+ public void arcTo(Point2D pt, double radius, double large_arc_flag, double sweep_flag) {
+ add(new double[] { radius, radius, 0, large_arc_flag, sweep_flag, pt.getX(), pt.getY() },
+ USegmentType.SEG_ARCTO);
+ // lineTo(x, y);
+ }
+
+ public void closePath() {
+ // System.err.println("CLOSE_PATH");
+ }
+
+ public double getMaxX() {
+ return minmax.getMaxX();
+ }
+
+ public double getMaxY() {
+ return minmax.getMaxY();
+ }
+
+ public double getMinX() {
+ return minmax.getMinX();
+ }
+
+ public double getMinY() {
+ return minmax.getMinY();
+ }
+
+ @Override
+ public String toString() {
+ return segments.toString();
+ }
+
+ public Iterator<USegment> iterator() {
+ return segments.iterator();
+ }
+
+ public boolean isOpenIconic() {
+ return isOpenIconic;
+ }
+
+ public void setOpenIconic(boolean isOpenIconic) {
+ this.isOpenIconic = isOpenIconic;
+ }
+
+ // public boolean isEmpty() {
+ // return segments.size() == 0;
+ // }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UPattern.java b/src/net/sourceforge/plantuml/ugraphic/UPattern.java
new file mode 100644
index 0000000..a51f772
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UPattern.java
@@ -0,0 +1,41 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+public enum UPattern implements UChange {
+
+ FULL, HORIZONTAL_STRIPE, VERTICAL_STRIPE, SMALL_CIRCLE
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UPixel.java b/src/net/sourceforge/plantuml/ugraphic/UPixel.java
new file mode 100644
index 0000000..d7f428e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UPixel.java
@@ -0,0 +1,38 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+public class UPixel implements UShape {
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UPolygon.java b/src/net/sourceforge/plantuml/ugraphic/UPolygon.java
new file mode 100644
index 0000000..2cfdf0d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UPolygon.java
@@ -0,0 +1,130 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+import java.util.List;
+
+public class UPolygon extends AbstractShadowable {
+
+ private final List<Point2D.Double> all = new ArrayList<Point2D.Double>();
+
+ private MinMax minmax = MinMax.getEmpty(false);
+
+ public UPolygon() {
+ }
+
+ public UPolygon(List<Point2D.Double> points) {
+ all.addAll(points);
+ for (Point2D.Double pt : all) {
+ manageMinMax(pt.getX(), pt.getY());
+ }
+ }
+
+ public void addPoint(double x, double y) {
+ all.add(new Point2D.Double(x, y));
+ manageMinMax(x, y);
+ }
+
+ private void manageMinMax(double x, double y) {
+ minmax = minmax.addPoint(x, y);
+ }
+
+ public List<Point2D.Double> getPoints() {
+ return all;
+ }
+
+ public UPolygon translate(double dx, double dy) {
+ final UPolygon result = new UPolygon();
+ for (Point2D.Double pt : all) {
+ result.addPoint(pt.x + dx, pt.y + dy);
+ }
+ return result;
+ }
+
+ public void rotate(double theta) {
+ final AffineTransform rotate = AffineTransform.getRotateInstance(theta);
+ for (Point2D.Double pt : all) {
+ rotate.transform(pt, pt);
+ }
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + " " + all;
+ }
+
+ public double getHeight() {
+ return minmax.getHeight();
+ }
+
+ public double getWidth() {
+ return minmax.getWidth();
+ }
+
+ public double getMinX() {
+ return minmax.getMinX();
+ }
+
+ public double getMinY() {
+ return minmax.getMinY();
+ }
+
+ public double getMaxX() {
+ return minmax.getMaxX();
+
+ }
+
+ public double getMaxY() {
+ return minmax.getMaxY();
+ }
+
+ public MinMax getMinMax() {
+ return minmax;
+ }
+
+ public double[] getPointArray(double x, double y) {
+ final double points[] = new double[getPoints().size() * 2];
+ int i = 0;
+
+ for (Point2D pt : getPoints()) {
+ points[i++] = pt.getX() + x;
+ points[i++] = pt.getY() + y;
+ }
+ return points;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/URectangle.java b/src/net/sourceforge/plantuml/ugraphic/URectangle.java
new file mode 100644
index 0000000..658632c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/URectangle.java
@@ -0,0 +1,105 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.awt.geom.Dimension2D;
+
+public class URectangle extends AbstractShadowable implements Scalable {
+
+ private final double width;
+ private final double height;
+ private final double rx;
+ private final double ry;
+
+ public UShape getScaled(double scale) {
+ if (scale == 1) {
+ return this;
+ }
+ final AbstractShadowable result = new URectangle(width * scale, height * scale, rx * scale, ry * scale);
+ result.setDeltaShadow(this.getDeltaShadow());
+ return result;
+ }
+
+ public URectangle(double width, double height) {
+ this(width, height, 0, 0);
+ }
+
+ public URectangle(double width, double height, double rx, double ry) {
+ // if (height == 0) {
+ // throw new IllegalArgumentException();
+ // }
+ if (width == 0) {
+ throw new IllegalArgumentException();
+ }
+ this.width = width;
+ this.height = height;
+ this.rx = rx;
+ this.ry = ry;
+ }
+
+ public URectangle(Dimension2D dim) {
+ this(dim.getWidth(), dim.getHeight());
+ }
+
+ @Override
+ public String toString() {
+ return "width=" + width + " height=" + height;
+ }
+
+ public double getWidth() {
+ return width;
+ }
+
+ public double getHeight() {
+ return height;
+ }
+
+ public double getRx() {
+ return rx;
+ }
+
+ public double getRy() {
+ return ry;
+ }
+
+ public URectangle clip(UClip clip) {
+ return this;
+ }
+
+ public MinMax getMinMax() {
+ return MinMax.fromMax(width, height);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UScale.java b/src/net/sourceforge/plantuml/ugraphic/UScale.java
new file mode 100644
index 0000000..f9676d2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UScale.java
@@ -0,0 +1,62 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+
+public class UScale implements UChange {
+
+ private final double scale;
+
+ @Override
+ public String toString() {
+ return "scale scale=" + scale;
+ }
+
+ public UScale(double scale) {
+ this.scale = scale;
+ }
+
+ public double getScale() {
+ return scale;
+ }
+
+// public Point2D getTranslated(Point2D p) {
+// if (p == null) {
+// return null;
+// }
+// return new Point2D.Double(p.getX() + dx, p.getY() + dy);
+// }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/USegment.java b/src/net/sourceforge/plantuml/ugraphic/USegment.java
new file mode 100644
index 0000000..0b27ca3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/USegment.java
@@ -0,0 +1,62 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.util.Arrays;
+
+public class USegment {
+
+ private final double coord[];
+ private final USegmentType pathType;
+
+ public USegment(double[] coord, USegmentType pathType) {
+ this.coord = coord.clone();
+ this.pathType = pathType;
+ }
+
+ @Override
+ public String toString() {
+ return pathType.toString() + " " + Arrays.toString(coord);
+ }
+
+ public final double[] getCoord() {
+ return coord;
+ }
+
+ public final USegmentType getSegmentType() {
+ return pathType;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/USegmentType.java b/src/net/sourceforge/plantuml/ugraphic/USegmentType.java
new file mode 100644
index 0000000..36f4e05
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/USegmentType.java
@@ -0,0 +1,60 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.awt.geom.PathIterator;
+import java.util.EnumSet;
+import net.sourceforge.plantuml.ugraphic.arc.ExtendedPathIterator;
+
+public enum USegmentType {
+
+ SEG_MOVETO(PathIterator.SEG_MOVETO), SEG_LINETO(PathIterator.SEG_LINETO), SEG_QUADTO(PathIterator.SEG_QUADTO), SEG_CUBICTO(
+ PathIterator.SEG_CUBICTO), SEG_CLOSE(PathIterator.SEG_CLOSE), SEG_ARCTO(ExtendedPathIterator.SEG_ARCTO);
+
+ private final int code;
+
+ private USegmentType(int code) {
+ this.code = code;
+ }
+
+ public static USegmentType getByCode(int code) {
+ for (USegmentType p : EnumSet.allOf(USegmentType.class)) {
+ if (p.code == code) {
+ return p;
+ }
+ }
+ throw new IllegalArgumentException();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UShape.java b/src/net/sourceforge/plantuml/ugraphic/UShape.java
new file mode 100644
index 0000000..18a77c7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UShape.java
@@ -0,0 +1,39 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+
+public interface UShape {
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UStroke.java b/src/net/sourceforge/plantuml/ugraphic/UStroke.java
new file mode 100644
index 0000000..cc4bf86
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UStroke.java
@@ -0,0 +1,95 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+public class UStroke implements UChange {
+
+ private final double dashVisible;
+ private final double dashSpace;
+ private final double thickness;
+
+ @Override
+ public String toString() {
+ return "" + dashVisible + "-" + dashSpace + "-" + thickness;
+ }
+
+ public UStroke(double dashVisible, double dashSpace, double thickness) {
+ this.dashVisible = dashVisible;
+ this.dashSpace = dashSpace;
+ this.thickness = thickness;
+ }
+
+ public UStroke(double thickness) {
+ this(0, 0, thickness);
+ }
+
+ public UStroke() {
+ this(1.0);
+ }
+
+ public double getDashVisible() {
+ return dashVisible;
+ }
+
+ public double getDashSpace() {
+ return dashSpace;
+ }
+
+ public double getThickness() {
+ return thickness;
+ }
+
+ public String getDasharraySvg() {
+ if (dashVisible == 0) {
+ return null;
+ }
+ return "" + dashVisible + "," + dashSpace;
+ }
+
+ public String getDashTikz() {
+ if (dashVisible == 0) {
+ return null;
+ }
+ return "on " + dashVisible + "pt off " + dashSpace + "pt";
+ }
+
+ // public String getDasharrayEps() {
+ // if (dashVisible == 0) {
+ // return null;
+ // }
+ // return "" + dashVisible + " " + dashSpace;
+ // }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UText.java b/src/net/sourceforge/plantuml/ugraphic/UText.java
new file mode 100644
index 0000000..ee458e7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UText.java
@@ -0,0 +1,74 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.awt.font.LineMetrics;
+
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+
+public class UText implements UShape {
+
+ private final String text;
+ private final FontConfiguration font;
+
+ @Override
+ public String toString() {
+ return "UText[" + text + "]";
+ }
+
+ public UText(String text, FontConfiguration font) {
+ assert text.indexOf('\t') == -1;
+ this.text = text;
+ this.font = font;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public FontConfiguration getFontConfiguration() {
+ return font;
+ }
+
+ public double getDescent() {
+ final LineMetrics fm = TextBlockUtils.getLineMetrics(font.getFont(), text);
+ final double descent = fm.getDescent();
+ return descent;
+ }
+
+
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UTranslate.java b/src/net/sourceforge/plantuml/ugraphic/UTranslate.java
new file mode 100644
index 0000000..c6349f6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UTranslate.java
@@ -0,0 +1,89 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic;
+
+import java.awt.geom.Point2D;
+
+public class UTranslate implements UChange {
+
+ private final double dx;
+ private final double dy;
+
+ @Override
+ public String toString() {
+ return "translate dx=" + dx + " dy=" + dy;
+ }
+
+ public UTranslate(double dx, double dy) {
+ this.dx = dx;
+ this.dy = dy;
+ }
+
+ public UTranslate(Point2D p) {
+ this(p.getX(), p.getY());
+ }
+
+ public UTranslate() {
+ this(0, 0);
+ }
+
+ public double getDx() {
+ return dx;
+ }
+
+ public double getDy() {
+ return dy;
+ }
+
+ public Point2D getTranslated(Point2D p) {
+ if (p == null) {
+ return null;
+ }
+ return new Point2D.Double(p.getX() + dx, p.getY() + dy);
+ }
+
+ public UTranslate scaled(double scale) {
+ return new UTranslate(dx * scale, dy * scale);
+ }
+
+ public UTranslate compose(UTranslate other) {
+ return new UTranslate(dx + other.dx, dy + other.dy);
+ }
+
+ public UTranslate reverse() {
+ return new UTranslate(-dx, -dy);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/arc/ExtendedGeneralPath.java b/src/net/sourceforge/plantuml/ugraphic/arc/ExtendedGeneralPath.java
new file mode 100644
index 0000000..579ce51
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/arc/ExtendedGeneralPath.java
@@ -0,0 +1,766 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.arc;
+
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ */
+
+import java.awt.Rectangle;
+import java.awt.Shape;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Arc2D;
+import java.awt.geom.GeneralPath;
+import java.awt.geom.PathIterator;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+import java.util.Arrays;
+
+/**
+ * The <code>ExtendedGeneralPath</code> class represents a geometric path constructed from straight lines, quadratic and
+ * cubic (Bezier) curves and elliptical arc. This class delegates lines and curves to an enclosed
+ * <code>GeneralPath</code>. Elliptical arc is implemented using an <code>Arc2D</code> in double precision.
+ *
+ * <p>
+ * <b>Warning</b> : An elliptical arc may be composed of several path segments. For futher details, see the SVG
+ * Appendix&nbsp;F.6
+ *
+ * @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
+ * @version $Id: ExtendedGeneralPath.java 594018 2007-11-12 04:17:41Z cam $
+ */
+public class ExtendedGeneralPath implements Shape, Cloneable {
+
+ /** The enclosed general path. */
+ private GeneralPath path;
+
+ private int numVals = 0;
+ private int numSeg = 0;
+ private double[] values = null;
+ private int[] types = null;
+
+ private double mx;
+ private double my;
+ private double cx;
+ private double cy;
+
+ /**
+ * Constructs a new <code>ExtendedGeneralPath</code>.
+ */
+ public ExtendedGeneralPath() {
+ path = new GeneralPath();
+ }
+
+ /**
+ * Constructs a new <code>ExtendedGeneralPath</code> with the specified winding rule to control operations that
+ * require the interior of the path to be defined.
+ */
+ public ExtendedGeneralPath(int rule) {
+ path = new GeneralPath(rule);
+ }
+
+ /**
+ * Constructs a new <code>ExtendedGeneralPath</code> object with the specified winding rule and the specified
+ * initial capacity to store path coordinates.
+ */
+ public ExtendedGeneralPath(int rule, int initialCapacity) {
+ path = new GeneralPath(rule, initialCapacity);
+ }
+
+ /**
+ * Constructs a new <code>ExtendedGeneralPath</code> object from an arbitrary <code>Shape</code> object.
+ */
+ public ExtendedGeneralPath(Shape s) {
+ this();
+ append(s, false);
+ }
+
+ /**
+ * Adds an elliptical arc, defined by two radii, an angle from the x-axis, a flag to choose the large arc or not, a
+ * flag to indicate if we increase or decrease the angles and the final point of the arc.
+ *
+ * @param rx
+ * the x radius of the ellipse
+ * @param ry
+ * the y radius of the ellipse
+ *
+ * @param angle
+ * the angle from the x-axis of the current coordinate system to the x-axis of the ellipse in degrees.
+ *
+ * @param largeArcFlag
+ * the large arc flag. If true the arc spanning less than or equal to 180 degrees is chosen, otherwise
+ * the arc spanning greater than 180 degrees is chosen
+ *
+ * @param sweepFlag
+ * the sweep flag. If true the line joining center to arc sweeps through decreasing angles otherwise it
+ * sweeps through increasing angles
+ *
+ * @param x
+ * the absolute x coordinate of the final point of the arc.
+ * @param y
+ * the absolute y coordinate of the final point of the arc.
+ */
+ public void arcTo(double rx, double ry, double angle, boolean largeArcFlag, boolean sweepFlag,
+ double x, double y) {
+
+ // Ensure radii are valid
+ if (rx == 0 || ry == 0) {
+ lineTo(x, y);
+ return;
+ }
+
+ checkMoveTo(); // check if prev command was moveto
+
+ // Get the current (x, y) coordinates of the path
+ final double x0 = cx;
+ final double y0 = cy;
+ if (x0 == x && y0 == y) {
+ // If the endpoints (x, y) and (x0, y0) are identical, then this
+ // is equivalent to omitting the elliptical arc segment entirely.
+ return;
+ }
+
+ final Arc2D arc = computeArc(x0, y0, rx, ry, angle, largeArcFlag, sweepFlag, x, y);
+ if (arc == null) {
+ return;
+ }
+
+ final AffineTransform t = AffineTransform.getRotateInstance(Math.toRadians(angle), arc.getCenterX(),
+ arc.getCenterY());
+ final Shape s = t.createTransformedShape(arc);
+ path.append(s, true);
+
+ makeRoom(7);
+ types[numSeg++] = ExtendedPathIterator.SEG_ARCTO;
+ values[numVals++] = rx;
+ values[numVals++] = ry;
+ values[numVals++] = angle;
+ values[numVals++] = largeArcFlag ? 1 : 0;
+ values[numVals++] = sweepFlag ? 1 : 0;
+ cx = values[numVals++] = x;
+ cy = values[numVals++] = y;
+ }
+
+ /**
+ * This constructs an unrotated Arc2D from the SVG specification of an Elliptical arc. To get the final arc you need
+ * to apply a rotation transform such as:
+ *
+ * AffineTransform.getRotateInstance (angle, arc.getX()+arc.getWidth()/2, arc.getY()+arc.getHeight()/2);
+ */
+ public static Arc2D computeArc(double x0, double y0, double rx, double ry, double angle, boolean largeArcFlag,
+ boolean sweepFlag, double x, double y) {
+ //
+ // Elliptical arc implementation based on the SVG specification notes
+ //
+
+ // Compute the half distance between the current and the final point
+ final double dx2 = (x0 - x) / 2.0;
+ final double dy2 = (y0 - y) / 2.0;
+ // Convert angle from degrees to radians
+ angle = Math.toRadians(angle % 360.0);
+ final double cosAngle = Math.cos(angle);
+ final double sinAngle = Math.sin(angle);
+
+ //
+ // Step 1 : Compute (x1, y1)
+ //
+ final double x1 = cosAngle * dx2 + sinAngle * dy2;
+ final double y1 = -sinAngle * dx2 + cosAngle * dy2;
+ // Ensure radii are large enough
+ rx = Math.abs(rx);
+ ry = Math.abs(ry);
+ double prx = rx * rx;
+ double pry = ry * ry;
+ final double px1 = x1 * x1;
+ final double py1 = y1 * y1;
+ // check that radii are large enough
+ final double radiiCheck = px1 / prx + py1 / pry;
+ if (radiiCheck > 1) {
+ rx = Math.sqrt(radiiCheck) * rx;
+ ry = Math.sqrt(radiiCheck) * ry;
+ prx = rx * rx;
+ pry = ry * ry;
+ }
+
+ //
+ // Step 2 : Compute (cx1, cy1)
+ //
+ double sign = (largeArcFlag == sweepFlag) ? -1 : 1;
+ double sq = ((prx * pry) - (prx * py1) - (pry * px1)) / ((prx * py1) + (pry * px1));
+ sq = (sq < 0) ? 0 : sq;
+ final double coef = sign * Math.sqrt(sq);
+ final double cx1 = coef * ((rx * y1) / ry);
+ final double cy1 = coef * -((ry * x1) / rx);
+
+ //
+ // Step 3 : Compute (cx, cy) from (cx1, cy1)
+ //
+ final double sx2 = (x0 + x) / 2.0;
+ final double sy2 = (y0 + y) / 2.0;
+ final double cx = sx2 + (cosAngle * cx1 - sinAngle * cy1);
+ final double cy = sy2 + (sinAngle * cx1 + cosAngle * cy1);
+
+ //
+ // Step 4 : Compute the angleStart (angle1) and the angleExtent (dangle)
+ //
+ final double ux = (x1 - cx1) / rx;
+ final double uy = (y1 - cy1) / ry;
+ final double vx = (-x1 - cx1) / rx;
+ final double vy = (-y1 - cy1) / ry;
+ // Compute the angle start
+ double n = Math.sqrt((ux * ux) + (uy * uy));
+ double p = ux; // (1 * ux) + (0 * uy)
+ sign = (uy < 0) ? -1.0 : 1.0;
+ double angleStart = Math.toDegrees(sign * Math.acos(p / n));
+
+ // Compute the angle extent
+ n = Math.sqrt((ux * ux + uy * uy) * (vx * vx + vy * vy));
+ p = ux * vx + uy * vy;
+ sign = (ux * vy - uy * vx < 0) ? -1.0 : 1.0;
+ double angleExtent = Math.toDegrees(sign * Math.acos(p / n));
+ if (!sweepFlag && angleExtent > 0) {
+ angleExtent -= 360f;
+ } else if (sweepFlag && angleExtent < 0) {
+ angleExtent += 360f;
+ }
+ angleExtent %= 360f;
+ angleStart %= 360f;
+
+ //
+ // We can now build the resulting Arc2D in double precision
+ //
+ final Arc2D.Double arc = new Arc2D.Double();
+ arc.x = cx - rx;
+ arc.y = cy - ry;
+ arc.width = rx * 2.0;
+ arc.height = ry * 2.0;
+ arc.start = -angleStart;
+ arc.extent = -angleExtent;
+
+ return arc;
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public void moveTo(double x, double y) {
+ // Don't add moveto to general path unless there is a reason.
+ makeRoom(2);
+ types[numSeg++] = PathIterator.SEG_MOVETO;
+ cx = mx = values[numVals++] = x;
+ cy = my = values[numVals++] = y;
+
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public void lineTo(double x, double y) {
+ checkMoveTo(); // check if prev command was moveto
+ path.lineTo(x, y);
+
+ makeRoom(2);
+ types[numSeg++] = PathIterator.SEG_LINETO;
+ cx = values[numVals++] = x;
+ cy = values[numVals++] = y;
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public void quadTo(double x1, double y1, double x2, double y2) {
+ checkMoveTo(); // check if prev command was moveto
+ path.quadTo(x1, y1, x2, y2);
+
+ makeRoom(4);
+ types[numSeg++] = PathIterator.SEG_QUADTO;
+ values[numVals++] = x1;
+ values[numVals++] = y1;
+ cx = values[numVals++] = x2;
+ cy = values[numVals++] = y2;
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public void curveTo(double x1, double y1, double x2, double y2, double x3, double y3) {
+ checkMoveTo(); // check if prev command was moveto
+ path.curveTo(x1, y1, x2, y2, x3, y3);
+
+ makeRoom(6);
+ types[numSeg++] = PathIterator.SEG_CUBICTO;
+ values[numVals++] = x1;
+ values[numVals++] = y1;
+ values[numVals++] = x2;
+ values[numVals++] = y2;
+ cx = values[numVals++] = x3;
+ cy = values[numVals++] = y3;
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public void closePath() {
+ // Don't double close path.
+ if (numSeg != 0 && types[numSeg - 1] == PathIterator.SEG_CLOSE) {
+ return;
+ }
+
+ // Only close path if the previous command wasn't a moveto
+ if (numSeg != 0 && types[numSeg - 1] != PathIterator.SEG_MOVETO) {
+ path.closePath();
+ }
+
+ makeRoom(0);
+ types[numSeg++] = PathIterator.SEG_CLOSE;
+ cx = mx;
+ cy = my;
+ }
+
+ /**
+ * Checks if previous command was a moveto command, skipping a close command (if present).
+ */
+ protected void checkMoveTo() {
+ if (numSeg == 0) {
+ return;
+ }
+
+ switch (types[numSeg - 1]) {
+
+ case PathIterator.SEG_MOVETO:
+ path.moveTo(values[numVals - 2], values[numVals - 1]);
+ break;
+
+ case PathIterator.SEG_CLOSE:
+ if (numSeg == 1) {
+ return;
+ }
+ if (types[numSeg - 2] == PathIterator.SEG_MOVETO) {
+ path.moveTo(values[numVals - 2], values[numVals - 1]);
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public void append(Shape s, boolean connect) {
+ append(s.getPathIterator(new AffineTransform()), connect);
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public void append(PathIterator pi, boolean connect) {
+ final double[] vals = new double[6];
+
+ while (!pi.isDone()) {
+ Arrays.fill(vals, 0);
+ int type = pi.currentSegment(vals);
+ pi.next();
+ if (connect && numVals != 0) {
+ if (type == PathIterator.SEG_MOVETO) {
+ final double x = vals[0];
+ final double y = vals[1];
+ if (x != cx || y != cy) {
+ // Change MOVETO to LINETO.
+ type = PathIterator.SEG_LINETO;
+ } else {
+ // Redundent segment (move to current loc) drop it...
+ if (pi.isDone()) {
+ break; // Nothing interesting
+ }
+ type = pi.currentSegment(vals);
+ pi.next();
+ }
+ }
+ connect = false;
+ }
+
+ switch (type) {
+ case PathIterator.SEG_CLOSE:
+ closePath();
+ break;
+ case PathIterator.SEG_MOVETO:
+ moveTo(vals[0], vals[1]);
+ break;
+ case PathIterator.SEG_LINETO:
+ lineTo(vals[0], vals[1]);
+ break;
+ case PathIterator.SEG_QUADTO:
+ quadTo(vals[0], vals[1], vals[2], vals[3]);
+ break;
+ case PathIterator.SEG_CUBICTO:
+ curveTo(vals[0], vals[1], vals[2], vals[3], vals[4], vals[5]);
+ break;
+ }
+ }
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public void append(ExtendedPathIterator epi, boolean connect) {
+ final double[] vals = new double[7];
+ while (!epi.isDone()) {
+ Arrays.fill(vals, 0);
+ int type = epi.currentSegment(vals);
+ epi.next();
+ if (connect && numVals != 0) {
+ if (type == PathIterator.SEG_MOVETO) {
+ final double x = vals[0];
+ final double y = vals[1];
+ if ((x != cx) || (y != cy)) {
+ // Change MOVETO to LINETO.
+ type = PathIterator.SEG_LINETO;
+ } else {
+ // Redundant segment (move to current loc) drop it...
+ if (epi.isDone()) {
+ break; // Nothing interesting
+ }
+ type = epi.currentSegment(vals);
+ epi.next();
+ }
+ }
+ connect = false;
+ }
+
+ switch (type) {
+ case PathIterator.SEG_CLOSE:
+ closePath();
+ break;
+ case PathIterator.SEG_MOVETO:
+ moveTo(vals[0], vals[1]);
+ break;
+ case PathIterator.SEG_LINETO:
+ lineTo(vals[0], vals[1]);
+ break;
+ case PathIterator.SEG_QUADTO:
+ quadTo(vals[0], vals[1], vals[2], vals[3]);
+ break;
+ case PathIterator.SEG_CUBICTO:
+ curveTo(vals[0], vals[1], vals[2], vals[3], vals[4], vals[5]);
+ break;
+ case ExtendedPathIterator.SEG_ARCTO:
+ arcTo(vals[0], vals[1], vals[2], vals[3] != 0, vals[4] != 0, vals[5], vals[6]);
+ break;
+ }
+ }
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public int getWindingRule() {
+ return path.getWindingRule();
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public void setWindingRule(int rule) {
+ path.setWindingRule(rule);
+ }
+
+ /**
+ * get the current position or <code>null</code>.
+ */
+ public Point2D getCurrentPoint() {
+ if (numVals == 0) {
+ return null;
+ }
+ return new Point2D.Double(cx, cy);
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public void reset() {
+ path.reset();
+
+ numSeg = 0;
+ numVals = 0;
+ values = null;
+ types = null;
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public void transform(AffineTransform at) {
+ if (at.getType() != AffineTransform.TYPE_IDENTITY) {
+ throw new IllegalArgumentException("ExtendedGeneralPaths can not be transformed");
+ }
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public Shape createTransformedShape(AffineTransform at) {
+ return path.createTransformedShape(at);
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public Rectangle getBounds() {
+ return path.getBounds();
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public Rectangle2D getBounds2D() {
+ return path.getBounds2D();
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public boolean contains(double x, double y) {
+ return path.contains(x, y);
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public boolean contains(Point2D p) {
+ return path.contains(p);
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public boolean contains(double x, double y, double w, double h) {
+ return path.contains(x, y, w, h);
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public boolean contains(Rectangle2D r) {
+ return path.contains(r);
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public boolean intersects(double x, double y, double w, double h) {
+ return path.intersects(x, y, w, h);
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public boolean intersects(Rectangle2D r) {
+ return path.intersects(r);
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public PathIterator getPathIterator(AffineTransform at) {
+ return path.getPathIterator(at);
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public PathIterator getPathIterator(AffineTransform at, double flatness) {
+ return path.getPathIterator(at, flatness);
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public ExtendedPathIterator getExtendedPathIterator() {
+ return new EPI();
+ }
+
+ class EPI implements ExtendedPathIterator {
+ private int segNum = 0;
+ private int valsIdx = 0;
+
+ public int currentSegment() {
+ return types[segNum];
+ }
+
+ public int currentSegment(double[] coords) {
+ final int ret = types[segNum];
+ switch (ret) {
+ case SEG_CLOSE:
+ break;
+ case SEG_MOVETO:
+ case SEG_LINETO:
+ coords[0] = values[valsIdx];
+ coords[1] = values[valsIdx + 1];
+ break;
+ case SEG_QUADTO:
+ coords[0] = values[valsIdx];
+ coords[1] = values[valsIdx + 1];
+ coords[2] = values[valsIdx + 2];
+ coords[3] = values[valsIdx + 3];
+ break;
+ case SEG_CUBICTO:
+ coords[0] = values[valsIdx];
+ coords[1] = values[valsIdx + 1];
+ coords[2] = values[valsIdx + 2];
+ coords[3] = values[valsIdx + 3];
+ coords[4] = values[valsIdx + 4];
+ coords[5] = values[valsIdx + 5];
+ break;
+ case SEG_ARCTO:
+ coords[0] = values[valsIdx];
+ coords[1] = values[valsIdx + 1];
+ coords[2] = values[valsIdx + 2];
+ coords[3] = values[valsIdx + 3];
+ coords[4] = values[valsIdx + 4];
+ coords[5] = values[valsIdx + 5];
+ coords[6] = values[valsIdx + 6];
+ break;
+ }
+ return ret;
+ }
+
+ public int getWindingRule() {
+ return path.getWindingRule();
+ }
+
+ public boolean isDone() {
+ return segNum == numSeg;
+ }
+
+ public void next() {
+ final int type = types[segNum++];
+ switch (type) {
+ case SEG_CLOSE:
+ break;
+ case SEG_MOVETO: // fallthrough is intended
+ case SEG_LINETO:
+ valsIdx += 2;
+ break;
+ case SEG_QUADTO:
+ valsIdx += 4;
+ break;
+ case SEG_CUBICTO:
+ valsIdx += 6;
+ break;
+ case SEG_ARCTO:
+ valsIdx += 7;
+ break;
+ }
+ }
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public Object clone() {
+ try {
+ final ExtendedGeneralPath result = (ExtendedGeneralPath) super.clone();
+ result.path = (GeneralPath) path.clone();
+
+ if (values != null) {
+ result.values = new double[values.length];
+ System.arraycopy(values, 0, result.values, 0, values.length);
+ }
+ result.numVals = numVals;
+
+ if (types != null) {
+ result.types = new int[types.length];
+ System.arraycopy(types, 0, result.types, 0, types.length);
+ }
+ result.numSeg = numSeg;
+
+ return result;
+ } catch (CloneNotSupportedException ex) {
+ ex.printStackTrace();
+ }
+ return null;
+ }
+
+ /**
+ * Make sure, that the requested number of slots in vales[] are available. Must be called even for numValues = 0,
+ * because it is also used for initialization of those arrays.
+ *
+ * @param numValues
+ * number of requested coordinates
+ */
+ private void makeRoom(int numValues) {
+ if (values == null) {
+ values = new double[2 * numValues];
+ types = new int[2];
+ numVals = 0;
+ numSeg = 0;
+ return;
+ }
+
+ final int newSize = numVals + numValues;
+ if (newSize > values.length) {
+ int nlen = values.length * 2;
+ if (nlen < newSize) {
+ nlen = newSize;
+ }
+
+ final double[] nvals = new double[nlen];
+ System.arraycopy(values, 0, nvals, 0, numVals);
+ values = nvals;
+ }
+
+ if (numSeg == types.length) {
+ final int[] ntypes = new int[types.length * 2];
+ System.arraycopy(types, 0, ntypes, 0, types.length);
+ types = ntypes;
+ }
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/arc/ExtendedPathIterator.java b/src/net/sourceforge/plantuml/ugraphic/arc/ExtendedPathIterator.java
new file mode 100644
index 0000000..2a7ab22
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/arc/ExtendedPathIterator.java
@@ -0,0 +1,133 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.arc;
+
+import java.awt.geom.PathIterator;
+
+
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE
+ * file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file
+ * to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+
+/**
+ * The <code>ExtendedPathIterator</code> class represents a geometric path constructed from straight lines, quadratic
+ * and cubic (Bezier) curves and elliptical arcs. This interface is identical to that of PathIterator except it can
+ * return SEG_ARCTO from currentSegment, also the array of values passed to currentSegment must be of length 7 or an
+ * error will be thrown.
+ *
+ * This does not extend PathIterator as it would break the interface contract for that class.
+ *
+ * @author <a href="mailto:deweese@apache.org">Thomas DeWeese</a>
+ * @version $Id: ExtendedPathIterator.java 475477 2006-11-15 22:44:28Z cam $
+ */
+public interface ExtendedPathIterator {
+
+ /**
+ * The segment type constant that specifies that the preceding subpath should be closed by appending a line segment
+ * back to the point corresponding to the most recent SEG_MOVETO.
+ */
+ int SEG_CLOSE = PathIterator.SEG_CLOSE;
+
+ /**
+ * The segment type constant for a point that specifies the end point of a line to be drawn from the most recently
+ * specified point.
+ */
+ int SEG_MOVETO = PathIterator.SEG_MOVETO;
+
+ /**
+ * The segment type constant for a point that specifies the end point of a line to be drawn from the most recently
+ * specified point.
+ */
+ int SEG_LINETO = PathIterator.SEG_LINETO;
+
+ /**
+ * The segment type constant for the pair of points that specify a quadratic parametric curve to be drawn from the
+ * most recently specified point. The curve is interpolated by solving the parametric control equation in the range
+ * (t=[0..1]) using the most recently specified (current) point (CP), the first control point (P1), and the final
+ * interpolated control point (P2).
+ */
+ int SEG_QUADTO = PathIterator.SEG_QUADTO;
+
+ /**
+ * The segment type constant for the set of 3 points that specify a cubic parametric curve to be drawn from the most
+ * recently specified point. The curve is interpolated by solving the parametric control equation in the range
+ * (t=[0..1]) using the most recently specified (current) point (CP), the first control point (P1), the second
+ * control point (P2), and the final interpolated control point (P3).
+ */
+ int SEG_CUBICTO = PathIterator.SEG_CUBICTO;
+
+ /**
+ * The segment type constant for an elliptical arc. This consists of Seven values [rx, ry, angle, largeArcFlag,
+ * sweepFlag, x, y]. rx, ry are the radious of the ellipse. angle is angle of the x axis of the ellipse.
+ * largeArcFlag is zero if the smaller of the two arcs are to be used. sweepFlag is zero if the 'left' branch is
+ * taken one otherwise. x and y are the destination for the ellipse.
+ */
+ int SEG_ARCTO = 4321;
+
+ /**
+ * The winding rule constant for specifying an even-odd rule for determining the interior of a path. The even-odd
+ * rule specifies that a point lies inside the path if a ray drawn in any direction from that point to infinity is
+ * crossed by path segments an odd number of times.
+ */
+ int WIND_EVEN_ODD = PathIterator.WIND_EVEN_ODD;
+
+ /**
+ * The winding rule constant for specifying a non-zero rule for determining the interior of a path. The non-zero
+ * rule specifies that a point lies inside the path if a ray drawn in any direction from that point to infinity is
+ * crossed by path segments a different number of times in the counter-clockwise direction than the clockwise
+ * direction.
+ */
+ int WIND_NON_ZERO = PathIterator.WIND_NON_ZERO;
+
+ int currentSegment();
+
+ int currentSegment(double[] coords);
+
+ int getWindingRule();
+
+ boolean isDone();
+
+ void next();
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/eps/DriverCenteredCharacterEps.java b/src/net/sourceforge/plantuml/ugraphic/eps/DriverCenteredCharacterEps.java
new file mode 100644
index 0000000..ed3cc6f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/eps/DriverCenteredCharacterEps.java
@@ -0,0 +1,66 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.eps;
+
+import java.awt.font.TextLayout;
+
+import net.sourceforge.plantuml.eps.EpsGraphics;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.graphic.UnusedSpace;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UCenteredCharacter;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverCenteredCharacterEps implements UDriver<EpsGraphics> {
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, EpsGraphics eps) {
+ final UCenteredCharacter centeredCharacter = (UCenteredCharacter) ushape;
+ final char c = centeredCharacter.getChar();
+ final UFont font = centeredCharacter.getFont();
+ final UnusedSpace unusedSpace = UnusedSpace.getUnusedSpace(font, c);
+
+ final double xpos = x - unusedSpace.getCenterX() - 0.5;
+ final double ypos = y - unusedSpace.getCenterY() - 0.5;
+
+ final TextLayout t = new TextLayout("" + c, font.getFont(), TextBlockUtils.getFontRenderContext());
+ eps.setStrokeColor(mapper.getMappedColor(param.getColor()));
+ DriverTextEps.drawPathIterator(eps, xpos, ypos, t.getOutline(null).getPathIterator(null));
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/eps/DriverDotPathEps.java b/src/net/sourceforge/plantuml/ugraphic/eps/DriverDotPathEps.java
new file mode 100644
index 0000000..b9ca820
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/eps/DriverDotPathEps.java
@@ -0,0 +1,57 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.eps;
+
+import net.sourceforge.plantuml.eps.EpsGraphics;
+import net.sourceforge.plantuml.posimo.DotPath;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverDotPathEps implements UDriver<EpsGraphics> {
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, EpsGraphics eps) {
+ final DotPath shape = (DotPath) ushape;
+ //DriverLineG2d.manageStroke(param, g2d);
+
+ if (param.getColor() != null) {
+ eps.setStrokeColor(mapper.getMappedColor(param.getColor()));
+ eps.setStrokeWidth("" + param.getStroke().getThickness(), param.getStroke().getDashVisible(), param.getStroke()
+ .getDashSpace());
+ shape.draw(eps, x, y);
+ }
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/eps/DriverEllipseEps.java b/src/net/sourceforge/plantuml/ugraphic/eps/DriverEllipseEps.java
new file mode 100644
index 0000000..da7961a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/eps/DriverEllipseEps.java
@@ -0,0 +1,86 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.eps;
+
+import net.sourceforge.plantuml.eps.EpsGraphics;
+import net.sourceforge.plantuml.ugraphic.ClipContainer;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UClip;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverEllipseEps implements UDriver<EpsGraphics> {
+
+ private final ClipContainer clipContainer;
+
+ public DriverEllipseEps(ClipContainer clipContainer) {
+ this.clipContainer = clipContainer;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, EpsGraphics eps) {
+ final UEllipse shape = (UEllipse) ushape;
+ final double width = shape.getWidth();
+ final double height = shape.getHeight();
+
+ final UClip clip = clipContainer.getClip();
+ if (clip != null) {
+ if (clip.isInside(x, y) == false) {
+ return;
+ }
+ if (clip.isInside(x + width, y + height) == false) {
+ return;
+ }
+ }
+
+ // Shadow
+ if (shape.getDeltaShadow() != 0) {
+ eps.epsEllipseShadow(x + width / 2, y + height / 2, width / 2, height / 2, shape.getDeltaShadow());
+ }
+
+ eps.setFillColor(mapper.getMappedColor(param.getBackcolor()));
+ eps.setStrokeColor(mapper.getMappedColor(param.getColor()));
+ eps.setStrokeWidth("" + param.getStroke().getThickness(), param.getStroke().getDashVisible(), param.getStroke()
+ .getDashSpace());
+
+ if (shape.getStart() == 0 && shape.getExtend() == 0) {
+ eps.epsEllipse(x + width / 2, y + height / 2, width / 2, height / 2);
+ } else {
+ eps.epsEllipse(x + width / 2, y + height / 2, width / 2, height / 2, shape.getStart(), shape.getExtend());
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/eps/DriverImageEps.java b/src/net/sourceforge/plantuml/ugraphic/eps/DriverImageEps.java
new file mode 100644
index 0000000..7beeebe
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/eps/DriverImageEps.java
@@ -0,0 +1,71 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.eps;
+
+import net.sourceforge.plantuml.eps.EpsGraphics;
+import net.sourceforge.plantuml.ugraphic.ClipContainer;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UClip;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UImage;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverImageEps implements UDriver<EpsGraphics> {
+
+ private final ClipContainer clipContainer;
+
+ public DriverImageEps(ClipContainer clipContainer) {
+ this.clipContainer = clipContainer;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, EpsGraphics eps) {
+
+ final UImage shape = (UImage) ushape;
+
+ final UClip clip = clipContainer.getClip();
+ if (clip != null) {
+ if (clip.isInside(x, y) == false) {
+ return;
+ }
+ if (clip.isInside(x + shape.getWidth(), y + shape.getHeight()) == false) {
+ return;
+ }
+ }
+
+ eps.drawImage(shape.getImage(), x, y);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/eps/DriverLineEps.java b/src/net/sourceforge/plantuml/ugraphic/eps/DriverLineEps.java
new file mode 100644
index 0000000..69e7d2b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/eps/DriverLineEps.java
@@ -0,0 +1,79 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.eps;
+
+import java.awt.geom.Line2D;
+
+import net.sourceforge.plantuml.eps.EpsGraphics;
+import net.sourceforge.plantuml.ugraphic.ClipContainer;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UClip;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverLineEps implements UDriver<EpsGraphics> {
+
+ private final ClipContainer clipContainer;
+
+ public DriverLineEps(ClipContainer clipContainer) {
+ this.clipContainer = clipContainer;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, EpsGraphics eps) {
+ final ULine shape = (ULine) ushape;
+
+ double x2 = x + shape.getDX();
+ double y2 = y + shape.getDY();
+
+ final UClip clip = clipContainer.getClip();
+ if (clip != null) {
+ final Line2D.Double line = clip.getClippedLine(new Line2D.Double(x, y, x2, y2));
+ if (line == null) {
+ return;
+ }
+ x = line.x1;
+ y = line.y1;
+ x2 = line.x2;
+ y2 = line.y2;
+ }
+
+ eps.setStrokeColor(mapper.getMappedColor(param.getColor()));
+ eps.setStrokeWidth("" + param.getStroke().getThickness(), param.getStroke().getDashVisible(), param.getStroke()
+ .getDashSpace());
+ eps.epsLine(x, y, x2, y2);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/eps/DriverPathEps.java b/src/net/sourceforge/plantuml/ugraphic/eps/DriverPathEps.java
new file mode 100644
index 0000000..f7f5ad9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/eps/DriverPathEps.java
@@ -0,0 +1,57 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.eps;
+
+import net.sourceforge.plantuml.eps.EpsGraphics;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverPathEps implements UDriver<EpsGraphics> {
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, EpsGraphics eps) {
+ final UPath shape = (UPath) ushape;
+
+ eps.setStrokeColor(mapper.getMappedColor(param.getColor()));
+ eps.setFillColor(mapper.getMappedColor(param.getBackcolor()));
+ eps.setStrokeWidth("" + param.getStroke().getThickness(), param.getStroke().getDashVisible(), param
+ .getStroke().getDashSpace());
+
+ eps.epsPath(x, y, shape);
+
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/eps/DriverPolygonEps.java b/src/net/sourceforge/plantuml/ugraphic/eps/DriverPolygonEps.java
new file mode 100644
index 0000000..dbd6296
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/eps/DriverPolygonEps.java
@@ -0,0 +1,93 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.eps;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.eps.EpsGraphics;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorGradient;
+import net.sourceforge.plantuml.ugraphic.ClipContainer;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UClip;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverPolygonEps implements UDriver<EpsGraphics> {
+
+ private final ClipContainer clipContainer;
+
+ public DriverPolygonEps(ClipContainer clipContainer) {
+ this.clipContainer = clipContainer;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, EpsGraphics eps) {
+ final UPolygon shape = (UPolygon) ushape;
+
+ final double points[] = new double[shape.getPoints().size() * 2];
+ int i = 0;
+
+ for (Point2D pt : shape.getPoints()) {
+ points[i++] = pt.getX() + x;
+ points[i++] = pt.getY() + y;
+ }
+
+ final UClip clip = clipContainer.getClip();
+ if (clip != null) {
+ for (int j = 0; j < points.length; j += 2) {
+ if (clip.isInside(points[j], points[j + 1]) == false) {
+ return;
+ }
+ }
+ }
+
+ if (shape.getDeltaShadow() != 0) {
+ eps.epsPolygonShadow(shape.getDeltaShadow(), points);
+ }
+
+ final HtmlColor back = param.getBackcolor();
+ if (back instanceof HtmlColorGradient) {
+ eps.setStrokeColor(mapper.getMappedColor(param.getColor()));
+ eps.epsPolygon((HtmlColorGradient) back, mapper, points);
+ } else {
+
+ eps.setFillColor(mapper.getMappedColor(back));
+ eps.setStrokeColor(mapper.getMappedColor(param.getColor()));
+ eps.epsPolygon(points);
+ }
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/eps/DriverRectangleEps.java b/src/net/sourceforge/plantuml/ugraphic/eps/DriverRectangleEps.java
new file mode 100644
index 0000000..2707e58
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/eps/DriverRectangleEps.java
@@ -0,0 +1,98 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.eps;
+
+import java.awt.geom.Rectangle2D;
+
+import net.sourceforge.plantuml.eps.EpsGraphics;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorGradient;
+import net.sourceforge.plantuml.ugraphic.ClipContainer;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UClip;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverRectangleEps implements UDriver<EpsGraphics> {
+
+ private final ClipContainer clipContainer;
+
+ public DriverRectangleEps(ClipContainer clipContainer) {
+ this.clipContainer = clipContainer;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, EpsGraphics eps) {
+ final URectangle rect = (URectangle) ushape;
+
+ double width = rect.getWidth();
+ double height = rect.getHeight();
+
+ final UClip clip = clipContainer.getClip();
+ if (clip != null) {
+ final Rectangle2D.Double orig = new Rectangle2D.Double(x, y, width, height);
+ final Rectangle2D.Double r = clip.getClippedRectangle(orig);
+ if (r.height < 0) {
+ return;
+ }
+ x = r.x;
+ y = r.y;
+ width = r.width;
+ height = r.height;
+ }
+
+ final double rx = rect.getRx();
+ final double ry = rect.getRy();
+
+ // Shadow
+ if (rect.getDeltaShadow() != 0) {
+ eps.epsRectangleShadow(x, y, width, height, rx / 2, ry / 2, rect.getDeltaShadow());
+ }
+
+ final HtmlColor back = param.getBackcolor();
+ if (back instanceof HtmlColorGradient) {
+ eps.setStrokeColor(mapper.getMappedColor(param.getColor()));
+ eps.epsRectangle(x, y, width, height, rx / 2, ry / 2, (HtmlColorGradient) back, mapper);
+ } else {
+ eps.setStrokeColor(mapper.getMappedColor(param.getColor()));
+ eps.setFillColor(mapper.getMappedColor(param.getBackcolor()));
+ eps.setStrokeWidth("" + param.getStroke().getThickness(), param.getStroke().getDashVisible(), param
+ .getStroke().getDashSpace());
+ eps.epsRectangle(x, y, width, height, rx / 2, ry / 2);
+ }
+
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/eps/DriverTextEps.java b/src/net/sourceforge/plantuml/ugraphic/eps/DriverTextEps.java
new file mode 100644
index 0000000..8cc6e2c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/eps/DriverTextEps.java
@@ -0,0 +1,225 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.eps;
+
+import java.awt.Color;
+import java.awt.FontMetrics;
+import java.awt.font.FontRenderContext;
+import java.awt.font.TextLayout;
+import java.awt.geom.Dimension2D;
+import java.awt.geom.PathIterator;
+
+import net.sourceforge.plantuml.eps.EpsGraphics;
+import net.sourceforge.plantuml.eps.EpsGraphicsMacroAndText;
+import net.sourceforge.plantuml.eps.EpsStrategy;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.FontStyle;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.ugraphic.ClipContainer;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.MinMax;
+import net.sourceforge.plantuml.ugraphic.UClip;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.ugraphic.UText;
+import net.sourceforge.plantuml.ugraphic.g2d.DriverTextAsPathG2d;
+
+public class DriverTextEps implements UDriver<EpsGraphics> {
+
+ private final StringBounder stringBounder;
+ private final ClipContainer clipContainer;
+ private final FontRenderContext fontRenderContext;
+ private final EpsStrategy strategy;
+
+ public DriverTextEps(ClipContainer clipContainer, EpsStrategy strategy) {
+ this.stringBounder = TextBlockUtils.getDummyStringBounder();
+ this.clipContainer = clipContainer;
+ this.fontRenderContext = TextBlockUtils.getFontRenderContext();
+ this.strategy = strategy;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, EpsGraphics eps) {
+
+ final UClip clip = clipContainer.getClip();
+ if (clip != null && clip.isInside(x, y) == false) {
+ return;
+ }
+
+ final UText shape = (UText) ushape;
+
+ if (strategy == EpsStrategy.WITH_MACRO_AND_TEXT) {
+ drawAsText(shape, x, y, param, eps, mapper);
+ return;
+ }
+
+ final FontConfiguration fontConfiguration = shape.getFontConfiguration();
+ final UFont font = fontConfiguration.getFont();
+
+ final TextLayout t = new TextLayout(shape.getText(), font.getFont(), fontRenderContext);
+
+ MinMax dim = null;
+
+ if (fontConfiguration.containsStyle(FontStyle.BACKCOLOR)) {
+ final Color extended = mapper.getMappedColor(fontConfiguration.getExtendedColor());
+ if (extended != null) {
+ eps.setStrokeColor(extended);
+ eps.setFillColor(extended);
+ eps.setStrokeWidth("1", 0, 0);
+ if (dim == null) {
+ dim = getMinMax(x, y, t.getOutline(null).getPathIterator(null));
+ }
+ eps.epsRectangle(dim.getMinX() - 1, dim.getMinY() - 1, dim.getWidth() + 2, dim.getHeight() + 2, 0, 0);
+ }
+ }
+
+ eps.setStrokeColor(mapper.getMappedColor(fontConfiguration.getColor()));
+ drawPathIterator(eps, x, y, t.getOutline(null).getPathIterator(null));
+
+ if (fontConfiguration.containsStyle(FontStyle.UNDERLINE)) {
+ final HtmlColor extended = fontConfiguration.getExtendedColor();
+ if (extended != null) {
+ eps.setStrokeColor(mapper.getMappedColor(extended));
+ }
+ if (dim == null) {
+ dim = getMinMax(x, y, t.getOutline(null).getPathIterator(null));
+ }
+ eps.setStrokeWidth("1.1", 0, 0);
+ eps.epsLine(x, y + 1.5, x + dim.getWidth(), y + 1.5);
+ eps.setStrokeWidth("1", 0, 0);
+ }
+ if (fontConfiguration.containsStyle(FontStyle.WAVE)) {
+ if (dim == null) {
+ dim = getMinMax(x, y, t.getOutline(null).getPathIterator(null));
+ }
+ final int ypos = (int) (y + 2.5) - 1;
+ final HtmlColor extended = fontConfiguration.getExtendedColor();
+ if (extended != null) {
+ eps.setStrokeColor(mapper.getMappedColor(extended));
+ }
+ eps.setStrokeWidth("1.1", 0, 0);
+ for (int i = (int) x; i < x + dim.getWidth() - 5; i += 6) {
+ eps.epsLine(i, ypos - 0, i + 3, ypos + 1);
+ eps.epsLine(i + 3, ypos + 1, i + 6, ypos - 0);
+ }
+ eps.setStrokeWidth("1", 0, 0);
+ }
+ if (fontConfiguration.containsStyle(FontStyle.STRIKE)) {
+ final HtmlColor extended = fontConfiguration.getExtendedColor();
+ if (extended != null) {
+ eps.setStrokeColor(mapper.getMappedColor(extended));
+ }
+ if (dim == null) {
+ dim = getMinMax(x, y, t.getOutline(null).getPathIterator(null));
+ }
+ // final FontMetrics fm = font.getFontMetrics();
+ final double ypos = (dim.getMinY() + dim.getMaxY() * 2) / 3;
+ eps.setStrokeWidth("1.3", 0, 0);
+ eps.epsLine(x, ypos, x + dim.getWidth(), ypos);
+ eps.setStrokeWidth("1", 0, 0);
+ }
+
+ }
+
+ private void drawAsText(UText shape, double x, double y, UParam param, EpsGraphics eps, ColorMapper mapper) {
+ final FontConfiguration fontConfiguration = shape.getFontConfiguration();
+ // final FontMetrics fm = g2dummy.getFontMetrics(fontConfiguration.getFont().getFont());
+ // final double ypos = y - fm.getDescent() + 0.5;
+ final double ypos = y - 1;
+
+ eps.setStrokeColor(mapper.getMappedColor(fontConfiguration.getColor()));
+ ((EpsGraphicsMacroAndText) eps).drawText(shape.getText(), fontConfiguration, x, ypos);
+
+ }
+
+ static void drawPathIterator(EpsGraphics eps, double x, double y, PathIterator path) {
+
+ eps.newpath();
+ final double coord[] = new double[6];
+ while (path.isDone() == false) {
+ final int code = path.currentSegment(coord);
+ if (code == PathIterator.SEG_MOVETO) {
+ eps.moveto(coord[0] + x, coord[1] + y);
+ } else if (code == PathIterator.SEG_LINETO) {
+ eps.lineto(coord[0] + x, coord[1] + y);
+ } else if (code == PathIterator.SEG_CLOSE) {
+ eps.closepath();
+ } else if (code == PathIterator.SEG_CUBICTO) {
+ eps.curveto(coord[0] + x, coord[1] + y, coord[2] + x, coord[3] + y, coord[4] + x, coord[5] + y);
+ } else if (code == PathIterator.SEG_QUADTO) {
+ eps.quadto(coord[0] + x, coord[1] + y, coord[2] + x, coord[3] + y);
+ } else {
+ throw new UnsupportedOperationException("code=" + code);
+ }
+
+ path.next();
+ }
+
+ eps.fill(path.getWindingRule());
+
+ }
+
+ static private MinMax getMinMax(double x, double y, PathIterator path) {
+
+ MinMax result = MinMax.getEmpty(false);
+
+ final double coord[] = new double[6];
+ while (path.isDone() == false) {
+ final int code = path.currentSegment(coord);
+ if (code == PathIterator.SEG_MOVETO) {
+ result = result.addPoint(coord[0] + x, coord[1] + y);
+ } else if (code == PathIterator.SEG_LINETO) {
+ result = result.addPoint(coord[0] + x, coord[1] + y);
+ } else if (code == PathIterator.SEG_CLOSE) {
+ } else if (code == PathIterator.SEG_CUBICTO) {
+ result = result.addPoint(coord[0] + x, coord[1] + y);
+ result = result.addPoint(coord[2] + x, coord[3] + y);
+ result = result.addPoint(coord[4] + x, coord[5] + y);
+ } else if (code == PathIterator.SEG_QUADTO) {
+ result = result.addPoint(coord[0] + x, coord[1] + y);
+ result = result.addPoint(coord[2] + x, coord[3] + y);
+ } else {
+ throw new UnsupportedOperationException("code=" + code);
+ }
+ path.next();
+ }
+
+ return result;
+
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/eps/UGraphicEps.java b/src/net/sourceforge/plantuml/ugraphic/eps/UGraphicEps.java
new file mode 100644
index 0000000..2762ba8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/eps/UGraphicEps.java
@@ -0,0 +1,143 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.eps;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.eps.EpsGraphics;
+import net.sourceforge.plantuml.eps.EpsStrategy;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.posimo.DotPath;
+import net.sourceforge.plantuml.ugraphic.AbstractCommonUGraphic;
+import net.sourceforge.plantuml.ugraphic.AbstractUGraphic;
+import net.sourceforge.plantuml.ugraphic.ClipContainer;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UCenteredCharacter;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic2;
+import net.sourceforge.plantuml.ugraphic.UImage;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UText;
+
+public class UGraphicEps extends AbstractUGraphic<EpsGraphics> implements ClipContainer, UGraphic2 {
+
+ private final StringBounder stringBounder;
+
+ private final EpsStrategy strategyTOBEREMOVED;
+
+ @Override
+ protected AbstractCommonUGraphic copyUGraphic() {
+ return new UGraphicEps(this);
+ }
+
+ protected UGraphicEps(UGraphicEps other) {
+ super(other);
+ this.stringBounder = other.stringBounder;
+ this.strategyTOBEREMOVED = other.strategyTOBEREMOVED;
+ register(strategyTOBEREMOVED);
+ }
+
+ public UGraphicEps(ColorMapper colorMapper, EpsStrategy strategy) {
+ this(colorMapper, strategy, strategy.creatEpsGraphics());
+ }
+
+ private UGraphicEps(ColorMapper colorMapper, EpsStrategy strategy, EpsGraphics eps) {
+ super(colorMapper, eps);
+ this.strategyTOBEREMOVED = strategy;
+ this.stringBounder = TextBlockUtils.getDummyStringBounder();
+ register(strategy);
+ }
+
+ private void register(EpsStrategy strategy) {
+ registerDriver(URectangle.class, new DriverRectangleEps(this));
+ registerDriver(UText.class, new DriverTextEps(this, strategy));
+ registerDriver(ULine.class, new DriverLineEps(this));
+ registerDriver(UPolygon.class, new DriverPolygonEps(this));
+ registerDriver(UEllipse.class, new DriverEllipseEps(this));
+ registerDriver(UImage.class, new DriverImageEps(this));
+ registerDriver(UPath.class, new DriverPathEps());
+ registerDriver(DotPath.class, new DriverDotPathEps());
+ registerDriver(UCenteredCharacter.class, new DriverCenteredCharacterEps());
+ }
+
+ public void close() {
+ getEpsGraphics().close();
+ }
+
+ public String getEPSCode() {
+ return getEpsGraphics().getEPSCode();
+ }
+
+ public EpsGraphics getEpsGraphics() {
+ return this.getGraphicObject();
+ }
+
+ public StringBounder getStringBounder() {
+ return stringBounder;
+ }
+
+ public void drawEps(String eps, double x, double y) {
+ this.getGraphicObject().drawEps(eps, x, y);
+ }
+
+ static public String getEpsString(ColorMapper colorMapper, EpsStrategy epsStrategy, UDrawable udrawable)
+ throws IOException {
+ final UGraphicEps ug = new UGraphicEps(colorMapper, epsStrategy);
+ udrawable.drawU(ug);
+ return ug.getEPSCode();
+ }
+
+ public void startUrl(Url url) {
+ getGraphicObject().openLink(url.getUrl());
+ }
+
+ public void closeAction() {
+ getGraphicObject().closeLink();
+ }
+
+ public void writeImageTOBEMOVED(OutputStream os, String metadata, int dpi) throws IOException {
+ os.write(getEPSCode().getBytes());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/g2d/DriverCenteredCharacterG2d.java b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverCenteredCharacterG2d.java
new file mode 100644
index 0000000..e206fc2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverCenteredCharacterG2d.java
@@ -0,0 +1,63 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.g2d;
+
+import java.awt.Graphics2D;
+
+import net.sourceforge.plantuml.graphic.UnusedSpace;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UCenteredCharacter;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverCenteredCharacterG2d implements UDriver<Graphics2D> {
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, Graphics2D g2d) {
+ final UCenteredCharacter characterCircled = (UCenteredCharacter) ushape;
+ final char c = characterCircled.getChar();
+ final UFont font = characterCircled.getFont();
+ final UnusedSpace unusedSpace = UnusedSpace.getUnusedSpace(font, c);
+
+ g2d.setColor(mapper.getMappedColor(param.getColor()));
+ final double xpos = x - unusedSpace.getCenterX();
+ final double ypos = y - unusedSpace.getCenterY() - 0.5;
+
+ g2d.setFont(font.getFont());
+ g2d.drawString("" + c, (float) xpos, (float) ypos);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/g2d/DriverDotPathG2d.java b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverDotPathG2d.java
new file mode 100644
index 0000000..862b943
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverDotPathG2d.java
@@ -0,0 +1,64 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.g2d;
+
+import java.awt.Graphics2D;
+
+import net.sourceforge.plantuml.EnsureVisible;
+import net.sourceforge.plantuml.posimo.DotPath;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverDotPathG2d implements UDriver<Graphics2D> {
+
+ private final EnsureVisible visible;
+
+ public DriverDotPathG2d(EnsureVisible visible) {
+ this.visible = visible;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, Graphics2D g2d) {
+ final DotPath shape = (DotPath) ushape;
+ DriverLineG2d.manageStroke(param, g2d);
+
+ if (param.getColor() != null) {
+ g2d.setColor(mapper.getMappedColor(param.getColor()));
+ shape.draw(g2d, x, y);
+ shape.manageEnsureVisible(x, y, visible);
+ }
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/g2d/DriverEllipseG2d.java b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverEllipseG2d.java
new file mode 100644
index 0000000..277a65d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverEllipseG2d.java
@@ -0,0 +1,143 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.g2d;
+
+import java.awt.BasicStroke;
+import java.awt.GradientPaint;
+import java.awt.Graphics2D;
+import java.awt.Shape;
+import java.awt.geom.Arc2D;
+import java.awt.geom.Ellipse2D;
+
+import net.sourceforge.plantuml.EnsureVisible;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorGradient;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverEllipseG2d extends DriverShadowedG2d implements UDriver<Graphics2D> {
+
+ private final double dpiFactor;
+ private final EnsureVisible visible;
+
+ public DriverEllipseG2d(double dpiFactor, EnsureVisible visible) {
+ this.dpiFactor = dpiFactor;
+ this.visible = visible;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, Graphics2D g2d) {
+ final UEllipse shape = (UEllipse) ushape;
+ g2d.setStroke(new BasicStroke((float) param.getStroke().getThickness()));
+ visible.ensureVisible(x, y);
+ visible.ensureVisible(x + shape.getWidth(), y + shape.getHeight());
+ if (shape.getStart() == 0 && shape.getExtend() == 0) {
+ final Shape ellipse = new Ellipse2D.Double(x, y, shape.getWidth(), shape.getHeight());
+
+ // Shadow
+ if (shape.getDeltaShadow() != 0) {
+ drawShadow(g2d, ellipse, shape.getDeltaShadow(), dpiFactor);
+ }
+
+ final HtmlColor back = param.getBackcolor();
+ if (back instanceof HtmlColorGradient) {
+ final GradientPaint paint = getPaintGradient(x, y, mapper, shape, back);
+ g2d.setPaint(paint);
+ g2d.fill(ellipse);
+
+ if (param.getColor() != null) {
+ g2d.setColor(mapper.getMappedColor(param.getColor()));
+ DriverLineG2d.manageStroke(param, g2d);
+ g2d.draw(ellipse);
+ }
+ } else {
+ if (back != null) {
+ g2d.setColor(mapper.getMappedColor(param.getBackcolor()));
+ DriverRectangleG2d.managePattern(param, g2d);
+ g2d.fill(ellipse);
+ }
+ if (param.getColor() != null && param.getColor().equals(param.getBackcolor()) == false) {
+ g2d.setColor(mapper.getMappedColor(param.getColor()));
+ DriverLineG2d.manageStroke(param, g2d);
+ g2d.draw(ellipse);
+ }
+ }
+ } else {
+ final Shape arc = new Arc2D.Double(x, y, shape.getWidth(), shape.getHeight(), round(shape.getStart()),
+ round(shape.getExtend()), Arc2D.OPEN);
+ if (param.getColor() != null) {
+ g2d.setColor(mapper.getMappedColor(param.getColor()));
+ g2d.draw(arc);
+ }
+ }
+ }
+
+ private GradientPaint getPaintGradient(double x, double y, ColorMapper mapper, final UEllipse shape,
+ final HtmlColor back) {
+ final HtmlColorGradient gr = (HtmlColorGradient) back;
+ final char policy = gr.getPolicy();
+ final GradientPaint paint;
+ if (policy == '|') {
+ paint = new GradientPaint((float) x, (float) (y + shape.getHeight()) / 2, mapper.getMappedColor(gr
+ .getColor1()), (float) (x + shape.getWidth()), (float) (y + shape.getHeight()) / 2,
+ mapper.getMappedColor(gr.getColor2()));
+ } else if (policy == '\\') {
+ paint = new GradientPaint((float) x, (float) (y + shape.getHeight()), mapper.getMappedColor(gr
+ .getColor1()), (float) (x + shape.getWidth()), (float) y, mapper.getMappedColor(gr.getColor2()));
+ } else if (policy == '-') {
+ paint = new GradientPaint((float) (x + shape.getWidth()) / 2, (float) y, mapper.getMappedColor(gr
+ .getColor1()), (float) (x + shape.getWidth()) / 2, (float) (y + shape.getHeight()),
+ mapper.getMappedColor(gr.getColor2()));
+ } else {
+ // for /
+ paint = new GradientPaint((float) x, (float) y, mapper.getMappedColor(gr.getColor1()),
+ (float) (x + shape.getWidth()), (float) (y + shape.getHeight()), mapper.getMappedColor(gr
+ .getColor2()));
+ }
+ return paint;
+ }
+
+
+ private static final double ROU = 5.0;
+
+ static double round(double value) {
+ return value;
+ // final int v = (int) Math.round(value / ROU);
+ // return v * ROU;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/g2d/DriverImageG2d.java b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverImageG2d.java
new file mode 100644
index 0000000..f63979e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverImageG2d.java
@@ -0,0 +1,61 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.g2d;
+
+import java.awt.Graphics2D;
+
+import net.sourceforge.plantuml.EnsureVisible;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UImage;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverImageG2d implements UDriver<Graphics2D> {
+
+ private final EnsureVisible visible;
+
+ public DriverImageG2d(EnsureVisible visible) {
+ this.visible = visible;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, Graphics2D g2d) {
+ final UImage shape = (UImage) ushape;
+ visible.ensureVisible(x, y);
+ visible.ensureVisible(x + shape.getWidth(), y + shape.getHeight());
+ g2d.drawImage(shape.getImage(), (int) x, (int) y, null);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/g2d/DriverLineG2d.java b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverLineG2d.java
new file mode 100644
index 0000000..26472f3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverLineG2d.java
@@ -0,0 +1,82 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.g2d;
+
+import java.awt.BasicStroke;
+import java.awt.Graphics2D;
+import java.awt.Shape;
+import java.awt.geom.Line2D;
+
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+
+public class DriverLineG2d extends DriverShadowedG2d implements UDriver<Graphics2D> {
+
+ private final double dpiFactor;
+
+ public DriverLineG2d(double dpiFactor) {
+ this.dpiFactor = dpiFactor;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, Graphics2D g2d) {
+ final ULine shape = (ULine) ushape;
+
+ final Shape line = new Line2D.Double(x, y, x + shape.getDX(), y + shape.getDY());
+ manageStroke(param, g2d);
+ // Shadow
+ if (shape.getDeltaShadow() != 0) {
+ drawShadow(g2d, line, shape.getDeltaShadow(), dpiFactor);
+ }
+ g2d.setColor(mapper.getMappedColor(param.getColor()));
+ g2d.draw(line);
+ }
+
+ static void manageStroke(UParam param, Graphics2D g2d) {
+ final UStroke stroke = param.getStroke();
+ final float thickness = (float) (stroke.getThickness() * param.getScale());
+ if (stroke.getDashVisible() == 0) {
+ g2d.setStroke(new BasicStroke(thickness));
+ } else {
+ final float dash1 = (float) stroke.getDashVisible();
+ final float dash2 = (float) stroke.getDashSpace();
+ final float[] style = { dash1, dash2 };
+ g2d.setStroke(new BasicStroke(thickness, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, style, 0));
+ }
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/g2d/DriverPathG2d.java b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverPathG2d.java
new file mode 100644
index 0000000..6982ade
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverPathG2d.java
@@ -0,0 +1,158 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.g2d;
+
+import java.awt.GradientPaint;
+import java.awt.Graphics2D;
+import java.awt.Shape;
+import java.awt.geom.Line2D;
+
+import net.sourceforge.plantuml.golem.MinMaxDouble;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorGradient;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.USegment;
+import net.sourceforge.plantuml.ugraphic.USegmentType;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.ugraphic.arc.ExtendedGeneralPath;
+
+public class DriverPathG2d extends DriverShadowedG2d implements UDriver<Graphics2D> {
+
+ private final double dpiFactor;
+
+ public DriverPathG2d(double dpiFactor) {
+ this.dpiFactor = dpiFactor;
+ }
+
+ public void draw(UShape ushape, final double x, final double y, ColorMapper mapper, UParam param, Graphics2D g2d) {
+ final UPath shape = (UPath) ushape;
+ DriverLineG2d.manageStroke(param, g2d);
+
+ final ExtendedGeneralPath p = new ExtendedGeneralPath();
+ final MinMaxDouble minMax = new MinMaxDouble();
+ minMax.manage(x, y);
+ boolean hasBezier = false;
+ for (USegment seg : shape) {
+ final USegmentType type = seg.getSegmentType();
+ final double coord[] = seg.getCoord();
+ if (type == USegmentType.SEG_MOVETO) {
+ p.moveTo(x + coord[0], y + coord[1]);
+ minMax.manage(x + coord[0], y + coord[1]);
+ } else if (type == USegmentType.SEG_LINETO) {
+ p.lineTo(x + coord[0], y + coord[1]);
+ minMax.manage(x + coord[0], y + coord[1]);
+ } else if (type == USegmentType.SEG_CUBICTO) {
+ p.curveTo(x + coord[0], y + coord[1], x + coord[2], y + coord[3], x + coord[4], y + coord[5]);
+ minMax.manage(x + coord[4], y + coord[5]);
+ hasBezier = true;
+ } else if (type == USegmentType.SEG_ARCTO) {
+ p.arcTo(coord[0], coord[1], coord[2], coord[3] != 0, coord[4] != 0, x + coord[5], y + coord[6]);
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ if (shape.isOpenIconic()) {
+ p.closePath();
+ g2d.setColor(mapper.getMappedColor(param.getColor()));
+ g2d.fill(p);
+ return;
+ }
+
+ // Shadow
+ if (shape.getDeltaShadow() != 0) {
+ if (hasBezier) {
+ drawShadow(g2d, p, shape.getDeltaShadow(), dpiFactor);
+ } else {
+ double lastX = 0;
+ double lastY = 0;
+ for (USegment seg : shape) {
+ final USegmentType type = seg.getSegmentType();
+ final double coord[] = seg.getCoord();
+ // Cast float for Java 1.5
+ if (type == USegmentType.SEG_MOVETO) {
+ lastX = x + coord[0];
+ lastY = y + coord[1];
+ } else if (type == USegmentType.SEG_LINETO) {
+ final Shape line = new Line2D.Double(lastX, lastY, x + coord[0], y + coord[1]);
+ drawShadow(g2d, line, shape.getDeltaShadow(), dpiFactor);
+ lastX = x + coord[0];
+ lastY = y + coord[1];
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ }
+ }
+ }
+
+ final HtmlColor back = param.getBackcolor();
+ if (back instanceof HtmlColorGradient) {
+ final HtmlColorGradient gr = (HtmlColorGradient) back;
+ final char policy = gr.getPolicy();
+ final GradientPaint paint;
+ if (policy == '|') {
+ paint = new GradientPaint((float) minMax.getMinX(), (float) minMax.getMaxY() / 2,
+ mapper.getMappedColor(gr.getColor1()), (float) minMax.getMaxX(), (float) minMax.getMaxY() / 2,
+ mapper.getMappedColor(gr.getColor2()));
+ } else if (policy == '\\') {
+ paint = new GradientPaint((float) minMax.getMinX(), (float) minMax.getMaxY(), mapper.getMappedColor(gr
+ .getColor1()), (float) minMax.getMaxX(), (float) minMax.getMinY(), mapper.getMappedColor(gr
+ .getColor2()));
+ } else if (policy == '-') {
+ paint = new GradientPaint((float) minMax.getMaxX() / 2, (float) minMax.getMinY(),
+ mapper.getMappedColor(gr.getColor1()), (float) minMax.getMaxX() / 2, (float) minMax.getMaxY(),
+ mapper.getMappedColor(gr.getColor2()));
+ } else {
+ // for /
+ paint = new GradientPaint((float) x, (float) y, mapper.getMappedColor(gr.getColor1()),
+ (float) minMax.getMaxX(), (float) minMax.getMaxY(), mapper.getMappedColor(gr.getColor2()));
+ }
+ g2d.setPaint(paint);
+ g2d.fill(p);
+ } else if (back != null) {
+ g2d.setColor(mapper.getMappedColor(back));
+ g2d.fill(p);
+ }
+
+ if (param.getColor() != null) {
+ g2d.setColor(mapper.getMappedColor(param.getColor()));
+ g2d.draw(p);
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/g2d/DriverPathG2dLegacy.java b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverPathG2dLegacy.java
new file mode 100644
index 0000000..7a5a324
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverPathG2dLegacy.java
@@ -0,0 +1,157 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.g2d;
+
+import java.awt.GradientPaint;
+import java.awt.Graphics2D;
+import java.awt.Shape;
+import java.awt.geom.GeneralPath;
+import java.awt.geom.Line2D;
+import java.awt.geom.Path2D;
+
+import net.sourceforge.plantuml.golem.MinMaxDouble;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorGradient;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.USegment;
+import net.sourceforge.plantuml.ugraphic.USegmentType;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverPathG2dLegacy extends DriverShadowedG2d implements UDriver<Graphics2D> {
+
+ private final double dpiFactor;
+
+ public DriverPathG2dLegacy(double dpiFactor) {
+ this.dpiFactor = dpiFactor;
+ }
+
+ public void draw(UShape ushape, final double x, final double y, ColorMapper mapper, UParam param, Graphics2D g2d) {
+ final UPath shape = (UPath) ushape;
+ DriverLineG2d.manageStroke(param, g2d);
+
+ final Path2D.Double p = new Path2D.Double();
+ boolean hasBezier = false;
+ final MinMaxDouble minMax = new MinMaxDouble();
+ minMax.manage(x, y);
+ for (USegment seg : shape) {
+ final USegmentType type = seg.getSegmentType();
+ final double coord[] = seg.getCoord();
+ if (type == USegmentType.SEG_MOVETO) {
+ p.moveTo(x + coord[0], y + coord[1]);
+ minMax.manage(x + coord[0], y + coord[1]);
+ } else if (type == USegmentType.SEG_LINETO) {
+ p.lineTo(x + coord[0], y + coord[1]);
+ minMax.manage(x + coord[0], y + coord[1]);
+ } else if (type == USegmentType.SEG_CUBICTO) {
+ p.curveTo(x + coord[0], y + coord[1], x + coord[2], y + coord[3], x + coord[4], y + coord[5]);
+ minMax.manage(x + coord[4], y + coord[5]);
+ hasBezier = true;
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ if (shape.isOpenIconic()) {
+ p.closePath();
+ g2d.setColor(mapper.getMappedColor(param.getColor()));
+ g2d.fill(p);
+ return;
+ }
+
+ // Shadow
+ if (shape.getDeltaShadow() != 0) {
+ if (hasBezier) {
+ drawShadow(g2d, p, shape.getDeltaShadow(), dpiFactor);
+ } else {
+ double lastX = 0;
+ double lastY = 0;
+ for (USegment seg : shape) {
+ final USegmentType type = seg.getSegmentType();
+ final double coord[] = seg.getCoord();
+ // Cast float for Java 1.5
+ if (type == USegmentType.SEG_MOVETO) {
+ lastX = x + coord[0];
+ lastY = y + coord[1];
+ } else if (type == USegmentType.SEG_LINETO) {
+ final Shape line = new Line2D.Double(lastX, lastY, x + coord[0], y + coord[1]);
+ drawShadow(g2d, line, shape.getDeltaShadow(), dpiFactor);
+ lastX = x + coord[0];
+ lastY = y + coord[1];
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ }
+ }
+ }
+
+ final HtmlColor back = param.getBackcolor();
+ if (back instanceof HtmlColorGradient) {
+ final HtmlColorGradient gr = (HtmlColorGradient) back;
+ final char policy = gr.getPolicy();
+ final GradientPaint paint;
+ if (policy == '|') {
+ paint = new GradientPaint((float) minMax.getMinX(), (float) minMax.getMaxY() / 2,
+ mapper.getMappedColor(gr.getColor1()), (float) minMax.getMaxX(), (float) minMax.getMaxY() / 2,
+ mapper.getMappedColor(gr.getColor2()));
+ } else if (policy == '\\') {
+ paint = new GradientPaint((float) minMax.getMinX(), (float) minMax.getMaxY(), mapper.getMappedColor(gr
+ .getColor1()), (float) minMax.getMaxX(), (float) minMax.getMinY(), mapper.getMappedColor(gr
+ .getColor2()));
+ } else if (policy == '-') {
+ paint = new GradientPaint((float) minMax.getMaxX() / 2, (float) minMax.getMinY(),
+ mapper.getMappedColor(gr.getColor1()), (float) minMax.getMaxX() / 2, (float) minMax.getMaxY(),
+ mapper.getMappedColor(gr.getColor2()));
+ } else {
+ // for /
+ paint = new GradientPaint((float) x, (float) y, mapper.getMappedColor(gr.getColor1()),
+ (float) minMax.getMaxX(), (float) minMax.getMaxY(), mapper.getMappedColor(gr.getColor2()));
+ }
+ g2d.setPaint(paint);
+ g2d.fill(p);
+ } else if (back != null) {
+ g2d.setColor(mapper.getMappedColor(back));
+ g2d.fill(p);
+ }
+
+ if (param.getColor() != null) {
+ g2d.setColor(mapper.getMappedColor(param.getColor()));
+ g2d.draw(p);
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/g2d/DriverPathOldG2d.java b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverPathOldG2d.java
new file mode 100644
index 0000000..02a9e96
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverPathOldG2d.java
@@ -0,0 +1,156 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.g2d;
+
+import java.awt.GradientPaint;
+import java.awt.Graphics2D;
+import java.awt.Shape;
+import java.awt.geom.GeneralPath;
+import java.awt.geom.Line2D;
+
+import net.sourceforge.plantuml.golem.MinMaxDouble;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorGradient;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.USegment;
+import net.sourceforge.plantuml.ugraphic.USegmentType;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverPathOldG2d extends DriverShadowedG2d implements UDriver<Graphics2D> {
+
+ private final double dpiFactor;
+
+ public DriverPathOldG2d(double dpiFactor) {
+ this.dpiFactor = dpiFactor;
+ }
+
+ public void draw(UShape ushape, final double x, final double y, ColorMapper mapper, UParam param, Graphics2D g2d) {
+ final UPath shape = (UPath) ushape;
+ DriverLineG2d.manageStroke(param, g2d);
+
+ final GeneralPath p = new GeneralPath();
+ boolean hasBezier = false;
+ final MinMaxDouble minMax = new MinMaxDouble();
+ minMax.manage(x, y);
+ for (USegment seg : shape) {
+ final USegmentType type = seg.getSegmentType();
+ final double coord[] = seg.getCoord();
+ // Cast float for Java 1.5
+ if (type == USegmentType.SEG_MOVETO) {
+ p.moveTo((float) (x + coord[0]), (float) (y + coord[1]));
+ minMax.manage(x + coord[0], y + coord[1]);
+ } else if (type == USegmentType.SEG_LINETO) {
+ p.lineTo((float) (x + coord[0]), (float) (y + coord[1]));
+ minMax.manage(x + coord[0], y + coord[1]);
+ } else if (type == USegmentType.SEG_CUBICTO) {
+ p.curveTo((float) (x + coord[0]), (float) (y + coord[1]), (float) (x + coord[2]),
+ (float) (y + coord[3]), (float) (x + coord[4]), (float) (y + coord[5]));
+ minMax.manage(x + coord[4], y + coord[5]);
+ hasBezier = true;
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ // bez = new CubicCurve2D.Double(x + bez.x1, y + bez.y1, x +
+ // bez.ctrlx1, y + bez.ctrly1, x + bez.ctrlx2, y
+ // + bez.ctrly2, x + bez.x2, y + bez.y2);
+ // p.append(bez, true);
+ }
+ // p.closePath();
+
+ // Shadow
+ if (shape.getDeltaShadow() != 0) {
+ if (hasBezier) {
+ drawShadow(g2d, p, shape.getDeltaShadow(), dpiFactor);
+ } else {
+ double lastX = 0;
+ double lastY = 0;
+ for (USegment seg : shape) {
+ final USegmentType type = seg.getSegmentType();
+ final double coord[] = seg.getCoord();
+ // Cast float for Java 1.5
+ if (type == USegmentType.SEG_MOVETO) {
+ lastX = x + coord[0];
+ lastY = y + coord[1];
+ } else if (type == USegmentType.SEG_LINETO) {
+ final Shape line = new Line2D.Double(lastX, lastY, x + coord[0], y + coord[1]);
+ drawShadow(g2d, line, shape.getDeltaShadow(), dpiFactor);
+ lastX = x + coord[0];
+ lastY = y + coord[1];
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ }
+ }
+ }
+
+ final HtmlColor back = param.getBackcolor();
+ if (back instanceof HtmlColorGradient) {
+ final HtmlColorGradient gr = (HtmlColorGradient) back;
+ final char policy = gr.getPolicy();
+ final GradientPaint paint;
+ if (policy == '|') {
+ paint = new GradientPaint((float) minMax.getMinX(), (float) minMax.getMaxY() / 2,
+ mapper.getMappedColor(gr.getColor1()), (float) minMax.getMaxX(), (float) minMax.getMaxY() / 2,
+ mapper.getMappedColor(gr.getColor2()));
+ } else if (policy == '\\') {
+ paint = new GradientPaint((float) minMax.getMinX(), (float) minMax.getMaxY(), mapper.getMappedColor(gr
+ .getColor1()), (float) minMax.getMaxX(), (float) minMax.getMinY(), mapper.getMappedColor(gr
+ .getColor2()));
+ } else if (policy == '-') {
+ paint = new GradientPaint((float) minMax.getMaxX() / 2, (float) minMax.getMinY(),
+ mapper.getMappedColor(gr.getColor1()), (float) minMax.getMaxX() / 2, (float) minMax.getMaxY(),
+ mapper.getMappedColor(gr.getColor2()));
+ } else {
+ // for /
+ paint = new GradientPaint((float) x, (float) y, mapper.getMappedColor(gr.getColor1()),
+ (float) minMax.getMaxX(), (float) minMax.getMaxY(), mapper.getMappedColor(gr.getColor2()));
+ }
+ g2d.setPaint(paint);
+ g2d.fill(p);
+ } else if (back != null) {
+ g2d.setColor(mapper.getMappedColor(back));
+ g2d.fill(p);
+ }
+
+ if (param.getColor() != null) {
+ g2d.setColor(mapper.getMappedColor(param.getColor()));
+ g2d.draw(p);
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/g2d/DriverPixelG2d.java b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverPixelG2d.java
new file mode 100644
index 0000000..d3c376e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverPixelG2d.java
@@ -0,0 +1,51 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.g2d;
+
+import java.awt.Graphics2D;
+
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverPixelG2d implements UDriver<Graphics2D> {
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, Graphics2D g2d) {
+ g2d.setColor(mapper.getMappedColor(param.getColor()));
+ g2d.fillRect((int) x, (int) y, 1, 1);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/g2d/DriverPolygonG2d.java b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverPolygonG2d.java
new file mode 100644
index 0000000..90feb50
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverPolygonG2d.java
@@ -0,0 +1,127 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.g2d;
+
+import java.awt.BasicStroke;
+import java.awt.GradientPaint;
+import java.awt.Graphics2D;
+import java.awt.geom.GeneralPath;
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.EnsureVisible;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorGradient;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverPolygonG2d extends DriverShadowedG2d implements UDriver<Graphics2D> {
+
+ private final double dpiFactor;
+ private final EnsureVisible visible;
+
+ public DriverPolygonG2d(double dpiFactor, EnsureVisible visible) {
+ this.dpiFactor = dpiFactor;
+ this.visible = visible;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, Graphics2D g2d) {
+ final UPolygon shape = (UPolygon) ushape;
+
+ g2d.setStroke(new BasicStroke((float) param.getStroke().getThickness()));
+
+ final GeneralPath path = new GeneralPath();
+
+ boolean first = true;
+ for (Point2D pt : shape.getPoints()) {
+ final double xp = pt.getX() + x;
+ final double yp = pt.getY() + y;
+ visible.ensureVisible(xp, yp);
+ if (first) {
+ path.moveTo((float) xp, (float) yp);
+ } else {
+ path.lineTo((float) xp, (float) yp);
+ }
+ first = false;
+ }
+
+ if (first == false) {
+ path.closePath();
+ }
+
+ if (shape.getDeltaShadow() != 0) {
+ drawShadow(g2d, path, shape.getDeltaShadow(), dpiFactor);
+ }
+
+ final HtmlColor back = param.getBackcolor();
+ if (back instanceof HtmlColorGradient) {
+ final HtmlColorGradient gr = (HtmlColorGradient) back;
+ final char policy = gr.getPolicy();
+ final GradientPaint paint;
+// final Rectangle2D bound = path.getBounds();
+ if (policy == '|') {
+ paint = new GradientPaint((float) x, (float) (y + shape.getHeight()) / 2, mapper.getMappedColor(gr
+ .getColor1()), (float) (x + shape.getWidth()), (float) (y + shape.getHeight()) / 2,
+ mapper.getMappedColor(gr.getColor2()));
+ } else if (policy == '\\') {
+ paint = new GradientPaint((float) x, (float) (y + shape.getHeight()), mapper.getMappedColor(gr
+ .getColor1()), (float) (x + shape.getWidth()), (float) y, mapper.getMappedColor(gr.getColor2()));
+ } else if (policy == '-') {
+ paint = new GradientPaint((float) (x + shape.getWidth()) / 2, (float) y, mapper.getMappedColor(gr
+ .getColor1()), (float) (x + shape.getWidth()) / 2, (float) (y + shape.getHeight()),
+ mapper.getMappedColor(gr.getColor2()));
+ } else {
+ // for /
+ paint = new GradientPaint((float) x, (float) y, mapper.getMappedColor(gr.getColor1()),
+ (float) (x + shape.getWidth()), (float) (y + shape.getHeight()), mapper.getMappedColor(gr
+ .getColor2()));
+ }
+ g2d.setPaint(paint);
+ g2d.fill(path);
+ } else if (back!=null) {
+ g2d.setColor(mapper.getMappedColor(back));
+ DriverRectangleG2d.managePattern(param, g2d);
+ g2d.fill(path);
+ }
+
+ if (param.getColor() != null) {
+ g2d.setColor(mapper.getMappedColor(param.getColor()));
+ DriverLineG2d.manageStroke(param, g2d);
+ g2d.draw(path);
+ }
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/g2d/DriverRectangleG2d.java b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverRectangleG2d.java
new file mode 100644
index 0000000..9c9faff
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverRectangleG2d.java
@@ -0,0 +1,179 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.g2d;
+
+import java.awt.BasicStroke;
+import java.awt.GradientPaint;
+import java.awt.Graphics2D;
+import java.awt.Rectangle;
+import java.awt.Shape;
+import java.awt.TexturePaint;
+import java.awt.geom.Rectangle2D;
+import java.awt.geom.RoundRectangle2D;
+import java.awt.image.BufferedImage;
+
+import net.sourceforge.plantuml.EnsureVisible;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorGradient;
+import net.sourceforge.plantuml.graphic.HtmlColorSimple;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UPattern;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverRectangleG2d extends DriverShadowedG2d implements UDriver<Graphics2D> {
+
+ private final double dpiFactor;
+ private final EnsureVisible visible;
+
+ public DriverRectangleG2d(double dpiFactor, EnsureVisible visible) {
+ this.dpiFactor = dpiFactor;
+ this.visible = visible;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, Graphics2D g2d) {
+ g2d.setStroke(new BasicStroke((float) param.getStroke().getThickness()));
+ final URectangle shape = (URectangle) ushape;
+ final double rx = shape.getRx();
+ final double ry = shape.getRy();
+ final Shape rect;
+ if (rx == 0 && ry == 0) {
+ rect = new Rectangle2D.Double(x, y, shape.getWidth(), shape.getHeight());
+ } else {
+ rect = new RoundRectangle2D.Double(x, y, shape.getWidth(), shape.getHeight(), rx, ry);
+ }
+
+ visible.ensureVisible(x, y);
+ visible.ensureVisible(x + shape.getWidth(), y + shape.getHeight());
+
+ // Shadow
+ if (shape.getDeltaShadow() != 0) {
+ drawShadow(g2d, rect, shape.getDeltaShadow(), dpiFactor);
+ }
+
+ final HtmlColor back = param.getBackcolor();
+ if (back instanceof HtmlColorGradient) {
+ final GradientPaint paint = getPaintGradient(x, y, mapper, shape, back);
+ g2d.setPaint(paint);
+ g2d.fill(rect);
+
+ if (param.getColor() != null && param.getColor() instanceof HtmlColorGradient == false) {
+ g2d.setColor(mapper.getMappedColor(param.getColor()));
+ DriverLineG2d.manageStroke(param, g2d);
+ g2d.draw(rect);
+ }
+
+ } else {
+ if (param.getBackcolor() != null) {
+ g2d.setColor(mapper.getMappedColor(param.getBackcolor()));
+ DriverLineG2d.manageStroke(param, g2d);
+ managePattern(param, g2d);
+ g2d.fill(rect);
+ }
+ if (param.getColor() != null && param.getColor().equals(param.getBackcolor()) == false) {
+ g2d.setColor(mapper.getMappedColor(param.getColor()));
+ DriverLineG2d.manageStroke(param, g2d);
+ g2d.draw(rect);
+ }
+ }
+ }
+
+ private GradientPaint getPaintGradient(double x, double y, ColorMapper mapper, final URectangle shape,
+ final HtmlColor back) {
+ final HtmlColorGradient gr = (HtmlColorGradient) back;
+ final char policy = gr.getPolicy();
+ final GradientPaint paint;
+ if (policy == '|') {
+ paint = new GradientPaint((float) x, (float) (y + shape.getHeight()) / 2, mapper.getMappedColor(gr
+ .getColor1()), (float) (x + shape.getWidth()), (float) (y + shape.getHeight()) / 2,
+ mapper.getMappedColor(gr.getColor2()));
+ } else if (policy == '\\') {
+ paint = new GradientPaint((float) x, (float) (y + shape.getHeight()), mapper.getMappedColor(gr
+ .getColor1()), (float) (x + shape.getWidth()), (float) y, mapper.getMappedColor(gr.getColor2()));
+ } else if (policy == '-') {
+ paint = new GradientPaint((float) (x + shape.getWidth()) / 2, (float) y, mapper.getMappedColor(gr
+ .getColor1()), (float) (x + shape.getWidth()) / 2, (float) (y + shape.getHeight()),
+ mapper.getMappedColor(gr.getColor2()));
+ } else {
+ // for /
+ paint = new GradientPaint((float) x, (float) y, mapper.getMappedColor(gr.getColor1()),
+ (float) (x + shape.getWidth()), (float) (y + shape.getHeight()), mapper.getMappedColor(gr
+ .getColor2()));
+ }
+ return paint;
+ }
+
+ public static void managePattern(UParam param, Graphics2D g2d) {
+ final UPattern pattern = param.getPattern();
+ if (pattern == UPattern.VERTICAL_STRIPE) {
+ final BufferedImage bi = new BufferedImage(4, 4, BufferedImage.TYPE_INT_ARGB);
+ final Rectangle r = new Rectangle(0, 0, 4, 4);
+ final int rgb = ((HtmlColorSimple) param.getBackcolor()).getColor999().getRGB();
+ for (int i = 0; i < 4; i++) {
+ for (int j = 0; j < 4; j++) {
+ if (i == 0 || i == 1) {
+ bi.setRGB(i, j, rgb);
+ }
+ }
+ }
+ g2d.setPaint(new TexturePaint(bi, r));
+ } else if (pattern == UPattern.HORIZONTAL_STRIPE) {
+ final BufferedImage bi = new BufferedImage(4, 4, BufferedImage.TYPE_INT_ARGB);
+ final Rectangle r = new Rectangle(0, 0, 4, 4);
+ final int rgb = ((HtmlColorSimple) param.getBackcolor()).getColor999().getRGB();
+ for (int i = 0; i < 4; i++) {
+ for (int j = 0; j < 4; j++) {
+ if (j == 0 || j == 1) {
+ bi.setRGB(i, j, rgb);
+ }
+ }
+ }
+ g2d.setPaint(new TexturePaint(bi, r));
+ } else if (pattern == UPattern.SMALL_CIRCLE) {
+ final BufferedImage bi = new BufferedImage(4, 4, BufferedImage.TYPE_INT_ARGB);
+ final Rectangle r = new Rectangle(0, 0, 4, 4);
+ final int rgb = ((HtmlColorSimple) param.getBackcolor()).getColor999().getRGB();
+ bi.setRGB(0, 1, rgb);
+ bi.setRGB(1, 0, rgb);
+ bi.setRGB(1, 1, rgb);
+ bi.setRGB(1, 2, rgb);
+ bi.setRGB(2, 1, rgb);
+ g2d.setPaint(new TexturePaint(bi, r));
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/g2d/DriverShadowedG2d.java b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverShadowedG2d.java
new file mode 100644
index 0000000..6a88f9a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverShadowedG2d.java
@@ -0,0 +1,111 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.g2d;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.Shape;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Line2D;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
+import java.awt.image.ConvolveOp;
+import java.awt.image.Kernel;
+
+import net.sourceforge.plantuml.Log;
+
+public class DriverShadowedG2d {
+
+ private ConvolveOp getConvolveOp(int blurRadius, double dpiFactor) {
+ blurRadius = (int) (blurRadius * dpiFactor);
+ final int blurRadius2 = blurRadius * blurRadius;
+ final float blurRadius2F = blurRadius2;
+ // final float weight = (float) (1.0 / blurRadius2F / dpiFactor);
+ final float weight = (float) (1.0 / blurRadius2F);
+ final float[] elements = new float[blurRadius2];
+ for (int k = 0; k < blurRadius2; k++) {
+ elements[k] = weight;
+ }
+ final Kernel myKernel = new Kernel(blurRadius, blurRadius, elements);
+
+ // if EDGE_NO_OP is not selected, EDGE_ZERO_FILL is the default which
+ // creates a black border
+ return new ConvolveOp(myKernel, ConvolveOp.EDGE_NO_OP, null);
+ }
+
+ private final Color color = new Color(170, 170, 170);
+ private final Color colorLine = new Color(30, 30, 30);
+
+ protected void drawShadow(Graphics2D g2d, Shape shape, double deltaShadow, double dpiFactor) {
+ if (dpiFactor < 1) {
+ dpiFactor = 1;
+ }
+ // dpiFactor = 1;
+ // Shadow
+ final Rectangle2D bounds = shape.getBounds2D();
+ final double ww = bounds.getMaxX() - bounds.getMinX();
+ final double hh = bounds.getMaxY() - bounds.getMinY();
+
+ final double w = (ww + deltaShadow * 2 + 6) * dpiFactor;
+ final double h = (hh + deltaShadow * 2 + 6) * dpiFactor;
+ BufferedImage destination = null;
+ try {
+ destination = new BufferedImage((int) w, (int) h, BufferedImage.TYPE_INT_ARGB);
+ final Graphics2D gg = destination.createGraphics();
+ gg.scale(dpiFactor, dpiFactor);
+ gg.translate(deltaShadow - bounds.getMinX(), deltaShadow - bounds.getMinY());
+ final boolean isLine = shape instanceof Line2D.Double;
+ if (isLine) {
+ gg.setColor(colorLine);
+ gg.draw(shape);
+ } else {
+ gg.setColor(color);
+ gg.fill(shape);
+ }
+ gg.dispose();
+
+ final ConvolveOp simpleBlur = getConvolveOp(6, dpiFactor);
+ destination = simpleBlur.filter(destination, null);
+ } catch (OutOfMemoryError error) {
+ Log.info("Warning: Cannot draw shadow, image too big.");
+ }
+ if (destination != null) {
+ final AffineTransform at = g2d.getTransform();
+ g2d.scale(1 / dpiFactor, 1 / dpiFactor);
+ g2d.drawImage(destination, (int) (bounds.getMinX() * dpiFactor), (int) (bounds.getMinY() * dpiFactor), null);
+ g2d.setTransform(at);
+ }
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/g2d/DriverTextAsPathG2d.java b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverTextAsPathG2d.java
new file mode 100644
index 0000000..697242b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverTextAsPathG2d.java
@@ -0,0 +1,152 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.g2d;
+
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.FontMetrics;
+import java.awt.Graphics2D;
+import java.awt.GraphicsEnvironment;
+import java.awt.font.FontRenderContext;
+import java.awt.font.TextLayout;
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Rectangle2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.EnsureVisible;
+import net.sourceforge.plantuml.Log;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.FontStyle;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.StringBounderUtils;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.ugraphic.UText;
+
+public class DriverTextAsPathG2d implements UDriver<Graphics2D> {
+
+ private final EnsureVisible visible;
+ private final FontRenderContext fontRenderContext;
+
+ public DriverTextAsPathG2d(EnsureVisible visible, FontRenderContext fontRenderContext) {
+ this.visible = visible;
+ this.fontRenderContext = fontRenderContext;
+ }
+
+ private static void printFont() {
+ final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
+ final String fontNames[] = ge.getAvailableFontFamilyNames();
+ final int j = fontNames.length;
+ for (int i = 0; i < j; i++) {
+ Log.info("Available fonts: " + fontNames[i]);
+ }
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, Graphics2D g2d) {
+ final UText shape = (UText) ushape;
+ final FontConfiguration fontConfiguration = shape.getFontConfiguration();
+
+ final UFont font = fontConfiguration.getFont().scaled(param.getScale());
+ final Dimension2D dimBack = calculateDimension(StringBounderUtils.asStringBounder(g2d), font, shape.getText());
+ if (fontConfiguration.containsStyle(FontStyle.BACKCOLOR)) {
+ final Color extended = mapper.getMappedColor(fontConfiguration.getExtendedColor());
+ if (extended != null) {
+ g2d.setColor(extended);
+ g2d.setBackground(extended);
+ g2d.fill(new Rectangle2D.Double(x, y - dimBack.getHeight() + 1.5, dimBack.getWidth(), dimBack
+ .getHeight()));
+ }
+ }
+ visible.ensureVisible(x, y - dimBack.getHeight() + 1.5);
+ visible.ensureVisible(x + dimBack.getWidth(), y + 1.5);
+
+ g2d.setFont(font.getFont());
+ g2d.setColor(mapper.getMappedColor(fontConfiguration.getColor()));
+ final TextLayout t = new TextLayout(shape.getText(), font.getFont(), fontRenderContext);
+ g2d.translate(x, y);
+ g2d.fill(t.getOutline(null));
+ g2d.translate(-x, -y);
+
+ if (fontConfiguration.containsStyle(FontStyle.UNDERLINE)) {
+ final HtmlColor extended = fontConfiguration.getExtendedColor();
+ if (extended != null) {
+ g2d.setColor(mapper.getMappedColor(extended));
+ }
+ final Dimension2D dim = calculateDimension(StringBounderUtils.asStringBounder(g2d), font, shape.getText());
+ final int ypos = (int) (y + 2.5);
+ g2d.setStroke(new BasicStroke((float) 1));
+ g2d.drawLine((int) x, ypos, (int) (x + dim.getWidth()), ypos);
+ g2d.setStroke(new BasicStroke());
+ }
+ if (fontConfiguration.containsStyle(FontStyle.WAVE)) {
+ final Dimension2D dim = calculateDimension(StringBounderUtils.asStringBounder(g2d), font, shape.getText());
+ final int ypos = (int) (y + 2.5) - 1;
+ final HtmlColor extended = fontConfiguration.getExtendedColor();
+ if (extended != null) {
+ g2d.setColor(mapper.getMappedColor(extended));
+ }
+ for (int i = (int) x; i < x + dim.getWidth() - 5; i += 6) {
+ g2d.drawLine(i, ypos - 0, i + 3, ypos + 1);
+ g2d.drawLine(i + 3, ypos + 1, i + 6, ypos - 0);
+ }
+ }
+ if (fontConfiguration.containsStyle(FontStyle.STRIKE)) {
+ final Dimension2D dim = calculateDimension(StringBounderUtils.asStringBounder(g2d), font, shape.getText());
+ final FontMetrics fm = g2d.getFontMetrics(font.getFont());
+ final int ypos = (int) (y - fm.getDescent() - 0.5);
+ final HtmlColor extended = fontConfiguration.getExtendedColor();
+ if (extended != null) {
+ g2d.setColor(mapper.getMappedColor(extended));
+ }
+ g2d.setStroke(new BasicStroke((float) 1.5));
+ g2d.drawLine((int) x, ypos, (int) (x + dim.getWidth()), ypos);
+ g2d.setStroke(new BasicStroke());
+ }
+ }
+
+ static public Dimension2D calculateDimension(StringBounder stringBounder, UFont font, String text) {
+ final Dimension2D rect = stringBounder.calculateDimension(font, text);
+ double h = rect.getHeight();
+ if (h < 10) {
+ h = 10;
+ }
+ return new Dimension2DDouble(rect.getWidth(), h);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/g2d/DriverTextG2d.java b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverTextG2d.java
new file mode 100644
index 0000000..baf7b48
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverTextG2d.java
@@ -0,0 +1,145 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.g2d;
+
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.FontMetrics;
+import java.awt.Graphics2D;
+import java.awt.GraphicsEnvironment;
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Rectangle2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.EnsureVisible;
+import net.sourceforge.plantuml.Log;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.FontStyle;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.StringBounderUtils;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.ugraphic.UText;
+
+public class DriverTextG2d implements UDriver<Graphics2D> {
+
+ private final EnsureVisible visible;
+
+ public DriverTextG2d(EnsureVisible visible) {
+ this.visible = visible;
+ }
+
+ private static void printFont() {
+ final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
+ final String fontNames[] = ge.getAvailableFontFamilyNames();
+ final int j = fontNames.length;
+ for (int i = 0; i < j; i++) {
+ Log.info("Available fonts: " + fontNames[i]);
+ }
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, Graphics2D g2d) {
+ final UText shape = (UText) ushape;
+ final FontConfiguration fontConfiguration = shape.getFontConfiguration();
+
+ final UFont font = fontConfiguration.getFont().scaled(param.getScale());
+ final Dimension2D dimBack = calculateDimension(StringBounderUtils.asStringBounder(g2d), font, shape.getText());
+ if (fontConfiguration.containsStyle(FontStyle.BACKCOLOR)) {
+ final Color extended = mapper.getMappedColor(fontConfiguration.getExtendedColor());
+ if (extended != null) {
+ g2d.setColor(extended);
+ g2d.setBackground(extended);
+ g2d.fill(new Rectangle2D.Double(x, y - dimBack.getHeight() + 1.5, dimBack.getWidth(), dimBack
+ .getHeight()));
+ }
+ }
+ visible.ensureVisible(x, y - dimBack.getHeight() + 1.5);
+ visible.ensureVisible(x + dimBack.getWidth(), y + 1.5);
+
+ g2d.setFont(font.getFont());
+ g2d.setColor(mapper.getMappedColor(fontConfiguration.getColor()));
+ g2d.drawString(shape.getText(), (float) x, (float) y);
+
+ if (fontConfiguration.containsStyle(FontStyle.UNDERLINE)) {
+ final HtmlColor extended = fontConfiguration.getExtendedColor();
+ if (extended != null) {
+ g2d.setColor(mapper.getMappedColor(extended));
+ }
+ final Dimension2D dim = calculateDimension(StringBounderUtils.asStringBounder(g2d), font, shape.getText());
+ final int ypos = (int) (y + 2.5);
+ g2d.setStroke(new BasicStroke((float) 1));
+ g2d.drawLine((int) x, ypos, (int) (x + dim.getWidth()), ypos);
+ g2d.setStroke(new BasicStroke());
+ }
+ if (fontConfiguration.containsStyle(FontStyle.WAVE)) {
+ final Dimension2D dim = calculateDimension(StringBounderUtils.asStringBounder(g2d), font, shape.getText());
+ final int ypos = (int) (y + 2.5) - 1;
+ final HtmlColor extended = fontConfiguration.getExtendedColor();
+ if (extended != null) {
+ g2d.setColor(mapper.getMappedColor(extended));
+ }
+ for (int i = (int) x; i < x + dim.getWidth() - 5; i += 6) {
+ g2d.drawLine(i, ypos - 0, i + 3, ypos + 1);
+ g2d.drawLine(i + 3, ypos + 1, i + 6, ypos - 0);
+ }
+ }
+ if (fontConfiguration.containsStyle(FontStyle.STRIKE)) {
+ final Dimension2D dim = calculateDimension(StringBounderUtils.asStringBounder(g2d), font, shape.getText());
+ final FontMetrics fm = g2d.getFontMetrics(font.getFont());
+ final int ypos = (int) (y - fm.getDescent() - 0.5);
+ final HtmlColor extended = fontConfiguration.getExtendedColor();
+ if (extended != null) {
+ g2d.setColor(mapper.getMappedColor(extended));
+ }
+ g2d.setStroke(new BasicStroke((float) 1.5));
+ g2d.drawLine((int) x, ypos, (int) (x + dim.getWidth()), ypos);
+ g2d.setStroke(new BasicStroke());
+ }
+ }
+
+ static public Dimension2D calculateDimension(StringBounder stringBounder, UFont font, String text) {
+ final Dimension2D rect = stringBounder.calculateDimension(font, text);
+ double h = rect.getHeight();
+ if (h < 10) {
+ h = 10;
+ }
+ return new Dimension2DDouble(rect.getWidth(), h);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/g2d/UGraphicG2d.java b/src/net/sourceforge/plantuml/ugraphic/g2d/UGraphicG2d.java
new file mode 100644
index 0000000..1650c8e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/g2d/UGraphicG2d.java
@@ -0,0 +1,216 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.g2d;
+
+import java.awt.Graphics2D;
+import java.awt.Shape;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import net.sourceforge.plantuml.EnsureVisible;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.anim.AffineTransformation;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.StringBounderUtils;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.png.PngIO;
+import net.sourceforge.plantuml.posimo.DotPath;
+import net.sourceforge.plantuml.ugraphic.AbstractCommonUGraphic;
+import net.sourceforge.plantuml.ugraphic.AbstractUGraphic;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UAntiAliasing;
+import net.sourceforge.plantuml.ugraphic.UCenteredCharacter;
+import net.sourceforge.plantuml.ugraphic.UChange;
+import net.sourceforge.plantuml.ugraphic.UClip;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UGraphic2;
+import net.sourceforge.plantuml.ugraphic.UImage;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.UPixel;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UText;
+
+public class UGraphicG2d extends AbstractUGraphic<Graphics2D> implements EnsureVisible, UGraphic2 {
+
+ private BufferedImage bufferedImage;
+
+ private final double dpiFactor;
+
+ private UAntiAliasing antiAliasing = UAntiAliasing.ANTI_ALIASING_ON;
+
+ private/* final */List<Url> urls = new ArrayList<Url>();
+ private Set<Url> allUrls = new HashSet<Url>();
+
+ private final boolean hasAffineTransform;
+
+ public final Set<Url> getAllUrlsEncountered() {
+ return Collections.unmodifiableSet(allUrls);
+ }
+
+ @Override
+ public UGraphic apply(UChange change) {
+ final UGraphicG2d copy = (UGraphicG2d) super.apply(change);
+ if (change instanceof UAntiAliasing) {
+ copy.antiAliasing = (UAntiAliasing) change;
+ }
+ return copy;
+ }
+
+ @Override
+ protected AbstractCommonUGraphic copyUGraphic() {
+ return new UGraphicG2d(this);
+ }
+
+ private UGraphicG2d(UGraphicG2d other) {
+ super(other);
+ this.hasAffineTransform = other.hasAffineTransform;
+ this.dpiFactor = other.dpiFactor;
+ this.bufferedImage = other.bufferedImage;
+ this.urls = other.urls;
+ this.allUrls = other.allUrls;
+ this.antiAliasing = other.antiAliasing;
+ register(dpiFactor);
+ }
+
+ public UGraphicG2d(ColorMapper colorMapper, Graphics2D g2d, double dpiFactor) {
+ this(colorMapper, g2d, dpiFactor, null, 0, 0);
+ }
+
+ public UGraphicG2d(ColorMapper colorMapper, Graphics2D g2d, double dpiFactor, AffineTransformation affineTransform,
+ double dx, double dy) {
+ super(colorMapper, g2d);
+ this.hasAffineTransform = affineTransform != null;
+ this.dpiFactor = dpiFactor;
+ if (dpiFactor != 1.0) {
+ g2d.scale(dpiFactor, dpiFactor);
+ }
+ if (this.hasAffineTransform) {
+ if (dx != 0 || dy != 0) {
+ getGraphicObject().transform(AffineTransform.getTranslateInstance(dx, dy));
+ }
+ getGraphicObject().transform(affineTransform.getAffineTransform());
+ }
+ register(dpiFactor);
+ }
+
+ private void register(double dpiFactor) {
+ registerDriver(URectangle.class, new DriverRectangleG2d(dpiFactor, this));
+ if (this.hasAffineTransform || dpiFactor != 1.0) {
+ registerDriver(UText.class, new DriverTextAsPathG2d(this, TextBlockUtils.getFontRenderContext()));
+ } else {
+ registerDriver(UText.class, new DriverTextG2d(this));
+ }
+ registerDriver(ULine.class, new DriverLineG2d(dpiFactor));
+ registerDriver(UPixel.class, new DriverPixelG2d());
+ registerDriver(UPolygon.class, new DriverPolygonG2d(dpiFactor, this));
+ registerDriver(UEllipse.class, new DriverEllipseG2d(dpiFactor, this));
+ registerDriver(UImage.class, new DriverImageG2d(this));
+ registerDriver(DotPath.class, new DriverDotPathG2d(this));
+ registerDriver(UPath.class, new DriverPathG2d(dpiFactor));
+ registerDriver(UCenteredCharacter.class, new DriverCenteredCharacterG2d());
+ }
+
+ public StringBounder getStringBounder() {
+ if (hasAffineTransform) {
+ return TextBlockUtils.getDummyStringBounder();
+ }
+ return StringBounderUtils.asStringBounder(getGraphicObject());
+ }
+
+ @Override
+ protected void beforeDraw() {
+ super.beforeDraw();
+ applyClip();
+ antiAliasing.apply(getGraphicObject());
+ }
+
+ private void applyClip() {
+ final UClip uclip = getClip();
+ if (uclip == null) {
+ getGraphicObject().setClip(null);
+ } else {
+ final Shape clip = new Rectangle2D.Double(uclip.getX(), uclip.getY(), uclip.getWidth(), uclip.getHeight());
+ getGraphicObject().setClip(clip);
+ }
+ }
+
+ protected final double getDpiFactor() {
+ return dpiFactor;
+ }
+
+ public void startUrl(Url url) {
+ urls.add(url);
+ allUrls.add(url);
+ }
+
+ public void closeAction() {
+ urls.remove(urls.size() - 1);
+ }
+
+ public void ensureVisible(double x, double y) {
+ for (Url u : urls) {
+ u.ensureVisible(x, y);
+ }
+ }
+
+ public BufferedImage getBufferedImage() {
+ return bufferedImage;
+ }
+
+ public void setBufferedImage(BufferedImage bufferedImage) {
+ this.bufferedImage = bufferedImage;
+ }
+
+ public Graphics2D getGraphics2D() {
+ return getGraphicObject();
+ }
+
+ public void writeImageTOBEMOVED(OutputStream os, String metadata, int dpi) throws IOException {
+ final BufferedImage im = getBufferedImage();
+ PngIO.write(im, os, metadata, dpi);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/hand/HandJiggle.java b/src/net/sourceforge/plantuml/ugraphic/hand/HandJiggle.java
new file mode 100644
index 0000000..7a3b628
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/hand/HandJiggle.java
@@ -0,0 +1,152 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.hand;
+
+import java.awt.geom.CubicCurve2D;
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+
+public class HandJiggle {
+ private final Collection<Point2D> points = new ArrayList<Point2D>();
+
+ private double startX;
+ private double startY;
+ private final double defaultVariation;
+
+ public HandJiggle(double startX, double startY, double defaultVariation) {
+ this.startX = startX;
+ this.startY = startY;
+ this.defaultVariation = defaultVariation;
+ points.add(new Point2D.Double(startX, startY));
+ }
+
+ public HandJiggle(Point2D start, double defaultVariation) {
+ this(start.getX(), start.getY(), defaultVariation);
+ }
+
+ public void lineTo(Point2D end) {
+ lineTo(end.getX(), end.getY());
+ }
+
+ public void arcTo(double angle0, double angle1, double centerX, double centerY, double rx, double ry) {
+ lineTo(pointOnCircle(centerX, centerY, (angle0 + angle1) / 2, rx, ry));
+ lineTo(pointOnCircle(centerX, centerY, angle1, rx, ry));
+ }
+
+ private static Point2D pointOnCircle(double centerX, double centerY, double angle, double rx, double ry) {
+ final double x = centerX + Math.cos(angle) * rx;
+ final double y = centerY + Math.sin(angle) * ry;
+ return new Point2D.Double(x, y);
+
+ }
+
+ public void lineTo(final double endX, final double endY) {
+
+ final double diffX = Math.abs(endX - startX);
+ final double diffY = Math.abs(endY - startY);
+ final double distance = Math.sqrt(diffX * diffX + diffY * diffY);
+ if (distance < 0.001) {
+ return;
+ }
+
+ int segments = (int) Math.round(distance / 10);
+ double variation = defaultVariation;
+ if (segments < 5) {
+ segments = 5;
+ variation /= 3;
+ }
+
+ final double stepX = Math.signum(endX - startX) * diffX / segments;
+ final double stepY = Math.signum(endY - startY) * diffY / segments;
+
+ final double fx = diffX / distance;
+ final double fy = diffY / distance;
+
+ for (int s = 0; s < segments; s++) {
+ double x = stepX * s + startX;
+ double y = stepY * s + startY;
+
+ final double offset = (Math.random() - 0.5) * variation;
+ points.add(new Point2D.Double(x - offset * fy, y - offset * fx));
+ }
+ points.add(new Point2D.Double(endX, endY));
+
+ this.startX = endX;
+ this.startY = endY;
+ }
+
+ public void curveTo(CubicCurve2D curve) {
+ final double flatness = curve.getFlatness();
+ final double dist = curve.getP1().distance(curve.getP2());
+ if (flatness > 0.1 && dist > 20) {
+ final CubicCurve2D left = new CubicCurve2D.Double();
+ final CubicCurve2D right = new CubicCurve2D.Double();
+ curve.subdivide(left, right);
+ curveTo(left);
+ curveTo(right);
+ return;
+ }
+ lineTo(curve.getP2());
+ }
+
+ public UPolygon toUPolygon() {
+ final UPolygon result = new UPolygon();
+ for (Point2D p : points) {
+ result.addPoint(p.getX(), p.getY());
+ }
+ return result;
+ }
+
+ public UPath toUPath() {
+ UPath path = null;
+ for (Point2D p : points) {
+ if (path == null) {
+ path = new UPath();
+ path.moveTo(p);
+ } else {
+ path.lineTo(p);
+ }
+ }
+ if (path == null) {
+ throw new IllegalStateException();
+ }
+ return path;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/hand/UDotPathHand.java b/src/net/sourceforge/plantuml/ugraphic/hand/UDotPathHand.java
new file mode 100644
index 0000000..739868e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/hand/UDotPathHand.java
@@ -0,0 +1,60 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.hand;
+
+import java.awt.geom.CubicCurve2D;
+
+import net.sourceforge.plantuml.posimo.DotPath;
+import net.sourceforge.plantuml.ugraphic.UPath;
+
+public class UDotPathHand {
+
+ private final UPath path;
+
+ public UDotPathHand(DotPath source) {
+
+ final HandJiggle jiggle = new HandJiggle(source.getStartPoint(), 2.0);
+ for (CubicCurve2D curve : source.getBeziers()) {
+ jiggle.curveTo(curve);
+ }
+
+ this.path = jiggle.toUPath();
+ }
+
+ public UPath getHanddrawn() {
+ return this.path;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/hand/UEllipseHand.java b/src/net/sourceforge/plantuml/ugraphic/hand/UEllipseHand.java
new file mode 100644
index 0000000..4ef0bca
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/hand/UEllipseHand.java
@@ -0,0 +1,90 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.hand;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.ugraphic.Shadowable;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+
+public class UEllipseHand {
+
+ private Shadowable poly;
+
+ public UEllipseHand(UEllipse source) {
+
+ if (source.getStart() != 0 || source.getExtend() != 0) {
+ this.poly = source;
+ return;
+ }
+ poly = new UPolygon();
+ final double width = source.getWidth();
+ final double height = source.getHeight();
+ double angle = 0;
+ if (width == height) {
+ while (angle < Math.PI * 2) {
+ angle += (10 + Math.random() * 10) * Math.PI / 180;
+ final double variation = 1 + (Math.random() - 0.5) / 8;
+ final double x = width / 2 + Math.cos(angle) * width * variation / 2;
+ final double y = height / 2 + Math.sin(angle) * height * variation / 2;
+ // final Point2D.Double p = new Point2D.Double(x, y);
+ ((UPolygon) poly).addPoint(x, y);
+ }
+ } else {
+ while (angle < Math.PI * 2) {
+ angle += Math.PI / 20;
+ final Point2D pt = getPoint(width, height, angle);
+ ((UPolygon) poly).addPoint(pt.getX(), pt.getY());
+ }
+
+ }
+
+ this.poly.setDeltaShadow(source.getDeltaShadow());
+ }
+
+ private Point2D getPoint(double width, double height, double angle) {
+ final double x = width / 2 + Math.cos(angle) * width / 2;
+ final double y = height / 2 + Math.sin(angle) * height / 2;
+ final double variation = (Math.random() - 0.5) / 50;
+ return new Point2D.Double(x + variation * width, y + variation * height);
+
+ }
+
+ public Shadowable getHanddrawn() {
+ return this.poly;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/hand/UGraphicHandwritten.java b/src/net/sourceforge/plantuml/ugraphic/hand/UGraphicHandwritten.java
new file mode 100644
index 0000000..a85c35f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/hand/UGraphicHandwritten.java
@@ -0,0 +1,141 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.hand;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.posimo.DotPath;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UChange;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class UGraphicHandwritten implements UGraphic {
+
+ private final UGraphic ug;
+
+ public UGraphicHandwritten(UGraphic ug) {
+ this.ug = ug;
+ }
+
+ public StringBounder getStringBounder() {
+ return ug.getStringBounder();
+ }
+
+ public UParam getParam() {
+ return ug.getParam();
+ }
+
+ public void draw(UShape shape) {
+ // http://www.ufonts.com/fonts/felt-tip-roman.html
+ // http://webdesignledger.com/freebies/20-amazing-free-handwritten-fonts-for-your-designs
+ if (shape instanceof ULine) {
+ drawHand((ULine) shape);
+ } else if (shape instanceof URectangle) {
+ drawHand((URectangle) shape);
+ } else if (shape instanceof UPolygon) {
+ drawHand((UPolygon) shape);
+ } else if (shape instanceof UEllipse) {
+ drawHand((UEllipse) shape);
+ } else if (shape instanceof DotPath) {
+ drawHand((DotPath) shape);
+ } else if (shape instanceof UPath) {
+ drawHand((UPath) shape);
+ } else {
+ ug.draw(shape);
+ }
+ }
+
+ private void drawHand(UPath shape) {
+ final UPathHand uline = new UPathHand(shape);
+ ug.draw(uline.getHanddrawn());
+ }
+
+ private void drawHand(DotPath shape) {
+ final UDotPathHand uline = new UDotPathHand(shape);
+ ug.draw(uline.getHanddrawn());
+ }
+
+ private void drawHand(UPolygon shape) {
+ final UPolygonHand hand = new UPolygonHand(shape);
+ ug.draw(hand.getHanddrawn());
+ }
+
+ private void drawHand(URectangle shape) {
+ final URectangleHand hand = new URectangleHand(shape);
+ ug.draw(hand.getHanddrawn());
+ }
+
+ private void drawHand(ULine shape) {
+ final ULineHand uline = new ULineHand(shape);
+ ug.draw(uline.getHanddrawn());
+ }
+
+ private void drawHand(UEllipse shape) {
+ final UEllipseHand uline = new UEllipseHand(shape);
+ ug.draw(uline.getHanddrawn());
+ }
+
+ public UGraphic apply(UChange change) {
+ return new UGraphicHandwritten(ug.apply(change));
+ }
+
+ public ColorMapper getColorMapper() {
+ return ug.getColorMapper();
+ }
+
+ public void startUrl(Url url) {
+ ug.startUrl(url);
+ }
+
+ public void closeAction() {
+ ug.closeAction();
+ }
+
+ public void flushUg() {
+ ug.flushUg();
+ }
+
+ public boolean isSpecialTxt() {
+ return false;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/hand/ULineHand.java b/src/net/sourceforge/plantuml/ugraphic/hand/ULineHand.java
new file mode 100644
index 0000000..85f2915
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/hand/ULineHand.java
@@ -0,0 +1,58 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.hand;
+
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UPath;
+
+public class ULineHand {
+
+ private UPath path;
+
+ public ULineHand(ULine line) {
+ final double endX = line.getDX();
+ final double endY = line.getDY();
+ final HandJiggle jiggle = new HandJiggle(0, 0, 2.0);
+ jiggle.lineTo(endX, endY);
+
+ this.path = jiggle.toUPath();
+
+ }
+
+ public UPath getHanddrawn() {
+ return this.path;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/hand/UPathHand.java b/src/net/sourceforge/plantuml/ugraphic/hand/UPathHand.java
new file mode 100644
index 0000000..4525aff
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/hand/UPathHand.java
@@ -0,0 +1,85 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.hand;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.USegment;
+import net.sourceforge.plantuml.ugraphic.USegmentType;
+
+public class UPathHand {
+
+ private final UPath path;
+ private final double defaultVariation = 4.0;
+
+ public UPathHand(UPath source) {
+
+ final UPath jigglePath = new UPath();
+
+ Point2D last = new Point2D.Double();
+
+ for (USegment segment : source) {
+ final USegmentType type = segment.getSegmentType();
+ if (type == USegmentType.SEG_MOVETO) {
+ final double x = segment.getCoord()[0];
+ final double y = segment.getCoord()[1];
+ jigglePath.moveTo(x, y);
+ last = new Point2D.Double(x, y);
+
+ } else if (type == USegmentType.SEG_LINETO) {
+ final double x = segment.getCoord()[0];
+ final double y = segment.getCoord()[1];
+ final HandJiggle jiggle = new HandJiggle(last.getX(), last.getY(), defaultVariation);
+ jiggle.lineTo(x, y);
+ for (USegment seg2 : jiggle.toUPath()) {
+ if (seg2.getSegmentType() == USegmentType.SEG_LINETO) {
+ jigglePath.lineTo(seg2.getCoord()[0], seg2.getCoord()[1]);
+ }
+ }
+ last = new Point2D.Double(x, y);
+ } else {
+ this.path = source;
+ return;
+ }
+ }
+ this.path = jigglePath;
+ }
+
+ public UPath getHanddrawn() {
+ return this.path;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/hand/UPolygonHand.java b/src/net/sourceforge/plantuml/ugraphic/hand/UPolygonHand.java
new file mode 100644
index 0000000..874fa40
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/hand/UPolygonHand.java
@@ -0,0 +1,67 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.hand;
+
+import java.awt.geom.Point2D;
+import java.util.List;
+
+import net.sourceforge.plantuml.ugraphic.Shadowable;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+
+public class UPolygonHand {
+
+ private final UPolygon poly;
+
+ public UPolygonHand(UPolygon source) {
+ final List<Point2D.Double> pt = source.getPoints();
+ if (pt.size() == 0) {
+ poly = new UPolygon();
+ return;
+ }
+ final HandJiggle jiggle = new HandJiggle(pt.get(0), 1.5);
+ for (int i = 1; i < pt.size(); i++) {
+ jiggle.lineTo(pt.get(i));
+ }
+ jiggle.lineTo(pt.get(0));
+
+ this.poly = jiggle.toUPolygon();
+ this.poly.setDeltaShadow(source.getDeltaShadow());
+ }
+
+ public Shadowable getHanddrawn() {
+ return this.poly;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/hand/URectangleHand.java b/src/net/sourceforge/plantuml/ugraphic/hand/URectangleHand.java
new file mode 100644
index 0000000..4508cbb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/hand/URectangleHand.java
@@ -0,0 +1,78 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.hand;
+
+import net.sourceforge.plantuml.ugraphic.Shadowable;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+
+public class URectangleHand {
+
+ final private UPolygon poly;
+
+ public URectangleHand(URectangle rectangle) {
+ final double width = rectangle.getWidth();
+ final double height = rectangle.getHeight();
+ final HandJiggle jiggle;
+ final double rx = Math.min(rectangle.getRx() / 2, width / 2);
+ final double ry = Math.min(rectangle.getRy() / 2, height / 2);
+ System.err.println("rx=" + rx + " ry=" + ry);
+ if (rx == 0 && ry == 0) {
+ jiggle = new HandJiggle(0, 0, 1.5);
+ jiggle.lineTo(width, 0);
+ jiggle.lineTo(width, height);
+ jiggle.lineTo(0, height);
+ jiggle.lineTo(0, 0);
+ } else {
+ jiggle = new HandJiggle(rx, 0, 1.5);
+ jiggle.lineTo(width - rx, 0);
+ jiggle.arcTo(-Math.PI / 2, 0, width - rx, ry, rx, ry);
+ jiggle.lineTo(width, height - ry);
+ jiggle.arcTo(0, Math.PI / 2, width - rx, height - ry, rx, ry);
+ jiggle.lineTo(rx, height);
+ jiggle.arcTo(Math.PI / 2, Math.PI, rx, height - ry, rx, ry);
+ jiggle.lineTo(0, ry);
+ jiggle.arcTo(Math.PI, 3 * Math.PI / 2, rx, ry, rx, ry);
+ }
+
+ this.poly = jiggle.toUPolygon();
+ this.poly.setDeltaShadow(rectangle.getDeltaShadow());
+ }
+
+ public Shadowable getHanddrawn() {
+ return this.poly;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/html5/DriverLineHtml5.java b/src/net/sourceforge/plantuml/ugraphic/html5/DriverLineHtml5.java
new file mode 100644
index 0000000..c629b37
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/html5/DriverLineHtml5.java
@@ -0,0 +1,82 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.html5;
+
+import java.awt.geom.Line2D;
+
+import net.sourceforge.plantuml.ugraphic.ClipContainer;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UClip;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.StringUtils;
+
+public class DriverLineHtml5 implements UDriver<Html5Drawer> {
+
+ private final ClipContainer clipContainer;
+
+ public DriverLineHtml5(ClipContainer clipContainer) {
+ this.clipContainer = clipContainer;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, Html5Drawer html) {
+ final ULine shape = (ULine) ushape;
+
+ double x2 = x + shape.getDX();
+ double y2 = y + shape.getDY();
+
+ final UClip clip = clipContainer.getClip();
+ if (clip != null) {
+ final Line2D.Double line = clip.getClippedLine(new Line2D.Double(x, y, x2, y2));
+ if (line == null) {
+ return;
+ }
+ x = line.x1;
+ y = line.y1;
+ x2 = line.x2;
+ y2 = line.y2;
+ }
+
+ final String color = param.getColor() == null ? null : StringUtils.getAsHtml(mapper.getMappedColor(param
+ .getColor()));
+ html.setStrokeColor(color);
+
+// html.setStrokeWidth("" + param.getStroke().getThickness(), param.getStroke().getDashVisible(), param.getStroke()
+// .getDashSpace());
+ html.htmlLine(x, y, x2, y2, 0);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/html5/DriverNopHtml5.java b/src/net/sourceforge/plantuml/ugraphic/html5/DriverNopHtml5.java
new file mode 100644
index 0000000..b0ec476
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/html5/DriverNopHtml5.java
@@ -0,0 +1,46 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.html5;
+
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverNopHtml5 implements UDriver<Html5Drawer> {
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, Html5Drawer html) {
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/html5/DriverRectangleHtml5.java b/src/net/sourceforge/plantuml/ugraphic/html5/DriverRectangleHtml5.java
new file mode 100644
index 0000000..8cf3095
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/html5/DriverRectangleHtml5.java
@@ -0,0 +1,99 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.html5;
+
+import java.awt.geom.Rectangle2D;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorGradient;
+import net.sourceforge.plantuml.ugraphic.ClipContainer;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UClip;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.StringUtils;
+
+public class DriverRectangleHtml5 implements UDriver<Html5Drawer> {
+
+ private final ClipContainer clipContainer;
+
+ public DriverRectangleHtml5(ClipContainer clipContainer) {
+ this.clipContainer = clipContainer;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, Html5Drawer html) {
+ final URectangle rect = (URectangle) ushape;
+
+ double width = rect.getWidth();
+ double height = rect.getHeight();
+
+ final UClip clip = clipContainer.getClip();
+ if (clip != null) {
+ final Rectangle2D.Double r = clip.getClippedRectangle(new Rectangle2D.Double(x, y, width, height));
+ x = r.x;
+ y = r.y;
+ width = r.width;
+ height = r.height;
+ }
+
+ final double rx = rect.getRx();
+ final double ry = rect.getRy();
+
+// // Shadow
+// if (rect.getDeltaShadow() != 0) {
+// eps.epsRectangleShadow(x, y, width, height, rx / 2, ry / 2, rect.getDeltaShadow());
+// }
+
+ final HtmlColor back = param.getBackcolor();
+ if (back instanceof HtmlColorGradient) {
+// eps.setStrokeColor(mapper.getMappedColor(param.getColor()));
+// eps.epsRectangle(x, y, width, height, rx / 2, ry / 2, (HtmlColorGradient) back, mapper);
+ } else {
+ final String color = param.getColor() == null ? null : StringUtils.getAsHtml(mapper.getMappedColor(param
+ .getColor()));
+ final String backcolor = param.getColor() == null ? null : StringUtils.getAsHtml(mapper.getMappedColor(param
+ .getBackcolor()));
+
+ html.setStrokeColor(color);
+ html.setFillColor(backcolor);
+// eps.setStrokeWidth("" + param.getStroke().getThickness(), param.getStroke().getDashVisible(), param
+// .getStroke().getDashSpace());
+ html.htmlRectangle(x, y, width, height, rx / 2, ry / 2);
+ }
+
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/html5/Html5Drawer.java b/src/net/sourceforge/plantuml/ugraphic/html5/Html5Drawer.java
new file mode 100644
index 0000000..5b9e76d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/html5/Html5Drawer.java
@@ -0,0 +1,134 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.html5;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.eps.EpsGraphics;
+
+public class Html5Drawer {
+
+ private int maxX = 10;
+ private int maxY = 10;
+ private String strokeStyle = "black";
+ private String fillStyle = "black";
+
+ private List<String> data = new ArrayList<String>();
+
+ final protected void ensureVisible(double x, double y) {
+ if (x > maxX) {
+ maxX = (int) (x + 1);
+ }
+ if (y > maxY) {
+ maxY = (int) (y + 1);
+ }
+ }
+
+ private static String format(double x) {
+ return EpsGraphics.format(x);
+ }
+
+ public final void setStrokeColor(String stroke) {
+ this.strokeStyle = stroke;
+ }
+
+ public final void setFillColor(String fill) {
+ this.fillStyle = fill;
+ }
+
+ public String generateHtmlCode() {
+ final StringBuilder sb = new StringBuilder();
+ ap(sb, "<html>");
+ ap(sb, "<canvas id=\"demo\" width=\"700\" height=\"350\">");
+ ap(sb, "</canvas>");
+ ap(sb, "</html>");
+ ap(sb, "<script>");
+ ap(sb, "window.addEventListener('load', function () {");
+ ap(sb, "var elem = document.getElementById('demo');");
+ ap(sb, "if (!elem || !elem.getContext) { return;}");
+ ap(sb, "var ctx = elem.getContext('2d');");
+ ap(sb, "if (!ctx) { return;}");
+ // ap(sb, "ctx.fillStyle = 'green';");
+ // ap(sb, "ctx.fillRect(30, 30, 55, 50);");
+ for (String s : data) {
+ ap(sb, s);
+ }
+ ap(sb, "}, false);");
+ ap(sb, "</script>");
+ ap(sb, "</html>");
+ return sb.toString();
+ }
+
+ private void ap(StringBuilder sb, String s) {
+ sb.append(s);
+ sb.append('\n');
+ }
+
+ public void htmlRectangle(double x, double y, double width, double height, double rx, double ry) {
+ ensureVisible(x, y);
+ ensureVisible(x + width, y + height);
+ // if (fillcolor != null) {
+ // appendColor(fillcolor);
+ // epsRectangleInternal(x, y, width, height, rx, ry, true);
+ // append("closepath eofill", true);
+ // }
+ //
+ // if (color != null) {
+ // append(strokeWidth + " setlinewidth", true);
+ // appendColor(color);
+ // epsRectangleInternal(x, y, width, height, rx, ry, false);
+ // append("closepath stroke", true);
+ // }
+ data.add("//RECT");
+ data.add("ctx.strokeStyle='" + strokeStyle + "';");
+ data.add("ctx.fillStyle='" + fillStyle + "';");
+ data.add("ctx.rect(" + format(x) + "," + format(y) + "," + format(width) + "," + format(height) + ");");
+ data.add("ctx.fill();");
+ data.add("ctx.stroke();");
+ }
+
+ public void htmlLine(double x1, double y1, double x2, double y2, double deltaShadow) {
+ ensureVisible(x1 + 2 * deltaShadow, y1 + 2 * deltaShadow);
+ ensureVisible(x2 + 2 * deltaShadow, y2 + 2 * deltaShadow);
+ data.add("ctx.strokeStyle='" + strokeStyle + "';");
+ data.add("ctx.beginPath();");
+ data.add("ctx.moveTo(" + format(x1) + "," + format(y1) + ");");
+ data.add("ctx.lineTo(" + format(x2) + "," + format(y2) + ");");
+ data.add("ctx.stroke();");
+ data.add("ctx.closePath();");
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/html5/UGraphicHtml5.java b/src/net/sourceforge/plantuml/ugraphic/html5/UGraphicHtml5.java
new file mode 100644
index 0000000..37b94f2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/html5/UGraphicHtml5.java
@@ -0,0 +1,141 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.html5;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.ugraphic.AbstractCommonUGraphic;
+import net.sourceforge.plantuml.ugraphic.AbstractUGraphic;
+import net.sourceforge.plantuml.ugraphic.ClipContainer;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UGraphic2;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UText;
+
+public class UGraphicHtml5 extends AbstractUGraphic<Html5Drawer> implements ClipContainer, UGraphic2 {
+
+ private final StringBounder stringBounder;
+
+ @Override
+ protected AbstractCommonUGraphic copyUGraphic() {
+ return this;
+ }
+
+ public UGraphicHtml5(ColorMapper colorMapper) {
+ super(colorMapper, new Html5Drawer());
+ stringBounder = TextBlockUtils.getDummyStringBounder();
+ registerDriver(URectangle.class, new DriverRectangleHtml5(this));
+ // registerDriver(UText.class, new DriverTextEps(imDummy, this, strategy));
+ registerDriver(UText.class, new DriverNopHtml5());
+ registerDriver(ULine.class, new DriverLineHtml5(this));
+ // registerDriver(UPolygon.class, new DriverPolygonEps(this));
+ registerDriver(UPolygon.class, new DriverNopHtml5());
+ // registerDriver(UEllipse.class, new DriverEllipseEps());
+ // registerDriver(UImage.class, new DriverImageEps());
+ // registerDriver(UPath.class, new DriverPathEps());
+ // registerDriver(DotPath.class, new DriverDotPathEps());
+ }
+
+ public StringBounder getStringBounder() {
+ return stringBounder;
+ }
+
+ public void startUrl(Url url) {
+ // throw new UnsupportedOperationException();
+
+ }
+
+ public void closeAction() {
+ // throw new UnsupportedOperationException();
+
+ }
+
+ // public void close() {
+ // getEpsGraphics().close();
+ // }
+
+ public String generateHtmlCode() {
+ return getGraphicObject().generateHtmlCode();
+ }
+
+ public void writeImageTOBEMOVED(OutputStream os, String metadata, int dpi) throws IOException {
+ os.write(generateHtmlCode().getBytes());
+ }
+
+ // public void centerChar(double x, double y, char c, UFont font) {
+ // final UnusedSpace unusedSpace = UnusedSpace.getUnusedSpace(font, c);
+ //
+ // final double xpos = x - unusedSpace.getCenterX() - 0.5;
+ // final double ypos = y - unusedSpace.getCenterY() - 0.5;
+ //
+ // final TextLayout t = new TextLayout("" + c, font.getFont(), imDummy.getFontRenderContext());
+ // getGraphicObject().setStrokeColor(getColorMapper().getMappedColor(getParam().getColor()));
+ // DriverTextEps.drawPathIterator(getGraphicObject(), xpos + getTranslateX(), ypos + getTranslateY(), t
+ // .getOutline(null).getPathIterator(null));
+ //
+ // }
+ //
+ // static public String getEpsString(ColorMapper colorMapper, EpsStrategy epsStrategy, UDrawable udrawable)
+ // throws IOException {
+ // final UGraphicHtml5 ug = new UGraphicHtml5(colorMapper, epsStrategy);
+ // udrawable.drawU(ug);
+ // return ug.getEPSCode();
+ // }
+ //
+ // static public void copyEpsToFile(ColorMapper colorMapper, UDrawable udrawable, File f) throws IOException {
+ // final PrintWriter pw = new PrintWriter(f);
+ // final EpsStrategy epsStrategy = EpsStrategy.getDefault2();
+ // pw.print(UGraphicHtml5.getEpsString(colorMapper, epsStrategy, udrawable));
+ // pw.close();
+ // }
+ //
+ // public void setAntiAliasing(boolean trueForOn) {
+ // }
+ //
+ // public void startUrl(String url, String tooltip) {
+ // getGraphicObject().openLink(url);
+ // }
+ //
+ // public void closeAction() {
+ // getGraphicObject().closeLink();
+ // }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/svg/DriverCenteredCharacterSvg.java b/src/net/sourceforge/plantuml/ugraphic/svg/DriverCenteredCharacterSvg.java
new file mode 100644
index 0000000..0cf7fce
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/svg/DriverCenteredCharacterSvg.java
@@ -0,0 +1,66 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.svg;
+
+import java.awt.font.TextLayout;
+
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.graphic.UnusedSpace;
+import net.sourceforge.plantuml.svg.SvgGraphics;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UCenteredCharacter;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.StringUtils;
+
+public class DriverCenteredCharacterSvg implements UDriver<SvgGraphics> {
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, SvgGraphics svg) {
+ final UCenteredCharacter characterCircled = (UCenteredCharacter) ushape;
+ final char c = characterCircled.getChar();
+ final UFont font = characterCircled.getFont();
+ final UnusedSpace unusedSpace = UnusedSpace.getUnusedSpace(font, c);
+
+ final double xpos = x - unusedSpace.getCenterX() - 0.5;
+ final double ypos = y - unusedSpace.getCenterY() - 0.5;
+
+ final TextLayout t = new TextLayout("" + c, font.getFont(), TextBlockUtils.getFontRenderContext());
+ svg.setStrokeColor(StringUtils.getAsHtml(mapper.getMappedColor(param.getColor())));
+ DriverTextAsPathSvg.drawPathIterator(svg, xpos, ypos, t.getOutline(null).getPathIterator(null));
+
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/svg/DriverDotPathSvg.java b/src/net/sourceforge/plantuml/ugraphic/svg/DriverDotPathSvg.java
new file mode 100644
index 0000000..28659d1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/svg/DriverDotPathSvg.java
@@ -0,0 +1,60 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.svg;
+
+import net.sourceforge.plantuml.posimo.DotPath;
+import net.sourceforge.plantuml.svg.SvgGraphics;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.StringUtils;
+
+public class DriverDotPathSvg implements UDriver<SvgGraphics> {
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, SvgGraphics svg) {
+ final DotPath shape = (DotPath) ushape;
+ // DriverLineG2d.manageStroke(param, g2d);
+
+ if (param.getColor() != null) {
+ final String color = StringUtils.getAsSvg(mapper, param.getColor());
+ svg.setStrokeColor(color);
+ svg.setFillColor(null);
+ svg.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDasharraySvg());
+
+ svg.svgPath(x, y, shape.toUPath(), 0);
+ }
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/svg/DriverEllipseSvg.java b/src/net/sourceforge/plantuml/ugraphic/svg/DriverEllipseSvg.java
new file mode 100644
index 0000000..399d984
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/svg/DriverEllipseSvg.java
@@ -0,0 +1,108 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.svg;
+
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorGradient;
+import net.sourceforge.plantuml.graphic.HtmlColorTransparent;
+import net.sourceforge.plantuml.svg.SvgGraphics;
+import net.sourceforge.plantuml.ugraphic.ClipContainer;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UClip;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverEllipseSvg implements UDriver<SvgGraphics> {
+
+ private final ClipContainer clipContainer;
+
+ public DriverEllipseSvg(ClipContainer clipContainer) {
+ this.clipContainer = clipContainer;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, SvgGraphics svg) {
+ final UEllipse shape = (UEllipse) ushape;
+ final double width = shape.getWidth();
+ final double height = shape.getHeight();
+
+ final UClip clip = clipContainer.getClip();
+ if (clip != null) {
+ if (clip.isInside(x, y) == false) {
+ return;
+ }
+ if (clip.isInside(x + width, y + height) == false) {
+ return;
+ }
+ }
+
+ final HtmlColor back = param.getBackcolor();
+ if (back instanceof HtmlColorGradient) {
+ final HtmlColorGradient gr = (HtmlColorGradient) back;
+ final String id = svg.createSvgGradient(StringUtils.getAsHtml(mapper.getMappedColor(gr.getColor1())),
+ StringUtils.getAsHtml(mapper.getMappedColor(gr.getColor2())), gr.getPolicy());
+ svg.setFillColor("url(#" + id + ")");
+ } else if (back == null || back instanceof HtmlColorTransparent) {
+ svg.setFillColor("none");
+ } else {
+ final String backcolor = StringUtils.getAsSvg(mapper, back);
+ svg.setFillColor(backcolor);
+ }
+ final String color = StringUtils.getAsSvg(mapper, param.getColor());
+ svg.setStrokeColor(color);
+ svg.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDasharraySvg());
+
+ double start = shape.getStart();
+ final double extend = shape.getExtend();
+ final double cx = x + width / 2;
+ final double cy = y + height / 2;
+ if (start == 0 && extend == 0) {
+ svg.svgEllipse(cx, cy, width / 2, height / 2, shape.getDeltaShadow());
+ } else {
+ // http://www.itk.ilstu.edu/faculty/javila/SVG/SVG_drawing1/elliptical_curve.htm
+ start = start + 90;
+ final double x1 = cx + Math.sin(start * Math.PI / 180.) * width / 2;
+ final double y1 = cy + Math.cos(start * Math.PI / 180.) * height / 2;
+ final double x2 = cx + Math.sin((start + extend) * Math.PI / 180.) * width / 2;
+ final double y2 = cy + Math.cos((start + extend) * Math.PI / 180.) * height / 2;
+ // svg.svgEllipse(x1, y1, 1, 1, 0);
+ // svg.svgEllipse(x2, y2, 1, 1, 0);
+ svg.svgArcEllipse(width / 2, height / 2, x1, y1, x2, y2);
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/svg/DriverImagePng.java b/src/net/sourceforge/plantuml/ugraphic/svg/DriverImagePng.java
new file mode 100644
index 0000000..74836d1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/svg/DriverImagePng.java
@@ -0,0 +1,76 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.svg;
+
+import java.io.IOException;
+
+import net.sourceforge.plantuml.Log;
+import net.sourceforge.plantuml.svg.SvgGraphics;
+import net.sourceforge.plantuml.ugraphic.ClipContainer;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UClip;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UImage;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverImagePng implements UDriver<SvgGraphics> {
+
+ private final ClipContainer clipContainer;
+
+ public DriverImagePng(ClipContainer clipContainer) {
+ this.clipContainer = clipContainer;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, SvgGraphics svg) {
+
+ final UImage image = (UImage) ushape;
+ final UClip clip = clipContainer.getClip();
+ if (clip != null) {
+ if (clip.isInside(x, y) == false) {
+ return;
+ }
+ if (clip.isInside(x + image.getWidth(), y + image.getHeight()) == false) {
+ return;
+ }
+ }
+
+ try {
+ svg.svgImage(image.getImage(), x, y);
+ } catch (IOException e) {
+ Log.error("Error in svg for image " + e);
+ }
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/svg/DriverImageSvgSvg.java b/src/net/sourceforge/plantuml/ugraphic/svg/DriverImageSvgSvg.java
new file mode 100644
index 0000000..c02c31d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/svg/DriverImageSvgSvg.java
@@ -0,0 +1,50 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.svg;
+
+import net.sourceforge.plantuml.svg.SvgGraphics;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UImageSvg;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverImageSvgSvg implements UDriver<SvgGraphics> {
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, SvgGraphics svg) {
+ final UImageSvg image = (UImageSvg) ushape;
+ svg.svgImage(image.getSvg(), x, y);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/svg/DriverLineSvg.java b/src/net/sourceforge/plantuml/ugraphic/svg/DriverLineSvg.java
new file mode 100644
index 0000000..2007978
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/svg/DriverLineSvg.java
@@ -0,0 +1,87 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.svg;
+
+import java.awt.geom.Line2D;
+
+import net.sourceforge.plantuml.svg.SvgGraphics;
+import net.sourceforge.plantuml.ugraphic.ClipContainer;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UClip;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.StringUtils;
+
+public class DriverLineSvg implements UDriver<SvgGraphics> {
+
+ private final ClipContainer clipContainer;
+
+ public DriverLineSvg(ClipContainer clipContainer) {
+ this.clipContainer = clipContainer;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, SvgGraphics svg) {
+ final ULine shape = (ULine) ushape;
+
+ double x2 = x + shape.getDX();
+ double y2 = y + shape.getDY();
+
+ final UClip clip = clipContainer.getClip();
+ if (clip != null) {
+ final Line2D.Double line = clip.getClippedLine(new Line2D.Double(x, y, x2, y2));
+ if (line == null) {
+ return;
+ }
+ x = line.x1;
+ y = line.y1;
+ x2 = line.x2;
+ y2 = line.y2;
+ }
+
+ // // Shadow
+ // if (shape.getDeltaShadow() != 0) {
+ // svg.svgLineShadow(x, y, x2, y2, shape.getDeltaShadow());
+ // }
+
+ // svg.setStroke(new BasicStroke((float)
+ // param.getStroke().getThickness()));
+ final String color = StringUtils.getAsSvg(mapper, param.getColor());
+ svg.setStrokeColor(color);
+ svg.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDasharraySvg());
+ svg.svgLine(x, y, x2, y2, shape.getDeltaShadow());
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/svg/DriverPathSvg.java b/src/net/sourceforge/plantuml/ugraphic/svg/DriverPathSvg.java
new file mode 100644
index 0000000..586f691
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/svg/DriverPathSvg.java
@@ -0,0 +1,83 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.svg;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorGradient;
+import net.sourceforge.plantuml.svg.SvgGraphics;
+import net.sourceforge.plantuml.ugraphic.ClipContainer;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.ugraphic.g2d.DriverShadowedG2d;
+import net.sourceforge.plantuml.StringUtils;
+
+public class DriverPathSvg extends DriverShadowedG2d implements UDriver<SvgGraphics> {
+
+ private final ClipContainer clipContainer;
+
+ public DriverPathSvg(ClipContainer clipContainer) {
+ this.clipContainer = clipContainer;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, SvgGraphics svg) {
+ final UPath shape = (UPath) ushape;
+
+ final String color = StringUtils.getAsSvg(mapper, param.getColor());
+ if (shape.isOpenIconic()) {
+ svg.setFillColor(color);
+ svg.setStrokeColor("");
+ svg.setStrokeWidth(0, "");
+ } else {
+ final HtmlColor back = param.getBackcolor();
+ if (back instanceof HtmlColorGradient) {
+ final HtmlColorGradient gr = (HtmlColorGradient) back;
+ final String id = svg.createSvgGradient(StringUtils.getAsHtml(mapper.getMappedColor(gr.getColor1())),
+ StringUtils.getAsHtml(mapper.getMappedColor(gr.getColor2())), gr.getPolicy());
+ svg.setFillColor("url(#" + id + ")");
+ } else {
+ final String backcolor = StringUtils.getAsSvg(mapper, back);
+ svg.setFillColor(backcolor);
+ }
+ svg.setStrokeColor(color);
+ svg.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDasharraySvg());
+ }
+
+ svg.svgPath(x, y, shape, shape.getDeltaShadow());
+
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/svg/DriverPolygonSvg.java b/src/net/sourceforge/plantuml/ugraphic/svg/DriverPolygonSvg.java
new file mode 100644
index 0000000..a3db97b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/svg/DriverPolygonSvg.java
@@ -0,0 +1,89 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.svg;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorGradient;
+import net.sourceforge.plantuml.svg.SvgGraphics;
+import net.sourceforge.plantuml.ugraphic.ClipContainer;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UClip;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.StringUtils;
+
+public class DriverPolygonSvg implements UDriver<SvgGraphics> {
+
+ private final ClipContainer clipContainer;
+
+ public DriverPolygonSvg(ClipContainer clipContainer) {
+ this.clipContainer = clipContainer;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, SvgGraphics svg) {
+ final UPolygon shape = (UPolygon) ushape;
+
+ final double points[] = shape.getPointArray(x, y);
+ final UClip clip = clipContainer.getClip();
+ if (clip != null) {
+ for (int j = 0; j < points.length; j += 2) {
+ if (clip.isInside(points[j], points[j + 1]) == false) {
+ return;
+ }
+ }
+ }
+
+ final String color = StringUtils.getAsSvg(mapper, param.getColor());
+ final HtmlColor back = param.getBackcolor();
+ if (back instanceof HtmlColorGradient) {
+ final HtmlColorGradient gr = (HtmlColorGradient) back;
+ final String id = svg.createSvgGradient(StringUtils.getAsHtml(mapper.getMappedColor(gr.getColor1())),
+ StringUtils.getAsHtml(mapper.getMappedColor(gr.getColor2())), gr.getPolicy());
+ svg.setFillColor("url(#" + id + ")");
+ } else {
+ final String backcolorString = StringUtils.getAsSvg(mapper, back);
+ svg.setFillColor(backcolorString);
+ }
+
+ svg.setStrokeColor(color);
+ svg.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDasharraySvg());
+
+ svg.svgPolygon(shape.getDeltaShadow(), points);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/svg/DriverRectangleSvg.java b/src/net/sourceforge/plantuml/ugraphic/svg/DriverRectangleSvg.java
new file mode 100644
index 0000000..67bfece
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/svg/DriverRectangleSvg.java
@@ -0,0 +1,96 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.svg;
+
+import java.awt.geom.Rectangle2D;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorGradient;
+import net.sourceforge.plantuml.svg.SvgGraphics;
+import net.sourceforge.plantuml.ugraphic.ClipContainer;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UClip;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.StringUtils;
+
+public class DriverRectangleSvg implements UDriver<SvgGraphics> {
+
+ private final ClipContainer clipContainer;
+
+ public DriverRectangleSvg(ClipContainer clipContainer) {
+ this.clipContainer = clipContainer;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, SvgGraphics svg) {
+ final URectangle rect = (URectangle) ushape;
+
+ final double rx = rect.getRx();
+ final double ry = rect.getRy();
+ double width = rect.getWidth();
+ double height = rect.getHeight();
+
+ final String color = StringUtils.getAsSvg(mapper, param.getColor());
+ final HtmlColor back = param.getBackcolor();
+ if (back instanceof HtmlColorGradient) {
+ final HtmlColorGradient gr = (HtmlColorGradient) back;
+ final String id = svg.createSvgGradient(StringUtils.getAsHtml(mapper.getMappedColor(gr.getColor1())),
+ StringUtils.getAsHtml(mapper.getMappedColor(gr.getColor2())), gr.getPolicy());
+ svg.setFillColor("url(#" + id + ")");
+ svg.setStrokeColor(color);
+ } else {
+ final String backcolor = StringUtils.getAsSvg(mapper, back);
+ svg.setFillColor(backcolor);
+ svg.setStrokeColor(color);
+ }
+
+ svg.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDasharraySvg());
+
+ final UClip clip = clipContainer.getClip();
+ if (clip != null) {
+ final Rectangle2D.Double r = clip.getClippedRectangle(new Rectangle2D.Double(x, y, width, height));
+ x = r.x;
+ y = r.y;
+ width = r.width;
+ height = r.height;
+ if (height <= 0) {
+ return;
+ }
+ }
+ svg.svgRectangle(x, y, width, height, rx / 2, ry / 2, rect.getDeltaShadow());
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/svg/DriverTextAsPathSvg.java b/src/net/sourceforge/plantuml/ugraphic/svg/DriverTextAsPathSvg.java
new file mode 100644
index 0000000..878bb17
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/svg/DriverTextAsPathSvg.java
@@ -0,0 +1,105 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.svg;
+
+import java.awt.font.FontRenderContext;
+import java.awt.font.TextLayout;
+import java.awt.geom.PathIterator;
+
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.svg.SvgGraphics;
+import net.sourceforge.plantuml.ugraphic.ClipContainer;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UClip;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.ugraphic.UText;
+
+public class DriverTextAsPathSvg implements UDriver<SvgGraphics> {
+
+ private final FontRenderContext fontRenderContext;
+ private final ClipContainer clipContainer;
+
+ public DriverTextAsPathSvg(FontRenderContext fontRenderContext, ClipContainer clipContainer) {
+ this.fontRenderContext = fontRenderContext;
+ this.clipContainer = clipContainer;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, SvgGraphics svg) {
+
+ final UClip clip = clipContainer.getClip();
+ if (clip != null && clip.isInside(x, y) == false) {
+ return;
+ }
+
+ final UText shape = (UText) ushape;
+ final FontConfiguration fontConfiguration = shape.getFontConfiguration();
+ final UFont font = fontConfiguration.getFont();
+
+ final TextLayout t = new TextLayout(shape.getText(), font.getFont(), fontRenderContext);
+ drawPathIterator(svg, x, y, t.getOutline(null).getPathIterator(null));
+
+ }
+
+ static void drawPathIterator(SvgGraphics svg, double x, double y, PathIterator path) {
+
+ svg.newpath();
+ final double coord[] = new double[6];
+ while (path.isDone() == false) {
+ final int code = path.currentSegment(coord);
+ if (code == PathIterator.SEG_MOVETO) {
+ svg.moveto(coord[0] + x, coord[1] + y);
+ } else if (code == PathIterator.SEG_LINETO) {
+ svg.lineto(coord[0] + x, coord[1] + y);
+ } else if (code == PathIterator.SEG_CLOSE) {
+ svg.closepath();
+ } else if (code == PathIterator.SEG_CUBICTO) {
+ svg.curveto(coord[0] + x, coord[1] + y, coord[2] + x, coord[3] + y, coord[4] + x, coord[5] + y);
+ } else if (code == PathIterator.SEG_QUADTO) {
+ svg.quadto(coord[0] + x, coord[1] + y, coord[2] + x, coord[3] + y);
+ } else {
+ throw new UnsupportedOperationException("code=" + code);
+ }
+
+ path.next();
+ }
+
+ svg.fill(path.getWindingRule());
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/svg/DriverTextSvg.java b/src/net/sourceforge/plantuml/ugraphic/svg/DriverTextSvg.java
new file mode 100644
index 0000000..e5816b4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/svg/DriverTextSvg.java
@@ -0,0 +1,103 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.svg;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.FontStyle;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.svg.SvgGraphics;
+import net.sourceforge.plantuml.ugraphic.ClipContainer;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UClip;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UFontContext;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.ugraphic.UText;
+import net.sourceforge.plantuml.StringUtils;
+
+public class DriverTextSvg implements UDriver<SvgGraphics> {
+
+ private final StringBounder stringBounder;
+ private final ClipContainer clipContainer;
+
+ public DriverTextSvg(StringBounder stringBounder, ClipContainer clipContainer) {
+ this.stringBounder = stringBounder;
+ this.clipContainer = clipContainer;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, SvgGraphics svg) {
+
+ final UClip clip = clipContainer.getClip();
+ if (clip != null && clip.isInside(x, y) == false) {
+ return;
+ }
+
+ final UText shape = (UText) ushape;
+ final FontConfiguration fontConfiguration = shape.getFontConfiguration();
+ final UFont font = fontConfiguration.getFont();
+ String fontWeight = null;
+ if (fontConfiguration.containsStyle(FontStyle.BOLD) || font.isBold()) {
+ fontWeight = "bold";
+ }
+ String fontStyle = null;
+ if (fontConfiguration.containsStyle(FontStyle.ITALIC) || font.isItalic()) {
+ fontStyle = "italic";
+ }
+ String textDecoration = null;
+ if (fontConfiguration.containsStyle(FontStyle.UNDERLINE)) {
+ textDecoration = "underline";
+ } else if (fontConfiguration.containsStyle(FontStyle.STRIKE)) {
+ textDecoration = "line-through";
+ }
+
+ svg.setFillColor(StringUtils.getAsHtml(mapper.getMappedColor(fontConfiguration.getColor())));
+ String text = shape.getText();
+ if (text.startsWith(" ")) {
+ final double space = stringBounder.calculateDimension(font, " ").getWidth();
+ while (text.startsWith(" ")) {
+ x += space;
+ text = text.substring(1);
+ }
+ }
+ text = text.trim();
+ final Dimension2D dim = stringBounder.calculateDimension(font, text);
+ svg.text(text, x, y, font.getFamily(UFontContext.SVG), font.getSize(), fontWeight, fontStyle, textDecoration,
+ dim.getWidth(), fontConfiguration.getAttributes());
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/svg/UGraphicSvg.java b/src/net/sourceforge/plantuml/ugraphic/svg/UGraphicSvg.java
new file mode 100644
index 0000000..2ce5faf
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/svg/UGraphicSvg.java
@@ -0,0 +1,174 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.svg;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import javax.xml.transform.TransformerException;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.graphic.HtmlColorGradient;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.posimo.DotPath;
+import net.sourceforge.plantuml.svg.SvgGraphics;
+import net.sourceforge.plantuml.ugraphic.AbstractCommonUGraphic;
+import net.sourceforge.plantuml.ugraphic.AbstractUGraphic;
+import net.sourceforge.plantuml.ugraphic.ClipContainer;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UCenteredCharacter;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic2;
+import net.sourceforge.plantuml.ugraphic.UImage;
+import net.sourceforge.plantuml.ugraphic.UImageSvg;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UText;
+
+public class UGraphicSvg extends AbstractUGraphic<SvgGraphics> implements ClipContainer, UGraphic2 {
+
+ private final StringBounder stringBounder;
+ private final boolean textAsPath2;
+
+ @Override
+ protected AbstractCommonUGraphic copyUGraphic() {
+ return new UGraphicSvg(this);
+ }
+
+ private UGraphicSvg(UGraphicSvg other) {
+ super(other);
+ this.stringBounder = other.stringBounder;
+ this.textAsPath2 = other.textAsPath2;
+ register();
+ }
+
+ public UGraphicSvg(ColorMapper colorMapper, String backcolor, boolean textAsPath, double scale) {
+ this(colorMapper, new SvgGraphics(backcolor, scale), textAsPath);
+ }
+
+ public UGraphicSvg(ColorMapper colorMapper, boolean textAsPath, double scale) {
+ this(colorMapper, new SvgGraphics(scale), textAsPath);
+ }
+
+ public UGraphicSvg(ColorMapper mapper, HtmlColorGradient gr, boolean textAsPath, double scale) {
+ this(mapper, new SvgGraphics(scale), textAsPath);
+
+ final SvgGraphics svg = getGraphicObject();
+ svg.paintBackcolorGradient(mapper, gr);
+ }
+
+ @Override
+ protected boolean manageHiddenAutomatically() {
+ return false;
+ }
+
+ @Override
+ protected void beforeDraw() {
+ getGraphicObject().setHidden(getParam().isHidden());
+ }
+
+ @Override
+ protected void afterDraw() {
+ getGraphicObject().setHidden(false);
+ }
+
+ private UGraphicSvg(ColorMapper colorMapper, SvgGraphics svg, boolean textAsPath) {
+ super(colorMapper, svg);
+ stringBounder = TextBlockUtils.getDummyStringBounder();
+ this.textAsPath2 = textAsPath;
+ register();
+ }
+
+ private void register() {
+ registerDriver(URectangle.class, new DriverRectangleSvg(this));
+ if (textAsPath2) {
+ registerDriver(UText.class, new DriverTextAsPathSvg(TextBlockUtils.getFontRenderContext(), this));
+ } else {
+ registerDriver(UText.class, new DriverTextSvg(getStringBounder(), this));
+ }
+ registerDriver(ULine.class, new DriverLineSvg(this));
+ registerDriver(UPolygon.class, new DriverPolygonSvg(this));
+ registerDriver(UEllipse.class, new DriverEllipseSvg(this));
+ registerDriver(UImage.class, new DriverImagePng(this));
+ registerDriver(UImageSvg.class, new DriverImageSvgSvg());
+ registerDriver(UPath.class, new DriverPathSvg(this));
+ registerDriver(DotPath.class, new DriverDotPathSvg());
+ registerDriver(UCenteredCharacter.class, new DriverCenteredCharacterSvg());
+ }
+
+ public SvgGraphics getSvgGraphics() {
+ return this.getGraphicObject();
+ }
+
+ public StringBounder getStringBounder() {
+ return stringBounder;
+ }
+
+ public void createXml(OutputStream os) throws IOException {
+ try {
+ getGraphicObject().createXml(os);
+ } catch (TransformerException e) {
+ throw new IOException(e.toString());
+ }
+ }
+
+ public void startUrl(Url url) {
+ getGraphicObject().openLink(url.getUrl(), url.getTooltip());
+ }
+
+ public void closeAction() {
+ getGraphicObject().closeLink();
+ }
+
+ public void writeImageTOBEMOVED(OutputStream os, String metadata, int dpi) throws IOException {
+ createXml(os);
+ }
+
+ // @Override
+ // public String startHiddenGroup() {
+ // getGraphicObject().startHiddenGroup();
+ // return null;
+ // }
+ //
+ // @Override
+ // public String closeHiddenGroup() {
+ // getGraphicObject().closeHiddenGroup();
+ // return null;
+ // }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/tikz/DriverAtomTextTikz.java b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverAtomTextTikz.java
new file mode 100644
index 0000000..b2ac3bb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverAtomTextTikz.java
@@ -0,0 +1,53 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.tikz;
+
+import net.sourceforge.plantuml.creole.AtomText;
+import net.sourceforge.plantuml.tikz.TikzGraphics;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverAtomTextTikz implements UDriver<TikzGraphics> {
+
+ public void draw(UShape shape, double x, double y, ColorMapper mapper, UParam param, TikzGraphics tikz) {
+ final AtomText text = (AtomText) shape;
+
+ tikz.text(x, y, text.getText());
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/tikz/DriverCenteredCharacterTikz.java b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverCenteredCharacterTikz.java
new file mode 100644
index 0000000..087d994
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverCenteredCharacterTikz.java
@@ -0,0 +1,66 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.tikz;
+
+import java.awt.font.TextLayout;
+
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.graphic.UnusedSpace;
+import net.sourceforge.plantuml.tikz.TikzGraphics;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UCenteredCharacter;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverCenteredCharacterTikz implements UDriver<TikzGraphics> {
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, TikzGraphics tikz) {
+ final UCenteredCharacter centeredCharacter = (UCenteredCharacter) ushape;
+ final char c = centeredCharacter.getChar();
+ final UFont font = centeredCharacter.getFont();
+ final UnusedSpace unusedSpace = UnusedSpace.getUnusedSpace(font, c);
+
+ final double xpos = x - unusedSpace.getCenterX() - 0.5;
+ final double ypos = y - unusedSpace.getCenterY() - 0.5;
+
+ final TextLayout t = new TextLayout("" + c, font.getFont(), TextBlockUtils.getFontRenderContext());
+ tikz.setStrokeColor(mapper.getMappedColor(param.getColor()));
+ tikz.drawPathIterator(xpos, ypos, t.getOutline(null).getPathIterator(null));
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/tikz/DriverDotPathTikz.java b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverDotPathTikz.java
new file mode 100644
index 0000000..a49a762
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverDotPathTikz.java
@@ -0,0 +1,53 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.tikz;
+
+import net.sourceforge.plantuml.posimo.DotPath;
+import net.sourceforge.plantuml.tikz.TikzGraphics;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverDotPathTikz implements UDriver<TikzGraphics> {
+
+ public void draw(UShape shape, double x, double y, ColorMapper mapper, UParam param, TikzGraphics tikz) {
+ final DotPath path = (DotPath) shape;
+ tikz.setStrokeColor(mapper.getMappedColor(param.getColor()));
+ tikz.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDashTikz());
+ tikz.upath(x, y, path.toUPath());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/tikz/DriverEllipseTikz.java b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverEllipseTikz.java
new file mode 100644
index 0000000..16acdd4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverEllipseTikz.java
@@ -0,0 +1,73 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.tikz;
+
+import net.sourceforge.plantuml.tikz.TikzGraphics;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverEllipseTikz implements UDriver<TikzGraphics> {
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, TikzGraphics tikz) {
+ final UEllipse shape = (UEllipse) ushape;
+ final double width = shape.getWidth();
+ final double height = shape.getHeight();
+
+ double start = shape.getStart();
+ final double extend = shape.getExtend();
+ final double cx = x + width / 2;
+ final double cy = y + height / 2;
+ tikz.setFillColor(mapper.getMappedColor(param.getBackcolor()));
+ tikz.setStrokeColor(mapper.getMappedColor(param.getColor()));
+ tikz.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDashTikz());
+ if (start == 0 && extend == 0) {
+ tikz.ellipse(cx, cy, width / 2, height / 2);
+ } else {
+ throw new UnsupportedOperationException();
+ // // http://www.itk.ilstu.edu/faculty/javila/SVG/SVG_drawing1/elliptical_curve.htm
+ // start = start + 90;
+ // final double x1 = cx + Math.sin(start * Math.PI / 180.) * width / 2;
+ // final double y1 = cy + Math.cos(start * Math.PI / 180.) * height / 2;
+ // final double x2 = cx + Math.sin((start + extend) * Math.PI / 180.) * width / 2;
+ // final double y2 = cy + Math.cos((start + extend) * Math.PI / 180.) * height / 2;
+ // // svg.svgEllipse(x1, y1, 1, 1, 0);
+ // // svg.svgEllipse(x2, y2, 1, 1, 0);
+ // svg.svgArcEllipse(width / 2, height / 2, x1, y1, x2, y2);
+ }
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/tikz/DriverLineTikz.java b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverLineTikz.java
new file mode 100644
index 0000000..20dd8b7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverLineTikz.java
@@ -0,0 +1,56 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.tikz;
+
+import net.sourceforge.plantuml.tikz.TikzGraphics;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverLineTikz implements UDriver<TikzGraphics> {
+
+ public void draw(UShape shape, double x, double y, ColorMapper mapper, UParam param, TikzGraphics tikz) {
+ final ULine line = (ULine) shape;
+
+ double x2 = x + line.getDX();
+ double y2 = y + line.getDY();
+ tikz.setStrokeColor(mapper.getMappedColor(param.getColor()));
+ tikz.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDashTikz());
+ tikz.line(x, y, x2, y2);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/tikz/DriverNoneTikz.java b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverNoneTikz.java
new file mode 100644
index 0000000..1c1754c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverNoneTikz.java
@@ -0,0 +1,48 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.tikz;
+
+import net.sourceforge.plantuml.tikz.TikzGraphics;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverNoneTikz implements UDriver<TikzGraphics> {
+
+ public void draw(UShape shape, double x, double y, ColorMapper mapper, UParam param, TikzGraphics object) {
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/tikz/DriverPolygonTikz.java b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverPolygonTikz.java
new file mode 100644
index 0000000..6aea91d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverPolygonTikz.java
@@ -0,0 +1,57 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.tikz;
+
+import net.sourceforge.plantuml.tikz.TikzGraphics;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverPolygonTikz implements UDriver<TikzGraphics> {
+
+ public void draw(UShape shape, double x, double y, ColorMapper mapper, UParam param, TikzGraphics tikz) {
+ final UPolygon poly = (UPolygon) shape;
+ final double points[] = poly.getPointArray(x, y);
+
+ tikz.setFillColor(mapper.getMappedColor(param.getBackcolor()));
+ tikz.setStrokeColor(mapper.getMappedColor(param.getColor()));
+ tikz.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDashTikz());
+
+ tikz.polygon(points);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/tikz/DriverRectangleTikz.java b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverRectangleTikz.java
new file mode 100644
index 0000000..84b8dc3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverRectangleTikz.java
@@ -0,0 +1,58 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.tikz;
+
+import net.sourceforge.plantuml.tikz.TikzGraphics;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverRectangleTikz implements UDriver<TikzGraphics> {
+
+ public void draw(UShape shape, double x, double y, ColorMapper mapper, UParam param, TikzGraphics tikz) {
+ final URectangle rect = (URectangle) shape;
+
+ final double width = rect.getWidth();
+ final double height = rect.getHeight();
+ tikz.setFillColor(mapper.getMappedColor(param.getBackcolor()));
+ tikz.setStrokeColor(mapper.getMappedColor(param.getColor()));
+ tikz.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDashTikz());
+ tikz.rectangle(x, y, width, height);
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/tikz/DriverUPathTikz.java b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverUPathTikz.java
new file mode 100644
index 0000000..a9e3b3a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverUPathTikz.java
@@ -0,0 +1,53 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.tikz;
+
+import net.sourceforge.plantuml.tikz.TikzGraphics;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverUPathTikz implements UDriver<TikzGraphics> {
+
+ public void draw(UShape shape, double x, double y, ColorMapper mapper, UParam param, TikzGraphics tikz) {
+ final UPath path = (UPath) shape;
+ tikz.setStrokeColor(mapper.getMappedColor(param.getColor()));
+ tikz.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDashTikz());
+ tikz.upath(x, y, path);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/tikz/DriverUTextTikz.java b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverUTextTikz.java
new file mode 100644
index 0000000..9507fd8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverUTextTikz.java
@@ -0,0 +1,53 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.tikz;
+
+import net.sourceforge.plantuml.tikz.TikzGraphics;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.ugraphic.UText;
+
+public class DriverUTextTikz implements UDriver<TikzGraphics> {
+
+ public void draw(UShape shape, double x, double y, ColorMapper mapper, UParam param, TikzGraphics tikz) {
+ final UText text = (UText) shape;
+
+ tikz.text(x, y, text.getText());
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/tikz/UGraphicTikz.java b/src/net/sourceforge/plantuml/ugraphic/tikz/UGraphicTikz.java
new file mode 100644
index 0000000..9303cc9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/tikz/UGraphicTikz.java
@@ -0,0 +1,124 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.tikz;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.creole.AtomText;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.posimo.DotPath;
+import net.sourceforge.plantuml.tikz.TikzGraphics;
+import net.sourceforge.plantuml.ugraphic.AbstractCommonUGraphic;
+import net.sourceforge.plantuml.ugraphic.AbstractUGraphic;
+import net.sourceforge.plantuml.ugraphic.ClipContainer;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UCenteredCharacter;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic2;
+import net.sourceforge.plantuml.ugraphic.UImage;
+import net.sourceforge.plantuml.ugraphic.UImageSvg;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UText;
+
+public class UGraphicTikz extends AbstractUGraphic<TikzGraphics> implements ClipContainer, UGraphic2 {
+
+ private final StringBounder stringBounder;
+
+ private UGraphicTikz(ColorMapper colorMapper, TikzGraphics tikz) {
+ super(colorMapper, tikz);
+ this.stringBounder = TextBlockUtils.getDummyStringBounder();
+ register();
+
+ }
+
+ public UGraphicTikz(ColorMapper colorMapper) {
+ this(colorMapper, new TikzGraphics());
+
+ }
+
+ @Override
+ protected AbstractCommonUGraphic copyUGraphic() {
+ return new UGraphicTikz(this);
+ }
+
+ private UGraphicTikz(UGraphicTikz other) {
+ super(other);
+ this.stringBounder = other.stringBounder;
+ register();
+ }
+
+ private void register() {
+ registerDriver(URectangle.class, new DriverRectangleTikz());
+ registerDriver(UText.class, new DriverUTextTikz());
+ registerDriver(AtomText.class, new DriverAtomTextTikz());
+ registerDriver(ULine.class, new DriverLineTikz());
+ registerDriver(UPolygon.class, new DriverPolygonTikz());
+ registerDriver(UEllipse.class, new DriverEllipseTikz());
+ registerDriver(UImage.class, new DriverNoneTikz());
+ registerDriver(UImageSvg.class, new DriverNoneTikz());
+ registerDriver(UPath.class, new DriverUPathTikz());
+ registerDriver(DotPath.class, new DriverDotPathTikz());
+ registerDriver(UCenteredCharacter.class, new DriverCenteredCharacterTikz());
+ }
+
+ public StringBounder getStringBounder() {
+ return stringBounder;
+ }
+
+ public void startUrl(Url url) {
+ }
+
+ public void closeAction() {
+ }
+
+ public void writeImageTOBEMOVED(OutputStream os, String metadata, int dpi) throws IOException {
+ createTikz(os);
+ }
+
+ public void createTikz(OutputStream os) throws IOException {
+ getGraphicObject().createData(os);
+ }
+
+ public boolean isSpecialTxt() {
+ return true;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/txt/UGraphicTxt.java b/src/net/sourceforge/plantuml/ugraphic/txt/UGraphicTxt.java
new file mode 100644
index 0000000..528259a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/txt/UGraphicTxt.java
@@ -0,0 +1,119 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.txt;
+
+import java.awt.geom.Dimension2D;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.asciiart.TextStringBounder;
+import net.sourceforge.plantuml.asciiart.TranslatedCharArea;
+import net.sourceforge.plantuml.asciiart.UmlCharArea;
+import net.sourceforge.plantuml.asciiart.UmlCharAreaImpl;
+import net.sourceforge.plantuml.graphic.FontStyle;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.AbstractCommonUGraphic;
+import net.sourceforge.plantuml.ugraphic.ClipContainer;
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+import net.sourceforge.plantuml.ugraphic.UImage;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.ugraphic.UText;
+
+public class UGraphicTxt extends AbstractCommonUGraphic implements ClipContainer {
+
+ private final UmlCharArea charArea;
+
+ @Override
+ protected AbstractCommonUGraphic copyUGraphic() {
+ return new UGraphicTxt(this);
+ }
+
+ private UGraphicTxt(UGraphicTxt other) {
+ super(other);
+ this.charArea = other.charArea;
+ }
+
+ public UGraphicTxt() {
+ super(new ColorMapperIdentity());
+ this.charArea = new UmlCharAreaImpl();
+ }
+
+ public StringBounder getStringBounder() {
+ return new TextStringBounder();
+ }
+
+ public void draw(UShape shape) {
+ // final UClip clip = getClip();
+ if (shape instanceof UText) {
+ final UText txt = (UText) shape;
+ final int y = ((int) (getTranslateY() + txt.getDescent())) / 10;
+ if (txt.getFontConfiguration().containsStyle(FontStyle.WAVE)) {
+ charArea.drawHLine('^', y, getDx(), txt.getText().length());
+ charArea.drawStringLR(txt.getText(), 0, y + 1);
+ } else {
+ charArea.drawStringLR(txt.getText(), 0, y);
+ }
+ return;
+ } else if (shape instanceof UImage) {
+ return;
+ }
+ throw new UnsupportedOperationException("cl=" + shape.getClass());
+ }
+
+ public final UmlCharArea getCharArea() {
+ return new TranslatedCharArea(charArea, getDx(), getDy());
+ }
+
+ private int getDy() {
+ return (int) getTranslateY();
+ }
+
+ private int getDx() {
+ return (int) getTranslateX();
+ }
+
+ public void startUrl(Url url) {
+ }
+
+ public void closeAction() {
+ }
+
+ public Dimension2D getDimension() {
+ return new Dimension2DDouble(0, 0);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/visio/DriverDotPathVdx.java b/src/net/sourceforge/plantuml/ugraphic/visio/DriverDotPathVdx.java
new file mode 100644
index 0000000..0df19b1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/visio/DriverDotPathVdx.java
@@ -0,0 +1,50 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.visio;
+
+import net.sourceforge.plantuml.posimo.DotPath;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverDotPathVdx implements UDriver<VisioGraphics> {
+
+ public void draw(UShape shape, double x, double y, ColorMapper mapper, UParam param, VisioGraphics visio) {
+ final DotPath path = (DotPath) shape;
+ visio.upath(x, y, path.toUPath());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/visio/DriverLineVdx.java b/src/net/sourceforge/plantuml/ugraphic/visio/DriverLineVdx.java
new file mode 100644
index 0000000..9e7ed05
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/visio/DriverLineVdx.java
@@ -0,0 +1,55 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.visio;
+
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverLineVdx implements UDriver<VisioGraphics> {
+
+ public void draw(UShape shape, double x, double y, ColorMapper mapper, UParam param, VisioGraphics visio) {
+ final ULine line = (ULine) shape;
+
+ final double dx = line.getDX();
+ final double dy = line.getDY();
+
+ visio.line(x, y, x + dx, y + dy);
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/visio/DriverNoneVdx.java b/src/net/sourceforge/plantuml/ugraphic/visio/DriverNoneVdx.java
new file mode 100644
index 0000000..0c55c5f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/visio/DriverNoneVdx.java
@@ -0,0 +1,47 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.visio;
+
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverNoneVdx implements UDriver<VisioGraphics> {
+
+ public void draw(UShape shape, double x, double y, ColorMapper mapper, UParam param, VisioGraphics object) {
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/visio/DriverPolygonVdx.java b/src/net/sourceforge/plantuml/ugraphic/visio/DriverPolygonVdx.java
new file mode 100644
index 0000000..69c29ba
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/visio/DriverPolygonVdx.java
@@ -0,0 +1,50 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.visio;
+
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverPolygonVdx implements UDriver<VisioGraphics> {
+
+ public void draw(UShape shape, double x, double y, ColorMapper mapper, UParam param, VisioGraphics visio) {
+ final UPolygon poly = (UPolygon) shape;
+ visio.polygon(poly.translate(x, y));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/visio/DriverRectangleVdx.java b/src/net/sourceforge/plantuml/ugraphic/visio/DriverRectangleVdx.java
new file mode 100644
index 0000000..147a989
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/visio/DriverRectangleVdx.java
@@ -0,0 +1,55 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.visio;
+
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverRectangleVdx implements UDriver<VisioGraphics> {
+
+ public void draw(UShape shape, double x, double y, ColorMapper mapper, UParam param, VisioGraphics visio) {
+ final URectangle rect = (URectangle) shape;
+
+ final double width = rect.getWidth();
+ final double height = rect.getHeight();
+
+ visio.rectangle(x, y, width, height);
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/visio/DriverTextVdx.java b/src/net/sourceforge/plantuml/ugraphic/visio/DriverTextVdx.java
new file mode 100644
index 0000000..90419ff
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/visio/DriverTextVdx.java
@@ -0,0 +1,80 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.visio;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UFontContext;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.ugraphic.UText;
+
+public class DriverTextVdx implements UDriver<VisioGraphics> {
+
+ private final StringBounder stringBounder;
+
+ public DriverTextVdx(StringBounder stringBounder) {
+ this.stringBounder = stringBounder;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, VisioGraphics visio) {
+ final UText shape = (UText) ushape;
+ Thread.dumpStack();
+
+ final FontConfiguration fontConfiguration = shape.getFontConfiguration();
+ final UFont font = fontConfiguration.getFont();
+
+ String text = shape.getText();
+ if (text.startsWith(" ")) {
+ final double space = stringBounder.calculateDimension(font, " ").getWidth();
+ while (text.startsWith(" ")) {
+ x += space;
+ text = text.substring(1);
+ }
+ }
+
+ text = text.trim();
+ final Dimension2D dim = stringBounder.calculateDimension(font, text);
+ visio.text(text, x, y, font.getFamily(UFontContext.SVG), font.getSize(), dim.getWidth(), dim.getHeight(),
+ fontConfiguration.getAttributes());
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/visio/DriverUPathVdx.java b/src/net/sourceforge/plantuml/ugraphic/visio/DriverUPathVdx.java
new file mode 100644
index 0000000..6f04eb4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/visio/DriverUPathVdx.java
@@ -0,0 +1,52 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.visio;
+
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverUPathVdx implements UDriver<VisioGraphics> {
+
+ public void draw(UShape shape, double x, double y, ColorMapper mapper, UParam param, VisioGraphics visio) {
+ final UPath path = (UPath) shape;
+
+ visio.upath(x, y, path);
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/visio/UGraphicVdx.java b/src/net/sourceforge/plantuml/ugraphic/visio/UGraphicVdx.java
new file mode 100644
index 0000000..f4966f1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/visio/UGraphicVdx.java
@@ -0,0 +1,123 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.visio;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.creole.AtomText;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.posimo.DotPath;
+import net.sourceforge.plantuml.ugraphic.AbstractCommonUGraphic;
+import net.sourceforge.plantuml.ugraphic.AbstractUGraphic;
+import net.sourceforge.plantuml.ugraphic.ClipContainer;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UCenteredCharacter;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic2;
+import net.sourceforge.plantuml.ugraphic.UImage;
+import net.sourceforge.plantuml.ugraphic.UImageSvg;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UText;
+
+public class UGraphicVdx extends AbstractUGraphic<VisioGraphics> implements ClipContainer, UGraphic2 {
+
+ private final StringBounder stringBounder;
+
+ private UGraphicVdx(ColorMapper colorMapper, VisioGraphics visio) {
+ super(colorMapper, visio);
+ this.stringBounder = TextBlockUtils.getDummyStringBounder();
+ register();
+
+ }
+
+ public UGraphicVdx(ColorMapper colorMapper) {
+ this(colorMapper, new VisioGraphics());
+
+ }
+
+ @Override
+ protected AbstractCommonUGraphic copyUGraphic() {
+ return new UGraphicVdx(this);
+ }
+
+ private UGraphicVdx(UGraphicVdx other) {
+ super(other);
+ this.stringBounder = other.stringBounder;
+ register();
+ }
+
+ private void register() {
+ registerDriver(URectangle.class, new DriverRectangleVdx());
+ registerDriver(UText.class, new DriverTextVdx(stringBounder));
+ registerDriver(AtomText.class, new DriverNoneVdx());
+ registerDriver(ULine.class, new DriverLineVdx());
+ registerDriver(UPolygon.class, new DriverPolygonVdx());
+ registerDriver(UEllipse.class, new DriverNoneVdx());
+ registerDriver(UImage.class, new DriverNoneVdx());
+ registerDriver(UImageSvg.class, new DriverNoneVdx());
+ registerDriver(UPath.class, new DriverUPathVdx());
+ registerDriver(DotPath.class, new DriverDotPathVdx());
+ registerDriver(UCenteredCharacter.class, new DriverNoneVdx());
+ }
+
+ public StringBounder getStringBounder() {
+ return stringBounder;
+ }
+
+ public void startUrl(Url url) {
+ }
+
+ public void closeAction() {
+ }
+
+ public void writeImageTOBEMOVED(OutputStream os, String metadata, int dpi) throws IOException {
+ createVsd(os);
+ }
+
+ public void createVsd(OutputStream os) throws IOException {
+ getGraphicObject().createVsd(os);
+ }
+
+ public boolean isSpecialTxt() {
+ return true;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/visio/VisioGraphics.java b/src/net/sourceforge/plantuml/ugraphic/visio/VisioGraphics.java
new file mode 100644
index 0000000..2cc4e43
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/visio/VisioGraphics.java
@@ -0,0 +1,187 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.visio;
+
+import java.awt.geom.Point2D;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import net.sourceforge.plantuml.Log;
+import net.sourceforge.plantuml.golem.MinMaxDouble;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.USegment;
+import net.sourceforge.plantuml.ugraphic.USegmentType;
+
+public class VisioGraphics {
+
+ private final List<VisioShape> shapes = new ArrayList<VisioShape>();
+ private final MinMaxDouble limits = new MinMaxDouble();
+
+ public void createVsd(OutputStream os) throws IOException {
+ final double width = toInches(limits.getMaxX());
+ final double height = toInches(limits.getMaxY());
+
+ out(os, "<?xml version='1.0' encoding='utf-8' ?>");
+ out(os,
+ "<VisioDocument xml:space='preserve' xmlns='http://schemas.microsoft.com/visio/2003/core' xmlns:vx='http://schemas.microsoft.com/visio/2006/extension' xmlns:v14='http://schemas.microsoft.com/office/visio/2010/extension'>");
+ out(os, "<DocumentProperties>");
+ out(os, "<Creator>PlantUML</Creator>");
+ out(os, "</DocumentProperties>");
+ out(os, "<DocumentSheet NameU='TheDoc' LineStyle='0' FillStyle='0' TextStyle='0'>");
+ out(os, "</DocumentSheet>");
+ out(os, "<Masters/>");
+ out(os, "<Pages>");
+ out(os, "<Page ID='0' NameU='Page-1' Name='Page 1' ViewScale='1' ViewCenterX='" + (width / 2)
+ + "' ViewCenterY='" + (height / 2) + "'>");
+ out(os, "<PageSheet LineStyle='0' FillStyle='0' TextStyle='0'>");
+ out(os, "<PageProps>");
+ out(os, "<PageWidth Unit='IN_F'>" + width + "</PageWidth>");
+ out(os, "<PageHeight Unit='IN_F'>" + height + "</PageHeight>");
+ out(os, "<PageScale Unit='IN_F'>1</PageScale>");
+ out(os, "<DrawingScale Unit='IN_F'>2</DrawingScale>"); // change for scale
+ out(os, "<DrawingSizeType>3</DrawingSizeType>");
+ out(os, "<DrawingScaleType>0</DrawingScaleType>");
+ out(os, "<InhibitSnap>0</InhibitSnap>");
+ out(os, "</PageProps>");
+ out(os, "</PageSheet>");
+ out(os, "<Shapes>");
+ for (VisioShape sh : shapes) {
+ sh.yReverse(height).print(os);
+ // sh.print(os);
+ }
+ out(os, "</Shapes>");
+ out(os, "</Page>");
+ out(os, "</Pages>");
+ out(os, "</VisioDocument>");
+ }
+
+ private void out(OutputStream os, String s) throws IOException {
+ os.write(s.getBytes());
+ os.write("\n".getBytes());
+ }
+
+ private double toInches(double val) {
+ return val / 72.0;
+ }
+
+ private void ensureVisible(double x, double y) {
+ limits.manage(x, y);
+ }
+
+ public void rectangle(double x, double y, double width, double height) {
+ ensureVisible(x, y);
+ ensureVisible(x + width, y + height);
+ final VisioRectangle rect = VisioRectangle.createInches(shapes.size() + 1, x, y, width, height);
+ shapes.add(rect);
+ }
+
+ public void text(String text, double x, double y, String family, int fontSize, double width, double height,
+ Map<String, String> attributes) {
+ // System.err.println("x=" + x);
+ // System.err.println("y=" + y);
+ // System.err.println("text=" + text);
+ // System.err.println("family=" + family);
+ // System.err.println("fontSize=" + fontSize);
+ // System.err.println("width=" + width);
+ // System.err.println("attributes=" + attributes);
+ ensureVisible(x, y);
+ final VisioText txt = VisioText.createInches(shapes.size() + 1, text, fontSize, x, y, width, height);
+ shapes.add(txt);
+
+ }
+
+ public void line(double x1, double y1, double x2, double y2) {
+ ensureVisible(x1, y1);
+ if (x1 == x2 && y1 == y2) {
+ return;
+ }
+ ensureVisible(x2, y2);
+ final VisioLine line = VisioLine.createInches(shapes.size() + 1, x1, y1, x2, y2);
+ shapes.add(line);
+ }
+
+ private void line(Point2D p1, Point2D p2) {
+ line(p1.getX(), p1.getY(), p2.getX(), p2.getY());
+ }
+
+ public void upath(final double x, final double y, UPath path) {
+ double lx = x;
+ double ly = y;
+ for (USegment seg : path) {
+ final USegmentType type = seg.getSegmentType();
+ final double coord[] = seg.getCoord();
+ if (type == USegmentType.SEG_MOVETO) {
+ lx = coord[0] + x;
+ ly = coord[1] + y;
+ } else if (type == USegmentType.SEG_LINETO) {
+ line(lx, ly, coord[0] + x, coord[1] + y);
+ lx = coord[0] + x;
+ ly = coord[1] + y;
+ } else if (type == USegmentType.SEG_QUADTO) {
+ line(lx, ly, coord[2] + x, coord[3] + y);
+ lx = coord[2] + x;
+ ly = coord[3] + y;
+ } else if (type == USegmentType.SEG_CUBICTO) {
+ line(lx, ly, coord[4] + x, coord[5] + y);
+ // linePoint(lx, ly, coord[0] + x, coord[1] + y);
+ // linePoint(coord[0] + x, coord[1] + y, coord[2] + x, coord[3] + y);
+ // linePoint(coord[2] + x, coord[3] + y, coord[4] + x, coord[5] + y);
+ lx = coord[4] + x;
+ ly = coord[5] + y;
+ } else if (type == USegmentType.SEG_CLOSE) {
+ // Nothing
+ } else {
+ Log.println("unknown " + seg);
+ }
+
+ }
+
+ }
+
+ public void polygon(UPolygon poly) {
+ Point2D last = null;
+ for (Point2D pt : poly.getPoints()) {
+ if (last != null) {
+ line(last, pt);
+ }
+ last = pt;
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/visio/VisioLine.java b/src/net/sourceforge/plantuml/ugraphic/visio/VisioLine.java
new file mode 100644
index 0000000..c2481ad
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/visio/VisioLine.java
@@ -0,0 +1,117 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.visio;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+public class VisioLine implements VisioShape {
+
+ private final int id;
+ private final double x1;
+ private final double y1;
+ private final double x2;
+ private final double y2;
+
+ public static VisioLine createInches(int id, double x1, double y1, double x2, double y2) {
+ return new VisioLine(id, toInches(x1), toInches(y1), toInches(x2), toInches(y2));
+ }
+
+ private VisioLine(int id, double x1, double y1, double x2, double y2) {
+ if (x1 < 0 || y1 < 0 || x2 < 0 || y2 < 0) {
+ throw new IllegalArgumentException();
+ }
+ this.id = id;
+ this.x1 = x1;
+ this.y1 = y1;
+ this.x2 = x2;
+ this.y2 = y2;
+ }
+
+ public VisioShape yReverse(double maxY) {
+ return new VisioLine(id, x1, maxY - y1, x2, maxY - y2);
+ }
+
+ private static double toInches(double val) {
+ return val / 72.0;
+ }
+
+ public void print(OutputStream os) throws IOException {
+ out(os, "<Shape ID='" + id + "' Type='Shape' LineStyle='3' FillStyle='3' TextStyle='3'>");
+ out(os, "<XForm>");
+ final double ddx = x2 - x1;
+ final double ddy = y2 - y1;
+ out(os, "<PinX F='(BeginX+EndX)/2'>" + ((x1 + x2) / 2) + "</PinX>");
+ out(os, "<PinY F='(BeginY+EndY)/2'>" + ((y1 + y2) / 2) + "</PinY>");
+ final double len = Math.sqrt(ddx * ddx + ddy * ddy);
+ out(os, "<Width F='Sqrt((EndX-BeginX)^2+(EndY-BeginY)^2)'>" + len + "</Width>");
+ out(os, "<Height>0</Height>");
+ out(os, "<LocPinX F='Width*0.5'>" + (len / 2) + "</LocPinX>");
+ out(os, "<LocPinY F='Height*0.5'>0</LocPinY>");
+ final double atan2 = Math.atan2(ddy, ddx);
+ out(os, "<Angle F='ATan2(EndY-BeginY,EndX-BeginX)'>" + atan2 + "</Angle>");
+ out(os, "<FlipX>0</FlipX>");
+ out(os, "<FlipY>0</FlipY>");
+ out(os, "<ResizeMode>0</ResizeMode>");
+ out(os, "</XForm>");
+ out(os, "<XForm1D>");
+ out(os, "<BeginX>" + x1 + "</BeginX>");
+ out(os, "<BeginY>" + y1 + "</BeginY>");
+ out(os, "<EndX>" + x2 + "</EndX>");
+ out(os, "<EndY>" + y2 + "</EndY>");
+ out(os, "</XForm1D>");
+ out(os, "<Geom IX='0'>");
+ out(os, "<NoFill>1</NoFill>");
+ out(os, "<NoLine>0</NoLine>");
+ out(os, "<NoShow>0</NoShow>");
+ out(os, "<NoSnap>0</NoSnap>");
+ out(os, "<MoveTo IX='1'>");
+ out(os, "<X F='Width*0'>0</X>");
+ out(os, "<Y>0</Y>");
+ out(os, "</MoveTo>");
+ out(os, "<LineTo IX='2'>");
+ out(os, "<X F='Width*1'>" + len + "</X>");
+ out(os, "<Y>0</Y>");
+ out(os, "</LineTo>");
+ out(os, "</Geom>");
+ out(os, "</Shape>");
+ }
+
+ private void out(OutputStream os, String s) throws IOException {
+ os.write(s.getBytes());
+ os.write("\n".getBytes());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/visio/VisioRectangle.java b/src/net/sourceforge/plantuml/ugraphic/visio/VisioRectangle.java
new file mode 100644
index 0000000..11cfd9f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/visio/VisioRectangle.java
@@ -0,0 +1,120 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.visio;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+public class VisioRectangle implements VisioShape {
+
+ private final int id;
+ private final double x;
+ private final double y;
+ private final double width;
+ private final double height;
+
+ public static VisioRectangle createInches(int id, double x, double y, double width, double height) {
+ return new VisioRectangle(id, toInches(x), toInches(y), toInches(width), toInches(height));
+ }
+
+ private VisioRectangle(int id, double x, double y, double width, double height) {
+ if (x < 0 || y < 0 || width < 0 || height < 0) {
+ // throw new IllegalArgumentException();
+ }
+ this.id = id;
+ this.x = x;
+ this.y = y;
+ this.width = width;
+ this.height = height;
+ }
+
+ public VisioShape yReverse(double maxY) {
+ final double y2 = maxY - (y + height);
+ return new VisioRectangle(id, x, y2, width, height);
+ }
+
+ private static double toInches(double val) {
+ return val / 72.0;
+ }
+
+ public void print(OutputStream os) throws IOException {
+ out(os, "<Shape ID='" + id + "' Type='Shape' LineStyle='3' FillStyle='3' TextStyle='3'>");
+ out(os, "<XForm>");
+ out(os, "<PinX>" + (x + width / 2) + "</PinX>");
+ out(os, "<PinY>" + (y + height / 2) + "</PinY>");
+ out(os, "<Width>" + width + "</Width>");
+ out(os, "<Height>" + height + "</Height>");
+ // out(os, "<LocPinX F='Width*0.5'>" + (x + width / 2) + "</LocPinX>");
+ // out(os, "<LocPinY F='Height*0.5'>" + (y + height / 2) + "</LocPinY>");
+ out(os, "<Angle>0</Angle>");
+ out(os, "<FlipX>0</FlipX>");
+ out(os, "<FlipY>0</FlipY>");
+ out(os, "<ResizeMode>0</ResizeMode>");
+ out(os, "</XForm>");
+ out(os, "<Geom IX='0'>");
+ out(os, "<NoFill>0</NoFill>");
+ out(os, "<NoLine>0</NoLine>");
+ out(os, "<NoShow>0</NoShow>");
+ out(os, "<NoSnap>0</NoSnap>");
+ out(os, "<MoveTo IX='1'>");
+ out(os, "<X F='Width*0'>0</X>");
+ out(os, "<Y F='Height*0'>0</Y>");
+ out(os, "</MoveTo>");
+ out(os, "<LineTo IX='2'>");
+ out(os, "<X F='Width*1'>" + width + "</X>");
+ out(os, "<Y F='Height*0'>0</Y>");
+ out(os, "</LineTo>");
+ out(os, "<LineTo IX='3'>");
+ out(os, "<X F='Width*1'>" + width + "</X>");
+ out(os, "<Y F='Height*1'>" + height + "</Y>");
+ out(os, "</LineTo>");
+ out(os, "<LineTo IX='4'>");
+ out(os, "<X F='Width*0'>0</X>");
+ out(os, "<Y F='Height*1'>" + height + "</Y>");
+ out(os, "</LineTo>");
+ out(os, "<LineTo IX='5'>");
+ out(os, "<X F='Geometry1.X1'>0</X>");
+ out(os, "<Y F='Geometry1.Y1'>0</Y>");
+ out(os, "</LineTo>");
+ out(os, "</Geom>");
+ out(os, "</Shape>");
+ }
+
+ private void out(OutputStream os, String s) throws IOException {
+ os.write(s.getBytes());
+ os.write("\n".getBytes());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/visio/VisioShape.java b/src/net/sourceforge/plantuml/ugraphic/visio/VisioShape.java
new file mode 100644
index 0000000..47f4da3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/visio/VisioShape.java
@@ -0,0 +1,46 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.visio;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+public interface VisioShape {
+
+ public void print(OutputStream os) throws IOException;
+
+ public VisioShape yReverse(double maxY);
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/visio/VisioText.java b/src/net/sourceforge/plantuml/ugraphic/visio/VisioText.java
new file mode 100644
index 0000000..d06cb12
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/visio/VisioText.java
@@ -0,0 +1,128 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.ugraphic.visio;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+public class VisioText implements VisioShape {
+
+ private final int id;
+ private final String text;
+ private final int fontSize;
+ private final double x;
+ private final double y;
+ private final double width;
+ private final double height;
+
+ private final double coefFont = 150.0;
+
+ public static VisioText createInches(int id, String text, int fontSize, double x, double y, double width,
+ double height) {
+ final double coef = 1.8;
+ return new VisioText(id, text, fontSize, toInches(x), toInches(y + 2.5), toInches(width * coef),
+ toInches(height * coef));
+ }
+
+ private static double toInches(double val) {
+ return val / 72.0;
+ }
+
+ private VisioText(int id, String text, int fontSize, double x, double y, double width, double height) {
+ this.id = id;
+ this.text = text;
+ this.x = x;
+ this.y = y;
+ this.height = height;
+ this.width = width;
+ this.fontSize = fontSize;
+ }
+
+ public void print(OutputStream os) throws IOException {
+ out(os, "<Shape ID='" + id + "' Type='Shape' LineStyle='1' FillStyle='1' TextStyle='3'>");
+ out(os, "<XForm>");
+ out(os, "<PinX>" + x + "</PinX>");
+ out(os, "<PinY>" + y + "</PinY>");
+ out(os, "<Width>" + width + "</Width>");
+ out(os, "<Height>" + height + "</Height>");
+ // out(os, "<PinX>1.0625</PinX>");
+ // out(os, "<PinY>1.9375</PinY>");
+ out(os, "<LocPinX F='Width*0'>0</LocPinX>");
+ out(os, "<LocPinY F='Height*0'>0</LocPinY>");
+ out(os, "<Angle>0</Angle>");
+ out(os, "<FlipX>0</FlipX>");
+ out(os, "<FlipY>0</FlipY>");
+ out(os, "<ResizeMode>0</ResizeMode>");
+ out(os, "</XForm>");
+ out(os, "<TextBlock>");
+ out(os, "<VerticalAlign>0</VerticalAlign>");
+ out(os, "</TextBlock>");
+ out(os, "<Char IX='" + id + "'>");
+ out(os, "<Font F='Inh'>0</Font>");
+ out(os, "<Color F='Inh'>0</Color>");
+ out(os, "<Style F='Inh'>0</Style>");
+ out(os, "<Case F='Inh'>0</Case>");
+ out(os, "<Pos F='Inh'>0</Pos>");
+ out(os, "<FontScale F='Inh'>1</FontScale>");
+ out(os, "<Locale F='Inh'>0</Locale>");
+ out(os, "<Size Unit='PT'>" + fontSize / coefFont + "</Size>");
+ out(os, "<DblUnderline F='Inh'>0</DblUnderline>");
+ out(os, "<Overline F='Inh'>0</Overline>");
+ out(os, "<Strikethru F='Inh'>0</Strikethru>");
+ out(os, "<Perpendicular F='Inh'>0</Perpendicular>");
+ out(os, "<Letterspace F='Inh'>0</Letterspace>");
+ out(os, "<ColorTrans F='Inh'>0</ColorTrans>");
+ out(os, "</Char>");
+
+ out(os, "<Para IX='" + id + "'>");
+ out(os, "<HorzAlign>0</HorzAlign>");
+ out(os, "</Para>");
+
+ out(os, "<Text><cp IX='" + id + "'/><pp IX='" + id + "'/>" + text + "</Text>");
+ out(os, "</Shape>");
+
+ }
+
+ public VisioShape yReverse(double maxY) {
+ final double y2 = maxY - y;
+ return new VisioText(id, text, fontSize, x, y2, width, height);
+ }
+
+ private void out(OutputStream os, String s) throws IOException {
+ os.write(s.getBytes());
+ os.write("\n".getBytes());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/utils/CharHidder.java b/src/net/sourceforge/plantuml/utils/CharHidder.java
new file mode 100644
index 0000000..2295ad7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/utils/CharHidder.java
@@ -0,0 +1,96 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.utils;
+
+public class CharHidder {
+
+ public static String addTileAtBegin(String s) {
+ return "~" + s;
+ }
+
+ public static String hide(String s) {
+ // System.err.println("hide " + s);
+ final StringBuilder result = new StringBuilder();
+ for (int i = 0; i < s.length(); i++) {
+ final char c = s.charAt(i);
+ if (c == '~' && i + 1 < s.length()) {
+ i++;
+ final char c2 = s.charAt(i);
+ if (isToBeHidden(c2)) {
+ result.append(hideChar(c2));
+ } else {
+ result.append(c);
+ result.append(c2);
+ }
+
+ } else {
+ result.append(c);
+ }
+ }
+ return result.toString();
+ }
+
+ private static boolean isToBeHidden(final char c) {
+ if (c == '_' || c == '\"' || c == '#' || c == ']' || c == '[' || c == '*' || c == '.' || c == '/') {
+ return true;
+ }
+ return false;
+ }
+
+ private static char hideChar(char c) {
+ if (c > 255) {
+ throw new IllegalArgumentException();
+ }
+ return (char) ('\uE000' + c);
+ }
+
+ private static char unhideChar(char c) {
+ if (c >= '\uE000' && c <= '\uE0FF') {
+ return (char) (c - '\uE000');
+ }
+ return c;
+ }
+
+ public static String unhide(String s) {
+ final StringBuilder result = new StringBuilder();
+ for (int i = 0; i < s.length(); i++) {
+ final char c = s.charAt(i);
+ result.append(unhideChar(c));
+ }
+ // System.err.println("unhide " + result);
+ return result.toString();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/utils/MathUtils.java b/src/net/sourceforge/plantuml/utils/MathUtils.java
new file mode 100644
index 0000000..69c21f4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/utils/MathUtils.java
@@ -0,0 +1,66 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.utils;
+
+public class MathUtils {
+
+ public static double max(double a, double b) {
+ return Math.max(a, b);
+ }
+
+ public static double max(double a, double b, double c) {
+ return Math.max(Math.max(a, b), c);
+ }
+
+ public static double max(double a, double b, double c, double d) {
+ return Math.max(Math.max(a, b), Math.max(c, d));
+ }
+
+ public static double limitation(double v, double min, double max) {
+ if (min >= max) {
+ // assert false : "min="+min+" max="+max+" v="+v;
+ return v;
+ // throw new IllegalArgumentException("min="+min+" max="+max+" v="+v);
+ }
+ if (v < min) {
+ return min;
+ }
+ if (v > max) {
+ return max;
+ }
+ return v;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/utils/StartUtils.java b/src/net/sourceforge/plantuml/utils/StartUtils.java
new file mode 100644
index 0000000..a6e878c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/utils/StartUtils.java
@@ -0,0 +1,74 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.utils;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+
+public class StartUtils {
+
+ public static boolean isArobaseStartDiagram(String s) {
+ s = s.trim();
+ return s.startsWith("@start");
+ }
+
+ public static boolean isArobaseEndDiagram(String s) {
+ s = s.trim();
+ return s.startsWith("@end");
+ }
+
+ public static boolean isArobasePauseDiagram(String s) {
+ s = s.trim();
+ return s.startsWith("@pause");
+ }
+
+ public static boolean isArobaseUnpauseDiagram(String s) {
+ s = s.trim();
+ return s.startsWith("@unpause");
+ }
+
+ private static final Pattern append = MyPattern.cmpile("^\\W*@append");
+
+ public static String getPossibleAppend(String s) {
+ final Matcher m = append.matcher(s);
+ if (m.find()) {
+ return s.substring(m.group(0).length()).trim();
+ }
+ return null;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/utils/UniqueSequence.java b/src/net/sourceforge/plantuml/utils/UniqueSequence.java
new file mode 100644
index 0000000..6bc9e7e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/utils/UniqueSequence.java
@@ -0,0 +1,57 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.utils;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+import net.sourceforge.plantuml.cucadiagram.Code;
+
+public class UniqueSequence {
+
+ private static final AtomicInteger cpt = new AtomicInteger(1);
+
+ public static void reset() {
+ cpt.set(0);
+ }
+
+ public static int getValue() {
+ return cpt.addAndGet(1);
+ }
+
+ public static Code getCode(String prefix) {
+ return Code.of(prefix + getValue());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/version/IteratorCounter.java b/src/net/sourceforge/plantuml/version/IteratorCounter.java
new file mode 100644
index 0000000..7ec069f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/version/IteratorCounter.java
@@ -0,0 +1,43 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.version;
+
+import java.util.Iterator;
+
+public interface IteratorCounter extends Iterator<String> {
+
+ public int currentNum();
+
+}
diff --git a/src/net/sourceforge/plantuml/version/IteratorCounterImpl.java b/src/net/sourceforge/plantuml/version/IteratorCounterImpl.java
new file mode 100644
index 0000000..876e35e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/version/IteratorCounterImpl.java
@@ -0,0 +1,66 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.version;
+
+import java.util.Iterator;
+
+public class IteratorCounterImpl implements IteratorCounter {
+
+ private final Iterator<String> it;
+ private int nb;
+
+ public IteratorCounterImpl(Iterator<String> it) {
+ this.it = it;
+ this.nb = 0;
+ }
+
+ public int currentNum() {
+ return nb;
+ }
+
+ public boolean hasNext() {
+ return it.hasNext();
+ }
+
+ public String next() {
+ nb++;
+ return it.next();
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/version/License.java b/src/net/sourceforge/plantuml/version/License.java
new file mode 100644
index 0000000..254c368
--- /dev/null
+++ b/src/net/sourceforge/plantuml/version/License.java
@@ -0,0 +1,331 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.version;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public enum License {
+
+ GPL, LGPL, APACHE, EPL, MIT;
+
+ public static License getCurrent() {
+ return MIT;
+ }
+
+ private void addMit(final List<String> text) {
+ text.add("PlantUML is free software; you can redistribute it and/or modify it");
+ text.add("under the terms of the MIT License.");
+ text.add("");
+ text.add("See http://opensource.org/licenses/MIT");
+ text.add("");
+ text.add("Permission is hereby granted, free of charge, to any person obtaining");
+ text.add("a copy of this software and associated documentation files (the \"Software\"),");
+ text.add("to deal in the Software without restriction, including without limitation");
+ text.add("the rights to use, copy, modify, merge, publish, distribute, sublicense,");
+ text.add("and/or sell copies of the Software, and to permit persons to whom the");
+ text.add("Software is furnished to do so, subject to the following conditions:");
+ text.add("");
+ text.add("The above copyright notice and this permission notice shall be included");
+ text.add("in all copies or substantial portions of the Software.");
+ text.add("");
+ text.add("THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS");
+ text.add("OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,");
+ text.add("FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE");
+ text.add("AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,");
+ text.add("WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR");
+ text.add("IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.");
+ text.add("");
+ text.add("Note that images (whatever their format : PNG, SVG...) generated by running PlantUML");
+ text.add("are owned by the author of their corresponding sources code (that is, their");
+ text.add("textual description in PlantUML language). Those images are not covered by");
+ text.add("the MIT License.");
+ text.add("");
+ text.add("The generated images can then be used without any reference to the MIT License.");
+ text.add("It is not even necessary to stipulate that they have been generated with PlantUML,");
+ text.add("also this will be appreciate by PlantUML team.");
+ text.add("");
+ text.add("There is an exception : if the textual description in PlantUML language is also covered");
+ text.add("by a license (like the MIT), then the generated images are logically covered");
+ text.add("by the very same license.");
+ }
+
+ private void addEpl(final List<String> text) {
+ text.add("PlantUML is free software; you can redistribute it and/or modify it");
+ text.add("under the terms of the Eclipse Public License.");
+ text.add("");
+ text.add("THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC");
+ text.add("LICENSE (\"AGREEMENT\"). [Eclipse Public License - v 1.0]");
+ text.add("");
+ text.add("ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES");
+ text.add("RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.");
+ text.add("");
+ text.add("You may obtain a copy of the License at");
+ text.add("");
+ text.add("http://www.eclipse.org/legal/epl-v10.html");
+ text.add("");
+ text.add("Unless required by applicable law or agreed to in writing, software");
+ text.add("distributed under the License is distributed on an \"AS IS\" BASIS,");
+ text.add("WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.");
+ text.add("See the License for the specific language governing permissions and");
+ text.add("limitations under the License.");
+ text.add("");
+ text.add("Note that images (whatever their format : PNG, SVG...) generated by running PlantUML");
+ text.add("are owned by the author of their corresponding sources code (that is, their");
+ text.add("textual description in PlantUML language). Those images are not covered by");
+ text.add("the Eclipse Public License.");
+ text.add("");
+ text.add("The generated images can then be used without any reference to the Eclipse Public License.");
+ text.add("It is not even necessary to stipulate that they have been generated with PlantUML,");
+ text.add("also this will be appreciate by PlantUML team.");
+ text.add("");
+ text.add("There is an exception : if the textual description in PlantUML language is also covered");
+ text.add("by a license (like the EPL), then the generated images are logically covered");
+ text.add("by the very same license.");
+ }
+
+ private void addApache(final List<String> text) {
+ text.add("PlantUML is free software; you can redistribute it and/or modify it");
+ text.add("under the terms of the Apache Software License.");
+ text.add("");
+ text.add("Licensed under the Apache License, Version 2.0 (the \"License\");");
+ text.add("you may not use this file except in compliance with the License.");
+ text.add("You may obtain a copy of the License at");
+ text.add("");
+ text.add("http://www.apache.org/licenses/LICENSE-2.0");
+ text.add("");
+ text.add("Unless required by applicable law or agreed to in writing, software");
+ text.add("distributed under the License is distributed on an \"AS IS\" BASIS,");
+ text.add("WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.");
+ text.add("See the License for the specific language governing permissions and");
+ text.add("limitations under the License.");
+ text.add("");
+ text.add("Note that images (whatever their format : PNG, SVG...) generated by running PlantUML");
+ text.add("are owned by the author of their corresponding sources code (that is, their");
+ text.add("textual description in PlantUML language). Those images are not covered by");
+ text.add("the Apache license.");
+ text.add("");
+ text.add("The generated images can then be used without any reference to the Apache license.");
+ text.add("It is not even necessary to stipulate that they have been generated with PlantUML,");
+ text.add("also this will be appreciate by PlantUML team.");
+ text.add("");
+ text.add("There is an exception : if the textual description in PlantUML language is also covered");
+ text.add("by a license (like the Apache), then the generated images are logically covered");
+ text.add("by the very same license.");
+ }
+
+ private void addGpl(final List<String> text) {
+ text.add("PlantUML is free software; you can redistribute it and/or modify it");
+ text.add("under the terms of the GNU General Public License as published by");
+ text.add("the Free Software Foundation, either version 3 of the License, or");
+ text.add("(at your option) any later version.");
+ text.add("");
+ text.add("PlantUML distributed in the hope that it will be useful, but");
+ text.add("WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY");
+ text.add("or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public");
+ text.add("License for more details.");
+ text.add("");
+ text.add("You should have received a copy of the GNU General Public");
+ text.add("License along with this library; if not, write to the Free Software");
+ text.add("Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,");
+ text.add("USA.");
+ text.add("");
+ text.add("Note that images (whatever their format : PNG, SVG...) generated by running PlantUML");
+ text.add("are owned by the author of their corresponding sources code (that is, their");
+ text.add("textual description in PlantUML language). Those images are not covered by");
+ text.add("the GPL license.");
+ text.add("");
+ text.add("The generated images can then be used without any reference to the GPL license.");
+ text.add("It is not even necessary to stipulate that they have been generated with PlantUML,");
+ text.add("also this will be appreciate by PlantUML team.");
+ text.add("");
+ text.add("There is an exception : if the textual description in PlantUML language is also covered");
+ text.add("by a license (like the GPL), then the generated images are logically covered");
+ text.add("by the very same license.");
+ }
+
+ private void addLgpl(final List<String> text) {
+ text.add("PlantUML is free software; you can redistribute it and/or modify it");
+ text.add("under the terms of the GNU Lesser General Public License as published by");
+ text.add("the Free Software Foundation, either version 3 of the License, or");
+ text.add("(at your option) any later version.");
+ text.add("");
+ text.add("PlantUML distributed in the hope that it will be useful, but");
+ text.add("WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY");
+ text.add("or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public");
+ text.add("License for more details.");
+ text.add("");
+ text.add("You should have received a copy of the GNU Lesser General Public");
+ text.add("License along with this library; if not, write to the Free Software");
+ text.add("Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,");
+ text.add("USA.");
+ text.add("");
+ text.add("Note that images (whatever their format : PNG, SVG...) generated by running PlantUML");
+ text.add("are owned by the author of their corresponding sources code (that is, their");
+ text.add("textual description in PlantUML language). Those images are not covered by");
+ text.add("the LGPL license.");
+ text.add("");
+ text.add("The generated images can then be used without any reference to the LGPL license.");
+ text.add("It is not even necessary to stipulate that they have been generated with PlantUML,");
+ text.add("although this will be appreciate by PlantUML team.");
+ text.add("");
+ text.add("There is an exception : if the textual description in PlantUML language is also covered");
+ text.add("by a license (like the LGPL), then the generated images are logically covered");
+ text.add("by the very same license.");
+ }
+
+ private List<String> getHeaderStart() {
+ final List<String> text = new ArrayList<String>();
+ text.add("========================================================================");
+ text.add("PlantUML : a free UML diagram generator");
+ text.add("========================================================================");
+ text.add("");
+ text.add("(C) Copyright 2009-2014, Arnaud Roques");
+ text.add("");
+ text.add("Project Info: http://plantuml.sourceforge.net");
+ text.add("");
+ return text;
+ }
+
+ public List<String> getJavaHeader() {
+ final List<String> h = new ArrayList<String>();
+ h.add("/* ========================================================================");
+ h.add(" * PlantUML : a free UML diagram generator");
+ h.add(" * ========================================================================");
+ h.add(" *");
+ h.add(" * (C) Copyright 2009-2014, Arnaud Roques");
+ h.add(" *");
+ h.add(" * Project Info: http://plantuml.sourceforge.net");
+ h.add(" * ");
+ h.add(" * This file is part of PlantUML.");
+ h.add(" *");
+ if (this == License.LGPL) {
+ h.add(" * PlantUML is free software; you can redistribute it and/or modify it");
+ h.add(" * under the terms of the GNU Lesser General Public License as published by");
+ h.add(" * the Free Software Foundation, either version 3 of the License, or");
+ h.add(" * (at your option) any later version.");
+ h.add(" *");
+ h.add(" * PlantUML distributed in the hope that it will be useful, but");
+ h.add(" * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY");
+ h.add(" * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public");
+ h.add(" * License for more details.");
+ h.add(" *");
+ h.add(" * You should have received a copy of the GNU Lesser General Public");
+ h.add(" * License along with this library; if not, write to the Free Software");
+ h.add(" * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,");
+ h.add(" * USA.");
+ h.add(" *");
+ } else if (this == License.APACHE) {
+ h.add(" * Licensed under the Apache License, Version 2.0 (the \"License\");");
+ h.add(" * you may not use this file except in compliance with the License.");
+ h.add(" * You may obtain a copy of the License at");
+ h.add(" * ");
+ h.add(" * http://www.apache.org/licenses/LICENSE-2.0");
+ h.add(" * ");
+ h.add(" * Unless required by applicable law or agreed to in writing, software");
+ h.add(" * distributed under the License is distributed on an \"AS IS\" BASIS,");
+ h.add(" * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.");
+ h.add(" * See the License for the specific language governing permissions and");
+ h.add(" * limitations under the License.");
+ h.add(" *");
+ } else if (this == License.EPL) {
+ h.add(" * THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC");
+ h.add(" * LICENSE (\"AGREEMENT\"). [Eclipse Public License - v 1.0]");
+ h.add(" * ");
+ h.add(" * ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES");
+ h.add(" * RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.");
+ h.add(" * ");
+ h.add(" * You may obtain a copy of the License at");
+ h.add(" * ");
+ h.add(" * http://www.eclipse.org/legal/epl-v10.html");
+ h.add(" * ");
+ h.add(" * Unless required by applicable law or agreed to in writing, software");
+ h.add(" * distributed under the License is distributed on an \"AS IS\" BASIS,");
+ h.add(" * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.");
+ h.add(" * See the License for the specific language governing permissions and");
+ h.add(" * limitations under the License.");
+ h.add(" * ");
+ } else if (this == License.MIT) {
+ h.add(" * Licensed under The MIT License (Massachusetts Institute of Technology License)");
+ h.add(" * ");
+ h.add(" * See http://opensource.org/licenses/MIT");
+ h.add(" * ");
+ h.add(" * Permission is hereby granted, free of charge, to any person obtaining");
+ h.add(" * a copy of this software and associated documentation files (the \"Software\"),");
+ h.add(" * to deal in the Software without restriction, including without limitation");
+ h.add(" * the rights to use, copy, modify, merge, publish, distribute, sublicense,");
+ h.add(" * and/or sell copies of the Software, and to permit persons to whom the");
+ h.add(" * Software is furnished to do so, subject to the following conditions:");
+ h.add(" * ");
+ h.add(" * The above copyright notice and this permission notice shall be included");
+ h.add(" * in all copies or substantial portions of the Software.");
+ h.add(" * ");
+ h.add(" * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS");
+ h.add(" * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,");
+ h.add(" * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE");
+ h.add(" * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,");
+ h.add(" * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR");
+ h.add(" * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.");
+ h.add(" * ");
+ }
+ h.add(" *");
+ h.add(" * Original Author: Arnaud Roques");
+ h.add(" */");
+ return Collections.unmodifiableList(h);
+ }
+
+ public List<String> getText() {
+ final List<String> text = getHeaderStart();
+ if (this == License.GPL) {
+ addGpl(text);
+ } else if (this == License.MIT) {
+ addMit(text);
+ } else if (this == License.EPL) {
+ addEpl(text);
+ } else if (this == License.APACHE) {
+ addApache(text);
+ } else if (this == License.LGPL) {
+ addLgpl(text);
+ } else {
+ throw new IllegalStateException();
+ }
+ text.add("");
+ text.add("Icon provided by OpenIconic : https://useiconic.com/open/");
+ text.add("");
+ return text;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/version/PSystemLicense.java b/src/net/sourceforge/plantuml/version/PSystemLicense.java
new file mode 100644
index 0000000..d2563b8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/version/PSystemLicense.java
@@ -0,0 +1,86 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.version;
+
+import java.awt.Font;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.core.DiagramDescription;
+import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.graphic.GraphicPosition;
+import net.sourceforge.plantuml.graphic.GraphicStrings;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+import net.sourceforge.plantuml.ugraphic.ImageBuilder;
+import net.sourceforge.plantuml.ugraphic.UAntiAliasing;
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public class PSystemLicense extends AbstractPSystem {
+
+ private final List<String> strings = new ArrayList<String>();
+
+ PSystemLicense() throws IOException {
+ strings.addAll(License.getCurrent().getText());
+ }
+
+ public ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormat) throws IOException {
+ final GraphicStrings result = getGraphicStrings();
+ final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(),
+ getMetadata(), null, 0, 0, null, false);
+ imageBuilder.addUDrawable(result);
+ return imageBuilder.writeImageTOBEMOVED(fileFormat.getFileFormat(), os);
+ }
+
+ public static PSystemLicense create() throws IOException {
+ return new PSystemLicense();
+ }
+
+ private GraphicStrings getGraphicStrings() throws IOException {
+ final UFont font = new UFont("SansSerif", Font.PLAIN, 12);
+ return new GraphicStrings(strings, font, HtmlColorUtils.BLACK, HtmlColorUtils.WHITE, UAntiAliasing.ANTI_ALIASING_ON,
+ null, GraphicPosition.BACKGROUND_CORNER_BOTTOM_RIGHT);
+ }
+
+ public DiagramDescription getDescription() {
+ return new DiagramDescriptionImpl("(License)", getClass());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/version/PSystemLicenseFactory.java b/src/net/sourceforge/plantuml/version/PSystemLicenseFactory.java
new file mode 100644
index 0000000..affcc05
--- /dev/null
+++ b/src/net/sourceforge/plantuml/version/PSystemLicenseFactory.java
@@ -0,0 +1,57 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.version;
+
+import java.io.IOException;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.Log;
+import net.sourceforge.plantuml.command.PSystemSingleLineFactory;
+
+public class PSystemLicenseFactory extends PSystemSingleLineFactory {
+
+ @Override
+ protected AbstractPSystem executeLine(String line) {
+ try {
+ if (line.matches("(?i)^li[sc][ea]n[sc]e\\s*$")) {
+ return PSystemLicense.create();
+ }
+ } catch (IOException e) {
+ Log.error("Error " + e);
+ }
+ return null;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/version/PSystemVersion.java b/src/net/sourceforge/plantuml/version/PSystemVersion.java
new file mode 100644
index 0000000..d319cab
--- /dev/null
+++ b/src/net/sourceforge/plantuml/version/PSystemVersion.java
@@ -0,0 +1,277 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.version;
+
+import java.awt.Font;
+import java.awt.image.BufferedImage;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Properties;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.imageio.ImageIO;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.Log;
+import net.sourceforge.plantuml.core.DiagramDescription;
+import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.cucadiagram.dot.GraphvizUtils;
+import net.sourceforge.plantuml.graphic.GraphicPosition;
+import net.sourceforge.plantuml.graphic.GraphicStrings;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+import net.sourceforge.plantuml.ugraphic.ImageBuilder;
+import net.sourceforge.plantuml.ugraphic.UAntiAliasing;
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public class PSystemVersion extends AbstractPSystem {
+
+ private final List<String> strings = new ArrayList<String>();
+ private BufferedImage image;
+
+ PSystemVersion(boolean withImage, List<String> args) {
+ strings.addAll(args);
+ if (withImage) {
+ image = getPlantumlImage();
+ }
+ }
+
+ public static BufferedImage getPlantumlImage() {
+ try {
+ final InputStream is = PSystemVersion.class.getResourceAsStream("logo.png");
+ final BufferedImage image = ImageIO.read(is);
+ is.close();
+ return image;
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ public static BufferedImage getCharlieImage() {
+ try {
+ final InputStream is = PSystemVersion.class.getResourceAsStream("charlie.png");
+ final BufferedImage image = ImageIO.read(is);
+ is.close();
+ return image;
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ public static BufferedImage getPlantumlSmallIcon() {
+ try {
+ final InputStream is = PSystemVersion.class.getResourceAsStream("favicon.png");
+ final BufferedImage image = ImageIO.read(is);
+ is.close();
+ return image;
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ private static BufferedImage transparentIcon;
+
+ public static BufferedImage getPlantumlSmallIcon2() {
+ if (transparentIcon != null) {
+ return transparentIcon;
+ }
+ final BufferedImage ico = getPlantumlSmallIcon();
+ if (ico == null) {
+ return null;
+ }
+ transparentIcon = new BufferedImage(ico.getWidth(), ico.getHeight(), BufferedImage.TYPE_INT_ARGB_PRE);
+ for (int i = 0; i < ico.getWidth(); i++) {
+ for (int j = 0; j < ico.getHeight(); j++) {
+ final int col = ico.getRGB(i, j);
+ if (col != ico.getRGB(0, 0)) {
+ transparentIcon.setRGB(i, j, col);
+ }
+ }
+ }
+ return transparentIcon;
+ }
+
+ public ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormat) throws IOException {
+ final GraphicStrings result = getGraphicStrings();
+ final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(),
+ getMetadata(), null, 0, 0, null, false);
+ imageBuilder.addUDrawable(result);
+ return imageBuilder.writeImageTOBEMOVED(fileFormat.getFileFormat(), os);
+ }
+
+ public static PSystemVersion createShowVersion() {
+ final List<String> strings = new ArrayList<String>();
+ strings.add("<b>PlantUML version " + Version.versionString() + "</b> (" + Version.compileTimeString() + ")");
+ strings.add("(" + License.getCurrent() + " source distribution)");
+ strings.add(" ");
+
+ strings.addAll(GraphvizUtils.getTestDotStrings(true));
+ strings.add(" ");
+ final Properties p = System.getProperties();
+ strings.add(p.getProperty("java.runtime.name"));
+ strings.add(p.getProperty("java.vm.name"));
+ strings.add(p.getProperty("java.runtime.version"));
+ strings.add(p.getProperty("os.name"));
+ strings.add("Processors: " + Runtime.getRuntime().availableProcessors());
+ return new PSystemVersion(true, strings);
+ }
+
+ public static PSystemVersion createShowAuthors() {
+ // Duplicate in OptionPrint
+ final List<String> strings = new ArrayList<String>();
+ strings.add("<b>PlantUML version " + Version.versionString() + "</b> (" + Version.compileTimeString() + ")");
+ strings.add("(" + License.getCurrent() + " source distribution)");
+ strings.add(" ");
+ strings.add("<u>Original idea</u>: Arnaud Roques");
+ strings.add("<u>Word Macro</u>: Alain Bertucat & Matthieu Sabatier");
+ strings.add("<u>Word Add-in</u>: Adriaan van den Brand");
+ strings.add("<u>Eclipse Plugin</u>: Claude Durif & Anne Pecoil");
+ strings.add("<u>Servlet & XWiki</u>: Maxime Sinclair");
+ strings.add("<u>Site design</u>: Raphael Cotisson");
+ strings.add("<u>Logo</u>: Benjamin Croizet");
+
+ strings.add(" ");
+ strings.add("http://plantuml.sourceforge.net");
+ strings.add(" ");
+ return new PSystemVersion(true, strings);
+ }
+
+ public static PSystemVersion createCheckVersions(String host, String port) {
+ final List<String> strings = new ArrayList<String>();
+ strings.add("<b>PlantUML version " + Version.versionString() + "</b> (" + Version.compileTimeString() + ")");
+
+ final int lastversion = extractDownloadableVersion(host, port);
+
+ int lim = 7;
+ if (lastversion == -1) {
+ strings.add("<b><color:red>Error</b>");
+ strings.add("<color:red>Cannot connect to http://plantuml.sourceforge.net/</b>");
+ strings.add("Maybe you should set your proxy ?");
+ strings.add("@startuml");
+ strings.add("checkversion(proxy=myproxy.com,port=8080)");
+ strings.add("@enduml");
+ lim = 9;
+ } else if (lastversion == 0) {
+ strings.add("<b><color:red>Error</b>");
+ strings.add("Cannot retrieve last version from http://plantuml.sourceforge.net/</b>");
+ } else {
+ strings.add("<b>Last available version for download</b> : " + lastversion);
+ strings.add(" ");
+ if (Version.version() >= lastversion) {
+ strings.add("<b><color:green>Your version is up to date.</b>");
+ } else {
+ strings.add("<b><color:red>A newer version is available for download.</b>");
+ }
+ }
+
+ while (strings.size() < lim) {
+ strings.add(" ");
+ }
+
+ return new PSystemVersion(true, strings);
+ }
+
+ public static int extractDownloadableVersion(String host, String port) {
+ if (host != null && port != null) {
+ System.setProperty("http.proxyHost", host);
+ System.setProperty("http.proxyPort", port);
+ }
+
+ try {
+ final URL url = new URL("http://plantuml.sourceforge.net/download.html");
+ final HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
+ urlConnection.setUseCaches(false);
+ urlConnection.connect();
+ if (urlConnection.getResponseCode() == HttpURLConnection.HTTP_OK) {
+ final BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
+ final int lastversion = extractVersion(in);
+ in.close();
+ urlConnection.disconnect();
+ return lastversion;
+ }
+ } catch (IOException e) {
+ Log.error(e.toString());
+ }
+ return -1;
+ }
+
+ private static int extractVersion(BufferedReader in) throws IOException {
+ String s;
+ final Pattern p = Pattern.compile(".*\\.(\\d{4,5})\\..*");
+ while ((s = in.readLine()) != null) {
+ final Matcher m = p.matcher(s);
+ if (m.matches()) {
+ final String v = m.group(1);
+ return Integer.parseInt(v);
+ }
+ }
+ return 0;
+ }
+
+ public static PSystemVersion createTestDot() throws IOException {
+ final List<String> strings = new ArrayList<String>();
+ strings.addAll(GraphvizUtils.getTestDotStrings(true));
+ return new PSystemVersion(false, strings);
+ }
+
+ private GraphicStrings getGraphicStrings() throws IOException {
+ final UFont font = new UFont("SansSerif", Font.PLAIN, 12);
+ return new GraphicStrings(strings, font, HtmlColorUtils.BLACK, HtmlColorUtils.WHITE, UAntiAliasing.ANTI_ALIASING_ON,
+ image, GraphicPosition.BACKGROUND_CORNER_BOTTOM_RIGHT);
+ }
+
+ public DiagramDescription getDescription() {
+ return new DiagramDescriptionImpl("(Version)", getClass());
+ }
+
+ public List<String> getLines() {
+ return Collections.unmodifiableList(strings);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/version/PSystemVersionFactory.java b/src/net/sourceforge/plantuml/version/PSystemVersionFactory.java
new file mode 100644
index 0000000..841b19d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/version/PSystemVersionFactory.java
@@ -0,0 +1,83 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.version;
+
+import java.io.IOException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.AbstractPSystem;
+import net.sourceforge.plantuml.Log;
+import net.sourceforge.plantuml.command.PSystemSingleLineFactory;
+
+public class PSystemVersionFactory extends PSystemSingleLineFactory {
+
+ @Override
+ protected AbstractPSystem executeLine(String line) {
+ try {
+ if (line.matches("(?i)^(authors?|about)\\s*$")) {
+ return PSystemVersion.createShowAuthors();
+ }
+ if (line.matches("(?i)^version\\s*$")) {
+ return PSystemVersion.createShowVersion();
+ }
+ if (line.matches("(?i)^testdot\\s*$")) {
+ return PSystemVersion.createTestDot();
+ }
+ if (line.matches("(?i)^checkversion\\s*$")) {
+ return PSystemVersion.createCheckVersions(null, null);
+ }
+ final Pattern p1 = Pattern.compile("(?i)^checkversion\\(proxy=([\\w.]+),port=(\\d+)\\)$");
+ final Matcher m1 = p1.matcher(line);
+ if (m1.matches()) {
+ final String host = m1.group(1);
+ final String port = m1.group(2);
+ return PSystemVersion.createCheckVersions(host, port);
+ }
+ final Pattern p2 = Pattern.compile("(?i)^checkversion\\(proxy=([\\w.]+)\\)$");
+ final Matcher m2 = p2.matcher(line);
+ if (m2.matches()) {
+ final String host = m2.group(1);
+ final String port = "80";
+ return PSystemVersion.createCheckVersions(host, port);
+ }
+ } catch (IOException e) {
+ Log.error("Error " + e);
+
+ }
+ return null;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/version/Version.java b/src/net/sourceforge/plantuml/version/Version.java
new file mode 100644
index 0000000..eb0bc15
--- /dev/null
+++ b/src/net/sourceforge/plantuml/version/Version.java
@@ -0,0 +1,76 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.version;
+
+import java.util.Date;
+
+public class Version {
+
+ public static int version() {
+ return 8024;
+ }
+
+ public static String versionString() {
+ if (beta() != 0) {
+ return "" + (version() + 1) + "beta" + beta();
+ }
+ return "" + version();
+ }
+
+ public static String versionString(int size) {
+ final StringBuilder sb = new StringBuilder(versionString());
+ while (sb.length() < size) {
+ sb.append(' ');
+ }
+ return sb.toString();
+ }
+
+ private static int beta() {
+ final int beta = 0;
+ return beta;
+ }
+
+ private static long compileTime() {
+ return 1430665511202L;
+ }
+
+ public static String compileTimeString() {
+ if (beta() != 0) {
+ return versionString();
+ }
+ return new Date(Version.compileTime()).toString();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/version/charlie.png b/src/net/sourceforge/plantuml/version/charlie.png
new file mode 100644
index 0000000..1d4281d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/version/charlie.png
Binary files differ
diff --git a/src/net/sourceforge/plantuml/version/favicon.png b/src/net/sourceforge/plantuml/version/favicon.png
new file mode 100644
index 0000000..f01b74a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/version/favicon.png
Binary files differ
diff --git a/src/net/sourceforge/plantuml/version/logo.png b/src/net/sourceforge/plantuml/version/logo.png
new file mode 100644
index 0000000..986cf4e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/version/logo.png
Binary files differ
diff --git a/src/net/sourceforge/plantuml/xmi/CucaDiagramXmiMaker.java b/src/net/sourceforge/plantuml/xmi/CucaDiagramXmiMaker.java
new file mode 100644
index 0000000..7b13ae3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/xmi/CucaDiagramXmiMaker.java
@@ -0,0 +1,84 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.xmi;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.TransformerException;
+
+import net.sourceforge.plantuml.FileFormat;
+import net.sourceforge.plantuml.Log;
+import net.sourceforge.plantuml.classdiagram.ClassDiagram;
+import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
+
+public final class CucaDiagramXmiMaker {
+
+ private final CucaDiagram diagram;
+ private final FileFormat fileFormat;
+
+ public CucaDiagramXmiMaker(CucaDiagram diagram, FileFormat fileFormat) throws IOException {
+ this.diagram = diagram;
+ this.fileFormat = fileFormat;
+ }
+
+ public void createFiles(OutputStream fos) throws IOException {
+ try {
+ final IXmiClassDiagram xmi;
+ if (fileFormat == FileFormat.XMI_STANDARD) {
+ xmi = new XmiClassDiagramStandard((ClassDiagram) diagram);
+ } else if (fileFormat == FileFormat.XMI_ARGO) {
+ xmi = new XmiClassDiagramArgo((ClassDiagram) diagram);
+ } else if (fileFormat == FileFormat.XMI_STAR) {
+ xmi = new XmiClassDiagramStar((ClassDiagram) diagram);
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ xmi.transformerXml(fos);
+ // fos.close();
+ // return Collections.singletonList(suggestedFile);
+ } catch (ParserConfigurationException e) {
+ Log.error(e.toString());
+ e.printStackTrace();
+ throw new IOException(e.toString());
+ } catch (TransformerException e) {
+ Log.error(e.toString());
+ e.printStackTrace();
+ throw new IOException(e.toString());
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/xmi/IXmiClassDiagram.java b/src/net/sourceforge/plantuml/xmi/IXmiClassDiagram.java
new file mode 100644
index 0000000..d0eb0f5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/xmi/IXmiClassDiagram.java
@@ -0,0 +1,46 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.xmi;
+
+import java.io.OutputStream;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.TransformerException;
+
+public interface IXmiClassDiagram {
+
+ void transformerXml(OutputStream os) throws TransformerException, ParserConfigurationException;
+
+}
diff --git a/src/net/sourceforge/plantuml/xmi/XmiClassDiagramArgo.java b/src/net/sourceforge/plantuml/xmi/XmiClassDiagramArgo.java
new file mode 100644
index 0000000..c03bce2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/xmi/XmiClassDiagramArgo.java
@@ -0,0 +1,289 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.xmi;
+
+import java.io.OutputStream;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import net.sourceforge.plantuml.classdiagram.ClassDiagram;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.cucadiagram.LinkDecor;
+import net.sourceforge.plantuml.cucadiagram.Member;
+import net.sourceforge.plantuml.utils.UniqueSequence;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+public class XmiClassDiagramArgo implements IXmiClassDiagram {
+
+ // http://pierre.ree7.fr/blog/?p=5
+
+ private final ClassDiagram classDiagram;
+
+ private final Document document;
+ private final Element ownedElement;
+
+ private final Set<IEntity> done = new HashSet<IEntity>();
+
+ public XmiClassDiagramArgo(ClassDiagram classDiagram) throws ParserConfigurationException {
+ this.classDiagram = classDiagram;
+ final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+
+ final DocumentBuilder builder = factory.newDocumentBuilder();
+ this.document = builder.newDocument();
+ document.setXmlVersion("1.0");
+ document.setXmlStandalone(true);
+
+ final Element xmi = document.createElement("XMI");
+ xmi.setAttribute("xmi.version", "1.1");
+ xmi.setAttribute("xmlns:UML", "href://org.omg/UML/1.3");
+ document.appendChild(xmi);
+
+ final Element header = document.createElement("XMI.header");
+ xmi.appendChild(header);
+
+ final Element metamodel = document.createElement("XMI.metamodel");
+ metamodel.setAttribute("xmi.name", "UML");
+ metamodel.setAttribute("xmi.version", "1.3");
+ header.appendChild(metamodel);
+
+ final Element content = document.createElement("XMI.content");
+ xmi.appendChild(content);
+
+ // <UML:Model xmi.id="UMLModel.4" name="Design Model"
+ // visibility="public" isSpecification="false" isRoot="false"
+ // isLeaf="false" isAbstract="false">
+ final Element model = document.createElement("UML:Model");
+ model.setAttribute("xmi.id", "model1");
+ model.setAttribute("name", "PlantUML");
+ content.appendChild(model);
+
+ // <UML:Namespace.ownedElement>
+ this.ownedElement = document.createElement("UML:Namespace.ownedElement");
+ model.appendChild(ownedElement);
+
+ for (final IEntity ent : classDiagram.getLeafsvalues()) {
+ if (classDiagram.isStandalone(ent) == false) {
+ continue;
+ }
+ final Element cla = createEntityNode(ent);
+ ownedElement.appendChild(cla);
+ done.add(ent);
+ }
+
+ // if (fileFormat != FileFormat.XMI_STANDARD) {
+ for (final Link link : classDiagram.getLinks()) {
+ addLink(link);
+ }
+ // }
+ }
+
+ public static String forXMI(String s) {
+ return s.replace(':', ' ');
+ }
+
+ public static String forXMI(Display s) {
+ return s.get(0).toString().replace(':', ' ');
+ }
+
+ private void addLink(Link link) {
+ final String assId = "ass" + UniqueSequence.getValue();
+// if ((link.getType().getDecor1() == LinkDecor.EXTENDS || link.getType().getDecor2() == LinkDecor.EXTENDS)
+// && fileFormat == FileFormat.XMI_STAR) {
+// addExtension(link, assId);
+// return;
+// }
+ final Element association = document.createElement("UML:Association");
+ association.setAttribute("xmi.id", assId);
+ association.setAttribute("namespace", "model1");
+ if (link.getLabel() != null) {
+ association.setAttribute("name", forXMI(link.getLabel()));
+ }
+
+ final Element connection = document.createElement("UML:Association.connection");
+ final Element end1 = document.createElement("UML:AssociationEnd");
+ end1.setAttribute("xmi.id", "end" + UniqueSequence.getValue());
+ end1.setAttribute("association", assId);
+ end1.setAttribute("type", link.getEntity1().getUid());
+ if (link.getQualifier1() != null) {
+ end1.setAttribute("name", forXMI(link.getQualifier1()));
+ }
+ final Element endparticipant1 = document.createElement("UML:AssociationEnd.participant");
+ // if (fileFormat == FileFormat.XMI_ARGO) {
+ if (done.contains(link.getEntity1())) {
+ endparticipant1.appendChild(createEntityNodeRef(link.getEntity1()));
+ } else {
+ endparticipant1.appendChild(createEntityNode(link.getEntity1()));
+ done.add(link.getEntity1());
+ }
+// } else if (fileFormat == FileFormat.XMI_STAR) {
+// if (link.getType().getDecor2() == LinkDecor.COMPOSITION) {
+// end1.setAttribute("aggregation", "composite");
+// }
+// if (link.getType().getDecor2() == LinkDecor.AGREGATION) {
+// end1.setAttribute("aggregation", "aggregate");
+// }
+// }
+ end1.appendChild(endparticipant1);
+ connection.appendChild(end1);
+
+ final Element end2 = document.createElement("UML:AssociationEnd");
+ end2.setAttribute("xmi.id", "end" + UniqueSequence.getValue());
+ end2.setAttribute("association", assId);
+ end2.setAttribute("type", link.getEntity2().getUid());
+ if (link.getQualifier2() != null) {
+ end2.setAttribute("name", forXMI(link.getQualifier2()));
+ }
+ final Element endparticipant2 = document.createElement("UML:AssociationEnd.participant");
+ // if (fileFormat == FileFormat.XMI_ARGO) {
+ if (done.contains(link.getEntity2())) {
+ endparticipant2.appendChild(createEntityNodeRef(link.getEntity2()));
+ } else {
+ endparticipant2.appendChild(createEntityNode(link.getEntity2()));
+ done.add(link.getEntity2());
+ }
+ // } else if (fileFormat == FileFormat.XMI_STAR) {
+ // if (link.getType().getDecor1() == LinkDecor.COMPOSITION) {
+ // end2.setAttribute("aggregation", "composite");
+ // }
+ // if (link.getType().getDecor1() == LinkDecor.AGREGATION) {
+ // end2.setAttribute("aggregation", "aggregate");
+ // }
+ // }
+ end2.appendChild(endparticipant2);
+ connection.appendChild(end2);
+
+ association.appendChild(connection);
+
+ ownedElement.appendChild(association);
+
+ }
+
+ private void addExtension(Link link, String assId) {
+ final Element association = document.createElement("UML:Generalization");
+ association.setAttribute("xmi.id", assId);
+ association.setAttribute("namespace", "model1");
+ if (link.getLabel() != null) {
+ association.setAttribute("name", forXMI(link.getLabel()));
+ }
+ if (link.getType().getDecor1() == LinkDecor.EXTENDS) {
+ association.setAttribute("child", link.getEntity1().getUid());
+ association.setAttribute("parent", link.getEntity2().getUid());
+ } else if (link.getType().getDecor2() == LinkDecor.EXTENDS) {
+ association.setAttribute("child", link.getEntity2().getUid());
+ association.setAttribute("parent", link.getEntity1().getUid());
+ } else {
+ throw new IllegalStateException();
+ }
+ ownedElement.appendChild(association);
+
+ }
+
+ private Element createEntityNode(IEntity entity) {
+ // <UML:Class xmi.id="UMLClass.5" name="Class1" visibility="public"
+ // isSpecification="false"
+ // namespace="UMLModel.4" isRoot="false" isLeaf="false"
+ // isAbstract="false" participant="UMLAssociationEnd.11"
+ // isActive="false">
+ final Element cla = document.createElement("UML:Class");
+
+ cla.setAttribute("xmi.id", entity.getUid());
+ cla.setAttribute("name", entity.getDisplay().get(0).toString());
+ cla.setAttribute("namespace", "model1");
+
+ final Element feature = document.createElement("UML:Classifier.feature");
+ cla.appendChild(feature);
+
+ for (Member m : entity.getFieldsToDisplay()) {
+ // <UML:Attribute xmi.id="UMLAttribute.6" name="Attribute1"
+ // visibility="public" isSpecification="false"
+ // ownerScope="instance" changeability="changeable"
+ // targetScope="instance" type="" owner="UMLClass.5"/>
+ final Element attribute = document.createElement("UML:Attribute");
+ attribute.setAttribute("xmi.id", "att" + UniqueSequence.getValue());
+ attribute.setAttribute("name", m.getDisplay(false));
+ feature.appendChild(attribute);
+ }
+
+ for (Member m : entity.getMethodsToDisplay()) {
+ // <UML:Operation xmi.id="UMLOperation.7" name="Operation1"
+ // visibility="public" isSpecification="false"
+ // ownerScope="instance" isQuery="false" concurrency="sequential"
+ // isRoot="false" isLeaf="false"
+ // isAbstract="false" specification="" owner="UMLClass.5"/>
+ final Element operation = document.createElement("UML:Operation");
+ operation.setAttribute("xmi.id", "att" + UniqueSequence.getValue());
+ operation.setAttribute("name", m.getDisplay(false));
+ feature.appendChild(operation);
+ }
+ return cla;
+ }
+
+ private Element createEntityNodeRef(IEntity entity) {
+ final Element cla = document.createElement("UML:Class");
+ cla.setAttribute("xmi.idref", entity.getUid());
+ return cla;
+ }
+
+ public void transformerXml(OutputStream os) throws TransformerException, ParserConfigurationException {
+ final Source source = new DOMSource(document);
+
+ final Result resultat = new StreamResult(os);
+
+ final TransformerFactory fabrique = TransformerFactory.newInstance();
+ final Transformer transformer = fabrique.newTransformer();
+ transformer.setOutputProperty(OutputKeys.INDENT, "yes");
+ // transformer.setOutputProperty(OutputKeys.ENCODING, "ISO-8859-1");
+ transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
+ // tf.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
+ transformer.transform(source, resultat);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/xmi/XmiClassDiagramStandard.java b/src/net/sourceforge/plantuml/xmi/XmiClassDiagramStandard.java
new file mode 100644
index 0000000..a01e142
--- /dev/null
+++ b/src/net/sourceforge/plantuml/xmi/XmiClassDiagramStandard.java
@@ -0,0 +1,297 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.xmi;
+
+import java.io.OutputStream;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import net.sourceforge.plantuml.classdiagram.ClassDiagram;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.cucadiagram.LinkDecor;
+import net.sourceforge.plantuml.cucadiagram.Member;
+import net.sourceforge.plantuml.utils.UniqueSequence;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+public class XmiClassDiagramStandard implements IXmiClassDiagram {
+
+ // http://pierre.ree7.fr/blog/?p=5
+
+ private final ClassDiagram classDiagram;
+ private final Document document;
+ private final Element ownedElement;
+
+ private final Set<IEntity> done = new HashSet<IEntity>();
+
+ public XmiClassDiagramStandard(ClassDiagram classDiagram) throws ParserConfigurationException {
+ this.classDiagram = classDiagram;
+ final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+
+ final DocumentBuilder builder = factory.newDocumentBuilder();
+ this.document = builder.newDocument();
+ document.setXmlVersion("1.0");
+ document.setXmlStandalone(true);
+
+ final Element xmi = document.createElement("XMI");
+ xmi.setAttribute("xmi.version", "1.1");
+ xmi.setAttribute("xmlns:UML", "href://org.omg/UML/1.3");
+ document.appendChild(xmi);
+
+ final Element header = document.createElement("XMI.header");
+ xmi.appendChild(header);
+
+ final Element metamodel = document.createElement("XMI.metamodel");
+ metamodel.setAttribute("xmi.name", "UML");
+ metamodel.setAttribute("xmi.version", "1.3");
+ header.appendChild(metamodel);
+
+ final Element content = document.createElement("XMI.content");
+ xmi.appendChild(content);
+
+ // <UML:Model xmi.id="UMLModel.4" name="Design Model"
+ // visibility="public" isSpecification="false" isRoot="false"
+ // isLeaf="false" isAbstract="false">
+ final Element model = document.createElement("UML:Model");
+ model.setAttribute("xmi.id", "model1");
+ model.setAttribute("name", "PlantUML");
+ content.appendChild(model);
+
+ // <UML:Namespace.ownedElement>
+ this.ownedElement = document.createElement("UML:Namespace.ownedElement");
+ model.appendChild(ownedElement);
+
+ for (final IEntity ent : classDiagram.getLeafsvalues()) {
+ // if (fileFormat == FileFormat.XMI_ARGO && isStandalone(ent) == false) {
+ // continue;
+ // }
+ final Element cla = createEntityNode(ent);
+ ownedElement.appendChild(cla);
+ done.add(ent);
+ }
+
+ // if (fileFormat != FileFormat.XMI_STANDARD) {
+ // for (final Link link : classDiagram.getLinks()) {
+ // addLink(link);
+ // }
+ // }
+ }
+
+// private boolean isStandalone(IEntity ent) {
+// for (final Link link : classDiagram.getLinks()) {
+// if (link.getEntity1() == ent || link.getEntity2() == ent) {
+// return false;
+// }
+// }
+// return true;
+// }
+
+ public static String forXMI(String s) {
+ return s.replace(':', ' ');
+ }
+
+ public static String forXMI(Display s) {
+ return s.get(0).toString().replace(':', ' ');
+ }
+
+ private void addLink(Link link) {
+ final String assId = "ass" + UniqueSequence.getValue();
+ // if ((link.getType().getDecor1() == LinkDecor.EXTENDS || link.getType().getDecor2() == LinkDecor.EXTENDS)
+ // && fileFormat == FileFormat.XMI_STAR) {
+ // addExtension(link, assId);
+ // return;
+ // }
+ final Element association = document.createElement("UML:Association");
+ association.setAttribute("xmi.id", assId);
+ association.setAttribute("namespace", "model1");
+ if (link.getLabel() != null) {
+ association.setAttribute("name", forXMI(link.getLabel()));
+ }
+
+ final Element connection = document.createElement("UML:Association.connection");
+ final Element end1 = document.createElement("UML:AssociationEnd");
+ end1.setAttribute("xmi.id", "end" + UniqueSequence.getValue());
+ end1.setAttribute("association", assId);
+ end1.setAttribute("type", link.getEntity1().getUid());
+ if (link.getQualifier1() != null) {
+ end1.setAttribute("name", forXMI(link.getQualifier1()));
+ }
+ final Element endparticipant1 = document.createElement("UML:AssociationEnd.participant");
+ // if (fileFormat == FileFormat.XMI_ARGO) {
+ // if (done.contains(link.getEntity1())) {
+ // endparticipant1.appendChild(createEntityNodeRef(link.getEntity1()));
+ // } else {
+ // endparticipant1.appendChild(createEntityNode(link.getEntity1()));
+ // done.add(link.getEntity1());
+ // }
+ // } else if (fileFormat == FileFormat.XMI_STAR) {
+ // if (link.getType().getDecor2() == LinkDecor.COMPOSITION) {
+ // end1.setAttribute("aggregation", "composite");
+ // }
+ // if (link.getType().getDecor2() == LinkDecor.AGREGATION) {
+ // end1.setAttribute("aggregation", "aggregate");
+ // }
+ // }
+ end1.appendChild(endparticipant1);
+ connection.appendChild(end1);
+
+ final Element end2 = document.createElement("UML:AssociationEnd");
+ end2.setAttribute("xmi.id", "end" + UniqueSequence.getValue());
+ end2.setAttribute("association", assId);
+ end2.setAttribute("type", link.getEntity2().getUid());
+ if (link.getQualifier2() != null) {
+ end2.setAttribute("name", forXMI(link.getQualifier2()));
+ }
+ final Element endparticipant2 = document.createElement("UML:AssociationEnd.participant");
+ // if (fileFormat == FileFormat.XMI_ARGO) {
+ // if (done.contains(link.getEntity2())) {
+ // endparticipant2.appendChild(createEntityNodeRef(link.getEntity2()));
+ // } else {
+ // endparticipant2.appendChild(createEntityNode(link.getEntity2()));
+ // done.add(link.getEntity2());
+ // }
+ // } else if (fileFormat == FileFormat.XMI_STAR) {
+ // if (link.getType().getDecor1() == LinkDecor.COMPOSITION) {
+ // end2.setAttribute("aggregation", "composite");
+ // }
+ // if (link.getType().getDecor1() == LinkDecor.AGREGATION) {
+ // end2.setAttribute("aggregation", "aggregate");
+ // }
+ // }
+ end2.appendChild(endparticipant2);
+ connection.appendChild(end2);
+
+ association.appendChild(connection);
+
+ ownedElement.appendChild(association);
+
+ }
+
+ private void addExtension(Link link, String assId) {
+ final Element association = document.createElement("UML:Generalization");
+ association.setAttribute("xmi.id", assId);
+ association.setAttribute("namespace", "model1");
+ if (link.getLabel() != null) {
+ association.setAttribute("name", forXMI(link.getLabel()));
+ }
+ if (link.getType().getDecor1() == LinkDecor.EXTENDS) {
+ association.setAttribute("child", link.getEntity1().getUid());
+ association.setAttribute("parent", link.getEntity2().getUid());
+ } else if (link.getType().getDecor2() == LinkDecor.EXTENDS) {
+ association.setAttribute("child", link.getEntity2().getUid());
+ association.setAttribute("parent", link.getEntity1().getUid());
+ } else {
+ throw new IllegalStateException();
+ }
+ ownedElement.appendChild(association);
+
+ }
+
+ private Element createEntityNode(IEntity entity) {
+ // <UML:Class xmi.id="UMLClass.5" name="Class1" visibility="public"
+ // isSpecification="false"
+ // namespace="UMLModel.4" isRoot="false" isLeaf="false"
+ // isAbstract="false" participant="UMLAssociationEnd.11"
+ // isActive="false">
+ final Element cla = document.createElement("UML:Class");
+
+ cla.setAttribute("xmi.id", entity.getUid());
+ cla.setAttribute("name", entity.getDisplay().get(0).toString());
+ cla.setAttribute("namespace", "model1");
+
+ final Element feature = document.createElement("UML:Classifier.feature");
+ cla.appendChild(feature);
+
+ for (Member m : entity.getFieldsToDisplay()) {
+ // <UML:Attribute xmi.id="UMLAttribute.6" name="Attribute1"
+ // visibility="public" isSpecification="false"
+ // ownerScope="instance" changeability="changeable"
+ // targetScope="instance" type="" owner="UMLClass.5"/>
+ final Element attribute = document.createElement("UML:Attribute");
+ attribute.setAttribute("xmi.id", "att" + UniqueSequence.getValue());
+ attribute.setAttribute("name", m.getDisplay(false));
+ feature.appendChild(attribute);
+ }
+
+ for (Member m : entity.getMethodsToDisplay()) {
+ // <UML:Operation xmi.id="UMLOperation.7" name="Operation1"
+ // visibility="public" isSpecification="false"
+ // ownerScope="instance" isQuery="false" concurrency="sequential"
+ // isRoot="false" isLeaf="false"
+ // isAbstract="false" specification="" owner="UMLClass.5"/>
+ final Element operation = document.createElement("UML:Operation");
+ operation.setAttribute("xmi.id", "att" + UniqueSequence.getValue());
+ operation.setAttribute("name", m.getDisplay(false));
+ feature.appendChild(operation);
+ }
+ return cla;
+ }
+
+ private Element createEntityNodeRef(IEntity entity) {
+ final Element cla = document.createElement("UML:Class");
+ cla.setAttribute("xmi.idref", entity.getUid());
+ return cla;
+ }
+
+ public void transformerXml(OutputStream os) throws TransformerException, ParserConfigurationException {
+ final Source source = new DOMSource(document);
+
+ final Result resultat = new StreamResult(os);
+
+ final TransformerFactory fabrique = TransformerFactory.newInstance();
+ final Transformer transformer = fabrique.newTransformer();
+ transformer.setOutputProperty(OutputKeys.INDENT, "yes");
+ // transformer.setOutputProperty(OutputKeys.ENCODING, "ISO-8859-1");
+ transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
+ // tf.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
+ transformer.transform(source, resultat);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/xmi/XmiClassDiagramStar.java b/src/net/sourceforge/plantuml/xmi/XmiClassDiagramStar.java
new file mode 100644
index 0000000..d9c32a0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/xmi/XmiClassDiagramStar.java
@@ -0,0 +1,294 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.xmi;
+
+import java.io.OutputStream;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import net.sourceforge.plantuml.classdiagram.ClassDiagram;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.IEntity;
+import net.sourceforge.plantuml.cucadiagram.Link;
+import net.sourceforge.plantuml.cucadiagram.LinkDecor;
+import net.sourceforge.plantuml.cucadiagram.Member;
+import net.sourceforge.plantuml.utils.UniqueSequence;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+public class XmiClassDiagramStar implements IXmiClassDiagram {
+
+ private final ClassDiagram classDiagram;
+ private final Document document;
+ private final Element ownedElement;
+
+ private final Set<IEntity> done = new HashSet<IEntity>();
+
+ public XmiClassDiagramStar(ClassDiagram classDiagram) throws ParserConfigurationException {
+ this.classDiagram = classDiagram;
+ final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+
+ final DocumentBuilder builder = factory.newDocumentBuilder();
+ this.document = builder.newDocument();
+ document.setXmlVersion("1.0");
+ document.setXmlStandalone(true);
+
+ final Element xmi = document.createElement("XMI");
+ xmi.setAttribute("xmi.version", "1.1");
+ xmi.setAttribute("xmlns:UML", "href://org.omg/UML/1.3");
+ document.appendChild(xmi);
+
+ final Element header = document.createElement("XMI.header");
+ xmi.appendChild(header);
+
+ final Element metamodel = document.createElement("XMI.metamodel");
+ metamodel.setAttribute("xmi.name", "UML");
+ metamodel.setAttribute("xmi.version", "1.3");
+ header.appendChild(metamodel);
+
+ final Element content = document.createElement("XMI.content");
+ xmi.appendChild(content);
+
+ // <UML:Model xmi.id="UMLModel.4" name="Design Model"
+ // visibility="public" isSpecification="false" isRoot="false"
+ // isLeaf="false" isAbstract="false">
+ final Element model = document.createElement("UML:Model");
+ model.setAttribute("xmi.id", "model1");
+ model.setAttribute("name", "PlantUML");
+ content.appendChild(model);
+
+ // <UML:Namespace.ownedElement>
+ this.ownedElement = document.createElement("UML:Namespace.ownedElement");
+ model.appendChild(ownedElement);
+
+ for (final IEntity ent : classDiagram.getLeafsvalues()) {
+ // if (fileFormat == FileFormat.XMI_ARGO && isStandalone(ent) == false) {
+ // continue;
+ // }
+ final Element cla = createEntityNode(ent);
+ ownedElement.appendChild(cla);
+ done.add(ent);
+ }
+
+ // if (fileFormat != FileFormat.XMI_STANDARD) {
+ for (final Link link : classDiagram.getLinks()) {
+ addLink(link);
+ }
+ // }
+ }
+
+// private boolean isStandalone(IEntity ent) {
+// for (final Link link : classDiagram.getLinks()) {
+// if (link.getEntity1() == ent || link.getEntity2() == ent) {
+// return false;
+// }
+// }
+// return true;
+// }
+
+ public static String forXMI(String s) {
+ return s.replace(':', ' ');
+ }
+
+ public static String forXMI(Display s) {
+ return s.get(0).toString().replace(':', ' ');
+ }
+
+ private void addLink(Link link) {
+ final String assId = "ass" + UniqueSequence.getValue();
+ if (link.getType().getDecor1() == LinkDecor.EXTENDS || link.getType().getDecor2() == LinkDecor.EXTENDS) {
+ addExtension(link, assId);
+ return;
+ }
+ final Element association = document.createElement("UML:Association");
+ association.setAttribute("xmi.id", assId);
+ association.setAttribute("namespace", "model1");
+ if (link.getLabel() != null) {
+ association.setAttribute("name", forXMI(link.getLabel()));
+ }
+
+ final Element connection = document.createElement("UML:Association.connection");
+ final Element end1 = document.createElement("UML:AssociationEnd");
+ end1.setAttribute("xmi.id", "end" + UniqueSequence.getValue());
+ end1.setAttribute("association", assId);
+ end1.setAttribute("type", link.getEntity1().getUid());
+ if (link.getQualifier1() != null) {
+ end1.setAttribute("name", forXMI(link.getQualifier1()));
+ }
+ final Element endparticipant1 = document.createElement("UML:AssociationEnd.participant");
+ // if (fileFormat == FileFormat.XMI_ARGO) {
+ // if (done.contains(link.getEntity1())) {
+ // endparticipant1.appendChild(createEntityNodeRef(link.getEntity1()));
+ // } else {
+ // endparticipant1.appendChild(createEntityNode(link.getEntity1()));
+ // done.add(link.getEntity1());
+ // }
+ // } else if (fileFormat == FileFormat.XMI_STAR) {
+ if (link.getType().getDecor2() == LinkDecor.COMPOSITION) {
+ end1.setAttribute("aggregation", "composite");
+ }
+ if (link.getType().getDecor2() == LinkDecor.AGREGATION) {
+ end1.setAttribute("aggregation", "aggregate");
+ }
+ // }
+ end1.appendChild(endparticipant1);
+ connection.appendChild(end1);
+
+ final Element end2 = document.createElement("UML:AssociationEnd");
+ end2.setAttribute("xmi.id", "end" + UniqueSequence.getValue());
+ end2.setAttribute("association", assId);
+ end2.setAttribute("type", link.getEntity2().getUid());
+ if (link.getQualifier2() != null) {
+ end2.setAttribute("name", forXMI(link.getQualifier2()));
+ }
+ final Element endparticipant2 = document.createElement("UML:AssociationEnd.participant");
+ // if (fileFormat == FileFormat.XMI_ARGO) {
+ // if (done.contains(link.getEntity2())) {
+ // endparticipant2.appendChild(createEntityNodeRef(link.getEntity2()));
+ // } else {
+ // endparticipant2.appendChild(createEntityNode(link.getEntity2()));
+ // done.add(link.getEntity2());
+ // }
+ // } else if (fileFormat == FileFormat.XMI_STAR) {
+ if (link.getType().getDecor1() == LinkDecor.COMPOSITION) {
+ end2.setAttribute("aggregation", "composite");
+ }
+ if (link.getType().getDecor1() == LinkDecor.AGREGATION) {
+ end2.setAttribute("aggregation", "aggregate");
+ }
+ // }
+ end2.appendChild(endparticipant2);
+ connection.appendChild(end2);
+
+ association.appendChild(connection);
+
+ ownedElement.appendChild(association);
+
+ }
+
+ private void addExtension(Link link, String assId) {
+ final Element association = document.createElement("UML:Generalization");
+ association.setAttribute("xmi.id", assId);
+ association.setAttribute("namespace", "model1");
+ if (link.getLabel() != null) {
+ association.setAttribute("name", forXMI(link.getLabel()));
+ }
+ if (link.getType().getDecor1() == LinkDecor.EXTENDS) {
+ association.setAttribute("child", link.getEntity1().getUid());
+ association.setAttribute("parent", link.getEntity2().getUid());
+ } else if (link.getType().getDecor2() == LinkDecor.EXTENDS) {
+ association.setAttribute("child", link.getEntity2().getUid());
+ association.setAttribute("parent", link.getEntity1().getUid());
+ } else {
+ throw new IllegalStateException();
+ }
+ ownedElement.appendChild(association);
+
+ }
+
+ private Element createEntityNode(IEntity entity) {
+ // <UML:Class xmi.id="UMLClass.5" name="Class1" visibility="public"
+ // isSpecification="false"
+ // namespace="UMLModel.4" isRoot="false" isLeaf="false"
+ // isAbstract="false" participant="UMLAssociationEnd.11"
+ // isActive="false">
+ final Element cla = document.createElement("UML:Class");
+
+ cla.setAttribute("xmi.id", entity.getUid());
+ cla.setAttribute("name", entity.getDisplay().get(0).toString());
+ cla.setAttribute("namespace", "model1");
+
+ final Element feature = document.createElement("UML:Classifier.feature");
+ cla.appendChild(feature);
+
+ for (Member m : entity.getFieldsToDisplay()) {
+ // <UML:Attribute xmi.id="UMLAttribute.6" name="Attribute1"
+ // visibility="public" isSpecification="false"
+ // ownerScope="instance" changeability="changeable"
+ // targetScope="instance" type="" owner="UMLClass.5"/>
+ final Element attribute = document.createElement("UML:Attribute");
+ attribute.setAttribute("xmi.id", "att" + UniqueSequence.getValue());
+ attribute.setAttribute("name", m.getDisplay(false));
+ feature.appendChild(attribute);
+ }
+
+ for (Member m : entity.getMethodsToDisplay()) {
+ // <UML:Operation xmi.id="UMLOperation.7" name="Operation1"
+ // visibility="public" isSpecification="false"
+ // ownerScope="instance" isQuery="false" concurrency="sequential"
+ // isRoot="false" isLeaf="false"
+ // isAbstract="false" specification="" owner="UMLClass.5"/>
+ final Element operation = document.createElement("UML:Operation");
+ operation.setAttribute("xmi.id", "att" + UniqueSequence.getValue());
+ operation.setAttribute("name", m.getDisplay(false));
+ feature.appendChild(operation);
+ }
+ return cla;
+ }
+
+ private Element createEntityNodeRef(IEntity entity) {
+ final Element cla = document.createElement("UML:Class");
+ cla.setAttribute("xmi.idref", entity.getUid());
+ return cla;
+ }
+
+ public void transformerXml(OutputStream os) throws TransformerException, ParserConfigurationException {
+ final Source source = new DOMSource(document);
+
+ final Result resultat = new StreamResult(os);
+
+ final TransformerFactory fabrique = TransformerFactory.newInstance();
+ final Transformer transformer = fabrique.newTransformer();
+ transformer.setOutputProperty(OutputKeys.INDENT, "yes");
+ // transformer.setOutputProperty(OutputKeys.ENCODING, "ISO-8859-1");
+ transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
+ // tf.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
+ transformer.transform(source, resultat);
+ }
+
+}