~ubuntu-branches/debian/squeeze/latexdraw/squeeze

« back to all changes in this revision

Viewing changes to latexDraw/util/LaTeXDrawCursor.java

  • Committer: Bazaar Package Importer
  • Author(s): Stuart Prescott
  • Date: 2009-05-03 23:49:35 UTC
  • Revision ID: james.westby@ubuntu.com-20090503234935-cls7n48x018g0vk2
Tags: upstream-2.0.2+1
ImportĀ upstreamĀ versionĀ 2.0.2+1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package latexDraw.util;
 
2
 
 
3
import java.awt.Cursor;
 
4
import java.awt.Graphics2D;
 
5
import java.awt.Point;
 
6
import java.awt.Toolkit;
 
7
import java.awt.image.BufferedImage;
 
8
import java.net.URL;
 
9
 
 
10
import javax.swing.ImageIcon;
 
11
 
 
12
 
 
13
/** 
 
14
 * This class contains defined several cursors using in LaTeXDraw.<br>
 
15
 *<br>
 
16
 * This file is part of LaTeXDraw<br>
 
17
 * Copyright (c) 2005-2008 Arnaud BLOUIN<br>
 
18
 *<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>
 
23
 *<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>
 
27
 *<br>
 
28
 * 11/20/06<br>
 
29
 * @author Arnaud BLOUIN<br>
 
30
 * @version 2.0.0<br>
 
31
 * @since 1.9<br>
 
32
 */
 
33
public abstract class LaTeXDrawCursor
 
34
{
 
35
        public static final Cursor ROTATE_CURSOR = getCursor("/res/cursors/RotCWDown.gif", "rotate");//$NON-NLS-1$//$NON-NLS-2$
 
36
 
 
37
        
 
38
        
 
39
        /**
 
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.
 
44
         * @since 1.9
 
45
         */
 
46
        public static Cursor getCursor(String path, String name)
 
47
        {
 
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);
 
52
                
 
53
        graphic.drawImage(img.getImage(), null, null);
 
54
                
 
55
                return Toolkit.getDefaultToolkit().createCustomCursor(bi,new Point(0,0), name);
 
56
        }
 
57
 
 
58
}