Java Geometry Algorithm forceMouseMove(Point pos)

Here you can find the source of forceMouseMove(Point pos)

Description

Forces a mouse movement by 1 pixel to the right and back that will generate mouse movement events.

License

Apache License

Parameter

Parameter Description
pos Current mouse positon in screen coordinates

Declaration

public static void forceMouseMove(Point pos) 

Method Source Code


//package com.java2s;
/*//from   www  .j  a va2s .  co  m
 *   Copyright 2007 skynamics AG
 *
 *   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.
 */

import java.awt.AWTException;

import java.awt.Point;

import java.awt.Robot;

public class Main {
    /**
     * Forces a mouse movement by 1 pixel to the right and back that will generate mouse movement events.
     * This is used in the first line to update mouse position-dependant cursor shapes programatically.
     *
     * @param pos Current mouse positon in screen coordinates
     */
    public static void forceMouseMove(Point pos) {
        try {
            Robot robot = new Robot();
            robot.setAutoDelay(0);
            robot.mouseMove(pos.x + 1, pos.y);
            robot.mouseMove(pos.x, pos.y);
        } catch (AWTException e) {
            // Ignored on systems that don't support Robot
        }
    }
}

Related

  1. findIntersect(Point2D p1, Point2D p2, Point2D p3, Point2D p4)
  2. findIntersection(Point2D.Double p1, Point2D.Double p2, Point2D.Double p3, Point2D.Double p4)
  3. findLineSegmentIntersection(Line2D one, Line2D two, Point2D intersection)
  4. findMiddlePoint(Point2D p1, Point2D p2)
  5. fitCircle(final Point2D P1, final Point2D P2, final Point2D P3)
  6. generateLine(Point2D.Double point, double length, double angle)
  7. generateLookAtTag(ArrayList geoCoords, ArrayList modsAM)
  8. generatePoint(Shape region)
  9. generateRobotPositions(Point start, Point end, int stepSize)