Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Support more than 2 paths out of a conditional #37

Open
tpotter7 opened this issue Mar 21, 2019 · 10 comments
Open

[Feature] Support more than 2 paths out of a conditional #37

tpotter7 opened this issue Mar 21, 2019 · 10 comments
Labels
bug Something isn't working

Comments

@tpotter7
Copy link

In the legacy syntax, you could have more than 2 paths out of a conditional. For example:
() --> Activity
if (color?) then
(
) --> [red] "Activity 1"
else
() --> [blue] "Activity 2"
else
(
) --> [green] "Activity 3"
endif

In the new syntax, I cannot find a way to do this. It appears that every conditional is assumed to be a binary question. Would it be possible to support trinary or quaternary conditionals in the new syntax?

@tpotter7
Copy link
Author

Not really. Let's say that the conditional question is "Color?" and you want the possible paths to be "Red", "Blue", "Green". When I create a sequence digram in Visio, I just create a conditional with "Color?" in the shape and then have 3 lines coming out of it, one for each color. In the legacy puml syntax, I was able to do something similar. In the new method, it appears that all conditionals are necessarily binary so I have to make it harder to read by having a "Red?" conditional, where no leads to a "Blue?" conditional, where no leads to a "Green?" conditional. It just makes for more conditionals when what I am really asking is "what color is it?". So, that will work, but it is not what I was looking for.

@arnaudroques
Copy link
Contributor

I think I've got the point.
This is not implemented yet, but we will propose something like:

@startuml
start
switch (color)
case (red)
  :Text 1;
case (blue)
  :Text 2;
case (green)
  :Text 3;
endswitch
stop
@enduml

Please be patient : we'll post a message here when this will be working. Thanks!

@tpotter7
Copy link
Author

tpotter7 commented Mar 31, 2019 via email

@arnaudroques
Copy link
Contributor

This is really an early version, but with last beta http://beta.plantuml.net/plantuml.jar you can have

@startuml
start
switch (color)
case (red)
  :Text 1;
case (blue)
  :Text 2;
case (green)
  :Text 3;
endswitch
stop
@enduml
  • The drawing is not complete
  • There is no syntax check in case of error

But at least it gives you an idea of what we'll get at the end.

@arnaudroques
Copy link
Contributor

Last beta http://beta.plantuml.net/plantuml.jar now prints links

@mlopezgva
Copy link

Wow. This needs to be mentioned in the docs... Mark it as beta in red with flashing, but it is worth mentioning anyway... :-)

@mlopezgva
Copy link

Hi!
Got a bug here... See:

@startuml

title Payment Router Flow

skinparam DefaultTextAlignment center
skinparam DefaultMonospacedFontName Lucida Sans Typewriter

start
:Load settings;
partition Alternative {
	switch (Alternative ""GatewayID"" defined for...)
		case (**SomeOne**'s Country Code nd **Selected** Payment Method?)
		case (**ANY** Country Code and **Selected** Payment Method?)
		case (else)
			:Get Main ""GatewayID""/
		endswitch
	:Get **Alternative**\n""GatewayID""/
}

stop

@enduml

...and got this:

You may think it is because it got somehow constrained by the partition box... Nope:

@arnaudroques
Copy link
Contributor

@mlopezgva Thanks for the feedback. This should be better in last beta http://beta.plantuml.net/plantuml.jar

@mlopezgva
Copy link

Yes. Better, but not quite. :-)

Odd line paths are now OK, but there are no arrow notes (and they're quite large).
If I force them to appear (adding block elements, of course), tey will appear, but their space does not grow with them.

Generated image

@startuml

title Switch Test

start

legend top
Using:
    PlantUML version 1.2019.07beta12
    Java Runtime: OpenJDK Runtime Environment
    JVM: OpenJDK 64-Bit Server VM
    Java Version: 1.8.0_181-8u181-b13-2~deb9u1-b13
    Operating System: Linux OS Version: 4.9.0-8-amd64
    Default Encoding: UTF-8
    PLANTUML_LIMIT_SIZE: 4096
    Dot executable is /usr/bin/dot
    Dot version: dot - graphviz version 2.38.0 (20140413.2041)
end legend

:Step One;
partition "Paths OK?" {
    note
        Arrow comments
        are quite tight.
    end note
	switch (Test a variable)
		case (case 1)
			:Select One;
		case (case 2)
			:Select Two;
		case (case 3)
			:Select Three;
		case (case 4)
			:Select Four;
	endswitch
}

partition "Not always" {
    note
        But it still breaks
        under some conditions:
        
        (Also, I don't get why
        is there so much space
        because of this note...)
    end note
	switch (Test a variable)
		case (case 1)
			:What if this is wider than expected?;
		case (case 2)
		case (case 3)
	endswitch
	:It's //a bit// broken on the left;
	switch (Test a variable)
		case (case 1)
		case (case 2)
		case (case\n it \nbreaks)
			:What if this is wider?/
	endswitch
	:Also on the right!;
	note
	 If you use "What if this is a bit wider?"
	 string above, it works better, although
	 it still breaks in the beginning of
	 the arrow.
	end note
}

partition "Comments\nhidden" {
    note
        I suppose this is something
        that happen by design, but
        it could at least throw an
        error... This is in fact a
        simple ""if"" sentence.
    end note
	switch (Test a variable)
		case (case 1)
		case (case 2)
		case (case 3)
			:Select 3/
	endswitch
}

partition "Miscalculated upper\nmargin or padding" {
	switch (Test a variable)
		case (This is a multiple\nline and long text\narrow comment)
			:Option One/
		case (This is another multiple\nline and long text\narrow comment)
			:Multiple\nline option Two/
		case (else\nwith \three \nlines)
			:In else case.../
	endswitch
}

:Let's go}

stop

@enduml

@arnaudroques arnaudroques added the bug Something isn't working label Mar 20, 2023
@arnaudroques arnaudroques transferred this issue from plantuml/plantuml Mar 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants