API Docs for:
Show:

BoundingBox Class

Module: views.utils
Parent Module: views

Utility object that encapsulates Y.Models and keeps their position state within an SVG canvas.

As a convenience attributes of the encapsulated model are exposed directly as attributes.

Methods

BoundingBox

(
  • module
  • model
)
BoundingBox

Parameters:

  • module Module

    Typically service module.

  • model Model

    Model object.

Returns:

BoundingBox: A Box model.

DecoratedRelation

(
  • relation
  • source
  • target
)
Object

Decorate a relation with some related/derived data.

Parameters:

  • relation Object

    The model object we will be based on.

  • source Object

    The service from which the relation originates.

  • target Object

    The service at which the relation terminates.

Returns:

Object: An object with attributes matching the result of relation.getAttrs() plus "source", "target", and other convenience data.

generateHash

(
  • value
)
Integer

Create a hash of a string. From stackoverflow: http://goo.gl/PEOgF

Parameters:

  • value String

    The string to hash.

Returns:

Integer: The hash of the string.

generateSafeDOMId

(
  • value
)
String

Create a stable, safe DOM id given an arbitrary string. See details and discussion in https://bugs.launchpad.net/juju-gui/+bug/1167295

Parameters:

  • value String

    The string to hash.

Returns:

String: The calculated DOM id.

isGuiCharmUrl

(
  • charmUrl
)
Boolean

Determine if a service is the Juju GUI by inspecting the charm URL.

Parameters:

  • charmUrl String

    The service to inspect.

Returns:

Boolean: True if the charm URL is that of the Juju GUI.

isGuiService

(
  • candidate
)
Boolean

Determine if a service is the Juju GUI by inspecting the charm URL.

Parameters:

  • candidate Object

    The service to inspect.

Returns:

Boolean: True if the service is the Juju GUI.

isPythonRelation

(
  • relationId
)
Bool static

Check whether or not the given relationId represents a PyJuju relation.

Parameters:

  • relationId String

    The relation identifier.

Returns:

Bool: True if the id represents a PyJuju relation, False otherwise.

toBoundingBoxes

(
  • Module
  • services
  • existing
)
Object

Covert an Array of services into BoundingBoxes. If existing is supplied it should be a map of {id: box} and will be updated in place by merging changed attribute into the index.

Parameters:

  • Module ServiceModule

    holding box canvas and context.

  • services ModelList

    Service modellist.

  • existing Object

    id:box mapping.

Returns:

Object: id:box mapping.

toString

(
  • value
)
String

Translate a value into a string, translating non-values into an empty string.

Parameters:

  • value Object

    The value to stringify.

Returns:

String: The input value translated into a string.