/*
 *  Copyright 2015-present Lucas Nelaupe and Ferrand
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package kit.scyla.core.facets.force;

/**
 * Created with IntelliJ
 * Created by Ferrand
 * Date 25/11/2014
 */
@SuppressWarnings({"unused", "unchecked"})
public class Gravity extends Force {
    static double G = 0.01;
    private static Gravity INSTANCE = null;

    private Gravity() {
        super();
    }

    public static Gravity getInstance() {
        if (INSTANCE == null) {
            INSTANCE = new Gravity();
        }

        return INSTANCE;
    }

    public static Gravity getReinitializedInstance() {
        if (INSTANCE == null) {
            INSTANCE = new Gravity();
        }

        INSTANCE.reinitialize();

        return INSTANCE;
    }

    public static void setGravity(double gravity) {
        if (isGravityHasChanged(gravity)) {
            getInstance().reinitialize();
        }

        G = gravity / 1000;
    }

    private static boolean isGravityHasChanged(double gravity) {
        return (!((gravity > 0 && G > 0) || (gravity < 0 && G < 0)));
    }

    public void stepGravityForward() {
        if (G != 0) {
            super.stepForward();
        }
    }

    @Override
    public int onStepX() {
        return 0;
    }

    @Override
    public int onStepY() {
        int y = (int) (G * instant() * instant());
        return y > 20 ? 20 : y;
    }

    @Override
    public void refresh() {
    }

    @Override
    public int getDuration() {
        return -1; // Unlimited
    }
}

@@ -839,13 +839,10 @@
  = 0
-.01
 ;%0A
+
     
@@ -1077,32 +1077,48 @@
 NSTANCE;%0A    %7D%0A%0A
+    @Deprecated%0A
     public stati
@@ -1271,16 +1271,16 @@
 ize();%0A%0A
-
         
@@ -1295,32 +1295,202 @@
 NSTANCE;%0A    %7D%0A%0A
+    public static void reinitializedInstance() %7B%0A        if (INSTANCE == null) %7B%0A            INSTANCE = new Gravity();%0A        %7D%0A%0A        INSTANCE.reinitialize();%0A    %7D%0A%0A
     public stati

Update force