1
package latexDraw.util;
3
import java.awt.Cursor;
4
import java.awt.Graphics2D;
6
import java.awt.Toolkit;
7
import java.awt.image.BufferedImage;
10
import javax.swing.ImageIcon;
14
* This class contains defined several cursors using in LaTeXDraw.<br>
16
* This file is part of LaTeXDraw<br>
17
* Copyright (c) 2005-2008 Arnaud BLOUIN<br>
19
* LaTeXDraw is free software; you can redistribute it and/or modify
20
* it under the terms of the GNU General Public License as published by
21
* the Free Software Foundation; either version 2 of the License, or
22
* any later version.<br>
24
* LaTeXDraw is distributed without any warranty; without even the
25
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
26
* PURPOSE. See the GNU General Public License for more details.<br>
29
* @author Arnaud BLOUIN<br>
33
public abstract class LaTeXDrawCursor
35
public static final Cursor ROTATE_CURSOR = getCursor("/res/cursors/RotCWDown.gif", "rotate");//$NON-NLS-1$//$NON-NLS-2$
40
* Create a cursor define by the picture corresponding to the path.
41
* @param path The path of the picture of the cursor.
42
* @param name The name which will be given to the cursor.
43
* @return The created cursor.
46
public static Cursor getCursor(String path, String name)
48
BufferedImage bi = new BufferedImage(32, 32, BufferedImage.TYPE_INT_ARGB);
49
Graphics2D graphic = (Graphics2D)bi.getGraphics();
50
URL url = LaTeXDrawCursor.class.getClass().getResource(path);
51
ImageIcon img = new ImageIcon(url);
53
graphic.drawImage(img.getImage(), null, null);
55
return Toolkit.getDefaultToolkit().createCustomCursor(bi,new Point(0,0), name);