Class ConnectorManager
Defined in: connectionManagers.js.
Constructor Attributes | Constructor Name and Description |
---|---|
It manages all the Connectors on a diagram
|
Field Attributes | Field Name and Description |
---|---|
Tells in what mode are we:
0 = disabled
1 = choosing first location (creation)
2 = choosing second location (creation)
3 = dragging connector
|
|
Used to generate unique IDs for ConnectionPoint
|
|
An {Array} of {ConnectionPoint}s.
|
|
An {Array} of {Connector}s.
|
|
An {Array} of {Glue}s.
|
Method Attributes | Method Name and Description |
---|---|
connectionPointCreate(parentId, point, type)
Creates a new ConnectionPoint.
|
|
connectionPointGetAllByParent(parentId)
Returns a subset of whole ConnectionPoints that belong to a figure or a connector
|
|
connectionPointGetById(connectionPointId)
Returns a ConnectionPoint based on its id
or null if none finded
|
|
connectionPointGetByParentAndCoordinates(parentId, x, y)
Returns a ConnectionPoint based on its id
or null if none finded
|
|
connectionPointGetByXY(x, y, type)
Returns a connection point id based on an x and y and the ConnectionPoint.RADIUS
It will pick the first one that matches the criteria
|
|
Returns the selected connection point
|
|
connectionPointHasGlues(conectionPointId)
See if a {ConnectionPoint} has {Glue}s attached to it
|
|
connectionPointIsConnected(id1, id2)
See if two {ConnectionPoint}s are connected
|
|
connectionPointOver(x, y, parentFigureId)
Get the connectionPoint the mouse is over
|
|
All ConnectionPoints we are over - but filtered by the parent type
|
|
connectionPointPaint(context, parentFigureId)
Paints ALL ConnectionPoints that are attached to a shape (Figure or Connector)
|
|
connectionPointRemoveAllByParent(parentId)
Removes the connectionPoints associated with a parent (it can be either Figure or Connector)
|
|
connectionPointTransform(fId, matrix)
Transform all ConnectionPoints of a Figure
|
|
TODO: This function needs a serious review
as it seems is no longer used?!?
|
|
connectorAdjustByConnectionPoint(cpId, x, y)
Adjust a connector by a ConnectionPoint id
The ConnectionPoint should be already changed/transformed
Usually the connector changed it's start or end ConnectionPoint and now we need to update it's turning
points (intermediate points)
|
|
connectorConnect(connectionPoint1, connectionPoint2)
Simplifies the connection of 2 ConnectionPoints
|
|
connectorCreate(startPoint, endPoint, type)
Creates a new connector.
|
|
connectorDisconnect(conectionPointId)
Disconnects all Connectors (actually one) that have a ConnectionPoint
|
|
connectorGetById(connectorId)
Get a Connector by its id
|
|
connectorGetByXY(x, y)
Returns the id of the connector the mouse is over.
|
|
Returns the currently selected connector
or null if none available
|
|
connectorPaint(context, highlightedConnectorId)
Paints all connectors and highlight the selected one
|
|
connectorRemove(connector)
Remove a connector
|
|
connectorRemoveById(connectorId)
Remove a connector by Id
|
|
connectorRemoveByIdCascade(connectorId)
Remove a connector by Id and also it will remove the
ConnectionPoints and Glues
|
|
connectorSelectXY(x, y)
Selects a connector using x and y coordinates, same as figure and handle
|
|
equals(anotherConnectionManager)
Performs a deeps equals
|
|
glueCreate(firstId, secondId)
Creates a new {Glue} and store it into the glue database.
|
|
glueGetAllByIds(firstId, secondId)
Returns all {Glue}s that have the first Id equals with a certain id value
|
|
glueGetByFirstConnectionPointId(pointId)
Returns all {Glue}s that have the first Id equals with a certain id value
|
|
glueGetBySecondConnectionPointId(pointId)
Returns all {Glue}s that have the second Id equals with a certain id value
|
|
Removes all the {Glue}s based on first Id (usually the Figure)
|
|
Removes all the {Glue}s based on first Id (usually the Connector)
|
|
glueRemoveByIds(id1, id2)
Removes all the {Glue}s based on it's two IDs
|
|
<static> |
ConnectorManager.load(o)
Creates a {ConnectorManager} out of JSON parsed object
|
mouseDown_deprecated(x, y)
Fired from onMouseDown in index.html
|
|
mouseMove_deprecated(x, y)
Fired from onMouseMove in index.html
|
|
mouseUp_deprecated(x, y)
Fired from onMouseUp in index.html when we know we are draggin a Connector
|
|
reset()
Reset this ConnectionManager
|
|
toSVG()
Export the entire ConnectionManager to SVG format
|
Field Detail
connectionMode
Tells in what mode are we:
0 = disabled
1 = choosing first location (creation)
2 = choosing second location (creation)
3 = dragging connector
connectionPointCurrentId
Used to generate unique IDs for ConnectionPoint
connectionPoints
An {Array} of {ConnectionPoint}s. Keeps all ConnectionPoints from canvas
connectors
An {Array} of {Connector}s. Keeps all Connectors from canvas
glues
An {Array} of {Glue}s. Keeps all Glues from canvas
Method Detail
{ConnectionPoint}
connectionPointCreate(parentId, point, type)
Creates a new ConnectionPoint. Beside creating the ConnectionPoint it will also
inject the id and store the ConnectionPoint
Author: Alex Gheorghiu.
Author: Alex Gheorghiu
- Parameters:
- {Number} parentId
- - the id of the parent ( Figure or Connector )this ConnectionPoint will belong to
- {Point} point
- - the location
- {String} type
- - the type of parent. It can be 'figure' (ConnectionPoint.TYPE_FIGURE) or 'connector' {ConnectionPoint.TYPE_CONNECTOR}
- Returns:
- {ConnectionPoint} with a proper id set
{Array}
connectionPointGetAllByParent(parentId)
Returns a subset of whole ConnectionPoints that belong to a figure or a connector
Author: Alex Gheorghiu.
Author: Alex Gheorghiu
- Parameters:
- {Number} parentId
- - the figure or connector's id whom subset we want
- Returns:
- {Array} {ConnectionPoint}s
{ConnectionPoint}
connectionPointGetById(connectionPointId)
Returns a ConnectionPoint based on its id
or null if none finded
- Parameters:
- {Number} connectionPointId
- - the id
- Returns:
- {ConnectionPoint}
{ConnectionPoint}
connectionPointGetByParentAndCoordinates(parentId, x, y)
Returns a ConnectionPoint based on its id
or null if none finded
- Parameters:
- {Number} parentId
- - the id of the parent
- {Number} x
- - the x of the point
- {Number} y
- - the y of the point
- Returns:
- {ConnectionPoint}
connectionPointGetByXY(x, y, type)
Returns a connection point id based on an x and y and the ConnectionPoint.RADIUS
It will pick the first one that matches the criteria
Author: Alex Gheorghiu.
Author: Alex Gheorghiu
- Parameters:
- {Number} x
- - the x coordinates of the point
- {Number} y
- - the y coordinates of the point
- {Boolean} type
- - the type of connector to select. Can be 'connector'(ConnectionPoint.TYPE_CONNECTOR) or 'figure' (ConnectionPoint.TYPE_FIGURE)
connectionPointGetSelected()
Returns the selected connection point
- Returns:
- a {ConnectionPoint} that is stored at position selectedConnectionPointIndex or null if selectedConnectionPointIndex is not set (equal to -1)
connectionPointHasGlues(conectionPointId)
See if a {ConnectionPoint} has {Glue}s attached to it
Author: Zack Newsham, Alex Gheorghiu .
Author: Zack Newsham
- Parameters:
- {Number} conectionPointId
- - the {ConnectionPoint}'s id
- Returns:
- true - if we have {Glue}s with it or false if not
connectionPointIsConnected(id1, id2)
See if two {ConnectionPoint}s are connected
Author: Alex Gheorghiu.
Author: Alex Gheorghiu
- Parameters:
- id1
- - a {ConnectionPoint}'s id
- id2
- - another {ConnectionPoint}'s id
{ConnectionPoint}
connectionPointOver(x, y, parentFigureId)
Get the connectionPoint the mouse is over
Author: Alex Gheorghiu.
Author: Alex Gheorghiu
- Parameters:
- {Number} x
- - coordinate
- {Number} y
- - coordinate
- {Number} parentFigureId
- - the subset to obtain (optional) If the parentFigureId is null we will get extend our search to all the ConnectionPoints on the canvas If the parentFigureId is positive we will limit our search to that shape (Figure or Connector) If the parentFigureId is negative we will search on all Canvas but except that shape (Figure or Connector)
- Returns:
- {ConnectionPoint} that fit the criteria or null if none present
{Array}
connectionPointOverByType(x, y)
All ConnectionPoints we are over - but filtered by the parent type
Author: Alex Gheorghiu
TODO: either documentation or the implementation is weird.
Author: Alex Gheorghiu
- Parameters:
- {Number} x
- - the x coordinate
- {Number} y
- - the x coordinate
- Returns:
- {Array} of {ConnectionPoint}s
connectionPointPaint(context, parentFigureId)
Paints ALL ConnectionPoints that are attached to a shape (Figure or Connector)
- Parameters:
- {Context} context
- - the HTML5 canvas' context
- {Number} parentFigureId
- - the the parent figure's ID
connectionPointRemoveAllByParent(parentId)
Removes the connectionPoints associated with a parent (it can be either Figure or Connector)
Author: Alex Gheorghiu.
Author: Alex Gheorghiu
- Parameters:
- {Number} parentId
- - the figure id
connectionPointTransform(fId, matrix)
Transform all ConnectionPoints of a Figure
- Parameters:
- {Number} fId
- - the the parent figure's ID
- {Matrix} matrix
- - the transformation matrix
connectionPointUnhighlightAll(x, y)
TODO: This function needs a serious review
as it seems is no longer used?!?
Author: Zack.
Author: Zack.
- Parameters:
- x
- y
connectorAdjustByConnectionPoint(cpId, x, y)
Adjust a connector by a ConnectionPoint id
The ConnectionPoint should be already changed/transformed
Usually the connector changed it's start or end ConnectionPoint and now we need to update it's turning
points (intermediate points)
- Parameters:
- {Number} cpId
- - the id of the {ConnectionPoint} of the {Connector}
- {Number} x
- - not used
- {Number} y
- - not used
connectorConnect(connectionPoint1, connectionPoint2)
Simplifies the connection of 2 ConnectionPoints
- Parameters:
- {ConnectionPoint} connectionPoint1
- - connectionPoint on a figure/connector
- {ConnectionPoint} connectionPoint2
- - connectionPoint on a figure/connector TODO: Is it mandatory that one ConnectionPoint is from a figure an the another one from a Connector?
{Number}
connectorCreate(startPoint, endPoint, type)
Creates a new connector. Also store the connector into the pool of connectors.
- Parameters:
- {Point} startPoint
- {Point} endPoint
- {String} type
- of Connector. It can be either 'straight' or 'jagged'
- Returns:
- {Number} the id of the newly created Connector
connectorDisconnect(conectionPointId)
Disconnects all Connectors (actually one) that have a ConnectionPoint
- Parameters:
- {Number} conectionPointId
- - connectionPoint to disconnect should only ever be called using the conPoint of a Connector, but could work either way
{Connetor}
connectorGetById(connectorId)
Get a Connector by its id
- Parameters:
- {Number} connectorId
- Returns:
- {Connetor} if founded or null if none finded
{Number}
connectorGetByXY(x, y)
Returns the id of the connector the mouse is over.
It actually return the first connector we found.
- Parameters:
- {Number} x
- - the x coord
- {Number} y
- - the y coord
- Returns:
- {Number} - the id of the connector or -1 if no connector found TODO: Note: We are picking the Connector the most far from user as if we iterate from 0 to connectors.lenght we are going from back to front, similar to painting
connectorGetSelected()
Returns the currently selected connector
or null if none available
connectorPaint(context, highlightedConnectorId)
Paints all connectors and highlight the selected one
Author: Zack, Alex TODO: maybe all painting should not be made in managers.
Author: Zack, Alex TODO: maybe all painting should not be made in managers.
- Parameters:
- {Context} context
- - a reference to HTML5's canvas
- {Number} highlightedConnectorId
- - the id of the highlighted connector
connectorRemove(connector)
Remove a connector
- Parameters:
- {Connector} connector
- - the connector you want to remove
connectorRemoveById(connectorId)
Remove a connector by Id
- Parameters:
- {Number} connectorId
- - the {Connector}'s id
connectorRemoveByIdCascade(connectorId)
Remove a connector by Id and also it will remove the
ConnectionPoints and Glues
- Parameters:
- {Number} connectorId
- - the {Connector}'s id
connectorSelectXY(x, y)
Selects a connector using x and y coordinates, same as figure and handle
- Parameters:
- {Number} x
- - the x coordinate
- {Number} y
- - the y coordinate
equals(anotherConnectionManager)
Performs a deeps equals
Author: Alex Gheorghiu.
Author: Alex Gheorghiu
- Parameters:
- {ConnectorManager} anotherConnectionManager
- - the other object to compare against
{Glue}
glueCreate(firstId, secondId)
Creates a new {Glue} and store it into the glue database. Use this instead
of creating the Glues by simply "new" operator
Author: Alex Gheorghiu.
Author: Alex Gheorghiu
- Parameters:
- {Number} firstId
- - the id of the first {ConnectionPoint} - usually the {Figure}'s {ConnectionPoint} id
- {Number} secondId
- - the id of the second {ConnectionPoint} - usually the {Connector}'s {ConnectionPoint} id
- Returns:
- {Glue} - the newly created Glue
{Array}
glueGetAllByIds(firstId, secondId)
Returns all {Glue}s that have the first Id equals with a certain id value
Author: Alex Gheorghiu.
Author: Alex Gheorghiu
- Parameters:
- {Number} firstId
- - first id (usually {Figure}'s id)
- {Number} secondId
- - second id (usually {Connector}'s id)
- Returns:
- {Array} {Glue}s
{Array}
glueGetByFirstConnectionPointId(pointId)
Returns all {Glue}s that have the first Id equals with a certain id value
Author: Alex Gheorghiu.
Author: Alex Gheorghiu
- Parameters:
- {Number} pointId
- - {Figure}'s id
- Returns:
- {Array} {Glue}s
{Array}
glueGetBySecondConnectionPointId(pointId)
Returns all {Glue}s that have the second Id equals with a certain id value
Author: Alex Gheorghiu.
Author: Alex Gheorghiu
- Parameters:
- {Number} pointId
- - {ConnectionPoint}'s id
- Returns:
- {Array} {Glue}s
glueRemoveAllByFirstId(id)
Removes all the {Glue}s based on first Id (usually the Figure)
Author: Alex Gheorghiu.
Author: Alex Gheorghiu
- Parameters:
- {Number} id
- - the id of the first shape (usually the Figure)
glueRemoveAllBySecondId(id)
Removes all the {Glue}s based on first Id (usually the Connector)
Author: Alex Gheorghiu.
Author: Alex Gheorghiu
- Parameters:
- {Number} id
- - the id of the second shape (usually the Connector)
glueRemoveByIds(id1, id2)
Removes all the {Glue}s based on it's two IDs
Author: Alex Gheorghiu.
Author: Alex Gheorghiu
- Parameters:
- {Number} id1
- - the id of the first shape (usually the Figure)
- {Number} id2
- - the id of the second shape (usually the Connector)
<static>
{ConnectorManager}
ConnectorManager.load(o)
Creates a {ConnectorManager} out of JSON parsed object
Author: Alex Gheorghiu.
Author: Alex Gheorghiu
- Parameters:
- {JSONObject} o
- - the JSON parsed object
- Returns:
- {ConnectorManager} a newly constructed ConnectorManager
{Boolean}
mouseDown_deprecated(x, y)
Fired from onMouseDown in index.html
- Parameters:
- {Number} x
- - the mouse coord
- {Number} y
- - the mouse coord
- Returns:
- {Boolean} - should we check for handle after this
{Boolean}
mouseMove_deprecated(x, y)
Fired from onMouseMove in index.html
- Parameters:
- {Number} x
- - the mouse coord
- {Number} y
- - the mouse coord
- Returns:
- {Boolean} - true if should we redraw after this action, false otherwise
mouseUp_deprecated(x, y)
Fired from onMouseUp in index.html when we know we are draggin a Connector
- Parameters:
- {Number} x
- - the mouse coord
- {Number} y
- - the mouse coord
reset()
Reset this ConnectionManager
toSVG()
Export the entire ConnectionManager to SVG format