X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.debug.graphical%2Fsrc%2Forg%2Fsimantics%2Fdebug%2Fgraphical%2Flayout%2FLayoutAlgorithm.java;h=fd1b4ff98a7743eceb24790322b70e58c419d51e;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hp=1fe13a433b667cbb4c06a39af69abb7a8036ced8;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.debug.graphical/src/org/simantics/debug/graphical/layout/LayoutAlgorithm.java b/bundles/org.simantics.debug.graphical/src/org/simantics/debug/graphical/layout/LayoutAlgorithm.java index 1fe13a433..fd1b4ff98 100644 --- a/bundles/org.simantics.debug.graphical/src/org/simantics/debug/graphical/layout/LayoutAlgorithm.java +++ b/bundles/org.simantics.debug.graphical/src/org/simantics/debug/graphical/layout/LayoutAlgorithm.java @@ -1,107 +1,107 @@ -package org.simantics.debug.graphical.layout; - -public class LayoutAlgorithm { - - final double OPTIMAL_DISTANCE = 150.0; - final double C = 0.1; - final double K = C / OPTIMAL_DISTANCE; - final double G = K; - final double Q = C * OPTIMAL_DISTANCE * OPTIMAL_DISTANCE; - final double TOLERANCE = 1e-3; - final int MAX_ITERATIONS = 10000; - final double MAX_MOVE2 = 40000.0; - - int size; - double[] posX; - double[] posY; - double[] forceX; - double[] forceY; - - int[][] neighbors; - - public LayoutAlgorithm(int[][] neighbors) { - this.size = neighbors.length; - this.neighbors = neighbors; - this.posX = new double[size]; - this.posY = new double[size]; - this.forceX = new double[size]; - this.forceY = new double[size]; - } - - public double[] getPosX() { - return posX; - } - - public double[] getPosY() { - return posY; - } - - private void computeForces() { - for(int i=0;i TOLERANCE) - return false; - } - return true; - } - - private void moveAll() { - for(int i=0;i MAX_MOVE2) { - double s = Math.sqrt(MAX_MOVE2 / f2); - fx *= s; - fy *= s; - } - posX[i] += fx; - posY[i] += fy; - } - computeForces(); - } - - public void optimize() { - computeForces(); - - for(int iter=0;iter TOLERANCE) + return false; + } + return true; + } + + private void moveAll() { + for(int i=0;i MAX_MOVE2) { + double s = Math.sqrt(MAX_MOVE2 / f2); + fx *= s; + fy *= s; + } + posX[i] += fx; + posY[i] += fy; + } + computeForces(); + } + + public void optimize() { + computeForces(); + + for(int iter=0;iter