Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javafx.scene;
import java.util.HashMap;
import java.util.Map;
import javafx.beans.InvalidationListener;
import javafx.beans.Observable;
import javafx.beans.property.ReadOnlyDoubleProperty;
import javafx.beans.property.ReadOnlyDoublePropertyBase;
import javafx.beans.property.ReadOnlyObjectProperty;
import javafx.beans.property.ReadOnlyObjectPropertyBase;
import javafx.geometry.Dimension2D;
import javafx.scene.image.Image;
import com.sun.javafx.cursor.CursorFrame;
import com.sun.javafx.cursor.ImageCursorFrame;
import com.sun.javafx.tk.Toolkit;
import java.util.Arrays;
/**
* A custom image representation of the mouse cursor. On platforms that don't
* support custom cursors, {@code Cursor.DEFAULT} will be used in place of the
* specified ImageCursor.
*
*
Example:
*
import javafx.scene.*;
import javafx.scene.image.*;
Image image = new Image("mycursor.png");
Scene scene = new Scene(400, 300);
scene.setCursor(new ImageCursor(image,
image.getWidth() / 2,
image.getHeight() /2));
*
*
* @since JavaFX 2.0
*/
public class ImageCursor extends Cursor {
/**
* The image to display when the cursor is active. If the image is null,
* {@code Cursor.DEFAULT} will be used.
*
* @defaultValue null
*/
private ObjectPropertyImpl image;
public final Image getImage() {
return image == null ? null : image.get();
}
public final ReadOnlyObjectProperty imageProperty() {
return imagePropertyImpl();
}
private ObjectPropertyImpl imagePropertyImpl() {
if (image == null) {
image = new ObjectPropertyImpl("image");
}
return image;
}
/**
* The X coordinate of the cursor's hot spot. This hotspot represents the
* location within the cursor image that will be displayed at the mouse
* position. This must be in the range of [0,image.width-1]. A value
* less than 0 will be set to 0. A value greater than
* image.width-1 will be set to image.width-1.
*
* @defaultValue 0
*/
private DoublePropertyImpl hotspotX;
public final double getHotspotX() {
return hotspotX == null ? 0.0 : hotspotX.get();
}
public final ReadOnlyDoubleProperty hotspotXProperty() {
return hotspotXPropertyImpl();
}
private DoublePropertyImpl hotspotXPropertyImpl() {
if (hotspotX == null) {
hotspotX = new DoublePropertyImpl("hotspotX");
}
return hotspotX;
}
/**
* The Y coordinate of the cursor's hot spot. This hotspot represents the
* location within the cursor image that will be displayed at the mouse
* position. This must be in the range of [0,image.height-1]. A value
* less than 0 will be set to 0. A value greater than
* image.height-1 will be set to image.height-1.
*
* @defaultValue 0
*/
private DoublePropertyImpl hotspotY;
public final double getHotspotY() {
return hotspotY == null ? 0.0 : hotspotY.get();
}
public final ReadOnlyDoubleProperty hotspotYProperty() {
return hotspotYPropertyImpl();
}
private DoublePropertyImpl hotspotYPropertyImpl() {
if (hotspotY == null) {
hotspotY = new DoublePropertyImpl("hotspotY");
}
return hotspotY;
}
private CursorFrame currentCursorFrame;
/**
* Stores the first cursor frame. For non-animated cursors there is only one
* frame and so the {@code restCursorFrames} is {@code null}.
*/
private ImageCursorFrame firstCursorFrame;
/**
* Maps platform images to cursor frames. It doesn't store the first cursor
* frame and so it needs to be created only for animated cursors.
*/
private Map