Skip to content

Commit

Permalink
Merge pull request #4 from iVis-at-Bilkent/unstable
Browse files Browse the repository at this point in the history
Merge unstable to master
  • Loading branch information
hasanbalci authored Oct 22, 2019
2 parents ff876f7 + 5b236a4 commit 8bca7ea
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 61 deletions.
123 changes: 63 additions & 60 deletions layout-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ return /******/ (function(modules) { // webpackBootstrap

function LayoutConstants() {}

/**
* Layout Quality: 0:draft, 1:default, 2:proof
/**
* Layout Quality: 0:draft, 1:default, 2:proof
*/
LayoutConstants.QUALITY = 1;

/**
* Default parameters
/**
* Default parameters
*/
LayoutConstants.DEFAULT_CREATE_BENDS_AS_NEEDED = false;
LayoutConstants.DEFAULT_INCREMENTAL = false;
Expand All @@ -103,50 +103,50 @@ LayoutConstants.DEFAULT_UNIFORM_LEAF_NODE_SIZES = false;
// -----------------------------------------------------------------------------
// Section: General other constants
// -----------------------------------------------------------------------------
/*
* Margins of a graph to be applied on bouding rectangle of its contents. We
* assume margins on all four sides to be uniform.
/*
* Margins of a graph to be applied on bouding rectangle of its contents. We
* assume margins on all four sides to be uniform.
*/
LayoutConstants.DEFAULT_GRAPH_MARGIN = 15;

/*
* Whether to consider labels in node dimensions or not
/*
* Whether to consider labels in node dimensions or not
*/
LayoutConstants.NODE_DIMENSIONS_INCLUDE_LABELS = false;

/*
* Default dimension of a non-compound node.
/*
* Default dimension of a non-compound node.
*/
LayoutConstants.SIMPLE_NODE_SIZE = 40;

/*
* Default dimension of a non-compound node.
/*
* Default dimension of a non-compound node.
*/
LayoutConstants.SIMPLE_NODE_HALF_SIZE = LayoutConstants.SIMPLE_NODE_SIZE / 2;

/*
* Empty compound node size. When a compound node is empty, its both
* dimensions should be of this value.
/*
* Empty compound node size. When a compound node is empty, its both
* dimensions should be of this value.
*/
LayoutConstants.EMPTY_COMPOUND_NODE_SIZE = 40;

/*
* Minimum length that an edge should take during layout
/*
* Minimum length that an edge should take during layout
*/
LayoutConstants.MIN_EDGE_LENGTH = 1;

/*
* World boundaries that layout operates on
/*
* World boundaries that layout operates on
*/
LayoutConstants.WORLD_BOUNDARY = 1000000;

/*
* World boundaries that random positioning can be performed with
/*
* World boundaries that random positioning can be performed with
*/
LayoutConstants.INITIAL_WORLD_BOUNDARY = LayoutConstants.WORLD_BOUNDARY / 1000;

/*
* Coordinates of the world center
/*
* Coordinates of the world center
*/
LayoutConstants.WORLD_CENTER_X = 1200;
LayoutConstants.WORLD_CENTER_Y = 900;
Expand Down Expand Up @@ -2314,8 +2314,8 @@ module.exports = LinkedList;
"use strict";


/*
*This class is the javascript implementation of the Point.java class in jdk
/*
*This class is the javascript implementation of the Point.java class in jdk
*/
function Point(x, y, p) {
this.x = null;
Expand Down Expand Up @@ -2569,16 +2569,16 @@ function Layout(isRemoteUse) {
this.animationDuringLayout = LayoutConstants.DEFAULT_ANIMATION_DURING_LAYOUT;
//Number iterations that should be done between two successive animations
this.animationPeriod = LayoutConstants.DEFAULT_ANIMATION_PERIOD;
/**
* Whether or not leaf nodes (non-compound nodes) are of uniform sizes. When
* they are, both spring and repulsion forces between two leaf nodes can be
* calculated without the expensive clipping point calculations, resulting
* in major speed-up.
/**
* Whether or not leaf nodes (non-compound nodes) are of uniform sizes. When
* they are, both spring and repulsion forces between two leaf nodes can be
* calculated without the expensive clipping point calculations, resulting
* in major speed-up.
*/
this.uniformLeafNodeSizes = LayoutConstants.DEFAULT_UNIFORM_LEAF_NODE_SIZES;
/**
* This is used for creation of bendpoints by using dummy nodes and edges.
* Maps an LEdge to its dummy bendpoint path.
/**
* This is used for creation of bendpoints by using dummy nodes and edges.
* Maps an LEdge to its dummy bendpoint path.
*/
this.edgeToDummyNodes = new Map();
this.graphManager = new LGraphManager(this);
Expand Down Expand Up @@ -2670,8 +2670,8 @@ Layout.prototype.runLayout = function () {
return isLayoutSuccessfull;
};

/**
* This method performs the operations required after layout.
/**
* This method performs the operations required after layout.
*/
Layout.prototype.doPostLayout = function () {
//assert !isSubLayout : "Should not be called on sub-layout!";
Expand All @@ -2682,9 +2682,9 @@ Layout.prototype.doPostLayout = function () {
this.update();
};

/**
* This method updates the geometry of the target graph according to
* calculated layout.
/**
* This method updates the geometry of the target graph according to
* calculated layout.
*/
Layout.prototype.update2 = function () {
// update bend points
Expand Down Expand Up @@ -2771,9 +2771,9 @@ Layout.prototype.update = function (obj) {
}
};

/**
* This method is used to set all layout parameters to default values
* determined at compile time.
/**
* This method is used to set all layout parameters to default values
* determined at compile time.
*/
Layout.prototype.initParameters = function () {
if (!this.isSubLayout) {
Expand Down Expand Up @@ -2848,11 +2848,11 @@ Layout.prototype.positionNodesRandomly = function (graph) {
}
};

/**
* This method returns a list of trees where each tree is represented as a
* list of l-nodes. The method returns a list of size 0 when:
* - The graph is not flat or
* - One of the component(s) of the graph is not a tree.
/**
* This method returns a list of trees where each tree is represented as a
* list of l-nodes. The method returns a list of size 0 when:
* - The graph is not flat or
* - One of the component(s) of the graph is not a tree.
*/
Layout.prototype.getFlatForest = function () {
var flatForest = [];
Expand Down Expand Up @@ -2953,10 +2953,10 @@ Layout.prototype.getFlatForest = function () {
return flatForest;
};

/**
* This method creates dummy nodes (an l-level node with minimal dimensions)
* for the given edge (one per bendpoint). The existing l-level structure
* is updated accordingly.
/**
* This method creates dummy nodes (an l-level node with minimal dimensions)
* for the given edge (one per bendpoint). The existing l-level structure
* is updated accordingly.
*/
Layout.prototype.createDummyNodesForBendpoints = function (edge) {
var dummyNodes = [];
Expand Down Expand Up @@ -2996,9 +2996,9 @@ Layout.prototype.createDummyNodesForBendpoints = function (edge) {
return dummyNodes;
};

/**
* This method creates bendpoints for edges from the dummy nodes
* at l-level.
/**
* This method creates bendpoints for edges from the dummy nodes
* at l-level.
*/
Layout.prototype.createBendpointsFromDummyNodes = function () {
var edges = [];
Expand Down Expand Up @@ -3059,9 +3059,9 @@ Layout.transform = function (sliderValue, defaultValue, minDiv, maxMul) {
}
};

/**
* This method finds and returns the center of the given nodes, assuming
* that the given nodes form a tree in themselves.
/**
* This method finds and returns the center of the given nodes, assuming
* that the given nodes form a tree in themselves.
*/
Layout.findCenterOfTree = function (nodes) {
var list = [];
Expand Down Expand Up @@ -3130,9 +3130,9 @@ Layout.findCenterOfTree = function (nodes) {
return centerNode;
};

/**
* During the coarsening process, this layout may be referenced by two graph managers
* this setter function grants access to change the currently being used graph manager
/**
* During the coarsening process, this layout may be referenced by two graph managers
* this setter function grants access to change the currently being used graph manager
*/
Layout.prototype.setGraphManager = function (gm) {
this.graphManager = gm;
Expand All @@ -3148,6 +3148,7 @@ module.exports = Layout;


function RandomSeed() {}
// adapted from: https://stackoverflow.com/a/19303725
RandomSeed.seed = 1;
RandomSeed.x = 0;

Expand Down Expand Up @@ -3491,6 +3492,8 @@ FDLayout.prototype.calcSpringForce = function (edge, idealLength) {

length = edge.getLength();

if (length == 0) return;

// Calculate spring forces
springForce = this.springConstant * (length - idealLength);

Expand Down
5 changes: 4 additions & 1 deletion src/fd/FDLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,10 @@ FDLayout.prototype.calcSpringForce = function (edge, idealLength) {
}

length = edge.getLength();


if(length == 0)
return;

// Calculate spring forces
springForce = this.springConstant * (length - idealLength);

Expand Down
1 change: 1 addition & 0 deletions src/util/RandomSeed.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
function RandomSeed() {
}
// adapted from: https://stackoverflow.com/a/19303725
RandomSeed.seed = 1;
RandomSeed.x = 0;

Expand Down

0 comments on commit 8bca7ea

Please sign in to comment.