Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
982 views
in Technique[技术] by (71.8m points)

uml - How to correct PlantUML Line Path

I created this diagram using the following code. But as you can see, the lines going from (Cancel Order) and (Place Order) to (Publisher) decide to take a terribly rounded path to get their, instead of going straight to the right and then down to publisher. I tried using manual direction commands like "-down" but none of them seemed to help. Does anybody know how to fix this?

And here is my code. I appreciate any help. Thank you.

@startUML EBook Use Case Diagram
left to right direction
Actor Customer as customer
Actor EBook as ebook
Actor Publisher as publisher
rectangle "Book Catalogue" {
    together {
        Actor "Book Database" as bookLog
        (Retrieve Information) as getBook
        customer -- getBook
        getBook -- ebook
        getBook -- bookLog

        (Update Catalogue) as updateCatalogue
        ebook -- updateCatalogue
        updateCatalogue -- bookLog
    }

    together {
        (Place Order) as order
        customer -- order
        order -- ebook
        order--publisher

        (Cancel Order) as cancelOrder
        customer -- cancelOrder
        cancelOrder -- ebook
        cancelOrder--publisher
    }
}

(Ship To EBook) as shipEBook
shipEBook -- publisher
(Ship To Customer) as shipCustomer
customer -- shipCustomer
ebook -- shipEBook
shipCustomer -- ebook

(Return to EBook) as returnCustomer
(Returnto Publisher) as returnPublisher
customer -- returnCustomer
returnCustomer -- ebook
ebook -- returnPublisher
returnPublisher -- publisher

@endUML
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

There are some tricks that you can try, listed below. The layouting itself is performed by GraphViz (dot layouting iirc), and GraphViz simply does this sometimes. Graph layouting is a NP-complete problem, so algorithms usually take harsh shortcuts.

Typical workarounds that I've seen or used include:

  • adding hidden lines a -[hidden]- b
  • extending the length of a line a --- b (more dashes, longer line)
  • specifying preferred direction of lines (a -left- b)
  • swapping association ends (a -- bb -- a)
  • changing the order of definitions (the order does matter... sometimes)
  • adding empty nodes with background/border colors set to Transparent

So if you really want to have a nice layout, you'll need to put some elbow grease in, but keep in mind that the layout will be still brittle -- if you add/remove items, you might need to redo it again.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...