123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- /**
- * Copyright (c) 2006-2015, JGraph Ltd
- * Copyright (c) 2006-2015, Gaudenz Alder
- */
- /**
- * Class: mxGraphHierarchyEdge
- *
- * An abstraction of a hierarchical edge for the hierarchy layout
- *
- * Constructor: mxGraphHierarchyEdge
- *
- * Constructs a hierarchy edge
- *
- * Arguments:
- *
- * edges - a list of real graph edges this abstraction represents
- */
- function mxGraphHierarchyEdge(edges)
- {
- mxGraphAbstractHierarchyCell.apply(this, arguments);
- this.edges = edges;
- this.ids = [];
-
- for (var i = 0; i < edges.length; i++)
- {
- this.ids.push(mxObjectIdentity.get(edges[i]));
- }
- };
- /**
- * Extends mxGraphAbstractHierarchyCell.
- */
- mxGraphHierarchyEdge.prototype = new mxGraphAbstractHierarchyCell();
- mxGraphHierarchyEdge.prototype.constructor = mxGraphHierarchyEdge;
- /**
- * Variable: edges
- *
- * The graph edge(s) this object represents. Parallel edges are all grouped
- * together within one hierarchy edge.
- */
- mxGraphHierarchyEdge.prototype.edges = null;
- /**
- * Variable: ids
- *
- * The object identities of the wrapped cells
- */
- mxGraphHierarchyEdge.prototype.ids = null;
- /**
- * Variable: source
- *
- * The node this edge is sourced at
- */
- mxGraphHierarchyEdge.prototype.source = null;
- /**
- * Variable: target
- *
- * The node this edge targets
- */
- mxGraphHierarchyEdge.prototype.target = null;
- /**
- * Variable: isReversed
- *
- * Whether or not the direction of this edge has been reversed
- * internally to create a DAG for the hierarchical layout
- */
- mxGraphHierarchyEdge.prototype.isReversed = false;
- /**
- * Function: invert
- *
- * Inverts the direction of this internal edge(s)
- */
- mxGraphHierarchyEdge.prototype.invert = function(layer)
- {
- var temp = this.source;
- this.source = this.target;
- this.target = temp;
- this.isReversed = !this.isReversed;
- };
- /**
- * Function: getNextLayerConnectedCells
- *
- * Returns the cells this cell connects to on the next layer up
- */
- mxGraphHierarchyEdge.prototype.getNextLayerConnectedCells = function(layer)
- {
- if (this.nextLayerConnectedCells == null)
- {
- this.nextLayerConnectedCells = [];
-
- for (var i = 0; i < this.temp.length; i++)
- {
- this.nextLayerConnectedCells[i] = [];
-
- if (i == this.temp.length - 1)
- {
- this.nextLayerConnectedCells[i].push(this.source);
- }
- else
- {
- this.nextLayerConnectedCells[i].push(this);
- }
- }
- }
-
- return this.nextLayerConnectedCells[layer - this.minRank - 1];
- };
- /**
- * Function: getPreviousLayerConnectedCells
- *
- * Returns the cells this cell connects to on the next layer down
- */
- mxGraphHierarchyEdge.prototype.getPreviousLayerConnectedCells = function(layer)
- {
- if (this.previousLayerConnectedCells == null)
- {
- this.previousLayerConnectedCells = [];
- for (var i = 0; i < this.temp.length; i++)
- {
- this.previousLayerConnectedCells[i] = [];
-
- if (i == 0)
- {
- this.previousLayerConnectedCells[i].push(this.target);
- }
- else
- {
- this.previousLayerConnectedCells[i].push(this);
- }
- }
- }
- return this.previousLayerConnectedCells[layer - this.minRank - 1];
- };
- /**
- * Function: isEdge
- *
- * Returns true.
- */
- mxGraphHierarchyEdge.prototype.isEdge = function()
- {
- return true;
- };
- /**
- * Function: getGeneralPurposeVariable
- *
- * Gets the value of temp for the specified layer
- */
- mxGraphHierarchyEdge.prototype.getGeneralPurposeVariable = function(layer)
- {
- return this.temp[layer - this.minRank - 1];
- };
- /**
- * Function: setGeneralPurposeVariable
- *
- * Set the value of temp for the specified layer
- */
- mxGraphHierarchyEdge.prototype.setGeneralPurposeVariable = function(layer, value)
- {
- this.temp[layer - this.minRank - 1] = value;
- };
- /**
- * Function: getCoreCell
- *
- * Gets the first core edge associated with this wrapper
- */
- mxGraphHierarchyEdge.prototype.getCoreCell = function()
- {
- if (this.edges != null && this.edges.length > 0)
- {
- return this.edges[0];
- }
-
- return null;
- };
|