X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.debug.graphical%2Fsrc%2Forg%2Fsimantics%2Fdebug%2Fgraphical%2Flayout%2FExtensionLayoutAlgorithm.java;h=e2d17a852c71cf66583466f99c9175f89b432d27;hb=b29a69792f689d2ac7beffb725c814aa65fca301;hp=9865e28f55cae613909db452f16f4d2e8ada1958;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.debug.graphical/src/org/simantics/debug/graphical/layout/ExtensionLayoutAlgorithm.java b/bundles/org.simantics.debug.graphical/src/org/simantics/debug/graphical/layout/ExtensionLayoutAlgorithm.java index 9865e28f5..e2d17a852 100644 --- a/bundles/org.simantics.debug.graphical/src/org/simantics/debug/graphical/layout/ExtensionLayoutAlgorithm.java +++ b/bundles/org.simantics.debug.graphical/src/org/simantics/debug/graphical/layout/ExtensionLayoutAlgorithm.java @@ -1,125 +1,125 @@ -package org.simantics.debug.graphical.layout; - -public class ExtensionLayoutAlgorithm { - 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 long TIMEOUT = 1000000000L; // 1 sec - final double MAX_MOVE2 = 40000.0; - - int size; - double[] posX; - double[] posY; - double[] forceX; - double[] forceY; - - int repulsiveSize; - double[] fixedRepulsiveX; - double[] fixedRepulsiveY; - double[][] neighbors; - - public ExtensionLayoutAlgorithm(double[][] neighbors, - double[] fixedRepulsiveX, double[] fixedRepulsiveY) { - this.size = neighbors.length; - this.neighbors = neighbors; - this.repulsiveSize = fixedRepulsiveX.length; - this.fixedRepulsiveX = fixedRepulsiveX; - this.fixedRepulsiveY = fixedRepulsiveY; - 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(); - - long beginTime = System.nanoTime(); - int iter; - for(iter=0;iter TIMEOUT)) - break; - moveAll(); - } - System.out.println("Elapsed: " + (System.nanoTime()-beginTime)*1e-6 + " ms"); - System.out.println("Iterations: " + iter); - } -} +package org.simantics.debug.graphical.layout; + +public class ExtensionLayoutAlgorithm { + 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 long TIMEOUT = 1000000000L; // 1 sec + final double MAX_MOVE2 = 40000.0; + + int size; + double[] posX; + double[] posY; + double[] forceX; + double[] forceY; + + int repulsiveSize; + double[] fixedRepulsiveX; + double[] fixedRepulsiveY; + double[][] neighbors; + + public ExtensionLayoutAlgorithm(double[][] neighbors, + double[] fixedRepulsiveX, double[] fixedRepulsiveY) { + this.size = neighbors.length; + this.neighbors = neighbors; + this.repulsiveSize = fixedRepulsiveX.length; + this.fixedRepulsiveX = fixedRepulsiveX; + this.fixedRepulsiveY = fixedRepulsiveY; + 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(); + + long beginTime = System.nanoTime(); + int iter; + for(iter=0;iter TIMEOUT)) + break; + moveAll(); + } + System.out.println("Elapsed: " + (System.nanoTime()-beginTime)*1e-6 + " ms"); + System.out.println("Iterations: " + iter); + } +}