ConnectPoint

class util.ConnectPoint.ConnectPoint(from_x, from_y, to_x, to_y, color=' black', level='same')[source]

This class stores information of each connection made in the grid.

Each connection is strictly either vertical or horizontal, the diagonal connections are invalid. Following properties are store with each connection

Methods:

__init__

move

flip_connection

This methods flips the connection depending upon the orientation, Valid arguments (V, H, v, h)

rotate_connection

translate_connection

Translates the connection by given x and y value

scale_connection

Scale up the connection by multipying the connection_from and connection_to coordinates with the scaling factor.

direction

This method extracts the direction of the connection.

Attributes:

connection

Return from and to connection points () (from_x, from_y, to_x, to_y)

full_connection

return all four connection points

distance

return the connection distance

is_buffered

Returns connection level

buffer

Returns connection level

from_connection

return from connection points

to_connection

return to connection points

color

return color of connection

level

Returns connection level

__init__(from_x, from_y, to_x, to_y, color=' black', level='same')[source]
property connection

Return from and to connection points () (from_x, from_y, to_x, to_y)

property full_connection

return all four connection points

property distance

return the connection distance

property is_buffered

Returns connection level

property buffer

Returns connection level

property from_connection

return from connection points

property to_connection

return to connection points

property color

return color of connection

property level

Returns connection level

flip_connection(orientation)[source]

This methods flips the connection depending upon the orientation, Valid arguments (V, H, v, h)

Parameters

orientation (str) – The orientation can be vertical or horizontal

translate_connection(x, y)[source]

Translates the connection by given x and y value

Parameters
  • x (int) – Horizontal shift in the connection

  • y (int) – Vertical shift in the connection

scale_connection(scale, anchor=(0, 0))[source]

Scale up the connection by multipying the connection_from and connection_to coordinates with the scaling factor.

This methd used to expand the exiting conenction

Parameters

scale (int) – Scale by which connection will be enlarged

direction(reverse=False)[source]

This method extracts the direction of the connection.

Direction is derived by subtracting the x and y coordinates of the to and from connection and if the value of X is 0 and the value of Y is: >1 direction = Top <1 direction = Bottom and if the value of Y is 0 and X is >1 direction = Right <1 direction = Left It returns the actual and reversed (if reverse = True) direction of the connect point.

Parameters

reverse (bool) – Reverse the connection (default=false)

Returns

Returns one of these strings [‘right’, ‘left’, ‘bottom’, ‘top’]

Return type

str