9

Is there any possible way to create component port in the component diagram?

If port has to be attached to only one arrow, its easy, because I can use #-- arrow.

interface y
[x] #- y

The problem is, if I try to attach to arrows to one port. I tried to use rectangle, but its not on the border then.

rectangle " " as P
[Component] - P

interface I1
interface I2

P - I1
P -- I2

Do you know any better workarounds?

  • Do both ports have to be on the right (east) side of Component? Otherwise why mot try `[Component] #- I1` and `[Component] #-- I2` – albert Oct 20 '19 at 09:04
  • That's not the case I have meant. I'd like to render two interfaces being attached to one port. In your example, both interfaces are attached to two different ports. – Patryk Cholewa Oct 24 '19 at 11:50
  • Maybe you can point the Rectangle in the port of `[Component]`, then point `I1` and `I2` to the rectangle.. so update it to `[Component] #-- P`.. – Manie Jan 30 '20 at 08:20

2 Answers2

8

Although a bit late for TO perhaps helpful for someone else.

I managed to create ports on components with the following approach:

@startuml
skinparam componentstyle uml2
left to right direction

component X {
    port " " as x_out
}

'u for layouting it more nicely, 0) for lollipop
x_out -u0)- [Y]
x_out -u0)- [Z]

@enduml

However I experienced a bad layout of the port itself, means when a component has several ports it will start looking messy. But hey at least its a port with multiple connections.

Result looks like:

enter image description here

HaeschenaufGras
  • 195
  • 1
  • 11
  • Don't know when port was added or where it is documented, but this is exactly what I needed. Thanks. – Patryk Cholewa Mar 25 '21 at 00:41
  • You can add `skinparam ComponentBackgroundColor #BUSINESS` and `skinparam ComponentBorderColor #firebrick` and `skinparam ComponentFontStyle normal` commands to give the ported component the same look as the others. – Ron McLeod Aug 12 '21 at 22:51
0

I've managed to get a satisfactory result, at least in my case, this way:

@startuml
Interface -# MasterComponent
component MasterComponent {
[Subcomponent1] - [Subomponent2]
}
MasterComponent - [Subcomponent1]
@enduml
  • Yes, I mensioned hash connection as a solution, when only one interface uses the port. My question is, how to draw two interfaces using a single port (for example both provided and required)? – Patryk Cholewa Jan 27 '21 at 15:57