All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.mauromidolo.mousemover.controll.MouseMoverController Maven / Gradle / Ivy

The newest version!
package com.github.mauromidolo.mousemover.controll;

/**
 * MouseMoverController: controller to manager MouseMoverManager background job
 */
public class MouseMoverController {

    private static MouseMoverController mouseMoverController;
    private MouseMoverManager thread;

    /**
     * Singleton instance
     *
     * @return MouseMoverController instance
     */
    public static MouseMoverController getInstance() {
        if (mouseMoverController == null) {
            mouseMoverController = new MouseMoverController();
        }
        return mouseMoverController;
    }

    private MouseMoverController() {
    }

    /**
     * start the background job, if the job is already in exertion stop and restart
     *
     * @param value seconds to move mouse
     */
    public void switchOn(int value) {
        if (thread != null) {
            thread.stop();
        }
        thread = new MouseMoverManager(value);
        thread.start();
    }

    /**
     * stop the background job
     *
     */
    public void switchOff() {
        if (thread != null) {
            thread.stop();
        }
        thread = null;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy