1 /* 2 * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package com.sun.javafx.webkit; 27 28 import com.sun.webkit.CursorManager; 29 import com.sun.webkit.graphics.WCGraphicsManager; 30 import com.sun.webkit.graphics.WCImage; 31 import java.util.HashMap; 32 import java.util.Locale; 33 import java.util.Map; 34 import java.util.MissingResourceException; 35 import java.util.ResourceBundle; 36 import javafx.scene.Cursor; 37 import javafx.scene.ImageCursor; 38 import javafx.scene.image.Image; 39 40 public final class CursorManagerImpl extends CursorManager<Cursor> { 41 42 private final Map<String, Cursor> map = new HashMap<String, Cursor>(); 43 private ResourceBundle bundle; 44 45 @Override protected Cursor getCustomCursor(WCImage image, int hotspotX, int hotspotY) { 46 return new ImageCursor( 47 Image.impl_fromPlatformImage( 48 WCGraphicsManager.getGraphicsManager().toPlatformImage(image)), 49 hotspotX, hotspotY); 50 } 51 52 @Override protected Cursor getPredefinedCursor(int type) { 53 switch (type) { 54 default: 55 case POINTER: return Cursor.DEFAULT; 56 case CROSS: return Cursor.CROSSHAIR; 57 case HAND: return Cursor.HAND; 58 case MOVE: return Cursor.MOVE; 59 case TEXT: return Cursor.TEXT; 60 case WAIT: return Cursor.WAIT; 61 case HELP: return getCustomCursor("help", Cursor.DEFAULT); 62 case EAST_RESIZE: return Cursor.E_RESIZE; 63 case NORTH_RESIZE: return Cursor.N_RESIZE; 64 case NORTH_EAST_RESIZE: return Cursor.NE_RESIZE; 65 case NORTH_WEST_RESIZE: return Cursor.NW_RESIZE; 66 case SOUTH_RESIZE: return Cursor.S_RESIZE; 67 case SOUTH_EAST_RESIZE: return Cursor.SE_RESIZE; | 1 /* 2 * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package com.sun.javafx.webkit; 27 28 import com.sun.javafx.tk.Toolkit; 29 import com.sun.webkit.CursorManager; 30 import com.sun.webkit.graphics.WCGraphicsManager; 31 import com.sun.webkit.graphics.WCImage; 32 import java.util.HashMap; 33 import java.util.Locale; 34 import java.util.Map; 35 import java.util.MissingResourceException; 36 import java.util.ResourceBundle; 37 import javafx.scene.Cursor; 38 import javafx.scene.ImageCursor; 39 import javafx.scene.image.Image; 40 41 public final class CursorManagerImpl extends CursorManager<Cursor> { 42 43 private final Map<String, Cursor> map = new HashMap<String, Cursor>(); 44 private ResourceBundle bundle; 45 46 @Override protected Cursor getCustomCursor(WCImage image, int hotspotX, int hotspotY) { 47 return new ImageCursor( 48 Toolkit.getImageAccessor().fromPlatformImage( 49 WCGraphicsManager.getGraphicsManager().toPlatformImage(image)), 50 hotspotX, hotspotY); 51 } 52 53 @Override protected Cursor getPredefinedCursor(int type) { 54 switch (type) { 55 default: 56 case POINTER: return Cursor.DEFAULT; 57 case CROSS: return Cursor.CROSSHAIR; 58 case HAND: return Cursor.HAND; 59 case MOVE: return Cursor.MOVE; 60 case TEXT: return Cursor.TEXT; 61 case WAIT: return Cursor.WAIT; 62 case HELP: return getCustomCursor("help", Cursor.DEFAULT); 63 case EAST_RESIZE: return Cursor.E_RESIZE; 64 case NORTH_RESIZE: return Cursor.N_RESIZE; 65 case NORTH_EAST_RESIZE: return Cursor.NE_RESIZE; 66 case NORTH_WEST_RESIZE: return Cursor.NW_RESIZE; 67 case SOUTH_RESIZE: return Cursor.S_RESIZE; 68 case SOUTH_EAST_RESIZE: return Cursor.SE_RESIZE; |