elk icon indicating copy to clipboard operation
elk copied to clipboard

Allow port labels to be centered in insufficient-space conditions

Open le-cds opened this issue 6 years ago • 1 comments

Given the following graph:

algorithm: layered

node n {
	layout [ size: 20, 20 ]
	
	portConstraints: FIXED_SIDE
	portLabels.placement: INSIDE
	
	port p {
		^port.side: SOUTH
		label "long label"
	}
}

This is the result:

graph

There is clearly not enough space for the label. Centering it above its port would produce an additional crossing between the label and the node's left border. The port label placement code currently optimizes for such crossings and thus does not centre the label.

There could be an additional option to force centred port labels in such cases.

le-cds avatar May 07 '19 14:05 le-cds

This is solved by setting node size constraints to PORTS and PORT_LABELS. I guess it should be enough to only set PORT_LABELS for the node to resize to accommodate the label.

algorithm: layered

node n {
  layout [ size: 20, 20 ]
  nodeSize.constraints: "PORTS PORT_LABELS"
  nodeSize.options: ASYMMETRICAL
  portConstraints: FIXED_SIDE
  portLabels.placement: "INSIDE ALWAYS_SAME_SIDE"
  
  port p {
    ^port.side: SOUTH
    label "long label"
  }
}

soerendomroes avatar Sep 06 '24 11:09 soerendomroes