author | serb |
Tue, 12 Nov 2013 20:24:25 +0400 | |
changeset 21596 | 0e3a39f29dbc |
parent 5506 | 202f599c92aa |
child 23010 | 6dadb192ad81 |
permissions | -rw-r--r-- |
4831
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
1 |
/* |
5506 | 2 |
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. |
4831
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
4 |
* |
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
21596 | 7 |
* published by the Free Software Foundation. |
4831
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
8 |
* |
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
13 |
* accompanied this code). |
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
14 |
* |
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
18 |
* |
5506 | 19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
4831
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
22 |
*/ |
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
23 |
|
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
24 |
/* |
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
25 |
* Image generator for cursor and drag |
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
26 |
*/ |
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
27 |
import java.awt.Color; |
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
28 |
import java.awt.Graphics; |
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
29 |
import java.awt.Image; |
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
30 |
import java.awt.image.BufferedImage; |
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
31 |
|
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
32 |
public abstract class ImageGenerator |
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
33 |
{ |
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
34 |
public int width; |
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
35 |
public int height; |
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
36 |
private final BufferedImage bi; |
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
37 |
public ImageGenerator(int _width, int _height, Color bgColor) |
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
38 |
{ |
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
39 |
width = _width; |
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
40 |
height = _height; |
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
41 |
bi = new BufferedImage( |
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
42 |
width, |
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
43 |
height, |
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
44 |
BufferedImage.TYPE_INT_ARGB); |
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
45 |
Graphics gr = bi.getGraphics(); |
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
46 |
if(null==bgColor){ |
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
47 |
bgColor = Color.WHITE; |
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
48 |
} |
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
49 |
gr.setColor(bgColor); |
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
50 |
gr.fillRect(0, 0, width, height); |
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
51 |
paint(gr); |
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
52 |
gr.dispose(); |
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
53 |
} |
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
54 |
public Image getImage() { return bi; } |
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
55 |
|
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
56 |
public abstract void paint(Graphics gr); |
85d01a4fe115
4874070: invoking DragSource's startDrag with an Image renders no image on drag
uta
parents:
diff
changeset
|
57 |
} |